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: Improved e2e test robustness #4758

Merged
merged 1 commit into from
Dec 16, 2020
Merged
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
3 changes: 2 additions & 1 deletion test/e2e/argo_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,8 @@ func (s *ArgoServerSuite) TestWorkflowService() {
{
"name": "run-workflow",
"container": {
"image": "argoproj/argosay:v2"
"image": "argoproj/argosay:v2",
"args": ["sleep", "10s"]
}
}
],
Expand Down
39 changes: 0 additions & 39 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1239,45 +1239,6 @@ func (s *CLISuite) TestRetryOmit() {
WaitForWorkflow()
}

func (s *CLISuite) TestSynchronizationWfLevelMutex() {
s.NeedsOffloading()
s.Given().
Workflow("@functional/synchronization-mutex-wf-level.yaml").
When().
RunCli([]string{"submit", "functional/synchronization-mutex-wf-level-1.yaml"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err) {
assert.Contains(t, output, "synchronization-wf-level-mutex")
}
}).
SubmitWorkflow().
Wait(1*time.Second).
RunCli([]string{"get", "synchronization-wf-level-mutex"}, func(t *testing.T, output string, err error) {
assert.Contains(t, output, "Pending")
}).
WaitForWorkflow(fixtures.ToBeCompleted, 120*time.Second).
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.NodeSucceeded, status.Phase)
})
}

func (s *CLISuite) TestTemplateLevelMutex() {
s.NeedsOffloading()
s.Given().
Workflow("@functional/synchronization-mutex-tmpl-level.yaml").
When().
SubmitWorkflow().
Wait(3*time.Second).
RunCli([]string{"get", "synchronization-tmpl-level-mutex"}, func(t *testing.T, output string, err error) {
assert.Contains(t, output, "Waiting for")
}).
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.NodeSucceeded, status.Phase)
})
}

func (s *CLISuite) TestResourceTemplateStopAndTerminate() {
s.NeedsOffloading()
s.Run("ResourceTemplateStop", func() {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/fixtures/given.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ var NoError = func(t *testing.T, output string, err error) {
assert.NoError(t, err, output)
}

var OutputContains = func(contains string) func(t *testing.T, output string, err error) {
var OutputRegexp = func(rx string) func(t *testing.T, output string, err error) {
return func(t *testing.T, output string, err error) {
t.Helper()
if assert.NoError(t, err, output) {
assert.Contains(t, output, contains)
assert.Regexp(t, rx, output)
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/fixtures/when.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ var ToBeDone Condition = func(wf *wfv1.Workflow) bool {

var ToBeArchived Condition = func(wf *wfv1.Workflow) bool { return wf.Labels[common.LabelKeyWorkflowArchivingStatus] == "Archived" }

var ToBeWaitingOnAMutex Condition = func(wf *wfv1.Workflow) bool {
return wf.Status.Synchronization != nil && wf.Status.Synchronization.Mutex != nil
}

// Wait for a workflow to meet a condition:
// Options:
// * `time.Duration` - change the timeout - 30s by default
Expand Down
38 changes: 34 additions & 4 deletions test/e2e/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *FunctionalSuite) TestDeletingPendingPod() {
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToStart, "to start").
Exec("kubectl", []string{"-n", "argo", "delete", "pod", "-l", "workflows.argoproj.io/workflow"}, fixtures.OutputContains(`pod "sleepy" deleted`)).
Exec("kubectl", []string{"-n", "argo", "delete", "pod", "-l", "workflows.argoproj.io/workflow"}, fixtures.OutputRegexp(`pod "sleepy-.*" deleted`)).
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
Expand All @@ -59,14 +59,14 @@ func (s *FunctionalSuite) TestDeletingRunningPod() {
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeRunning, "to be running").
Exec("kubectl", []string{"-n", "argo", "delete", "pod", "-l", "workflows.argoproj.io/workflow"}, fixtures.NoError).
Exec("kubectl", []string{"-n", "argo", "delete", "pod", "-l", "workflows.argoproj.io/workflow"}, fixtures.OutputRegexp(`pod "sleepy-.*" deleted`)).
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.NodeError, status.Phase)
assert.Len(t, status.Nodes, 1)
if assert.Contains(t, status.Nodes, "sleepy") {
assert.Equal(t, "pod deleted during operation", status.Nodes["sleepy"].Message)
if assert.Contains(t, status.Nodes, metadata.Name) {
assert.Equal(t, "pod deleted during operation", status.Nodes[metadata.Name].Message)
}
})
}
Expand All @@ -88,6 +88,36 @@ func (s *FunctionalSuite) TestDeletingRunningPodWithOrErrorRetryPolicy() {
})
}

func (s *FunctionalSuite) TestSynchronizationWfLevelMutex() {
s.Given().
Workflow("@functional/synchronization-mutex-wf-level-1.yaml").
When().
SubmitWorkflow().
Given().
Workflow("@functional/synchronization-mutex-wf-level.yaml").
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeWaitingOnAMutex, "to be waiting on a mutex").
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.NodeSucceeded, status.Phase)
})
}

func (s *FunctionalSuite) TestTemplateLevelMutex() {
s.Given().
Workflow("@functional/synchronization-mutex-tmpl-level.yaml").
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeWaitingOnAMutex, "to be waiting on a mutex").
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.NodeSucceeded, status.Phase)
})
}

func (s *FunctionalSuite) TestWorkflowTTL() {
s.Given().
Workflow(`
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/testdata/sleepy-workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: Workflow
apiVersion: argoproj.io/v1alpha1
metadata:
name: sleepy
generateName: sleepy-
labels:
argo-e2e: "true"
spec:
Expand Down