diff options
Diffstat (limited to 'ms/blueprintsprocessor')
32 files changed, 399 insertions, 42 deletions
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml index c079ba990..a5d45277d 100755 --- a/ms/blueprintsprocessor/application/pom.xml +++ b/ms/blueprintsprocessor/application/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>parent</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> <artifactId>application</artifactId> diff --git a/ms/blueprintsprocessor/distribution/pom.xml b/ms/blueprintsprocessor/distribution/pom.xml index 0a9e4a93e..91ead8d90 100755 --- a/ms/blueprintsprocessor/distribution/pom.xml +++ b/ms/blueprintsprocessor/distribution/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>parent</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> <artifactId>distribution</artifactId> diff --git a/ms/blueprintsprocessor/functions/cli-executor/pom.xml b/ms/blueprintsprocessor/functions/cli-executor/pom.xml index 77c45e76e..af76d128b 100644 --- a/ms/blueprintsprocessor/functions/cli-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/cli-executor/pom.xml @@ -18,7 +18,7 @@ <parent> <artifactId>functions</artifactId> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>cli-executor</artifactId> diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml index 16ec6fbc1..a46e7433d 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml @@ -18,7 +18,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>functions</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId> diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml index 3f948061f..a635c9f4c 100755 --- a/ms/blueprintsprocessor/functions/pom.xml +++ b/ms/blueprintsprocessor/functions/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>parent</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/ms/blueprintsprocessor/functions/python-executor/pom.xml b/ms/blueprintsprocessor/functions/python-executor/pom.xml index af9d1987a..8e098bfef 100644 --- a/ms/blueprintsprocessor/functions/python-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/python-executor/pom.xml @@ -18,7 +18,7 @@ <parent> <artifactId>functions</artifactId> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> 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 0c5a947f1..896d9a648 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 @@ -17,14 +17,22 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper 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.* +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.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.putJsonElement +import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import kotlin.test.assertEquals @@ -58,7 +66,117 @@ class ComponentRemotePythonExecutorTest { executionServiceInput.stepData = stepInputData componentRemotePythonExecutor.applyNB(executionServiceInput) } + } + + /** + * Test cases for python executor to work with the process NB of remote + * executor. + */ + @Test + fun testComponentRemotePythonExecutorProcessNB() { + runBlocking { + val remoteScriptExecutionService = + MockRemoteScriptExecutionService() + val componentRemotePythonExecutor = ComponentRemotePythonExecutor( + remoteScriptExecutionService) + val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>( + "123456-1000") + val input = getMockedOutput(bluePrintRuntime) + componentRemotePythonExecutor.bluePrintRuntimeService = + bluePrintRuntime + componentRemotePythonExecutor.applyNB(input) + } + } + + /** + * Mocked input information for remote python executor. + */ + fun getMockedOutput(svc: DefaultBluePrintRuntimeService): + ExecutionServiceInput { + val stepMetaData: MutableMap<String, JsonNode> = hashMapOf() + + stepMetaData.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, + "execute-remote-python") + stepMetaData.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_INTERFACE, + "ComponentRemotePythonExecutor") + stepMetaData.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") + + val mapper = ObjectMapper() + val rootNode = mapper.createObjectNode() + rootNode.put("ip-address", "0.0.0.0") + rootNode.put("type", "rest") + + val operationalInputs: MutableMap<String, JsonNode> = hashMapOf() + operationalInputs.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, + "execute-remote-python") + operationalInputs.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_INTERFACE, + "ComponentRemotePythonExecutor") + operationalInputs.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") + operationalInputs.putJsonElement("endpoint-selector", "aai") + operationalInputs.putJsonElement("dynamic-properties", rootNode) + operationalInputs.putJsonElement("command", "./run.sh") + operationalInputs.putJsonElement("packages", "py") + + every { + svc.resolveNodeTemplateInterfaceOperationInputs( + "execute-remote-python", + "ComponentRemotePythonExecutor", "process") + } returns operationalInputs + + val stepInputData = StepData().apply { + name = "execute-remote-python" + properties = stepMetaData + } + val executionServiceInput = JacksonUtils + .readValueFromClassPathFile( + "payload/requests/sample-remote-python-request.json", + ExecutionServiceInput::class.java)!! + executionServiceInput.stepData = stepInputData + + val operationOutputs = hashMapOf<String, JsonNode>() + every { + svc.resolveNodeTemplateInterfaceOperationOutputs( + "execute-remote-python", + "ComponentRemotePythonExecutor", "process") + } returns operationOutputs + val bluePrintRuntimeService = BluePrintMetadataUtils + .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") + every { + svc.setNodeTemplateAttributeValue( + "execute-remote-python", "prepare-environment-logs", + "prepared successfully".asJsonPrimitive()) + } returns Unit + every { + svc.setNodeTemplateAttributeValue( + "execute-remote-python", + "execute-command-logs", "N/A".asJsonPrimitive()) + } returns Unit + every { + svc.setNodeTemplateAttributeValue( + "execute-remote-python", + "execute-command-logs", + "processed successfully".asJsonPrimitive()) + } returns Unit + + every { + svc.bluePrintContext() + } returns bluePrintRuntimeService.bluePrintContext() + return executionServiceInput } } 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 new file mode 100644 index 000000000..68a366432 --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-remote-python-request.json @@ -0,0 +1,23 @@ +{ + "actionIdentifiers": { + "actionName": "activate", + "blueprintName": "remote_scripts", + "blueprintVersion": "1.0.0", + "mode": "sync" + }, + "commonHeader": { + "flags": { + "force": true, + "ttl": 3600 + }, + "originatorId": "sdnc", + "requestId": "123456-1000", + "subRequestId": "sub-123456-1000", + "timestamp": "2012-04-23T18:25:43.511Z" + }, + "payload": { + "execute-remote-python": { + "input": "1234" + } + } +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml index b4bbd50f9..3666b4109 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml +++ b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>functions</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId> <artifactId>resource-resolution</artifactId> diff --git a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml index ef2f8bbb6..47a7af7ea 100644 --- a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml @@ -18,7 +18,7 @@ <parent> <artifactId>functions</artifactId> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId> diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml index faf5578c9..df66ff391 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>commons</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>db-lib</artifactId> diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml index 5f302993a..3261489ee 100644 --- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>commons</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>dmaap-lib</artifactId> diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml index e50b1915f..c7933a7ff 100644 --- a/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml @@ -14,14 +14,11 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>commons</artifactId> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> @@ -45,4 +42,4 @@ </dependency> </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt index a459d5fe2..8df218fe9 100644 --- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt @@ -16,17 +16,22 @@ package org.onap.ccsdk.cds.blueprintsprocessor.grpc.service +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BasicAuthGrpcClientProperties import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BluePrintGrpcLibConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner +import kotlin.test.assertEquals import kotlin.test.assertNotNull +import kotlin.test.assertTrue @RunWith(SpringRunner::class) @ContextConfiguration(classes = [BluePrintGrpcLibConfiguration::class, @@ -36,21 +41,92 @@ import kotlin.test.assertNotNull "blueprintsprocessor.grpcclient.sample.host=127.0.0.1", "blueprintsprocessor.grpcclient.sample.port=50505", "blueprintsprocessor.grpcclient.sample.username=sampleuser", - "blueprintsprocessor.grpcclient.sample.password=sampleuser" + "blueprintsprocessor.grpcclient.sample.password=sampleuser", + "blueprintsprocessor.grpcclient.token.type=token-auth", + "blueprintsprocessor.grpcclient.token.host=127.0.0.1", + "blueprintsprocessor.grpcclient.token.port=50505", + "blueprintsprocessor.grpcclient.token.username=sampleuser", + "blueprintsprocessor.grpcclient.token.password=sampleuser" ]) class BluePrintGrpcLibPropertyServiceTest { @Autowired lateinit var bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService + /** + * Tests the GRPC client properties with selector for basic auth. + */ @Test fun testGrpcClientProperties() { val properties = bluePrintGrpcLibPropertyService.grpcClientProperties( - "blueprintsprocessor.grpcclient.sample") as BasicAuthGrpcClientProperties + "blueprintsprocessor.grpcclient.sample") + as BasicAuthGrpcClientProperties assertNotNull(properties, "failed to create property bean") - assertNotNull(properties.host, "failed to get host property in property bean") - assertNotNull(properties.port, "failed to get host property in property bean") - assertNotNull(properties.username, "failed to get host property in property bean") - assertNotNull(properties.password, "failed to get host property in property bean") + assertNotNull(properties.host, "failed to get host property" + + " in property bean") + assertNotNull(properties.port, "failed to get host property" + + " in property bean") + assertNotNull(properties.username, "failed to get host pro" + + "perty in property bean") + assertNotNull(properties.password, "failed to get host pr" + + "operty in property bean") + } + + /** + * Tests the GRPC client properties with JSON node for token auth. + */ + @Test + fun testGrpcClientPropertiesWithJson() { + val json: String = "{\n" + + " \"type\" : \"token-auth\",\n" + + " \"host\" : \"127.0.0.1\",\n" + + " \"port\" : \"50505\"\n" + + "}" + val mapper = ObjectMapper() + val actualObj: JsonNode = mapper.readTree(json) + val properties = bluePrintGrpcLibPropertyService.grpcClientProperties( + actualObj) as TokenAuthGrpcClientProperties + assertNotNull(properties, "failed to create property bean") + assertEquals(properties.host, "127.0.0.1") + assertNotNull(properties.port, "50505") + } + + /** + * Tests the GRPC client service with selector for basic auth. + */ + @Test + fun testGrpcClientServiceBasic() { + val svc = bluePrintGrpcLibPropertyService.blueprintGrpcClientService( + "sample") + assertTrue(svc is BasicAuthGrpcClientService) + } + + /** + * Tests the GRPC client service with selector for token auth. + */ + @Test + fun testGrpcClientServiceToken() { + val svc = bluePrintGrpcLibPropertyService.blueprintGrpcClientService( + "token") + assertTrue(svc is TokenAuthGrpcClientService) + } + + /** + * Tests the GRPC client service with JSON node for basic auth. + */ + @Test + fun testGrpcClientServiceWithJson() { + val json: String = "{\n" + + " \"type\" : \"basic-auth\",\n" + + " \"host\" : \"127.0.0.1\",\n" + + " \"port\" : \"50505\",\n" + + " \"username\" : \"sampleuser\",\n" + + " \"password\" : \"samplepwd\"\n" + + "}" + val mapper = ObjectMapper() + val actualObj: JsonNode = mapper.readTree(json) + val svc = bluePrintGrpcLibPropertyService + .blueprintGrpcClientService(actualObj) + assertTrue(svc is BasicAuthGrpcClientService) } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml index 9b52565c1..5fdfb5064 100755 --- a/ms/blueprintsprocessor/modules/commons/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>modules</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>commons</artifactId> diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml index 93a9b793a..31feff177 100644 --- a/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>commons</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>processor-core</artifactId> diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml index 6809e7968..0cae94690 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>commons</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>rest-lib</artifactId> diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt index a85dc9ad7..37a797f78 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt @@ -20,7 +20,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.rest.service import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.ObjectMapper -import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties @@ -63,7 +62,6 @@ import kotlin.test.assertNotNull "blueprintsprocessor.restclient.ssl.sslKey=src/test/resources/keystore.p12", "blueprintsprocessor.restclient.ssl.sslKeyPassword=changeit" ]) -@Ignore class BluePrintRestLibPropertyServiceTest { @Autowired @@ -215,5 +213,25 @@ class BluePrintRestLibPropertyServiceTest { "eprintWebClientService") } + @Test + fun testBlueprintWebClientServiceWithJsonNode() { + val json: String = "{\n" + + " \"type\" : \"ssl-basic-auth\",\n" + + " \"url\" : \"https://localhost:8443\",\n" + + " \"keyStoreInstance\" : \"PKCS12\",\n" + + " \"sslTrust\" : \"src/test/resources/keystore.p12\",\n" + + " \"sslTrustPassword\" : \"changeit\",\n" + + " \"basicAuth\" : {\n" + + " \"username\" : \"admin\",\n" + + " \"password\" : \"cds\"\n" + + " }\n" + + "}" + val mapper = ObjectMapper() + val actualObj: JsonNode = mapper.readTree(json) + val blueprintWebClientService = bluePrintRestLibPropertyService + .blueprintWebClientService(actualObj) + assertNotNull(blueprintWebClientService, "failed to create blu" + + "eprintWebClientService") + } } diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml index c8f6b9e42..17b630fdd 100644 --- a/ms/blueprintsprocessor/modules/inbounds/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>modules</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>inbounds</artifactId> diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml index 4d5857651..d5acf4f93 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>inbounds</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>resource-api</artifactId> diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml index d3f8b4616..340f2c618 100755 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>inbounds</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>selfservice-api</artifactId> diff --git a/ms/blueprintsprocessor/modules/outbounds/pom.xml b/ms/blueprintsprocessor/modules/outbounds/pom.xml index d406462db..7512990c1 100644 --- a/ms/blueprintsprocessor/modules/outbounds/pom.xml +++ b/ms/blueprintsprocessor/modules/outbounds/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>modules</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>outbounds</artifactId> diff --git a/ms/blueprintsprocessor/modules/pom.xml b/ms/blueprintsprocessor/modules/pom.xml index c67c97882..3bdd13d58 100644 --- a/ms/blueprintsprocessor/modules/pom.xml +++ b/ms/blueprintsprocessor/modules/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>parent</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml index d366f740d..edfa4e3f7 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml +++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>services</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>execution-service</artifactId> diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt index c5fbea80f..b404fbed6 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt @@ -21,6 +21,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts; import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.node.ObjectNode import io.mockk.every import io.mockk.mockk @@ -32,12 +33,16 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.cds.controllerblueprints.scripts.BluePrintScriptsServiceImpl +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.junit4.SpringRunner import kotlin.test.BeforeTest import kotlin.test.assertEquals @@ -47,10 +52,16 @@ import kotlin.test.assertNotNull * Unit test cases for abstract component function. */ @RunWith(SpringRunner::class) +@ContextConfiguration(classes = [ComponentFunctionScriptingService::class, + BluePrintScriptsServiceImpl::class,PythonExecutorProperty::class, + BlueprintJythonService::class]) class AbstractComponentFunctionTest { lateinit var blueprintContext: BluePrintContext + @Autowired + lateinit var compSvc: ComponentFunctionScriptingService + @BeforeTest fun init() { blueprintContext = mockk<BluePrintContext>() @@ -82,12 +93,56 @@ class AbstractComponentFunctionTest { } } + /** + * Tests the abstract script component functionality. + */ + @Test + fun testAbstractScriptComponent() { + runBlocking { + val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>("1234") + val samp = SampleRestconfComponent(compSvc) + val comp = samp as AbstractComponentFunction + + comp.bluePrintRuntimeService = bluePrintRuntime + comp.stepName = "sample-step" + assertNotNull(comp, "failed to get kotlin instance") + + val input = getMockedInput(bluePrintRuntime) + val inp = getMockedContext() + + val output = comp.applyNB(input) + + assertEquals(output.actionIdentifiers.actionName, "activate") + assertEquals(output.commonHeader.requestId, "1234") + assertEquals(output.stepData!!.name, "activate-restconf") + assertEquals(output.status.message, "success") + } + } + + /** + * Mocked input for abstract function test. + */ + private fun getMockedContext() { + val operationOutputs = hashMapOf<String, JsonNode>() + every { + blueprintContext.name() + } returns "SampleTest" + every { + blueprintContext.version() + } returns "SampleScriptComponent" + } /** * Mocked input for abstract function test. */ private fun getMockedInput(bluePrintRuntime: DefaultBluePrintRuntimeService): ExecutionServiceInput { + + val mapper = ObjectMapper() + val rootNode = mapper.createObjectNode() + rootNode.put("ip-address", "0.0.0.0") + rootNode.put("type", "rest") + val operationInputs = hashMapOf<String, JsonNode>() operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = "activate-restconf".asJsonPrimitive() @@ -95,6 +150,8 @@ class AbstractComponentFunctionTest { "interfaceName".asJsonPrimitive() operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive() + operationInputs["dynamic-properties"] = rootNode + val stepInputData = StepData().apply { name = "activate-restconf" @@ -125,4 +182,6 @@ class AbstractComponentFunctionTest { return executionServiceInput } + } + diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt index dd417e56d..ae7b7b2ef 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt @@ -28,8 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner -import kotlin.test.assertNotNull import kotlin.test.BeforeTest +import kotlin.test.assertNotNull @RunWith(SpringRunner::class) @ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class]) diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt index e09cbfb66..000d8c09b 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt @@ -23,6 +23,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService + import org.slf4j.LoggerFactory open class SampleComponent : AbstractComponentFunction() { @@ -37,12 +40,34 @@ open class SampleComponent : AbstractComponentFunction() { } } -open class SampleScriptComponent : AbstractComponentFunction() { +open class SampleRestconfComponent (private var componentFunctionScriptingService: ComponentFunctionScriptingService) + : AbstractComponentFunction() { val log = LoggerFactory.getLogger(SampleScriptComponent::class.java)!! override suspend fun processNB(executionRequest: ExecutionServiceInput) { + var scriptComponent: AbstractScriptComponentFunction + scriptComponent = componentFunctionScriptingService + .scriptInstance<AbstractScriptComponentFunction>(this, + "internal", + "org.onap.ccsdk.cds.blueprintsprocessor.services" + + ".execution.scripts.SampleTest", + mutableListOf()) + scriptComponent.executeScript(executionServiceInput) + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + } +} + +open class SampleScriptComponent : AbstractScriptComponentFunction() { + + val log = LoggerFactory.getLogger(SampleScriptComponent::class.java)!! + + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt new file mode 100644 index 000000000..6a95e29e7 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt @@ -0,0 +1,42 @@ +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +/*- + * ============LICENSE_START======================================================= + * ONAP - CDS + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.slf4j.LoggerFactory +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +open class SampleTest : AbstractScriptComponentFunction() { + + val log = LoggerFactory.getLogger(SampleTest::class.java)!! + + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + val isPresent = checkDynamicProperties("type") + assertTrue(isPresent) + val prop = getDynamicProperties("ip-address").toString() + assertEquals(prop, "\"0.0.0.0\"") + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/pom.xml b/ms/blueprintsprocessor/modules/services/pom.xml index 751ad94d4..d2f1219e9 100755 --- a/ms/blueprintsprocessor/modules/services/pom.xml +++ b/ms/blueprintsprocessor/modules/services/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>modules</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <artifactId>services</artifactId> diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml index c48ff250f..d7f87aeff 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml +++ b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>services</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml index 42abbc51d..c99b84f45 100755 --- a/ms/blueprintsprocessor/parent/pom.xml +++ b/ms/blueprintsprocessor/parent/pom.xml @@ -16,13 +16,12 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.cds</groupId> <artifactId>blueprintsprocessor</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> </parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>parent</artifactId> diff --git a/ms/blueprintsprocessor/pom.xml b/ms/blueprintsprocessor/pom.xml index ffdb877e4..99d796972 100755 --- a/ms/blueprintsprocessor/pom.xml +++ b/ms/blueprintsprocessor/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.cds</groupId> <artifactId>ms</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>0.5.0-SNAPSHOT</version> <relativePath>..</relativePath> </parent> <artifactId>blueprintsprocessor</artifactId> |