From 47b4a177dd2e6c80ac09d6bf3f2598bfd9eef7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Mon, 30 Jan 2023 15:11:06 +0100 Subject: [PATCH] chore: improve a couple kuttl tests (#6079) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: improve a couple kuttl tests Signed-off-by: Charles-Edouard Brétéché * more Signed-off-by: Charles-Edouard Brétéché * more Signed-off-by: Charles-Edouard Brétéché * readme Signed-off-by: Charles-Edouard Brétéché * Update test/conformance/kuttl/cleanup/validation/cron-format/README.md Signed-off-by: Charles-Edouard Brétéché --------- Signed-off-by: Charles-Edouard Brétéché --- .../_aaa_template_resources/99-cleanup.yaml | 5 ----- .../commands/99-cleanup.yaml | 4 ---- .../clusterpolicy/cleanup-pod/01-policy.yaml | 20 ------------------- .../clusterpolicy/cleanup-pod/01-rbac.yaml | 4 ++++ .../clusterpolicy/cleanup-pod/02-pod.yaml | 6 ++++++ .../clusterpolicy/cleanup-pod/02-sleep.yaml | 5 ----- .../clusterpolicy/cleanup-pod/03-policy.yaml | 6 ++++++ .../clusterpolicy/cleanup-pod/04-sleep.yaml | 4 ++++ .../clusterpolicy/cleanup-pod/05-check.yaml | 4 ++++ .../clusterpolicy/cleanup-pod/99-cleanup.yaml | 5 ----- .../clusterpolicy/cleanup-pod/README.md | 1 - .../cleanup-pod/pod-assert.yaml} | 2 +- .../cleanup-pod/{03-errors.yaml => pod.yaml} | 2 +- .../{01-assert.yaml => policy.yaml} | 2 +- .../cleanup-pod/rbac.yaml} | 10 ---------- .../cleanup/policy/cleanup-pod/01-assert.yaml | 17 ---------------- .../cleanup/policy/cleanup-pod/01-rbac.yaml | 4 ++++ .../cleanup/policy/cleanup-pod/02-pod.yaml | 6 ++++++ .../cleanup/policy/cleanup-pod/02-sleep.yaml | 5 ----- .../cleanup/policy/cleanup-pod/03-policy.yaml | 6 ++++++ .../cleanup/policy/cleanup-pod/04-sleep.yaml | 4 ++++ .../cleanup/policy/cleanup-pod/05-check.yaml | 4 ++++ .../policy/cleanup-pod/99-cleanup.yaml | 5 ----- .../cleanup-pod/pod-assert.yaml} | 2 +- .../cleanup-pod/{03-errors.yaml => pod.yaml} | 2 +- .../{01-policy.yaml => policy.yaml} | 0 .../cleanup-pod/rbac.yaml} | 10 ---------- .../cron-format/00-cleanuppolicy.yaml | 17 ---------------- .../cron-format/01-clustercleanuppolicy.yaml | 16 --------------- .../validation/cron-format/01-policy.yaml | 6 ++++++ .../cron-format/02-clusterpolicy.yaml | 6 ++++++ .../cron-format/02-create-task.yaml | 14 ------------- .../cron-format/03-invalidpolicy.yaml | 5 +++++ .../cleanup/validation/cron-format/README.md | 4 ++++ .../{01-assert.yaml => clusterpolicy.yaml} | 0 ...dcleanuppolicy.yaml => invalidpolicy.yaml} | 0 .../{00-assert.yaml => policy.yaml} | 0 37 files changed, 74 insertions(+), 139 deletions(-) delete mode 100644 test/conformance/kuttl/_aaa_template_resources/99-cleanup.yaml delete mode 100644 test/conformance/kuttl/_aaa_template_resources/commands/99-cleanup.yaml delete mode 100644 test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-policy.yaml create mode 100644 test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-rbac.yaml create mode 100644 test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/02-pod.yaml delete mode 100644 test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/02-sleep.yaml create mode 100644 test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/03-policy.yaml create mode 100644 test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/04-sleep.yaml create mode 100644 test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/05-check.yaml delete mode 100644 test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/99-cleanup.yaml rename test/conformance/kuttl/cleanup/{policy/cleanup-pod/00-assert.yaml => clusterpolicy/cleanup-pod/pod-assert.yaml} (70%) rename test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/{03-errors.yaml => pod.yaml} (86%) rename test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/{01-assert.yaml => policy.yaml} (93%) rename test/conformance/kuttl/cleanup/{policy/cleanup-pod/00-manifests.yaml => clusterpolicy/cleanup-pod/rbac.yaml} (77%) delete mode 100644 test/conformance/kuttl/cleanup/policy/cleanup-pod/01-assert.yaml create mode 100644 test/conformance/kuttl/cleanup/policy/cleanup-pod/01-rbac.yaml create mode 100644 test/conformance/kuttl/cleanup/policy/cleanup-pod/02-pod.yaml delete mode 100644 test/conformance/kuttl/cleanup/policy/cleanup-pod/02-sleep.yaml create mode 100644 test/conformance/kuttl/cleanup/policy/cleanup-pod/03-policy.yaml create mode 100644 test/conformance/kuttl/cleanup/policy/cleanup-pod/04-sleep.yaml create mode 100644 test/conformance/kuttl/cleanup/policy/cleanup-pod/05-check.yaml delete mode 100644 test/conformance/kuttl/cleanup/policy/cleanup-pod/99-cleanup.yaml rename test/conformance/kuttl/cleanup/{clusterpolicy/cleanup-pod/00-assert.yaml => policy/cleanup-pod/pod-assert.yaml} (70%) rename test/conformance/kuttl/cleanup/policy/cleanup-pod/{03-errors.yaml => pod.yaml} (86%) rename test/conformance/kuttl/cleanup/policy/cleanup-pod/{01-policy.yaml => policy.yaml} (100%) rename test/conformance/kuttl/cleanup/{clusterpolicy/cleanup-pod/00-manifests.yaml => policy/cleanup-pod/rbac.yaml} (77%) delete mode 100644 test/conformance/kuttl/cleanup/validation/cron-format/00-cleanuppolicy.yaml delete mode 100644 test/conformance/kuttl/cleanup/validation/cron-format/01-clustercleanuppolicy.yaml create mode 100644 test/conformance/kuttl/cleanup/validation/cron-format/01-policy.yaml create mode 100644 test/conformance/kuttl/cleanup/validation/cron-format/02-clusterpolicy.yaml delete mode 100644 test/conformance/kuttl/cleanup/validation/cron-format/02-create-task.yaml create mode 100644 test/conformance/kuttl/cleanup/validation/cron-format/03-invalidpolicy.yaml create mode 100644 test/conformance/kuttl/cleanup/validation/cron-format/README.md rename test/conformance/kuttl/cleanup/validation/cron-format/{01-assert.yaml => clusterpolicy.yaml} (100%) rename test/conformance/kuttl/cleanup/validation/cron-format/{badcleanuppolicy.yaml => invalidpolicy.yaml} (100%) rename test/conformance/kuttl/cleanup/validation/cron-format/{00-assert.yaml => policy.yaml} (100%) diff --git a/test/conformance/kuttl/_aaa_template_resources/99-cleanup.yaml b/test/conformance/kuttl/_aaa_template_resources/99-cleanup.yaml deleted file mode 100644 index 6ed1836e07..0000000000 --- a/test/conformance/kuttl/_aaa_template_resources/99-cleanup.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# A clean-up is presently required because kuttl does not do a reliable job of cleaning up both cluster-scoped objects. -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - command: kubectl delete -f 01-manifests.yaml,02-secret.yaml --force --wait=true --ignore-not-found=true \ No newline at end of file diff --git a/test/conformance/kuttl/_aaa_template_resources/commands/99-cleanup.yaml b/test/conformance/kuttl/_aaa_template_resources/commands/99-cleanup.yaml deleted file mode 100644 index b7de47a47c..0000000000 --- a/test/conformance/kuttl/_aaa_template_resources/commands/99-cleanup.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - command: kubectl delete -f 01-manifests.yaml,02-secret.yaml --force --wait=true --ignore-not-found=true \ No newline at end of file diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-policy.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-policy.yaml deleted file mode 100644 index 17315fdea5..0000000000 --- a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-policy.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: kyverno.io/v2alpha1 -kind: ClusterCleanupPolicy -metadata: - name: cleanup-pod -spec: - match: - any: - - resources: - kinds: - - Pod - conditions: - all: - - key: "{{ target.metadata.name }}" - operator: Equals - value: example - - key: "{{ target.metadata.namespace }}" - operator: Equals - value: default - ## execute every minute - schedule: "*/1 * * * *" \ No newline at end of file diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-rbac.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-rbac.yaml new file mode 100644 index 0000000000..170a96da85 --- /dev/null +++ b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-rbac.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- rbac.yaml diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/02-pod.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/02-pod.yaml new file mode 100644 index 0000000000..3e1752d840 --- /dev/null +++ b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/02-pod.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- pod.yaml +assert: +- pod-assert.yaml diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/02-sleep.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/02-sleep.yaml deleted file mode 100644 index 2e6f7ecbec..0000000000 --- a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/02-sleep.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# A command can only run a single command, not a pipeline and not a script. The program called must exist on the system where the test is run. -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - command: sleep 65 \ No newline at end of file diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/03-policy.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/03-policy.yaml new file mode 100644 index 0000000000..a2918426aa --- /dev/null +++ b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/03-policy.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- policy.yaml +assert: +- policy.yaml diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/04-sleep.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/04-sleep.yaml new file mode 100644 index 0000000000..17d43867a6 --- /dev/null +++ b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/04-sleep.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: sleep 65 diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/05-check.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/05-check.yaml new file mode 100644 index 0000000000..7916be6554 --- /dev/null +++ b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/05-check.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +error: +- pod-assert.yaml diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/99-cleanup.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/99-cleanup.yaml deleted file mode 100644 index 9dabca6ad3..0000000000 --- a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/99-cleanup.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# A clean-up is presently required because kuttl does not do a reliable job of cleaning up both cluster-scoped objects. -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - command: kubectl delete -f 00-manifests.yaml,01-policy.yaml --force --wait=true --ignore-not-found=true \ No newline at end of file diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/README.md b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/README.md index 80ddb26a6a..017a677c05 100644 --- a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/README.md +++ b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/README.md @@ -6,5 +6,4 @@ This test cleans up pods via a cluster cleanup policy. The pod `default/example` is cleaned up successfully. - ## Reference Issue(s) diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/00-assert.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/pod-assert.yaml similarity index 70% rename from test/conformance/kuttl/cleanup/policy/cleanup-pod/00-assert.yaml rename to test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/pod-assert.yaml index 3276cffe3c..99bac5fb09 100644 --- a/test/conformance/kuttl/cleanup/policy/cleanup-pod/00-assert.yaml +++ b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/pod-assert.yaml @@ -2,4 +2,4 @@ apiVersion: v1 kind: Pod metadata: name: example - namespace: default \ No newline at end of file + namespace: default diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/03-errors.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/pod.yaml similarity index 86% rename from test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/03-errors.yaml rename to test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/pod.yaml index 765e64e70d..91b8d5074d 100644 --- a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/03-errors.yaml +++ b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/pod.yaml @@ -6,4 +6,4 @@ metadata: spec: containers: - image: nginx:latest - name: example \ No newline at end of file + name: example diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-assert.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/policy.yaml similarity index 93% rename from test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-assert.yaml rename to test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/policy.yaml index 17315fdea5..44e0f0fdb1 100644 --- a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/01-assert.yaml +++ b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/policy.yaml @@ -17,4 +17,4 @@ spec: operator: Equals value: default ## execute every minute - schedule: "*/1 * * * *" \ No newline at end of file + schedule: "*/1 * * * *" diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/00-manifests.yaml b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/rbac.yaml similarity index 77% rename from test/conformance/kuttl/cleanup/policy/cleanup-pod/00-manifests.yaml rename to test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/rbac.yaml index ebc9b53388..a9af733222 100644 --- a/test/conformance/kuttl/cleanup/policy/cleanup-pod/00-manifests.yaml +++ b/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/rbac.yaml @@ -1,13 +1,3 @@ -apiVersion: v1 -kind: Pod -metadata: - name: example - namespace: default -spec: - containers: - - image: nginx:latest - name: example ---- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/01-assert.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/01-assert.yaml deleted file mode 100644 index daaa4723bb..0000000000 --- a/test/conformance/kuttl/cleanup/policy/cleanup-pod/01-assert.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kyverno.io/v2alpha1 -kind: CleanupPolicy -metadata: - name: cleanup-pod - namespace: default -spec: - match: - any: - - resources: - kinds: - - Pod - conditions: - any: - - key: "{{ target.metadata.name }}" - operator: Equals - value: example - schedule: "*/1 * * * *" \ No newline at end of file diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/01-rbac.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/01-rbac.yaml new file mode 100644 index 0000000000..170a96da85 --- /dev/null +++ b/test/conformance/kuttl/cleanup/policy/cleanup-pod/01-rbac.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- rbac.yaml diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/02-pod.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/02-pod.yaml new file mode 100644 index 0000000000..3e1752d840 --- /dev/null +++ b/test/conformance/kuttl/cleanup/policy/cleanup-pod/02-pod.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- pod.yaml +assert: +- pod-assert.yaml diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/02-sleep.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/02-sleep.yaml deleted file mode 100644 index 2e6f7ecbec..0000000000 --- a/test/conformance/kuttl/cleanup/policy/cleanup-pod/02-sleep.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# A command can only run a single command, not a pipeline and not a script. The program called must exist on the system where the test is run. -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - command: sleep 65 \ No newline at end of file diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/03-policy.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/03-policy.yaml new file mode 100644 index 0000000000..a2918426aa --- /dev/null +++ b/test/conformance/kuttl/cleanup/policy/cleanup-pod/03-policy.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- policy.yaml +assert: +- policy.yaml diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/04-sleep.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/04-sleep.yaml new file mode 100644 index 0000000000..17d43867a6 --- /dev/null +++ b/test/conformance/kuttl/cleanup/policy/cleanup-pod/04-sleep.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: sleep 65 diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/05-check.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/05-check.yaml new file mode 100644 index 0000000000..7916be6554 --- /dev/null +++ b/test/conformance/kuttl/cleanup/policy/cleanup-pod/05-check.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +error: +- pod-assert.yaml diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/99-cleanup.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/99-cleanup.yaml deleted file mode 100644 index 9dabca6ad3..0000000000 --- a/test/conformance/kuttl/cleanup/policy/cleanup-pod/99-cleanup.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# A clean-up is presently required because kuttl does not do a reliable job of cleaning up both cluster-scoped objects. -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - command: kubectl delete -f 00-manifests.yaml,01-policy.yaml --force --wait=true --ignore-not-found=true \ No newline at end of file diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/00-assert.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/pod-assert.yaml similarity index 70% rename from test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/00-assert.yaml rename to test/conformance/kuttl/cleanup/policy/cleanup-pod/pod-assert.yaml index 3276cffe3c..99bac5fb09 100644 --- a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/00-assert.yaml +++ b/test/conformance/kuttl/cleanup/policy/cleanup-pod/pod-assert.yaml @@ -2,4 +2,4 @@ apiVersion: v1 kind: Pod metadata: name: example - namespace: default \ No newline at end of file + namespace: default diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/03-errors.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/pod.yaml similarity index 86% rename from test/conformance/kuttl/cleanup/policy/cleanup-pod/03-errors.yaml rename to test/conformance/kuttl/cleanup/policy/cleanup-pod/pod.yaml index 765e64e70d..91b8d5074d 100644 --- a/test/conformance/kuttl/cleanup/policy/cleanup-pod/03-errors.yaml +++ b/test/conformance/kuttl/cleanup/policy/cleanup-pod/pod.yaml @@ -6,4 +6,4 @@ metadata: spec: containers: - image: nginx:latest - name: example \ No newline at end of file + name: example diff --git a/test/conformance/kuttl/cleanup/policy/cleanup-pod/01-policy.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/policy.yaml similarity index 100% rename from test/conformance/kuttl/cleanup/policy/cleanup-pod/01-policy.yaml rename to test/conformance/kuttl/cleanup/policy/cleanup-pod/policy.yaml diff --git a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/00-manifests.yaml b/test/conformance/kuttl/cleanup/policy/cleanup-pod/rbac.yaml similarity index 77% rename from test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/00-manifests.yaml rename to test/conformance/kuttl/cleanup/policy/cleanup-pod/rbac.yaml index ebc9b53388..a9af733222 100644 --- a/test/conformance/kuttl/cleanup/clusterpolicy/cleanup-pod/00-manifests.yaml +++ b/test/conformance/kuttl/cleanup/policy/cleanup-pod/rbac.yaml @@ -1,13 +1,3 @@ -apiVersion: v1 -kind: Pod -metadata: - name: example - namespace: default -spec: - containers: - - image: nginx:latest - name: example ---- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: diff --git a/test/conformance/kuttl/cleanup/validation/cron-format/00-cleanuppolicy.yaml b/test/conformance/kuttl/cleanup/validation/cron-format/00-cleanuppolicy.yaml deleted file mode 100644 index 09873d582a..0000000000 --- a/test/conformance/kuttl/cleanup/validation/cron-format/00-cleanuppolicy.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kyverno.io/v2alpha1 -kind: CleanupPolicy -metadata: - name: cleanuppolicy - namespace: default -spec: - match: - any: - - resources: - kinds: - - Pod - conditions: - any: - - key: "{{ target.metadata.name }}" - operator: Equals - value: example - schedule: "*/2 * * * *" \ No newline at end of file diff --git a/test/conformance/kuttl/cleanup/validation/cron-format/01-clustercleanuppolicy.yaml b/test/conformance/kuttl/cleanup/validation/cron-format/01-clustercleanuppolicy.yaml deleted file mode 100644 index bdafe1104c..0000000000 --- a/test/conformance/kuttl/cleanup/validation/cron-format/01-clustercleanuppolicy.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kyverno.io/v2alpha1 -kind: ClusterCleanupPolicy -metadata: - name: cleanuppolicy -spec: - match: - any: - - resources: - kinds: - - Pod - conditions: - any: - - key: "{{ target.metadata.name }}" - operator: Equals - value: example - schedule: "*/2 * * * *" \ No newline at end of file diff --git a/test/conformance/kuttl/cleanup/validation/cron-format/01-policy.yaml b/test/conformance/kuttl/cleanup/validation/cron-format/01-policy.yaml new file mode 100644 index 0000000000..a2918426aa --- /dev/null +++ b/test/conformance/kuttl/cleanup/validation/cron-format/01-policy.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- policy.yaml +assert: +- policy.yaml diff --git a/test/conformance/kuttl/cleanup/validation/cron-format/02-clusterpolicy.yaml b/test/conformance/kuttl/cleanup/validation/cron-format/02-clusterpolicy.yaml new file mode 100644 index 0000000000..f567863a3f --- /dev/null +++ b/test/conformance/kuttl/cleanup/validation/cron-format/02-clusterpolicy.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- clusterpolicy.yaml +assert: +- clusterpolicy.yaml diff --git a/test/conformance/kuttl/cleanup/validation/cron-format/02-create-task.yaml b/test/conformance/kuttl/cleanup/validation/cron-format/02-create-task.yaml deleted file mode 100644 index 9623c1a599..0000000000 --- a/test/conformance/kuttl/cleanup/validation/cron-format/02-create-task.yaml +++ /dev/null @@ -1,14 +0,0 @@ -## Checks that the manifests.yaml file CANNOT be successfully created. If it can, fail the test as this is incorrect. - -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: -- script: | - if kubectl apply -f badcleanuppolicy.yaml - then - echo "Tested failed. Task was created when it shouldn't have been." - exit 1 - else - echo "Test succeeded. Task was not created as intended." - exit 0 - fi \ No newline at end of file diff --git a/test/conformance/kuttl/cleanup/validation/cron-format/03-invalidpolicy.yaml b/test/conformance/kuttl/cleanup/validation/cron-format/03-invalidpolicy.yaml new file mode 100644 index 0000000000..d103484154 --- /dev/null +++ b/test/conformance/kuttl/cleanup/validation/cron-format/03-invalidpolicy.yaml @@ -0,0 +1,5 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- file: invalidpolicy.yaml + shouldFail: true diff --git a/test/conformance/kuttl/cleanup/validation/cron-format/README.md b/test/conformance/kuttl/cleanup/validation/cron-format/README.md new file mode 100644 index 0000000000..c17eaf07d6 --- /dev/null +++ b/test/conformance/kuttl/cleanup/validation/cron-format/README.md @@ -0,0 +1,4 @@ +## Description + +This test creates tries to create two cleanup policies, one with a valid schedule and one with an invalid schedule. +The creation of the one with the valid schedule is expected to succeed while the one with the invalid schedule is expected to fail. diff --git a/test/conformance/kuttl/cleanup/validation/cron-format/01-assert.yaml b/test/conformance/kuttl/cleanup/validation/cron-format/clusterpolicy.yaml similarity index 100% rename from test/conformance/kuttl/cleanup/validation/cron-format/01-assert.yaml rename to test/conformance/kuttl/cleanup/validation/cron-format/clusterpolicy.yaml diff --git a/test/conformance/kuttl/cleanup/validation/cron-format/badcleanuppolicy.yaml b/test/conformance/kuttl/cleanup/validation/cron-format/invalidpolicy.yaml similarity index 100% rename from test/conformance/kuttl/cleanup/validation/cron-format/badcleanuppolicy.yaml rename to test/conformance/kuttl/cleanup/validation/cron-format/invalidpolicy.yaml diff --git a/test/conformance/kuttl/cleanup/validation/cron-format/00-assert.yaml b/test/conformance/kuttl/cleanup/validation/cron-format/policy.yaml similarity index 100% rename from test/conformance/kuttl/cleanup/validation/cron-format/00-assert.yaml rename to test/conformance/kuttl/cleanup/validation/cron-format/policy.yaml