From a966bab93a17fcba4e7fc28354c01b3f0878fbbe Mon Sep 17 00:00:00 2001 From: ToineSiebelink Date: Mon, 18 Dec 2023 12:25:41 +0000 Subject: Remove the dependency-cycle between beans - Splitting admin service into AnchorService and DataspaceService (this resolves the cyclic dependency) - Improved Delete dataspace integration error tests (were depending on execution order, now independent) Issue-ID: CPS-871 Change-Id: I47efedb6eb4bd2900f72d689616b7b7b62df2938 Signed-off-by: halil.cakal Signed-off-by: ToineSiebelink --- .../integration/base/CpsIntegrationSpecBase.groovy | 25 +-- .../cps/integration/base/FunctionalSpecBase.groovy | 10 +- .../CpsAdminServiceIntegrationSpec.groovy | 181 --------------------- .../CpsAnchorServiceIntegrationSpec.groovy | 124 ++++++++++++++ .../CpsDataServiceIntegrationSpec.groovy | 4 +- .../CpsDataspaceServiceIntegrationSpec.groovy | 107 ++++++++++++ .../CpsModuleServiceIntegrationSpec.groovy | 15 +- .../performance/base/CpsPerfTestBase.groovy | 2 +- .../performance/base/NcmpPerfTestBase.groovy | 6 +- .../cps/CpsAdminServiceLimitsPerfTest.groovy | 50 ------ .../cps/CpsDataServiceLimitsPerfTest.groovy | 4 +- .../cps/CpsDataspaceServiceLimitsPerfTest.groovy | 50 ++++++ .../performance/cps/DeletePerfTest.groovy | 2 +- .../performance/cps/WritePerfTest.groovy | 8 +- 14 files changed, 321 insertions(+), 267 deletions(-) delete mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsAdminServiceIntegrationSpec.groovy create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsAnchorServiceIntegrationSpec.groovy create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataspaceServiceIntegrationSpec.groovy delete mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsAdminServiceLimitsPerfTest.groovy create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataspaceServiceLimitsPerfTest.groovy (limited to 'integration-test/src/test/groovy') 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 40fe03018..6dec3dbf9 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,11 @@ package org.onap.cps.integration.base +import org.onap.cps.api.CpsAnchorService +import org.onap.cps.api.CpsDataService +import org.onap.cps.api.CpsDataspaceService +import org.onap.cps.api.CpsModuleService 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.config.CpsSessionFactory import org.onap.cps.spi.exceptions.DataspaceNotFoundException @@ -44,7 +45,7 @@ import spock.lang.Specification import java.time.OffsetDateTime -@SpringBootTest(classes = [TestConfig, CpsAdminServiceImpl, CpsValidatorImpl, SessionManager, CpsSessionFactory]) +@SpringBootTest(classes = [TestConfig, CpsValidatorImpl, SessionManager, CpsSessionFactory]) @Testcontainers @EnableAutoConfiguration @EnableJpaRepositories(basePackageClasses = [DataspaceRepository]) @@ -57,15 +58,19 @@ class CpsIntegrationSpecBase extends Specification { @Autowired @Lazy - CpsAdminServiceImpl cpsAdminService + CpsDataspaceService cpsDataspaceService @Autowired @Lazy - CpsDataServiceImpl cpsDataService + CpsAnchorService cpsAnchorService @Autowired @Lazy - CpsModuleServiceImpl cpsModuleService + CpsDataService cpsDataService + + @Autowired + @Lazy + CpsModuleService cpsModuleService @Autowired @Lazy @@ -83,7 +88,7 @@ class CpsIntegrationSpecBase extends Specification { def setup() { if (!initialized) { - cpsAdminService.createDataspace(GENERAL_TEST_DATASPACE) + cpsDataspaceService.createDataspace(GENERAL_TEST_DATASPACE) def bookstoreModelFileContent = readResourceDataFile('bookstore/bookstore.yang') cpsModuleService.createSchemaSet(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, [bookstore : bookstoreModelFileContent]) initialized = true; @@ -108,7 +113,7 @@ class CpsIntegrationSpecBase extends Specification { def dataspaceExists(dataspaceName) { try { - cpsAdminService.getDataspace(dataspaceName) + cpsDataspaceService.getDataspace(dataspaceName) } catch (DataspaceNotFoundException dataspaceNotFoundException) { return false } @@ -117,7 +122,7 @@ class CpsIntegrationSpecBase extends Specification { def addAnchorsWithData(numberOfAnchors, dataspaceName, schemaSetName, anchorNamePrefix, data) { (1..numberOfAnchors).each { - cpsAdminService.createAnchor(dataspaceName, schemaSetName, anchorNamePrefix + it) + cpsAnchorService.createAnchor(dataspaceName, schemaSetName, anchorNamePrefix + it) cpsDataService.saveData(dataspaceName, anchorNamePrefix + it, data.replace("Easons", "Easons-"+it.toString()), OffsetDateTime.now()) } } 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 index 14612d6c1..b10194560 100644 --- 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 @@ -50,9 +50,9 @@ class FunctionalSpecBase extends CpsIntegrationSpecBase { } def setupBookstoreInfraStructure() { - cpsAdminService.createDataspace(FUNCTIONAL_TEST_DATASPACE_1) - cpsAdminService.createDataspace(FUNCTIONAL_TEST_DATASPACE_2) - cpsAdminService.createDataspace(FUNCTIONAL_TEST_DATASPACE_3) + cpsDataspaceService.createDataspace(FUNCTIONAL_TEST_DATASPACE_1) + cpsDataspaceService.createDataspace(FUNCTIONAL_TEST_DATASPACE_2) + cpsDataspaceService.createDataspace(FUNCTIONAL_TEST_DATASPACE_3) def bookstoreYangModelAsString = readResourceDataFile('bookstore/bookstore.yang') cpsModuleService.createSchemaSet(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_SCHEMA_SET, [bookstore: bookstoreYangModelAsString]) cpsModuleService.createSchemaSet(FUNCTIONAL_TEST_DATASPACE_2, BOOKSTORE_SCHEMA_SET, [bookstore: bookstoreYangModelAsString]) @@ -73,8 +73,8 @@ class FunctionalSpecBase extends CpsIntegrationSpecBase { def restoreBookstoreDataAnchor(anchorNumber) { def anchorName = 'bookstoreAnchor' + anchorNumber - cpsAdminService.deleteAnchor(FUNCTIONAL_TEST_DATASPACE_1, anchorName) - cpsAdminService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_SCHEMA_SET, anchorName) + cpsAnchorService.deleteAnchor(FUNCTIONAL_TEST_DATASPACE_1, anchorName) + cpsAnchorService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_SCHEMA_SET, anchorName) cpsDataService.saveData(FUNCTIONAL_TEST_DATASPACE_1, anchorName, bookstoreJsonData.replace("Easons", "Easons-"+anchorNumber.toString()), 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 deleted file mode 100644 index f8eca6199..000000000 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsAdminServiceIntegrationSpec.groovy +++ /dev/null @@ -1,181 +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.functional - -import org.onap.cps.api.CpsAdminService -import org.onap.cps.integration.base.CpsIntegrationSpecBase -import org.onap.cps.spi.FetchDescendantsOption -import org.onap.cps.spi.exceptions.AlreadyDefinedException -import org.onap.cps.spi.exceptions.AnchorNotFoundException -import org.onap.cps.spi.exceptions.DataspaceInUseException -import org.onap.cps.spi.exceptions.DataspaceNotFoundException -import java.time.OffsetDateTime - -class CpsAdminServiceIntegrationSpec extends CpsIntegrationSpecBase { - - CpsAdminService objectUnderTest - - def setup() { objectUnderTest = cpsAdminService } - - def 'Dataspace CRUD operations.'() { - when: 'a dataspace is created' - objectUnderTest.createDataspace('newDataspace') - then: 'the dataspace can be read' - assert objectUnderTest.getDataspace('newDataspace').name == 'newDataspace' - and: 'it can be deleted' - objectUnderTest.deleteDataspace('newDataspace') - then: 'the dataspace no longer exists i.e. an exception is thrown if an attempt is made to retrieve it' - def thrown = null - try { - objectUnderTest.getDataspace('newDataspace') - } catch(Exception exception) { - thrown = exception - } - assert thrown instanceof DataspaceNotFoundException - } - - def 'Delete dataspace with error; #scenario.'() { - setup: 'add some anchors if needed' - numberOfAnchors.times { - objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'anchor' + it) - } - when: 'attempt to delete dataspace' - objectUnderTest.deleteDataspace(dataspaceName) - then: 'the correct exception is thrown with the relevant details' - def thrownException = thrown(expectedException) - thrownException.details.contains(expectedMessageDetails) - cleanup: - numberOfAnchors.times { - objectUnderTest.deleteAnchor(GENERAL_TEST_DATASPACE, 'anchor' + it) - } - where: 'the following data is used' - scenario | dataspaceName | numberOfAnchors || expectedException | expectedMessageDetails - 'dataspace name does not exist' | 'unknown' | 0 || DataspaceNotFoundException | 'unknown does not exist' - 'dataspace contains schemasets' | GENERAL_TEST_DATASPACE | 0 || DataspaceInUseException | 'contains 1 schemaset(s)' - 'dataspace contains anchors' | GENERAL_TEST_DATASPACE | 2 || DataspaceInUseException | 'contains 2 anchor(s)' - } - - def 'Retrieve all dataspaces (depends on total test suite).'() { - given: 'two addtional dataspaces are created' - objectUnderTest.createDataspace('dataspace1') - objectUnderTest.createDataspace('dataspace2') - when: 'all datespaces are retreived' - def result = objectUnderTest.getAllDataspaces() - then: 'there are at least 3 dataspaces (2 new ones plus the general test dataspace)' - result.size() >= 3 - assert result.name.containsAll([GENERAL_TEST_DATASPACE, 'dataspace1', 'dataspace2']) - } - - def 'Duplicate dataspaces.'() { - when: 'attempting to create a dataspace with the same name as an existing one' - objectUnderTest.createDataspace(GENERAL_TEST_DATASPACE) - then: 'an exception is thrown indicating the dataspace already exists' - thrown(AlreadyDefinedException) - } - - def 'Anchor CRUD operations.'() { - when: 'an anchor is created' - objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'newAnchor') - then: 'the anchor be read' - assert objectUnderTest.getAnchor(GENERAL_TEST_DATASPACE, 'newAnchor').name == 'newAnchor' - and: 'it can be deleted' - objectUnderTest.deleteAnchor(GENERAL_TEST_DATASPACE,'newAnchor') - then: 'the anchor no longer exists i.e. an exception is thrown if an attempt is made to retrieve it' - def thrown = null - try { - objectUnderTest.getAnchor(GENERAL_TEST_DATASPACE, 'newAnchor') - } catch(Exception exception) { - thrown = exception - } - assert thrown instanceof AnchorNotFoundException - } - - def 'Filtering multiple anchors.'() { - when: '2 anchors with bookstore schema set are created' - 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 = 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' - assert objectUnderTest.getAnchors(GENERAL_TEST_DATASPACE).size() == 3 - and: 'there are 2 anchors associated with bookstore schema set' - assert objectUnderTest.getAnchors(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET).size() == 2 - and: 'there is 1 anchor associated with other schema set' - assert objectUnderTest.getAnchors(GENERAL_TEST_DATASPACE, 'otherSchemaSet').size() == 1 - } - - def 'Querying anchor(name)s (depends on previous test!).'() { - expect: 'there are now 3 anchors using the "stores" module (both schema sets use the same modules) ' - assert objectUnderTest.queryAnchorNames(GENERAL_TEST_DATASPACE, ['stores']).size() == 3 - and: 'there are no anchors using both "stores" and a "unused-model"' - assert objectUnderTest.queryAnchorNames(GENERAL_TEST_DATASPACE, ['stores', 'unused-model']).size() == 0 - } - - def 'Duplicate anchors.'() { - given: 'an anchor is created' - objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'newAnchor') - when: 'attempt to create another anchor with the same name' - objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'newAnchor') - then: 'an exception is thrown that the anchor already is defined' - thrown(AlreadyDefinedException) - cleanup: - objectUnderTest.deleteAnchor(GENERAL_TEST_DATASPACE, 'newAnchor') - } - - def 'Query anchors without any known modules and #scenario'() { - when: 'querying for anchors with #scenario' - def result = objectUnderTest.queryAnchorNames(dataspaceName, ['unknownModule']) - then: 'an empty result is returned (no error)' - assert result == [] - where: - scenario | dataspaceName - 'non existing database' | 'nonExistingDataspace' - 'just unknown module(s)' | GENERAL_TEST_DATASPACE - } - - def 'Update anchor schema set.'() { - when: 'a new schema set with tree yang model is created' - def newTreeYangModelAsString = readResourceDataFile('tree/new-test-tree.yang') - cpsModuleService.createSchemaSet(GENERAL_TEST_DATASPACE, 'newTreeSchemaSet', [tree: newTreeYangModelAsString]) - then: 'an anchor with new schema set is created' - objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, 'newTreeSchemaSet', 'anchor4') - and: 'the new tree datanode is saved' - def treeJsonData = readResourceDataFile('tree/new-test-tree.json') - cpsDataService.saveData(GENERAL_TEST_DATASPACE, 'anchor4', treeJsonData, OffsetDateTime.now()) - and: 'saved tree data node can be retrieved by its normalized xpath' - def branchName = cpsDataService.getDataNodes(GENERAL_TEST_DATASPACE, 'anchor4', "/test-tree/branch", FetchDescendantsOption.DIRECT_CHILDREN_ONLY)[0].leaves['name'] - assert branchName == 'left' - and: 'a another schema set with updated tree yang model is created' - def updatedTreeYangModelAsString = readResourceDataFile('tree/updated-test-tree.yang') - cpsModuleService.createSchemaSet(GENERAL_TEST_DATASPACE, 'anotherTreeSchemaSet', [tree: updatedTreeYangModelAsString]) - and: 'anchor4 schema set is updated with another schema set successfully' - objectUnderTest.updateAnchorSchemaSet(GENERAL_TEST_DATASPACE, 'anchor4', 'anotherTreeSchemaSet') - when: 'updated tree data node with new leaves' - def updatedTreeJsonData = readResourceDataFile('tree/updated-test-tree.json') - cpsDataService.updateNodeLeaves(GENERAL_TEST_DATASPACE, "anchor4", "/test-tree/branch[@name='left']", updatedTreeJsonData, OffsetDateTime.now()) - then: 'updated tree data node can be retrieved by its normalized xpath' - def birdsName = cpsDataService.getDataNodes(GENERAL_TEST_DATASPACE, 'anchor4',"/test-tree/branch[@name='left']/nest", FetchDescendantsOption.DIRECT_CHILDREN_ONLY)[0].leaves['birds'] as List - assert birdsName.size() == 3 - assert birdsName.containsAll('Night Owl', 'Raven', 'Crow') - } -} diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsAnchorServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsAnchorServiceIntegrationSpec.groovy new file mode 100644 index 000000000..99dab8426 --- /dev/null +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsAnchorServiceIntegrationSpec.groovy @@ -0,0 +1,124 @@ +/* + * ============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.functional + +import org.onap.cps.api.CpsAnchorService +import org.onap.cps.integration.base.CpsIntegrationSpecBase +import org.onap.cps.spi.FetchDescendantsOption +import org.onap.cps.spi.exceptions.AlreadyDefinedException +import org.onap.cps.spi.exceptions.AnchorNotFoundException + +import java.time.OffsetDateTime + +class CpsAnchorServiceIntegrationSpec extends CpsIntegrationSpecBase { + + CpsAnchorService objectUnderTest + + def setup() { objectUnderTest = cpsAnchorService } + + def 'Anchor CRUD operations.'() { + when: 'an anchor is created' + objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'newAnchor') + then: 'the anchor be read' + assert objectUnderTest.getAnchor(GENERAL_TEST_DATASPACE, 'newAnchor').name == 'newAnchor' + and: 'it can be deleted' + objectUnderTest.deleteAnchor(GENERAL_TEST_DATASPACE,'newAnchor') + then: 'the anchor no longer exists i.e. an exception is thrown if an attempt is made to retrieve it' + def thrown = null + try { + objectUnderTest.getAnchor(GENERAL_TEST_DATASPACE, 'newAnchor') + } catch(Exception exception) { + thrown = exception + } + assert thrown instanceof AnchorNotFoundException + } + + def 'Filtering multiple anchors.'() { + when: '2 anchors with bookstore schema set are created' + 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 = 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' + assert objectUnderTest.getAnchors(GENERAL_TEST_DATASPACE).size() == 3 + and: 'there are 2 anchors associated with bookstore schema set' + assert objectUnderTest.getAnchors(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET).size() == 2 + and: 'there is 1 anchor associated with other schema set' + assert objectUnderTest.getAnchors(GENERAL_TEST_DATASPACE, 'otherSchemaSet').size() == 1 + } + + def 'Querying anchor(name)s (depends on previous test!).'() { + expect: 'there are now 3 anchors using the "stores" module (both schema sets use the same modules) ' + assert objectUnderTest.queryAnchorNames(GENERAL_TEST_DATASPACE, ['stores']).size() == 3 + and: 'there are no anchors using both "stores" and a "unused-model"' + assert objectUnderTest.queryAnchorNames(GENERAL_TEST_DATASPACE, ['stores', 'unused-model']).size() == 0 + } + + def 'Duplicate anchors.'() { + given: 'an anchor is created' + objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'newAnchor') + when: 'attempt to create another anchor with the same name' + objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'newAnchor') + then: 'an exception is thrown that the anchor already is defined' + thrown(AlreadyDefinedException) + cleanup: + objectUnderTest.deleteAnchor(GENERAL_TEST_DATASPACE, 'newAnchor') + } + + def 'Query anchors without any known modules and #scenario'() { + when: 'querying for anchors with #scenario' + def result = objectUnderTest.queryAnchorNames(dataspaceName, ['unknownModule']) + then: 'an empty result is returned (no error)' + assert result == [] + where: + scenario | dataspaceName + 'non existing database' | 'nonExistingDataspace' + 'just unknown module(s)' | GENERAL_TEST_DATASPACE + } + + def 'Update anchor schema set.'() { + when: 'a new schema set with tree yang model is created' + def newTreeYangModelAsString = readResourceDataFile('tree/new-test-tree.yang') + cpsModuleService.createSchemaSet(GENERAL_TEST_DATASPACE, 'newTreeSchemaSet', [tree: newTreeYangModelAsString]) + then: 'an anchor with new schema set is created' + objectUnderTest.createAnchor(GENERAL_TEST_DATASPACE, 'newTreeSchemaSet', 'anchor4') + and: 'the new tree datanode is saved' + def treeJsonData = readResourceDataFile('tree/new-test-tree.json') + cpsDataService.saveData(GENERAL_TEST_DATASPACE, 'anchor4', treeJsonData, OffsetDateTime.now()) + and: 'saved tree data node can be retrieved by its normalized xpath' + def branchName = cpsDataService.getDataNodes(GENERAL_TEST_DATASPACE, 'anchor4', "/test-tree/branch", FetchDescendantsOption.DIRECT_CHILDREN_ONLY)[0].leaves['name'] + assert branchName == 'left' + and: 'a another schema set with updated tree yang model is created' + def updatedTreeYangModelAsString = readResourceDataFile('tree/updated-test-tree.yang') + cpsModuleService.createSchemaSet(GENERAL_TEST_DATASPACE, 'anotherTreeSchemaSet', [tree: updatedTreeYangModelAsString]) + and: 'anchor4 schema set is updated with another schema set successfully' + objectUnderTest.updateAnchorSchemaSet(GENERAL_TEST_DATASPACE, 'anchor4', 'anotherTreeSchemaSet') + when: 'updated tree data node with new leaves' + def updatedTreeJsonData = readResourceDataFile('tree/updated-test-tree.json') + cpsDataService.updateNodeLeaves(GENERAL_TEST_DATASPACE, "anchor4", "/test-tree/branch[@name='left']", updatedTreeJsonData, OffsetDateTime.now()) + then: 'updated tree data node can be retrieved by its normalized xpath' + def birdsName = cpsDataService.getDataNodes(GENERAL_TEST_DATASPACE, 'anchor4',"/test-tree/branch[@name='left']/nest", FetchDescendantsOption.DIRECT_CHILDREN_ONLY)[0].leaves['birds'] as List + assert birdsName.size() == 3 + assert birdsName.containsAll('Night Owl', 'Raven', 'Crow') + } +} 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 017ede7de..b107a87e8 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 @@ -34,8 +34,6 @@ import org.onap.cps.spi.exceptions.DataValidationException import org.onap.cps.spi.exceptions.DataspaceNotFoundException import org.onap.cps.spi.model.DeltaReport -import java.time.OffsetDateTime - import static org.onap.cps.spi.FetchDescendantsOption.DIRECT_CHILDREN_ONLY import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS @@ -174,7 +172,7 @@ class CpsDataServiceIntegrationSpec extends FunctionalSpecBase { def 'Attempt to create a top level data node using root.'() { given: 'a new anchor' - cpsAdminService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_SCHEMA_SET, 'newAnchor1'); + cpsAnchorService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_SCHEMA_SET, 'newAnchor1'); when: 'attempt to save new top level datanode' def json = '{"bookstore": {"bookstore-name": "New Store"} }' objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, 'newAnchor1' , '/', json, now) diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataspaceServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataspaceServiceIntegrationSpec.groovy new file mode 100644 index 000000000..739e80224 --- /dev/null +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataspaceServiceIntegrationSpec.groovy @@ -0,0 +1,107 @@ +/* + * ============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.functional + +import org.onap.cps.api.CpsDataspaceService +import org.onap.cps.integration.base.CpsIntegrationSpecBase +import org.onap.cps.spi.exceptions.AlreadyDefinedException +import org.onap.cps.spi.exceptions.DataspaceInUseException +import org.onap.cps.spi.exceptions.DataspaceNotFoundException + +class CpsDataspaceServiceIntegrationSpec extends CpsIntegrationSpecBase { + + CpsDataspaceService objectUnderTest + + def setup() { objectUnderTest = cpsDataspaceService } + + def 'Dataspace CRUD operations.'() { + when: 'a dataspace is created' + objectUnderTest.createDataspace('newDataspace') + then: 'the dataspace can be read' + assert objectUnderTest.getDataspace('newDataspace').name == 'newDataspace' + and: 'it can be deleted' + objectUnderTest.deleteDataspace('newDataspace') + then: 'the dataspace no longer exists i.e. an exception is thrown if an attempt is made to retrieve it' + def thrown = null + try { + objectUnderTest.getDataspace('newDataspace') + } catch(Exception exception) { + thrown = exception + } + assert thrown instanceof DataspaceNotFoundException + } + + def 'Attempt to delete a non-existing dataspace'() { + when: 'attempt to delete a non-existing dataspace' + objectUnderTest.deleteDataspace('non-existing-name') + then: 'a not found exception is thrown with the relevant dataspace name' + def thrownException = thrown(DataspaceNotFoundException) + assert thrownException.details.contains('non-existing-name does not exist') + } + + def 'Attempt Delete dataspace with a schema set and anchor'() { + setup: 'a dataspace with a schema set and anchor' + objectUnderTest.createDataspace('targetDataspace') + cpsModuleService.createSchemaSet('targetDataspace','someSchemaSet',[:]) + cpsAnchorService.createAnchor('targetDataspace', 'someSchemaSet', 'some_anchor') + when: 'attempt to delete dataspace' + objectUnderTest.deleteDataspace('targetDataspace') + then: 'an in-use exception is thrown mentioning anchors' + def thrownException = thrown(DataspaceInUseException) + assert thrownException.details.contains('contains 1 anchor(s)') + cleanup: + cpsModuleService.deleteSchemaSetsWithCascade('targetDataspace',['someSchemaSet']) + objectUnderTest.deleteDataspace('targetDataspace') + } + + def 'Attempt to delete dataspace with just a schema set'() { + setup: 'a dataspace with a schema set' + objectUnderTest.createDataspace('targetDataspace') + cpsModuleService.createSchemaSet('targetDataspace','someSchemaSet',[:]) + when: 'attempt to delete dataspace' + objectUnderTest.deleteDataspace('targetDataspace') + then: 'an in-use exception is thrown mentioning schemasets' + def thrownException = thrown(DataspaceInUseException) + assert thrownException.details.contains('contains 1 schemaset(s)') + cleanup: + cpsModuleService.deleteSchemaSetsWithCascade('targetDataspace',['someSchemaSet']) + objectUnderTest.deleteDataspace('targetDataspace') + } + + def 'Retrieve all dataspaces (depends on total test suite).'() { + given: 'two addtional dataspaces are created' + objectUnderTest.createDataspace('dataspace1') + objectUnderTest.createDataspace('dataspace2') + when: 'all datespaces are retreived' + def result = objectUnderTest.getAllDataspaces() + then: 'there are at least 3 dataspaces (2 new ones plus the general test dataspace)' + result.size() >= 3 + assert result.name.containsAll([GENERAL_TEST_DATASPACE, 'dataspace1', 'dataspace2']) + } + + def 'Duplicate dataspaces.'() { + when: 'attempting to create a dataspace with the same name as an existing one' + objectUnderTest.createDataspace(GENERAL_TEST_DATASPACE) + then: 'an exception is thrown indicating the dataspace already exists' + thrown(AlreadyDefinedException) + } + +} diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsModuleServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsModuleServiceIntegrationSpec.groovy index 2e1b082c0..cf0e0b594 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsModuleServiceIntegrationSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsModuleServiceIntegrationSpec.groovy @@ -20,6 +20,7 @@ package org.onap.cps.integration.functional +import org.onap.cps.api.CpsModuleService import org.onap.cps.api.impl.CpsModuleServiceImpl import org.onap.cps.integration.base.FunctionalSpecBase import org.onap.cps.spi.CascadeDeleteAllowed @@ -33,7 +34,7 @@ import org.onap.cps.spi.model.ModuleReference class CpsModuleServiceIntegrationSpec extends FunctionalSpecBase { - CpsModuleServiceImpl objectUnderTest + CpsModuleService objectUnderTest private static def originalNumberOfModuleReferences = 1 private static def existingModuleReference = new ModuleReference('stores','2020-09-15') @@ -97,7 +98,7 @@ class CpsModuleServiceIntegrationSpec extends FunctionalSpecBase { def schemaSetName = "NewSchemaWith${numberOfNewModules}Modules" objectUnderTest.createSchemaSetFromModules(FUNCTIONAL_TEST_DATASPACE_1, schemaSetName, newYangResourcesNameToContentMap, moduleReferences) and: 'associated with a new anchor' - cpsAdminService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, schemaSetName, 'newAnchor') + cpsAnchorService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, schemaSetName, 'newAnchor') then: 'the new anchor has the correct number of modules' def yangResourceModuleReferences = objectUnderTest.getYangResourcesModuleReferences(FUNCTIONAL_TEST_DATASPACE_1, 'newAnchor') assert expectedNumberOfModulesForAnchor == yangResourceModuleReferences.size() @@ -204,7 +205,7 @@ class CpsModuleServiceIntegrationSpec extends FunctionalSpecBase { objectUnderTest.createSchemaSet(FUNCTIONAL_TEST_DATASPACE_1, 'newSchemaSet', newYangResourcesNameToContentMap) and: 'optionally create anchor for the schema set' if (associateWithAnchor) { - cpsAdminService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, 'newSchemaSet', 'newAnchor') + cpsAnchorService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, 'newSchemaSet', 'newAnchor') } when: 'attempt to delete the schema set' try { @@ -270,7 +271,7 @@ class CpsModuleServiceIntegrationSpec extends FunctionalSpecBase { given: 'an anchor and schema set with 2 modules (to be upgraded)' populateNewYangResourcesNameToContentMapAndAllModuleReferences('original', 2) objectUnderTest.createSchemaSetFromModules(FUNCTIONAL_TEST_DATASPACE_1, 'targetSchema', newYangResourcesNameToContentMap, []) - cpsAdminService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, 'targetSchema', 'targetAnchor') + cpsAnchorService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, 'targetSchema', 'targetAnchor') def yangResourceModuleReferencesBeforeUpgrade = objectUnderTest.getYangResourcesModuleReferences(FUNCTIONAL_TEST_DATASPACE_1, 'targetAnchor') assert yangResourceModuleReferencesBeforeUpgrade.size() == 2 assert yangResourceModuleReferencesBeforeUpgrade.containsAll([new ModuleReference('original_0','2000-01-01'),new ModuleReference('original_1','2001-01-01')]) @@ -291,18 +292,18 @@ class CpsModuleServiceIntegrationSpec extends FunctionalSpecBase { cleanup: objectUnderTest.deleteSchemaSetsWithCascade(FUNCTIONAL_TEST_DATASPACE_1, ['targetSchema']) } - + def 'Upgrade existing schema set from another anchor (used in NCMP for matching module set tag)'() { given: 'an anchor and schema set with 1 module (target)' populateNewYangResourcesNameToContentMapAndAllModuleReferences('target', 1) objectUnderTest.createSchemaSetFromModules(FUNCTIONAL_TEST_DATASPACE_1, 'targetSchema', newYangResourcesNameToContentMap, []) - cpsAdminService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, 'targetSchema', 'targetAnchor') + cpsAnchorService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, 'targetSchema', 'targetAnchor') def moduleReferencesBeforeUpgrade = objectUnderTest.getYangResourcesModuleReferences(FUNCTIONAL_TEST_DATASPACE_1, 'targetAnchor') assert moduleReferencesBeforeUpgrade.size() == 1 and: 'another anchor and schema set with 2 other modules (source for upgrade)' populateNewYangResourcesNameToContentMapAndAllModuleReferences('source', 2) objectUnderTest.createSchemaSetFromModules(FUNCTIONAL_TEST_DATASPACE_1, 'sourceSchema', newYangResourcesNameToContentMap, []) - cpsAdminService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, 'sourceSchema', 'sourceAnchor') + cpsAnchorService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, 'sourceSchema', 'sourceAnchor') assert objectUnderTest.getYangResourcesModuleReferences(FUNCTIONAL_TEST_DATASPACE_1, 'sourceAnchor').size() == 2 when: 'the target schema is upgraded using the module references from the source anchor' def moduleReferencesFromSourceAnchor = objectUnderTest.getYangResourcesModuleReferences(FUNCTIONAL_TEST_DATASPACE_1, 'sourceAnchor') 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 index d8012ec6d..816aeff71 100644 --- 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 @@ -43,7 +43,7 @@ class CpsPerfTestBase extends PerfTestBase { } def setupPerformanceInfraStructure() { - cpsAdminService.createDataspace(CPS_PERFORMANCE_TEST_DATASPACE) + cpsDataspaceService.createDataspace(CPS_PERFORMANCE_TEST_DATASPACE) def modelAsString = readResourceDataFile('bookstore/bookstore.yang') cpsModuleService.createSchemaSet(CPS_PERFORMANCE_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, [bookstore: modelAsString]) } diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpPerfTestBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpPerfTestBase.groovy index 12b04be2e..0557d5bb7 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpPerfTestBase.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpPerfTestBase.groovy @@ -59,14 +59,14 @@ class NcmpPerfTestBase extends PerfTestBase { } def setupPerformanceInfraStructure() { - cpsAdminService.createDataspace(NCMP_PERFORMANCE_TEST_DATASPACE) + cpsDataspaceService.createDataspace(NCMP_PERFORMANCE_TEST_DATASPACE) createRegistrySchemaSet() createCmDataSubscriptionsSchemaSet() addCmSubscriptionData() } def createInitialData() { - cpsAdminService.createAnchor(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_SCHEMA_SET, REGISTRY_ANCHOR) + cpsDataspaceService.createAnchor(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_SCHEMA_SET, REGISTRY_ANCHOR) def data = readResourceDataFile('ncmp-registry/1000-cmhandles.json') cpsDataService.saveData(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, data, OffsetDateTime.now()) } @@ -82,7 +82,7 @@ class NcmpPerfTestBase extends PerfTestBase { } def addCmSubscriptionData() { - cpsAdminService.createAnchor(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_SCHEMA_SET, CM_DATA_SUBSCRIPTIONS_ANCHOR) + cpsDataspaceService.createAnchor(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_SCHEMA_SET, CM_DATA_SUBSCRIPTIONS_ANCHOR) cpsDataService.saveData(NCMP_PERFORMANCE_TEST_DATASPACE, CM_DATA_SUBSCRIPTIONS_ANCHOR, datastore1cmHandlePlaceHolder, now) def subscribers = createLeafList('subscribers',numberOfCmDataSubscribers, subscriberIdPrefix) def filters = '"filters":' + createJsonArray('filter',numberOfFiltersPerCmHandle,'xpath',xpathPrefix,subscribers) diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsAdminServiceLimitsPerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsAdminServiceLimitsPerfTest.groovy deleted file mode 100644 index 9ea7a7b53..000000000 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsAdminServiceLimitsPerfTest.groovy +++ /dev/null @@ -1,50 +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.performance.cps - -import org.onap.cps.api.CpsAdminService -import org.onap.cps.integration.performance.base.CpsPerfTestBase - -class CpsAdminServiceLimitsPerfTest extends CpsPerfTestBase { - - CpsAdminService objectUnderTest - - def setup() { objectUnderTest = cpsAdminService } - - def 'Get anchors from multiple schema set names limit exceeded: 32,766 (~ 2^15) schema set names.'() { - given: 'more than 32,766 schema set names' - def schemaSetNames = (0..40_000).collect { "size-of-this-name-does-not-matter-for-limit-" + it } - when: 'single get is executed to get all the anchors' - objectUnderTest.getAnchors(CPS_PERFORMANCE_TEST_DATASPACE, schemaSetNames) - then: 'a database exception is not thrown' - noExceptionThrown() - } - - def 'Querying anchor names limit exceeded: 32,766 (~ 2^15) modules.'() { - given: 'more than 32,766 module names' - def moduleNames = (0..40_000).collect { "size-of-this-name-does-not-matter-for-limit-" + it } - when: 'single query is executed to get all the anchors' - objectUnderTest.queryAnchorNames(CPS_PERFORMANCE_TEST_DATASPACE, moduleNames) - then: 'a database exception is not thrown' - noExceptionThrown() - } - -} diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataServiceLimitsPerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataServiceLimitsPerfTest.groovy index ce66cb08a..4d4d6125c 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataServiceLimitsPerfTest.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataServiceLimitsPerfTest.groovy @@ -35,7 +35,7 @@ class CpsDataServiceLimitsPerfTest extends CpsPerfTestBase { def 'Create 33,000 books (note further tests depend on this running first).'() { given: 'an anchor containing a bookstore with one category' - cpsAdminService.createAnchor(CPS_PERFORMANCE_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'limitsAnchor') + cpsAnchorService.createAnchor(CPS_PERFORMANCE_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'limitsAnchor') def parentNodeData = '{"bookstore": { "categories": [{ "code": 1, "name": "Test", "books" : [] }] }}' cpsDataService.saveData(CPS_PERFORMANCE_TEST_DATASPACE, 'limitsAnchor', parentNodeData, OffsetDateTime.now()) when: '33,000 books are added' @@ -84,7 +84,7 @@ class CpsDataServiceLimitsPerfTest extends CpsPerfTestBase { when: resourceMeter.start() cpsDataService.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'limitsAnchor', OffsetDateTime.now()) - cpsAdminService.deleteAnchor(CPS_PERFORMANCE_TEST_DATASPACE, 'limitsAnchor') + cpsAnchorService.deleteAnchor(CPS_PERFORMANCE_TEST_DATASPACE, 'limitsAnchor') resourceMeter.stop() def durationInSeconds = resourceMeter.getTotalTimeInSeconds() then: 'test data is deleted in 1 second' diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataspaceServiceLimitsPerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataspaceServiceLimitsPerfTest.groovy new file mode 100644 index 000000000..e1235272f --- /dev/null +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataspaceServiceLimitsPerfTest.groovy @@ -0,0 +1,50 @@ +/* + * ============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.api.CpsAnchorService +import org.onap.cps.integration.performance.base.CpsPerfTestBase + +class CpsDataspaceServiceLimitsPerfTest extends CpsPerfTestBase { + + CpsAnchorService objectUnderTest + + def setup() { objectUnderTest = cpsAnchorService } + + def 'Get anchors from multiple schema set names limit exceeded: 32,766 (~ 2^15) schema set names.'() { + given: 'more than 32,766 schema set names' + def schemaSetNames = (0..40_000).collect { "size-of-this-name-does-not-matter-for-limit-" + it } + when: 'single get is executed to get all the anchors' + objectUnderTest.getAnchors(CPS_PERFORMANCE_TEST_DATASPACE, schemaSetNames) + then: 'a database exception is not thrown' + noExceptionThrown() + } + + def 'Querying anchor names limit exceeded: 32,766 (~ 2^15) modules.'() { + given: 'more than 32,766 module names' + def moduleNames = (0..40_000).collect { "size-of-this-name-does-not-matter-for-limit-" + it } + when: 'single query is executed to get all the anchors' + objectUnderTest.queryAnchorNames(CPS_PERFORMANCE_TEST_DATASPACE, moduleNames) + then: 'a database exception is not thrown' + noExceptionThrown() + } + +} diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/DeletePerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/DeletePerfTest.groovy index 818c300a5..e7bfabefb 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/DeletePerfTest.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/DeletePerfTest.groovy @@ -182,7 +182,7 @@ class DeletePerfTest extends CpsPerfTestBase { def anchorNames = (1..10).collect {'delete' + it} when: 'data nodes are deleted' resourceMeter.start() - cpsAdminService.deleteAnchors(CPS_PERFORMANCE_TEST_DATASPACE, anchorNames) + cpsAnchorService.deleteAnchors(CPS_PERFORMANCE_TEST_DATASPACE, anchorNames) resourceMeter.stop() def deleteDurationInSeconds = resourceMeter.getTotalTimeInSeconds() then: 'delete duration is within expected time and memory used is within limit' diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/WritePerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/WritePerfTest.groovy index 0c7107a56..2d38a0dfb 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/WritePerfTest.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/WritePerfTest.groovy @@ -27,7 +27,7 @@ class WritePerfTest extends CpsPerfTestBase { def 'Writing openroadm data has linear time.'() { given: 'an empty anchor exists for openroadm' - cpsAdminService.createAnchor(CPS_PERFORMANCE_TEST_DATASPACE, LARGE_SCHEMA_SET, 'writeAnchor') + cpsAnchorService.createAnchor(CPS_PERFORMANCE_TEST_DATASPACE, LARGE_SCHEMA_SET, 'writeAnchor') and: 'a list of device nodes to add' def jsonData = generateOpenRoadData(totalNodes) when: 'device nodes are added' @@ -39,7 +39,7 @@ class WritePerfTest extends CpsPerfTestBase { recordAndAssertResourceUsage("Writing ${totalNodes} devices", expectedDuration, durationInSeconds, memoryLimit, resourceMeter.getTotalMemoryUsageInMB()) cleanup: cpsDataService.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', OffsetDateTime.now()) - cpsAdminService.deleteAnchor(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor') + cpsAnchorService.deleteAnchor(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor') where: totalNodes || expectedDuration | memoryLimit 50 || 4 | 100 @@ -50,7 +50,7 @@ class WritePerfTest extends CpsPerfTestBase { def 'Writing bookstore data has exponential time.'() { given: 'an anchor containing a bookstore with a single category' - cpsAdminService.createAnchor(CPS_PERFORMANCE_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'writeAnchor') + cpsAnchorService.createAnchor(CPS_PERFORMANCE_TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'writeAnchor') def parentNodeData = '{"bookstore": { "categories": [{ "code": 1, "name": "Test", "books" : [] }] }}' cpsDataService.saveData(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', parentNodeData, OffsetDateTime.now()) and: 'a list of books to add' @@ -64,7 +64,7 @@ class WritePerfTest extends CpsPerfTestBase { recordAndAssertResourceUsage("Writing ${totalBooks} books", expectedDuration, durationInSeconds, memoryLimit, resourceMeter.getTotalMemoryUsageInMB()) cleanup: cpsDataService.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', OffsetDateTime.now()) - cpsAdminService.deleteAnchor(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor') + cpsAnchorService.deleteAnchor(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor') where: totalBooks || expectedDuration | memoryLimit 800 || 1 | 50 -- cgit 1.2.3-korg