From 90d5cbded1f01f96530e11305c28a84bf6983414 Mon Sep 17 00:00:00 2001 From: toyamagu-2021 Date: Sun, 6 Aug 2023 20:33:12 +0900 Subject: [PATCH] fix: Flaky test about lifecycle hooks Signed-off-by: toyamagu-2021 --- test/e2e/hooks_test.go | 53 ++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/test/e2e/hooks_test.go b/test/e2e/hooks_test.go index 04a4b2008d2a..7401778be1c3 100644 --- a/test/e2e/hooks_test.go +++ b/test/e2e/hooks_test.go @@ -344,36 +344,35 @@ spec: hooks: running: expression: workflow.status == "Running" - template: sleep + template: argosay-sleep-2second # 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-2second 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-2second 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 { @@ -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-2second 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-2second + + - name: argosay + container: + image: argoproj/argosay:v2 + command: ["/bin/sh", "-c"] + args: ["/bin/sleep 1; /argosay"] + - name: argosay-sleep-2second + 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")