diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-09-05 09:08:15 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2024-09-05 09:39:43 +0000 |
commit | abe1caac52206d5fb5d6861bd0f55bb6407b15dc (patch) | |
tree | 6f2e5ffb969090acb2f65aadf056266858dc2247 | |
parent | 7c5744fecbc2067e800cd3bc90acac0e44318ada (diff) |
Remove restart reference in ACM-runtime
Restart has been replaced in ACM by sync messages, and
there are still some java code that should be removed
around the old restart scenario implementation.
Issue-ID: POLICY-5125
Change-Id: Iffbd228fb352f1d53a2e9de24b061bccbc9dfea9
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
22 files changed, 48 insertions, 533 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java index 005d8a147..61610bb47 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java @@ -44,8 +44,6 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut private UUID compositionTargetId; - private Boolean restarting; - private Boolean precheck; @NonNull @@ -75,7 +73,6 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut this.instanceId = otherAutomationComposition.instanceId; this.compositionId = otherAutomationComposition.compositionId; this.compositionTargetId = otherAutomationComposition.compositionTargetId; - this.restarting = otherAutomationComposition.restarting; this.precheck = otherAutomationComposition.precheck; this.deployState = otherAutomationComposition.deployState; this.lockState = otherAutomationComposition.lockState; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java index 987cb8832..57b6837af 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java @@ -41,8 +41,6 @@ public class AutomationCompositionDefinition { @NonNull private ToscaServiceTemplate serviceTemplate; - private Boolean restarting; - @NonNull private AcTypeState state; @@ -63,7 +61,6 @@ public class AutomationCompositionDefinition { public AutomationCompositionDefinition(final AutomationCompositionDefinition otherAcmDefinition) { this.compositionId = otherAcmDefinition.compositionId; this.serviceTemplate = new ToscaServiceTemplate(otherAcmDefinition.serviceTemplate); - this.restarting = otherAcmDefinition.restarting; this.state = otherAcmDefinition.state; this.lastMsg = otherAcmDefinition.lastMsg; this.elementStateMap = PfUtils.mapMap(otherAcmDefinition.elementStateMap, NodeTemplateState::new); diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java deleted file mode 100644 index ff9755ec1..000000000 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2023-2024 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.models.acm.messages.kafka.participant; - -import java.util.ArrayList; -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.models.acm.concepts.AcTypeState; -import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; -import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc; -import org.onap.policy.models.base.PfUtils; - -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantRestart extends ParticipantMessage { - - // composition state - private AcTypeState state; - - // element definition - private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>(); - - // automation composition instances list - private List<ParticipantRestartAc> automationcompositionList = new ArrayList<>(); - - /** - * Constructor. - */ - public ParticipantRestart() { - super(ParticipantMessageType.PARTICIPANT_RESTART); - } - - /** - * Constructor with message type. - * @param messageType messageType - */ - public ParticipantRestart(ParticipantMessageType messageType) { - super(messageType); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantRestart(ParticipantRestart source) { - super(source); - this.state = source.state; - this.participantDefinitionUpdates = - PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new); - this.automationcompositionList = PfUtils.mapList(source.automationcompositionList, ParticipantRestartAc::new); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java index 962b6137c..85b715b86 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java @@ -20,17 +20,32 @@ package org.onap.policy.clamp.models.acm.messages.kafka.participant; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.UUID; import lombok.Getter; import lombok.Setter; import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.AcTypeState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc; +import org.onap.policy.models.base.PfUtils; @Getter @Setter @ToString(callSuper = true) -public class ParticipantSync extends ParticipantRestart { +public class ParticipantSync extends ParticipantMessage { + + // composition state + private AcTypeState state; + + // element definition + private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>(); + + // automation composition instances list + private List<ParticipantRestartAc> automationcompositionList = new ArrayList<>(); private Set<UUID> excludeReplicas = new HashSet<>(); private boolean restarting = false; @@ -50,6 +65,10 @@ public class ParticipantSync extends ParticipantRestart { */ public ParticipantSync(ParticipantSync source) { super(source); + this.state = source.state; + this.participantDefinitionUpdates = + PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new); + this.automationcompositionList = PfUtils.mapList(source.automationcompositionList, ParticipantRestartAc::new); this.excludeReplicas = new HashSet<>(source.excludeReplicas); this.restarting = source.restarting; this.delete = source.delete; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java index 1f4768ea8..001f2e7f3 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java @@ -87,9 +87,6 @@ public class JpaAutomationComposition extends Validated private String compositionTargetId; @Column - private Boolean restarting; - - @Column @NotNull private DeployState deployState; @@ -163,7 +160,6 @@ public class JpaAutomationComposition extends Validated this.version = copyConcept.version; this.compositionId = copyConcept.compositionId; this.compositionTargetId = copyConcept.compositionTargetId; - this.restarting = copyConcept.restarting; this.deployState = copyConcept.deployState; this.lockState = copyConcept.lockState; this.lastMsg = copyConcept.lastMsg; @@ -194,7 +190,6 @@ public class JpaAutomationComposition extends Validated if (compositionTargetId != null) { automationComposition.setCompositionTargetId(UUID.fromString(compositionTargetId)); } - automationComposition.setRestarting(restarting); automationComposition.setDeployState(deployState); automationComposition.setLockState(lockState); automationComposition.setLastMsg(lastMsg.toString()); @@ -235,7 +230,6 @@ public class JpaAutomationComposition extends Validated if (automationComposition.getCompositionTargetId() != null) { this.compositionTargetId = automationComposition.getCompositionTargetId().toString(); } - this.restarting = automationComposition.getRestarting(); this.deployState = automationComposition.getDeployState(); this.lockState = automationComposition.getLockState(); this.lastMsg = TimestampHelper.toTimestamp(automationComposition.getLastMsg()); @@ -289,11 +283,6 @@ public class JpaAutomationComposition extends Validated return result; } - result = ObjectUtils.compare(restarting, other.restarting); - if (result != 0) { - return result; - } - result = ObjectUtils.compare(deployState, other.deployState); if (result != 0) { return result; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java index 1cab89d5d..3d61c4ed9 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java @@ -79,9 +79,6 @@ public class JpaAutomationCompositionDefinition extends Validated private String version; @Column - private Boolean restarting; - - @Column @NotNull private AcTypeState state; @@ -107,7 +104,6 @@ public class JpaAutomationCompositionDefinition extends Validated public AutomationCompositionDefinition toAuthorative() { var acmDefinition = new AutomationCompositionDefinition(); acmDefinition.setCompositionId(UUID.fromString(this.compositionId)); - acmDefinition.setRestarting(this.restarting); acmDefinition.setState(this.state); acmDefinition.setStateChangeResult(this.stateChangeResult); acmDefinition.setLastMsg(this.lastMsg.toString()); @@ -122,7 +118,6 @@ public class JpaAutomationCompositionDefinition extends Validated @Override public void fromAuthorative(final AutomationCompositionDefinition copyConcept) { this.compositionId = copyConcept.getCompositionId().toString(); - this.restarting = copyConcept.getRestarting(); this.state = copyConcept.getState(); this.stateChangeResult = copyConcept.getStateChangeResult(); this.lastMsg = TimestampHelper.toTimestamp(copyConcept.getLastMsg()); diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java index 46b43f950..bb05c46c6 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java @@ -138,10 +138,8 @@ public class AcDefinitionProvider { * @param compositionId The UUID of the automation composition definition to update * @param state the AcTypeState * @param stateChangeResult the StateChangeResult - * @param restarting restarting process */ - public void updateAcDefinitionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult, - Boolean restarting) { + public void updateAcDefinitionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult) { var jpaUpdate = acmDefinitionRepository.findById(compositionId.toString()); if (jpaUpdate.isEmpty()) { String errorMessage = "update of Automation Composition Definition \"" + compositionId @@ -151,7 +149,6 @@ public class AcDefinitionProvider { var acDefinition = jpaUpdate.get(); acDefinition.setState(state); acDefinition.setStateChangeResult(stateChangeResult); - acDefinition.setRestarting(restarting); acmDefinitionRepository.save(acDefinition); acmDefinitionRepository.flush(); } diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java deleted file mode 100644 index 95b718e68..000000000 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2023-2024 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.models.acm.messages.kafka.participant; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageUtils.removeVariableFields; - -import java.time.Instant; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.models.acm.concepts.AcElementRestart; -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.ParticipantDefinition; -import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc; -import org.onap.policy.clamp.models.acm.utils.CommonTestData; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantRestartTest { - - @Test - void testCopyConstructor() throws CoderException { - - final var orig = new ParticipantRestart(); - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantRestart(orig).toString())); - - orig.setMessageId(UUID.randomUUID()); - orig.setCompositionId(UUID.randomUUID()); - orig.setTimestamp(Instant.ofEpochMilli(3000)); - orig.setParticipantId(CommonTestData.getParticipantId()); - - var participantDefinitionUpdate = new ParticipantDefinition(); - var type = new ToscaConceptIdentifier("id", "1.2.3"); - var acDefinition = CommonTestData.getAcElementDefinition(type); - participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition)); - orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate)); - - var acElement = new AcElementRestart(); - acElement.setId(UUID.randomUUID()); - var id = new ToscaConceptIdentifier("id", "1.2.3"); - acElement.setDefinition(id); - acElement.setDeployState(DeployState.DEPLOYED); - acElement.setLockState(LockState.LOCKED); - acElement.setOperationalState("OperationalState"); - acElement.setUseState("UseState"); - acElement.setProperties(Map.of("key", "value")); - acElement.setOutProperties(Map.of("keyOut", "valueOut")); - - var acRestart = new ParticipantRestartAc(); - acRestart.setAcElementList(List.of(acElement)); - acRestart.setAutomationCompositionId(UUID.randomUUID()); - - orig.setAutomationcompositionList(List.of(acRestart)); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantRestart(orig).toString())); - - assertSerializable(orig, ParticipantRestart.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java index 541e9ba6f..38153d488 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java @@ -213,11 +213,6 @@ class JpaAutomationCompositionTest { jpaAutomationComposition.setDescription(null); assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); - jpaAutomationComposition.setRestarting(true); - assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); - jpaAutomationComposition.setRestarting(null); - assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); - jpaAutomationComposition.setStateChangeResult(StateChangeResult.NO_ERROR); assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); jpaAutomationComposition.setStateChangeResult(null); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java index 85dadc3de..95811917d 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java @@ -83,7 +83,7 @@ class AcDefinitionProviderTest { .hasMessageStartingWith("\"AutomationCompositionDefinition\" INVALID, item has status INVALID"); assertThatThrownBy(() -> acDefinitionProvider.updateAcDefinitionState(compositionId, AcTypeState.PRIMED, - StateChangeResult.NO_ERROR, false)) + StateChangeResult.NO_ERROR)) .hasMessageStartingWith("update of Automation Composition Definition"); } @@ -195,7 +195,7 @@ class AcDefinitionProviderTest { when(acmDefinitionRepository.findById(acmDefinition.getCompositionId().toString())) .thenReturn(Optional.of(jpa)); acDefinitionProvider.updateAcDefinitionState(acmDefinition.getCompositionId(), AcTypeState.PRIMED, - StateChangeResult.NO_ERROR, false); + StateChangeResult.NO_ERROR); verify(acmDefinitionRepository).save(jpa); } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java index 8a56fbb1e..48b139495 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java @@ -188,10 +188,6 @@ public class CommissioningProvider { throw new PfModelRuntimeException(Status.BAD_REQUEST, "There are instances, Priming/Depriming not allowed"); } var acmDefinition = acDefinitionProvider.getAcDefinition(compositionId); - if (acmDefinition.getRestarting() != null) { - throw new PfModelRuntimeException(Status.BAD_REQUEST, - "There is a restarting process, Priming/Depriming not allowed"); - } var stateOrdered = acTypeStateResolver.resolve(acTypeStateUpdate.getPrimeOrder(), acmDefinition.getState(), acmDefinition.getStateChangeResult()); switch (stateOrdered) { 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 867148d8b..42af70596 100644 --- 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 @@ -144,10 +144,6 @@ public class AutomationCompositionInstantiationProvider { } - if (automationComposition.getRestarting() != null) { - throw new PfModelRuntimeException(Status.BAD_REQUEST, "There is a restarting process, Update not allowed"); - } - var deployOrder = DeployOrder.UPDATE; var subOrder = SubOrder.NONE; @@ -336,12 +332,6 @@ public class AutomationCompositionInstantiationProvider { ValidationStatus.INVALID, "Commissioned automation composition definition not primed")); return result; } - if (acDefinitionOpt.get().getRestarting() != null) { - result.addResult( - new ObjectValidationResult("ServiceTemplate.restarting", acDefinitionOpt.get().getRestarting(), - ValidationStatus.INVALID, "There is a restarting process in composition")); - return result; - } var participantIds = acDefinitionOpt.get().getElementStateMap().values().stream() .map(NodeTemplateState::getParticipantId).collect(Collectors.toSet()); @@ -405,9 +395,6 @@ public class AutomationCompositionInstantiationProvider { throw new PfModelRuntimeException(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"); - } var acDefinition = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId()); var participantIds = acDefinition.getElementStateMap().values().stream() .map(NodeTemplateState::getParticipantId).collect(Collectors.toSet()); diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java index 95294285e..f13f5da2c 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java @@ -114,7 +114,7 @@ public class SupervisionHandler { } if (toUpdate) { acDefinitionProvider.updateAcDefinitionState(acDefinition.getCompositionId(), acDefinition.getState(), - acDefinition.getStateChangeResult(), null); + acDefinition.getStateChangeResult()); if (!participantPrimeAckMessage.getParticipantId().equals(participantPrimeAckMessage.getReplicaId())) { participantSyncPublisher.sendSync(acDefinition, participantPrimeAckMessage.getReplicaId()); } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java index 3c93a3571..ea3ef0ff7 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java @@ -30,7 +30,6 @@ import org.apache.commons.collections4.MapUtils; import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher; -import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRestartPublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantSyncPublisher; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; @@ -40,7 +39,6 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; import org.onap.policy.clamp.models.acm.concepts.ParticipantReplica; import org.onap.policy.clamp.models.acm.concepts.ParticipantState; import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType; -import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantDeregister; import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantRegister; import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantStatus; @@ -65,7 +63,6 @@ public class SupervisionParticipantHandler { private final ParticipantDeregisterAckPublisher participantDeregisterAckPublisher; private final AutomationCompositionProvider automationCompositionProvider; private final AcDefinitionProvider acDefinitionProvider; - private final ParticipantRestartPublisher participantRestartPublisher; private final ParticipantSyncPublisher participantSyncPublisher; private final AcRuntimeParameterGroup acRuntimeParameterGroup; @@ -183,61 +180,11 @@ public class SupervisionParticipantHandler { private void handleRestart(UUID participantId, UUID replicaId) { var compositionIds = participantProvider.getCompositionIds(participantId); - var oldParticipant = participantId.equals(replicaId); for (var compositionId : compositionIds) { var acDefinition = acDefinitionProvider.getAcDefinition(compositionId); LOGGER.debug("Scan Composition {} for restart", acDefinition.getCompositionId()); - if (oldParticipant) { - handleRestart(participantId, acDefinition); - } else { - handleSyncRestart(participantId, replicaId, acDefinition); - } - } - } - - private void handleRestart(final UUID participantId, AutomationCompositionDefinition acDefinition) { - if (AcTypeState.COMMISSIONED.equals(acDefinition.getState())) { - LOGGER.debug("Composition {} COMMISSIONED", acDefinition.getCompositionId()); - return; - } - LOGGER.debug("Composition to be send in Restart message {}", acDefinition.getCompositionId()); - for (var elementState : acDefinition.getElementStateMap().values()) { - if (participantId.equals(elementState.getParticipantId())) { - elementState.setRestarting(true); - } - } - // expected final state - if (StateChangeResult.TIMEOUT.equals(acDefinition.getStateChangeResult())) { - acDefinition.setStateChangeResult(StateChangeResult.NO_ERROR); - } - acDefinition.setRestarting(true); - acDefinitionProvider.updateAcDefinition(acDefinition, - acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()); - - var automationCompositionList = - automationCompositionProvider.getAcInstancesByCompositionId(acDefinition.getCompositionId()); - var automationCompositions = automationCompositionList.stream() - .filter(ac -> isAcToBeRestarted(participantId, ac)).toList(); - participantRestartPublisher.send(participantId, acDefinition, automationCompositions); - } - - private boolean isAcToBeRestarted(UUID participantId, AutomationComposition automationComposition) { - boolean toAdd = false; - for (var element : automationComposition.getElements().values()) { - if (participantId.equals(element.getParticipantId())) { - element.setRestarting(true); - toAdd = true; - } - } - if (toAdd) { - automationComposition.setRestarting(true); - // expected final state - if (StateChangeResult.TIMEOUT.equals(automationComposition.getStateChangeResult())) { - automationComposition.setStateChangeResult(StateChangeResult.NO_ERROR); - } - automationCompositionProvider.updateAutomationComposition(automationComposition); + handleSyncRestart(participantId, replicaId, acDefinition); } - return toAdd; } private void handleSyncRestart(final UUID participantId, UUID replicaId, 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 d746b331f..c4cebb430 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 @@ -126,7 +126,7 @@ public class SupervisionScanner { } if (completed) { acDefinitionProvider.updateAcDefinitionState(acDefinition.getCompositionId(), finalState, - StateChangeResult.NO_ERROR, null); + StateChangeResult.NO_ERROR); participantSyncPublisher.sendSync(acDefinition, null); } else { handleTimeout(acDefinition); @@ -299,7 +299,7 @@ public class SupervisionScanner { LOGGER.debug("Report timeout for the ac definition {}", acDefinition.getCompositionId()); acDefinition.setStateChangeResult(StateChangeResult.TIMEOUT); acDefinitionProvider.updateAcDefinitionState(acDefinition.getCompositionId(), - acDefinition.getState(), acDefinition.getStateChangeResult(), acDefinition.getRestarting()); + acDefinition.getState(), acDefinition.getStateChangeResult()); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java deleted file mode 100644 index 540cf62be..000000000 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2023-2024 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.acm.runtime.supervision.comm; - -import io.micrometer.core.annotation.Timed; -import java.time.Instant; -import java.util.List; -import java.util.UUID; -import lombok.AllArgsConstructor; -import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; -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.messages.kafka.participant.ParticipantRestart; -import org.onap.policy.clamp.models.acm.utils.AcmUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component -@AllArgsConstructor -public class ParticipantRestartPublisher extends AbstractParticipantPublisher<ParticipantRestart> { - - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantRestartPublisher.class); - private final AcRuntimeParameterGroup acRuntimeParameterGroup; - - /** - * Send Restart to Participant. - * - * @param participantId the ParticipantId - * @param acmDefinition the AutomationComposition Definition - * @param automationCompositions the list of automationCompositions - */ - @Timed(value = "publisher.participant_restart", description = "Participant Restart published") - public void send(UUID participantId, AutomationCompositionDefinition acmDefinition, - List<AutomationComposition> automationCompositions) { - - var message = new ParticipantRestart(); - message.setParticipantId(participantId); - message.setCompositionId(acmDefinition.getCompositionId()); - message.setMessageId(UUID.randomUUID()); - message.setTimestamp(Instant.now()); - message.setState(acmDefinition.getState()); - message.setParticipantDefinitionUpdates( - AcmUtils.prepareParticipantRestarting(participantId, acmDefinition, - acRuntimeParameterGroup.getAcmParameters().getToscaElementName())); - var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(acmDefinition.getServiceTemplate()); - - for (var automationComposition : automationCompositions) { - var restartAc = AcmUtils - .createAcRestart(automationComposition, participantId, toscaServiceTemplateFragment); - message.getAutomationcompositionList().add(restartAc); - } - - LOGGER.debug("Participant Restart sent {}", message.getMessageId()); - super.send(message); - } -} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java index e001d91bc..8c76baef7 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java @@ -233,22 +233,4 @@ class CommissioningProviderTest { assertThatThrownBy(() -> provider.deleteAutomationCompositionDefinition(compositionId)) .hasMessageMatching("ACM not in COMMISSIONED state, Delete of ACM Definition not allowed"); } - - @Test - void testPrimingBadRequest() { - var acDefinitionProvider = mock(AcDefinitionProvider.class); - var toscaServiceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); - var acmDefinition = CommonTestData.createAcDefinition(toscaServiceTemplate, AcTypeState.PRIMED); - acmDefinition.setRestarting(true); - var compositionId = acmDefinition.getCompositionId(); - when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition); - - var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - mock(ParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class), - mock(AcRuntimeParameterGroup.class)); - - var acTypeStateUpdate = new AcTypeStateUpdate(); - assertThatThrownBy(() -> provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate)) - .hasMessageMatching("There is a restarting process, Priming/Depriming 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 90633e706..21ad2f616 100644 --- 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 @@ -231,75 +231,6 @@ class AutomationCompositionInstantiationProviderTest { } @Test - void testUpdateRestartedBadRequest() { - var automationCompositionUpdate = - InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Crud"); - automationCompositionUpdate.setDeployState(DeployState.DEPLOYED); - automationCompositionUpdate.setLockState(LockState.LOCKED); - automationCompositionUpdate.setRestarting(true); - var acProvider = mock(AutomationCompositionProvider.class); - when(acProvider.getAutomationComposition(automationCompositionUpdate.getInstanceId())) - .thenReturn(automationCompositionUpdate); - - var instantiationProvider = - new AutomationCompositionInstantiationProvider(acProvider, mock(AcDefinitionProvider.class), null, - mock(SupervisionAcHandler.class), mock(ParticipantProvider.class), - mock(AcRuntimeParameterGroup.class)); - - var compositionId = automationCompositionUpdate.getCompositionId(); - assertThatThrownBy( - () -> instantiationProvider.updateAutomationComposition(compositionId, automationCompositionUpdate)) - .hasMessageMatching("There is a restarting process, Update not allowed"); - - automationCompositionUpdate.setCompositionTargetId(UUID.randomUUID()); - assertThatThrownBy( - () -> instantiationProvider.updateAutomationComposition(compositionId, automationCompositionUpdate)) - .hasMessageMatching("There is a restarting process, Update not allowed"); - - automationCompositionUpdate.setDeployState(DeployState.UNDEPLOYED); - automationCompositionUpdate.setLockState(LockState.NONE); - - var instanceId = automationCompositionUpdate.getInstanceId(); - assertThatThrownBy(() -> instantiationProvider.deleteAutomationComposition(compositionId, instanceId)) - .hasMessageMatching("There is a restarting process, Delete not allowed"); - } - - @Test - void testUpdateCompositionRestartedBadRequest() { - var acDefinitionProvider = mock(AcDefinitionProvider.class); - var acDefinition = CommonTestData.createAcDefinition(serviceTemplate, AcTypeState.PRIMED); - acDefinition.setRestarting(true); - var compositionId = acDefinition.getCompositionId(); - when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(acDefinition)); - - var automationCompositionUpdate = - InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Crud"); - automationCompositionUpdate.setCompositionId(compositionId); - automationCompositionUpdate.setDeployState(DeployState.DEPLOYED); - automationCompositionUpdate.setLockState(LockState.LOCKED); - var acProvider = mock(AutomationCompositionProvider.class); - when(acProvider.getAutomationComposition(automationCompositionUpdate.getInstanceId())) - .thenReturn(automationCompositionUpdate); - when(acProvider.updateAutomationComposition(automationCompositionUpdate)) - .thenReturn(automationCompositionUpdate); - - var supervisionAcHandler = mock(SupervisionAcHandler.class); - var participantProvider = mock(ParticipantProvider.class); - var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, - new AcInstanceStateResolver(), supervisionAcHandler, participantProvider, - mock(AcRuntimeParameterGroup.class)); - var message = - """ - "AutomationComposition" INVALID, item has status INVALID - item "ServiceTemplate.restarting" value "true" INVALID, There is a restarting process in composition - """; - - assertThatThrownBy( - () -> instantiationProvider.updateAutomationComposition(compositionId, automationCompositionUpdate)) - .hasMessageMatching(message); - } - - @Test void testMigrationAddRemoveElements() { var acDefinitionProvider = mock(AcDefinitionProvider.class); var acDefinition = CommonTestData.createAcDefinition(serviceTemplate, AcTypeState.PRIMED); diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java index e689e6467..09a79d890 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java @@ -130,7 +130,7 @@ class SupervisionHandlerTest { verify(acDefinitionProvider, times(acDefinition.getElementStateMap().size())) .updateAcDefinitionElement(any(), any()); verify(acDefinitionProvider).updateAcDefinitionState(acDefinition.getCompositionId(), AcTypeState.PRIMED, - StateChangeResult.NO_ERROR, null); + StateChangeResult.NO_ERROR); } @Test @@ -156,6 +156,6 @@ class SupervisionHandlerTest { verify(acDefinitionProvider).findAcDefinition(any()); verify(acDefinitionProvider).updateAcDefinitionElement(any(), any()); verify(acDefinitionProvider).updateAcDefinitionState(acDefinition.getCompositionId(), AcTypeState.PRIMING, - StateChangeResult.FAILED, null); + StateChangeResult.FAILED); } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java index 932529d79..aab1a1ceb 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java @@ -37,7 +37,6 @@ import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher; -import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRestartPublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantSyncPublisher; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; @@ -77,8 +76,8 @@ class SupervisionParticipantHandlerTest { var handler = new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class), participantDeregisterAckPublisher, mock(AutomationCompositionProvider.class), - mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class), - mock(ParticipantSyncPublisher.class), mock(AcRuntimeParameterGroup.class)); + mock(AcDefinitionProvider.class), mock(ParticipantSyncPublisher.class), + mock(AcRuntimeParameterGroup.class)); handler.handleParticipantMessage(participantDeregisterMessage); @@ -98,8 +97,8 @@ class SupervisionParticipantHandlerTest { var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class); var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher, mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionProvider.class), - mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class), - mock(ParticipantSyncPublisher.class), mock(AcRuntimeParameterGroup.class)); + mock(AcDefinitionProvider.class), mock(ParticipantSyncPublisher.class), + mock(AcRuntimeParameterGroup.class)); handler.handleParticipantMessage(participantRegisterMessage); verify(participantProvider).saveParticipant(any()); @@ -108,64 +107,6 @@ class SupervisionParticipantHandlerTest { } @Test - void testHandleParticipantRestart() { - var participantRegisterMessage = new ParticipantRegister(); - participantRegisterMessage.setMessageId(UUID.randomUUID()); - var participantId = CommonTestData.getParticipantId(); - participantRegisterMessage.setParticipantId(participantId); - participantRegisterMessage.setReplicaId(participantId); - var supportedElementType = CommonTestData.createParticipantSupportedElementType(); - participantRegisterMessage.setParticipantSupportedElementType(List.of(supportedElementType)); - - var participant = new Participant(); - var replica = new ParticipantReplica(); - replica.setReplicaId(participantId); - participant.setParticipantId(participantId); - participant.getReplicas().put(replica.getReplicaId(), replica); - var participantProvider = mock(ParticipantProvider.class); - when(participantProvider.findParticipant(participantId)).thenReturn(Optional.of(participant)); - when(participantProvider.findParticipantReplica(participantId)).thenReturn(Optional.of(replica)); - var compositionId = UUID.randomUUID(); - var composition2Id = UUID.randomUUID(); - when(participantProvider.getCompositionIds(participantId)).thenReturn(Set.of(compositionId, composition2Id)); - - var acDefinitionProvider = mock(AcDefinitionProvider.class); - var acDefinition = new AutomationCompositionDefinition(); - acDefinition.setState(AcTypeState.COMMISSIONED); - acDefinition.setCompositionId(composition2Id); - when(acDefinitionProvider.getAcDefinition(composition2Id)).thenReturn(acDefinition); - - acDefinition = new AutomationCompositionDefinition(); - acDefinition.setCompositionId(compositionId); - acDefinition.setState(AcTypeState.PRIMED); - var nodeTemplateState = new NodeTemplateState(); - nodeTemplateState.setParticipantId(participantId); - acDefinition.setElementStateMap(Map.of("code", nodeTemplateState)); - when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acDefinition); - - var automationComposition = - InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); - automationComposition.getElements().values().iterator().next().setParticipantId(participantId); - var automationCompositionProvider = mock(AutomationCompositionProvider.class); - when(automationCompositionProvider.getAcInstancesByCompositionId(compositionId)) - .thenReturn(List.of(automationComposition)); - - var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class); - var participantRestartPublisher = mock(ParticipantRestartPublisher.class); - var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher, - mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider, acDefinitionProvider, - participantRestartPublisher, mock(ParticipantSyncPublisher.class), - CommonTestData.getTestParamaterGroup()); - handler.handleParticipantMessage(participantRegisterMessage); - - verify(participantRegisterAckPublisher) - .send(participantRegisterMessage.getMessageId(), participantId, participantId); - verify(acDefinitionProvider).updateAcDefinition(any(AutomationCompositionDefinition.class), - eq(CommonTestData.TOSCA_COMP_NAME)); - verify(participantRestartPublisher).send(any(), any(AutomationCompositionDefinition.class), any()); - } - - @Test void testHandleParticipantSyncRestart() { var participantRegisterMessage = new ParticipantRegister(); participantRegisterMessage.setMessageId(UUID.randomUUID()); @@ -213,8 +154,7 @@ class SupervisionParticipantHandlerTest { var participantSyncPublisher = mock(ParticipantSyncPublisher.class); var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher, mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider, acDefinitionProvider, - mock(ParticipantRestartPublisher.class), participantSyncPublisher, - CommonTestData.getTestParamaterGroup()); + participantSyncPublisher, CommonTestData.getTestParamaterGroup()); handler.handleParticipantMessage(participantRegisterMessage); verify(participantRegisterAckPublisher) @@ -235,8 +175,8 @@ class SupervisionParticipantHandlerTest { var handler = new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider, - mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class), - mock(ParticipantSyncPublisher.class), mock(AcRuntimeParameterGroup.class)); + mock(AcDefinitionProvider.class), mock(ParticipantSyncPublisher.class), + mock(AcRuntimeParameterGroup.class)); var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId()); when(participantProvider.findParticipant(CommonTestData.getParticipantId())) .thenReturn(Optional.of(participant)); @@ -271,8 +211,8 @@ class SupervisionParticipantHandlerTest { var handler = new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionProvider.class), - acDefinitionProvider, mock(ParticipantRestartPublisher.class), - mock(ParticipantSyncPublisher.class), CommonTestData.getTestParamaterGroup()); + acDefinitionProvider, mock(ParticipantSyncPublisher.class), + CommonTestData.getTestParamaterGroup()); handler.handleParticipantMessage(participantStatusMessage); verify(acDefinitionProvider).updateAcDefinition(acDefinition, CommonTestData.TOSCA_COMP_NAME); @@ -288,8 +228,8 @@ class SupervisionParticipantHandlerTest { var handler = new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider, - mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class), - mock(ParticipantSyncPublisher.class), mock(AcRuntimeParameterGroup.class)); + mock(AcDefinitionProvider.class), mock(ParticipantSyncPublisher.class), + mock(AcRuntimeParameterGroup.class)); handler.handleParticipantMessage(participantStatusMessage); verify(participantProvider).saveParticipant(any()); @@ -306,8 +246,8 @@ class SupervisionParticipantHandlerTest { var handler = new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider, - mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class), - mock(ParticipantSyncPublisher.class), mock(AcRuntimeParameterGroup.class)); + mock(AcDefinitionProvider.class), mock(ParticipantSyncPublisher.class), + mock(AcRuntimeParameterGroup.class)); var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId()); when(participantProvider.findParticipant(CommonTestData.getParticipantId())) .thenReturn(Optional.of(participant)); 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 1e3c89091..5cefd5f09 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 @@ -108,7 +108,7 @@ class SupervisionScannerTest { mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class), mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup); supervisionScanner.run(); - verify(acDefinitionProvider, times(0)).updateAcDefinitionState(any(), any(), any(), any()); + verify(acDefinitionProvider, times(0)).updateAcDefinitionState(any(), any(), any()); } @Test @@ -121,7 +121,7 @@ class SupervisionScannerTest { mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup); supervisionScanner.run(); // Ac Definition in Priming state - verify(acDefinitionProvider, times(0)).updateAcDefinitionState(any(), any(), any(), any()); + verify(acDefinitionProvider, times(0)).updateAcDefinitionState(any(), any(), any()); acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1); supervisionScanner = new SupervisionScanner(mock(AutomationCompositionProvider.class), acDefinitionProvider, @@ -130,13 +130,13 @@ class SupervisionScannerTest { supervisionScanner.run(); // set Timeout verify(acDefinitionProvider).updateAcDefinitionState(acDefinition.getCompositionId(), acDefinition.getState(), - StateChangeResult.TIMEOUT, null); + StateChangeResult.TIMEOUT); clearInvocations(acDefinitionProvider); acDefinition.setStateChangeResult(StateChangeResult.TIMEOUT); supervisionScanner.run(); // already in Timeout - verify(acDefinitionProvider, times(0)).updateAcDefinitionState(any(), any(), any(), any()); + verify(acDefinitionProvider, times(0)).updateAcDefinitionState(any(), any(), any()); clearInvocations(acDefinitionProvider); // retry by the user @@ -144,7 +144,7 @@ class SupervisionScannerTest { supervisionScanner.run(); // set Timeout verify(acDefinitionProvider).updateAcDefinitionState(acDefinition.getCompositionId(), acDefinition.getState(), - StateChangeResult.TIMEOUT, null); + StateChangeResult.TIMEOUT); clearInvocations(acDefinitionProvider); for (var element : acDefinition.getElementStateMap().values()) { @@ -153,7 +153,7 @@ class SupervisionScannerTest { supervisionScanner.run(); // completed verify(acDefinitionProvider).updateAcDefinitionState(acDefinition.getCompositionId(), AcTypeState.PRIMED, - StateChangeResult.NO_ERROR, null); + StateChangeResult.NO_ERROR); } @Test diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java index 7fd0aa2e2..a1ef9b4e2 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java @@ -258,30 +258,6 @@ class SupervisionMessagesTest { } @Test - void testParticipantRestartPublisher() { - var publisher = new ParticipantRestartPublisher(CommonTestData.getTestParamaterGroup()); - var topicSink = mock(TopicSink.class); - publisher.active(topicSink); - - var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); - var acmDefinition = new AutomationCompositionDefinition(); - acmDefinition.setCompositionId(UUID.randomUUID()); - acmDefinition.setServiceTemplate(serviceTemplate); - var acElements = AcmUtils - .extractAcElementsFromServiceTemplate(serviceTemplate, ""); - acmDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, AcTypeState.PRIMED)); - - var automationComposition = - InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Crud"); - - var participantId = automationComposition.getElements().values().iterator().next().getParticipantId(); - acmDefinition.getElementStateMap().values().iterator().next().setParticipantId(participantId); - - publisher.send(participantId, acmDefinition, List.of(automationComposition)); - verify(topicSink).send(anyString()); - } - - @Test void testParticipantSyncPublisherAutomationComposition() { var publisher = new ParticipantSyncPublisher(CommonTestData.getTestParamaterGroup()); var topicSink = mock(TopicSink.class); |