Skip to content

Commit

Permalink
test: Add daemon set tests. Fixes #7409 (#7675)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <[email protected]>
  • Loading branch information
alexec committed Jan 28, 2022
1 parent ed9b093 commit 0419bae
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
111 changes: 111 additions & 0 deletions test/e2e/daemon_pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,117 @@ spec:
})
}

func (s *DaemonPodSuite) TestDaemonFromWorkflowTemplate() {
s.Given().
WorkflowTemplate(`
metadata:
name: daemon
spec:
entrypoint: main
templates:
- name: main
dag:
tasks:
- name: redis
template: redis-tmpl
- name: whale
dependencies: [redis]
template: whale-tmpl
- name: redis-tmpl
daemon: true
container:
image: argoproj/argosay:v2
args: ["sleep", "100s"]
- name: whale-tmpl
container:
image: argoproj/argosay:v2
`).
When().
CreateWorkflowTemplates().
SubmitWorkflowsFromWorkflowTemplates().
WaitForWorkflow(fixtures.ToBeSucceeded)
}

func (s *DaemonPodSuite) TestDaemonFromClusterWorkflowTemplate() {
s.Given().
ClusterWorkflowTemplate(`
metadata:
name: daemon
spec:
entrypoint: main
templates:
- name: main
dag:
tasks:
- name: redis
template: redis-tmpl
- name: whale
dependencies: [redis]
template: whale-tmpl
- name: redis-tmpl
daemon: true
container:
image: argoproj/argosay:v2
args: ["sleep", "100s"]
- name: whale-tmpl
container:
image: argoproj/argosay:v2
`).
When().
CreateClusterWorkflowTemplates().
SubmitWorkflowsFromClusterWorkflowTemplates().
WaitForWorkflow(fixtures.ToBeSucceeded)
}

func (s *DaemonPodSuite) TestDaemonTemplateRef() {
s.Given().
WorkflowTemplate(`
metadata:
name: broken-pipeline
spec:
entrypoint: main
templates:
- name: do-something
container:
image: argoproj/argosay:v2
- name: main
dag:
tasks:
- name: do-something
template: do-something
- name: run-tests-broken
depends: "do-something"
templateRef:
name: run-tests-broken
template: main
`).
WorkflowTemplate(`
metadata:
name: run-tests-broken
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: postgres
template: postgres
- - name: run-tests-broken
template: run-tests-broken
- name: run-tests-broken
container:
image: argoproj/argosay:v2
- name: postgres
daemon: true
container:
image: argoproj/argosay:v2
args: ["sleep", "100s"]
name: database`).
When().
CreateWorkflowTemplates().
SubmitWorkflowsFromWorkflowTemplates().
WaitForWorkflow(fixtures.ToBeSucceeded)
}

func (s *DaemonPodSuite) TestMarkDaemonedPodSucceeded() {
s.Given().
Workflow("@testdata/daemoned-pod-completed.yaml").
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/fixtures/when.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func (w *When) SubmitWorkflow() *When {

func label(obj metav1.Object) {
labels := obj.GetLabels()
if labels == nil {
labels = map[string]string{}
}
if labels[Label] == "" {
labels[Label] = "true"
obj.SetLabels(labels)
Expand All @@ -70,6 +73,9 @@ func (w *When) SubmitWorkflowsFromWorkflowTemplates() *When {
ctx := context.Background()
for _, tmpl := range w.wfTemplates {
_, _ = fmt.Println("Submitting workflow from workflow template", tmpl.Name)
if tmpl.Spec.WorkflowMetadata == nil {
tmpl.Spec.WorkflowMetadata = &metav1.ObjectMeta{}
}
label(tmpl.Spec.WorkflowMetadata)
wf, err := w.client.Create(ctx, common.NewWorkflowFromWorkflowTemplate(tmpl.Name, tmpl.Spec.WorkflowMetadata, false), metav1.CreateOptions{})
if err != nil {
Expand All @@ -86,6 +92,9 @@ func (w *When) SubmitWorkflowsFromClusterWorkflowTemplates() *When {
ctx := context.Background()
for _, tmpl := range w.cwfTemplates {
_, _ = fmt.Println("Submitting workflow from cluster workflow template", tmpl.Name)
if tmpl.Spec.WorkflowMetadata == nil {
tmpl.Spec.WorkflowMetadata = &metav1.ObjectMeta{}
}
label(tmpl.Spec.WorkflowMetadata)
wf, err := w.client.Create(ctx, common.NewWorkflowFromWorkflowTemplate(tmpl.Name, tmpl.Spec.WorkflowMetadata, true), metav1.CreateOptions{})
if err != nil {
Expand Down

0 comments on commit 0419bae

Please sign in to comment.