Skip to content

Commit

Permalink
test(controller): Add memoization tests. See #3214 (#3455)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Jul 13, 2020
1 parent e3a8319 commit b252b40
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/e2e/argo_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,16 @@ func (s *ArgoServerSuite) TestWorkflowService() {
Equal("Stopped with strategy 'Terminate'")
})

s.Run("Resubmit", func() {
s.e().PUT("/api/v1/workflows/argo/test/resubmit").
WithBytes([]byte(`{"memoized": true}`)).
Expect().
Status(200).
JSON().
Path("$.metadata.name").
NotNull()
})

s.Run("Delete", func() {
s.e().DELETE("/api/v1/workflows/argo/test").
Expect().
Expand Down
38 changes: 38 additions & 0 deletions workflow/controller/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3975,3 +3975,41 @@ func TestCheckForbiddenErrorAndResbmitAllowed(t *testing.T) {
})

}

func TestResubmitMemoization(t *testing.T) {
wf := unmarshalWF(`apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: my-wf
namespace: argo
spec:
entrypoint: main
templates:
- name: main
container:
image: busybox
status:
phase: Failed
nodes:
my-wf-lzarl:
phase: Failed
`)
wf, err := util.FormulateResubmitWorkflow(wf, true)
if assert.NoError(t, err) {
cancel, controller := newController(wf)
defer cancel()
woc := newWorkflowOperationCtx(wf, controller)
woc.operate()
assert.Equal(t, wfv1.NodePending, woc.wf.Status.Phase)
for _, node := range woc.wf.Status.Nodes {
switch node.TemplateName {
case "main":
assert.Equal(t, wfv1.NodePending, node.Phase)
assert.False(t, node.StartTime().IsZero())
case "":
default:
assert.Fail(t, "invalid template")
}
}
}
}

0 comments on commit b252b40

Please sign in to comment.