Skip to content

Commit 3776c44

Browse files
committed
test(e2e): poll users-Job DESIRED_USERS_JSON for target email, not just Job existence
CI E2E showed the users-Job assertion returning `DESIRED_USERS_JSON: []` — but the CR body had `users: [{email: [email protected], role: Admin}]`. Root cause: `hook-delete-policy: before-hook-creation` keeps the previous hook Job around across helm upgrades, so `until kubectl get job` matches a stale Job from the previous customconfig- mode test where users may have been unset (the secretRef swap CR had no `users:` field, so the schema default `[]` propagated to the prior Job's DESIRED_USERS_JSON). The System test then grabbed that stale Job before the helm upgrade for the new CR completed and swapped in the fresh Job. Fix: poll on the target env value itself — the new Job with the correct users list is the first Job whose DESIRED_USERS_JSON string contains `[email protected]`. 600s window matches the inner HR's 15m timeout with room for a slow reconcile. Signed-off-by: IvanHunters <[email protected]>
1 parent b2fd323 commit 3776c44

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,20 @@ EOF
187187

188188
@test "users-Job runs and carries the desired list from spec.oidc.users" {
189189
# helm.sh/hook: post-install,post-upgrade — the Job appears after the
190-
# inner HR reconciles. `hook-delete-policy: before-hook-creation` keeps
191-
# it around after completion so we can assert on its shape.
192-
timeout 180 sh -ec 'until kubectl -n tenant-test get job "'"${INNER_REL}"'-oidc-users" >/dev/null 2>&1; do sleep 5; done'
190+
# inner HR reconciles. `hook-delete-policy: before-hook-creation`
191+
# keeps the previous Job around across upgrades, so `until kubectl
192+
# get job` may return a stale Job from the previous test (or from
193+
# the customconfig round where users was set differently or absent).
194+
# Poll on the target env value directly — the new Job with our
195+
# desired list is the first Job whose DESIRED_USERS_JSON contains
196+
197+
timeout 600 sh -ec '
198+
until kubectl -n tenant-test get job "'"${INNER_REL}"'-oidc-users" \
199+
-o jsonpath="{.spec.template.spec.containers[?(@.name==\"reconcile\")].env[?(@.name==\"DESIRED_USERS_JSON\")].value}" 2>/dev/null \
200+
| grep -q "[email protected]"; do
201+
sleep 5
202+
done
203+
'
193204

194205
desired=$(kubectl -n tenant-test get job "${INNER_REL}-oidc-users" \
195206
-o jsonpath='{.spec.template.spec.containers[?(@.name=="reconcile")].env[?(@.name=="DESIRED_USERS_JSON")].value}')

0 commit comments

Comments
 (0)