Skip to content

Commit

Permalink
test: Add e2e test for argoproj#12636
Browse files Browse the repository at this point in the history
Signed-off-by: Shiwei Tang <siwe.tang@gmail.com>
  • Loading branch information
siwet committed Apr 21, 2024
1 parent 49e21ac commit aade1a0
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
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,47 @@ func (s *CLISuite) TestRetryWorkflowWithContinueOn() {
})
}

func (s *CLISuite) TestWorkflowRetryTTLDeletePod() {
var workflowName string
var retryTime metav1.Time
var opts metav1.ListOptions
s.Given().
Workflow("@testdata/retry-ttl-delete-pod.yaml").
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
}, time.Second*5).
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-ttl-delete-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: retry-test-12636-
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 aade1a0

Please sign in to comment.