Skip to content

Commit 5c57db5

Browse files
test(tests): fix the same ineffective api-resources guard in monitoring OIDC bats
Both suites skip when the EDP Keycloak CRDs are absent, but the probe tested the exit code of `kubectl api-resources`, which is 0 for an absent API group. The skip therefore never fired: on a runner without the Keycloak operator, monitoring-oidc-system spent its 60s timeout waiting for a KeycloakClient that can never exist, and monitoring-oidc-customconfig passed for the wrong reason (its negative assertions succeed on an unknown resource type). Test the discovery output instead, like the ValidatingAdmissionPolicy preflight in e2e-install-cozystack.bats already does. Signed-off-by: Mattia Eleuteri <[email protected]>
1 parent 50f3fae commit 5c57db5

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎hack/e2e-apps/monitoring-oidc-customconfig.bats‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,11 @@ EOF
107107
}
108108

109109
@test "No KeycloakClient / Scope are created in the cozy realm" {
110-
# Only meaningful when the EDP CRDs exist on the cluster.
111-
if ! kubectl api-resources --api-group=v1.edp.epam.com >/dev/null 2>&1; then
110+
# Only meaningful when the EDP CRDs exist on the cluster. Test the OUTPUT,
111+
# not the exit code: `kubectl api-resources` exits 0 for an absent API group
112+
# and just prints an empty list, so an exit-code guard never skips.
113+
if ! kubectl api-resources --api-group=v1.edp.epam.com --output=name 2>/dev/null \
114+
| grep -q '^keycloakclients\.'; then
112115
skip "EDP Keycloak operator CRDs not present on this cluster"
113116
fi
114117

‎hack/e2e-apps/monitoring-oidc-system.bats‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ EOF
128128
# The EDP Keycloak operator API group is only present when the
129129
# platform-level OIDC feature is on. Skip gracefully otherwise so the
130130
# test suite works on runners without Keycloak installed.
131-
if ! kubectl api-resources --api-group=v1.edp.epam.com >/dev/null 2>&1; then
131+
# Test the OUTPUT, not the exit code: `kubectl api-resources` exits 0 for an
132+
# absent API group and just prints an empty list, so an exit-code guard never
133+
# skips and the assertions below would time out instead.
134+
if ! kubectl api-resources --api-group=v1.edp.epam.com --output=name 2>/dev/null \
135+
| grep -q '^keycloakclients\.'; then
132136
skip "EDP Keycloak operator CRDs not present on this cluster"
133137
fi
134138

0 commit comments

Comments
 (0)