diff options
author | 2024-11-26 14:23:39 +0000 | |
---|---|---|
committer | 2024-11-26 17:45:52 +0000 | |
commit | 66ccb9814f2105b8c37a8ec47b9595fc09e4c5e7 (patch) | |
tree | 75099d312177d8e3080e13814e6063ac21fd0cf4 /models | |
parent | 69486c769a936881a1d11d2ff1f0f11e7be7e9df (diff) |
Fix undeploy issue after migration failure in ACM-R
Issue-ID: POLICY-5177
Change-Id: Ic49dc15a9fd2a92f358eb60a440a8efb5080bbde
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models')
3 files changed, 44 insertions, 1 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java index 9c827d701..12c21f52c 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java @@ -48,7 +48,9 @@ public final class ParticipantUtils { for (var element : automationComposition.getElements().values()) { var toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates() .get(element.getDefinition().getName()); - int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties()); + int startPhase = toscaNodeTemplate != null + && element.getDefinition().getVersion().equals(toscaNodeTemplate.getVersion()) + ? ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties()) : 0; minStartPhase = Math.min(minStartPhase, startPhase); maxStartPhase = Math.max(maxStartPhase, startPhase); } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java index 7bffdd966..9239b3ae9 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java @@ -139,6 +139,8 @@ public class AcInstanceStateResolver { this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY); this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, + UNDEPLOYING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY); + this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, UPDATING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY); this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, MIGRATING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java index bac0842f1..9a8316cdb 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java @@ -67,6 +67,45 @@ class ParticipantUtilsTest { } @Test + void testGetFirstStartPhaseWithNull() throws CoderException { + var serviceTemplate = CommonTestData.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML); + var automationComposition = + CODER.decode(ResourceUtils.getResourceAsString(AUTOMATION_COMPOSITION_JSON), AutomationCompositions.class) + .getAutomationCompositionList().get(0); + automationComposition.setDeployState(DeployState.DEPLOYING); + automationComposition.setLockState(LockState.NONE); + + serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().values() + .forEach(node -> node.setVersion("0.0.0")); + var result = ParticipantUtils.getFirstStartPhase(automationComposition, serviceTemplate); + assertThat(result).isZero(); + + automationComposition.setDeployState(DeployState.DEPLOYED); + automationComposition.setLockState(LockState.UNLOCKING); + result = ParticipantUtils.getFirstStartPhase(automationComposition, serviceTemplate); + assertThat(result).isZero(); + + automationComposition.setDeployState(DeployState.UNDEPLOYING); + automationComposition.setLockState(LockState.NONE); + result = ParticipantUtils.getFirstStartPhase(automationComposition, serviceTemplate); + assertThat(result).isZero(); + + serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().clear(); + result = ParticipantUtils.getFirstStartPhase(automationComposition, serviceTemplate); + assertThat(result).isZero(); + + automationComposition.setDeployState(DeployState.DEPLOYED); + automationComposition.setLockState(LockState.UNLOCKING); + result = ParticipantUtils.getFirstStartPhase(automationComposition, serviceTemplate); + assertThat(result).isZero(); + + automationComposition.setDeployState(DeployState.UNDEPLOYING); + automationComposition.setLockState(LockState.NONE); + result = ParticipantUtils.getFirstStartPhase(automationComposition, serviceTemplate); + assertThat(result).isZero(); + } + + @Test void testGetFirstStage() throws CoderException { var serviceTemplate = CommonTestData.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML); var automationCompositions = |