mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
chore: improve a couple kuttl tests (#6079)
* chore: improve a couple kuttl tests Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * more Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * more Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * readme Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * Update test/conformance/kuttl/cleanup/validation/cron-format/README.md Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
6a95f480e3
commit
47b4a177dd
37 changed files with 74 additions and 139 deletions
|
@ -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
|
|
@ -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
|
|
@ -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 * * * *"
|
|
@ -0,0 +1,4 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- rbac.yaml
|
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- pod.yaml
|
||||
assert:
|
||||
- pod-assert.yaml
|
|
@ -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
|
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- policy.yaml
|
||||
assert:
|
||||
- policy.yaml
|
|
@ -0,0 +1,4 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
commands:
|
||||
- command: sleep 65
|
|
@ -0,0 +1,4 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
error:
|
||||
- pod-assert.yaml
|
|
@ -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
|
|
@ -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)
|
||||
|
|
|
@ -2,4 +2,4 @@ apiVersion: v1
|
|||
kind: Pod
|
||||
metadata:
|
||||
name: example
|
||||
namespace: default
|
||||
namespace: default
|
|
@ -6,4 +6,4 @@ metadata:
|
|||
spec:
|
||||
containers:
|
||||
- image: nginx:latest
|
||||
name: example
|
||||
name: example
|
|
@ -17,4 +17,4 @@ spec:
|
|||
operator: Equals
|
||||
value: default
|
||||
## execute every minute
|
||||
schedule: "*/1 * * * *"
|
||||
schedule: "*/1 * * * *"
|
|
@ -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:
|
|
@ -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 * * * *"
|
|
@ -0,0 +1,4 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- rbac.yaml
|
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- pod.yaml
|
||||
assert:
|
||||
- pod-assert.yaml
|
|
@ -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
|
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- policy.yaml
|
||||
assert:
|
||||
- policy.yaml
|
|
@ -0,0 +1,4 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
commands:
|
||||
- command: sleep 65
|
|
@ -0,0 +1,4 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
error:
|
||||
- pod-assert.yaml
|
|
@ -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
|
|
@ -2,4 +2,4 @@ apiVersion: v1
|
|||
kind: Pod
|
||||
metadata:
|
||||
name: example
|
||||
namespace: default
|
||||
namespace: default
|
|
@ -6,4 +6,4 @@ metadata:
|
|||
spec:
|
||||
containers:
|
||||
- image: nginx:latest
|
||||
name: example
|
||||
name: example
|
|
@ -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:
|
|
@ -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 * * * *"
|
|
@ -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 * * * *"
|
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- policy.yaml
|
||||
assert:
|
||||
- policy.yaml
|
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- clusterpolicy.yaml
|
||||
assert:
|
||||
- clusterpolicy.yaml
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- file: invalidpolicy.yaml
|
||||
shouldFail: true
|
|
@ -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.
|
Loading…
Reference in a new issue