Skip to content

Commit

Permalink
fix: added namespaces in e2e events test
Browse files Browse the repository at this point in the history
Signed-off-by: Eshaan Mathur <[email protected]>
  • Loading branch information
eshaanm25 committed Mar 23, 2023
1 parent 5070c36 commit 6513e4e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/bats/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ __required_labels_audit_test() {

@test "emit events test" {
# list events for easy debugging
kubectl get events -n ${GATEKEEPER_NAMESPACE}
events=$(kubectl get events -n ${GATEKEEPER_NAMESPACE} --field-selector reason=FailedAdmission -o json | jq -r '.items[] | select(.metadata.annotations.constraint_kind=="K8sRequiredLabels" )' | jq -s '. | length')
kubectl get events -n gatekeeper-test-playground
events=$(kubectl get events -n gatekeeper-test-playground --field-selector reason=FailedAdmission -o json | jq -r '.items[] | select(.metadata.annotations.constraint_kind=="K8sRequiredLabels" )' | jq -s '. | length')
[[ "$events" -ge 1 ]]

events=$(kubectl get events -n ${GATEKEEPER_NAMESPACE} --field-selector reason=DryrunViolation -o json | jq -r '.items[] | select(.metadata.annotations.constraint_kind=="K8sRequiredLabels" )' | jq -s '. | length')
events=$(kubectl get events -n gatekeeper-test-playground --field-selector reason=DryrunViolation -o json | jq -r '.items[] | select(.metadata.annotations.constraint_kind=="K8sRequiredLabels" )' | jq -s '. | length')
[[ "$events" -ge 1 ]]

events=$(kubectl get events -n ${GATEKEEPER_NAMESPACE} --field-selector reason=AuditViolation -o json | jq -r '.items[] | select(.metadata.annotations.constraint_kind=="K8sRequiredLabels" )' | jq -s '. | length')
events=$(kubectl get events -n gatekeeper-test-playground --field-selector reason=AuditViolation -o json | jq -r '.items[] | select(.metadata.annotations.constraint_kind=="K8sRequiredLabels" )' | jq -s '. | length')
[[ "$events" -ge 1 ]]
}

Expand Down

0 comments on commit 6513e4e

Please sign in to comment.