Updates WF step verification logic before creating graph

- Fixes duplicate issues for function, iterator and gateway steps
- Extends workflow tests for above scenario
This commit is contained in:
Vivek Patel
2021-10-18 12:54:13 +05:30
parent 59ffe768a8
commit e2e7510c07
3 changed files with 175 additions and 32 deletions
+67
View File
@@ -0,0 +1,67 @@
package workflows
import (
"context"
"github.com/stretchr/testify/require"
"testing"
"github.com/cortezaproject/corteza-server/automation/types"
)
func Test0015_step_issue(t *testing.T) {
var (
ctx = bypassRBAC(context.Background())
req = require.New(t)
)
loadScenario(ctx, t)
t.Run("exclusive gateway step issue", func(t *testing.T) {
_, _, err := execWorkflow(ctx, "case1", types.WorkflowExecParams{})
issues, is := err.(types.WorkflowIssueSet)
req.True(is)
// It should return only 3 issues
// 1. gateway step expects at least 1 outbound path(s)
// 2. expecting at least two paths for exclusive gateway
// 3. failed to resolve workflow step dependencies
req.Len(issues, 3)
})
t.Run("inclusive gateway step issue", func(t *testing.T) {
_, _, err := execWorkflow(ctx, "case2", types.WorkflowExecParams{})
issues, is := err.(types.WorkflowIssueSet)
req.True(is)
// It should return only 3 issues
// 1. gateway step expects at least 1 outbound path(s)
// 2. expecting at least two paths for inclusive gateway
// 3. failed to resolve workflow step dependencies
req.Len(issues, 3)
})
t.Run("function step issue", func(t *testing.T) {
_, _, err := execWorkflow(ctx, "case3", types.WorkflowExecParams{})
issues, is := err.(types.WorkflowIssueSet)
req.True(is)
// It should return only 2 issues
// 1. failed to verify argument expressions for function logInfo: parameter message is required
// 2. failed to resolve workflow step dependencies
req.Len(issues, 2)
})
t.Run("iterator step issue", func(t *testing.T) {
_, _, err := execWorkflow(ctx, "case4", types.WorkflowExecParams{})
issues, is := err.(types.WorkflowIssueSet)
req.True(is)
// It should return only 4 issues
// 1. iterator step expects reference
// 2. iterator step expects exactly 2 outbound path(s)
// 3. unknown function ""
// 4. failed to resolve workflow step dependencies
req.Len(issues, 4)
})
}
+83
View File
@@ -0,0 +1,83 @@
workflows:
case1:
enabled: true
trace: true
triggers:
- enabled: true
stepID: 1
steps:
- stepID: 1
kind: expressions
arguments: [ { target: foo, type: Integer, expr: "40" } ]
- stepID: 2
kind: expressions
arguments: [ { target: bar, type: Integer, expr: "50" } ]
- stepID: 3
kind: gateway
ref: excl
paths:
- { parentID: 1, childID: 2 }
case2:
enabled: true
trace: true
triggers:
- enabled: true
stepID: 1
steps:
- stepID: 1
kind: expressions
arguments: [ { target: foo, type: Integer, expr: "40" } ]
- stepID: 2
kind: expressions
arguments: [ { target: bar, type: Integer, expr: "50" } ]
- stepID: 3
kind: gateway
ref: incl
paths:
- { parentID: 1, childID: 2 }
case3:
enabled: true
trace: true
triggers:
- enabled: true
stepID: 1
steps:
- stepID: 1
kind: expressions
arguments: [ { target: foo, type: Integer, expr: "40" } ]
- stepID: 2
kind: expressions
arguments: [ { target: bar, type: Integer, expr: "50" } ]
- stepID: 3
kind: function
ref: logInfo
paths:
- { parentID: 1, childID: 2 }
case4:
enabled: true
trace: true
triggers:
- enabled: true
stepID: 1
steps:
- stepID: 1
kind: expressions
arguments: [ { target: foo, type: Integer, expr: "40" } ]
- stepID: 2
kind: expressions
arguments: [ { target: bar, type: Integer, expr: "50" } ]
- stepID: 3
kind: iterator
paths:
- { parentID: 1, childID: 2 }