Skip to content

Commit

Permalink
fix: Flaky test about lifecycle hooks
Browse files Browse the repository at this point in the history
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
  • Loading branch information
toyamagu-2021 committed Aug 6, 2023
1 parent 54ab391 commit 4076420
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions test/e2e/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,36 +344,35 @@ spec:
hooks:
running:
expression: workflow.status == "Running"
template: sleep
template: argosay-sleep-2seconds
# This hook never triggered by following test.
# To guarantee workflow does not wait forever for untriggered hooks.
failed:
expression: workflow.status == "Failed"
template: sleep
template: argosay-sleep-2seconds
templates:
- name: main
steps:
- - name: step1
template: exit0
template: argosay
- name: exit0
- name: argosay
container:
image: alpine:latest
image: argoproj/argosay:v2
command: ["/bin/sh", "-c"]
args: ["exit 0"]
- name: sleep
args: ["/bin/sleep 1; /argosay"]
- name: argosay-sleep-2seconds
container:
image: alpine:latest
image: argoproj/argosay:v2
command: ["/bin/sh", "-c"]
args: ["/bin/sleep 2; exit 0"]
args: ["/bin/sleep 2; /argosay"]
`).When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeSucceeded).
Then().
ExpectWorkflow(func(t *testing.T, metadata *v1.ObjectMeta, status *v1alpha1.WorkflowStatus) {
assert.Equal(t, status.Phase, v1alpha1.WorkflowSucceeded)
// TODO: This is sometimes "1/1" which might be a bug we need to investigate later.
//assert.Equal(t, status.Progress, v1alpha1.Progress("2/2"))
assert.Equal(t, status.Progress, v1alpha1.Progress("2/2"))
assert.Equal(t, 1, int(status.Progress.N()/status.Progress.M()))
}).
ExpectWorkflowNode(func(status v1alpha1.NodeStatus) bool {
Expand All @@ -396,34 +395,32 @@ spec:
- name: main
steps:
- - name: job
template: exit0
template: argosay
hooks:
running:
expression: steps['job'].status == "Running"
template: hook
template: argosay-sleep-2seconds
failed:
expression: steps['job'].status == "Failed"
template: hook
- name: hook
script:
image: alpine:latest
command: [/bin/sh]
source: |
sleep 2
- name: exit0
script:
image: alpine:latest
command: [/bin/sh]
source: |
exit 0
template: argosay-sleep-2seconds
- name: argosay
container:
image: argoproj/argosay:v2
command: ["/bin/sh", "-c"]
args: ["/bin/sleep 1; /argosay"]
- name: argosay-sleep-2seconds
container:
image: argoproj/argosay:v2
command: ["/bin/sh", "-c"]
args: ["/bin/sleep 2; /argosay"]
`).When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeSucceeded).
Then().
ExpectWorkflow(func(t *testing.T, metadata *v1.ObjectMeta, status *v1alpha1.WorkflowStatus) {
assert.Equal(t, status.Phase, v1alpha1.WorkflowSucceeded)
// TODO: This is sometimes "1/1" which might be a bug we need to investigate later.
//assert.Equal(t, status.Progress, v1alpha1.Progress("2/2"))
assert.Equal(t, status.Progress, v1alpha1.Progress("2/2"))
}).
ExpectWorkflowNode(func(status v1alpha1.NodeStatus) bool {
return strings.Contains(status.Name, "job.hooks.running")
Expand Down

0 comments on commit 4076420

Please sign in to comment.