Skip to content

Commit

Permalink
Add exists operation to diff summary, update tests accordingly (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenrewar authored Nov 19, 2021
1 parent 75379ed commit 4b9a9e6
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pkg/kapp/clusterapply/changes_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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)
})

Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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)
})

Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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)
})
}
Expand Down Expand Up @@ -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)
})
}
4 changes: 2 additions & 2 deletions test/e2e/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
}
}
Expand Down Expand Up @@ -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{})
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/diff_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand All @@ -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)
})

Expand All @@ -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)
})

Expand All @@ -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)
})

Expand All @@ -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)
})

Expand All @@ -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)
})

Expand All @@ -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)
})

Expand Down Expand Up @@ -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)
})
}
8 changes: 4 additions & 4 deletions test/e2e/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})

Expand All @@ -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")
})

Expand Down Expand Up @@ -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")
})

Expand Down Expand Up @@ -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")
})
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/exists_ann_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
<replaced>: ---- applying 1 changes [0/2 done] ----
Expand Down Expand Up @@ -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`
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/noop_ann_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
<replaced>: ---- applying 1 changes [0/1 done] ----
Expand All @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
<replaced>: ---- applying 4 changes [0/7 done] ----
Expand Down Expand Up @@ -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 - <replaced> 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
<replaced>: ---- applying 1 changes [0/2 done] ----
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/warnings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
<replaced>: ---- applying 1 changes [0/1 done] ----
Expand Down Expand Up @@ -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
<replaced>: ---- applying 1 changes [0/1 done] ----
Expand Down

0 comments on commit 4b9a9e6

Please sign in to comment.