From cbbe0eac48b8df6e616f56a8ef51fbc7c955d171 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) --- .../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 +++++++++++++++ 4 files changed, 184 insertions(+) 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 (limited to 'ms/blueprintsprocessor/modules/services/workflow-service/src/test') 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 000000000..5c90852ee --- /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 000000000..5787721ca --- /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 000000000..5ff26ad2c --- /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 000000000..7de61db57 --- /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 -- cgit 1.2.3-korg