summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java14
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java1
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java23
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java2
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/resources/ChartList.json4
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java65
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java34
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java11
-rw-r--r--runtime-controlloop/src/main/resources/application.yaml2
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java32
10 files changed, 137 insertions, 51 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java
index 05f5a4bb8..4c3dd4b06 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java
@@ -57,6 +57,20 @@ public final class ParticipantUtils {
}
/**
+ * Finds startPhase from a map of properties.
+ *
+ * @param properties Map of properties
+ * @return startPhase
+ */
+ public static int findStartPhase(Map<String, Object> properties) {
+ var objParticipantType = properties.get("startPhase");
+ if (objParticipantType != null) {
+ return Integer.valueOf(objParticipantType.toString());
+ }
+ return 0;
+ }
+
+ /**
* Checks If NodeTemplate Is ControlLoopElement.
*
* @param nodeTemplate the ToscaNodeTemplate
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java
index 42b9712e2..f8a47c7c9 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java
@@ -40,6 +40,7 @@ public class ControlLoopUpdate extends ParticipantMessage {
// A list of ParticipantUpdates instances which carries details of an updated participant.
private List<ParticipantUpdates> participantUpdatesList = new ArrayList<>();
+ private Integer startPhase = 0;
/**
* Constructor for instantiating ControlLoopUpdate class with message name.
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java
index fcac64dd6..bbb57c320 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java
@@ -29,7 +29,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.List;
+import org.apache.commons.io.FileUtils;
import org.json.JSONObject;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
@@ -65,9 +68,11 @@ class ChartControllerTest {
private static final Coder CODER = new StandardCoder();
private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json";
private static List<ChartInfo> charts;
- private static String DEFAULT_CHART_URL = "/helm/charts";
+ private static String RETRIEVE_CHART_URL = "/helm/charts";
private static String INSTALL_CHART_URL = "/helm/install";
private static String UNINSTALL_CHART_URL = "/helm/uninstall/";
+ private static String ONBOARD_CHART_URL = "/helm/onboard/chart";
+ private static String DELETE_CHART_URL = "/helm/chart";
@Autowired
private MockMvc mockMvc;
@@ -107,7 +112,7 @@ class ChartControllerTest {
@Test
void retrieveAllCharts() throws Exception {
RequestBuilder requestBuilder;
- requestBuilder = MockMvcRequestBuilders.get(DEFAULT_CHART_URL).accept(MediaType.APPLICATION_JSON_VALUE);
+ requestBuilder = MockMvcRequestBuilders.get(RETRIEVE_CHART_URL).accept(MediaType.APPLICATION_JSON_VALUE);
mockMvc.perform(requestBuilder).andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
@@ -180,7 +185,7 @@ class ChartControllerTest {
//Mocking successful scenario for void uninstall method
when(chartService.saveChart(charts.get(0), chartFile, null)).thenReturn(charts.get(0));
- requestBuilder = MockMvcRequestBuilders.multipart(DEFAULT_CHART_URL)
+ requestBuilder = MockMvcRequestBuilders.multipart(ONBOARD_CHART_URL)
.file(chartFile).file(overrideFile).param("info", getChartInfoJson());
mockMvc.perform(requestBuilder).andExpect(status().isOk());
@@ -197,7 +202,7 @@ class ChartControllerTest {
//Mocking successful scenario for void uninstall method
doNothing().when(chartService).deleteChart(charts.get(0));
- requestBuilder = MockMvcRequestBuilders.delete(DEFAULT_CHART_URL + "/" + charts.get(0)
+ requestBuilder = MockMvcRequestBuilders.delete(DELETE_CHART_URL + "/" + charts.get(0)
.getChartId().getName() + "/" + charts.get(0).getChartId().getVersion())
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE);
@@ -219,14 +224,8 @@ class ChartControllerTest {
return jsonObj.toString();
}
- private String getChartInfoJson() {
- JSONObject jsonObj = new JSONObject();
- jsonObj.put("chartName", charts.get(0).getChartId().getName());
- jsonObj.put("version", charts.get(0).getChartId().getVersion());
- jsonObj.put("namespace", charts.get(0).getNamespace());
- jsonObj.put("repository", charts.get(0).getRepository());
- jsonObj.put("releaseName", charts.get(0).getReleaseName());
- return jsonObj.toString();
+ private String getChartInfoJson() throws IOException {
+ return FileUtils.readFileToString(new File(CHART_INFO_YAML), StandardCharsets.UTF_8);
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java
index 4c8b5b3b3..f1c8d19df 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java
@@ -121,7 +121,7 @@ class ChartServiceTest {
doReturn("dummyRepoName").when(chartService).findChartRepo(any());
doNothing().when(helmClient).installChart(any());
chartService.installChart(charts.get(1));
- assertEquals("dummyRepoName", charts.get(1).getRepository());
+ assertEquals("dummyRepoName", charts.get(1).getRepository().getRepoName());
ChartInfo testChart = charts.get(1);
testChart.setRepository(null);
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/ChartList.json b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/ChartList.json
index 2f4ec2827..9822846f3 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/ChartList.json
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/ChartList.json
@@ -6,7 +6,9 @@
"version" : "1.0"
},
"namespace" : "onap",
- "repository" : "chartMuseum",
+ "repository" : {
+ "repoName": "chartMuseum"
+ },
"releaseName" : "helloworld"
},
{
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
index 5cb79a37f..40dc901db 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
@@ -38,6 +38,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
@@ -219,6 +220,15 @@ public class ControlLoopHandler {
return;
}
+ if (0 == updateMsg.getStartPhase()) {
+ handleClUpdatePhase0(updateMsg, clElementDefinitions);
+ } else {
+ handleClUpdatePhaseN(updateMsg, clElementDefinitions);
+ }
+ }
+
+ private void handleClUpdatePhase0(ControlLoopUpdate updateMsg,
+ List<ControlLoopElementDefinition> clElementDefinitions) {
var controlLoop = controlLoopMap.get(updateMsg.getControlLoopId());
// TODO: Updates to existing ControlLoops are not supported yet (Addition/Removal of ControlLoop
@@ -244,28 +254,51 @@ public class ControlLoopHandler {
var clElements = storeElementsOnThisParticipant(updateMsg.getParticipantUpdatesList());
+ var clElementMap = prepareClElementMap(clElements);
+ controlLoop = new ControlLoop();
+ controlLoop.setDefinition(updateMsg.getControlLoopId());
+ controlLoop.setElements(clElementMap);
+ controlLoopMap.put(updateMsg.getControlLoopId(), controlLoop);
+
+ handleControlLoopElementUpdate(clElements, clElementDefinitions, updateMsg.getStartPhase(),
+ updateMsg.getControlLoopId());
+ }
+
+ private void handleClUpdatePhaseN(ControlLoopUpdate updateMsg,
+ List<ControlLoopElementDefinition> clElementDefinitions) {
+
+ var clElementList = updateMsg.getParticipantUpdatesList().stream()
+ .flatMap(participantUpdate -> participantUpdate.getControlLoopElementList().stream())
+ .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
+
+ handleControlLoopElementUpdate(clElementList, clElementDefinitions, updateMsg.getStartPhase(),
+ updateMsg.getControlLoopId());
+ }
+
+ private void handleControlLoopElementUpdate(List<ControlLoopElement> clElements,
+ List<ControlLoopElementDefinition> clElementDefinitions, Integer startPhaseMsg,
+ ToscaConceptIdentifier controlLoopId) {
try {
for (var element : clElements) {
- var clElementNodeTemplate =
- getClElementNodeTemplate(clElementDefinitions, element.getDefinition());
- for (var clElementListener : listeners) {
- clElementListener.controlLoopElementUpdate(updateMsg.getControlLoopId(), element,
- clElementNodeTemplate);
+ var clElementNodeTemplate = getClElementNodeTemplate(clElementDefinitions, element.getDefinition());
+ if (clElementNodeTemplate != null) {
+ int startPhase = ParticipantUtils.findStartPhase(clElementNodeTemplate.getProperties());
+ if (startPhaseMsg.equals(startPhase)) {
+ for (var clElementListener : listeners) {
+ clElementListener.controlLoopElementUpdate(controlLoopId, element, clElementNodeTemplate);
+ }
+ }
}
}
} catch (PfModelException e) {
- LOGGER.debug("Control loop element update failed {}", updateMsg.getControlLoopId());
+ LOGGER.debug("Control loop element update failed {}", controlLoopId);
}
- var clElementMap = prepareClElementMap(clElements);
- controlLoop = new ControlLoop();
- controlLoop.setDefinition(updateMsg.getControlLoopId());
- controlLoop.setElements(clElementMap);
- controlLoopMap.put(updateMsg.getControlLoopId(), controlLoop);
}
private ToscaNodeTemplate getClElementNodeTemplate(List<ControlLoopElementDefinition> clElementDefinitions,
ToscaConceptIdentifier clElementDefId) {
+
for (var clElementDefinition : clElementDefinitions) {
if (clElementDefId.getName().contains(
clElementDefinition.getClElementDefinitionId().getName())) {
@@ -276,14 +309,14 @@ public class ControlLoopHandler {
}
private List<ControlLoopElement> storeElementsOnThisParticipant(List<ParticipantUpdates> participantUpdates) {
- var clElementMap = participantUpdates.stream()
+ var clElementList = participantUpdates.stream()
.flatMap(participantUpdate -> participantUpdate.getControlLoopElementList().stream())
.filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
- for (var element : clElementMap) {
+ for (var element : clElementList) {
elementsOnThisParticipant.put(element.getId(), element);
}
- return clElementMap;
+ return clElementList;
}
private Map<UUID, ControlLoopElement> prepareClElementMap(List<ControlLoopElement> clElements) {
@@ -348,8 +381,8 @@ public class ControlLoopHandler {
controlLoop.getElements().values().stream().forEach(clElement -> {
for (var clElementListener : listeners) {
try {
- clElementListener.controlLoopElementStateChange(controlLoop.getDefinition(),
- clElement.getId(), clElement.getState(), orderedState);
+ clElementListener.controlLoopElementStateChange(controlLoop.getDefinition(), clElement.getId(),
+ clElement.getState(), orderedState);
} catch (PfModelException e) {
LOGGER.debug("Control loop element update failed {}", controlLoop.getDefinition());
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
index fde94bc0d..684711677 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
@@ -29,6 +29,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
@@ -37,7 +38,10 @@ import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopUpd
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusReqPublisher;
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -55,6 +59,7 @@ public class SupervisionScanner {
new HandleCounter<>();
private final ControlLoopProvider controlLoopProvider;
+ private final PolicyModelsProvider modelsProvider;
private final ControlLoopStateChangePublisher controlLoopStateChangePublisher;
private final ControlLoopUpdatePublisher controlLoopUpdatePublisher;
private final ParticipantProvider participantProvider;
@@ -65,6 +70,7 @@ public class SupervisionScanner {
* Constructor for instantiating SupervisionScanner.
*
* @param controlLoopProvider the provider to use to read control loops from the database
+ * @param modelsProvider the Policy Models Provider
* @param controlLoopStateChangePublisher the ControlLoop StateChange Publisher
* @param controlLoopUpdatePublisher the ControlLoopUpdate Publisher
* @param participantProvider the Participant Provider
@@ -72,13 +78,14 @@ public class SupervisionScanner {
* @param participantUpdatePublisher the Participant Update Publisher
* @param clRuntimeParameterGroup the parameters for the control loop runtime
*/
- public SupervisionScanner(final ControlLoopProvider controlLoopProvider,
+ public SupervisionScanner(final ControlLoopProvider controlLoopProvider, PolicyModelsProvider modelsProvider,
final ControlLoopStateChangePublisher controlLoopStateChangePublisher,
ControlLoopUpdatePublisher controlLoopUpdatePublisher, ParticipantProvider participantProvider,
ParticipantStatusReqPublisher participantStatusReqPublisher,
ParticipantUpdatePublisher participantUpdatePublisher,
final ClRuntimeParameterGroup clRuntimeParameterGroup) {
this.controlLoopProvider = controlLoopProvider;
+ this.modelsProvider = modelsProvider;
this.controlLoopStateChangePublisher = controlLoopStateChangePublisher;
this.controlLoopUpdatePublisher = controlLoopUpdatePublisher;
this.participantProvider = participantProvider;
@@ -119,8 +126,13 @@ public class SupervisionScanner {
}
try {
- for (ControlLoop controlLoop : controlLoopProvider.getControlLoops(null, null)) {
- scanControlLoop(controlLoop, counterCheck);
+ var list = modelsProvider.getServiceTemplateList(null, null);
+ if (list != null && !list.isEmpty()) {
+ ToscaServiceTemplate toscaServiceTemplate = list.get(0);
+
+ for (ControlLoop controlLoop : controlLoopProvider.getControlLoops(null, null)) {
+ scanControlLoop(controlLoop, toscaServiceTemplate, counterCheck);
+ }
}
} catch (PfModelException pfme) {
LOGGER.warn("error reading control loops from database", pfme);
@@ -190,7 +202,8 @@ public class SupervisionScanner {
participantUpdateCounter.remove(id);
}
- private void scanControlLoop(final ControlLoop controlLoop, boolean counterCheck) throws PfModelException {
+ private void scanControlLoop(final ControlLoop controlLoop, ToscaServiceTemplate toscaServiceTemplate,
+ boolean counterCheck) throws PfModelException {
LOGGER.debug("scanning control loop {} . . .", controlLoop.getKey().asIdentifier());
if (controlLoop.getState().equals(controlLoop.getOrderedState().asState())) {
@@ -202,11 +215,16 @@ public class SupervisionScanner {
}
var completed = true;
+ var minSpNotCompleted = 1000; // min startPhase not completed
for (ControlLoopElement element : controlLoop.getElements().values()) {
if (!element.getState().equals(element.getOrderedState().asState())) {
completed = false;
- break;
+ ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()
+ .get(element.getDefinition().getName());
+ int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties());
+ minSpNotCompleted = Math.min(minSpNotCompleted, startPhase);
}
+
}
if (completed) {
@@ -222,7 +240,7 @@ public class SupervisionScanner {
LOGGER.debug("control loop scan: transition from state {} to {} not completed", controlLoop.getState(),
controlLoop.getOrderedState());
if (counterCheck) {
- handleCounter(controlLoop);
+ handleCounter(controlLoop, minSpNotCompleted);
}
}
}
@@ -231,7 +249,7 @@ public class SupervisionScanner {
controlLoopCounter.clear(controlLoop.getKey().asIdentifier());
}
- private void handleCounter(ControlLoop controlLoop) {
+ private void handleCounter(ControlLoop controlLoop, int startPhase) {
ToscaConceptIdentifier id = controlLoop.getKey().asIdentifier();
if (controlLoopCounter.isFault(id)) {
LOGGER.debug("report ControlLoop fault");
@@ -242,7 +260,7 @@ public class SupervisionScanner {
if (controlLoopCounter.count(id)) {
if (ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState())) {
LOGGER.debug("retry message ControlLoopUpdate");
- controlLoopUpdatePublisher.send(controlLoop);
+ controlLoopUpdatePublisher.send(controlLoop, startPhase);
} else {
LOGGER.debug("retry message ControlLoopStateChange");
controlLoopStateChangePublisher.send(controlLoop);
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
index d68a643d2..74d987240 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
@@ -58,7 +58,18 @@ public class ControlLoopUpdatePublisher extends AbstractParticipantPublisher<Con
* @param controlLoop the ControlLoop
*/
public void send(ControlLoop controlLoop) {
+ send(controlLoop, 0);
+ }
+
+ /**
+ * Send ControlLoopUpdate to Participant.
+ *
+ * @param controlLoop the ControlLoop
+ * @param startPhase the Start Phase
+ */
+ public void send(ControlLoop controlLoop, int startPhase) {
var controlLoopUpdateMsg = new ControlLoopUpdate();
+ controlLoopUpdateMsg.setStartPhase(startPhase);
controlLoopUpdateMsg.setControlLoopId(controlLoop.getKey().asIdentifier());
controlLoopUpdateMsg.setMessageId(UUID.randomUUID());
controlLoopUpdateMsg.setTimestamp(Instant.now());
diff --git a/runtime-controlloop/src/main/resources/application.yaml b/runtime-controlloop/src/main/resources/application.yaml
index 96c340491..50c063fb3 100644
--- a/runtime-controlloop/src/main/resources/application.yaml
+++ b/runtime-controlloop/src/main/resources/application.yaml
@@ -26,7 +26,7 @@ runtime:
heartBeatMs: 20000
maxStatusWaitMs: 100000
updateParameters:
- maxRetryCount: 3
+ maxRetryCount: 4
maxWaitMs: 20000
databaseProviderParameters:
name: PolicyProviderParameterGroup
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java
index 9b64f9076..1bf445734 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java
@@ -46,13 +46,16 @@ import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantSta
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
class SupervisionScannerTest {
@Test
void testScannerOrderedStateEqualsToState() throws PfModelException {
var controlLoopProvider = mock(ControlLoopProvider.class);
+ var modelsProvider = mock(PolicyModelsProvider.class);
var controlLoopStateChangePublisher = mock(ControlLoopStateChangePublisher.class);
var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class);
var participantProvider = mock(ParticipantProvider.class);
@@ -63,9 +66,9 @@ class SupervisionScannerTest {
var controlLoop = new ControlLoop();
when(controlLoopProvider.getControlLoops(null, null)).thenReturn(List.of(controlLoop));
- var supervisionScanner = new SupervisionScanner(controlLoopProvider, controlLoopStateChangePublisher,
- controlLoopUpdatePublisher, participantProvider, participantStatusReqPublisher,
- participantUpdatePublisher, clRuntimeParameterGroup);
+ var supervisionScanner = new SupervisionScanner(controlLoopProvider, modelsProvider,
+ controlLoopStateChangePublisher, controlLoopUpdatePublisher, participantProvider,
+ participantStatusReqPublisher, participantUpdatePublisher, clRuntimeParameterGroup);
supervisionScanner.run(false);
verify(controlLoopProvider, times(0)).updateControlLoop(any(ControlLoop.class));
@@ -87,9 +90,12 @@ class SupervisionScannerTest {
var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var clRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
- var supervisionScanner = new SupervisionScanner(controlLoopProvider, controlLoopStateChangePublisher,
- controlLoopUpdatePublisher, participantProvider, participantStatusReqPublisher,
- participantUpdatePublisher, clRuntimeParameterGroup);
+ var modelsProvider = mock(PolicyModelsProvider.class);
+ when(modelsProvider.getServiceTemplateList(null, null)).thenReturn(List.of(new ToscaServiceTemplate()));
+
+ var supervisionScanner = new SupervisionScanner(controlLoopProvider, modelsProvider,
+ controlLoopStateChangePublisher, controlLoopUpdatePublisher, participantProvider,
+ participantStatusReqPublisher, participantUpdatePublisher, clRuntimeParameterGroup);
supervisionScanner.run(false);
verify(controlLoopProvider, times(1)).updateControlLoop(any(ControlLoop.class));
@@ -107,15 +113,16 @@ class SupervisionScannerTest {
participant.setVersion("1.0.0");
when(participantProvider.getParticipants(null, null)).thenReturn(List.of(participant));
+ var modelsProvider = mock(PolicyModelsProvider.class);
var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class);
var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
var controlLoopStateChangePublisher = mock(ControlLoopStateChangePublisher.class);
var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var clRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
- var supervisionScanner = new SupervisionScanner(controlLoopProvider, controlLoopStateChangePublisher,
- controlLoopUpdatePublisher, participantProvider, participantStatusReqPublisher,
- participantUpdatePublisher, clRuntimeParameterGroup);
+ var supervisionScanner = new SupervisionScanner(controlLoopProvider, modelsProvider,
+ controlLoopStateChangePublisher, controlLoopUpdatePublisher, participantProvider,
+ participantStatusReqPublisher, participantUpdatePublisher, clRuntimeParameterGroup);
supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier());
supervisionScanner.run(true);
@@ -143,14 +150,15 @@ class SupervisionScannerTest {
var participantProvider = new ParticipantProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
participantProvider.updateParticipants(List.of(participant));
+ var modelsProvider = mock(PolicyModelsProvider.class);
var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class);
var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
var controlLoopStateChangePublisher = mock(ControlLoopStateChangePublisher.class);
var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
- var supervisionScanner = new SupervisionScanner(controlLoopProvider, controlLoopStateChangePublisher,
- controlLoopUpdatePublisher, participantProvider, participantStatusReqPublisher,
- participantUpdatePublisher, clRuntimeParameterGroup);
+ var supervisionScanner = new SupervisionScanner(controlLoopProvider, modelsProvider,
+ controlLoopStateChangePublisher, controlLoopUpdatePublisher, participantProvider,
+ participantStatusReqPublisher, participantUpdatePublisher, clRuntimeParameterGroup);
supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier());
supervisionScanner.run(true);