summaryrefslogtreecommitdiffstats
path: root/integration-test/src/test/groovy/org/onap/cps/integration/performance
diff options
context:
space:
mode:
Diffstat (limited to 'integration-test/src/test/groovy/org/onap/cps/integration/performance')
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/performance/base/CpsPerfTestBase.groovy86
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpRegistryPerfTestBase.groovy54
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/performance/base/PerfTestBase.groovy70
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/GetPerfTest.groovy51
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleQueryPerfTest.groovy65
5 files changed, 326 insertions, 0 deletions
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/CpsPerfTestBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/CpsPerfTestBase.groovy
new file mode 100644
index 000000000..6fb6d844a
--- /dev/null
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/CpsPerfTestBase.groovy
@@ -0,0 +1,86 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.integration.performance.base
+
+import java.time.OffsetDateTime
+import org.onap.cps.integration.base.CpsIntegrationSpecBase
+import org.onap.cps.rest.utils.MultipartFileUtil
+import org.springframework.web.multipart.MultipartFile
+
+class CpsPerfTestBase extends PerfTestBase {
+
+ static def CPS_PERFORMANCE_TEST_DATASPACE = 'cpsPerformanceDataspace'
+
+ def printTitle() {
+ println('## C P S P E R F O R M A N C E T E S T R E S U L T S ##')
+ }
+
+ def isInitialised() {
+ return dataspaceExists(CPS_PERFORMANCE_TEST_DATASPACE)
+ }
+
+ def setupPerformanceInfraStructure() {
+ cpsAdminService.createDataspace(CPS_PERFORMANCE_TEST_DATASPACE)
+ def modelAsString = CpsIntegrationSpecBase.readResourceDataFile('bookstore/bookstore.yang')
+ cpsModuleService.createSchemaSet(CPS_PERFORMANCE_TEST_DATASPACE, CpsIntegrationSpecBase.BOOKSTORE_SCHEMA_SET, [bookstore: modelAsString])
+ }
+
+ def createInitialData() {
+ createLargeBookstoresData()
+ addOpenRoadModel()
+ addOpenRoadData()
+ }
+
+ def createLargeBookstoresData() {
+ def data = CpsIntegrationSpecBase.readResourceDataFile('bookstore/largeModelData.json')
+ stopWatch.start()
+ addAnchorsWithData(5, CpsIntegrationSpecBase.BOOKSTORE_SCHEMA_SET, 'bookstore', data)
+ stopWatch.stop()
+ def durationInMillis = stopWatch.getTotalTimeMillis()
+ recordAndAssertPerformance('Creating bookstore anchors with large data tree', 3_000, durationInMillis)
+ }
+
+ def addOpenRoadModel() {
+ def file = new File('src/test/resources/data/openroadm/correctedModel.zip')
+ def multipartFile = Mock(MultipartFile)
+ multipartFile.getOriginalFilename() >> file.getName()
+ multipartFile.getInputStream() >> new FileInputStream(file)
+ cpsModuleService.createSchemaSet(CPS_PERFORMANCE_TEST_DATASPACE, PerfTestBase.LARGE_SCHEMA_SET, MultipartFileUtil.extractYangResourcesMap(multipartFile))
+ }
+
+ def addOpenRoadData() {
+ def data = CpsIntegrationSpecBase.readResourceDataFile('openroadm/innerNode.json')
+ stopWatch.start()
+ addAnchorsWithData(5, PerfTestBase.LARGE_SCHEMA_SET, 'openroadm', data)
+ stopWatch.stop()
+ def durationInMillis = stopWatch.getTotalTimeMillis()
+ recordAndAssertPerformance('Creating openroadm anchors with large data tree', 25_000, durationInMillis)
+ }
+
+ def addAnchorsWithData(numberOfAnchors, schemaSetName, anchorNamePrefix, data) {
+ (1..numberOfAnchors).each {
+ cpsAdminService.createAnchor(CPS_PERFORMANCE_TEST_DATASPACE, schemaSetName, anchorNamePrefix + it)
+ cpsDataService.saveData(CPS_PERFORMANCE_TEST_DATASPACE, anchorNamePrefix + it, data, OffsetDateTime.now())
+ }
+
+ }
+
+}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpRegistryPerfTestBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpRegistryPerfTestBase.groovy
new file mode 100644
index 000000000..adece2ebf
--- /dev/null
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpRegistryPerfTestBase.groovy
@@ -0,0 +1,54 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.integration.performance.base
+
+import java.time.OffsetDateTime
+
+import org.onap.cps.integration.base.CpsIntegrationSpecBase
+
+class NcmpRegistryPerfTestBase extends PerfTestBase {
+
+ def static REGISTRY_ANCHOR = 'ncmp-registry'
+ def static REGISTRY_SCHEMA_SET = 'registrySchemaSet'
+ def static NCMP_PERFORMANCE_TEST_DATASPACE = 'ncmpPerformacne'
+
+ def printTitle() {
+ 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 ##')
+ }
+
+ def isInitialised() {
+ return dataspaceExists(NCMP_PERFORMANCE_TEST_DATASPACE)
+ }
+
+ def setupPerformanceInfraStructure() {
+ cpsAdminService.createDataspace(NCMP_PERFORMANCE_TEST_DATASPACE)
+ def modelAsString = CpsIntegrationSpecBase.readResourceDataFile('ncmp-registry/dmi-registry@2022-05-10.yang')
+ cpsModuleService.createSchemaSet(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_SCHEMA_SET, [registry: modelAsString])
+ }
+
+ def createInitialData() {
+ def data = CpsIntegrationSpecBase.readResourceDataFile('ncmp-registry/1000-cmhandles.json')
+ cpsAdminService.createAnchor(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_SCHEMA_SET, REGISTRY_ANCHOR)
+ cpsDataService.saveData(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, data, OffsetDateTime.now())
+ }
+
+
+}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/PerfTestBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/PerfTestBase.groovy
new file mode 100644
index 000000000..25cd70431
--- /dev/null
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/PerfTestBase.groovy
@@ -0,0 +1,70 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.integration.performance.base
+
+import org.onap.cps.integration.base.CpsIntegrationSpecBase
+import org.springframework.util.StopWatch
+
+abstract class PerfTestBase extends CpsIntegrationSpecBase {
+
+ static def LARGE_SCHEMA_SET = 'largeSchemaSet'
+ static def PERFORMANCE_RECORD = []
+
+ def stopWatch = new StopWatch()
+
+ def cleanupSpec() {
+ println('#############################################################################')
+ printTitle()
+ println('#############################################################################')
+ PERFORMANCE_RECORD.sort().each {
+ println(it)
+ }
+ println('#############################################################################')
+ PERFORMANCE_RECORD.clear()
+ }
+
+ def setup() {
+ if (!isInitialised()) {
+ setupPerformanceInfraStructure()
+ createInitialData()
+ }
+ }
+
+ abstract def printTitle()
+
+ abstract def isInitialised()
+
+ abstract def setupPerformanceInfraStructure()
+
+ abstract def createInitialData()
+
+ def recordAndAssertPerformance(String shortTitle, thresholdInMs, recordedTimeInMs) {
+ def pass = recordedTimeInMs <= thresholdInMs
+ if (shortTitle.length() > 40) {
+ shortTitle = shortTitle.substring(0, 40)
+ }
+ def record = String.format('%2d.%-40s limit%,7d took %,7d ms ', PERFORMANCE_RECORD.size() + 1, shortTitle, thresholdInMs, recordedTimeInMs)
+ record += pass ? 'PASS' : 'FAIL'
+ PERFORMANCE_RECORD.add(record)
+ assert recordedTimeInMs != thresholdInMs
+ return true
+ }
+}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/GetPerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/GetPerfTest.groovy
new file mode 100644
index 000000000..753faf44f
--- /dev/null
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/GetPerfTest.groovy
@@ -0,0 +1,51 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.integration.performance.cps
+
+import org.onap.cps.integration.performance.base.CpsPerfTestBase
+import org.onap.cps.spi.FetchDescendantsOption
+
+class GetPerfTest extends CpsPerfTestBase {
+
+ def objectUnderTest
+
+ def setup() { objectUnderTest = cpsDataService }
+
+ def 'Read complete data trees from multiple anchors with #scenario.'() {
+ when: 'get data nodes for 5 anchors'
+ stopWatch.start()
+ (1..5).each {
+ def result = objectUnderTest.getDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, anchorPrefix + it, xpath, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS)
+ assert countDataNodesInTree(result) == expectedNumberOfDataNodes
+ }
+ stopWatch.stop()
+ def durationInMillis = stopWatch.getTotalTimeMillis()
+ then: 'all data is read within #durationLimit ms'
+ recordAndAssertPerformance("Read datatrees using ${scenario}", durationLimit, durationInMillis)
+ where: 'the following xpaths are used'
+ scenario | anchorPrefix | xpath || durationLimit | expectedNumberOfDataNodes
+ 'bookstore root' | 'bookstore' | '/' || 25_000 | 78
+ 'bookstore top element' | 'bookstore' | '/bookstore' || 1_000 | 78
+ 'openroadm root' | 'openroadm' | '/' || 1_000 | 2151
+ 'openroadm top element' | 'openroadm' | '/openroadm-devices' || 10_000 | 2151
+ }
+
+}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleQueryPerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleQueryPerfTest.groovy
new file mode 100644
index 000000000..939281a73
--- /dev/null
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleQueryPerfTest.groovy
@@ -0,0 +1,65 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.integration.performance.ncmp
+
+import java.util.stream.Collectors
+
+import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS
+import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
+
+import org.onap.cps.integration.performance.base.NcmpRegistryPerfTestBase
+
+class CmHandleQueryPerfTest extends NcmpRegistryPerfTestBase {
+
+ def objectUnderTest
+
+ def setup() { objectUnderTest = cpsQueryService }
+
+ def 'Query CM Handle IDs by a property name and value.'() {
+ when: 'a cps-path query on name-value pair is performed (without getting descendants)'
+ stopWatch.start()
+ def cpsPath = '//additional-properties[@name="neType" and @value="RadioNode"]/ancestor::cm-handles'
+ def dataNodes = cpsQueryService.queryDataNodes(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, cpsPath, OMIT_DESCENDANTS)
+ and: 'the ids of the result are extracted and converted to xpath'
+ def xpaths = dataNodes.stream().map(dataNode -> "/dmi-registry/cm-handles[@id='${dataNode.leaves.id}']".toString() ).collect(Collectors.toSet())
+ and: 'a single get is executed to get all the parent objects and their descendants'
+ def result = cpsDataService.getDataNodesForMultipleXpaths(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, xpaths, INCLUDE_ALL_DESCENDANTS)
+ stopWatch.stop()
+ def durationInMillis = stopWatch.getTotalTimeMillis()
+ then: 'the required operations are performed within 3 seconds'
+ recordAndAssertPerformance("CpsPath Registry attributes Query", 3_000, durationInMillis)
+ and: 'all but 1 (other node) are returned'
+ result.size() == 999
+ and: 'the tree contains all the expected descendants too'
+ assert countDataNodesInTree(result) == 5 * 999
+ }
+
+ def 'Multiple get limitation: 32,764 (~ 2^15) xpaths.'() {
+ given: 'more than 32,764 xpaths)'
+ def xpaths = []
+ (0..32_765).each { xpaths.add("/size/of/this/path/does/not/matter/for/limit[@id='" + it + "']") }
+ when: 'get single get is executed to get all the parent objects and their descendants'
+ cpsDataService.getDataNodesForMultipleXpaths(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, xpaths, INCLUDE_ALL_DESCENDANTS)
+ then: 'no exception is thrown (limit is not present in current implementation)'
+ noExceptionThrown()
+ }
+
+}