summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src/test
diff options
context:
space:
mode:
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-08-10 21:51:48 +0100
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-08-18 14:58:42 +0100
commitd0a1bcee60c43a736a0526d49c07c564632c4f02 (patch)
tree32d46f33307a9bb65215a1f52eb626ae7db3d1ee /runtime-controlloop/src/test
parenta37bd982693785af5fc791df0baaa49dda039846 (diff)
Updated ControlLoop component messages
Updated controlloop messages (ParticipantUpdate, ControlLoopUpdate, ParticipantStatus) according to the following Wiki and added implementation for the corresponding updates in runtime-controlloop and participant components https://wiki.onap.org/display/DW/The+CLAMP+Control+Loop+Participant+Protocol Issue-ID: POLICY-3417 Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech> Change-Id: I80d96a7553a89ca47de2aa35e09df5a5c792acfa
Diffstat (limited to 'runtime-controlloop/src/test')
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java93
-rw-r--r--runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json32
-rw-r--r--runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml4
-rw-r--r--runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml4
4 files changed, 108 insertions, 25 deletions
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
index e74af7901..10116a240 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
@@ -21,7 +21,9 @@
package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
import java.time.Instant;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -30,6 +32,7 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ClElementStatisticsProvider;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
@@ -41,6 +44,7 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
+import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationUtils;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
@@ -48,6 +52,9 @@ import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
@@ -63,12 +70,15 @@ class SupervisionMessagesTest extends CommonRestController {
private static final Object lockit = new Object();
private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
private static final String TOPIC = "my-topic";
- private static final long interval = 1000;
private static SupervisionHandler supervisionHandler;
private static CommissioningProvider commissioningProvider;
private static ControlLoopProvider clProvider;
private static PolicyModelsProvider modelsProvider;
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+ private static final String TOSCA_TEMPLATE_YAML =
+ "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
+ private static final String CONTROL_LOOP_ELEMENT = "ControlLoopElement";
+ private static final Coder CODER = new StandardCoder();
/**
* setup Db Provider Parameters.
@@ -118,7 +128,6 @@ class SupervisionMessagesTest extends CommonRestController {
ToscaServiceTemplate serviceTemplate = yamlTranslator.fromYaml(
ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
- List<ToscaNodeTemplate> listOfTemplates = commissioningProvider.getControlLoopDefinitions(null, null);
commissioningProvider.createControlLoopDefinitions(serviceTemplate);
participantRegisterListener.onTopicEvent(INFRA, TOPIC, null, participantRegisterMsg);
}
@@ -168,6 +177,9 @@ class SupervisionMessagesTest extends CommonRestController {
@Test
void testSendParticipantUpdate() throws Exception {
+ InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, commissioningProvider);
+ commissioningProvider.getToscaServiceTemplate(null, null);
+
final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate();
participantUpdateMsg.setParticipantId(getParticipantId());
participantUpdateMsg.setTimestamp(Instant.now());
@@ -175,32 +187,71 @@ class SupervisionMessagesTest extends CommonRestController {
participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000));
participantUpdateMsg.setMessageId(UUID.randomUUID());
- ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate();
- toscaServiceTemplate.setName("serviceTemplate");
- toscaServiceTemplate.setDerivedFrom("parentServiceTemplate");
- toscaServiceTemplate.setDescription("Description of serviceTemplate");
- toscaServiceTemplate.setVersion("1.2.3");
+ ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getToscaServiceTemplate(null, null);
+ List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
+ for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry :
+ toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().entrySet()) {
+ if (toscaInputEntry.getValue().getType().contains(CONTROL_LOOP_ELEMENT)) {
+ ToscaConceptIdentifier clParticipantId;
+ try {
+ clParticipantId = CODER.decode(
+ toscaInputEntry.getValue().getProperties().get("participant_id").toString(),
+ ToscaConceptIdentifier.class);
+ } catch (CoderException e) {
+ throw new RuntimeException("cannot get ParticipantId from toscaNodeTemplate", e);
+ }
+ prepareParticipantDefinitionUpdate(clParticipantId, toscaInputEntry.getKey(),
+ toscaInputEntry.getValue(), participantDefinitionUpdates);
+ }
+ }
- ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
- clDefinition.setId(UUID.randomUUID());
- clDefinition.setControlLoopElementToscaServiceTemplate(toscaServiceTemplate);
- Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
- clDefinition.setCommonPropertiesMap(commonPropertiesMap);
+ participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates);
+ participantUpdateMsg.setToscaServiceTemplate(toscaServiceTemplate);
+ synchronized (lockit) {
+ ParticipantUpdatePublisher participantUpdatePublisher =
+ new ParticipantUpdatePublisher(commissioningProvider);
+ participantUpdatePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
+ participantUpdatePublisher.send(participantUpdateMsg);
+ }
+ }
- Map<UUID, ControlLoopElementDefinition> controlLoopElementDefinitionMap =
- Map.of(UUID.randomUUID(), clDefinition);
+ private void prepareParticipantDefinitionUpdate(ToscaConceptIdentifier clParticipantId, String entryKey,
+ ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates) {
- Map<String, Map<UUID, ControlLoopElementDefinition>> participantDefinitionUpdateMap =
- Map.of(getParticipantId().toString(), controlLoopElementDefinitionMap);
- participantUpdateMsg.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
+ var clDefinition = new ControlLoopElementDefinition();
+ clDefinition.setClElementDefinitionId(new ToscaConceptIdentifier(
+ entryKey, entryValue.getVersion()));
+ clDefinition.setControlLoopElementToscaNodeTemplate(entryValue);
+ List<ControlLoopElementDefinition> controlLoopElementDefinitionList = new ArrayList<>();
- synchronized (lockit) {
- ParticipantUpdatePublisher clUpdatePublisher = new ParticipantUpdatePublisher(commissioningProvider);
- clUpdatePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
- clUpdatePublisher.send(participantUpdateMsg);
+ if (participantDefinitionUpdates.isEmpty()) {
+ participantDefinitionUpdates.add(getParticipantDefinition(clDefinition, clParticipantId,
+ controlLoopElementDefinitionList));
+ } else {
+ boolean participantExists = false;
+ for (ParticipantDefinition participantDefinitionUpdate : participantDefinitionUpdates) {
+ if (participantDefinitionUpdate.getParticipantId().equals(clParticipantId)) {
+ participantDefinitionUpdate.getControlLoopElementDefinitionList().add(clDefinition);
+ participantExists = true;
+ }
+ }
+ if (!participantExists) {
+ participantDefinitionUpdates.add(getParticipantDefinition(clDefinition, clParticipantId,
+ controlLoopElementDefinitionList));
+ }
}
}
+ private ParticipantDefinition getParticipantDefinition(ControlLoopElementDefinition clDefinition,
+ ToscaConceptIdentifier clParticipantId,
+ List<ControlLoopElementDefinition> controlLoopElementDefinitionList) {
+ ParticipantDefinition participantDefinition = new ParticipantDefinition();
+ participantDefinition.setParticipantId(clParticipantId);
+ controlLoopElementDefinitionList.add(clDefinition);
+ participantDefinition.setControlLoopElementDefinitionList(controlLoopElementDefinitionList);
+ return participantDefinition;
+ }
+
@Test
void testReceiveParticipantUpdateAckMessage() throws Exception {
final ParticipantUpdateAck participantUpdateAckMsg = new ParticipantUpdateAck();
diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json
index 13ea1bfc4..64443ff62 100644
--- a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json
+++ b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json
@@ -17,6 +17,10 @@
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
+ "participantId": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
"participantType": {
"name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
"version": "2.3.4"
@@ -31,6 +35,10 @@
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
+ "participantId": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
"participantType": {
"name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
"version": "2.3.1"
@@ -45,6 +53,10 @@
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
"version": "1.2.3"
},
+ "participantId": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
"participantType": {
"name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
"version": "2.3.1"
@@ -59,6 +71,10 @@
"name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
"version": "1.2.3"
},
+ "participantId": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
"participantType": {
"name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
"version": "2.2.1"
@@ -86,6 +102,10 @@
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
+ "participantId": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
"participantType": {
"name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
"version": "2.3.4"
@@ -100,6 +120,10 @@
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
+ "participantId": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
"participantType": {
"name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
"version": "2.3.1"
@@ -114,6 +138,10 @@
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
"version": "1.2.3"
},
+ "participantId": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
"participantType": {
"name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
"version": "2.3.1"
@@ -128,6 +156,10 @@
"name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
"version": "1.2.3"
},
+ "participantId": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
"participantType": {
"name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
"version": "2.2.1"
diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml
index 099e2e945..dc09b4623 100644
--- a/runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml
+++ b/runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml
@@ -129,7 +129,7 @@ topology_template:
description: Control loop element for CDS for Performance Management Subscription Handling
properties:
provider: Ericsson
- participant_Id:
+ participant_id:
name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
version: 3.2.1
cds_blueprint_id:
@@ -197,7 +197,7 @@ topology_template:
description: Control loop element for CDS for Performance Management Subscription Handling
properties:
provider: Ericsson
- participant_Id:
+ participant_id:
name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
version: 3.2.1
cds_blueprint_id:
diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml
index 099e2e945..dc09b4623 100644
--- a/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml
+++ b/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml
@@ -129,7 +129,7 @@ topology_template:
description: Control loop element for CDS for Performance Management Subscription Handling
properties:
provider: Ericsson
- participant_Id:
+ participant_id:
name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
version: 3.2.1
cds_blueprint_id:
@@ -197,7 +197,7 @@ topology_template:
description: Control loop element for CDS for Performance Management Subscription Handling
properties:
provider: Ericsson
- participant_Id:
+ participant_id:
name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
version: 3.2.1
cds_blueprint_id: