From 5f0a5dde67bc0e7c99bd8f9e9b7c447e69ce62fa Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Sat, 29 Jun 2019 00:28:40 -0400 Subject: Enforce resolutionKey or resourceId/resourceType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are three existing ways to perform the resolution: either we don't store the results at all, whether for resource or template either we store using the resolution key. The combination of blueprintName, blueprintVersion, artifactName and resolutionKey has to be unique. If it is re-used, it is considered as a new attempt for that specific resolution request, and process will only try to resolve resources not marked at SUCCESS in the database. either we store using the resourceId and resourceType. As previous point, the combination of blueprintName, blueprintVersion, artifactName and resolutionKey has to be unique. If it is re-used, it is considered as a new attempt for that specific resolution request, and process will only try to resolve resources not marked at SUCCESS in the database. TBD: add uni tests Issue-ID: CCSDK-1423 Change-Id: I6b7198453cf0002edfa7a0c9ea3179555211b5dc Signed-off-by: Alexis de Talhouët --- .../executor/ComponentRemotePythonExecutorTest.kt | 78 ++++++++++++---------- 1 file changed, 41 insertions(+), 37 deletions(-) (limited to 'ms/blueprintsprocessor/functions/python-executor') 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 166d7b136..31aa7c7c1 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 @@ -48,11 +48,12 @@ class ComponentRemotePythonExecutorTest { val componentRemotePythonExecutor = ComponentRemotePythonExecutor(remoteScriptExecutionService) - val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-activate-request.json", + val executionServiceInput = + JacksonUtils.readValueFromClassPathFile("payload/requests/sample-activate-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") val stepMetaData: MutableMap = hashMapOf() stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "execute-remote-python") @@ -76,14 +77,17 @@ class ComponentRemotePythonExecutorTest { fun testComponentRemotePythonExecutorProcessNB() { runBlocking { val remoteScriptExecutionService = - MockRemoteScriptExecutionService() + MockRemoteScriptExecutionService() val componentRemotePythonExecutor = ComponentRemotePythonExecutor( - remoteScriptExecutionService) + remoteScriptExecutionService) val bluePrintRuntime = mockk( - "123456-1000") - val input = getMockedOutput(bluePrintRuntime) + "123456-1000") + + every { bluePrintRuntime.setNodeTemplateAttributeValue(any(), any(), any()) } answers {} + + val input = getMockedOutput(bluePrintRuntime) componentRemotePythonExecutor.bluePrintRuntimeService = - bluePrintRuntime + bluePrintRuntime componentRemotePythonExecutor.applyNB(input) } } @@ -96,13 +100,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() @@ -111,13 +115,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") @@ -125,8 +129,8 @@ class ComponentRemotePythonExecutorTest { every { svc.resolveNodeTemplateInterfaceOperationInputs( - "execute-remote-python", - "ComponentRemotePythonExecutor", "process") + "execute-remote-python", + "ComponentRemotePythonExecutor", "process") } returns operationalInputs val stepInputData = StepData().apply { @@ -135,42 +139,42 @@ 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") - } returns bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition( "execute-remote-python", "component-script") + } returns bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition( + "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 { -- cgit 1.2.3-korg