Remove forced module sync from NCMP integration tests 93/138393/1
authordanielhanrahan <daniel.hanrahan@est.tech>
Thu, 4 Jul 2024 17:01:28 +0000 (18:01 +0100)
committerdanielhanrahan <daniel.hanrahan@est.tech>
Thu, 4 Jul 2024 17:27:14 +0000 (18:27 +0100)
- remove forced module sync in tests
- set module sync timers to 1 second in test application.yml
- have tests wait up to 2 seconds for module sync to run

Issue-ID: CPS-2304
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: I727894dc1b4b9cee1ab82d05a9c31d1e3e067cf3

integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy
integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleUpgradeSpec.groovy
integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpRestApiSpec.groovy
integration-test/src/test/resources/application.yml

index 0afdfa1..6b38936 100644 (file)
@@ -133,8 +133,9 @@ abstract class CpsIntegrationSpecBase extends Specification {
     static NO_MODULE_SET_TAG = ''
     static GENERAL_TEST_DATASPACE = 'generalTestDataspace'
     static BOOKSTORE_SCHEMA_SET = 'bookstoreSchemaSet'
+    static MODULE_SYNC_WAIT_TIME_IN_SECONDS = 2
 
-    def static initialized = false
+    static initialized = false
     def now = OffsetDateTime.now()
 
     def setup() {
@@ -218,8 +219,7 @@ abstract class CpsIntegrationSpecBase extends Specification {
     def registerCmHandle(dmiPlugin, cmHandleId, moduleSetTag) {
         def cmHandleToCreate = new NcmpServiceCmHandle(cmHandleId: cmHandleId, moduleSetTag: moduleSetTag)
         networkCmProxyInventoryFacade.updateDmiRegistrationAndSyncModule(new DmiPluginRegistration(dmiPlugin: dmiPlugin, createdCmHandles: [cmHandleToCreate]))
-        moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
-        new PollingConditions().within(3, () -> {
+        new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
             CmHandleState.READY == networkCmProxyInventoryFacade.getCmHandleCompositeState(cmHandleId).cmHandleState
         })
     }
index 0f442a8..2678270 100644 (file)
@@ -64,11 +64,8 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
         and: 'CM-handle is initially in ADVISED state'
             assert CmHandleState.ADVISED == objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState
 
-        when: 'module sync runs'
-            moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
-
-        then: 'CM-handle goes to READY state'
-            new PollingConditions().within(3, () -> {
+        and: 'CM-handle goes to READY state after module sync'
+            new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
                 assert CmHandleState.READY == objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState
             })
 
@@ -96,11 +93,8 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: DMI_URL, createdCmHandles: [cmHandleToCreate])
             objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
 
-        and: 'module sync runs'
-            moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
-
         then: 'CM-handle goes to LOCKED state with reason MODULE_SYNC_FAILED'
-            new PollingConditions().within(3, () -> {
+            new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
                 def cmHandleCompositeState = objectUnderTest.getCmHandleCompositeState('ch-1')
                 assert cmHandleCompositeState.cmHandleState == CmHandleState.LOCKED
                 assert cmHandleCompositeState.lockReason.lockReasonCategory == LockReasonCategory.MODULE_SYNC_FAILED
@@ -124,9 +118,8 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
             def cmHandleToCreate = new NcmpServiceCmHandle(cmHandleId: 'ch-3', moduleSetTag: 'B')
             objectUnderTest.updateDmiRegistrationAndSyncModule(new DmiPluginRegistration(dmiPlugin: DMI_URL, createdCmHandles: [cmHandleToCreate]))
 
-        then: 'the CM-handle goes to READY state after module sync'
-            moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
-            new PollingConditions().within(3, () -> {
+        then: 'the CM-handle goes to READY state'
+            new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
                 assert CmHandleState.READY == objectUnderTest.getCmHandleCompositeState('ch-3').cmHandleState
             })
 
@@ -148,10 +141,8 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
             def cmHandlesToCreate = [new NcmpServiceCmHandle(cmHandleId: 'ch-1'), new NcmpServiceCmHandle(cmHandleId: 'ch-2')]
             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: DMI_URL, createdCmHandles: cmHandlesToCreate)
             objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
-        and: 'module sync runs'
-            moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
         then: 'CM-handles go to LOCKED state'
-            new PollingConditions().within(3, () -> {
+            new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
                 assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.LOCKED
                 assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.LOCKED
             })
@@ -159,20 +150,18 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
         when: 'we wait for LOCKED CM handle retry time (actually just subtract 3 minutes from handles lastUpdateTime)'
             overrideCmHandleLastUpdateTime('ch-1', OffsetDateTime.now().minusMinutes(3))
             overrideCmHandleLastUpdateTime('ch-2', OffsetDateTime.now().minusMinutes(3))
-        and: 'failed CM handles are reset'
-            moduleSyncWatchdog.resetPreviouslyFailedCmHandles()
-        then: 'CM-handles are ADVISED state'
-            assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.ADVISED
-            assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.ADVISED
+        then: 'CM-handles go to ADVISED state'
+            new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
+                assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.ADVISED
+                assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.ADVISED
+            })
 
-        when: 'DMI is available for retry'
-            dmiDispatcher.isAvailable = true
-        and: 'DMI will return expected modules'
+        when: 'DMI will return expected modules'
             dmiDispatcher.moduleNamesPerCmHandleId = ['ch-1': ['M1', 'M2'], 'ch-2': ['M1', 'M3']]
-        and: 'module sync runs'
-            moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
+        and: 'DMI is available for retry'
+            dmiDispatcher.isAvailable = true
         then: 'CM-handles go to READY state'
-            new PollingConditions().within(3, () -> {
+            new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
                 assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.READY
                 assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.READY
             })
index 72e7983..3a08cfd 100644 (file)
@@ -62,14 +62,11 @@ class NcmpCmHandleUpgradeSpec extends CpsIntegrationSpecBase {
 
         when: 'DMI will return different modules for upgrade: M1 and M3'
             dmiDispatcher.moduleNamesPerCmHandleId[CM_HANDLE_ID] = ['M1', 'M3']
-        and: 'module sync runs'
-            moduleSyncWatchdog.resetPreviouslyFailedCmHandles()
-            moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
 
         then: 'CM-handle goes to READY state'
-            new PollingConditions().eventually {
+            new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
                 assert CmHandleState.READY == objectUnderTest.getCmHandleCompositeState(CM_HANDLE_ID).cmHandleState
-            }
+            })
 
         and: 'the CM-handle has expected moduleSetTag'
             assert objectUnderTest.getNcmpServiceCmHandle(CM_HANDLE_ID).moduleSetTag == updatedModuleSetTag
@@ -107,14 +104,10 @@ class NcmpCmHandleUpgradeSpec extends CpsIntegrationSpecBase {
         then: 'registration gives successful response'
             assert dmiPluginRegistrationResponse.upgradedCmHandles == [CmHandleRegistrationResponse.createSuccessResponse(CM_HANDLE_ID)]
 
-        when: 'module sync runs'
-            moduleSyncWatchdog.resetPreviouslyFailedCmHandles()
-            moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
-
-        then: 'CM-handle goes to READY state'
-            new PollingConditions().eventually {
+        and: 'CM-handle goes to READY state'
+            new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
                 assert CmHandleState.READY == objectUnderTest.getCmHandleCompositeState(CM_HANDLE_ID).cmHandleState
-            }
+            })
 
         and: 'the CM-handle has expected moduleSetTag'
             assert objectUnderTest.getNcmpServiceCmHandle(CM_HANDLE_ID).moduleSetTag == updatedModuleSetTag
@@ -167,16 +160,12 @@ class NcmpCmHandleUpgradeSpec extends CpsIntegrationSpecBase {
             objectUnderTest.updateDmiRegistrationAndSyncModule(
                     new DmiPluginRegistration(dmiPlugin: DMI_URL, upgradedCmHandles: cmHandlesToUpgrade))
 
-        and: 'module sync runs'
-            moduleSyncWatchdog.resetPreviouslyFailedCmHandles()
-            moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
-
         then: 'CM-handle goes to LOCKED state with reason MODULE_UPGRADE_FAILED'
-            new PollingConditions(timeout: 3).eventually {
+            new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
                 def cmHandleCompositeState = objectUnderTest.getCmHandleCompositeState(CM_HANDLE_ID)
                 assert cmHandleCompositeState.cmHandleState == CmHandleState.LOCKED
                 assert cmHandleCompositeState.lockReason.lockReasonCategory == LockReasonCategory.MODULE_UPGRADE_FAILED
-            }
+            })
 
         and: 'the CM-handle has same moduleSetTag as before'
             assert objectUnderTest.getNcmpServiceCmHandle(CM_HANDLE_ID).moduleSetTag == 'oldTag'
index 5325f1a..fbfebab 100644 (file)
@@ -40,20 +40,18 @@ class NcmpRestApiSpec extends CpsIntegrationSpecBase {
                 'ch-2': ['M1', 'M2'],
                 'ch-3': ['M1', 'M3']
             ]
-        and: 'a POST request is made to register the CM Handles'
+        when: 'a POST request is made to register the CM Handles'
             def requestBody = '{"dmiPlugin":"'+DMI_URL+'","createdCmHandles":[{"cmHandle":"ch-1"},{"cmHandle":"ch-2"},{"cmHandle":"ch-3"}]}'
             mvc.perform(post('/ncmpInventory/v1/ch').contentType(MediaType.APPLICATION_JSON).content(requestBody))
                     .andExpect(status().is2xxSuccessful())
-        when: 'module sync runs'
-            moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
         then: 'CM-handles go to READY state'
-            new PollingConditions().eventually {
+            new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
                 (1..3).each {
                     mvc.perform(get('/ncmp/v1/ch/ch-'+it))
                             .andExpect(status().isOk())
                             .andExpect(jsonPath('$.state.cmHandleState').value('READY'))
                 }
-            }
+            })
     }
 
     def 'Search for CM Handles by module using REST API.'() {
index 58e6287..fefae34 100644 (file)
@@ -179,9 +179,9 @@ ncmp:
 
   timers:
     advised-modules-sync:
-      sleep-time-ms: 100000
+      sleep-time-ms: 1000
     locked-modules-sync:
-      sleep-time-ms: 300000
+      sleep-time-ms: 1000
     cm-handle-data-sync:
       sleep-time-ms: 30000
     subscription-forwarding: