diff options
author | ToineSiebelink <toine.siebelink@est.tech> | 2024-11-27 15:32:27 +0000 |
---|---|---|
committer | ToineSiebelink <toine.siebelink@est.tech> | 2024-11-28 15:37:43 +0000 |
commit | 6067e18b93a7bde19547406769498fcd64407ad8 (patch) | |
tree | a9fa8c552bdf389c537b1c3d83ecd0ad0a237555 /cps-service/src/test/groovy | |
parent | 05e97441ad192b69051fbb67263284eb99ee1c41 (diff) |
De-Registration without Orphaned Module Check
- Testware updates to measure time spent for de-registration
- Removed orphan check from module delete methods
- Using @scheduled to run Db Cleaner method once
(see https://lf-onap.atlassian.net/wiki/spaces/DW/pages/52494359/CPS-2478+Module+Sync+Inefficiencies#De-Registration:-Test-Measurements-With-and-Without-Orphanage-removal for reasoning)
- Updated integration tests to call orphan check where need (after schema set deletion)
Issue-ID: CPS-2478
Change-Id: I513af9d8bb88486a242284b58e0363a527346dd4
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Diffstat (limited to 'cps-service/src/test/groovy')
-rw-r--r-- | cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy | 13 | ||||
-rw-r--r-- | cps-service/src/test/groovy/org/onap/cps/init/DbCleanerSpec.groovy | 38 |
2 files changed, 45 insertions, 6 deletions
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 1831506563..c02b06fd80 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 @@ -142,8 +142,6 @@ class CpsModuleServiceImplSpec extends Specification { 1 * mockCpsModulePersistenceService.deleteSchemaSet('my-dataspace', 'my-schemaset') and: 'schema set will be removed from the cache' 1 * mockYangTextSchemaSourceSetCache.removeFromCache('my-dataspace', 'my-schemaset') - and: 'orphan yang resources are deleted' - 1 * mockCpsModulePersistenceService.deleteUnusedYangResourceModules() and: 'the CpsValidator is called on the dataspaceName and schemaSetName' 1 * mockCpsValidator.validateNameCharacters('my-dataspace', _) where: 'following parameters are used' @@ -161,8 +159,6 @@ class CpsModuleServiceImplSpec extends Specification { 1 * mockCpsModulePersistenceService.deleteSchemaSet('my-dataspace', 'my-schemaset') and: 'schema set will be removed from the cache' 1 * mockYangTextSchemaSourceSetCache.removeFromCache('my-dataspace', 'my-schemaset') - and: 'orphan yang resources are deleted' - 1 * mockCpsModulePersistenceService.deleteUnusedYangResourceModules() and: 'the CpsValidator is called on the dataspaceName and schemaSetName' 1 * mockCpsValidator.validateNameCharacters('my-dataspace', 'my-schemaset') } @@ -187,8 +183,6 @@ class CpsModuleServiceImplSpec extends Specification { 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' @@ -276,6 +270,13 @@ class CpsModuleServiceImplSpec extends Specification { 1 * mockCpsValidator.validateNameCharacters('some-dataspace-name', 'some-anchor-name') } + def 'Delete unused yang resource modules.'() { + when: 'deleting unused yang resource modules' + objectUnderTest.deleteUnusedYangResourceModules() + then: 'it is delegated to the module persistence service' + 1 * mockCpsModulePersistenceService.deleteUnusedYangResourceModules() + } + def getModuleReferences() { return [new ModuleReference('some module name','some revision name')] } diff --git a/cps-service/src/test/groovy/org/onap/cps/init/DbCleanerSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/init/DbCleanerSpec.groovy new file mode 100644 index 0000000000..5106d29fa5 --- /dev/null +++ b/cps-service/src/test/groovy/org/onap/cps/init/DbCleanerSpec.groovy @@ -0,0 +1,38 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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.init + +import org.onap.cps.api.CpsModuleService +import spock.lang.Specification + +class DbCleanerSpec extends Specification { + + def mockCpsModuleService = Mock(CpsModuleService) + + def objectUnderTest = new DbCleaner(mockCpsModuleService) + + def 'DB clean up.'() { + when: 'scheduled method is triggered' + objectUnderTest.cleanDbAtStartUp() + then: 'the unused yang resource modules are deleted' + 1 * mockCpsModuleService.deleteUnusedYangResourceModules() + } +} |