Skip to content

Commit

Permalink
test: Tidy up E2E tests (argoproj#4276)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec authored Oct 14, 2020
1 parent 8ed799f commit e07abe2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 59 deletions.
30 changes: 8 additions & 22 deletions test/e2e/argo_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,10 @@ func (s *ArgoServerSuite) TestHintWhenWorkflowExists() {
s.e().POST("/api/v1/workflows/argo").
WithBytes([]byte((`{
"workflow": {
"apiVersion": "argoproj.io/v1alpha1",
"kind": "Workflow",
"metadata": {
"generateName": "hello-world-",
"name": "hello-world",
"name": "hint",
"labels": {
"workflows.argoproj.io/archive-strategy": "false"
"argo-e2e": "true"
}
},
"spec": {
Expand All @@ -654,11 +651,7 @@ func (s *ArgoServerSuite) TestHintWhenWorkflowExists() {
{
"name": "whalesay",
"container": {
"image": "argoproj/argosay:v2",
"args": [
"exit",
"0"
]
"image": "argoproj/argosay:v2"
}
}
]
Expand All @@ -671,13 +664,10 @@ func (s *ArgoServerSuite) TestHintWhenWorkflowExists() {
s.e().POST("/api/v1/workflows/argo").
WithBytes([]byte((`{
"workflow": {
"apiVersion": "argoproj.io/v1alpha1",
"kind": "Workflow",
"metadata": {
"generateName": "hello-world-",
"name": "hello-world",
"name": "hint",
"labels": {
"workflows.argoproj.io/archive-strategy": "false"
"argo-e2e": "true"
}
},
"spec": {
Expand All @@ -686,21 +676,17 @@ func (s *ArgoServerSuite) TestHintWhenWorkflowExists() {
{
"name": "whalesay",
"container": {
"image": "argoproj/argosay:v2",
"args": [
"exit",
"0"
]
"image": "argoproj/argosay:v2"
}
}
]
}
}
}`))).
Expect().
Status(500).
Status(409).
Body().
Contains("create request failed due to timeout, but it's possible that workflow")
Contains("already exists")
}

func (s *ArgoServerSuite) TestCreateWorkflowDryRun() {
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ func (s *CLISuite) TestTokenArg() {
s.Run("ListWithGoodToken", func() {
s.Given().RunCli([]string{"list", "--user", "fake_token_user", "--token", goodToken}, func(t *testing.T, output string, err error) {
assert.NoError(t, err)
assert.Contains(t, output, "NAME")
assert.Contains(t, output, "STATUS")
})
})
}
Expand Down Expand Up @@ -1153,6 +1151,7 @@ func (s *CLIWithServerSuite) TestResourceTemplateStopAndTerminate() {
RunCli([]string{"submit", "functional/resource-template.yaml", "--name", "resource-tmpl-wf-1"}, func(t *testing.T, output string, err error) {
assert.Contains(t, output, "Pending")
}).
WaitForWorkflow(fixtures.ToBeRunning).
RunCli([]string{"get", "resource-tmpl-wf-1"}, func(t *testing.T, output string, err error) {
assert.Contains(t, output, "Running")
}).
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/fixtures/e2e_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"github.com/argoproj/argo/config"
"github.com/argoproj/argo/pkg/apis/workflow"
"github.com/argoproj/argo/pkg/client/clientset/versioned"
"github.com/argoproj/argo/pkg/client/clientset/versioned/typed/workflow/v1alpha1"
Expand All @@ -34,6 +35,7 @@ const defaultTimeout = 30 * time.Second

type E2ESuite struct {
suite.Suite
Config config.Config
Persistence *Persistence
RestConfig *rest.Config
wfClient v1alpha1.WorkflowInterface
Expand Down
1 change: 1 addition & 0 deletions test/e2e/fixtures/then.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (t *Then) expectWorkflow(workflowName string, block func(t *testing.T, meta
if err != nil {
t.t.Fatal(err)
}
println(wf.Name, ":", wf.Status.Phase, wf.Status.Message)
block(t.t, &wf.ObjectMeta, &wf.Status)
if t.t.Failed() {
t.t.FailNow()
Expand Down
6 changes: 5 additions & 1 deletion test/e2e/fixtures/when.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,18 @@ func (w *When) WaitForWorkflow(options ...interface{}) *When {
select {
case event := <-watch.ResultChan():
wf, ok := event.Object.(*wfv1.Workflow)
print(".")
if ok {
w.hydrateWorkflow(wf)
if condition(wf) {
println("Condition met after", time.Since(start).Truncate(time.Second).String())
w.wf = wf
return w
}
// once done the workflow is done, the condition can never be met
// rather than wait maybe 30s for something that can never happen
if ToBeDone(wf) {
w.t.Fatalf("condition never and cannot be met because the workflow is done")
}
} else {
w.t.Fatal("not ok")
}
Expand Down
51 changes: 17 additions & 34 deletions test/e2e/smoke/artifact-passing.yaml
Original file line number Diff line number Diff line change
@@ -1,57 +1,40 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: artifact-passing
generateName: artifact-passing-
labels:
argo-e2e: true
spec:
entrypoint: artifact-example
volumes:
- name: test-volume
entrypoint: main
templates:
- name: artifact-example
steps:
- - name: generate-artifact
- name: main
dag:
tasks:
- name: generate-artifact
template: generate-message
- - name: consume-artifact
- name: consume-artifact
template: print-message
dependencies:
- generate-artifact
arguments:
artifacts:
- name: message
from: "{{steps.generate-artifact.outputs.artifacts.hello-art}}"
- name: consume-artifact-2
template: print-message-with-volume
arguments:
artifacts:
- name: message
from: "{{steps.generate-artifact.outputs.artifacts.hello-art}}"
- name: in
from: "{{tasks.generate-artifact.outputs.artifacts.out}}"

- name: generate-message
container:
image: argoproj/argosay:v2
args: ["echo", "hello world", "/tmp/hello_world.txt"]
args: [ "echo", "hello world", "/mnt/out/message" ]
outputs:
artifacts:
- name: hello-art
path: /tmp/hello_world.txt
- name: out
path: /mnt/out

- name: print-message
inputs:
artifacts:
- name: message
path: /tmp/message
- name: in
path: /mnt/in
container:
image: argoproj/argosay:v2
args: ["cat", "/tmp/message"]

- name: print-message-with-volume
inputs:
artifacts:
- name: message
path: /test-volume/message
script:
volumeMounts:
- mountPath: /test-volume
name: test-volume
image: argoproj/argosay:v2
args: ["cat", "/test-volume/message"]
args: [ "cat", "/mnt/in/message" ]

0 comments on commit e07abe2

Please sign in to comment.