From e28b62148676d189bdd11b78d8d78419d548e358 Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Tue, 14 Feb 2023 13:24:40 +0000 Subject: Bulk delete schemasets in CM handle deregistration - Batch delete schema sets in single query - Call deleteUnusedYangResourceModules once per batch, not per CM handle - Results for deregistering 10k: 14 mins before; 6 mins after Issue-ID: CPS-1423 Signed-off-by: danielhanrahan Change-Id: Ia3a86a0dc88677323e2f386253a99022a7f02603 --- .../cps/api/impl/CpsModuleServiceImplSpec.groovy | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cps-service/src/test/groovy/org/onap') diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy index 2bb0e63ab2..615d3af35a 100644 --- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy @@ -167,6 +167,28 @@ class CpsModuleServiceImplSpec extends Specification { return anchors } + def 'Delete multiple schema-sets when cascade is allowed.'() { + given: '#numberOfAnchors anchors are associated with each schemaset' + mockCpsAdminService.getAnchors('my-dataspace', 'my-schemaset1') >> createAnchors(numberOfAnchors) + mockCpsAdminService.getAnchors('my-dataspace', 'my-schemaset2') >> createAnchors(numberOfAnchors) + when: 'schema set deletion is requested with cascade allowed' + objectUnderTest.deleteSchemaSetsWithCascade('my-dataspace', ['my-schemaset1', 'my-schemaset2']) + then: 'anchor deletion is called 2 * #numberOfAnchors times' + (2 * numberOfAnchors) * mockCpsAdminService.deleteAnchor('my-dataspace', _) + and: 'persistence service method is invoked with same parameters' + mockCpsModulePersistenceService.deleteSchemaSets('my-dataspace', _) + and: 'schema sets will be removed from the cache' + 2 * mockYangTextSchemaSourceSetCache.removeFromCache('my-dataspace', _) + and: 'orphan yang resources are deleted' + 1 * mockCpsModulePersistenceService.deleteUnusedYangResourceModules() + and: 'the CpsValidator is called on the dataspaceName' + 1 * mockCpsValidator.validateNameCharacters('my-dataspace') + and: 'the CpsValidator is called on the schemaSetNames' + 1 * mockCpsValidator.validateNameCharacters(_) + where: 'following parameters are used' + numberOfAnchors << [0, 3] + } + def 'Get all yang resources module references.'() { given: 'an already present module reference' def moduleReferences = [new ModuleReference('some module name','some revision name')] -- cgit 1.2.3-korg