Skip to content

Commit

Permalink
test: Add e2e test for "workflows that are retrying should not be del…
Browse files Browse the repository at this point in the history
…eted"

Signed-off-by: Shiwei Tang <siwe.tang@gmail.com>
  • Loading branch information
siwet committed May 9, 2024
1 parent 49e21ac commit 536693a
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/e2e/cli_test.go
Expand Up @@ -963,6 +963,47 @@ func (s *CLISuite) TestRetryWorkflowWithContinueOn() {
})
}

func (s *CLISuite) TestWorkflowRetryWithTTLExpired() {
var workflowName string
var retryTime metav1.Time
var opts metav1.ListOptions
s.Given().
Workflow("@testdata/retry-with-ttl-expired").
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToStart).
WaitForWorkflow(fixtures.Condition(func(wf *wfv1.Workflow) (bool, string) {
workflowName = wf.Name
nodeStatus := wf.Status.Nodes.FindByDisplayName("A")
return nodeStatus != nil && nodeStatus.Message == "Error (exit code 36)",
"Node A should failed"
})).
WaitForWorkflow(fixtures.Condition(func(wf *wfv1.Workflow) (bool, string) {
retryTime = wf.Status.FinishedAt
return wf.Status.Failed(), "Workflow failed, while be deleted after 3s"
})).
RunCli([]string{"retry", workflowName, "-p", "fail=false"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err, output) {
assert.Contains(t, output, "Name:")
assert.Contains(t, output, "Namespace:")
}
time.Sleep(5 * time.Second) // wait 5s for pod deletion
opts = metav1.ListOptions{LabelSelector: fixtures.Label, FieldSelector: "metadata.name=" + workflowName}
}).
WaitForWorkflowList(opts, func(list []wfv1.Workflow) bool {
assert.Len(s.T(), list, 1)
//"Node A sleep 5s, should not be deleted after retry"
return true
}).
WaitForWorkflow(fixtures.ToBeCompleted).
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.True(t, status.Successful())
nodeB := status.Nodes.FindByDisplayName("B")
assert.True(t, retryTime.Before(&nodeB.FinishedAt))
})
}

func (s *CLISuite) TestWorkflowStop() {
s.Given().
Workflow("@smoke/basic.yaml").
Expand Down
53 changes: 53 additions & 0 deletions test/e2e/testdata/retry-with-ttl-expired.yaml
@@ -0,0 +1,53 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: retry-with-ttl-expired-
spec:
entrypoint: main
ttlStrategy:
secondsAfterFailure: 3
arguments:
parameters:
- name: fail
value: 'true'
templates:
- name: main
dag:
tasks:
- name: A
template: first-fail
arguments:
parameters:
- name: fail
value: "{{workflow.parameters.fail}}"
- name: B
depends: "A"
template: echo

- name: first-fail
inputs:
parameters:
- name: fail
container:
image: alpine:3.19
imagePullPolicy: IfNotPresent
command: [sh, -c]
args:
- |
set -e
if [ "{{inputs.parameters.fail}}" == "true" ]; then
echo "Failing"
exit 36
fi
echo "Succeeded"
- name: echo
container:
image: alpine:3.19
imagePullPolicy: IfNotPresent
command: [sh, -c]
args:
- |
set -e
echo "sleep 20s"
sleep 5
echo "finished"

0 comments on commit 536693a

Please sign in to comment.