aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2024-11-26 14:23:39 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2024-11-26 17:45:52 +0000
commit66ccb9814f2105b8c37a8ec47b9595fc09e4c5e7 (patch)
tree75099d312177d8e3080e13814e6063ac21fd0cf4 /runtime-acm
parent69486c769a936881a1d11d2ff1f0f11e7be7e9df (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')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java4
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java36
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);