2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the 'License');
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an 'AS IS' BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.cps.integration.performance.base
23 import java.time.OffsetDateTime
25 class NcmpPerfTestBase extends PerfTestBase {
27 def static NCMP_PERFORMANCE_TEST_DATASPACE = 'ncmpPerformance'
28 def static REGISTRY_ANCHOR = 'ncmp-registry'
29 def static REGISTRY_SCHEMA_SET = 'registrySchemaSet'
30 def static CM_DATA_SUBSCRIPTIONS_ANCHOR = 'cm-data-subscriptions'
31 def static CM_DATA_SUBSCRIPTIONS_SCHEMA_SET = 'cmDataSubscriptionsSchemaSet'
33 def datastore1cmHandlePlaceHolder = '{"datastores":{"datastore":[{"name":"ds-1","cm-handles":{"cm-handle":[]}}]}}'
34 def xPathForDataStore1CmHandles = '/datastores/datastore[@name="ds-1"]/cm-handles'
35 def numberOfCmDataSubscribers = 200
36 def numberOfFiltersPerCmHandle = 10
37 def numberOfCmHandlesPerCmDataSubscription = 200
39 // SHORT versions for easier debugging
40 // def subscriberIdPrefix = 'sub'
41 // def xpathPrefix = 'f'
42 // def cmHandlePrefix = 'ch'
45 // LONG versions for performance testing
46 def subscriberIdPrefix = 'some really long subscriber id to see if this makes any difference to the performance'
47 def xpathPrefix = 'some really long xpath/with/loads/of/children/grandchildren/and/whatever/else/I/can/think/of to see if this makes any difference to the performance'
48 def cmHandlePrefix = 'some really long cm handle id to see if this makes any difference to the performance'
51 println('## N C M P P E R F O R M A N C E T E S T R E S U L T S ##')
55 return dataspaceExists(NCMP_PERFORMANCE_TEST_DATASPACE)
58 def setupPerformanceInfraStructure() {
59 cpsAdminService.createDataspace(NCMP_PERFORMANCE_TEST_DATASPACE)
60 createRegistrySchemaSet()
61 createCmDataSubscriptionsSchemaSet()
62 addCmSubscriptionData()
65 def createInitialData() {
66 cpsAdminService.createAnchor(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_SCHEMA_SET, REGISTRY_ANCHOR)
67 def data = readResourceDataFile('ncmp-registry/1000-cmhandles.json')
68 cpsDataService.saveData(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, data, OffsetDateTime.now())
71 def createRegistrySchemaSet() {
72 def modelAsString = readResourceDataFile('ncmp-registry/dmi-registry@2022-05-10.yang')
73 cpsModuleService.createSchemaSet(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_SCHEMA_SET, [registry: modelAsString])
76 def createCmDataSubscriptionsSchemaSet() {
77 def modelAsString = readResourceDataFile('cm-data-subscriptions/cm-data-subscriptions@2023-09-21.yang')
78 cpsModuleService.createSchemaSet(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_SCHEMA_SET, [registry: modelAsString])
81 def addCmSubscriptionData() {
82 cpsAdminService.createAnchor(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_SCHEMA_SET, CM_DATA_SUBSCRIPTIONS_ANCHOR)
83 cpsDataService.saveData(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_ANCHOR, datastore1cmHandlePlaceHolder, now)
84 def subscribers = createLeafList('subscribers',numberOfCmDataSubscribers, subscriberIdPrefix)
85 def filters = '"filters":' + createJsonArray('filter',numberOfFiltersPerCmHandle,'xpath',xpathPrefix,subscribers)
86 def cmHandles = createJsonArray('cm-handle',numberOfCmHandlesPerCmDataSubscription,'id',cmHandlePrefix, filters)
87 cpsDataService.saveData(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_ANCHOR, xPathForDataStore1CmHandles, cmHandles, now)