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
24 import org.onap.cps.integration.ResourceMeter
26 class NcmpPerfTestBase extends PerfTestBase {
28 def static NCMP_PERFORMANCE_TEST_DATASPACE = 'ncmpPerformance'
29 def static REGISTRY_ANCHOR = 'ncmp-registry'
30 def static REGISTRY_SCHEMA_SET = 'registrySchemaSet'
31 def static CM_DATA_SUBSCRIPTIONS_ANCHOR = 'cm-data-subscriptions'
32 def static CM_DATA_SUBSCRIPTIONS_SCHEMA_SET = 'cmDataSubscriptionsSchemaSet'
34 def datastore1cmHandlePlaceHolder = '{"datastores":{"datastore":[{"name":"ds-1","cm-handles":{"cm-handle":[]}}]}}'
35 def xPathForDataStore1CmHandles = '/datastores/datastore[@name="ds-1"]/cm-handles'
36 def numberOfCmDataSubscribers = 200
37 def numberOfFiltersPerCmHandle = 10
38 def numberOfCmHandlesPerCmDataSubscription = 200
40 ResourceMeter resourceMeter = new ResourceMeter()
42 // SHORT versions for easier debugging
43 // def subscriberIdPrefix = 'sub'
44 // def xpathPrefix = 'f'
45 // def cmHandlePrefix = 'ch'
48 // LONG versions for performance testing
49 def subscriberIdPrefix = 'some really long subscriber id to see if this makes any difference to the performance'
50 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'
51 def cmHandlePrefix = 'some really long cm handle id to see if this makes any difference to the performance'
54 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 ##')
58 return dataspaceExists(NCMP_PERFORMANCE_TEST_DATASPACE)
61 def setupPerformanceInfraStructure() {
62 cpsAdminService.createDataspace(NCMP_PERFORMANCE_TEST_DATASPACE)
63 createRegistrySchemaSet()
64 createCmDataSubscriptionsSchemaSet()
65 addCmSubscriptionData()
68 def createInitialData() {
69 cpsAdminService.createAnchor(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_SCHEMA_SET, REGISTRY_ANCHOR)
70 def data = readResourceDataFile('ncmp-registry/1000-cmhandles.json')
71 cpsDataService.saveData(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, data, OffsetDateTime.now())
74 def createRegistrySchemaSet() {
75 def modelAsString = readResourceDataFile('ncmp-registry/dmi-registry@2023-11-27.yang')
76 cpsModuleService.createSchemaSet(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_SCHEMA_SET, [registry: modelAsString])
79 def createCmDataSubscriptionsSchemaSet() {
80 def modelAsString = readResourceDataFile('cm-data-subscriptions/cm-data-subscriptions@2023-09-21.yang')
81 cpsModuleService.createSchemaSet(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_SCHEMA_SET, [registry: modelAsString])
84 def addCmSubscriptionData() {
85 cpsAdminService.createAnchor(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_SCHEMA_SET, CM_DATA_SUBSCRIPTIONS_ANCHOR)
86 cpsDataService.saveData(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_ANCHOR, datastore1cmHandlePlaceHolder, now)
87 def subscribers = createLeafList('subscribers',numberOfCmDataSubscribers, subscriberIdPrefix)
88 def filters = '"filters":' + createJsonArray('filter',numberOfFiltersPerCmHandle,'xpath',xpathPrefix,subscribers)
89 def cmHandles = createJsonArray('cm-handle',numberOfCmHandlesPerCmDataSubscription,'id',cmHandlePrefix, filters)
90 cpsDataService.saveData(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_ANCHOR, xPathForDataStore1CmHandles, cmHandles, now)