From c0908b5a8acee321086286c0cf33c412caaae29c Mon Sep 17 00:00:00 2001 From: eeginux Date: Fri, 5 Apr 2019 16:49:07 +0000 Subject: Change to use OAM IPAddress Change to use ipaddress-v4/6-oam for the config deploy Add more assertions to the integration test Issue-ID: SO-1506 Change-Id: I5ba45b055569f90f91308b6e9d4bd85a1d4e99fe Signed-off-by: eeginux --- .../pnf/delegate/PrepareConfigDeployDelegate.java | 9 ++- .../delegate/PrepareConfigDeployDelegateTest.java | 4 +- .../src/test/java/org/onap/so/GrpcNettyServer.java | 8 +- .../CreateVcpeResCustServiceSimplifiedTest.java | 91 ++++++++++++++++++++-- 4 files changed, 98 insertions(+), 14 deletions(-) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java index 9b13be8e52..5fbed598e3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java @@ -95,8 +95,13 @@ public class PrepareConfigDeployDelegate extends PrepareCdsCallDelegate { Optional pnfOptional = pnfManagement.getEntryFor(pnfName); if ( pnfOptional.isPresent()){ Pnf pnf = pnfOptional.get(); - configDeployProperties.setPnfIpV4Address(pnf.getPnfIpv4Address()); - configDeployProperties.setPnfIpV6Address(pnf.getPnfIpv6Address()); + + /** + * PRH patches the AAI with oam address. + * Use ipaddress-v4-oam and ipaddress-v6-oam for the config deploy request. + */ + configDeployProperties.setPnfIpV4Address(pnf.getIpaddressV4Oam()); + configDeployProperties.setPnfIpV6Address(pnf.getIpaddressV6Oam()); } else { exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, "AAI entry for PNF: " + pnfName + " does not exist"); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java index 77b6d9ffdd..0964d2146b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java @@ -99,8 +99,8 @@ public class PrepareConfigDeployDelegateTest { private void mockAai() throws IOException { Pnf pnf = new Pnf(); - pnf.setPnfIpv4Address(TEST_IPV4_ADDRESS); - pnf.setPnfIpv6Address(TEST_IPV6_ADDRESS); + pnf.setIpaddressV4Oam(TEST_IPV4_ADDRESS); + pnf.setIpaddressV6Oam(TEST_IPV6_ADDRESS); when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenReturn(Optional.of(pnf)); } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java index a4de95e4fa..bf4a015e36 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java @@ -53,9 +53,9 @@ public class GrpcNettyServer extends BluePrintProcessingServiceImplBase { @Rule public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule(); - private final List messagesDelivered = new ArrayList<>(); private final CountDownLatch allRequestsDelivered = new CountDownLatch(1); private final AtomicReference> responseObserverRef = new AtomicReference<>(); + private final List detailedMessages = new ArrayList<>(); @PostConstruct public void start() throws IOException { @@ -71,7 +71,7 @@ public class GrpcNettyServer extends BluePrintProcessingServiceImplBase { StreamObserver requestObserver = new StreamObserver() { @Override public void onNext(ExecutionServiceInput message) { - messagesDelivered.add(message.getActionIdentifiers().getActionName()); + detailedMessages.add(message); logger.info("Message received: {}", message); ExecutionServiceOutput executionServiceOutput = ExecutionServiceOutput.newBuilder() .setActionIdentifiers(message.getActionIdentifiers()) @@ -103,8 +103,8 @@ public class GrpcNettyServer extends BluePrintProcessingServiceImplBase { } - public List getMessagesDelivered() { - return this.messagesDelivered; + public List getDetailedMessages(){ + return this.detailedMessages; } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java index 897ab037f2..2b1dc384a1 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -23,18 +23,26 @@ package org.onap.so.bpmn.infrastructure.process; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.ok; import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.put; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static org.assertj.core.api.Assertions.fail; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; +import com.google.protobuf.Struct; +import com.google.protobuf.Value; import java.io.IOException; import java.util.List; +import java.util.Map; import java.util.UUID; import org.camunda.bpm.engine.runtime.Execution; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; import org.onap.so.BaseBPMNTest; import org.onap.so.GrpcNettyServer; import org.onap.so.bpmn.mock.FileUtil; @@ -55,6 +63,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { private String testBusinessKey; private String requestObject; private String responseObject; + private String msoRequestId; @Autowired private GrpcNettyServer grpcNettyServer; @@ -82,7 +91,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { /** * Create mso-request-id. */ - String msoRequestId = UUID.randomUUID().toString(); + msoRequestId = UUID.randomUUID().toString(); variables.put("mso-request-id", msoRequestId); @@ -99,6 +108,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { public void workflow_validInput_expectedOuput() { mockCatalogDb(); + mockRequestDb(); mockAai(); mockDmaapForPnf(); @@ -111,7 +121,6 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { if (!execution.isSuspended() && !execution.isEnded()) { try { - runtimeService.signal(execution.getId()); } catch (Exception e) { logger.info(e.getMessage(), e); @@ -140,8 +149,73 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { assertThat(pi).isEnded(); - List messagesDelivered = grpcNettyServer.getMessagesDelivered(); - assertThat(messagesDelivered).containsSequence("config-assign", "config-deploy"); + List detailedMessages = grpcNettyServer.getDetailedMessages(); + assertThat(detailedMessages).hasSize(2); + try { + checkConfigAssign(detailedMessages.get(0)); + checkConfigDeploy(detailedMessages.get(1)); + } catch(Exception e){ + e.printStackTrace(); + fail("ConfigAssign/deploy request exception", e); + } + } + + private void checkConfigAssign(ExecutionServiceInput executionServiceInput) { + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the response/createVcpeResCustServiceSimplifiedTest_catalogdb.json. + */ + assertThat(actionIdentifiers.getBlueprintName()).matches("test_configuration_restconf"); + assertThat(actionIdentifiers.getBlueprintVersion()).matches("1.0.0"); + assertThat(actionIdentifiers.getActionName()).matches("config-assign"); + assertThat(actionIdentifiers.getMode()).matches("sync"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + assertThat(commonHeader.getOriginatorId()).matches("SO"); + assertThat(commonHeader.getRequestId()).matches(msoRequestId); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow("config-assign-request").getStructValue(); + + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).matches("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow("config-assign-properties").getStructValue(); + + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).matches("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()).matches("f2daaac6-5017-4e1e-96c8-6a27dfbe1421"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()).matches("68dc9a92-214c-11e7-93ae-92361f002680"); + } + + private void checkConfigDeploy(ExecutionServiceInput executionServiceInput) { + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the response/createVcpeResCustServiceSimplifiedTest_catalogdb.json. + */ + assertThat(actionIdentifiers.getBlueprintName()).matches("test_configuration_restconf"); + assertThat(actionIdentifiers.getBlueprintVersion()).matches("1.0.0"); + assertThat(actionIdentifiers.getActionName()).matches("config-deploy"); + assertThat(actionIdentifiers.getMode()).matches("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + assertThat(commonHeader.getOriginatorId()).matches("SO"); + assertThat(commonHeader.getRequestId()).matches(msoRequestId); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow("config-deploy-request").getStructValue(); + + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).matches("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow("config-deploy-properties").getStructValue(); + + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).matches("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()).matches("f2daaac6-5017-4e1e-96c8-6a27dfbe1421"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()).matches("68dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * IP addresses match the OAM ip addresses from AAI. + */ + assertThat(propertiesStruct.getFieldsOrThrow("pnf-ipv4-address").getStringValue()).matches("1.1.1.1"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-ipv6-address").getStringValue()).matches("::/128"); } /** @@ -174,8 +248,8 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" + " \"resource-version\":\"1541720264047\",\n" - + " \"pnf-ipv4-address\":\"1.1.1.1\",\n" - + " \"pnf-ipv6-address\":\"ipv6\"\n" + + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; /** @@ -258,4 +332,9 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=f2daaac6-5017-4e1e-96c8-6a27dfbe1421")) .willReturn(okJson(catalogdbClientResponse))); } + + private void mockRequestDb() { + wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")).willReturn(ok())); + } + } -- cgit 1.2.3-korg