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