From ee9f70f704e978c2119a5e8f38ed98a8a1b70590 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 13 Nov 2018 16:47:33 -0500 Subject: Blueprints Processor Microservice Implement basic blueprint service logic workflow execution engine. Change-Id: Ifbbad70f2bdc4ba879b07d972083a411c7cc02f1 Issue-ID: CCSDK-672 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../modules/commons/adaptors/pom.xml | 34 ----- .../core/api/data/BlueprintProcessorData.kt | 4 +- .../core/api/data/BlueprintProcessorException.kt | 48 ------- .../core/factory/ComponentNodeFactory.kt | 2 - .../factory/ResourceAssignmentProcessorFactory.kt | 4 +- ms/blueprintsprocessor/modules/commons/pom.xml | 1 - .../api/ExecutionServiceController.java | 8 +- .../modules/services/db-service/pom.xml | 33 ----- .../execution/AbstractComponentFunction.kt | 55 ++++++++ .../services/execution/ExecutionService.kt | 46 ------- .../execution/JavaScriptExecuteComponent.kt | 45 ------ .../services/execution/PythonExecuteComponent.kt | 44 ------ .../services/execution/ExecutionServiceTest.java | 70 ---------- ms/blueprintsprocessor/modules/services/pom.xml | 4 +- .../resolution/ResourceResolutionService.kt | 35 +++-- .../modules/services/workflow-service/pom.xml | 44 ++++++ .../services/workflow/BlueprintSvcLogicContext.kt | 52 +++++++ .../services/workflow/BlueprintSvcLogicService.kt | 152 +++++++++++++++++++++ .../workflow/WorkflowServiceConfiguration.kt | 26 ++++ .../executor/ComponentExecuteNodeExecutor.kt | 81 +++++++++++ .../services/workflow/utils/SvcGraphUtils.kt | 35 +++++ .../services/workflow/BlueprintServiceLogicTest.kt | 62 +++++++++ .../workflow/mock/MockComponentFunction.kt | 46 +++++++ .../test/resources/service-logic/one-component.xml | 34 +++++ .../test/resources/service-logic/two-component.xml | 42 ++++++ ms/blueprintsprocessor/parent/pom.xml | 52 ++++++- 26 files changed, 703 insertions(+), 356 deletions(-) delete mode 100644 ms/blueprintsprocessor/modules/commons/adaptors/pom.xml delete mode 100644 ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorException.kt delete mode 100644 ms/blueprintsprocessor/modules/services/db-service/pom.xml create mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt delete mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionService.kt delete mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt delete mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt delete mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionServiceTest.java create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/pom.xml create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml diff --git a/ms/blueprintsprocessor/modules/commons/adaptors/pom.xml b/ms/blueprintsprocessor/modules/commons/adaptors/pom.xml deleted file mode 100644 index 410111b4..00000000 --- a/ms/blueprintsprocessor/modules/commons/adaptors/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - 4.0.0 - - org.onap.ccsdk.apps.blueprintsprocessor - commons - 0.4.0-SNAPSHOT - - - adaptors - pom - Blueprints Processor Adaptors POM - Blueprints Processor Adaptors - - - - - diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt index dc93825e..45f684f1 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt @@ -67,7 +67,7 @@ open class ExecutionServiceOutput { @get:ApiModelProperty(required = true) lateinit var actionIdentifiers: ActionIdentifiers @get:ApiModelProperty(required = true) - lateinit var status: Status + var status: Status = Status() @get:ApiModelProperty(required = true) lateinit var payload: ObjectNode var metadata: MutableMap = hashMapOf() @@ -110,7 +110,7 @@ open class Status { @get:ApiModelProperty(required = false) var errorMessage: String? = null @get:ApiModelProperty(required = true) - lateinit var message: String + var message: String = "success" } diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorException.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorException.kt deleted file mode 100644 index df4d6703..00000000 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorException.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.blueprintsprocessor.core.api.data - -/** - * BlueprintProcessorException - * @author Brinda Santh - * DATE : 8/15/2018 - */ -open class BlueprintProcessorException : Exception { - var code: Int = 100 - - constructor(cause: Throwable) : super(cause) - constructor(message: String) : super(message) - constructor(message: String, cause: Throwable) : super(message, cause) - constructor(cause: Throwable, message: String, vararg args: Any?) : super(String.format(message, *args), cause) - - constructor(code: Int, cause: Throwable) : super(cause) { - this.code = code - } - - constructor(code: Int, message: String) : super(message) { - this.code = code - } - - constructor(code: Int, message: String, cause: Throwable) : super(message, cause) { - this.code = code - } - - constructor(code: Int, cause: Throwable, message: String, vararg args: Any?) - : super(String.format(message, *args), cause) { - this.code = code - } -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt index feacbcab..66643ee0 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt @@ -21,7 +21,6 @@ import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware -import org.springframework.stereotype.Service /** * ComponentNode @@ -48,7 +47,6 @@ interface ComponentNode { * * @author Brinda Santh */ -@Service open class ComponentNodeFactory : ApplicationContextAware { private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java) diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt index 01a110d5..80ad0e67 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt @@ -21,14 +21,14 @@ import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware -import org.springframework.stereotype.Service +import org.springframework.context.annotation.Configuration /** * ResourceAssignmentProcessorFactory * * @author Brinda Santh */ -@Service +@Configuration open class ResourceAssignmentProcessorFactory : ApplicationContextAware { private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java) diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml index 299a87d6..c080f817 100644 --- a/ms/blueprintsprocessor/modules/commons/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/pom.xml @@ -31,7 +31,6 @@ db-lib rest-lib - adaptors core diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.java b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.java index 75407c52..3b5dfabe 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.java +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.java @@ -19,7 +19,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api; import io.swagger.annotations.ApiOperation; import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput; import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput; -import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ExecutionService; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Mono; @@ -33,11 +32,6 @@ import reactor.core.publisher.Mono; @RequestMapping("/api/v1/execution-service") public class ExecutionServiceController { - private ExecutionService executionService; - - public ExecutionServiceController(ExecutionService executionService) { - this.executionService = executionService; - } @RequestMapping(path = "/ping", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody @@ -50,6 +44,6 @@ public class ExecutionServiceController { notes = "Takes the blueprint information and process as per the payload") public @ResponseBody Mono process(@RequestBody ExecutionServiceInput executionServiceInput) { - return Mono.just(executionService.process(executionServiceInput)); + return Mono.just(new ExecutionServiceOutput()); } } diff --git a/ms/blueprintsprocessor/modules/services/db-service/pom.xml b/ms/blueprintsprocessor/modules/services/db-service/pom.xml deleted file mode 100644 index 4ff4d8c0..00000000 --- a/ms/blueprintsprocessor/modules/services/db-service/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - 4.0.0 - - org.onap.ccsdk.apps.blueprintsprocessor - services - 0.4.0-SNAPSHOT - - - db-service - jar - Blueprints Processor DB Service - Blueprints Processor DB Service - - - - diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt new file mode 100644 index 00000000..0e70e490 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt @@ -0,0 +1,55 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.services.execution + + +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode +import org.slf4j.LoggerFactory + +/** + * AbstractComponentFunction + * @author Brinda Santh + */ +abstract class AbstractComponentFunction : BlueprintFunctionNode { + private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java) + + override fun prepareRequest(executionRequest: ExecutionServiceInput): ExecutionServiceInput { + log.info("prepareRequest...") + return executionRequest + } + + override fun process(executionRequest: ExecutionServiceInput) { + log.info("Processing...") + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Recovering...") + } + + override fun prepareResponse(): ExecutionServiceOutput { + log.info("Preparing Response...") + return ExecutionServiceOutput() + } + + override fun apply(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput { + prepareRequest(executionServiceInput) + process(executionServiceInput) + return prepareResponse() + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionService.kt deleted file mode 100644 index 75b26bb5..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionService.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.blueprintsprocessor.services.execution - - -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.springframework.stereotype.Service -import com.fasterxml.jackson.databind.node.ObjectNode - -/** - * ExecutionService - * @author Brinda Santh - * 8/14/2018 - */ -@Service -class ExecutionService { - - fun process(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput { - val executionServiceOutput = ExecutionServiceOutput() - executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers - executionServiceOutput.commonHeader = executionServiceInput.commonHeader - executionServiceOutput.payload = JacksonUtils.jsonNode("{}") as ObjectNode - val status = Status() - status.code = 200 - status.message = "Success" - executionServiceOutput.status = status - return executionServiceOutput - } -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt deleted file mode 100644 index 427dc873..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.apps.blueprintsprocessor.services.execution - -import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode -import org.springframework.stereotype.Component - -/** - * JavaScriptExecuteComponent - * - * @author Brinda Santh - */ -@Component("component-javascript-executor") -class JavaScriptExecuteComponent : ComponentNode { - - override fun validate(context: MutableMap, componentContext: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun process(context: MutableMap, componentContext: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun errorHandle(context: MutableMap, componentContext: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun reTrigger(context: MutableMap, componentContext: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt deleted file mode 100644 index 59be1f51..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.apps.blueprintsprocessor.services.execution - -import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode -import org.springframework.stereotype.Component - -/** - * PythonExecuteComponent - * - * @author Brinda Santh - */ -@Component("component-python-executor") -class PythonExecuteComponent : ComponentNode { - override fun validate(context: MutableMap, componentContext: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun process(context: MutableMap, componentContext: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun errorHandle(context: MutableMap, componentContext: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun reTrigger(context: MutableMap, componentContext: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionServiceTest.java b/ms/blueprintsprocessor/modules/services/execution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionServiceTest.java deleted file mode 100644 index 0df95d2d..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionServiceTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.blueprintsprocessor.services.execution; - -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput; -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import java.io.File; -import java.nio.charset.Charset; - - -/** - * ExecutionServiceTest - * - * @author Brinda Santh - * DATE : 8/15/2018 - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = ExecutionService.class) -public class ExecutionServiceTest { - private static Logger log = LoggerFactory.getLogger(ExecutionServiceTest.class); - - @Autowired - private ExecutionService executionService; - - @Test - public void testExecutionService() throws Exception { - - Assert.assertNotNull("failed to create ResourceResolutionService", executionService); - - String resourceResolutionInputContent = FileUtils.readFileToString( - new File("src/test/resources/payload/requests/sample-execution-request.json"), Charset.defaultCharset()); - - ExecutionServiceInput executionServiceInput = JacksonUtils.readValue(resourceResolutionInputContent, ExecutionServiceInput.class ); - Assert.assertNotNull("failed to populate executionServiceInput request ",executionServiceInput); - - ObjectNode inputContent = (ObjectNode)JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json"); - Assert.assertNotNull("failed to populate input payload ",inputContent); - executionServiceInput.setPayload(inputContent); - - ExecutionServiceOutput executionServiceOutput = executionService.process(executionServiceInput); - Assert.assertNotNull("failed to populate output",executionServiceOutput); - - } -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/pom.xml b/ms/blueprintsprocessor/modules/services/pom.xml index eb3bda08..d175f129 100644 --- a/ms/blueprintsprocessor/modules/services/pom.xml +++ b/ms/blueprintsprocessor/modules/services/pom.xml @@ -29,9 +29,9 @@ pom - db-service - resolution-service execution-service + resolution-service + workflow-service diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt index d442c96b..3ee7e41f 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt @@ -17,12 +17,11 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.BlueprintProcessorException -import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status -import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils import org.springframework.stereotype.Service @@ -59,22 +58,22 @@ class ResourceResolutionService(private val resourceAssignmentProcessorFactory: val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments) bulkSequenced.map { batchResourceAssignments -> - batchResourceAssignments.filter { it.name != "*" && it.name != "start"} - .map { resourceAssignment -> - val dictionarySource = resourceAssignment.dictionarySource - val processorInstanceName = "resource-assignment-processor-".plus(dictionarySource) - val resourceAssignmentProcessor = resourceAssignmentProcessorFactory.getInstance(processorInstanceName) - ?: throw BlueprintProcessorException(format("failed to get resource processor for instance name({}) " + - "for resource assignment({})", processorInstanceName, resourceAssignment.name)) - try { - resourceAssignmentProcessor.validate(resourceAssignment, context) - resourceAssignmentProcessor.process(resourceAssignment, context) - } catch (e: Exception) { - resourceAssignmentProcessor.errorHandle(resourceAssignment, context) - throw BlueprintProcessorException(e) - } + batchResourceAssignments.filter { it.name != "*" && it.name != "start" } + .map { resourceAssignment -> + val dictionarySource = resourceAssignment.dictionarySource + val processorInstanceName = "resource-assignment-processor-".plus(dictionarySource) + val resourceAssignmentProcessor = resourceAssignmentProcessorFactory.getInstance(processorInstanceName) + ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " + + "for resource assignment(${resourceAssignment.name})") + try { + resourceAssignmentProcessor.validate(resourceAssignment, context) + resourceAssignmentProcessor.process(resourceAssignment, context) + } catch (e: Exception) { + resourceAssignmentProcessor.errorHandle(resourceAssignment, context) + throw BluePrintProcessorException(e) + } - } + } } } } diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml new file mode 100644 index 00000000..5809c06d --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml @@ -0,0 +1,44 @@ + + + + + + org.onap.ccsdk.apps.blueprintsprocessor + services + 0.4.0-SNAPSHOT + + 4.0.0 + + workflow-service + Blueprints Processor Workflow Service + Blueprints Processor Workflow Service + + + + org.onap.ccsdk.apps.blueprintsprocessor + execution-service + + + org.onap.ccsdk.sli.core + sli-provider + + + + + \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt new file mode 100644 index 00000000..d2648c07 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt @@ -0,0 +1,52 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.sli.core.sli.SvcLogicContext + +class BlueprintSvcLogicContext : SvcLogicContext() { + + private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null + private var request: Any? = null + private var response: Any? = null + + fun getBluePrintService(): BluePrintRuntimeService<*> { + return this.bluePrintRuntimeService!! + } + + fun setBluePrintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) { + this.bluePrintRuntimeService = bluePrintRuntimeService + } + + fun setRequest(request: Any) { + this.request = request + } + + fun getRequest(): Any { + return this.request!! + } + + fun setResponse(response: Any) { + this.response = response + } + + fun getResponse(): Any { + return this.response!! + } + +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt new file mode 100644 index 00000000..8750d98b --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt @@ -0,0 +1,152 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.sli.core.sli.* +import org.onap.ccsdk.sli.core.sli.provider.* +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker +import org.slf4j.LoggerFactory +import org.slf4j.MDC +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.ApplicationContext +import org.springframework.stereotype.Service +import java.util.* +import javax.annotation.PostConstruct + +interface BlueprintSvcLogicService : SvcLogicService { + + fun registerDefaultExecutors() + + fun registerExecutors(name: String, svcLogicNodeExecutor: SvcLogicNodeExecutor) + + fun unRegisterExecutors(name: String) + + fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>): Any + + @Deprecated("Populate Graph Dynamically from Blueprints, No need to get from Database Store ") + override fun getStore(): SvcLogicStore { + TODO("not implemented") + } + + @Deprecated("Not used in Micro service Implementation") + override fun hasGraph(module: String, rpc: String, version: String?, mode: String): Boolean { + TODO("not implemented") + } + + @Deprecated("Not used in Micro service Implementation") + override fun execute(p0: String?, p1: String?, p2: String?, p3: String?, p4: Properties?): Properties { + TODO("not implemented") + } + + @Deprecated("Not used in Micro service Implementation") + override fun execute(p0: String?, p1: String?, p2: String?, p3: String?, p4: Properties?, p5: DOMDataBroker?): Properties { + TODO("not implemented") + } +} + + +@Service +class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService { + + private val log = LoggerFactory.getLogger(DefaultBlueprintSvcLogicService::class.java) + + private val nodeExecutors: MutableMap = hashMapOf() + + @Autowired + private lateinit var context: ApplicationContext + + @PostConstruct + override fun registerDefaultExecutors() { + + val executeNodeExecutor = context.getBean(ExecuteNodeExecutor::class.java) + registerExecutors("execute", executeNodeExecutor) + registerExecutors("block", BlockNodeExecutor()) + registerExecutors("return", ReturnNodeExecutor()) + registerExecutors("break", BreakNodeExecutor()) + registerExecutors("exit", ExitNodeExecutor()) + } + + override fun registerExecutors(name: String, svcLogicNodeExecutor: SvcLogicNodeExecutor) { + log.info("Registering executors($name) with type(${svcLogicNodeExecutor.javaClass}") + nodeExecutors.put(name, svcLogicNodeExecutor) + } + + override fun unRegisterExecutors(name: String) { + if (nodeExecutors.containsKey(name)) { + log.info("UnRegistering executors($name)") + nodeExecutors.remove(name) + } + } + + override fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>): Any { + //Initialise BlueprintSvcLogic Context + val blueprintSvcLogicContext = BlueprintSvcLogicContext() + blueprintSvcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService) + // Execute the Graph + execute(graph, blueprintSvcLogicContext) + // Get the Response + return blueprintSvcLogicContext.getResponse() + } + + override fun executeNode(node: SvcLogicNode?, ctx: SvcLogicContext): SvcLogicNode? { + if (node == null) { + return null + } else { + if (log.isDebugEnabled()) { + log.debug("Executing node {}", node.getNodeId()) + } + + val executor = this.nodeExecutors[node.getNodeType()] + + if (executor != null) { + log.debug("Executing node executor for node type {} - {}", node.getNodeType(), executor.javaClass.name) + return executor.execute(this, node, ctx) + } else { + throw SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type") + } + } + } + + override fun execute(graph: SvcLogicGraph, svcLogicContext: SvcLogicContext): SvcLogicContext { + MDC.put("currentGraph", graph.toString()) + + val ctx = svcLogicContext as BlueprintSvcLogicContext + + val blueprintRuntimeService = ctx.getBluePrintService() + + log.info("Blueprint Runtime Service : ${blueprintRuntimeService}") + + var curNode: SvcLogicNode? = graph.getRootNode() + log.info("About to execute graph {}", graph.toString()) + + try { + while (curNode != null) { + MDC.put("nodeId", curNode.nodeId.toString() + " (" + curNode.nodeType + ")") + log.info("About to execute node # {} ({})", curNode.nodeId, curNode.nodeType) + val nextNode = this.executeNode(curNode, ctx) + curNode = nextNode + } + } catch (var5: ExitNodeException) { + log.debug("SvcLogicServiceImpl caught ExitNodeException") + } + + MDC.remove("nodeId") + MDC.remove("currentGraph") + return ctx + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt new file mode 100644 index 00000000..b9c041e9 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt @@ -0,0 +1,26 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow + +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.Configuration + +@Configuration +@ComponentScan +open class WorkflowServiceConfiguration { + +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt new file mode 100644 index 00000000..125a1ff6 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt @@ -0,0 +1,81 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor + +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction +import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintSvcLogicContext +import org.onap.ccsdk.sli.core.sli.SvcLogicContext +import org.onap.ccsdk.sli.core.sli.SvcLogicException +import org.onap.ccsdk.sli.core.sli.SvcLogicNode +import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicExpressionResolver +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.ApplicationContext +import org.springframework.stereotype.Service + +@Service +open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() { + + private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java) + + @Autowired + private lateinit var context: ApplicationContext + + fun getComponentFunction(pluginName: String): AbstractComponentFunction { + return context.getBean(pluginName, AbstractComponentFunction::class.java) + } + + @Throws(SvcLogicException::class) + override fun execute(svc: SvcLogicService, node: SvcLogicNode, svcLogicContext: SvcLogicContext): SvcLogicNode { + + var outValue: String + + val ctx = svcLogicContext as BlueprintSvcLogicContext + + val nodeTemplateName = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx) + + try { + // Get the Blueprint Context + val blueprintContext = ctx.getBluePrintService().bluePrintContext() + // Get the Component Name, NodeTemplate type is mapped to Component Name + val componentName = blueprintContext.nodeTemplateByName(nodeTemplateName).type + + log.info("executing node template($nodeTemplateName) component($componentName)") + // Get the Component Instance + val plugin = this.getComponentFunction(componentName) + + val executionInput = ctx.getRequest() as ExecutionServiceInput + // Get the Request from the Context and Set to the Function Input and Invoke the function + val executionOutput = plugin.apply(executionInput) + + ctx.setResponse(executionOutput) + + outValue = executionOutput.status.message + ctx.status = executionOutput.status.message + + } catch (e: Exception) { + this.log.error("Could not execute plugin($nodeTemplateName) : ", e) + outValue = "failure" + ctx.status = "failure" + } + + return this.getNextNode(node, outValue) + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt new file mode 100644 index 00000000..ada36ac0 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt @@ -0,0 +1,35 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils + +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph +import org.onap.ccsdk.sli.core.sli.SvcLogicParser + +object SvcGraphUtils { + + @JvmStatic + fun getSvcGraphFromClassPathFile(fileName: String): SvcLogicGraph { + val url = SvcGraphUtils::class.java.classLoader.getResource(fileName) + return getSvcGraphFromFile(url.path) + } + + @JvmStatic + fun getSvcGraphFromFile(fileName: String): SvcLogicGraph { + val svcLogicParser = SvcLogicParser() + return svcLogicParser.parse(fileName).first + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt new file mode 100644 index 00000000..5c90852e --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt @@ -0,0 +1,62 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow + +import org.junit.Test +import org.junit.runner.RunWith +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor +import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.junit4.SpringRunner + +@RunWith(SpringRunner::class) +@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class]) +class BlueprintServiceLogicTest { + + private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java) + + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", + "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + + @Autowired + lateinit var blueprintSvcLogicService: BlueprintSvcLogicService + + @Test + fun testExecuteGraphWithSingleComponent() { + + val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/one-component.xml") + val svcLogicContext = BlueprintSvcLogicContext() + svcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService) + svcLogicContext.setRequest(ExecutionServiceInput()) + blueprintSvcLogicService.execute(graph, svcLogicContext) + + } + + @Test + fun testExecuteGraphWithMultipleComponents() { + val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/two-component.xml") + val svcLogicContext = BlueprintSvcLogicContext() + svcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService) + svcLogicContext.setRequest(ExecutionServiceInput()) + blueprintSvcLogicService.execute(graph, svcLogicContext) + + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt new file mode 100644 index 00000000..5787721c --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt @@ -0,0 +1,46 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock + +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction +import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor +import org.slf4j.LoggerFactory +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +open class MockComponentConfiguration { + + @Bean(name = ["component-resource-assignment", "component-netconf-executor"]) + open fun createComponentFunction(): AbstractComponentFunction { + return MockComponentFunction() + } +} + +class MockComponentFunction : AbstractComponentFunction() { + + private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java) + + override fun process(executionRequest: ExecutionServiceInput) { + super.process(executionRequest) + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + super.recover(runtimeException, executionRequest) + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml new file mode 100644 index 00000000..5ff26ad2 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml new file mode 100644 index 00000000..7de61db5 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml index fd32ae12..a53ea2df 100644 --- a/ms/blueprintsprocessor/parent/pom.xml +++ b/ms/blueprintsprocessor/parent/pom.xml @@ -16,7 +16,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 org.onap.ccsdk.apps @@ -34,6 +35,7 @@ 1.3.0 1.0.1 1.0.0 + 0.3.1 26.0-jre 2.9.2 1.4.197 @@ -84,6 +86,47 @@ ${kotlin.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${sli.version} + + + commons-lang + commons-lang + + + org.apache.commons + * + + + org.slf4j + * + + + org.opendaylight.mdsal.model + * + + + + + + + org.apache.tomcat + * + + + org.apache.karaf.shell + * + + + org.mariadb.jdbc + * + + + + @@ -111,6 +154,11 @@ execution-service ${project.version} + + org.onap.ccsdk.apps.blueprintsprocessor + workflow-service + ${project.version} + org.onap.ccsdk.apps.blueprintsprocessor resolution-service @@ -211,7 +259,7 @@ compile - + compile -- cgit 1.2.3-korg