diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-09-25 17:04:00 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2024-09-30 09:43:38 +0000 |
commit | 15302061ba7e9572ed4ea8c3aa0255d01ef07310 (patch) | |
tree | 94e97d4daafdfd7ed063306377270a5a5017ce6c /runtime-acm/src/test/java | |
parent | 6ed514f31be046cf31caeada994e7b9c036b5f90 (diff) |
Handle timeout as hard timeout
Issue-ID: POLICY-5132
Change-Id: Ic78d346972e955f7700118ffa74be11643a885f0
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/test/java')
-rw-r--r-- | runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java index 5cefd5f09..17cc8ad3b 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java @@ -115,10 +115,11 @@ class SupervisionScannerTest { void testAcDefinitionPrimeTimeout() { var acDefinition = createAutomationCompositionDefinition(AcTypeState.PRIMING, StateChangeResult.NO_ERROR); var acDefinitionProvider = createAcDefinitionProvider(acDefinition); + var participantSyncPublisher = mock(ParticipantSyncPublisher.class); var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); var supervisionScanner = new SupervisionScanner(mock(AutomationCompositionProvider.class), acDefinitionProvider, mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class), - mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup); + participantSyncPublisher, null, acRuntimeParameterGroup); supervisionScanner.run(); // Ac Definition in Priming state verify(acDefinitionProvider, times(0)).updateAcDefinitionState(any(), any(), any()); @@ -126,25 +127,30 @@ class SupervisionScannerTest { acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1); supervisionScanner = new SupervisionScanner(mock(AutomationCompositionProvider.class), acDefinitionProvider, mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class), - mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup); + participantSyncPublisher, null, acRuntimeParameterGroup); supervisionScanner.run(); // set Timeout verify(acDefinitionProvider).updateAcDefinitionState(acDefinition.getCompositionId(), acDefinition.getState(), StateChangeResult.TIMEOUT); + verify(participantSyncPublisher).sendSync(any(AutomationCompositionDefinition.class), any()); clearInvocations(acDefinitionProvider); + clearInvocations(participantSyncPublisher); acDefinition.setStateChangeResult(StateChangeResult.TIMEOUT); supervisionScanner.run(); // already in Timeout verify(acDefinitionProvider, times(0)).updateAcDefinitionState(any(), any(), any()); + verify(participantSyncPublisher, times(0)).sendSync(acDefinition, null); clearInvocations(acDefinitionProvider); + clearInvocations(participantSyncPublisher); // retry by the user acDefinition.setStateChangeResult(StateChangeResult.NO_ERROR); supervisionScanner.run(); // set Timeout verify(acDefinitionProvider).updateAcDefinitionState(acDefinition.getCompositionId(), acDefinition.getState(), StateChangeResult.TIMEOUT); + verify(participantSyncPublisher).sendSync(any(AutomationCompositionDefinition.class), any()); clearInvocations(acDefinitionProvider); for (var element : acDefinition.getElementStateMap().values()) { @@ -263,31 +269,38 @@ class SupervisionScannerTest { when(automationCompositionProvider.updateAcState(any())).thenReturn(automationComposition); var automationCompositionDeployPublisher = mock(AutomationCompositionDeployPublisher.class); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); + var participantSyncPublisher = mock(ParticipantSyncPublisher.class); var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1); // verify timeout scenario var scannerObj2 = new SupervisionScanner(automationCompositionProvider, createAcDefinitionProvider(), automationCompositionStateChangePublisher, automationCompositionDeployPublisher, - mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup); + participantSyncPublisher, null, acRuntimeParameterGroup); automationComposition.setStateChangeResult(StateChangeResult.NO_ERROR); automationComposition.setLastMsg(TimestampHelper.now()); scannerObj2.run(); - verify(automationCompositionProvider, times(1)).updateAcState(any(AutomationComposition.class)); + verify(automationCompositionProvider).updateAcState(any(AutomationComposition.class)); + verify(participantSyncPublisher).sendSync(any(ToscaServiceTemplate.class), any(AutomationComposition.class)); assertEquals(StateChangeResult.TIMEOUT, automationComposition.getStateChangeResult()); //already in TIMEOUT clearInvocations(automationCompositionProvider); + clearInvocations(participantSyncPublisher); scannerObj2.run(); verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class)); + verify(participantSyncPublisher, times(0)) + .sendSync(any(ToscaServiceTemplate.class), any(AutomationComposition.class)); clearInvocations(automationCompositionProvider); + clearInvocations(participantSyncPublisher); for (Map.Entry<UUID, AutomationCompositionElement> entry : automationComposition.getElements().entrySet()) { entry.getValue().setDeployState(DeployState.DEPLOYED); } scannerObj2.run(); - verify(automationCompositionProvider, times(1)).updateAcState(any(AutomationComposition.class)); + verify(automationCompositionProvider).updateAcState(any(AutomationComposition.class)); + verify(participantSyncPublisher).sendSync(any(ToscaServiceTemplate.class), any(AutomationComposition.class)); assertEquals(StateChangeResult.NO_ERROR, automationComposition.getStateChangeResult()); } |