aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml2
-rwxr-xr-x[-rw-r--r--]runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java14
-rwxr-xr-x[-rw-r--r--]runtime-acm/src/main/resources/application.yaml2
-rwxr-xr-x[-rw-r--r--]runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java58
-rwxr-xr-x[-rw-r--r--]runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java13
5 files changed, 74 insertions, 15 deletions
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml
index a8e45ff0a..ea8ae2e74 100644..100755
--- a/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml
@@ -40,7 +40,7 @@ server:
runtime:
participantParameters:
heartBeatMs: 20000
- maxStatusWaitMs: 100000
+ maxStatusWaitMs: 200000
topicParameterGroup:
topicSources:
-
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 e0d11ed9f..f8bc233e9 100644..100755
--- 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
@@ -76,10 +76,7 @@ public class SupervisionParticipantHandler {
if (participantOpt.isPresent()) {
var participant = participantOpt.get();
- if (ParticipantState.OFF_LINE.equals(participant.getParticipantState())) {
- participant.setParticipantState(ParticipantState.ON_LINE);
- participantProvider.saveParticipant(participant);
- }
+ checkOnline(participant);
handleRestart(participant.getParticipantId());
} else {
var participant = createParticipant(participantRegisterMsg.getParticipantId(),
@@ -127,12 +124,21 @@ public class SupervisionParticipantHandler {
var participant = createParticipant(participantStatusMsg.getParticipantId(),
listToMap(participantStatusMsg.getParticipantSupportedElementType()));
participantProvider.saveParticipant(participant);
+ } else {
+ checkOnline(participantOpt.get());
}
if (!participantStatusMsg.getAutomationCompositionInfoList().isEmpty()) {
automationCompositionProvider.upgradeStates(participantStatusMsg.getAutomationCompositionInfoList());
}
}
+ private void checkOnline(Participant participant) {
+ if (ParticipantState.OFF_LINE.equals(participant.getParticipantState())) {
+ participant.setParticipantState(ParticipantState.ON_LINE);
+ participantProvider.saveParticipant(participant);
+ }
+ }
+
private void handleRestart(UUID participantId) {
var compositionIds = participantProvider.getCompositionIds(participantId);
for (var compositionId : compositionIds) {
diff --git a/runtime-acm/src/main/resources/application.yaml b/runtime-acm/src/main/resources/application.yaml
index faef54af0..8dd4b574a 100644..100755
--- a/runtime-acm/src/main/resources/application.yaml
+++ b/runtime-acm/src/main/resources/application.yaml
@@ -42,7 +42,7 @@ server:
runtime:
participantParameters:
heartBeatMs: 20000
- maxStatusWaitMs: 100000
+ maxStatusWaitMs: 200000
topicParameterGroup:
topicSources:
-
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 ed8a85664..49aa03096 100644..100755
--- 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
@@ -82,9 +82,7 @@ class SupervisionParticipantHandlerTest {
var participantRegisterMessage = new ParticipantRegister();
participantRegisterMessage.setMessageId(UUID.randomUUID());
participantRegisterMessage.setParticipantId(CommonTestData.getParticipantId());
- var supportedElementType = new ParticipantSupportedElementType();
- supportedElementType.setTypeName("Type");
- supportedElementType.setTypeVersion("1.0.0");
+ var supportedElementType = CommonTestData.createParticipantSupportedElementType();
participantRegisterMessage.setParticipantSupportedElementType(List.of(supportedElementType));
var participantProvider = mock(ParticipantProvider.class);
@@ -105,9 +103,7 @@ class SupervisionParticipantHandlerTest {
participantRegisterMessage.setMessageId(UUID.randomUUID());
var participantId = CommonTestData.getParticipantId();
participantRegisterMessage.setParticipantId(participantId);
- var supportedElementType = new ParticipantSupportedElementType();
- supportedElementType.setTypeName("Type");
- supportedElementType.setTypeVersion("1.0.0");
+ var supportedElementType = CommonTestData.createParticipantSupportedElementType();
participantRegisterMessage.setParticipantSupportedElementType(List.of(supportedElementType));
var participant = new Participant();
@@ -156,9 +152,7 @@ class SupervisionParticipantHandlerTest {
var participantStatusMessage = new ParticipantStatus();
participantStatusMessage.setParticipantId(CommonTestData.getParticipantId());
participantStatusMessage.setState(ParticipantState.ON_LINE);
- var supportedElementType = new ParticipantSupportedElementType();
- supportedElementType.setTypeName("Type");
- supportedElementType.setTypeVersion("1.0.0");
+ var supportedElementType = CommonTestData.createParticipantSupportedElementType();
participantStatusMessage.setParticipantSupportedElementType(List.of(supportedElementType));
participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
@@ -175,4 +169,50 @@ class SupervisionParticipantHandlerTest {
verify(automationCompositionProvider).upgradeStates(any());
}
+
+ @Test
+ void testHandleParticipantStatusNotRegisterd() {
+ var participantStatusMessage = new ParticipantStatus();
+ participantStatusMessage.setParticipantId(CommonTestData.getParticipantId());
+ participantStatusMessage.setState(ParticipantState.ON_LINE);
+ var supportedElementType = CommonTestData.createParticipantSupportedElementType();
+ participantStatusMessage.setParticipantSupportedElementType(List.of(supportedElementType));
+ participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
+
+ var participantProvider = mock(ParticipantProvider.class);
+ var automationCompositionProvider = mock(AutomationCompositionProvider.class);
+ var handler =
+ new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
+ mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class));
+ handler.handleParticipantMessage(participantStatusMessage);
+
+ verify(participantProvider).saveParticipant(any());
+ verify(automationCompositionProvider).upgradeStates(any());
+ }
+
+ @Test
+ void testHandleParticipantStatusCheckOnline() {
+ var participantStatusMessage = new ParticipantStatus();
+ participantStatusMessage.setParticipantId(CommonTestData.getParticipantId());
+ participantStatusMessage.setState(ParticipantState.ON_LINE);
+ var supportedElementType = CommonTestData.createParticipantSupportedElementType();
+ participantStatusMessage.setParticipantSupportedElementType(List.of(supportedElementType));
+ participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
+
+ var participantProvider = mock(ParticipantProvider.class);
+ var automationCompositionProvider = mock(AutomationCompositionProvider.class);
+ var handler =
+ new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
+ mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class));
+ var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
+ participant.setParticipantState(ParticipantState.OFF_LINE);
+ when(participantProvider.findParticipant(CommonTestData.getParticipantId()))
+ .thenReturn(Optional.of(participant));
+ handler.handleParticipantMessage(participantStatusMessage);
+
+ verify(participantProvider).saveParticipant(any());
+ verify(automationCompositionProvider).upgradeStates(any());
+ }
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
index 5c82713b0..270f1e0be 100644..100755
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
@@ -29,6 +29,7 @@ import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.concepts.Participant;
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.utils.AcmUtils;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -97,6 +98,18 @@ public class CommonTestData {
return participant;
}
+ /**
+ * Create a new ParticipantSupportedElementType.
+ *
+ * @return a new ParticipantSupportedElementType
+ */
+ public static ParticipantSupportedElementType createParticipantSupportedElementType() {
+ var supportedElementType = new ParticipantSupportedElementType();
+ supportedElementType.setTypeName("Type");
+ supportedElementType.setTypeVersion("1.0.0");
+ return supportedElementType;
+ }
+
public static UUID getParticipantId() {
return UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c03");
}