From 546be61a361f81d6c2cded4448404390a59075f6 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Tue, 23 Jul 2019 17:33:56 -0400 Subject: Fix for python executor unit test case failure. Change-Id: I193e2a092ff8cefe48419031096e1336e5c84fc1 Issue-ID: CCSDK-1046 Signed-off-by: Brinda Santh --- .../executor/ComponentRemotePythonExecutorTest.kt | 95 +++++++++++----------- .../requests/sample-remote-python-request.json | 2 +- 2 files changed, 49 insertions(+), 48 deletions(-) (limited to 'ms/blueprintsprocessor') diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt index 13202c6ea..d103bbf08 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt @@ -22,15 +22,11 @@ import io.mockk.every import io.mockk.mockk import kotlinx.coroutines.runBlocking import org.junit.Test -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.PrepareRemoteEnvInput -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionInput -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionOutput -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StatusType -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.* import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.RemoteScriptExecutionService import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.putJsonElement import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils @@ -49,11 +45,16 @@ class ComponentRemotePythonExecutorTest { val componentRemotePythonExecutor = ComponentRemotePythonExecutor(remoteScriptExecutionService) val executionServiceInput = - JacksonUtils.readValueFromClassPathFile("payload/requests/sample-activate-request.json", - ExecutionServiceInput::class.java)!! + JacksonUtils.readValueFromClassPathFile("payload/requests/sample-remote-python-request.json", + ExecutionServiceInput::class.java)!! + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("123456-1000", - "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts") + "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts") + + /** Load Workflow Inputs */ + bluePrintRuntimeService.assignWorkflowInputs("execute-remote-python", + executionServiceInput.payload.get("execute-remote-python-request")) val stepMetaData: MutableMap = hashMapOf() stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "execute-remote-python") @@ -76,18 +77,14 @@ class ComponentRemotePythonExecutorTest { @Test fun testComponentRemotePythonExecutorProcessNB() { runBlocking { - val remoteScriptExecutionService = - MockRemoteScriptExecutionService() - val componentRemotePythonExecutor = ComponentRemotePythonExecutor( - remoteScriptExecutionService) - val bluePrintRuntime = mockk( - "123456-1000") + val remoteScriptExecutionService = MockRemoteScriptExecutionService() + val componentRemotePythonExecutor = ComponentRemotePythonExecutor(remoteScriptExecutionService) + val bluePrintRuntime = mockk("123456-1000") every { bluePrintRuntime.setNodeTemplateAttributeValue(any(), any(), any()) } answers {} val input = getMockedOutput(bluePrintRuntime) - componentRemotePythonExecutor.bluePrintRuntimeService = - bluePrintRuntime + componentRemotePythonExecutor.bluePrintRuntimeService = bluePrintRuntime componentRemotePythonExecutor.applyNB(input) } } @@ -100,13 +97,13 @@ class ComponentRemotePythonExecutorTest { val stepMetaData: MutableMap = hashMapOf() stepMetaData.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, - "execute-remote-python") + BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, + "execute-remote-python") stepMetaData.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_INTERFACE, - "ComponentRemotePythonExecutor") + BluePrintConstants.PROPERTY_CURRENT_INTERFACE, + "ComponentRemotePythonExecutor") stepMetaData.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") + BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") val mapper = ObjectMapper() val rootNode = mapper.createObjectNode() @@ -115,13 +112,13 @@ class ComponentRemotePythonExecutorTest { val operationalInputs: MutableMap = hashMapOf() operationalInputs.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, - "execute-remote-python") + BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, + "execute-remote-python") operationalInputs.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_INTERFACE, - "ComponentRemotePythonExecutor") + BluePrintConstants.PROPERTY_CURRENT_INTERFACE, + "ComponentRemotePythonExecutor") operationalInputs.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") + BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") operationalInputs.putJsonElement("endpoint-selector", "aai") operationalInputs.putJsonElement("dynamic-properties", rootNode) operationalInputs.putJsonElement("command", "./run.sh") @@ -129,8 +126,8 @@ class ComponentRemotePythonExecutorTest { every { svc.resolveNodeTemplateInterfaceOperationInputs( - "execute-remote-python", - "ComponentRemotePythonExecutor", "process") + "execute-remote-python", + "ComponentRemotePythonExecutor", "process") } returns operationalInputs val stepInputData = StepData().apply { @@ -139,44 +136,48 @@ class ComponentRemotePythonExecutorTest { } val executionServiceInput = JacksonUtils - .readValueFromClassPathFile( - "payload/requests/sample-remote-python-request.json", - ExecutionServiceInput::class.java)!! + .readValueFromClassPathFile( + "payload/requests/sample-remote-python-request.json", + ExecutionServiceInput::class.java)!! executionServiceInput.stepData = stepInputData val operationOutputs = hashMapOf() every { svc.resolveNodeTemplateInterfaceOperationOutputs( - "execute-remote-python", - "ComponentRemotePythonExecutor", "process") + "execute-remote-python", + "ComponentRemotePythonExecutor", "process") } returns operationOutputs val bluePrintRuntimeService = BluePrintMetadataUtils - .getBluePrintRuntime("123456-1000", - "./../../../../components/model-" + - "catalog/blueprint-model/test-blueprint/" + - "remote_scripts") + .getBluePrintRuntime("123456-1000", + "./../../../../components/model-" + + "catalog/blueprint-model/test-blueprint/" + + "remote_scripts") every { svc.resolveNodeTemplateArtifactDefinition( - "execute-remote-python", "component-script") + "execute-remote-python", "component-script") } returns bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition( - "execute-remote-python", "component-script") + "execute-remote-python", "component-script") every { svc.setNodeTemplateAttributeValue( - "execute-remote-python", "prepare-environment-logs", - "prepared successfully".asJsonPrimitive()) + "execute-remote-python", "prepare-environment-logs", + "prepared successfully".asJsonPrimitive()) } returns Unit every { svc.setNodeTemplateAttributeValue( - "execute-remote-python", - "execute-command-logs", "N/A".asJsonPrimitive()) + "execute-remote-python", + "execute-command-logs", "N/A".asJsonPrimitive()) } returns Unit every { svc.setNodeTemplateAttributeValue( - "execute-remote-python", - "execute-command-logs", - "processed successfully".asJsonPrimitive()) + "execute-remote-python", + "execute-command-logs", + "processed successfully".asJsonPrimitive()) } returns Unit + every { + svc.resolveDSLExpression("aai") + } returns """{"url" : "http://xxx.com"}""".asJsonType() + every { svc.bluePrintContext() } returns bluePrintRuntimeService.bluePrintContext() diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-remote-python-request.json b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-remote-python-request.json index 68a366432..7fe12bdf0 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-remote-python-request.json +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-remote-python-request.json @@ -16,7 +16,7 @@ "timestamp": "2012-04-23T18:25:43.511Z" }, "payload": { - "execute-remote-python": { + "execute-remote-python-request": { "input": "1234" } } -- cgit 1.2.3-korg