aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKAPIL SINGAL <ks220y@att.com>2022-04-13 12:47:30 +0000
committerGerrit Code Review <gerrit@onap.org>2022-04-13 12:47:30 +0000
commit221223e7d0689e5d43d72acba112f95589b51892 (patch)
tree47cf2c4f7d8d6ad29e45c676be36a37df64fe5fb
parentf5329877c16a910338274240d8e5e80ad7a28573 (diff)
parent577316e6c8fbf21bb25f41174cd80f7bd8df327a (diff)
Merge "Return errormessages in failing imperative workflows"
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/uat-imperative-workflow.json24
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Tests/uat.yaml27
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatExecutor.kt3
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt3
5 files changed, 55 insertions, 4 deletions
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/uat-imperative-workflow.json b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/uat-imperative-workflow.json
index 508d8b2e2..16466df85 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/uat-imperative-workflow.json
+++ b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/uat-imperative-workflow.json
@@ -112,6 +112,30 @@
}
}
}
+ },
+ "uat-unhandled-error" : {
+ "steps" : {
+ "execute-A" : {
+ "target" : "execute-script-1",
+ "on_success" : [ "finalize" ],
+ "on_failure" : [ "clean-up" ]
+ },
+ "finalize" : {
+ "target" : "execute-script-3"
+ },
+ "clean-up" : {
+ "target" : "execute-script-4"
+ }
+ },
+ "inputs" : {
+ "service-instance-id" : {
+ "type" : "string"
+ },
+ "failing-steps" : {
+ "type" : "json"
+ }
+ },
+ "outputs" : {}
}
},
"node_templates" : {
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Tests/uat.yaml b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Tests/uat.yaml
index 3aab65e8a..693cad696 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Tests/uat.yaml
+++ b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Tests/uat.yaml
@@ -305,4 +305,29 @@ processes:
execute-script-1: FAILED
execute-script-2: FAILED
execute-script-3: null
- execute-script-4: SUCCEEDED \ No newline at end of file
+ execute-script-4: SUCCEEDED
+
+ - name: uat-unhandled-error
+ request:
+ commonHeader: &ch
+ originatorId: sdnc
+ requestId: "1234"
+ subRequestId: "1234-12234"
+ actionIdentifiers: &ai
+ blueprintName: uat-imperative-workflow
+ blueprintVersion: "1.0.0"
+ actionName: uat-unhandled-error
+ mode: sync
+ payload:
+ uat-unhandled-error-request:
+ failing-steps:
+ execute-A: true
+ clean-up: true
+ expectedResponse:
+ commonHeader: *ch
+ actionIdentifiers: *ai
+ status:
+ code: 500
+ eventType: EVENT_COMPONENT_FAILURE
+ errorMessage: "Step failed: execute-A, Step failed: clean-up, node(clean-up) outgoing edge(FAILURE) is missing."
+ message: failure \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatExecutor.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatExecutor.kt
index 1e1d3ac2a..ae9b7d35c 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatExecutor.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatExecutor.kt
@@ -241,7 +241,8 @@ class UatExecutor(
}
val response = client.execute(request) { response ->
val statusLine = response.statusLine
- assertThat("${process.name}", statusLine.statusCode, equalTo(HttpStatus.SC_OK))
+ val expectedCode = expectedResponse?.get("status")?.get("code")?.intValue()
+ assertThat("${process.name}", statusLine.statusCode, equalTo(expectedCode ?: HttpStatus.SC_OK))
val entity = response.entity
assertThat("${process.name} Response contains no content", entity, notNullValue())
entity.content.bufferedReader().use { it.readText() }
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt
index 1ac49d6fe..18dcd16f7 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt
@@ -35,4 +35,6 @@ class BluePrintError {
fun allErrors(): List<String> = errors.values.flatten()
fun stepErrors(stepName: String): MutableList<String>? = errors[stepName]
+
+ fun clearAll() = errors.clear();
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
index b8350f4f1..fbe51acae 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
@@ -119,6 +119,7 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
}
message = BluePrintConstants.STATUS_FAILURE
} else {
+ bluePrintRuntimeService.getBluePrintError().clearAll()
message = BluePrintConstants.STATUS_SUCCESS
}
eventType = EventType.EVENT_COMPONENT_EXECUTED.name
@@ -163,8 +164,6 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
.executeNodeTemplate(bluePrintRuntimeService, node.id, nodeTemplateName, nodeInput)
if (executionServiceOutput.status.message == BluePrintConstants.STATUS_FAILURE) {
- // Clear step errors so that the workflow does not fail
- bluePrintRuntimeService.getBluePrintError().stepErrors(node.id)?.clear()
return EdgeLabel.FAILURE
}