summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src/test')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy37
-rw-r--r--cps-ncmp-service/src/test/resources/application.yml9
2 files changed, 44 insertions, 2 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy
index 868ee7a705..6829d834d2 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START========================================================
- * Copyright (C) 2022 Nordix Foundation
+ * 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.
@@ -20,6 +20,7 @@
package org.onap.cps.ncmp.api.impl.config.embeddedcache
+import com.hazelcast.config.Config
import com.hazelcast.core.Hazelcast
import com.hazelcast.map.IMap
import org.onap.cps.spi.model.DataNode
@@ -74,6 +75,40 @@ class SynchronizationCacheConfigSpec extends Specification {
assert dataSyncSemaphoresConfig.asyncBackupCount == 3
}
+ def 'Verify deployment network configs for Distributed objects'() {
+ given: 'the Module Sync Work Queue config'
+ def queueNetworkConfig = Hazelcast.getHazelcastInstanceByName('moduleSyncWorkQueue').config.networkConfig
+ and: 'the Module Sync Started Cm Handle Map config'
+ def moduleSyncStartedOnCmHandlesNetworkConfig = Hazelcast.getHazelcastInstanceByName('moduleSyncStartedOnCmHandles').config.networkConfig
+ and: 'the Data Sync Semaphores Map config'
+ def dataSyncSemaphoresNetworkConfig = Hazelcast.getHazelcastInstanceByName('dataSyncSemaphores').config.networkConfig
+ expect: 'system created instance with correct config of Module Sync Work Queue'
+ assert queueNetworkConfig.join.autoDetectionConfig.enabled
+ assert !queueNetworkConfig.join.kubernetesConfig.enabled
+ and: 'Module Sync Started Cm Handle Map has the correct settings'
+ assert moduleSyncStartedOnCmHandlesNetworkConfig.join.autoDetectionConfig.enabled
+ assert !moduleSyncStartedOnCmHandlesNetworkConfig.join.kubernetesConfig.enabled
+ and: 'Data Sync Semaphore Map has the correct settings'
+ assert dataSyncSemaphoresNetworkConfig.join.autoDetectionConfig.enabled
+ assert !dataSyncSemaphoresNetworkConfig.join.kubernetesConfig.enabled
+
+ }
+
+ def 'Verify network config'() {
+ given: 'Synchronization config object and test configuration'
+ def objectUnderTest = new SynchronizationCacheConfig()
+ def testConfig = new Config()
+ when: 'kubernetes properties are enabled'
+ objectUnderTest.cacheKubernetesEnabled = true
+ objectUnderTest.cacheKubernetesServiceName = 'test-service-name'
+ and: 'method called to update the discovery mode'
+ objectUnderTest.updateDiscoveryMode(testConfig)
+ then: 'applied properties are reflected'
+ assert testConfig.networkConfig.join.kubernetesConfig.enabled
+ assert testConfig.networkConfig.join.kubernetesConfig.properties.get('service-name') == 'test-service-name'
+
+ }
+
def 'Time to Live Verify for Module Sync Semaphore'() {
when: 'the key is inserted with a TTL of 1 second (Hazelcast TTL resolution is seconds!)'
moduleSyncStartedOnCmHandles.put('testKeyModuleSync', 'toBeExpired' as Object, 1, TimeUnit.SECONDS)
diff --git a/cps-ncmp-service/src/test/resources/application.yml b/cps-ncmp-service/src/test/resources/application.yml
index e66f23d23f..679248ba86 100644
--- a/cps-ncmp-service/src/test/resources/application.yml
+++ b/cps-ncmp-service/src/test/resources/application.yml
@@ -35,4 +35,11 @@ ncmp:
parallelism-level: 3
model-loader:
- subscription: true \ No newline at end of file
+ subscription: true
+
+# Custom Hazelcast Config.
+hazelcast:
+ mode:
+ kubernetes:
+ enabled: false
+ service-name: "cps-and-ncmp-service" \ No newline at end of file