aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/test
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2023-06-12 16:24:32 +0100
committerLiam Fallon <liam.fallon@est.tech>2023-06-15 14:41:50 +0000
commit28a9eeb00e7de39c611a4e7a2b847b77b785e5ed (patch)
tree6d25c65342cfb4b07688335124b539189629d9d5 /runtime-acm/src/test
parent444d286f337a6d067e0b7db92da61cc478d840bc (diff)
Add timeout for ACM operations
User can retry the ACM state change order when ACM operations time out. Issue-ID: POLICY-4716 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: Ie840fc13170ef235c6b6f3b26a47b7516f10296c (cherry picked from commit 1d1908528e67d9763482cf9d5921456f19af31e7)
Diffstat (limited to 'runtime-acm/src/test')
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java39
1 files changed, 39 insertions, 0 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 8ead9a7c0..7aaa6d22c 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
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVICE_TEMPLATE_YAML;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import org.junit.jupiter.api.BeforeAll;
@@ -40,6 +41,7 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionS
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
@@ -104,6 +106,7 @@ class SupervisionScannerTest {
verify(automationCompositionProvider).updateAutomationComposition(any(AutomationComposition.class));
}
+
@Test
void testScannerDelete() {
var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud");
@@ -145,6 +148,42 @@ class SupervisionScannerTest {
}
@Test
+ void testScannerForCounterHandling() {
+ var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud");
+ automationComposition.setDeployState(DeployState.DEPLOYING);
+ automationComposition.setLockState(LockState.NONE);
+ for (Map.Entry<UUID, AutomationCompositionElement> entry : automationComposition.getElements().entrySet()) {
+ entry.getValue().setDeployState(DeployState.DEPLOYING);
+ }
+ var automationCompositionProvider = mock(AutomationCompositionProvider.class);
+ when(automationCompositionProvider.getAcInstancesByCompositionId(compositionId))
+ .thenReturn(List.of(automationComposition));
+
+ var automationCompositionDeployPublisher = mock(AutomationCompositionDeployPublisher.class);
+ var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
+ var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
+ acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1);
+
+ //verify retry scenario
+ var scannerObj1 = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
+ automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
+ acRuntimeParameterGroup);
+
+ scannerObj1.run(true);
+ verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
+
+ //verify timeout scenario
+ acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().setMaxRetryCount(0);
+ var scannerObj2 = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
+ automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
+ acRuntimeParameterGroup);
+
+ scannerObj2.run(true);
+ verify(automationCompositionProvider, times(1)).updateAutomationComposition(any(AutomationComposition.class));
+
+ }
+
+ @Test
void testSendAutomationCompositionMsgUpdate() {
var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud");
automationComposition.setDeployState(DeployState.DEPLOYING);