From 4b9a9e676f7cef73a8bdc51abb34b04f05b68208 Mon Sep 17 00:00:00 2001 From: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com> Date: Sat, 20 Nov 2021 00:31:58 +0530 Subject: [PATCH] Add exists operation to diff summary, update tests accordingly (#379) --- pkg/kapp/clusterapply/changes_view.go | 2 +- test/e2e/annotations_test.go | 16 ++++++++-------- test/e2e/config_test.go | 4 ++-- test/e2e/diff_filter_test.go | 16 ++++++++-------- test/e2e/diff_test.go | 8 ++++---- test/e2e/exists_ann_test.go | 4 ++-- test/e2e/filter_test.go | 8 ++++---- test/e2e/noop_ann_test.go | 4 ++-- test/e2e/order_test.go | 4 ++-- test/e2e/warnings_test.go | 4 ++-- 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/pkg/kapp/clusterapply/changes_view.go b/pkg/kapp/clusterapply/changes_view.go index e9cc62e11..711b93760 100644 --- a/pkg/kapp/clusterapply/changes_view.go +++ b/pkg/kapp/clusterapply/changes_view.go @@ -235,7 +235,7 @@ func (v *ChangesCountsView) Add(applyOp ClusterChangeApplyOp, waitOp ClusterChan func (v *ChangesCountsView) Strings(table bool) []string { applyOpsStats := []string{} visibleApplyOps := []ClusterChangeApplyOp{ - ClusterChangeApplyOpAdd, ClusterChangeApplyOpDelete, ClusterChangeApplyOpUpdate, ClusterChangeApplyOpNoop} + ClusterChangeApplyOpAdd, ClusterChangeApplyOpDelete, ClusterChangeApplyOpUpdate, ClusterChangeApplyOpNoop, ClusterChangeApplyOpExists} for _, op := range visibleApplyOps { applyOpsStats = append(applyOpsStats, fmt.Sprintf("%d %s", v.applyOps[op], applyOpCodeUI[op])) diff --git a/test/e2e/annotations_test.go b/test/e2e/annotations_test.go index 077340f5c..c9e6da6eb 100644 --- a/test/e2e/annotations_test.go +++ b/test/e2e/annotations_test.go @@ -113,7 +113,7 @@ metadata: respNonVer := uitest.JSONUIFromBytes(t, []byte(nonVerOut)) - validateChanges(t, respNonVer.Tables, expectedNonVer, "Op: 2 create, 0 delete, 0 update, 0 noop", + validateChanges(t, respNonVer.Tables, expectedNonVer, "Op: 2 create, 0 delete, 0 update, 0 noop, 0 exists", "Wait to: 2 reconcile, 0 delete, 0 noop", nonVerOut) verOut, _ := kapp.RunWithOpts([]string{"deploy", "-f", "-", "-a", name, "--json"}, @@ -163,7 +163,7 @@ metadata: "wait_to": "reconcile", }} - validateChanges(t, respVer.Tables, expectedVer, "Op: 2 create, 2 delete, 0 update, 0 noop", + validateChanges(t, respVer.Tables, expectedVer, "Op: 2 create, 2 delete, 0 update, 0 noop, 0 exists", "Wait to: 2 reconcile, 2 delete, 0 noop", verOut) verKeepOrgOut, _ := kapp.RunWithOpts([]string{"deploy", "-f", "-", "-a", name, "--json"}, @@ -215,7 +215,7 @@ metadata: }, } - validateChanges(t, respVerKeepOrg.Tables, expectedVerKeepOrg, "Op: 4 create, 0 delete, 0 update, 0 noop", + validateChanges(t, respVerKeepOrg.Tables, expectedVerKeepOrg, "Op: 4 create, 0 delete, 0 update, 0 noop, 0 exists", "Wait to: 4 reconcile, 0 delete, 0 noop", verKeepOrgOut) }) @@ -271,7 +271,7 @@ metadata: }, } - validateChanges(t, respVerKeepOrg.Tables, expectedVerKeepOrg, "Op: 4 create, 0 delete, 0 update, 0 noop", + validateChanges(t, respVerKeepOrg.Tables, expectedVerKeepOrg, "Op: 4 create, 0 delete, 0 update, 0 noop, 0 exists", "Wait to: 4 reconcile, 0 delete, 0 noop", verKeepOrgOut) verOut, _ := kapp.RunWithOpts([]string{"deploy", "-f", "-", "-a", name, "--json"}, @@ -321,7 +321,7 @@ metadata: "wait_to": "reconcile", }} - validateChanges(t, respVer.Tables, expectedVer, "Op: 2 create, 2 delete, 0 update, 0 noop", + validateChanges(t, respVer.Tables, expectedVer, "Op: 2 create, 2 delete, 0 update, 0 noop, 0 exists", "Wait to: 2 reconcile, 2 delete, 0 noop", verOut) }) @@ -377,7 +377,7 @@ metadata: }, } - validateChanges(t, respVerKeepOrg.Tables, expectedVerKeepOrg, "Op: 4 create, 0 delete, 0 update, 0 noop", + validateChanges(t, respVerKeepOrg.Tables, expectedVerKeepOrg, "Op: 4 create, 0 delete, 0 update, 0 noop, 0 exists", "Wait to: 4 reconcile, 0 delete, 0 noop", verKeepOrgOut) nonVerOut, _ := kapp.RunWithOpts([]string{"deploy", "-f", "-", "-a", name, "--json"}, @@ -427,7 +427,7 @@ metadata: "wait_to": "delete", }} - validateChanges(t, respNonVer.Tables, expectedVer, "Op: 0 create, 2 delete, 2 update, 0 noop", + validateChanges(t, respNonVer.Tables, expectedVer, "Op: 0 create, 2 delete, 2 update, 0 noop, 0 exists", "Wait to: 2 reconcile, 2 delete, 0 noop", nonVerOut) }) } @@ -497,7 +497,7 @@ data: "reconcile_state": "", "wait_to": "reconcile", }} - validateChanges(t, respKapp.Tables, expectedKapp, "Op: 1 create, 1 delete, 0 update, 0 noop", + validateChanges(t, respKapp.Tables, expectedKapp, "Op: 1 create, 1 delete, 0 update, 0 noop, 0 exists", "Wait to: 1 reconcile, 1 delete, 0 noop", kappOut) }) } diff --git a/test/e2e/config_test.go b/test/e2e/config_test.go index f63465a7f..2fb189838 100644 --- a/test/e2e/config_test.go +++ b/test/e2e/config_test.go @@ -211,7 +211,7 @@ secrets: expected := []map[string]string{} require.Exactlyf(t, expected, resp.Tables[0].Rows, "Expected to see correct changes, but did not") - require.Equalf(t, "Op: 0 create, 0 delete, 0 update, 0 noop", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") + require.Equalf(t, "Op: 0 create, 0 delete, 0 update, 0 noop, 0 exists", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") }) } } @@ -399,7 +399,7 @@ data: expected := []map[string]string{} require.Exactlyf(t, expected, resp.Tables[0].Rows, "Expected to see correct changes, but did not") - require.Equalf(t, "Op: 0 create, 0 delete, 0 update, 0 noop", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") + require.Equalf(t, "Op: 0 create, 0 delete, 0 update, 0 noop, 0 exists", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") cm = NewPresentClusterResource("configmap", "test-cm", env.Namespace, kubectl) data := cm.RawPath(ctlres.NewPathFromStrings([]string{"data"})).(map[string]interface{}) diff --git a/test/e2e/diff_filter_test.go b/test/e2e/diff_filter_test.go index 5e3262b73..562070a40 100644 --- a/test/e2e/diff_filter_test.go +++ b/test/e2e/diff_filter_test.go @@ -105,7 +105,7 @@ data: resp := uitest.JSONUIFromBytes(t, []byte(out)) - validateChanges(t, resp.Tables, expectedChange, "Op: 1 create, 0 delete, 0 update, 0 noop", + validateChanges(t, resp.Tables, expectedChange, "Op: 1 create, 0 delete, 0 update, 0 noop, 0 exists", "Wait to: 1 reconcile, 0 delete, 0 noop", out) }) @@ -128,7 +128,7 @@ data: resp := uitest.JSONUIFromBytes(t, []byte(out)) - validateChanges(t, resp.Tables, expectedChange, "Op: 1 create, 0 delete, 0 update, 0 noop", + validateChanges(t, resp.Tables, expectedChange, "Op: 1 create, 0 delete, 0 update, 0 noop, 0 exists", "Wait to: 1 reconcile, 0 delete, 0 noop", out) }) @@ -151,7 +151,7 @@ data: resp := uitest.JSONUIFromBytes(t, []byte(out)) - validateChanges(t, resp.Tables, expectedChange, "Op: 0 create, 0 delete, 1 update, 0 noop", + validateChanges(t, resp.Tables, expectedChange, "Op: 0 create, 0 delete, 1 update, 0 noop, 0 exists", "Wait to: 1 reconcile, 0 delete, 0 noop", out) }) @@ -174,7 +174,7 @@ data: resp := uitest.JSONUIFromBytes(t, []byte(out)) - validateChanges(t, resp.Tables, expectedChange, "Op: 0 create, 1 delete, 0 update, 0 noop", + validateChanges(t, resp.Tables, expectedChange, "Op: 0 create, 1 delete, 0 update, 0 noop, 0 exists", "Wait to: 0 reconcile, 1 delete, 0 noop", out) }) @@ -197,7 +197,7 @@ data: resp := uitest.JSONUIFromBytes(t, []byte(out)) - validateChanges(t, resp.Tables, expectedChange, "Op: 1 create, 0 delete, 0 update, 0 noop", + validateChanges(t, resp.Tables, expectedChange, "Op: 1 create, 0 delete, 0 update, 0 noop, 0 exists", "Wait to: 1 reconcile, 0 delete, 0 noop", out) }) @@ -220,7 +220,7 @@ data: resp := uitest.JSONUIFromBytes(t, []byte(out)) - validateChanges(t, resp.Tables, expectedChange, "Op: 0 create, 0 delete, 1 update, 0 noop", + validateChanges(t, resp.Tables, expectedChange, "Op: 0 create, 0 delete, 1 update, 0 noop, 0 exists", "Wait to: 1 reconcile, 0 delete, 0 noop", out) }) @@ -243,7 +243,7 @@ data: resp := uitest.JSONUIFromBytes(t, []byte(out)) - validateChanges(t, resp.Tables, expectedChange, "Op: 0 create, 0 delete, 1 update, 0 noop", + validateChanges(t, resp.Tables, expectedChange, "Op: 0 create, 0 delete, 1 update, 0 noop, 0 exists", "Wait to: 1 reconcile, 0 delete, 0 noop", out) }) @@ -286,7 +286,7 @@ data: resp := uitest.JSONUIFromBytes(t, []byte(out)) - validateChanges(t, resp.Tables, expectedChange, "Op: 0 create, 2 delete, 0 update, 1 noop", + validateChanges(t, resp.Tables, expectedChange, "Op: 0 create, 2 delete, 0 update, 1 noop, 0 exists", "Wait to: 0 reconcile, 3 delete, 0 noop", out) }) } diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go index ea6b499f3..482d58783 100644 --- a/test/e2e/diff_test.go +++ b/test/e2e/diff_test.go @@ -115,7 +115,7 @@ data: }} require.Exactlyf(t, expected, resp.Tables[0].Rows, "Expected to see correct changes, but did not") - require.Equalf(t, "Op: 3 create, 0 delete, 0 update, 0 noop", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") + require.Equalf(t, "Op: 3 create, 0 delete, 0 update, 0 noop, 0 exists", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") require.Equalf(t, "Wait to: 3 reconcile, 0 delete, 0 noop", resp.Tables[0].Notes[1], "Expected to see correct summary, but did not") }) @@ -127,7 +127,7 @@ data: expected := []map[string]string{} require.Exactlyf(t, expected, resp.Tables[0].Rows, "Expected to see correct changes, but did not") - require.Equalf(t, "Op: 0 create, 0 delete, 0 update, 0 noop", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") + require.Equalf(t, "Op: 0 create, 0 delete, 0 update, 0 noop, 0 exists", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") require.Equalf(t, "Wait to: 0 reconcile, 0 delete, 0 noop", resp.Tables[0].Notes[1], "Expected to see correct summary, but did not") }) @@ -173,7 +173,7 @@ data: }} require.Exactlyf(t, expected, replaceAge(resp.Tables[0].Rows), "Expected to see correct changes, but did not") - require.Equalf(t, "Op: 1 create, 1 delete, 1 update, 0 noop", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") + require.Equalf(t, "Op: 1 create, 1 delete, 1 update, 0 noop, 0 exists", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") require.Equalf(t, "Wait to: 2 reconcile, 1 delete, 0 noop", resp.Tables[0].Notes[1], "Expected to see correct summary, but did not") }) @@ -218,7 +218,7 @@ data: }} require.Exactlyf(t, expected, replaceAge(resp.Tables[0].Rows), "Expected to see correct changes, but did not") - require.Equalf(t, "Op: 0 create, 3 delete, 0 update, 0 noop", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") + require.Equalf(t, "Op: 0 create, 3 delete, 0 update, 0 noop, 0 exists", resp.Tables[0].Notes[0], "Expected to see correct summary, but did not") require.Equalf(t, "Wait to: 0 reconcile, 3 delete, 0 noop", resp.Tables[0].Notes[1], "Expected to see correct summary, but did not") }) } diff --git a/test/e2e/exists_ann_test.go b/test/e2e/exists_ann_test.go index 5deb7a66e..b86c7b6a9 100644 --- a/test/e2e/exists_ann_test.go +++ b/test/e2e/exists_ann_test.go @@ -59,7 +59,7 @@ Namespace Name Kind Conds. Age Op Op st. Wait to Rs Ri (cluster) kapp-ns Namespace - - create - reconcile - - $ kapp-ns external ConfigMap - - exists - reconcile - - $ -Op: 1 create, 0 delete, 0 update, 0 noop +Op: 1 create, 0 delete, 0 update, 0 noop, 1 exists Wait to: 2 reconcile, 0 delete, 0 noop : ---- applying 1 changes [0/2 done] ---- @@ -91,7 +91,7 @@ Changes Namespace Name Kind Conds. Age Op Op st. Wait to Rs Ri $ -Op: 0 create, 0 delete, 0 update, 0 noop +Op: 0 create, 0 delete, 0 update, 0 noop, 0 exists Wait to: 0 reconcile, 0 delete, 0 noop Succeeded` diff --git a/test/e2e/filter_test.go b/test/e2e/filter_test.go index 1e9219aaf..a7821cf3a 100644 --- a/test/e2e/filter_test.go +++ b/test/e2e/filter_test.go @@ -65,7 +65,7 @@ Namespace Name Kind Conds. Age Op Op st. Wait to Rs kapp-test redis-config ConfigMap - - create - reconcile - - ^ redis-primary Service - - create - reconcile - - -Op: 2 create, 0 delete, 0 update, 0 noop +Op: 2 create, 0 delete, 0 update, 0 noop, 0 exists Wait to: 2 reconcile, 0 delete, 0 noop ` require.Contains(t, out, expectedOutput1, "Did not find expected diff output") @@ -80,7 +80,7 @@ Namespace Name Kind Conds. Age Op Op st. Wait to Rs kapp-test redis-config ConfigMap - - create - reconcile - - ^ redis-config2 ConfigMap - - create - reconcile - - -Op: 2 create, 0 delete, 0 update, 0 noop +Op: 2 create, 0 delete, 0 update, 0 noop, 0 exists Wait to: 2 reconcile, 0 delete, 0 noop ` require.Contains(t, out, expectedOutput2, "Did not find expected diff output") @@ -94,7 +94,7 @@ Wait to: 2 reconcile, 0 delete, 0 noop Namespace Name Kind Conds. Age Op Op st. Wait to Rs Ri kapp-test redis-primary Service - - create - reconcile - - -Op: 1 create, 0 delete, 0 update, 0 noop +Op: 1 create, 0 delete, 0 update, 0 noop, 0 exists Wait to: 1 reconcile, 0 delete, 0 noop ` require.Contains(t, out, expectedOutput3, "Did not find expected diff output") @@ -110,7 +110,7 @@ Wait to: 1 reconcile, 0 delete, 0 noop Namespace Name Kind Conds. Age Op Op st. Wait to Rs Ri kapp-test redis-config2 ConfigMap - - create - reconcile - - -Op: 1 create, 0 delete, 0 update, 0 noop +Op: 1 create, 0 delete, 0 update, 0 noop, 0 exists Wait to: 1 reconcile, 0 delete, 0 noop ` require.Contains(t, out, expectedOutput4, "Did not find expected diff output") diff --git a/test/e2e/noop_ann_test.go b/test/e2e/noop_ann_test.go index fa451dbc9..b81337467 100644 --- a/test/e2e/noop_ann_test.go +++ b/test/e2e/noop_ann_test.go @@ -52,7 +52,7 @@ Changes Namespace Name Kind Conds. Age Op Op st. Wait to Rs Ri $ (cluster) kapp-ns Namespace - - create - reconcile - - $ -Op: 1 create, 0 delete, 0 update, 0 noop +Op: 1 create, 0 delete, 0 update, 0 noop, 0 exists Wait to: 1 reconcile, 0 delete, 0 noop : ---- applying 1 changes [0/1 done] ---- @@ -79,7 +79,7 @@ Changes Namespace Name Kind Conds. Age Op Op st. Wait to Rs Ri $ -Op: 0 create, 0 delete, 0 update, 0 noop +Op: 0 create, 0 delete, 0 update, 0 noop, 0 exists Wait to: 0 reconcile, 0 delete, 0 noop Succeeded` diff --git a/test/e2e/order_test.go b/test/e2e/order_test.go index 661c08481..45772b191 100644 --- a/test/e2e/order_test.go +++ b/test/e2e/order_test.go @@ -93,7 +93,7 @@ kapp-test app ConfigMap - - create - reconcil ^ import-etcd-into-db ConfigMap - - create - reconcile - - $ ^ migrations ConfigMap - - create - reconcile - - $ -Op: 7 create, 0 delete, 0 update, 0 noop +Op: 7 create, 0 delete, 0 update, 0 noop, 0 exists Wait to: 7 reconcile, 0 delete, 0 noop : ---- applying 4 changes [0/7 done] ---- @@ -189,7 +189,7 @@ Namespace Name Kind Conds. Age Op Op st. Wait to kapp-test app-config2 ConfigMap - - create - reconcile - - $ ^ import-etcd-into-db ConfigMap - delete - delete ok - $ -Op: 1 create, 1 delete, 0 update, 0 noop +Op: 1 create, 1 delete, 0 update, 0 noop, 0 exists Wait to: 1 reconcile, 1 delete, 0 noop : ---- applying 1 changes [0/2 done] ---- diff --git a/test/e2e/warnings_test.go b/test/e2e/warnings_test.go index 4f4490ff9..ffa55d9d4 100644 --- a/test/e2e/warnings_test.go +++ b/test/e2e/warnings_test.go @@ -91,7 +91,7 @@ Changes Namespace Name Kind Conds. Age Op Op st. Wait to Rs Ri kapp-test cr-1 CronTab - - create - reconcile - - -Op: 1 create, 0 delete, 0 update, 0 noop +Op: 1 create, 0 delete, 0 update, 0 noop, 0 exists Wait to: 1 reconcile, 0 delete, 0 noop : ---- applying 1 changes [0/1 done] ---- @@ -123,7 +123,7 @@ Changes Namespace Name Kind Conds. Age Op Op st. Wait to Rs Ri kapp-test cr-2 CronTab - - create - reconcile - - -Op: 1 create, 0 delete, 0 update, 0 noop +Op: 1 create, 0 delete, 0 update, 0 noop, 0 exists Wait to: 1 reconcile, 0 delete, 0 noop : ---- applying 1 changes [0/1 done] ----