From 153c4e856e3c818837efc0c17348c18ccf64821c Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Tue, 9 May 2023 13:33:37 +0100 Subject: Migrate cps-ri performance tests to integration-test module - Migrate update and delete data service tests, using openroadm model - Move module service tests to integration-test module - Update performance test timings - Remove all performance-related files from cps-ri - Remove performance profile from cps-ri pom.xml Issue-ID: CPS-1687 Signed-off-by: danielhanrahan Change-Id: Id9d864f8cab0377cb37c7967943d738748e1b6c5 --- cps-ri/pom.xml | 8 - .../cps/spi/impl/CpsPersistencePerfSpecBase.groovy | 105 --------- .../CpsDataPersistenceServiceDeletePerfTest.groovy | 239 --------------------- .../CpsDataPersistenceServicePerfTest.groovy | 100 --------- .../CpsModuleReferenceRepositoryPerfTest.groovy | 99 --------- cps-ri/src/test/resources/data/perf-test.sql | 28 --- 6 files changed, 579 deletions(-) delete mode 100644 cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistencePerfSpecBase.groovy delete mode 100644 cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy delete mode 100644 cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServicePerfTest.groovy delete mode 100644 cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsModuleReferenceRepositoryPerfTest.groovy delete mode 100644 cps-ri/src/test/resources/data/perf-test.sql (limited to 'cps-ri') diff --git a/cps-ri/pom.xml b/cps-ri/pom.xml index ea1efcb3e..3162aa89a 100644 --- a/cps-ri/pom.xml +++ b/cps-ri/pom.xml @@ -147,18 +147,10 @@ org.apache.maven.plugins maven-surefire-plugin - - - %regex[.*PerfTest.*] - - - - include-performance - diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistencePerfSpecBase.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistencePerfSpecBase.groovy deleted file mode 100644 index daa774698..000000000 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistencePerfSpecBase.groovy +++ /dev/null @@ -1,105 +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.spi.impl - -import org.onap.cps.spi.model.DataNode -import org.onap.cps.spi.model.DataNodeBuilder -import org.springframework.util.StopWatch - -class CpsPersistencePerfSpecBase extends CpsPersistenceSpecBase { - - static final String PERF_TEST_DATA = '/data/perf-test.sql' - static final String PERF_DATASPACE = 'PERF-DATASPACE' - static final String PERF_ANCHOR = 'PERF-ANCHOR' - static final String PERF_TEST_PARENT = '/perf-parent-1' - - static def xpathsToAllGrandChildren = [] - - static def PERFORMANCE_RECORD = [] - - def stopWatch = new StopWatch() - - def cleanupSpec() { - println('#############################################################################') - println('## P E R F O R M A N C E T E S T R E S U L T S ##') - println('#############################################################################') - PERFORMANCE_RECORD.sort().each { println(it) } - PERFORMANCE_RECORD.clear() - } - - def createLineage(cpsDataPersistenceService, numberOfChildren, numberOfGrandChildren, createLists) { - xpathsToAllGrandChildren = [] - (1..numberOfChildren).each { - if (createLists) { - def xpathFormat = "${PERF_TEST_PARENT}/perf-test-list-${it}[@key='%d']" - def listElements = goForthAndMultiply(xpathFormat, numberOfGrandChildren) - cpsDataPersistenceService.addListElements(PERF_DATASPACE, PERF_ANCHOR, PERF_TEST_PARENT, listElements) - } else { - def xpathFormat = "${PERF_TEST_PARENT}/perf-test-child-${it}/perf-test-grand-child-%d" - def grandChildren = goForthAndMultiply(xpathFormat, numberOfGrandChildren) - def child = new DataNodeBuilder() - .withXpath("${PERF_TEST_PARENT}/perf-test-child-${it}") - .withChildDataNodes(grandChildren) - .build() - cpsDataPersistenceService.addChildDataNode(PERF_DATASPACE, PERF_ANCHOR, PERF_TEST_PARENT, child) - } - } - } - - def goForthAndMultiply(xpathFormat, numberOfGrandChildren) { - def grandChildren = [] - (1..numberOfGrandChildren).each { - def xpath = String.format(xpathFormat as String, it) - def grandChild = new DataNodeBuilder().withXpath(xpath).build() - xpathsToAllGrandChildren.add(grandChild.xpath) - grandChildren.add(grandChild) - } - return grandChildren - } - - def countDataNodes(Collection dataNodes) { - int nodeCount = 0 - for (DataNode parent : dataNodes) { - nodeCount = nodeCount + countDataNodes(parent) - } - return nodeCount - } - - def countDataNodes(DataNode dataNode) { - int nodeCount = 1 - for (DataNode child : dataNode.childDataNodes) { - nodeCount = nodeCount + countDataNodes(child) - } - return nodeCount - } - - 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/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy deleted file mode 100644 index 428088135..000000000 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy +++ /dev/null @@ -1,239 +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.spi.performance - -import org.onap.cps.spi.CpsDataPersistenceService -import org.onap.cps.spi.impl.CpsPersistencePerfSpecBase -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.test.context.jdbc.Sql - -class CpsDataPersistenceServiceDeletePerfTest extends CpsPersistencePerfSpecBase { - - @Autowired - CpsDataPersistenceService objectUnderTest - - @Sql([CLEAR_DATA, PERF_TEST_DATA]) - def 'Create a node with many descendants (please note, subsequent tests depend on this running first).'() { - when: 'a node with a large number of descendants is created' - stopWatch.start() - createLineage(objectUnderTest, 150, 50, false) - stopWatch.stop() - def setupDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'setup duration is under 10 seconds' - recordAndAssertPerformance('Setup', 10_000, setupDurationInMillis) - } - - def 'Delete 10 children with grandchildren'() { - when: 'child nodes are deleted' - stopWatch.start() - (1..10).each { - def childPath = "${PERF_TEST_PARENT}/perf-test-child-${it}".toString() - objectUnderTest.deleteDataNode(PERF_DATASPACE, PERF_ANCHOR, childPath) - } - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 300 milliseconds' - recordAndAssertPerformance('Delete 10 children', 300, deleteDurationInMillis) - } - - def 'Batch delete 100 children with grandchildren'() { - given: 'a list of xpaths to delete' - def xpathsToDelete = (11..110).collect { - "${PERF_TEST_PARENT}/perf-test-child-${it}".toString() - } - when: 'child nodes are deleted' - stopWatch.start() - objectUnderTest.deleteDataNodes(PERF_DATASPACE, PERF_ANCHOR, xpathsToDelete) - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 300 milliseconds' - recordAndAssertPerformance('Batch delete 100 children', 300, deleteDurationInMillis) - } - - def 'Delete 50 grandchildren (that have no descendants)'() { - when: 'target nodes are deleted' - stopWatch.start() - (1..50).each { - def grandchildPath = "${PERF_TEST_PARENT}/perf-test-child-111/perf-test-grand-child-${it}".toString() - objectUnderTest.deleteDataNode(PERF_DATASPACE, PERF_ANCHOR, grandchildPath) - } - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 700 milliseconds' - recordAndAssertPerformance('Delete 50 grandchildren', 700, deleteDurationInMillis) - } - - def 'Batch delete 500 grandchildren (that have no descendants)'() { - given: 'a list of xpaths to delete' - def xpathsToDelete = [] - for (int childIndex = 0; childIndex < 10; childIndex++) { - xpathsToDelete.addAll((1..50).collect { - "${PERF_TEST_PARENT}/perf-test-child-${112+childIndex}/perf-test-grand-child-${it}".toString() - }) - } - when: 'target nodes are deleted' - stopWatch.start() - objectUnderTest.deleteDataNodes(PERF_DATASPACE, PERF_ANCHOR, xpathsToDelete) - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 100 milliseconds' - recordAndAssertPerformance('Batch delete 500 grandchildren', 100, deleteDurationInMillis) - } - - @Sql([CLEAR_DATA, PERF_TEST_DATA]) - def 'Create a node with many list elements (please note, subsequent tests depend on this running first).'() { - when: 'a node with a large number of lists is created' - stopWatch.start() - createLineage(objectUnderTest, 150, 50, true) - stopWatch.stop() - def setupDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'setup duration is under 6 seconds' - recordAndAssertPerformance('Setup lists', 6_000, setupDurationInMillis) - } - - def 'Delete 10 whole lists'() { - when: 'lists are deleted' - stopWatch.start() - (1..10).each { - def childPath = "${PERF_TEST_PARENT}/perf-test-list-${it}".toString() - objectUnderTest.deleteListDataNode(PERF_DATASPACE, PERF_ANCHOR, childPath) - } - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 300 milliseconds' - recordAndAssertPerformance('Delete 10 whole lists', 300, deleteDurationInMillis) - } - - def 'Batch delete 100 whole lists'() { - given: 'a list of xpaths to delete' - def xpathsToDelete = (11..110).collect { - "${PERF_TEST_PARENT}/perf-test-list-${it}".toString() - } - when: 'lists are deleted' - stopWatch.start() - objectUnderTest.deleteDataNodes(PERF_DATASPACE, PERF_ANCHOR, xpathsToDelete) - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 600 milliseconds' - recordAndAssertPerformance('Batch delete 100 whole lists', 600, deleteDurationInMillis) - } - - def 'Delete 10 list elements'() { - when: 'list elements are deleted' - stopWatch.start() - (1..10).each { - def grandchildPath = "${PERF_TEST_PARENT}/perf-test-list-111[@key='${it}']".toString() - objectUnderTest.deleteListDataNode(PERF_DATASPACE, PERF_ANCHOR, grandchildPath) - } - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 200 milliseconds' - recordAndAssertPerformance('Delete 10 lists elements', 200, deleteDurationInMillis) - } - - def 'Batch delete 500 list elements'() { - given: 'a list of xpaths to delete' - def xpathsToDelete = [] - for (int childIndex = 0; childIndex < 10; childIndex++) { - xpathsToDelete.addAll((1..50).collect { - "${PERF_TEST_PARENT}/perf-test-list-${112+childIndex}[@key='${it}']".toString() - }) - } - when: 'list elements are deleted' - stopWatch.start() - objectUnderTest.deleteDataNodes(PERF_DATASPACE, PERF_ANCHOR, xpathsToDelete) - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 100 milliseconds' - recordAndAssertPerformance('Batch delete 500 lists elements', 100, deleteDurationInMillis) - } - - @Sql([CLEAR_DATA, PERF_TEST_DATA]) - def 'Delete 1 large data node'() { - given: 'a node with a large number of descendants is created' - createLineage(objectUnderTest, 50, 50, false) - createLineage(objectUnderTest, 50, 50, true) - when: 'parent node is deleted' - stopWatch.start() - objectUnderTest.deleteDataNode(PERF_DATASPACE, PERF_ANCHOR, PERF_TEST_PARENT) - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 300 milliseconds' - recordAndAssertPerformance('Delete one large node', 300, deleteDurationInMillis) - } - - @Sql([CLEAR_DATA, PERF_TEST_DATA]) - def 'Batch delete 1 large data node'() { - given: 'a node with a large number of descendants is created' - createLineage(objectUnderTest, 50, 50, false) - createLineage(objectUnderTest, 50, 50, true) - when: 'parent node is batch deleted' - stopWatch.start() - objectUnderTest.deleteDataNodes(PERF_DATASPACE, PERF_ANCHOR, [PERF_TEST_PARENT]) - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 300 milliseconds' - recordAndAssertPerformance('Batch delete one large node', 300, deleteDurationInMillis) - } - - @Sql([CLEAR_DATA, PERF_TEST_DATA]) - def 'Delete root node with many descendants'() { - given: 'a node with a large number of descendants is created' - createLineage(objectUnderTest, 50, 50, false) - createLineage(objectUnderTest, 50, 50, true) - when: 'root node is deleted' - stopWatch.start() - objectUnderTest.deleteDataNode(PERF_DATASPACE, PERF_ANCHOR, '/') - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 300 milliseconds' - recordAndAssertPerformance('Delete root node', 300, deleteDurationInMillis) - } - - @Sql([CLEAR_DATA, PERF_TEST_DATA]) - def 'Delete data nodes for an anchor'() { - given: 'a node with a large number of descendants is created' - createLineage(objectUnderTest, 50, 50, false) - createLineage(objectUnderTest, 50, 50, true) - when: 'data nodes are deleted' - stopWatch.start() - objectUnderTest.deleteDataNodes(PERF_DATASPACE, PERF_ANCHOR) - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 300 milliseconds' - recordAndAssertPerformance('Delete data nodes for anchor', 300, deleteDurationInMillis) - } - - @Sql([CLEAR_DATA, PERF_TEST_DATA]) - def 'Delete data nodes for multiple anchors'() { - given: 'a node with a large number of descendants is created' - createLineage(objectUnderTest, 50, 50, false) - createLineage(objectUnderTest, 50, 50, true) - when: 'data nodes are deleted' - stopWatch.start() - objectUnderTest.deleteDataNodes(PERF_DATASPACE, [PERF_ANCHOR]) - stopWatch.stop() - def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 300 milliseconds' - recordAndAssertPerformance('Delete data nodes for anchors', 300, deleteDurationInMillis) - } - -} diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServicePerfTest.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServicePerfTest.groovy deleted file mode 100644 index 2628e9697..000000000 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServicePerfTest.groovy +++ /dev/null @@ -1,100 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2022-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.spi.performance - -import org.onap.cps.spi.impl.CpsPersistencePerfSpecBase -import org.onap.cps.spi.CpsDataPersistenceService -import org.onap.cps.spi.repository.AnchorRepository -import org.onap.cps.spi.repository.DataspaceRepository -import org.onap.cps.spi.repository.FragmentRepository -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.test.context.jdbc.Sql - -import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS -import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS - -class CpsDataPersistenceServicePerfTest extends CpsPersistencePerfSpecBase { - - @Autowired - CpsDataPersistenceService objectUnderTest - - @Autowired - DataspaceRepository dataspaceRepository - - @Autowired - AnchorRepository anchorRepository - - @Autowired - FragmentRepository fragmentRepository - - static def NUMBER_OF_CHILDREN = 200 - static def NUMBER_OF_GRAND_CHILDREN = 50 - - @Sql([CLEAR_DATA, PERF_TEST_DATA]) - def 'Create a node with many descendants (please note, subsequent tests depend on this running first).'() { - given: 'a node with a large number of descendants is created' - stopWatch.start() - createLineage(objectUnderTest, NUMBER_OF_CHILDREN, NUMBER_OF_GRAND_CHILDREN, false) - stopWatch.stop() - def setupDurationInMillis = stopWatch.getTotalTimeMillis() - and: 'setup duration is under 10 seconds' - recordAndAssertPerformance('Setup', 10000, setupDurationInMillis) - } - - def 'Update data nodes with descendants'() { - given: 'a list of xpaths to data nodes with descendants (xpath for each child)' - def xpaths = (1..20).collect { - "${PERF_TEST_PARENT}/perf-test-child-${it}".toString() - } - and: 'the correct number of data nodes are fetched' - def dataNodes = objectUnderTest.getDataNodesForMultipleXpaths(PERF_DATASPACE, PERF_ANCHOR, xpaths, INCLUDE_ALL_DESCENDANTS) - assert dataNodes.size() == 20 - assert countDataNodes(dataNodes) == 20 + 20 * 50 - when: 'the fragment entities are updated by the data nodes' - stopWatch.start() - objectUnderTest.updateDataNodesAndDescendants(PERF_DATASPACE, PERF_ANCHOR, dataNodes) - stopWatch.stop() - def updateDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'update duration is under 600 milliseconds' - recordAndAssertPerformance('Update data nodes with descendants', 600, updateDurationInMillis) - } - - def 'Update data nodes without descendants'() { - given: 'a list of xpaths to data nodes without descendants (xpath for each grandchild)' - def xpaths = [] - for (int childIndex = 21; childIndex <= 40; childIndex++) { - xpaths.addAll((1..50).collect { - "${PERF_TEST_PARENT}/perf-test-child-${childIndex}/perf-test-grand-child-${it}".toString() - }) - } - and: 'the correct number of data nodes are fetched' - def dataNodes = objectUnderTest.getDataNodesForMultipleXpaths(PERF_DATASPACE, PERF_ANCHOR, xpaths, OMIT_DESCENDANTS) - assert dataNodes.size() == 20 * 50 - assert countDataNodes(dataNodes) == 20 * 50 - when: 'the fragment entities are updated by the data nodes' - stopWatch.start() - objectUnderTest.updateDataNodesAndDescendants(PERF_DATASPACE, PERF_ANCHOR, dataNodes) - stopWatch.stop() - def updateDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'update duration is under 900 milliseconds' - recordAndAssertPerformance('Update data nodes without descendants', 900, updateDurationInMillis) - } -} diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsModuleReferenceRepositoryPerfTest.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsModuleReferenceRepositoryPerfTest.groovy deleted file mode 100644 index 222a828b9..000000000 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsModuleReferenceRepositoryPerfTest.groovy +++ /dev/null @@ -1,99 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2022-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.spi.performance - -import org.onap.cps.spi.CpsModulePersistenceService -import org.onap.cps.spi.entities.SchemaSetEntity -import org.onap.cps.spi.impl.CpsPersistenceSpecBase -import org.onap.cps.spi.model.ModuleReference -import org.onap.cps.spi.repository.ModuleReferenceRepository -import org.onap.cps.spi.repository.SchemaSetRepository -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.test.context.jdbc.Sql -import org.springframework.util.StopWatch - -import java.util.concurrent.ThreadLocalRandom - -class CpsModuleReferenceRepositoryPerfTest extends CpsPersistenceSpecBase { - - static final String PERF_TEST_DATA = '/data/perf-test.sql' - - def NEW_RESOURCE_CONTENT = 'module stores {\n' + - ' yang-version 1.1;\n' + - ' namespace "org:onap:ccsdk:sample";\n' + - '\n' + - ' prefix book-store;\n' + - '\n' + - ' revision "2020-09-15" {\n' + - ' description\n' + - ' "Sample Model";\n' + - ' }' + - '}' - - @Autowired - CpsModulePersistenceService objectUnderTest - - @Autowired - SchemaSetRepository schemaSetRepository - - @Autowired - ModuleReferenceRepository moduleReferenceRepository - - @Sql([CLEAR_DATA, PERF_TEST_DATA]) - def 'Store new schema set with many modules'() { - when: 'a new schema set with 200 modules is stored' - def newYangResourcesNameToContentMap = [:] - (1..200).each { - def year = 2000 + it - def resourceName = "module${it}".toString() - def moduleName = "stores${it}" - def content = NEW_RESOURCE_CONTENT.replace('2020',String.valueOf(year)).replace('stores',moduleName) - newYangResourcesNameToContentMap.put(resourceName, content) - } - objectUnderTest.storeSchemaSet('PERF-DATASPACE', 'perfSchemaSet', newYangResourcesNameToContentMap) - then: 'the schema set is persisted correctly' - def dataspaceEntity = dataspaceRepository.getByName('PERF-DATASPACE') - SchemaSetEntity result = schemaSetRepository.getByDataspaceAndName(dataspaceEntity, 'perfSchemaSet') - result.yangResources.size() == 200 - and: 'identification of new module resources is fast enough (1,000 executions less then 6,000 milliseconds)' - def stopWatch = new StopWatch() - 1000.times() { - def moduleReferencesToCheck = createModuleReferencesWithRandomMatchingExistingModuleReferences() - stopWatch.start() - def newModuleReferences = moduleReferenceRepository.identifyNewModuleReferences(moduleReferencesToCheck) - stopWatch.stop() - assert newModuleReferences.size() > 0 && newModuleReferences.size() < 300 - } - assert stopWatch.getTotalTimeMillis() < 6000 - } - - def createModuleReferencesWithRandomMatchingExistingModuleReferences() { - def moduleReferences = [] - (1..250).each { - def randomNumber = ThreadLocalRandom.current().nextInt(1, 300) - def year = 2000 + randomNumber - def moduleName = "stores${randomNumber}" - moduleReferences.add(new ModuleReference(moduleName, "${year}-09-15")) - } - return moduleReferences - } - -} diff --git a/cps-ri/src/test/resources/data/perf-test.sql b/cps-ri/src/test/resources/data/perf-test.sql deleted file mode 100644 index 5119f26b2..000000000 --- a/cps-ri/src/test/resources/data/perf-test.sql +++ /dev/null @@ -1,28 +0,0 @@ -/* - ============LICENSE_START======================================================= - Copyright (C) 2022 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========================================================= -*/ - -INSERT INTO DATASPACE (ID, NAME) VALUES (9001, 'PERF-DATASPACE'); - -INSERT INTO SCHEMA_SET (ID, NAME, DATASPACE_ID) VALUES (9002, 'PERF-SCHEMA-SET', 9001); - -INSERT INTO ANCHOR (ID, NAME, DATASPACE_ID, SCHEMA_SET_ID) VALUES (9003, 'PERF-ANCHOR', 9001, 9002); - -INSERT INTO FRAGMENT (ID, DATASPACE_ID, ANCHOR_ID, PARENT_ID, XPATH) VALUES (0, 9001, 9003, null, '/perf-parent-1'); - -- cgit 1.2.3-korg