diff options
author | ToineSiebelink <toine.siebelink@est.tech> | 2022-10-20 18:34:29 +0100 |
---|---|---|
committer | Toine Siebelink <toine.siebelink@est.tech> | 2022-10-27 10:52:56 +0000 |
commit | a096a7faa35b345c765102201a5a09cc03ef541a (patch) | |
tree | bcf99d79138ef5f15e681a564ff655da44f26a5a /cps-ncmp-service/src/test | |
parent | 321d969c11826ccc3a01f6002cfaae2d0a5a4f9d (diff) |
Read Performance Improvement - Using Native Query
- Native query for FragmentExtracts
- Convert FragmentExtracts to tree of FragmentEntity
- Native Query now used for all Gets with descendants (orignal hibernate option only used when descendanst ommited)
- Added error handling for not-found on native query
- Ommit descendants by default on many udpate use-cases (this might have a signifcant perf. improvemnt impact too)
- Improved legacy tests for delete use-cases
- Corrected performace test expectation
- Fix TTL test realizing TTL resolution is whole seconds!
Issue-ID: CPS-1301
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Change-Id: I658ac1b7b7036f01050f30bdf9e5bd175725ef1d
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.groovy | 33 |
1 files changed, 23 insertions, 10 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 c16d6b69b6..868ee7a705 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 @@ -74,17 +74,30 @@ class SynchronizationCacheConfigSpec extends Specification { assert dataSyncSemaphoresConfig.asyncBackupCount == 3 } - def 'Time to Live Verify for Module Sync and Data Sync Semaphore'() { - when: 'the keys are inserted with a TTL' - moduleSyncStartedOnCmHandles.put('testKeyModuleSync', 'toBeExpired' as Object, 1000, TimeUnit.MILLISECONDS) - dataSyncSemaphores.put('testKeyDataSync', Boolean.TRUE, 1000, TimeUnit.MILLISECONDS) - then: 'the entries are present in the map' + 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) + then: 'the entry is present in the map' assert moduleSyncStartedOnCmHandles.get('testKeyModuleSync') != null + and: 'the entry expires in less then 2 seconds' + waitMax2SecondsForKeyExpiration(moduleSyncStartedOnCmHandles, 'testKeyModuleSync') + } + + def 'Time to Live Verify for Data Sync Semaphore'() { + when: 'the key is inserted with a TTL of 1 second' + dataSyncSemaphores.put('testKeyDataSync', Boolean.TRUE, 1, TimeUnit.SECONDS) + then: 'the entry is present in the map' assert dataSyncSemaphores.get('testKeyDataSync') != null - and: 'we wait for the key expiration' - sleep(1500) - and: 'the keys should be expired as TTL elapsed' - assert moduleSyncStartedOnCmHandles.get('testKeyModuleSync') == null - assert dataSyncSemaphores.get('testKeyDataSync') == null + and: 'the entry expires in less then 2 seconds' + waitMax2SecondsForKeyExpiration(dataSyncSemaphores, 'testKeyDataSync') } + + def waitMax2SecondsForKeyExpiration(map, key) { + def count = 0 + while ( map.get(key)!=null && ++count <= 20 ) { + sleep(100) + } + return count < 20 // Should have expired in less the 20 x 100ms = 2 seconds! + } + } |