From: halil.cakal Date: Tue, 6 May 2025 12:40:46 +0000 (+0100) Subject: Fix the tests that failing irregularly in groovy pipeline X-Git-Tag: 3.6.3~29^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F140843%2F2;p=cps.git Fix the tests that failing irregularly in groovy pipeline - Don't check if the key is present in the map anymore instead keep looking for if the key deleted after TTL period - Optimize the test by reducing the max wait time from 10 seconds to 1 second Issue-ID: CPS-2798 Change-Id: Ibbd40e682c28fa0c52da3f07d3687927fa42aa02 Signed-off-by: halil.cakal --- diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/SynchronizationCacheConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/SynchronizationCacheConfigSpec.groovy index 7db9e5a870..1cecbbedee 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/SynchronizationCacheConfigSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/SynchronizationCacheConfigSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================== - * Copyright (C) 2022-2025 Nordix Foundation + * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,23 +105,19 @@ class SynchronizationCacheConfigSpec extends Specification { } 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' - new PollingConditions().within(10) { + when: 'the key is inserted with a TTL' + moduleSyncStartedOnCmHandles.put('testKeyModuleSync', 'toBeExpired' as Object, 100, TimeUnit.MILLISECONDS) + then: 'the entry expires within a second' + new PollingConditions().within(1) { assert moduleSyncStartedOnCmHandles.get('testKeyModuleSync') == null } } 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: 'the entry expires' - new PollingConditions().within(10) { + when: 'the key is inserted with a TTL' + dataSyncSemaphores.put('testKeyDataSync', Boolean.TRUE, 100, TimeUnit.MILLISECONDS) + then: 'the entry expires within a second' + new PollingConditions().within(1) { assert dataSyncSemaphores.get('testKeyDataSync') == null } }