Skip to content

Commit 4aa7bac

Browse files
authored
Update ci.yaml
1 parent d15d6f7 commit 4aa7bac

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

.github/workflows/ci.yaml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ jobs:
267267
\"
268268
"
269269
270-
- name: Run Python tests in-cluster (same pattern as Go)
270+
- name: Run Python tests in-cluster (robust)
271271
run: |
272272
set -euo pipefail
273273
@@ -277,16 +277,21 @@ jobs:
277277
POD=py-test-runner
278278
IMAGE=python:3.11-slim
279279
280-
# wait for endpoints (same as Go)
280+
# wait for endpoints
281281
WAIT_TIMEOUT=300
282282
INTERVAL=5
283283
deadline=$((SECONDS + WAIT_TIMEOUT))
284284
while [ $SECONDS -lt $deadline ]; do
285285
addrs=$(kubectl -n ${NS} get endpoints ${SVC} -o jsonpath='{.subsets[*].addresses[*].ip}' 2>/dev/null || true)
286286
[ -n "$addrs" ] && break || sleep ${INTERVAL}
287287
done
288+
if [ -z "$addrs" ]; then
289+
kubectl -n ${NS} get pods -o wide || true
290+
kubectl -n ${NS} get endpoints ${SVC} -o yaml || true
291+
exit 1
292+
fi
288293
289-
# create test pod and wait Running
294+
# create test pod and wait ready
290295
kubectl -n ${NS} delete pod ${POD} --ignore-not-found || true
291296
kubectl -n ${NS} run ${POD} --image=${IMAGE} --restart=Never --command -- sleep infinity
292297
kubectl -n ${NS} wait --for=condition=Ready pod/${POD} --timeout=180s
@@ -295,13 +300,11 @@ jobs:
295300
kubectl -n ${NS} exec -i pod/${POD} -- mkdir -p /workspace
296301
tar cf - . | kubectl -n ${NS} exec -i pod/${POD} -- tar xf - -C /workspace
297302
298-
# install system deps if tests need them
303+
# ensure build deps and python deps
299304
kubectl -n ${NS} exec pod/${POD} -- bash -lc 'apt-get update -qq && apt-get install -y -qq build-essential libssl-dev libpq-dev || true'
300-
301-
# install python deps
302305
kubectl -n ${NS} exec pod/${POD} -- bash -lc 'python -m pip install --upgrade pip >/dev/null 2>&1 || true; pip install tox pytest >/dev/null 2>&1 || true'
303306
304-
# fetch token inside cluster (curl pod)
307+
# fetch token inside cluster and copy into pod
305308
CT_POD="curl-token-$$"
306309
kubectl -n keycloak run ${CT_POD} --restart=Never --image=curlimages/curl:latest --command -- sleep 300
307310
kubectl -n keycloak wait --for=condition=Ready pod/${CT_POD} --timeout=120s || true
@@ -318,23 +321,17 @@ jobs:
318321
HTTP_CODE=$(printf "%s" "$RAW_JSON" | tail -n1)
319322
BODY=$(printf "%s" "$RAW_JSON" | sed '$d')
320323
if [ -z "$HTTP_CODE" ] || [ "$HTTP_CODE" -lt 200 ] || [ "$HTTP_CODE" -ge 300 ]; then
321-
echo "Failed to fetch token; http=$HTTP_CODE; body:"
322324
printf "%.1024s\n" "$BODY"
323325
exit 1
324326
fi
325327
TOKEN=$(printf "%s" "$BODY" | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("access_token",""))' || true)
326-
if [ -z "$TOKEN" ]; then
327-
echo "No access_token found; body:"
328-
echo "$BODY"
329-
exit 1
330-
fi
331328
printf '%s' "$TOKEN" > access_token.txt
332329
if ! kubectl -n ${NS} cp access_token.txt pod/${POD}:/workspace/access_token.txt 2>/dev/null; then
333330
printf '%s' "$TOKEN" | kubectl -n ${NS} exec -i pod/${POD} -- tee /workspace/access_token.txt >/dev/null
334331
fi
335332
rm -f access_token.txt
336333
337-
# inside pod: wait for TCP and run tests
334+
# inside pod: wait for vertica TCP then run tests
338335
kubectl -n ${NS} exec -i pod/${POD} -- bash -lc "
339336
set -euo pipefail
340337
cd /workspace
@@ -351,7 +348,6 @@ jobs:
351348
tox -e py
352349
"
353350
354-
# cleanup
355351
kubectl -n ${NS} delete pod ${POD} --ignore-not-found || true
356352
357353

0 commit comments

Comments
 (0)