diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
4 files changed, 82 insertions, 37 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java index 1220dc05c1..f49cf48ff5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java @@ -109,12 +109,15 @@ public class CnfAdapterCreateTasks { protected InstanceRequest createInstanceRequest(VfModule vfModule, CloudRegion cloudRegion, Map<String, String> sdncDirectives) { InstanceRequest request = new InstanceRequest(); - request.setRbName(vfModule.getModelInfoVfModule().getModelInvariantUUID()); - request.setRbVersion(vfModule.getModelInfoVfModule().getModelUUID()); + request.setModelInvariantId(vfModule.getModelInfoVfModule().getModelInvariantUUID()); + request.setModelVersionId(vfModule.getModelInfoVfModule().getModelUUID()); + request.setModelCustomizationId(vfModule.getModelInfoVfModule().getModelCustomizationUUID()); request.setCloudRegion(cloudRegion.getLcpCloudRegionId()); request.setVfModuleUUID(vfModule.getVfModuleId()); request.setProfileName(sdncDirectives.get("k8s-rb-profile-name")); request.setReleaseName(sdncDirectives.get("k8s-rb-instance-release-name")); + if (sdncDirectives.containsKey("k8s-rb-instance-status-check")) + request.setStatusCheck(sdncDirectives.get("k8s-rb-instance-status-check").equalsIgnoreCase("true")); request.setOverrideValues(sdncDirectives); return request; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java index 2d39cc185e..76c67eefc5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java @@ -21,11 +21,12 @@ */ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; +import static org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants.CONTROLLER_STATUS; import java.util.HashMap; import java.util.Optional; -import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.appc.client.lcm.model.Action; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -33,9 +34,9 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.catalog.beans.ControllerSelectionReference; -import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,13 +91,12 @@ public class GenericVnfHealthCheck { public void callAppcClient(BuildingBlockExecution execution) { logger.trace("Start runAppcCommand "); String appcCode = "1002"; - String appcMessage = ""; + String appcMessage; try { - Action action = null; - action = Action.valueOf(execution.getVariable("action")); + Action action = Action.valueOf(execution.getVariable("action")); String msoRequestId = execution.getVariable("msoRequestId"); String vnfId = execution.getVariable("vnfId"); - Optional<String> payload = null; + Optional<String> payload = Optional.empty(); if (execution.getVariable("payload") != null) { String pay = execution.getVariable("payload"); payload = Optional.of(pay); @@ -108,7 +108,7 @@ public class GenericVnfHealthCheck { payloadInfo.put(OAM_IP_ADDRESS, execution.getVariable(OAM_IP_ADDRESS)); payloadInfo.put(VNF_HOST_IP_ADDRESS, execution.getVariable(VNF_HOST_IP_ADDRESS)); - logger.debug("Running APP-C action: {}", action.toString()); + logger.debug("Running APP-C action: {}", action); logger.debug("VNFID: {}", vnfId); // PayloadInfo contains extra information that adds on to payload before making request to appc appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType); @@ -134,11 +134,14 @@ public class GenericVnfHealthCheck { exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } } + logger.error("Error Message: " + appcMessage); logger.error("ERROR CODE: " + appcCode); - logger.trace("End of runAppCommand "); if (appcCode != null && !("0").equals(appcCode)) { exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } + + execution.setVariable(CONTROLLER_STATUS, "Success"); + logger.debug("Successfully end of runAppCommand "); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java index f4b2a8b4b1..c4fbdc5359 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java @@ -7,83 +7,89 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"rb-name", "rb-version", "profile-name", "release-name", "cloud-region", "labels", - "override-values"}) public class InstanceRequest { @JsonProperty("modelInvariantId") - private String rbName; + private String modelInvariantId; @JsonProperty("modelVersionId") - private String rbVersion; + private String modelVersionId; + @JsonProperty("modelCustomizationId") + private String modelCustomizationId; @JsonProperty("k8sRBProfileName") private String profileName; @JsonProperty("k8sRBInstanceReleaseName") private String releaseName; + @JsonProperty("k8sRBInstanceStatusCheck") + private Boolean statusCheck = false; @JsonProperty("vfModuleUUID") private String vfModuleUUID; @JsonProperty("cloudRegionId") private String cloudRegion; @JsonProperty("labels") private Map<String, String> labels; - @JsonProperty(value = "override-values") + @JsonProperty("override-values") private Map<String, String> overrideValues; - @JsonProperty("rb-name") - public String getRbName() { - return rbName; + public String getModelInvariantId() { + return modelInvariantId; } - @JsonProperty("rb-name") - public void setRbName(String rbName) { - this.rbName = rbName; + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; } - @JsonProperty("rb-version") - public String getRbVersion() { - return rbVersion; + public String getModelVersionId() { + return modelVersionId; } - @JsonProperty("rb-version") - public void setRbVersion(String rbVersion) { - this.rbVersion = rbVersion; + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + public String getModelCustomizationId() { + return modelCustomizationId; + } + + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; } - @JsonProperty("profile-name") public String getProfileName() { return profileName; } - @JsonProperty("profile-name") public void setProfileName(String profileName) { this.profileName = profileName; } - @JsonProperty("release-name") + public Boolean getStatusCheck() { + return statusCheck; + } + + public void setStatusCheck(Boolean statusCheck) { + this.statusCheck = statusCheck; + } + public String getReleaseName() { return releaseName; } - @JsonProperty("release-name") public void setReleaseName(String releaseName) { this.releaseName = releaseName; } - @JsonProperty("cloud-region") public String getCloudRegion() { return cloudRegion; } - @JsonProperty("cloud-region") public void setCloudRegion(String cloudRegion) { this.cloudRegion = cloudRegion; } - @JsonProperty("labels") public Map<String, String> getLabels() { return labels; } - @JsonProperty("labels") public void setLabels(Map<String, String> labels) { this.labels = labels; } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java index fb15ffa2b3..f22932b988 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java @@ -25,7 +25,9 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; @@ -37,6 +39,8 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.Workflow; +import org.onap.so.db.catalog.client.CatalogDbClient; @RunWith(MockitoJUnitRunner.class) public class ServiceLevelTest { @@ -44,11 +48,15 @@ public class ServiceLevelTest { private static final String EXECUTION_KEY_PNF_NAME_LIST = "pnfNameList"; private static final String EXECUTION_KEY_PNF_COUNTER = "pnfCounter"; private static final String PARAM_NAME = "param1"; - private static final String SCOPE = "scope1"; private static final String PNF_NAME = "pnfName1"; + private static final String OPERATION_NAME = ServiceLevelConstants.HEALTH_CHECK_OPERATION; + private static final String SCOPE = ServiceLevelConstants.PNF; + private static final String WORKFLOW_NAME = "workflowTestName"; @Mock private ExceptionBuilder exceptionBuilderMock; + @Mock + private CatalogDbClient catalogDbClientMock; @InjectMocks private ServiceLevel testedObject; @@ -60,6 +68,31 @@ public class ServiceLevelTest { } @Test + public void fetchWorkflowUsingScope_catalogDBReturnsEmpty() { + // given + when(catalogDbClientMock.findWorkflowByOperationName(OPERATION_NAME)).thenReturn(Collections.emptyList()); + // when + String workflowResult = testedObject.fetchWorkflowUsingScope(SCOPE, OPERATION_NAME); + // then + assertThat(workflowResult).isEqualTo("GenericPnfHealthCheck"); + } + + @Test + public void fetchWorkflowUsingScope_catalogDBReturnsNotEmpty() { + // given + Workflow workflow = new Workflow(); + workflow.setResourceTarget(SCOPE); + workflow.setName(WORKFLOW_NAME); + List<Workflow> workflowList = new ArrayList<>(); + workflowList.add(workflow); + when(catalogDbClientMock.findWorkflowByOperationName(OPERATION_NAME)).thenReturn(workflowList); + // when + String workflowResult = testedObject.fetchWorkflowUsingScope(SCOPE, OPERATION_NAME); + // then + assertThat(workflowResult).isEqualTo(WORKFLOW_NAME); + } + + @Test public void pnfCounterExecution_success() { // given execution.setVariable(EXECUTION_KEY_PNF_NAME_LIST, createPnfNameList()); |