diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-07-24 09:58:26 +0100 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-07-24 10:30:31 +0100 |
commit | d944ef408f099cbd5e3644e4abb37886d16c985e (patch) | |
tree | d2075f3612eca650a4bb92ed423ed88b68efafdf /runtime-acm/src | |
parent | a78d8dbecaca562d900858321e70c2a9fa064ec7 (diff) |
Add missing validation in Delete AC instance
Add missing validation in Delete AC instance
when deployState is in DELETING.
Fix send Heartbeat when "reportingTimeIntervalMs" is set to short time.
Issue-ID: POLICY-4773
Change-Id: Ia90902a68aadbde5c2bb63d093a2495f1a529571
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src')
2 files changed, 9 insertions, 1 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java index 710a975f0..84944e74c 100644..100755 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java @@ -35,6 +35,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; 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.concepts.NodeTemplateState; +import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AcInstanceStateUpdate; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider; @@ -254,6 +255,11 @@ public class AutomationCompositionInstantiationProvider { throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, "Automation composition state is still " + automationComposition.getDeployState()); } + if (DeployState.DELETING.equals(automationComposition.getDeployState()) + && StateChangeResult.NO_ERROR.equals(automationComposition.getStateChangeResult())) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, + "Automation composition state is still " + automationComposition.getDeployState()); + } if (automationComposition.getRestarting() != null) { throw new PfModelRuntimeException(Status.BAD_REQUEST, "There is a restarting process, Delete not allowed"); } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java index 3ac2efc1a..a59872f0a 100644..100755 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java @@ -44,6 +44,7 @@ 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.DeployState; import org.onap.policy.clamp.models.acm.concepts.LockState; +import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AcInstanceStateUpdate; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder; @@ -257,7 +258,7 @@ class AutomationCompositionInstantiationProviderTest { void testInstantiationDelete() { var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete"); - + automationComposition.setStateChangeResult(StateChangeResult.NO_ERROR); var acProvider = mock(AutomationCompositionProvider.class); var acDefinitionProvider = mock(AcDefinitionProvider.class); var supervisionAcHandler = mock(SupervisionAcHandler.class); @@ -278,6 +279,7 @@ class AutomationCompositionInstantiationProviderTest { assertThatDeleteThrownBy(automationComposition, DeployState.DEPLOYED, LockState.LOCKED); assertThatDeleteThrownBy(automationComposition, DeployState.DEPLOYING, LockState.NONE); assertThatDeleteThrownBy(automationComposition, DeployState.UNDEPLOYING, LockState.LOCKED); + assertThatDeleteThrownBy(automationComposition, DeployState.DELETING, LockState.NONE); automationComposition.setDeployState(DeployState.UNDEPLOYED); automationComposition.setLockState(LockState.NONE); |