diff options
Diffstat (limited to 'cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy')
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy index 6184a9722..3eff96d79 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy @@ -22,7 +22,6 @@ 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.ncmp.api.impl.trustlevel.TrustLevel import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest @@ -32,7 +31,10 @@ import spock.lang.Specification class TrustLevelCacheConfigSpec extends Specification { @Autowired - private IMap<String, TrustLevel> trustLevelPerDmiPlugin + private Map<String, TrustLevel> trustLevelPerDmiPlugin + + @Autowired + private Map<String, TrustLevel> trustLevelPerCmHandle def 'Hazelcast cache for trust level per dmi plugin'() { expect: 'system is able to create an instance of the trust level per dmi plugin cache' @@ -43,23 +45,29 @@ class TrustLevelCacheConfigSpec extends Specification { assert Hazelcast.allHazelcastInstances.name.contains('hazelcastInstanceTrustLevelPerDmiPluginMap') } - def 'Verify Trust Level Per Dmi Plugin Cache for basic hazelcast map operations'() { - when: 'the key inserted into Trust Level Per Dmi Plugin Cache' - trustLevelPerDmiPlugin.put('dmi1', TrustLevel.COMPLETE) - trustLevelPerDmiPlugin.put('dmi2', TrustLevel.NONE) - then: 'the value for each dmi can be retrieved' - assert trustLevelPerDmiPlugin.get('dmi1') == TrustLevel.COMPLETE - assert trustLevelPerDmiPlugin.get('dmi2') == TrustLevel.NONE + def 'Hazelcast cache for trust level per cm handle'() { + expect: 'system is able to create an instance of the trust level per cm handle cache' + assert null != trustLevelPerCmHandle + and: 'there is at least 1 instance' + assert Hazelcast.allHazelcastInstances.size() > 0 + and: 'Hazelcast cache instance for trust level is present' + assert Hazelcast.allHazelcastInstances.name.contains('hazelcastInstanceTrustLevelPerCmHandleMap') } - def 'Verify configs for Distributed Caches'(){ - given: 'the Trust Level Per Dmi Plugin Cache config' - def trustLevelDmiPerPluginCacheConfig = Hazelcast.getHazelcastInstanceByName('hazelcastInstanceTrustLevelPerDmiPluginMap').config - def trustLevelDmiPerPluginCacheMapConfig = trustLevelDmiPerPluginCacheConfig.mapConfigs.get('trustLevelPerDmiPluginCacheConfig') - expect: 'system created instance with correct config' - assert trustLevelDmiPerPluginCacheConfig.clusterName == 'cps-and-ncmp-test-caches' - assert trustLevelDmiPerPluginCacheMapConfig.backupCount == 3 - assert trustLevelDmiPerPluginCacheMapConfig.asyncBackupCount == 3 + def 'Trust level cache configurations: #scenario'() { + when: 'retrieving the cache config for trustLevel' + def cacheConfig = Hazelcast.getHazelcastInstanceByName(hazelcastInstanceName).config + then: 'the cache config has the right cluster' + assert cacheConfig.clusterName == 'cps-and-ncmp-test-caches' + when: 'retrieving the map config for trustLevel' + def mapConfig = cacheConfig.mapConfigs.get(hazelcastMapConfigName) + then: 'the map config has the correct backup counts' + assert mapConfig.backupCount == 3 + assert mapConfig.asyncBackupCount == 3 + where: 'the following caches are used' + scenario | hazelcastInstanceName | hazelcastMapConfigName + 'cmhandle map' | 'hazelcastInstanceTrustLevelPerCmHandleMap' | 'trustLevelPerCmHandleCacheConfig' + 'dmi plugin map' | 'hazelcastInstanceTrustLevelPerDmiPluginMap' | 'trustLevelPerDmiPluginCacheConfig' } def 'Verify deployment network configs for Distributed Caches'() { @@ -70,6 +78,14 @@ class TrustLevelCacheConfigSpec extends Specification { assert !trustLevelDmiPerPluginCacheConfig.join.kubernetesConfig.enabled } + def 'Verify deployment network configs for Cm Handle Distributed Caches'() { + given: 'the Trust Level Per Cm Handle Cache config' + def trustLevelPerCmHandlePluginCacheConfig = Hazelcast.getHazelcastInstanceByName('hazelcastInstanceTrustLevelPerCmHandleMap').config.networkConfig + expect: 'system created instance with correct config' + assert trustLevelPerCmHandlePluginCacheConfig.join.autoDetectionConfig.enabled + assert !trustLevelPerCmHandlePluginCacheConfig.join.kubernetesConfig.enabled + } + def 'Verify network config'() { given: 'Synchronization config object and test configuration' def objectUnderTest = new TrustLevelCacheConfig() |