forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BugFix: SubWorkflow and dynamic node handling failure (flyteorg#84)
* Handling Finalize for subworkflows * config change * improved logging * Fixing the regression Increment was called before calling the abort. Since the logic is derived using the current attempt number, everything broke * updated and fixed tests * comment updated * updated * More unit tests
- Loading branch information
Ketan Umare
authored
Mar 13, 2020
1 parent
bc96237
commit 34c7598
Showing
10 changed files
with
108 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package subworkflow | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/mock" | ||
|
||
"github.com/lyft/flytepropeller/pkg/apis/flyteworkflow/v1alpha1" | ||
coreMocks "github.com/lyft/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks" | ||
execMocks "github.com/lyft/flytepropeller/pkg/controller/executors/mocks" | ||
"github.com/lyft/flytepropeller/pkg/controller/nodes/handler/mocks" | ||
) | ||
|
||
func Test_subworkflowHandler_HandleAbort(t *testing.T) { | ||
ctx := context.TODO() | ||
|
||
t.Run("missing-subworkflow", func(t *testing.T) { | ||
nCtx := &mocks.NodeExecutionContext{} | ||
nodeExec := &execMocks.Node{} | ||
s := newSubworkflowHandler(nodeExec) | ||
wf := &coreMocks.ExecutableWorkflow{} | ||
wf.OnFindSubWorkflow("x").Return(nil) | ||
nCtx.OnNodeID().Return("n1") | ||
assert.Error(t, s.HandleAbort(ctx, nCtx, wf, "x", "reason")) | ||
}) | ||
|
||
t.Run("missing-startNode", func(t *testing.T) { | ||
nCtx := &mocks.NodeExecutionContext{} | ||
nodeExec := &execMocks.Node{} | ||
s := newSubworkflowHandler(nodeExec) | ||
wf := &coreMocks.ExecutableWorkflow{} | ||
st := &coreMocks.ExecutableNodeStatus{} | ||
swf := &coreMocks.ExecutableSubWorkflow{} | ||
wf.OnFindSubWorkflow("x").Return(swf) | ||
wf.OnGetNodeExecutionStatus(ctx, "n1").Return(st) | ||
nCtx.OnNodeID().Return("n1") | ||
swf.OnStartNode().Return(nil) | ||
assert.Error(t, s.HandleAbort(ctx, nCtx, wf, "x", "reason")) | ||
}) | ||
|
||
t.Run("abort-error", func(t *testing.T) { | ||
nCtx := &mocks.NodeExecutionContext{} | ||
nodeExec := &execMocks.Node{} | ||
s := newSubworkflowHandler(nodeExec) | ||
wf := &coreMocks.ExecutableWorkflow{} | ||
st := &coreMocks.ExecutableNodeStatus{} | ||
swf := &coreMocks.ExecutableSubWorkflow{} | ||
wf.OnFindSubWorkflow("x").Return(swf) | ||
wf.OnGetNodeExecutionStatus(ctx, "n1").Return(st) | ||
nCtx.OnNodeID().Return("n1") | ||
n := &coreMocks.ExecutableNode{} | ||
swf.OnStartNode().Return(n) | ||
nodeExec.OnAbortHandler(ctx, wf, n, "reason").Return(fmt.Errorf("err")) | ||
assert.Error(t, s.HandleAbort(ctx, nCtx, wf, "x", "reason")) | ||
}) | ||
|
||
t.Run("abort-success", func(t *testing.T) { | ||
nCtx := &mocks.NodeExecutionContext{} | ||
nodeExec := &execMocks.Node{} | ||
s := newSubworkflowHandler(nodeExec) | ||
wf := &coreMocks.ExecutableWorkflow{} | ||
st := &coreMocks.ExecutableNodeStatus{} | ||
swf := &coreMocks.ExecutableSubWorkflow{} | ||
wf.OnFindSubWorkflow("x").Return(swf) | ||
wf.OnGetNodeExecutionStatus(ctx, "n1").Return(st) | ||
nCtx.OnNodeID().Return("n1") | ||
n := &coreMocks.ExecutableNode{} | ||
swf.OnStartNode().Return(n) | ||
swf.OnGetID().Return("swf") | ||
nodeExec.OnAbortHandlerMatch(mock.Anything, mock.MatchedBy(func(wf v1alpha1.ExecutableWorkflow) bool { | ||
return wf.GetID() == swf.GetID() | ||
}), n, mock.Anything).Return(nil) | ||
assert.NoError(t, s.HandleAbort(ctx, nCtx, wf, "x", "reason")) | ||
}) | ||
} |