diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-11-26 14:23:39 +0000 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2024-11-26 17:45:52 +0000 |
commit | 66ccb9814f2105b8c37a8ec47b9595fc09e4c5e7 (patch) | |
tree | 75099d312177d8e3080e13814e6063ac21fd0cf4 /runtime-acm | |
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 'runtime-acm')
2 files changed, 39 insertions, 1 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java index db67e5eea..de2f37564 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java @@ -173,7 +173,9 @@ public class SupervisionScanner { for (var element : automationComposition.getElements().values()) { var toscaNodeTemplate = serviceTemplate.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; defaultMin = Math.min(defaultMin, startPhase); defaultMax = Math.max(defaultMax, startPhase); if (AcmUtils.isInTransitionalState(element.getDeployState(), element.getLockState(), 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 17cc8ad3b..b425c4b80 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 @@ -339,6 +339,42 @@ class SupervisionScannerTest { } @Test + void testStartPhaseWithNull() { + var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud"); + automationComposition.setDeployState(DeployState.DEPLOYING); + automationComposition.setLockState(LockState.NONE); + automationComposition.setPhase(0); + automationComposition.setLastMsg(TimestampHelper.now()); + automationComposition.setCompositionId(compositionId); + for (var element : automationComposition.getElements().values()) { + if (ELEMENT_NAME.equals(element.getDefinition().getName())) { + element.setDeployState(DeployState.DEPLOYING); + element.getDefinition().setName("NotExistElement"); + element.setLockState(LockState.NONE); + } else { + element.setDeployState(DeployState.DEPLOYING); + element.getDefinition().setVersion("0.0.0"); + element.setLockState(LockState.NONE); + } + } + + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + when(automationCompositionProvider.getAcInstancesInTransition()).thenReturn(List.of(automationComposition)); + + var automationCompositionDeployPublisher = mock(AutomationCompositionDeployPublisher.class); + var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); + + var supervisionScanner = new SupervisionScanner(automationCompositionProvider, createAcDefinitionProvider(), + mock(AutomationCompositionStateChangePublisher.class), automationCompositionDeployPublisher, + mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup); + + supervisionScanner.run(); + + verify(automationCompositionDeployPublisher, times(0)).send(any(AutomationComposition.class), + any(ToscaServiceTemplate.class), anyInt(), anyBoolean()); + } + + @Test void testSendAutomationCompositionMigrate() { var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud"); automationComposition.setDeployState(DeployState.MIGRATING); |