aboutsummaryrefslogtreecommitdiffstats
path: root/participant
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2024-11-25 14:20:44 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2024-11-25 16:43:16 +0000
commit69486c769a936881a1d11d2ff1f0f11e7be7e9df (patch)
tree8f28c388d48fe19da559d6ae07b68a9915a851f1 /participant
parentcf733e17a5abe9bc8378a33eeadc1b541a4713a4 (diff)
Fix issue after fail scenario in ACM-intermediary
Issue-ID: POLICY-5173 Change-Id: I8a6c4ca0650935c5e651c5d9274a082d7707f99b Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java14
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java24
2 files changed, 34 insertions, 4 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java
index 7cf83db9d..d9f2b7acd 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java
@@ -162,10 +162,10 @@ public class AutomationCompositionOutHandler {
LOGGER.warn("SubState has always NO_ERROR result!");
}
} else if (deployState != null) {
- handleDeployState(automationComposition, element, deployState);
+ handleDeployState(automationComposition, element, deployState, stateChangeResult);
}
if (lockState != null) {
- handleLockState(automationComposition, element, lockState);
+ handleLockState(automationComposition, element, lockState, stateChangeResult);
}
var automationCompositionStateChangeAck =
@@ -186,9 +186,12 @@ public class AutomationCompositionOutHandler {
}
private void handleDeployState(AutomationComposition automationComposition, AutomationCompositionElement element,
- DeployState deployState) {
+ DeployState deployState, StateChangeResult stateChangeResult) {
element.setDeployState(deployState);
element.setLockState(DeployState.DEPLOYED.equals(element.getDeployState()) ? LockState.LOCKED : LockState.NONE);
+ if (StateChangeResult.FAILED.equals(stateChangeResult)) {
+ return;
+ }
var checkOpt = automationComposition.getElements().values().stream()
.filter(acElement -> !deployState.equals(acElement.getDeployState())).findAny();
if (checkOpt.isEmpty()) {
@@ -209,8 +212,11 @@ public class AutomationCompositionOutHandler {
}
private void handleLockState(AutomationComposition automationComposition, AutomationCompositionElement element,
- LockState lockState) {
+ LockState lockState, StateChangeResult stateChangeResult) {
element.setLockState(lockState);
+ if (StateChangeResult.FAILED.equals(stateChangeResult)) {
+ return;
+ }
var checkOpt = automationComposition.getElements().values().stream()
.filter(acElement -> !lockState.equals(acElement.getLockState())).findAny();
if (checkOpt.isEmpty()) {
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java
index 202f25c6f..ce62fcb6d 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java
@@ -311,4 +311,28 @@ class AutomationCompositionOutHandlerTest {
.sendAutomationCompositionAck(any(AutomationCompositionDeployAck.class));
assertEquals(compositionTarget, automationComposition.getCompositionId());
}
+
+ @Test
+ void updateFailMigrationTest() {
+ var cacheProvider = mock(CacheProvider.class);
+ when(cacheProvider.getParticipantId()).thenReturn(UUID.randomUUID());
+ var publisher = mock(ParticipantMessagePublisher.class);
+ var acOutHandler = new AutomationCompositionOutHandler(publisher, cacheProvider);
+
+ var automationComposition = CommonTestData.getTestAutomationCompositionMap().values().iterator().next();
+ when(cacheProvider.getAutomationComposition(automationComposition.getInstanceId()))
+ .thenReturn(automationComposition);
+
+ automationComposition.setCompositionTargetId(UUID.randomUUID());
+ automationComposition.setDeployState(DeployState.MIGRATING);
+ var compositionId = automationComposition.getCompositionId();
+ for (var element : automationComposition.getElements().values()) {
+ element.setDeployState(DeployState.MIGRATING);
+ acOutHandler.updateAutomationCompositionElementState(automationComposition.getInstanceId(),
+ element.getId(), DeployState.DEPLOYED, null, StateChangeResult.FAILED, "");
+ }
+ verify(publisher, times(automationComposition.getElements().size()))
+ .sendAutomationCompositionAck(any(AutomationCompositionDeployAck.class));
+ assertEquals(compositionId, automationComposition.getCompositionId());
+ }
}