1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

chore: run background-only tests with chainsaw (#8943)

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
This commit is contained in:
Mariam Fahmy 2023-11-19 03:30:42 +02:00 committed by GitHub
parent dcea5b084d
commit fc841c0417
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 473 additions and 0 deletions

View file

@ -196,6 +196,7 @@ jobs:
# - verify-manifests # - verify-manifests
# - verifyImages # - verifyImages
- webhooks - webhooks
- background-only
needs: prepare-images needs: prepare-images
name: chainsaw - ${{ matrix.k8s-version.name }} - ${{ matrix.config.name }} - ${{ matrix.tests }} name: chainsaw - ${{ matrix.k8s-version.name }} - ${{ matrix.config.name }} - ${{ matrix.tests }}
steps: steps:

View file

@ -3,6 +3,9 @@ kind: Configuration
metadata: metadata:
name: congiguration name: congiguration
spec: spec:
timeouts:
assert: 90s
error: 90s
parallel: 1 parallel: 1
fullName: true fullName: true
failFast: true failFast: true

View file

@ -0,0 +1,10 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: policy
spec:
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml

View file

@ -0,0 +1,8 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: resource
spec:
try:
- apply:
file: resource.yaml

View file

@ -0,0 +1,12 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: event
spec:
try:
- assert:
file: background-event.yaml
- error:
file: admission-event.yaml
catch:
- events: {}

View file

@ -0,0 +1,10 @@
## Description
This test creates a policy with `admission` set to `false`.
Then it creates a resource that violates the policy.
## Expected Behavior
The resource creates fine as the policy doesn't apply at admission time.
No admission ezvent is created.
One background event is created.

View file

@ -0,0 +1,8 @@
apiVersion: v1
involvedObject:
apiVersion: v1
kind: Pod
name: pod
kind: Event
metadata: {}
reportingComponent: kyverno-admission

View file

@ -0,0 +1,8 @@
apiVersion: v1
involvedObject:
apiVersion: v1
kind: Pod
name: pod
kind: Event
metadata: {}
reportingComponent: kyverno-scan

View file

@ -0,0 +1,10 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -0,0 +1,17 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec:
validationFailureAction: Enforce
admission: false
background: true
rules:
- name: validate
match:
any:
- resources:
kinds:
- Pod
validate:
deny: {}

View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: pod
spec:
containers:
- name: container
image: nginx:latest
ports:
- containerPort: 80

View file

@ -0,0 +1,10 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: policy
spec:
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml

View file

@ -0,0 +1,8 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: resource
spec:
try:
- apply:
file: resource.yaml

View file

@ -0,0 +1,8 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: report
spec:
try:
- error:
file: admission-report.yaml

View file

@ -0,0 +1,9 @@
## Description
This test creates a policy with `admission` set to `false`.
Then it creates a resource that violates the policy.
## Expected Behavior
The resource creates fine as the policy doesn't apply at admission time.
No admission report is created.

View file

@ -0,0 +1,7 @@
apiVersion: kyverno.io/v1alpha2
kind: AdmissionReport
metadata:
ownerReferences:
- apiVersion: v1
kind: Pod
name: pod

View file

@ -0,0 +1,10 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -0,0 +1,17 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec:
validationFailureAction: Enforce
admission: false
background: true
rules:
- name: validate
match:
any:
- resources:
kinds:
- Pod
validate:
deny: {}

View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: pod
spec:
containers:
- name: container
image: nginx:latest
ports:
- containerPort: 80

View file

@ -0,0 +1,10 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: policy
spec:
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml

View file

@ -0,0 +1,8 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: resource
spec:
try:
- apply:
file: resource.yaml

View file

@ -0,0 +1,8 @@
## Description
This test creates a policy with `admission` set to `false`.
Then it creates a resource that violates the policy.
## Expected Behavior
The resource creates fine as the policy doesn't apply at admission time.

View file

@ -0,0 +1,10 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -0,0 +1,17 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec:
validationFailureAction: Enforce
admission: false
background: true
rules:
- name: validate
match:
any:
- resources:
kinds:
- Pod
validate:
deny: {}

View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: pod
spec:
containers:
- name: container
image: nginx:latest
ports:
- containerPort: 80

View file

@ -0,0 +1,10 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: policy
spec:
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml

View file

@ -0,0 +1,8 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: resource
spec:
try:
- apply:
file: resource.yaml

View file

@ -0,0 +1,10 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: event
spec:
try:
- assert:
file: background-event.yaml
- error:
file: admission-event.yaml

View file

@ -0,0 +1,10 @@
## Description
This test creates a policy with `admission` set to `false`.
Then it creates a resource that violates the policy.
## Expected Behavior
The resource creates fine as the policy doesn't apply at admission time.
No admission ezvent is created.
One background event is created.

View file

@ -0,0 +1,8 @@
apiVersion: v1
involvedObject:
apiVersion: v1
kind: Pod
name: pod
kind: Event
metadata: {}
reportingComponent: kyverno-admission

View file

@ -0,0 +1,8 @@
apiVersion: v1
involvedObject:
apiVersion: v1
kind: Pod
name: pod
kind: Event
metadata: {}
reportingComponent: kyverno-scan

View file

@ -0,0 +1,10 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -0,0 +1,17 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec:
validationFailureAction: Enforce
admission: false
background: true
rules:
- name: validate
match:
any:
- resources:
kinds:
- Pod
validate:
deny: {}

View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: pod
spec:
containers:
- name: container
image: nginx:latest
ports:
- containerPort: 80

View file

@ -0,0 +1,10 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: policy
spec:
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml

View file

@ -0,0 +1,8 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: resource
spec:
try:
- apply:
file: resource.yaml

View file

@ -0,0 +1,8 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: report
spec:
try:
- error:
file: admission-report.yaml

View file

@ -0,0 +1,9 @@
## Description
This test creates a policy with `admission` set to `false`.
Then it creates a resource that violates the policy.
## Expected Behavior
The resource creates fine as the policy doesn't apply at admission time.
No admission report is created.

View file

@ -0,0 +1,7 @@
apiVersion: kyverno.io/v1alpha2
kind: AdmissionReport
metadata:
ownerReferences:
- apiVersion: v1
kind: Pod
name: pod

View file

@ -0,0 +1,10 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -0,0 +1,17 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec:
validationFailureAction: Enforce
admission: false
background: true
rules:
- name: validate
match:
any:
- resources:
kinds:
- Pod
validate:
deny: {}

View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: pod
spec:
containers:
- name: container
image: nginx:latest
ports:
- containerPort: 80

View file

@ -0,0 +1,10 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: policy
spec:
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml

View file

@ -0,0 +1,9 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
creationTimestamp: null
name: resource
spec:
try:
- apply:
file: resource.yaml

View file

@ -0,0 +1,8 @@
## Description
This test creates a policy with `admission` set to `false`.
Then it creates a resource that violates the policy.
## Expected Behavior
The resource creates fine as the policy doesn't apply at admission time.

View file

@ -0,0 +1,10 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -0,0 +1,17 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec:
validationFailureAction: Enforce
admission: false
background: true
rules:
- name: validate
match:
any:
- resources:
kinds:
- Pod
validate:
deny: {}

View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: pod
spec:
containers:
- name: container
image: nginx:latest
ports:
- containerPort: 80