From 6dbed125ad1e61bab03572993db54c5a78662316 Mon Sep 17 00:00:00 2001 From: "halil.cakal" Date: Tue, 6 May 2025 13:40:46 +0100 Subject: [PATCH] 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 --- .../sync/SynchronizationCacheConfigSpec.groovy | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) 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 } } -- 2.16.6