Skip to content

Commit

Permalink
fix: e2e teardown. (#1165)
Browse files Browse the repository at this point in the history
This will allow the tests to be re-run.

Signed-off-by: Julian Dolce <jdolce@qnx.com>
  • Loading branch information
jdolce committed Mar 5, 2021
1 parent 70fdfe9 commit 84f64c4
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/bats/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ teardown() {
}

teardown_file() {
kubectl label ns ${GATEKEEPER_NAMESPACE} admission.gatekeeper.sh/ignore=no-self-managing --overwrite || true
kubectl delete ns gatekeeper-test-playground gatekeeper-excluded-namespace || true
kubectl delete constrainttemplates k8scontainerlimits k8srequiredlabels k8suniquelabel || true
kubectl delete configs.config.gatekeeper.sh config -n ${GATEKEEPER_NAMESPACE} || true
kubectl delete "$(kubectl api-resources --api-group=constraints.gatekeeper.sh -o name | tr "\n" "," | sed -e 's/,$//')" -l gatekeeper.sh/tests=yes || true
kubectl delete ConstraintTemplates -l gatekeeper.sh/tests=yes || true
kubectl delete configs.config.gatekeeper.sh -n ${GATEKEEPER_NAMESPACE} -l gatekeeper.sh/tests=yes || true
}

@test "gatekeeper-controller-manager is running" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sUniqueLabel
metadata:
name: cm-gk-label-unique
labels:
gatekeeper.sh/tests: "yes"
spec:
match:
namespaces: ["gatekeeper-test-playground"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sRequiredLabels
metadata:
name: cm-must-have-gk
labels:
gatekeeper.sh/tests: "yes"
spec:
enforcementAction: dryrun
match:
Expand Down
2 changes: 2 additions & 0 deletions test/bats/tests/constraints/all_cm_must_have_gatekeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sRequiredLabels
metadata:
name: cm-must-have-gk
labels:
gatekeeper.sh/tests: "yes"
spec:
match:
namespaces: ["gatekeeper-test-playground", "gatekeeper-excluded-namespace"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sRequiredLabels
metadata:
name: cm-must-have-gk-audit
labels:
gatekeeper.sh/tests: "yes"
spec:
match:
namespaces: ["gatekeeper-test-playground"]
Expand Down
2 changes: 2 additions & 0 deletions test/bats/tests/constraints/containers_must_be_limited.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sContainerLimits
metadata:
name: container-must-have-limits
labels:
gatekeeper.sh/tests: "yes"
spec:
match:
kinds:
Expand Down
2 changes: 2 additions & 0 deletions test/bats/tests/sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: config.gatekeeper.sh/v1alpha1
kind: Config
metadata:
name: config
labels:
gatekeeper.sh/tests: "yes"
spec:
sync:
syncOnly:
Expand Down
2 changes: 2 additions & 0 deletions test/bats/tests/sync_with_exclusion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: config.gatekeeper.sh/v1alpha1
kind: Config
metadata:
name: config
labels:
gatekeeper.sh/tests: "yes"
spec:
match:
- excludedNamespaces: ["gatekeeper-excluded-namespace"]
Expand Down
2 changes: 2 additions & 0 deletions test/bats/tests/templates/k8scontainterlimits_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: templates.gatekeeper.sh/v1beta1
kind: ConstraintTemplate
metadata:
name: k8scontainerlimits
labels:
gatekeeper.sh/tests: "yes"
spec:
crd:
spec:
Expand Down
2 changes: 2 additions & 0 deletions test/bats/tests/templates/k8srequiredlabels_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: templates.gatekeeper.sh/v1beta1
kind: ConstraintTemplate
metadata:
name: k8srequiredlabels
labels:
gatekeeper.sh/tests: "yes"
spec:
crd:
spec:
Expand Down
2 changes: 2 additions & 0 deletions test/bats/tests/templates/k8suniquelabel_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: templates.gatekeeper.sh/v1beta1
kind: ConstraintTemplate
metadata:
name: k8suniquelabel
labels:
gatekeeper.sh/tests: "yes"
spec:
crd:
spec:
Expand Down

0 comments on commit 84f64c4

Please sign in to comment.