Add UAT for imperative workflow 37/119637/4
authorJozsef Csongvai <jozsef.csongvai@bell.ca>
Sun, 14 Mar 2021 23:10:30 +0000 (19:10 -0400)
committerKAPIL SINGAL <ks220y@att.com>
Wed, 24 Mar 2021 20:44:53 +0000 (20:44 +0000)
Issue-ID: CCSDK-3219
Change-Id: I7b6e619fb60e687885b5545ba323bd7bb15ec209
Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
(cherry picked from commit f19c463ecaf39655005441c4c0e352140c153a82)

12 files changed:
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/artifact_types.json [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/data_types.json [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/node_types.json [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/policy_types.json [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/relationship_types.json [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/resources_definition_types.json [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/uat-imperative-workflow.json [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Scripts/kotlin/CollectorScript.kt [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Scripts/kotlin/TestScript.kt [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/TOSCA-Metadata/TOSCA.meta [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Templates/assign-mapping.json [new file with mode: 0644]
components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Tests/uat.yaml [new file with mode: 0644]

diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/artifact_types.json
new file mode 100644 (file)
index 0000000..a730e48
--- /dev/null
@@ -0,0 +1,10 @@
+{
+  "artifact_types" : {
+    "artifact-mapping-resource" : {
+      "description" : "Resource Mapping File used along with Configuration template",
+      "version" : "1.0.0",
+      "derived_from" : "tosca.artifacts.Implementation",
+      "file_ext" : [ "json" ]
+    }
+  }
+}
\ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/data_types.json b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/data_types.json
new file mode 100644 (file)
index 0000000..1b8f2b3
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "data_types" : {
+    "dt-uat-wf-properties" : {
+      "description" : "Dynamic DataType definition for workflow(uat-wf).",
+      "version" : "1.0.0",
+      "properties" : {
+        "service-instance-id" : {
+          "required" : true,
+          "type" : "string"
+        }
+      },
+      "derived_from" : "tosca.datatypes.Dynamic"
+    }
+  }
+}
\ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/node_types.json b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/node_types.json
new file mode 100644 (file)
index 0000000..e86405c
--- /dev/null
@@ -0,0 +1,185 @@
+{
+  "node_types" : {
+    "component-resource-resolution" : {
+      "description" : "This is Resource Assignment Component API",
+      "version" : "1.0.0",
+      "attributes" : {
+        "assignment-params" : {
+          "description" : "Holds resolved template, resolution-summary or key-value",
+          "required" : true,
+          "type" : "string"
+        },
+        "assignment-map" : {
+          "description" : "Holds resolved values for each artifact prefix eg. { vdns: { vnf-id: 123 } }",
+          "required" : true,
+          "type" : "map"
+        }
+      },
+      "capabilities" : {
+        "component-node" : {
+          "type" : "tosca.capabilities.Node"
+        }
+      },
+      "interfaces" : {
+        "ResourceResolutionComponent" : {
+          "operations" : {
+            "process" : {
+              "inputs" : {
+                "resolution-key" : {
+                  "description" : "Key for service instance related correlation.",
+                  "required" : false,
+                  "type" : "string"
+                },
+                "occurrence" : {
+                  "description" : "Number of time to perform the resolution.",
+                  "required" : false,
+                  "type" : "integer",
+                  "default" : 1
+                },
+                "store-result" : {
+                  "description" : "Whether or not to store the output.",
+                  "required" : false,
+                  "type" : "boolean"
+                },
+                "resource-type" : {
+                  "description" : "Request type.",
+                  "required" : false,
+                  "type" : "string"
+                },
+                "resolution-summary" : {
+                  "description" : "Enable resolution-summary output",
+                  "required" : false,
+                  "type" : "boolean"
+                },
+                "artifact-prefix-names" : {
+                  "description" : "Template , Resource Assignment Artifact Prefix names",
+                  "required" : true,
+                  "type" : "list",
+                  "entry_schema" : {
+                    "type" : "string"
+                  }
+                },
+                "request-id" : {
+                  "description" : "Request Id, Unique Id for the request.",
+                  "required" : true,
+                  "type" : "string"
+                },
+                "resource-id" : {
+                  "description" : "Resource Id.",
+                  "required" : false,
+                  "type" : "string"
+                },
+                "action-name" : {
+                  "description" : "Action Name of the process",
+                  "required" : false,
+                  "type" : "string"
+                },
+                "dynamic-properties" : {
+                  "description" : "Dynamic Json Content or DSL Json reference.",
+                  "required" : false,
+                  "type" : "json"
+                }
+              },
+              "outputs" : {
+                "resource-assignment-params" : {
+                  "required" : true,
+                  "type" : "string"
+                },
+                "resource-assignment-map" : {
+                  "required" : true,
+                  "type" : "string"
+                },
+                "status" : {
+                  "required" : true,
+                  "type" : "string"
+                }
+              }
+            }
+          }
+        }
+      },
+      "derived_from" : "tosca.nodes.Component"
+    },
+    "component-script-executor" : {
+      "description" : "This is CLI Transaction Configuration Component API",
+      "version" : "1.0.0",
+      "attributes" : {
+        "response-data" : {
+          "required" : false,
+          "type" : "json"
+        }
+      },
+      "capabilities" : {
+        "component-node" : {
+          "type" : "tosca.capabilities.Node"
+        }
+      },
+      "interfaces" : {
+        "ComponentScriptExecutor" : {
+          "operations" : {
+            "process" : {
+              "inputs" : {
+                "script-type" : {
+                  "description" : "Script type, kotlin type is supported",
+                  "required" : true,
+                  "type" : "string",
+                  "constraints" : [ {
+                    "valid_values" : [ "kotlin", "jython", "internal" ]
+                  } ],
+                  "default" : "internal"
+                },
+                "script-class-reference" : {
+                  "description" : "Kotlin Script class name or jython script name.",
+                  "required" : true,
+                  "type" : "string"
+                },
+                "instance-dependencies" : {
+                  "description" : "Instance names to inject to Jython or Kotlin Script.",
+                  "required" : true,
+                  "type" : "list",
+                  "entry_schema" : {
+                    "type" : "string"
+                  }
+                },
+                "dynamic-properties" : {
+                  "description" : "Dynamic Json Content or DSL Json reference.",
+                  "required" : false,
+                  "type" : "json"
+                }
+              },
+              "outputs" : {
+                "response-data" : {
+                  "description" : "Execution Response Data.",
+                  "required" : false,
+                  "type" : "string"
+                },
+                "status" : {
+                  "description" : "Status of the Component Execution ( success or failure )",
+                  "required" : true,
+                  "type" : "string"
+                }
+              }
+            }
+          }
+        }
+      },
+      "derived_from" : "tosca.nodes.Component"
+    },
+    "source-input" : {
+      "description" : "This is Input Resource Source Node Type",
+      "version" : "1.0.0",
+      "properties" : { },
+      "derived_from" : "tosca.nodes.ResourceSource"
+    },
+    "tosca.nodes.Component" : {
+      "description" : "This is default Component Node",
+      "version" : "1.0.0",
+      "derived_from" : "tosca.nodes.Root"
+    },
+    "tosca.nodes.ResourceSource" : {
+      "description" : "TOSCA base type for Resource Sources",
+      "version" : "1.0.0",
+      "derived_from" : "tosca.nodes.Root"
+    }
+  }
+}
\ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/policy_types.json b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/policy_types.json
new file mode 100644 (file)
index 0000000..1e44cc7
--- /dev/null
@@ -0,0 +1,3 @@
+{
+  "policy_types" : { }
+}
\ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/relationship_types.json
new file mode 100644 (file)
index 0000000..4ddd7a5
--- /dev/null
@@ -0,0 +1,3 @@
+{
+  "relationship_types" : { }
+}
\ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Definitions/resources_definition_types.json
new file mode 100644 (file)
index 0000000..c7277c0
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "input-source" : {
+    "tags" : "input-source",
+    "name" : "input-source",
+    "property" : {
+      "description" : "name of the ",
+      "type" : "string"
+    },
+    "group" : "default",
+    "updated-by" : "brindasanth@onap.com",
+    "sources" : {
+      "input" : {
+        "type" : "source-input",
+        "properties" : { }
+      }
+    }
+  }
+}
\ No newline at end of file
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
new file mode 100644 (file)
index 0000000..508d8b2
--- /dev/null
@@ -0,0 +1,246 @@
+{
+  "tosca_definitions_version" : "controller_blueprint_1_0_0",
+  "metadata" : {
+    "template_author" : "cds-dev",
+    "author-email" : "test@bell.ca",
+    "template_name" : "uat-imperative-workflow",
+    "template_version" : "1.0.0",
+    "template_tags" : "UAT, CBA, test",
+    "template_type" : "DEFAULT"
+  },
+  "imports" : [ {
+    "file" : "Definitions/data_types.json"
+  }, {
+    "file" : "Definitions/relationship_types.json"
+  }, {
+    "file" : "Definitions/artifact_types.json"
+  }, {
+    "file" : "Definitions/node_types.json"
+  }, {
+    "file" : "Definitions/policy_types.json"
+  } ],
+  "dsl_definitions" : { },
+  "topology_template" : {
+    "workflows" : {
+      "uat-wf" : {
+        "steps" : {
+          "assign" : {
+            "target" : "resource-resolution",
+            "on_success" : [ "deploy" ],
+            "on_failure" : [ "assign-recover" ]
+          },
+          "assign-recover" : {
+            "target" : "execute-script-1",
+            "on_success" : [ "deploy" ],
+            "on_failure" : [ "collect" ]
+          },
+          "deploy" : {
+            "target" : "execute-script-2",
+            "on_success" : [ "collect" ],
+            "on_failure" : [ "deploy-recover" ]
+          },
+          "deploy-recover" : {
+            "target" : "execute-script-3",
+            "on_success" : [ "collect" ],
+            "on_failure" : [ "collect" ]
+          },
+          "collect" : {
+            "target" : "collect-results"
+          }
+        },
+        "inputs" : {
+          "service-instance-id" : {
+            "type" : "string"
+          },
+          "failing-steps" : {
+            "type" : "json"
+          },
+          "uat-wf-properties" : {
+            "description" : "Dynamic PropertyDefinition for workflow(uat-wf).",
+            "required" : true,
+            "type" : "dt-uat-wf-properties"
+          }
+        },
+        "outputs" : {
+          "results" : {
+            "type" : "string",
+            "value" : {
+              "get_attribute" : [ "collect-results", "response-data" ]
+            }
+          }
+        }
+      },
+      "uat-wf-parallel" : {
+        "steps" : {
+          "execute-A" : {
+            "target" : "execute-script-1",
+            "on_success" : [ "finalize" ],
+            "on_failure" : [ "clean-up" ]
+          },
+          "execute-B" : {
+            "target" : "execute-script-2",
+            "on_success" : [ "finalize" ],
+            "on_failure" : [ "clean-up" ]
+          },
+          "finalize" : {
+            "target" : "execute-script-3",
+            "on_success" : [ "clean-up" ],
+            "on_failure" : [ "clean-up" ]
+          },
+          "clean-up" : {
+            "target" : "execute-script-4",
+            "on_success" : [ "collect" ],
+            "on_failure" : [ "collect" ]
+          },
+          "collect" : {
+            "target" : "collect-results"
+          }
+        },
+        "inputs" : {
+          "service-instance-id" : {
+            "type" : "string"
+          },
+          "failing-steps" : {
+            "type" : "json"
+          }
+        },
+        "outputs" : {
+          "results" : {
+            "type" : "string",
+            "value" : {
+              "get_attribute" : [ "collect-results", "response-data" ]
+            }
+          }
+        }
+      }
+    },
+    "node_templates" : {
+      "resource-resolution" : {
+        "type" : "component-resource-resolution",
+        "interfaces" : {
+          "ResourceResolutionComponent" : {
+            "operations" : {
+              "process" : {
+                "inputs" : {
+                  "artifact-prefix-names" : [ "assign" ],
+                  "store-result" : false
+                }
+              }
+            }
+          }
+        },
+        "artifacts" : {
+          "assign-mapping" : {
+            "type" : "artifact-mapping-resource",
+            "file" : "Templates/assign-mapping.json"
+          }
+        }
+      },
+      "execute-script-1" : {
+        "type" : "component-script-executor",
+        "interfaces" : {
+          "ComponentScriptExecutor" : {
+            "operations" : {
+              "process" : {
+                "implementation" : {
+                  "primary" : "component-script",
+                  "timeout" : 180,
+                  "operation_host" : "SELF"
+                },
+                "inputs" : {
+                  "script-type" : "kotlin",
+                  "script-class-reference" : "cba.cds.uat.TestScript"
+                },
+                "outputs" : { }
+              }
+            }
+          }
+        }
+      },
+      "execute-script-2" : {
+        "type" : "component-script-executor",
+        "interfaces" : {
+          "ComponentScriptExecutor" : {
+            "operations" : {
+              "process" : {
+                "implementation" : {
+                  "primary" : "component-script",
+                  "timeout" : 180,
+                  "operation_host" : "SELF"
+                },
+                "inputs" : {
+                  "script-type" : "kotlin",
+                  "script-class-reference" : "cba.cds.uat.TestScript"
+                },
+                "outputs" : { }
+              }
+            }
+          }
+        }
+      },
+      "execute-script-3" : {
+        "type" : "component-script-executor",
+        "interfaces" : {
+          "ComponentScriptExecutor" : {
+            "operations" : {
+              "process" : {
+                "implementation" : {
+                  "primary" : "component-script",
+                  "timeout" : 180,
+                  "operation_host" : "SELF"
+                },
+                "inputs" : {
+                  "script-type" : "kotlin",
+                  "script-class-reference" : "cba.cds.uat.TestScript"
+                },
+                "outputs" : { }
+              }
+            }
+          }
+        }
+      },
+      "execute-script-4" : {
+        "type" : "component-script-executor",
+        "interfaces" : {
+          "ComponentScriptExecutor" : {
+            "operations" : {
+              "process" : {
+                "implementation" : {
+                  "primary" : "component-script",
+                  "timeout" : 180,
+                  "operation_host" : "SELF"
+                },
+                "inputs" : {
+                  "script-type" : "kotlin",
+                  "script-class-reference" : "cba.cds.uat.TestScript"
+                },
+                "outputs" : { }
+              }
+            }
+          }
+        }
+      },
+      "collect-results" : {
+        "type" : "component-script-executor",
+        "interfaces" : {
+          "ComponentScriptExecutor" : {
+            "operations" : {
+              "process" : {
+                "implementation" : {
+                  "primary" : "component-script",
+                  "timeout" : 180,
+                  "operation_host" : "SELF"
+                },
+                "inputs" : {
+                  "script-type" : "kotlin",
+                  "script-class-reference" : "cba.cds.uat.CollectorScript"
+                },
+                "outputs" : { }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Scripts/kotlin/CollectorScript.kt b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Scripts/kotlin/CollectorScript.kt
new file mode 100644 (file)
index 0000000..28ce149
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  Copyright © 20201 Bell Canada.
+ *
+ *  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 cba.cds.uat
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
+import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+
+open class CollectorScript : AbstractScriptComponentFunction() {
+
+    private val log = logger(CollectorScript::class)
+
+    override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+        bluePrintRuntimeService.bluePrintContext()
+                .serviceTemplate.topologyTemplate!!.nodeTemplates!!
+                .keys.filter { it.startsWith("execute-script") }
+                .associateWith { responseData(it) }
+                .let { it.asJsonNode() }
+                .also { log.info("Collected results: $it") }
+                .let { setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, it) }
+    }
+
+    private fun responseData(nodeTemplateName: String): JsonNode? {
+        return try {
+            bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
+                    ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA)
+        } catch (exception: BlueprintProcessorException) { null }
+    }
+
+    override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+        addError(runtimeException.message ?: "Failed without error message")
+    }
+}
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Scripts/kotlin/TestScript.kt b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Scripts/kotlin/TestScript.kt
new file mode 100644 (file)
index 0000000..af3ebff
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *  Copyright © 20201 Bell Canada.
+ *
+ *  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 cba.cds.uat
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
+import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+
+open class TestScript : AbstractScriptComponentFunction() {
+
+    private val log = logger(TestScript::class)
+
+    private val FAILED = "FAILED".asJsonPrimitive()
+    private val SUCCEEDED = "SUCCEEDED".asJsonPrimitive()
+
+    override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+        val failingSteps = inputValue("failing-steps")
+        var shouldFail = false
+        if (failingSteps?.has(this.stepName) == true) {
+            shouldFail = failingSteps[this.stepName].asBoolean()
+        }
+        log.info("running step ${this.stepName}, should fail: $shouldFail")
+        setAttribute("response-data", if (shouldFail) FAILED else SUCCEEDED)
+
+        if (shouldFail) {
+            throw BlueprintException("Step failed: ${this.stepName}")
+        }
+    }
+
+    fun inputValue(name: String): JsonNode? {
+        return try {
+            return bluePrintRuntimeService.getInputValue(name)
+        } catch (e: BlueprintProcessorException) { null }
+    }
+
+    override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+        log.info("Executing Recovery for step ${this.stepName}")
+        addError(runtimeException.message ?: "Failed without error message")
+    }
+}
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/TOSCA-Metadata/TOSCA.meta
new file mode 100644 (file)
index 0000000..33e51a7
--- /dev/null
@@ -0,0 +1,8 @@
+TOSCA-Meta-File-Version: 1.0.0
+CSAR-Version: 1.0
+Created-By: cds-dev
+Entry-Definitions: Definitions/uat-imperative-workflow.json
+Template-Tags: UAT, CBA, test
+Template-Name: uat-imperative-workflow
+Template-Version: 1.0.0
+Template-Type: DEFAULT
\ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Templates/assign-mapping.json b/components/model-catalog/blueprint-model/uat-blueprints/imperative_workflow/Templates/assign-mapping.json
new file mode 100644 (file)
index 0000000..57a0ad4
--- /dev/null
@@ -0,0 +1,13 @@
+[
+  {
+    "name": "service-instance-id",
+    "input-param": true,
+    "property": {
+      "type": "string",
+      "required": true
+    },
+    "dictionary-name": "input-source",
+    "dictionary-source": "input",
+    "dependencies": []
+  }
+]
\ No newline at end of file
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
new file mode 100644 (file)
index 0000000..3aab65e
--- /dev/null
@@ -0,0 +1,308 @@
+%YAML 1.1
+---
+#  Imperative workflow UAT
+#
+#  The CBA has 4 node-templates: execute-script-N(1..4), which all execute TestScript.kt
+#  The kotlin script will either succeed or fail depending on request input values
+#  example input:
+#    "uat-wf-request": {
+#        "service-instance-id": {},
+#        "failing-steps": {
+#           "assign": true
+#           "deploy-recover": true
+#        }
+#    }
+#  The kotlin script will look for failing-steps[stepName], if value is present and true
+#  an exception will be thrown, causing the step to fail.
+#
+#  All workflows end with running CollectorScripts.kt which will produce the final
+#  response payload with the execution results.
+#
+#    "uat-wf-response": {
+#            "results": {
+#                "execute-script-1": null,  (script was not executed)
+#                "execute-script-2": "SUCCEEDED",
+#                "execute-script-3": null,
+#                "execute-script-4": "FAILED"
+#            }
+#        }
+#
+#  CBA WORKFLOWS
+#   uat-wf
+#     steps: step (target node-template) : outgoing edges
+#       assign (resource-resolution) : success -> deploy, failure -> assign-recover
+#       assign-recover (execute-script-1) : success -> deploy, failure -> collect
+#       deploy (execute-script-2) : success -> collect, failure -> deploy-recover
+#       deploy-recover (execute-script-3) : success -> collect, failure -> collect
+#       collect (collect-results)
+#
+#   uat-wf-parallel - 2 parallel start nodes
+#     steps: step (target node-template) : outgoing edges
+#       execute-A (execute-script-1) : success -> finalize, failure -> clean-up
+#       execute-B (execute-script-2) : success -> finalize, failure -> clean-up
+#       finalize (execute-script-3) : success -> clean-up, failure -> clean-up
+#       clean-up (execute-script-4) : success -> collect, failure -> collect
+#       collect (collect-results)
+
+processes:
+# Test cases for uat-wf
+  - name: uat-wf-happy-case
+    request:
+      commonHeader: &ch
+        originatorId: sdnc
+        requestId: "1234"
+        subRequestId: "1234-12234"
+      actionIdentifiers: &ai
+        blueprintName: uat-imperative-workflow
+        blueprintVersion: "1.0.0"
+        actionName: uat-wf
+        mode: sync
+      payload:
+        uat-wf-request:
+          service-instance-id: test-123
+    #Expected flow: assign -> deploy -> collect
+    expectedResponse:
+      commonHeader: *ch
+      actionIdentifiers: *ai
+      status:
+        code: 200
+        eventType: EVENT_COMPONENT_EXECUTED
+        errorMessage: null
+        message: success
+      payload:
+        uat-wf-response:
+          results:
+            execute-script-1: null
+            execute-script-2: SUCCEEDED
+            execute-script-3: null
+            execute-script-4: null
+
+  - name: uat-wf-assign-fails
+    request:
+      commonHeader: &ch
+        originatorId: sdnc
+        requestId: "1234"
+        subRequestId: "1234-12234"
+      actionIdentifiers: &ai
+        blueprintName: uat-imperative-workflow
+        blueprintVersion: "1.0.0"
+        actionName: uat-wf
+        mode: sync
+      payload:
+        uat-wf-request:
+          #service-instance-id: assign will fail when this is removed
+    #Expected flow: assign(fail) -> assign-recover -> deploy -> collect
+    expectedResponse:
+      commonHeader: *ch
+      actionIdentifiers: *ai
+      status:
+        code: 200
+        eventType: EVENT_COMPONENT_EXECUTED
+        errorMessage: null
+        message: success
+      payload:
+        uat-wf-response:
+          results:
+            execute-script-1: SUCCEEDED
+            execute-script-2: SUCCEEDED
+            execute-script-3: null
+            execute-script-4: null
+
+  - name: uat-wf-assign-recover-fails
+    request:
+      commonHeader: &ch
+        originatorId: sdnc
+        requestId: "1234"
+        subRequestId: "1234-12234"
+      actionIdentifiers: &ai
+        blueprintName: uat-imperative-workflow
+        blueprintVersion: "1.0.0"
+        actionName: uat-wf
+        mode: sync
+      payload:
+        uat-wf-request:
+          #service-instance-id: assign will fail when this is removed
+          failing-steps:
+            assign-recover: true
+    # Expected flow: assign(fail) -> assign-recover(fail) -> collect
+    expectedResponse:
+      commonHeader: *ch
+      actionIdentifiers: *ai
+      status:
+        code: 200
+        eventType: EVENT_COMPONENT_EXECUTED
+        errorMessage: null
+        message: success
+      payload:
+        uat-wf-response:
+          results:
+            execute-script-1: FAILED
+            execute-script-2: null
+            execute-script-3: null
+            execute-script-4: null
+
+  - name: uat-wf-deploy-fail
+    request:
+      commonHeader: &ch
+        originatorId: sdnc
+        requestId: "1234"
+        subRequestId: "1234-12234"
+      actionIdentifiers: &ai
+        blueprintName: uat-imperative-workflow
+        blueprintVersion: "1.0.0"
+        actionName: uat-wf
+        mode: sync
+      payload:
+        uat-wf-request:
+          service-instance-id: test-123
+          failing-steps:
+            deploy: true
+    #Expected flow: assign -> deploy(fail) -> deploy-recover -> collect
+    expectedResponse:
+      commonHeader: *ch
+      actionIdentifiers: *ai
+      status:
+        code: 200
+        eventType: EVENT_COMPONENT_EXECUTED
+        errorMessage: null
+        message: success
+      payload:
+        uat-wf-response:
+          results:
+            execute-script-1: null
+            execute-script-2: FAILED
+            execute-script-3: SUCCEEDED
+            execute-script-4: null
+
+  - name: uat-wf-assign-fail-and-deploy-fail
+    request:
+      commonHeader: &ch
+        originatorId: sdnc
+        requestId: "1234"
+        subRequestId: "1234-12234"
+      actionIdentifiers: &ai
+        blueprintName: uat-imperative-workflow
+        blueprintVersion: "1.0.0"
+        actionName: uat-wf
+        mode: sync
+      payload:
+        uat-wf-request:
+          #service-instance-id: assign will fail when this is removed
+          failing-steps:
+            deploy: true
+    #Expected flow: assign(fail) -> assign-recover -> deploy(fail) -> deploy-recover -> collect
+    expectedResponse:
+      commonHeader: *ch
+      actionIdentifiers: *ai
+      status:
+        code: 200
+        eventType: EVENT_COMPONENT_EXECUTED
+        errorMessage: null
+        message: success
+      payload:
+        uat-wf-response:
+          results:
+            execute-script-1: SUCCEEDED
+            execute-script-2: FAILED
+            execute-script-3: SUCCEEDED
+            execute-script-4: null
+
+# Test cases for uat-wf-parallel
+  - name: uat-wf-parallel-happy-case
+    request:
+      commonHeader: &ch
+        originatorId: sdnc
+        requestId: "1234"
+        subRequestId: "1234-12234"
+      actionIdentifiers: &ai
+        blueprintName: uat-imperative-workflow
+        blueprintVersion: "1.0.0"
+        actionName: uat-wf-parallel
+        mode: sync
+      payload:
+        uat-wf-parallel-request:
+    #Expected flow: execute-A, execute-B -> finalize -> clean-up -> collect
+    expectedResponse:
+      commonHeader: *ch
+      actionIdentifiers: *ai
+      status:
+        code: 200
+        eventType: EVENT_COMPONENT_EXECUTED
+        errorMessage: null
+        message: success
+      payload:
+        uat-wf-parallel-response:
+          results:
+            execute-script-1: SUCCEEDED
+            execute-script-2: SUCCEEDED
+            execute-script-3: SUCCEEDED
+            execute-script-4: SUCCEEDED
+
+  - name: uat-wf-execute-script-1-fail
+    request:
+      commonHeader: &ch
+        originatorId: sdnc
+        requestId: "1234"
+        subRequestId: "1234-12234"
+      actionIdentifiers: &ai
+        blueprintName: uat-imperative-workflow
+        blueprintVersion: "1.0.0"
+        actionName: uat-wf-parallel
+        mode: sync
+      payload:
+        uat-wf-parallel-request:
+          failing-steps:
+            execute-A: true
+    #Expected flow: execute-A (fail) ------>
+    #                                        clean-up -> collect
+    #               execute-B -> finalize ->
+    expectedResponse:
+      commonHeader: *ch
+      actionIdentifiers: *ai
+      status:
+        code: 200
+        eventType: EVENT_COMPONENT_EXECUTED
+        errorMessage: null
+        message: success
+      payload:
+        uat-wf-parallel-response:
+          results:
+            execute-script-1: FAILED
+            execute-script-2: SUCCEEDED
+            execute-script-3: SUCCEEDED
+            execute-script-4: SUCCEEDED
+
+  - name: uat-wf-both-execute-scrips-fail
+    request:
+      commonHeader: &ch
+        originatorId: sdnc
+        requestId: "1234"
+        subRequestId: "1234-12234"
+      actionIdentifiers: &ai
+        blueprintName: uat-imperative-workflow
+        blueprintVersion: "1.0.0"
+        actionName: uat-wf-parallel
+        mode: sync
+      payload:
+        uat-wf-parallel-request:
+          failing-steps:
+            execute-A: true
+            execute-B: true
+    #Expected flow: execute-A (fail) ->
+    #                                   clean-up -> collect
+    #               execute-B (fail) ->
+    expectedResponse:
+      commonHeader: *ch
+      actionIdentifiers: *ai
+      status:
+        code: 200
+        eventType: EVENT_COMPONENT_EXECUTED
+        errorMessage: null
+        message: success
+      payload:
+        uat-wf-parallel-response:
+          results:
+            execute-script-1: FAILED
+            execute-script-2: FAILED
+            execute-script-3: null
+            execute-script-4: SUCCEEDED
\ No newline at end of file