Skip to content

Commit

Permalink
fix(test): Add e2e test. Fixes #13196
Browse files Browse the repository at this point in the history
Signed-off-by: oninowang <[email protected]>
  • Loading branch information
jswxstw authored and oninowang committed Jun 18, 2024
1 parent 0e5b027 commit 785f75a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,47 @@ func (s *CLISuite) TestRetryWorkflowWithContinueOn() {
})
}

func (s *CLISuite) TestRetryWorkflowWithFailedExitHandler() {
var workflowName string
s.Given().
Workflow(`@testdata/retry-workflow-with-failed-exit-handler.yaml`).
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeFailed).
Then().
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
workflowName = metadata.Name
assert.Equal(t, 2, len(status.Nodes))
}).
RunCli([]string{"retry", workflowName}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err, output) {
assert.Contains(t, output, "Name:")
assert.Contains(t, output, "Namespace:")
}
})

s.Given().
When().
WaitForWorkflow(fixtures.ToBeCompleted).
Then().
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
workflowName = metadata.Name
assert.Equal(t, wfv1.WorkflowFailed, status.Phase)
assert.Equal(t, 2, len(status.Nodes))
}).
ExpectWorkflowNode(func(status wfv1.NodeStatus) bool {
return status.Name == workflowName
}, func(t *testing.T, status *wfv1.NodeStatus, pod *corev1.Pod) {
assert.Equal(t, wfv1.NodeSucceeded, status.Phase)
}).
ExpectWorkflowNode(func(status wfv1.NodeStatus) bool {
return strings.Contains(status.Name, ".onExit")
}, func(t *testing.T, status *wfv1.NodeStatus, pod *corev1.Pod) {
assert.Equal(t, wfv1.NodeFailed, status.Phase)
assert.Contains(t, status.Message, "exit code 1")
})
}

func (s *CLISuite) TestWorkflowStop() {
s.Given().
Workflow("@smoke/basic.yaml").
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/testdata/retry-workflow-with-failed-exit-handler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: retry-workflow-with-failed-exit-handler
spec:
entrypoint: hello
onExit: exit-handler
templates:
- name: hello
container:
image: alpine:3.18
command: [sh, -c]
args: ["echo hello"]
- name: exit-handler
container:
image: alpine:3.18
command: [sh, -c]
args: ["exit 1"]

0 comments on commit 785f75a

Please sign in to comment.