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 Apr 21, 2024
1 parent 49e21ac commit 1b95a86
Show file tree
Hide file tree
Showing 3 changed files with 120 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
}).
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
26 changes: 26 additions & 0 deletions test/e2e/manifests/tswtest/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
#- ../../../../manifests/quick-start/mysql
- ../../../../manifests/quick-start/minimal
- https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/base/crds/argoproj.io_eventbus.yaml
- https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/base/crds/argoproj.io_eventsources.yaml
- https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/base/crds/argoproj.io_sensors.yaml
- ../mixins/argo-server.service-account-token-secret.yaml
#- ../../../../manifests/cluster-install/workflow-controller-rbac
#- ../../../../manifests/quick-start/base/workflow-default-rolebinding.yaml

patches:
- path: ../mixins/argo-server-deployment.yaml
- path: ../mixins/argo-server-cluster-workflow-template-rbac.yaml
- path: ../mixins/workflow-controller-configmap.yaml
- path: ../mixins/workflow-controller-deployment.yaml
- path: ../mixins/workflow-controller-cluster-workflow-template-rbac.yaml
- path: ../mixins/minio-deployment.yaml
#
labels:
- includeSelectors: true
pairs:
app.kubernetes.io/part-of: argo
namespace: argo
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 1b95a86

Please sign in to comment.