From d615826a9eba1501adf9f129cfa0e164f2f3af9a Mon Sep 17 00:00:00 2001 From: Shubham Gupta <69793468+shubham-cmyk@users.noreply.github.com> Date: Mon, 4 Sep 2023 23:11:34 +0530 Subject: [PATCH] [Fix] flakes in e2e tests (#8253) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix small errors Signed-off-by: Shubham Gupta * fix ns Signed-off-by: Shubham Gupta * fixes Signed-off-by: Shubham Gupta * drop sleep Signed-off-by: Shubham Gupta * update readme Signed-off-by: Shubham Gupta * typo Signed-off-by: Shubham Gupta * fixes Signed-off-by: Shubham Gupta * intendation Signed-off-by: Shubham Gupta --------- Signed-off-by: Shubham Gupta Co-authored-by: Charles-Edouard Brétéché --- test/conformance/kuttl/ttl/past-timestamp/01-pod.yaml | 4 +--- test/conformance/kuttl/ttl/past-timestamp/02-check.yaml | 6 ++++++ test/conformance/kuttl/ttl/past-timestamp/03-pod.yaml | 6 ++++++ .../ttl/past-timestamp/{02-wait.yaml => 04-patch.yaml} | 4 ++-- .../ttl/past-timestamp/{03-check.yaml => 05-check.yaml} | 2 +- test/conformance/kuttl/ttl/past-timestamp/README.md | 4 ++++ .../kuttl/ttl/past-timestamp/past-timestamp.yaml | 6 ++++++ test/conformance/kuttl/ttl/past-timestamp/pod-2.yaml | 8 ++++++++ .../kuttl/ttl/past-timestamp/pod-assert-2.yaml | 4 ++++ 9 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 test/conformance/kuttl/ttl/past-timestamp/02-check.yaml create mode 100644 test/conformance/kuttl/ttl/past-timestamp/03-pod.yaml rename test/conformance/kuttl/ttl/past-timestamp/{02-wait.yaml => 04-patch.yaml} (60%) rename test/conformance/kuttl/ttl/past-timestamp/{03-check.yaml => 05-check.yaml} (73%) create mode 100644 test/conformance/kuttl/ttl/past-timestamp/past-timestamp.yaml create mode 100644 test/conformance/kuttl/ttl/past-timestamp/pod-2.yaml create mode 100644 test/conformance/kuttl/ttl/past-timestamp/pod-assert-2.yaml diff --git a/test/conformance/kuttl/ttl/past-timestamp/01-pod.yaml b/test/conformance/kuttl/ttl/past-timestamp/01-pod.yaml index 52ffd92005..5486b71486 100644 --- a/test/conformance/kuttl/ttl/past-timestamp/01-pod.yaml +++ b/test/conformance/kuttl/ttl/past-timestamp/01-pod.yaml @@ -1,6 +1,4 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep apply: -- pod.yaml -assert: -- pod-assert.yaml \ No newline at end of file +- pod.yaml \ No newline at end of file diff --git a/test/conformance/kuttl/ttl/past-timestamp/02-check.yaml b/test/conformance/kuttl/ttl/past-timestamp/02-check.yaml new file mode 100644 index 0000000000..9c67825294 --- /dev/null +++ b/test/conformance/kuttl/ttl/past-timestamp/02-check.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- command: sleep 5 +error: +- pod-assert.yaml \ No newline at end of file diff --git a/test/conformance/kuttl/ttl/past-timestamp/03-pod.yaml b/test/conformance/kuttl/ttl/past-timestamp/03-pod.yaml new file mode 100644 index 0000000000..d785e1bad3 --- /dev/null +++ b/test/conformance/kuttl/ttl/past-timestamp/03-pod.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- pod-2.yaml +assert: +- pod-assert-2.yaml \ No newline at end of file diff --git a/test/conformance/kuttl/ttl/past-timestamp/02-wait.yaml b/test/conformance/kuttl/ttl/past-timestamp/04-patch.yaml similarity index 60% rename from test/conformance/kuttl/ttl/past-timestamp/02-wait.yaml rename to test/conformance/kuttl/ttl/past-timestamp/04-patch.yaml index 5b8bfb4701..b407e8ffaf 100644 --- a/test/conformance/kuttl/ttl/past-timestamp/02-wait.yaml +++ b/test/conformance/kuttl/ttl/past-timestamp/04-patch.yaml @@ -1,4 +1,4 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep -commands: - - command: sleep 5 \ No newline at end of file +apply: +- past-timestamp.yaml \ No newline at end of file diff --git a/test/conformance/kuttl/ttl/past-timestamp/03-check.yaml b/test/conformance/kuttl/ttl/past-timestamp/05-check.yaml similarity index 73% rename from test/conformance/kuttl/ttl/past-timestamp/03-check.yaml rename to test/conformance/kuttl/ttl/past-timestamp/05-check.yaml index 024ee4f1b4..04fd99e7de 100644 --- a/test/conformance/kuttl/ttl/past-timestamp/03-check.yaml +++ b/test/conformance/kuttl/ttl/past-timestamp/05-check.yaml @@ -1,4 +1,4 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep error: -- pod-assert.yaml \ No newline at end of file +- pod-assert-2.yaml \ No newline at end of file diff --git a/test/conformance/kuttl/ttl/past-timestamp/README.md b/test/conformance/kuttl/ttl/past-timestamp/README.md index 85d30bac98..c0d0060141 100644 --- a/test/conformance/kuttl/ttl/past-timestamp/README.md +++ b/test/conformance/kuttl/ttl/past-timestamp/README.md @@ -6,4 +6,8 @@ This test cleans up pods instanteaously without any delay as the value of the la The pod `test-pod` is cleaned up instantaneously. +The pod `test-pod-2` is cleaned up instantaneously when the label is updated to `cleanup.kyverno.io/ttl: 2023-07-19T120000Z` the timestamp is mentioned in past. + ## Reference Issue(s) + +- [8242](https://github.com/kyverno/kyverno/issues/8242): `test-pod` might never be created, so the assert could fail. diff --git a/test/conformance/kuttl/ttl/past-timestamp/past-timestamp.yaml b/test/conformance/kuttl/ttl/past-timestamp/past-timestamp.yaml new file mode 100644 index 0000000000..7aca725c6d --- /dev/null +++ b/test/conformance/kuttl/ttl/past-timestamp/past-timestamp.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Pod +metadata: + name: test-pod-2 + labels: + cleanup.kyverno.io/ttl: 2023-07-19T120000Z \ No newline at end of file diff --git a/test/conformance/kuttl/ttl/past-timestamp/pod-2.yaml b/test/conformance/kuttl/ttl/past-timestamp/pod-2.yaml new file mode 100644 index 0000000000..9f96a38a24 --- /dev/null +++ b/test/conformance/kuttl/ttl/past-timestamp/pod-2.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Pod +metadata: + name: test-pod-2 +spec: + containers: + - image: nginx:latest + name: nginx diff --git a/test/conformance/kuttl/ttl/past-timestamp/pod-assert-2.yaml b/test/conformance/kuttl/ttl/past-timestamp/pod-assert-2.yaml new file mode 100644 index 0000000000..cb80212cdf --- /dev/null +++ b/test/conformance/kuttl/ttl/past-timestamp/pod-assert-2.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Pod +metadata: + name: test-pod-2 \ No newline at end of file