Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add e2e test for #12636 #12959

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) TestWorkflowRetryWithTTLExpired() {
var workflowName string
var retryTime metav1.Time
var opts metav1.ListOptions
s.Given().
Workflow("@testdata/retry-with-ttl-expired.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
}).
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
52 changes: 52 additions & 0 deletions test/e2e/testdata/retry-with-ttl-expired.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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 5s"
sleep 5
echo "finished"