From a0c608cb4d247802ea11950b7b888ec0882c65a7 Mon Sep 17 00:00:00 2001 From: jswxstw Date: Fri, 28 Jun 2024 22:16:30 +0800 Subject: [PATCH] fix(test): test logged progress with initial progress and workflow uses legacy/insecure pod patch. Fixes #13057 Signed-off-by: jswxstw --- workflow/controller/operator_test.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/workflow/controller/operator_test.go b/workflow/controller/operator_test.go index 822d790729858..45335f0d769e2 100644 --- a/workflow/controller/operator_test.go +++ b/workflow/controller/operator_test.go @@ -281,6 +281,9 @@ spec: - name: pod template: pod - name: pod + metadata: + annotations: + workflows.argoproj.io/progress: 0/100 container: image: my-image `) @@ -291,17 +294,25 @@ spec: woc := newWorkflowOperationCtx(wf, controller) woc.operate(ctx) - makePodsPhase(ctx, woc, apiv1.PodRunning, withProgress("50/100")) + assert.Equal(t, wfv1.WorkflowRunning, woc.wf.Status.Phase) + assert.Equal(t, wfv1.Progress("0/100"), woc.wf.Status.Progress) + assert.Equal(t, wfv1.Progress("0/100"), woc.wf.Status.Nodes[woc.wf.Name].Progress) + pod := woc.wf.Status.Nodes.FindByDisplayName("pod") + assert.Equal(t, wfv1.Progress("0/100"), pod.Progress) + + // mock workflow uses legacy/insecure pod patch + makePodsPhase(ctx, woc, apiv1.PodRunning, withAnnotation(common.AnnotationKeyReportOutputsCompleted, "false"), withProgress("50/100")) woc = newWorkflowOperationCtx(woc.wf, controller) woc.operate(ctx) assert.Equal(t, wfv1.WorkflowRunning, woc.wf.Status.Phase) assert.Equal(t, wfv1.Progress("50/100"), woc.wf.Status.Progress) assert.Equal(t, wfv1.Progress("50/100"), woc.wf.Status.Nodes[woc.wf.Name].Progress) - pod := woc.wf.Status.Nodes.FindByDisplayName("pod") + pod = woc.wf.Status.Nodes.FindByDisplayName("pod") assert.Equal(t, wfv1.Progress("50/100"), pod.Progress) - makePodsPhase(ctx, woc, apiv1.PodSucceeded, withProgress("100/100")) + // mock workflow uses legacy/insecure pod patch + makePodsPhase(ctx, woc, apiv1.PodSucceeded, withAnnotation(common.AnnotationKeyReportOutputsCompleted, "true"), withProgress("100/100")) woc = newWorkflowOperationCtx(woc.wf, controller) woc.operate(ctx) @@ -6271,7 +6282,7 @@ func TestConfigMapCacheSaveOperate(t *testing.T) { ctx := context.Background() woc.operate(ctx) - makePodsPhase(ctx, woc, apiv1.PodSucceeded, withExitCode(0), withOutputs(wfv1.MustMarshallJSON(sampleOutputs))) + makePodsPhase(ctx, woc, apiv1.PodSucceeded, withExitCode(0), withAnnotation(common.AnnotationKeyReportOutputsCompleted, "true"), withOutputs(wfv1.MustMarshallJSON(sampleOutputs))) woc = newWorkflowOperationCtx(woc.wf, controller) woc.operate(ctx) @@ -6555,7 +6566,7 @@ spec: assert.Equal(t, wfv1.WorkflowRunning, woc.wf.Status.Phase) // make all created pods as successful - makePodsPhase(ctx, woc, apiv1.PodSucceeded, withOutputs(`{"parameters": [{"name": "my-param"}]}`)) + makePodsPhase(ctx, woc, apiv1.PodSucceeded, withAnnotation(common.AnnotationKeyReportOutputsCompleted, "true"), withOutputs(`{"parameters": [{"name": "my-param"}]}`)) // reconcile woc = newWorkflowOperationCtx(woc.wf, controller)