From adcd4f2bc695840e9ecbc05003bc52c675f22fec Mon Sep 17 00:00:00 2001 From: KAPIL SINGAL Date: Fri, 22 Jan 2021 11:49:51 -0500 Subject: Renaming Files having BluePrint to have Blueprint Replacing BluePrint with Blueprint throughout Issue-ID: CCSDK-3098 Signed-off-by: KAPIL SINGAL Change-Id: Ibee8bad07ae7d9287073db2d4f2f2cd730fa8b96 --- .../execution/AbstractComponentFunction.kt | 34 +++---- .../execution/AbstractScriptComponentFunction.kt | 26 ++--- .../services/execution/AbstractServiceFunction.kt | 4 +- .../execution/ComponentFunctionScriptingService.kt | 24 ++--- .../execution/ComponentRemoteScriptExecutor.kt | 14 +-- .../execution/ComponentRemoteScriptExecutorDSL.kt | 34 +++---- .../services/execution/ComponentScriptExecutor.kt | 2 +- .../execution/ComponentScriptExecutorDSL.kt | 38 ++++---- .../execution/RemoteScriptExecutionService.kt | 8 +- .../execution/StreamingRemoteExecutionService.kt | 22 ++--- .../execution/scripts/BlueprintJythonService.kt | 10 +- .../execution/ComponentRemoteScriptExecutorTest.kt | 24 ++--- .../execution/MockBluePrintProcessingServer.kt | 107 --------------------- .../execution/MockBlueprintProcessingServer.kt | 107 +++++++++++++++++++++ .../StreamingRemoteExecutionServiceTest.kt | 8 +- .../scripts/AbstractComponentFunctionTest.kt | 30 +++--- 16 files changed, 246 insertions(+), 246 deletions(-) delete mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt create mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBlueprintProcessingServer.kt (limited to 'ms/blueprintsprocessor/modules/services/execution-service') diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt index 94920235b..c1a898582 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt @@ -24,11 +24,11 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutp import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData import org.onap.ccsdk.cds.blueprintsprocessor.core.cluster.executeWithLock -import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BluePrintClusterService +import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterService import org.onap.ccsdk.cds.blueprintsprocessor.core.service.CDS_LOCK_GROUP import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.checkNotBlank import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty @@ -38,8 +38,8 @@ import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunction import org.onap.ccsdk.cds.controllerblueprints.core.jsonPathParse import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.readNBLines -import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService -import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintVelocityTemplateService import org.slf4j.LoggerFactory /** @@ -53,8 +53,8 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode - lateinit var bluePrintClusterService: BluePrintClusterService + lateinit var bluePrintRuntimeService: BlueprintRuntimeService<*> + lateinit var bluePrintClusterService: BlueprintClusterService lateinit var implementation: Implementation lateinit var processId: String lateinit var workflowName: String @@ -88,13 +88,13 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode { diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt index 8b46ae693..3cb46ed44 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt @@ -19,9 +19,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution import com.fasterxml.jackson.databind.JsonNode import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException import org.slf4j.LoggerFactory abstract class AbstractScriptComponentFunction : AbstractComponentFunction() { @@ -47,7 +47,7 @@ abstract class AbstractScriptComponentFunction : AbstractComponentFunction() { @Deprecated("Dependencies will be resolved dynamically") open fun functionDependencyInstanceAsType(name: String): T { return functionDependencyInstances[name] as? T - ?: throw BluePrintProcessorException("couldn't get script property instance ($name)") + ?: throw BlueprintProcessorException("couldn't get script property instance ($name)") } fun checkDynamicProperties(key: String): Boolean { @@ -60,7 +60,7 @@ abstract class AbstractScriptComponentFunction : AbstractComponentFunction() { suspend fun executeScript(executionServiceInput: ExecutionServiceInput) { return when (scriptType) { - BluePrintConstants.SCRIPT_JYTHON -> { + BlueprintConstants.SCRIPT_JYTHON -> { executeScriptBlocking(executionServiceInput) } else -> { @@ -97,34 +97,34 @@ abstract class AbstractScriptComponentFunction : AbstractComponentFunction() { */ final override fun apply(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput { - throw BluePrintException("Not Implemented, use applyNB method") + throw BlueprintException("Not Implemented, use applyNB method") } final override fun prepareRequest(executionRequest: ExecutionServiceInput): ExecutionServiceInput { - throw BluePrintException("Not Implemented required") + throw BlueprintException("Not Implemented required") } final override fun prepareResponse(): ExecutionServiceOutput { - throw BluePrintException("Not Implemented required") + throw BlueprintException("Not Implemented required") } final override suspend fun applyNB(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput { - throw BluePrintException("Not Implemented required") + throw BlueprintException("Not Implemented required") } final override suspend fun prepareRequestNB(executionRequest: ExecutionServiceInput): ExecutionServiceInput { - throw BluePrintException("Not Implemented required") + throw BlueprintException("Not Implemented required") } final override suspend fun prepareResponseNB(): ExecutionServiceOutput { - throw BluePrintException("Not Implemented required") + throw BlueprintException("Not Implemented required") } override fun process(executionRequest: ExecutionServiceInput) { - throw BluePrintException("Not Implemented, child class will implement this") + throw BlueprintException("Not Implemented, child class will implement this") } override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - throw BluePrintException("Not Implemented, child class will implement this") + throw BlueprintException("Not Implemented, child class will implement this") } } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt index 33f5d749f..41e26e4ab 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt @@ -21,7 +21,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode import org.onap.ccsdk.cds.controllerblueprints.core.jsonPathParse import org.onap.ccsdk.cds.controllerblueprints.core.logger @@ -79,7 +79,7 @@ abstract class AbstractServiceFunction : BlueprintFunctionNode> scriptInstance( - bluePrintContext: BluePrintContext, + bluePrintContext: BlueprintContext, scriptType: String, scriptClassReference: String ): T { var scriptComponent: T? = null when (scriptType) { - BluePrintConstants.SCRIPT_INTERNAL -> { - val bluePrintScriptsService: BluePrintScriptsService = BluePrintScriptsServiceImpl() + BlueprintConstants.SCRIPT_INTERNAL -> { + val bluePrintScriptsService: BlueprintScriptsService = BlueprintScriptsServiceImpl() scriptComponent = bluePrintScriptsService.scriptInstance(scriptClassReference) } - BluePrintConstants.SCRIPT_KOTLIN -> { - val bluePrintScriptsService: BluePrintScriptsService = BluePrintScriptsServiceImpl() + BlueprintConstants.SCRIPT_KOTLIN -> { + val bluePrintScriptsService: BlueprintScriptsService = BlueprintScriptsServiceImpl() scriptComponent = bluePrintScriptsService.scriptInstance( bluePrintContext.rootPath, bluePrintContext.name(), bluePrintContext.version(), scriptClassReference, false ) } - BluePrintConstants.SCRIPT_JYTHON -> { + BlueprintConstants.SCRIPT_JYTHON -> { scriptComponent = blueprintJythonService.jythonComponentInstance(bluePrintContext, scriptClassReference) as T } else -> { - throw BluePrintProcessorException("script type($scriptType) is not supported") + throw BlueprintProcessorException("script type($scriptType) is not supported") } } return scriptComponent diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutor.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutor.kt index 43ad183c0..815b190dd 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutor.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutor.kt @@ -22,8 +22,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.PayloadUtils import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.createActionIdentifiersProto import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.createCommonHeaderProto import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.createExecutionServiceInputProto -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.springframework.beans.factory.config.ConfigurableBeanFactory import org.springframework.context.annotation.Scope @@ -70,7 +70,7 @@ open class ComponentRemoteScriptExecutor( val txId = UUID.randomUUID().toString() val commonHeader = createCommonHeaderProto( executionRequest.commonHeader.subRequestId, - txId, BluePrintConstants.APP_NAME + txId, BlueprintConstants.APP_NAME ) val actionIdentifier = createActionIdentifiersProto(blueprintName, blueprintVersion, blueprintAction) @@ -92,16 +92,16 @@ open class ComponentRemoteScriptExecutor( /** set node template attribute */ val statusMessage = executionServiceOutputProto.status.message - if (statusMessage == BluePrintConstants.STATUS_SUCCESS) { - setAttribute(ATTRIBUTE_STATUS, BluePrintConstants.STATUS_SUCCESS.asJsonPrimitive()) + if (statusMessage == BlueprintConstants.STATUS_SUCCESS) { + setAttribute(ATTRIBUTE_STATUS, BlueprintConstants.STATUS_SUCCESS.asJsonPrimitive()) } else { val errorMessage = executionServiceOutputProto.status.errorMessage ?: "failed in remote execution" - throw BluePrintProcessorException(errorMessage) + throw BlueprintProcessorException(errorMessage) } } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - bluePrintRuntimeService.getBluePrintError() + bluePrintRuntimeService.getBlueprintError() .addError("Failed in ComponentRemoteScriptExecutor : ${runtimeException.message}") } } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt index 7bb071501..4263768b9 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt @@ -17,8 +17,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate @@ -31,24 +31,24 @@ import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType /** Component Extensions **/ fun ServiceTemplateBuilder.nodeTypeComponentRemoteScriptExecutor() { - val nodeType = BluePrintTypes.nodeTypeComponentRemoteScriptExecutor() + val nodeType = BlueprintTypes.nodeTypeComponentRemoteScriptExecutor() if (this.nodeTypes == null) this.nodeTypes = hashMapOf() this.nodeTypes!![nodeType.id!!] = nodeType } -fun BluePrintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType { +fun BlueprintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType { return nodeType( - id = "component-remote-script-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, + id = "component-remote-script-executor", version = BlueprintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BlueprintConstants.MODEL_TYPE_NODE_COMPONENT, description = "Generic Remote Script Component Executor" ) { /** Attribute definitions */ attribute( - ComponentRemoteScriptExecutor.ATTRIBUTE_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON, false, + ComponentRemoteScriptExecutor.ATTRIBUTE_RESPONSE_DATA, BlueprintConstants.DATA_TYPE_JSON, false, "Remote executed response data." ) attribute( - ComponentRemoteScriptExecutor.ATTRIBUTE_STATUS, BluePrintConstants.DATA_TYPE_STRING, true, + ComponentRemoteScriptExecutor.ATTRIBUTE_STATUS, BlueprintConstants.DATA_TYPE_STRING, true, "Remote execution status." ) @@ -56,35 +56,35 @@ fun BluePrintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType { operation("ComponentRemoteScriptExecutor", "ComponentRemoteScriptExecutor Operation") { inputs { property( - ComponentRemoteScriptExecutor.INPUT_SELECTOR, BluePrintConstants.DATA_TYPE_JSON, + ComponentRemoteScriptExecutor.INPUT_SELECTOR, BlueprintConstants.DATA_TYPE_JSON, true, "Remote GRPC selector or DSL reference or GRPC Json config." ) property( - ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_NAME, BluePrintConstants.DATA_TYPE_STRING, + ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_NAME, BlueprintConstants.DATA_TYPE_STRING, true, "Blueprint name." ) property( - ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_VERSION, BluePrintConstants.DATA_TYPE_STRING, + ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_VERSION, BlueprintConstants.DATA_TYPE_STRING, true, "Blueprint version." ) property( - ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_ACTION, BluePrintConstants.DATA_TYPE_STRING, + ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_ACTION, BlueprintConstants.DATA_TYPE_STRING, true, "Blueprint action name." ) property( - ComponentRemoteScriptExecutor.INPUT_TIMEOUT, BluePrintConstants.DATA_TYPE_INTEGER, + ComponentRemoteScriptExecutor.INPUT_TIMEOUT, BlueprintConstants.DATA_TYPE_INTEGER, true, "Remote execution timeout in sec." ) { defaultValue(180) } property( - ComponentRemoteScriptExecutor.INPUT_REQUEST_DATA, BluePrintConstants.DATA_TYPE_JSON, + ComponentRemoteScriptExecutor.INPUT_REQUEST_DATA, BlueprintConstants.DATA_TYPE_JSON, false, "Dynamic Json Content or DSL Json reference." ) } outputs { property( - ComponentRemoteScriptExecutor.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING, + ComponentRemoteScriptExecutor.OUTPUT_STATUS, BlueprintConstants.DATA_TYPE_STRING, true, "Status of the Component Execution ( success or failure )" ) } @@ -98,7 +98,7 @@ fun TopologyTemplateBuilder.nodeTemplateComponentRemoteScriptExecutor( description: String, block: ComponentRemoteScriptExecutorNodeTemplateBuilder.() -> Unit ) { - val nodeTemplate = BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor( + val nodeTemplate = BlueprintTypes.nodeTemplateComponentRemoteScriptExecutor( id, description, block ) @@ -106,7 +106,7 @@ fun TopologyTemplateBuilder.nodeTemplateComponentRemoteScriptExecutor( nodeTemplates!![nodeTemplate.id!!] = nodeTemplate } -fun BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor( +fun BlueprintTypes.nodeTemplateComponentRemoteScriptExecutor( id: String, description: String, block: ComponentRemoteScriptExecutorNodeTemplateBuilder.() -> Unit diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt index a7ef0a8a0..597426a5f 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt @@ -64,7 +64,7 @@ open class ComponentScriptExecutor(private var componentFunctionScriptingService } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - bluePrintRuntimeService.getBluePrintError() + bluePrintRuntimeService.getBlueprintError() .addError("Failed in ComponentScriptExecutor : ${runtimeException.message}") } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt index 8592ce62b..08a964b55 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt @@ -17,8 +17,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate @@ -32,53 +32,53 @@ import kotlin.reflect.KClass /** Component Extensions **/ fun ServiceTemplateBuilder.nodeTypeComponentScriptExecutor() { - val nodeType = BluePrintTypes.nodeTypeComponentScriptExecutor() + val nodeType = BlueprintTypes.nodeTypeComponentScriptExecutor() if (this.nodeTypes == null) this.nodeTypes = hashMapOf() this.nodeTypes!![nodeType.id!!] = nodeType } -fun BluePrintTypes.nodeTypeComponentScriptExecutor(): NodeType { +fun BlueprintTypes.nodeTypeComponentScriptExecutor(): NodeType { return nodeType( - id = "component-script-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, + id = "component-script-executor", version = BlueprintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BlueprintConstants.MODEL_TYPE_NODE_COMPONENT, description = "Generic Script Component Executor" ) { - attribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON, false) - attribute(ComponentScriptExecutor.ATTRIBUTE_STATUS, BluePrintConstants.DATA_TYPE_STRING, true) + attribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, BlueprintConstants.DATA_TYPE_JSON, false) + attribute(ComponentScriptExecutor.ATTRIBUTE_STATUS, BlueprintConstants.DATA_TYPE_STRING, true) operation("ComponentScriptExecutor", "ComponentScriptExecutor Operation") { inputs { property( - ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING, + ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BlueprintConstants.DATA_TYPE_STRING, true, "Script Type" ) { - defaultValue(BluePrintConstants.SCRIPT_INTERNAL) + defaultValue(BlueprintConstants.SCRIPT_INTERNAL) constrain { validValues( listOf( - BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(), - BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive(), - BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive() + BlueprintConstants.SCRIPT_INTERNAL.asJsonPrimitive(), + BlueprintConstants.SCRIPT_JYTHON.asJsonPrimitive(), + BlueprintConstants.SCRIPT_KOTLIN.asJsonPrimitive() ) ) } } property( - ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING, + ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BlueprintConstants.DATA_TYPE_STRING, true, "Kotlin Script class name or jython script name." ) property( - ComponentScriptExecutor.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON, + ComponentScriptExecutor.INPUT_DYNAMIC_PROPERTIES, BlueprintConstants.DATA_TYPE_JSON, false, "Dynamic Json Content or DSL Json reference." ) } outputs { property( - ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON, + ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, BlueprintConstants.DATA_TYPE_JSON, false, "Output Response" ) property( - ComponentScriptExecutor.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING, + ComponentScriptExecutor.OUTPUT_STATUS, BlueprintConstants.DATA_TYPE_STRING, true, "Status of the Component Execution ( success or failure )" ) } @@ -92,7 +92,7 @@ fun TopologyTemplateBuilder.nodeTemplateComponentScriptExecutor( description: String, block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit ) { - val nodeTemplate = BluePrintTypes.nodeTemplateComponentScriptExecutor( + val nodeTemplate = BlueprintTypes.nodeTemplateComponentScriptExecutor( id, description, block ) @@ -100,7 +100,7 @@ fun TopologyTemplateBuilder.nodeTemplateComponentScriptExecutor( nodeTemplates!![nodeTemplate.id!!] = nodeTemplate } -fun BluePrintTypes.nodeTemplateComponentScriptExecutor( +fun BlueprintTypes.nodeTemplateComponentScriptExecutor( id: String, description: String, block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt index a0cd7fce6..4f3f60110 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt @@ -27,8 +27,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteIdentifier 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.grpc.service.BluePrintGrpcClientService -import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BlueprintGrpcClientService +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BlueprintGrpcLibPropertyService import org.onap.ccsdk.cds.controllerblueprints.command.api.CommandExecutorServiceGrpc import org.onap.ccsdk.cds.controllerblueprints.command.api.ExecutionInput import org.onap.ccsdk.cds.controllerblueprints.command.api.ExecutionOutput @@ -58,7 +58,7 @@ interface RemoteScriptExecutionService { havingValue = "true", matchIfMissing = false ) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService) : +class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyService: BlueprintGrpcLibPropertyService) : RemoteScriptExecutionService { private val log = LoggerFactory.getLogger(GrpcRemoteScriptExecutionService::class.java)!! @@ -68,7 +68,7 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi override suspend fun init(selector: Any) { // Get the GRPC Client Service based on selector - val grpcClientService: BluePrintGrpcClientService = if (selector is JsonNode) { + val grpcClientService: BlueprintGrpcClientService = if (selector is JsonNode) { bluePrintGrpcLibPropertyService.blueprintGrpcClientService(selector) } else { bluePrintGrpcLibPropertyService.blueprintGrpcClientService(selector.toString()) diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt index fc37b488f..dadf72e04 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt @@ -29,12 +29,12 @@ import kotlinx.coroutines.flow.consumeAsFlow import kotlinx.coroutines.launch import kotlinx.coroutines.withTimeout import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GrpcClientProperties -import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcClientService -import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BlueprintGrpcClientService +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BlueprintGrpcLibPropertyService import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException import org.onap.ccsdk.cds.controllerblueprints.core.logger -import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BlueprintProcessingServiceGrpc import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty @@ -58,7 +58,7 @@ interface StreamingRemoteExecutionService { prefix = "blueprintsprocessor.streamingRemoteExecution", name = ["enabled"], havingValue = "true", matchIfMissing = false ) -class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService) : +class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertyService: BlueprintGrpcLibPropertyService) : StreamingRemoteExecutionService { private val log = logger(StreamingRemoteExecutionServiceImpl::class) @@ -84,12 +84,12 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe val grpcChannel = grpcChannel(selector) /** Get Send and Receive Channel for bidirectional process method*/ - val channels = clientCallBidiStreaming(BluePrintProcessingServiceGrpc.getProcessMethod(), grpcChannel) + val channels = clientCallBidiStreaming(BlueprintProcessingServiceGrpc.getProcessMethod(), grpcChannel) commChannels[txId] = channels } val commChannel = commChannels[txId] - ?: throw BluePrintException("failed to create response subscription for transactionId($txId) channel") + ?: throw BlueprintException("failed to create response subscription for transactionId($txId) channel") log.info("created subscription for transactionId($txId)") @@ -102,7 +102,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe */ override suspend fun send(txId: String, input: ExecutionServiceInput) { val sendChannel = commChannels[txId]?.requestChannel - ?: throw BluePrintException("failed to get transactionId($txId) send channel") + ?: throw BlueprintException("failed to get transactionId($txId) send channel") coroutineScope { launch { sendChannel.send(input) @@ -127,7 +127,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe /** Send the request */ val sendChannel = commChannels[txId]?.requestChannel - ?: throw BluePrintException("failed to get transactionId($txId) send channel") + ?: throw BlueprintException("failed to get transactionId($txId) send channel") sendChannel.send(input) /** Receive the response with timeout */ @@ -186,7 +186,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe } suspend fun createGrpcChannel(grpcProperties: GrpcClientProperties): ManagedChannel { - val grpcClientService: BluePrintGrpcClientService = bluePrintGrpcLibPropertyService + val grpcClientService: BlueprintGrpcClientService = bluePrintGrpcLibPropertyService .blueprintGrpcClientService(grpcProperties) return grpcClientService.channel() } @@ -203,7 +203,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe selector } else -> { - throw BluePrintException("couldn't process selector($selector)") + throw BlueprintException("couldn't process selector($selector)") } } } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt index 2f1ae2fc5..69cb0b6eb 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt @@ -16,9 +16,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode -import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext import org.springframework.stereotype.Service // TODO("After Jython depreciation, this interface will be removed") @@ -26,15 +26,15 @@ import org.springframework.stereotype.Service @Deprecated("CDS won's support Jython services") interface BlueprintJythonService { - fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String): + fun jythonComponentInstance(bluePrintContext: BlueprintContext, scriptClassReference: String): BlueprintFunctionNode<*, *> } @Service open class DeprecatedBlueprintJythonService : BlueprintJythonService { - override fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String): + override fun jythonComponentInstance(bluePrintContext: BlueprintContext, scriptClassReference: String): BlueprintFunctionNode<*, *> { - throw BluePrintProcessorException("Include python-executor module for Jython support") + throw BlueprintProcessorException("Include python-executor module for Jython support") } } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt index b3a0a5892..5ef62d0bc 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt @@ -32,15 +32,15 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.createExecutionServiceOutputProto import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.createStatus import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.toProto -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType 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.service.BlueprintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBlueprintRuntimeService import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput import kotlin.test.assertNotNull @@ -48,7 +48,7 @@ class ComponentRemoteScriptExecutorTest { @Test fun testNodeComponentRemoteScriptExecutorType() { - val nodeType = BluePrintTypes.nodeTypeComponentRemoteScriptExecutor() + val nodeType = BlueprintTypes.nodeTypeComponentRemoteScriptExecutor() assertNotNull(nodeType, "failed to generate nodeType Component Remote Script Executor") } @@ -96,7 +96,7 @@ class ComponentRemoteScriptExecutorTest { fun testComponentRemoteScriptExecutor() { runBlocking { /** Mock blueprint context */ - val blueprintContext = mockk() + val blueprintContext = mockk() every { blueprintContext.rootPath } returns normalizedPathName("target") every { blueprintContext.nodeTemplateOperationImplementation( @@ -104,7 +104,7 @@ class ComponentRemoteScriptExecutorTest { ) } returns Implementation() - val bluePrintRuntime = mockk("1234") + val bluePrintRuntime = mockk("1234") every { bluePrintRuntime.bluePrintContext() } returns blueprintContext val mockExecutionServiceInput = mockExecutionServiceInput(bluePrintRuntime) @@ -130,7 +130,7 @@ class ComponentRemoteScriptExecutorTest { } } - private fun mockExecutionServiceInput(bluePrintRuntime: DefaultBluePrintRuntimeService): ExecutionServiceInput { + private fun mockExecutionServiceInput(bluePrintRuntime: DefaultBlueprintRuntimeService): ExecutionServiceInput { val mapper = ObjectMapper() val requestNode = mapper.createObjectNode() @@ -138,10 +138,10 @@ class ComponentRemoteScriptExecutorTest { requestNode.put("type", "grpc") val operationInputs = hashMapOf() - operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = "remote-execute".asJsonPrimitive() - operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] = + operationInputs[BlueprintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = "remote-execute".asJsonPrimitive() + operationInputs[BlueprintConstants.PROPERTY_CURRENT_INTERFACE] = "ComponentRemoteScriptExecutor".asJsonPrimitive() - operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "process".asJsonPrimitive() + operationInputs[BlueprintConstants.PROPERTY_CURRENT_OPERATION] = "process".asJsonPrimitive() operationInputs[ComponentRemoteScriptExecutor.INPUT_SELECTOR] = "remote-script-executor".asJsonPrimitive() operationInputs[ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_NAME] = "sample-blueprint".asJsonPrimitive() @@ -205,7 +205,7 @@ class ComponentRemoteScriptExecutorTest { return createExecutionServiceOutputProto( executionServiceInput.commonHeader.toProto(), executionServiceInput.actionIdentifiers.toProto(), - createStatus(BluePrintConstants.STATUS_SUCCESS, 200), + createStatus(BlueprintConstants.STATUS_SUCCESS, 200), responsePayload ) } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt deleted file mode 100644 index 8edea46f6..000000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright © 2018-2019 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.cds.blueprintsprocessor.services.execution.scripts - -import io.grpc.ServerBuilder -import io.grpc.stub.StreamObserver -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking -import org.onap.ccsdk.cds.blueprintsprocessor.grpc.interceptor.GrpcServerLoggingInterceptor -import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType -import org.onap.ccsdk.cds.controllerblueprints.common.api.Status -import org.onap.ccsdk.cds.controllerblueprints.core.MDCContext -import org.onap.ccsdk.cds.controllerblueprints.core.logger -import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput - -private val log = logger(MockBluePrintProcessingServer::class) - -class MockBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() { - - override fun process(responseObserver: StreamObserver): StreamObserver { - - return object : StreamObserver { - override fun onNext(executionServiceInput: ExecutionServiceInput) { - log.info( - "Received requestId(${executionServiceInput.commonHeader.requestId}) " + - "subRequestId(${executionServiceInput.commonHeader.subRequestId})" - ) - runBlocking { - launch(MDCContext()) { - responseObserver.onNext(buildNotification(executionServiceInput)) - responseObserver.onNext(buildResponse(executionServiceInput)) - log.info("message has sent successfully...") - } - } - responseObserver.onCompleted() - } - - override fun onError(error: Throwable) { - log.debug("Fail to process message", error) - responseObserver.onError( - io.grpc.Status.INTERNAL - .withDescription(error.message) - .asException() - ) - } - - override fun onCompleted() { - log.info("Completed") - } - } - } - - private fun buildNotification(input: ExecutionServiceInput): ExecutionServiceOutput { - val status = Status.newBuilder() - .setEventType(EventType.EVENT_COMPONENT_NOTIFICATION) - .build() - return ExecutionServiceOutput.newBuilder() - .setCommonHeader(input.commonHeader) - .setActionIdentifiers(input.actionIdentifiers) - .setStatus(status) - .build() - } - - private fun buildResponse(input: ExecutionServiceInput): ExecutionServiceOutput { - - val status = Status.newBuilder().setCode(200) - .setEventType(EventType.EVENT_COMPONENT_EXECUTED) - .build() - return ExecutionServiceOutput.newBuilder() - .setCommonHeader(input.commonHeader) - .setActionIdentifiers(input.actionIdentifiers) - .setStatus(status) - .build() - } -} - -/** For Integration testing stat this server */ -fun main() { - try { - val server = ServerBuilder - .forPort(50052) - .intercept(GrpcServerLoggingInterceptor()) - .addService(MockBluePrintProcessingServer()) - .build() - server.start() - log.info("GRPC Serve started(${server.isShutdown}) on port(${server.port})...") - server.awaitTermination() - } catch (e: Exception) { - e.printStackTrace() - } -} diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBlueprintProcessingServer.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBlueprintProcessingServer.kt new file mode 100644 index 000000000..7ac6134d9 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBlueprintProcessingServer.kt @@ -0,0 +1,107 @@ +/* + * Copyright © 2018-2019 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.cds.blueprintsprocessor.services.execution.scripts + +import io.grpc.ServerBuilder +import io.grpc.stub.StreamObserver +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.interceptor.GrpcServerLoggingInterceptor +import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType +import org.onap.ccsdk.cds.controllerblueprints.common.api.Status +import org.onap.ccsdk.cds.controllerblueprints.core.MDCContext +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BlueprintProcessingServiceGrpc +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput + +private val log = logger(MockBlueprintProcessingServer::class) + +class MockBlueprintProcessingServer : BlueprintProcessingServiceGrpc.BlueprintProcessingServiceImplBase() { + + override fun process(responseObserver: StreamObserver): StreamObserver { + + return object : StreamObserver { + override fun onNext(executionServiceInput: ExecutionServiceInput) { + log.info( + "Received requestId(${executionServiceInput.commonHeader.requestId}) " + + "subRequestId(${executionServiceInput.commonHeader.subRequestId})" + ) + runBlocking { + launch(MDCContext()) { + responseObserver.onNext(buildNotification(executionServiceInput)) + responseObserver.onNext(buildResponse(executionServiceInput)) + log.info("message has sent successfully...") + } + } + responseObserver.onCompleted() + } + + override fun onError(error: Throwable) { + log.debug("Fail to process message", error) + responseObserver.onError( + io.grpc.Status.INTERNAL + .withDescription(error.message) + .asException() + ) + } + + override fun onCompleted() { + log.info("Completed") + } + } + } + + private fun buildNotification(input: ExecutionServiceInput): ExecutionServiceOutput { + val status = Status.newBuilder() + .setEventType(EventType.EVENT_COMPONENT_NOTIFICATION) + .build() + return ExecutionServiceOutput.newBuilder() + .setCommonHeader(input.commonHeader) + .setActionIdentifiers(input.actionIdentifiers) + .setStatus(status) + .build() + } + + private fun buildResponse(input: ExecutionServiceInput): ExecutionServiceOutput { + + val status = Status.newBuilder().setCode(200) + .setEventType(EventType.EVENT_COMPONENT_EXECUTED) + .build() + return ExecutionServiceOutput.newBuilder() + .setCommonHeader(input.commonHeader) + .setActionIdentifiers(input.actionIdentifiers) + .setStatus(status) + .build() + } +} + +/** For Integration testing stat this server */ +fun main() { + try { + val server = ServerBuilder + .forPort(50052) + .intercept(GrpcServerLoggingInterceptor()) + .addService(MockBlueprintProcessingServer()) + .build() + server.start() + log.info("GRPC Serve started(${server.isShutdown}) on port(${server.port})...") + server.awaitTermination() + } catch (e: Exception) { + e.printStackTrace() + } +} diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt index 28e2b11b2..0d3e42a5e 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt @@ -35,8 +35,8 @@ import org.junit.Test import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_SYNC import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GRPCLibConstants import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties -import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService -import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.MockBluePrintProcessingServer +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BlueprintGrpcLibPropertyService +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.MockBlueprintProcessingServer import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType @@ -67,11 +67,11 @@ class StreamingRemoteExecutionServiceTest { @ExperimentalCoroutinesApi @FlowPreview fun testStreamingChannel() { - grpcCleanup.register(serverBuilder.addService(MockBluePrintProcessingServer()).build().start()) + grpcCleanup.register(serverBuilder.addService(MockBlueprintProcessingServer()).build().start()) val channel = grpcCleanup.register(channelBuilder.maxInboundMessageSize(1024).build()) runBlocking { - val bluePrintGrpcLibPropertyService = BluePrintGrpcLibPropertyService(mockk()) + val bluePrintGrpcLibPropertyService = BlueprintGrpcLibPropertyService(mockk()) val streamingRemoteExecutionService = StreamingRemoteExecutionServiceImpl(bluePrintGrpcLibPropertyService) 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 377b95010..8440e5faa 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 @@ -34,22 +34,22 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers 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.core.service.BluePrintClusterService +import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterService import org.onap.ccsdk.cds.blueprintsprocessor.core.service.CDS_LOCK_GROUP import org.onap.ccsdk.cds.blueprintsprocessor.core.service.ClusterLock import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.nodeTypeComponentScriptExecutor -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation import org.onap.ccsdk.cds.controllerblueprints.core.data.LockAssignment import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl -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.scripts.BlueprintScriptsServiceImpl +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.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration @@ -65,14 +65,14 @@ import kotlin.test.assertNotNull @ContextConfiguration( classes = [ ComponentFunctionScriptingService::class, - BluePrintScriptsServiceImpl::class, DeprecatedBlueprintJythonService::class + BlueprintScriptsServiceImpl::class, DeprecatedBlueprintJythonService::class ] ) class AbstractComponentFunctionTest { - lateinit var bluePrintRuntimeService: DefaultBluePrintRuntimeService - lateinit var blueprintContext: BluePrintContext - lateinit var blueprintClusterService: BluePrintClusterService + lateinit var bluePrintRuntimeService: DefaultBlueprintRuntimeService + lateinit var blueprintContext: BlueprintContext + lateinit var blueprintClusterService: BlueprintClusterService @Autowired lateinit var compSvc: ComponentFunctionScriptingService @@ -149,7 +149,7 @@ class AbstractComponentFunctionTest { @Test fun testComponentScriptExecutorNodeType() { - val componentScriptExecutor = BluePrintTypes.nodeTypeComponentScriptExecutor() + val componentScriptExecutor = BlueprintTypes.nodeTypeComponentScriptExecutor() assertNotNull(componentScriptExecutor.interfaces, "failed to get interface operations") } @@ -274,7 +274,7 @@ class AbstractComponentFunctionTest { /** * Mocked input for abstract function test. */ - private fun getMockedInput(bluePrintRuntime: DefaultBluePrintRuntimeService): + private fun getMockedInput(bluePrintRuntime: DefaultBlueprintRuntimeService): ExecutionServiceInput { val mapper = ObjectMapper() @@ -283,11 +283,11 @@ class AbstractComponentFunctionTest { rootNode.put("type", "rest") val operationInputs = hashMapOf() - operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = + operationInputs[BlueprintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = "activate-restconf".asJsonPrimitive() - operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] = + operationInputs[BlueprintConstants.PROPERTY_CURRENT_INTERFACE] = "interfaceName".asJsonPrimitive() - operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = + operationInputs[BlueprintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive() operationInputs["dynamic-properties"] = rootNode -- cgit 1.2.3-korg