From 0133eb03c09c6142b4a98047d00b0145a934dd45 Mon Sep 17 00:00:00 2001 From: ToineSiebelink Date: Tue, 28 Feb 2023 18:12:51 +0000 Subject: Create Base and Sample Performance Integration Tests - added data (folders) for different models and json data - added base and data for cps-ncmp (registry) specific test cases - integrated Ahila's (large) openroadm model and data (corrected version provided by Lee Anjella) - created profiles to exclude/include *PerfTest - fixed dependency test check - included integration test for overall coverage - increased margings in existing perf test to reduce nordix intermitten failures Issue-ID: CPS-1516 Signed-off-by: ToineSiebelink Change-Id: Ia82826f610636c14aa7e8939b385c278e5039817 --- .../cps/integration/base/BookstoreSpecBase.groovy | 49 ------------ .../integration/base/CpsIntegrationSpecBase.groovy | 23 +++++- .../cps/integration/base/FunctionalSpecBase.groovy | 49 ++++++++++++ .../CpsAdminServiceIntegrationSpec.groovy | 2 +- .../CpsDataServiceIntegrationSpec.groovy | 7 +- .../performance/base/CpsPerfTestBase.groovy | 86 ++++++++++++++++++++++ .../base/NcmpRegistryPerfTestBase.groovy | 54 ++++++++++++++ .../performance/base/PerfTestBase.groovy | 70 ++++++++++++++++++ .../integration/performance/cps/GetPerfTest.groovy | 51 +++++++++++++ .../performance/ncmp/CmHandleQueryPerfTest.groovy | 65 ++++++++++++++++ 10 files changed, 398 insertions(+), 58 deletions(-) delete mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/base/BookstoreSpecBase.groovy create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/base/FunctionalSpecBase.groovy create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/performance/base/CpsPerfTestBase.groovy create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpRegistryPerfTestBase.groovy create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/performance/base/PerfTestBase.groovy create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/GetPerfTest.groovy create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleQueryPerfTest.groovy (limited to 'integration-test/src/test/groovy/org') diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/base/BookstoreSpecBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/base/BookstoreSpecBase.groovy deleted file mode 100644 index 7eb47b35ae..0000000000 --- a/integration-test/src/test/groovy/org/onap/cps/integration/base/BookstoreSpecBase.groovy +++ /dev/null @@ -1,49 +0,0 @@ -/* - * ============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.base - -import java.time.OffsetDateTime - -class BookstoreSpecBase extends CpsIntegrationSpecBase { - - def static initialized = false - - def setup() { - if (!initialized) { - setupBookstoreInfraStructure() - addBookstoreData() - initialized = true - } - } - - def setupBookstoreInfraStructure() { - cpsAdminService.createDataspace(BOOKSTORE_DATASPACE) - def bookstoreYangModelAsString = readResourceFile('bookstore.yang') - cpsModuleService.createSchemaSet(BOOKSTORE_DATASPACE, BOOKSTORE_SCHEMA_SET, [bookstore : bookstoreYangModelAsString]) - cpsAdminService.createAnchor(BOOKSTORE_DATASPACE, BOOKSTORE_SCHEMA_SET, BOOKSTORE_ANCHOR) - } - - def addBookstoreData() { - def bookstoreJsonData = readResourceFile('BookstoreDataNodes.json') - cpsDataService.saveData(BOOKSTORE_DATASPACE, BOOKSTORE_ANCHOR, bookstoreJsonData, OffsetDateTime.now()) - } - -} diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy index 567b33cb46..866fef4f24 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy @@ -20,10 +20,12 @@ package org.onap.cps.integration.base +import org.onap.cps.api.CpsQueryService import org.onap.cps.api.impl.CpsAdminServiceImpl import org.onap.cps.api.impl.CpsDataServiceImpl import org.onap.cps.api.impl.CpsModuleServiceImpl import org.onap.cps.integration.DatabaseTestContainer +import org.onap.cps.spi.exceptions.DataspaceNotFoundException import org.onap.cps.spi.model.DataNode import org.onap.cps.spi.repository.DataspaceRepository import org.onap.cps.spi.impl.utils.CpsValidatorImpl @@ -61,8 +63,12 @@ class CpsIntegrationSpecBase extends Specification { @Lazy CpsModuleServiceImpl cpsModuleService - def static GENERAL_TEST_DATASPACE = 'generalTestDataSpace' - def static BOOKSTORE_DATASPACE = 'bookstoreDataspace' + @Autowired + @Lazy + CpsQueryService cpsQueryService + + def static GENERAL_TEST_DATASPACE = 'generalTestDataspace' + def static FUNCTIONAL_TEST_DATASPACE = 'functionalTestDataspace' def static BOOKSTORE_SCHEMA_SET = 'bookstoreSchemaSet' def static BOOKSTORE_ANCHOR = 'bookstoreAnchor' @@ -71,7 +77,7 @@ class CpsIntegrationSpecBase extends Specification { def setup() { if (!initialized) { cpsAdminService.createDataspace(GENERAL_TEST_DATASPACE) - def bookstoreModelFileContent = readResourceFile('bookstore.yang') + def bookstoreModelFileContent = readResourceDataFile('bookstore/bookstore.yang') cpsModuleService.createSchemaSet(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, [bookstore : bookstoreModelFileContent]) initialized = true; } @@ -89,7 +95,16 @@ class CpsIntegrationSpecBase extends Specification { return nodeCount } - def static readResourceFile(filename) { + def static readResourceDataFile(filename) { return new File('src/test/resources/data/' + filename).text } + + def dataspaceExists(dataspaceName) { + try { + cpsAdminService.getDataspace(dataspaceName) + } catch (DataspaceNotFoundException e) { + return false + } + return true + } } diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/base/FunctionalSpecBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/base/FunctionalSpecBase.groovy new file mode 100644 index 0000000000..5e5269114e --- /dev/null +++ b/integration-test/src/test/groovy/org/onap/cps/integration/base/FunctionalSpecBase.groovy @@ -0,0 +1,49 @@ +/* + * ============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.base + +import java.time.OffsetDateTime + +class FunctionalSpecBase extends CpsIntegrationSpecBase { + + def static initialized = false + + def setup() { + if (!initialized) { + setupBookstoreInfraStructure() + addBookstoreData() + initialized = true + } + } + + def setupBookstoreInfraStructure() { + cpsAdminService.createDataspace(FUNCTIONAL_TEST_DATASPACE) + def bookstoreYangModelAsString = readResourceDataFile('bookstore/bookstore.yang') + cpsModuleService.createSchemaSet(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, [bookstore: bookstoreYangModelAsString]) + cpsAdminService.createAnchor(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, BOOKSTORE_ANCHOR) + } + + def addBookstoreData() { + def bookstoreJsonData = readResourceDataFile('bookstore/bookstoreData.json') + cpsDataService.saveData(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, bookstoreJsonData, OffsetDateTime.now()) + } + +} diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsAdminServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsAdminServiceIntegrationSpec.groovy index d504a9e0dd..a8ab5cab57 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsAdminServiceIntegrationSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsAdminServiceIntegrationSpec.groovy @@ -88,7 +88,7 @@ class CpsAdminServiceIntegrationSpec extends CpsIntegrationSpecBase { objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'anchor1') objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'anchor2') and: '1 anchor with "other" schema set is created' - def bookstoreModelFileContent = readResourceFile('bookstore.yang') + def bookstoreModelFileContent = readResourceDataFile('bookstore/bookstore.yang') cpsModuleService.createSchemaSet(GENERAL_TEST_DATASPACE, 'otherSchemaSet', [someFileName: bookstoreModelFileContent]) objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, 'otherSchemaSet', 'anchor3') then: 'there are 3 anchors in the general test database' diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy index 5e839f27a8..c333911fcc 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy @@ -21,10 +21,10 @@ package org.onap.cps.integration.functional -import org.onap.cps.integration.base.BookstoreSpecBase +import org.onap.cps.integration.base.FunctionalSpecBase import org.onap.cps.spi.FetchDescendantsOption -class CpsDataServiceIntegrationSpec extends BookstoreSpecBase { +class CpsDataServiceIntegrationSpec extends FunctionalSpecBase { def objectUnderTest @@ -32,7 +32,7 @@ class CpsDataServiceIntegrationSpec extends BookstoreSpecBase { def 'Read bookstore top-level container(s) using #fetchDescendantsOption.'() { when: 'get data nodes for bookstore container' - def result = objectUnderTest.getDataNodes(BOOKSTORE_DATASPACE, BOOKSTORE_ANCHOR, '/bookstore', fetchDescendantsOption) + def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, '/bookstore', fetchDescendantsOption) then: 'the tree consist ouf of #expectNumberOfDataNodes data nodes' assert countDataNodesInTree(result) == expectNumberOfDataNodes and: 'the top level data node has the expected attribute and value' @@ -44,5 +44,4 @@ class CpsDataServiceIntegrationSpec extends BookstoreSpecBase { FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS || 8 new FetchDescendantsOption(2) || 8 } - } 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 0000000000..6fb6d844a9 --- /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 0000000000..adece2ebf5 --- /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 0000000000..25cd704311 --- /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 0000000000..753faf44f1 --- /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 0000000000..939281a73c --- /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() + } + +} -- cgit 1.2.3-korg