Skip to content

Commit

Permalink
fix(test): test logged progress with initial progress and workflow us…
Browse files Browse the repository at this point in the history
…es legacy/insecure pod patch. Fixes #13057

Signed-off-by: jswxstw <[email protected]>
  • Loading branch information
jswxstw committed Jun 28, 2024
1 parent 789bc17 commit 5079fe4
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions workflow/controller/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ spec:
- name: pod
template: pod
- name: pod
metadata:
annotations:
workflows.argoproj.io/progress: 0/100
container:
image: my-image
`)
Expand All @@ -290,17 +293,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)

Expand Down Expand Up @@ -6288,7 +6299,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)

Expand Down Expand Up @@ -6578,7 +6589,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)
Expand Down

0 comments on commit 5079fe4

Please sign in to comment.