Skip to content

Commit 90e9db4

Browse files
authored
Update ci.yaml
1 parent 5a97bac commit 90e9db4

1 file changed

Lines changed: 50 additions & 16 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -303,47 +303,80 @@ jobs:
303303
kubectl -n ${NS} exec pod/${POD} -- bash -lc 'apt-get update -qq && apt-get install -y -qq build-essential libssl-dev libpq-dev || true'
304304
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'
305305
306-
# fetch token inside cluster and copy into pod
306+
# fetch token inside cluster
307307
CT_POD="curl-token-$$"
308-
kubectl -n keycloak run ${CT_POD} --restart=Never --image=curlimages/curl:latest --command -- sleep 300
308+
echo "Launching temporary curl pod in keycloak namespace..."
309+
kubectl -n keycloak delete pod ${CT_POD} --ignore-not-found || true
310+
kubectl -n keycloak run ${CT_POD} --restart=Never --image=curlimages/curl:latest --command -- sleep 120
309311
kubectl -n keycloak wait --for=condition=Ready pod/${CT_POD} --timeout=120s || true
312+
313+
echo "Requesting token from Keycloak..."
310314
kubectl -n keycloak exec pod/${CT_POD} -- sh -c "
311-
curl -s -w '\n%{http_code}' -X POST 'http://keycloak.keycloak.svc.cluster.local:8080/realms/${REALM}/protocol/openid-connect/token' \
315+
curl -s -X POST 'http://keycloak.keycloak.svc.cluster.local:8080/realms/${REALM}/protocol/openid-connect/token' \
312316
-d 'client_id=${CLIENT_ID}' \
313317
-d 'username=${USER}' \
314318
-d 'password=${PASSWORD}' \
315319
-d 'grant_type=password' \
316-
-d 'client_secret=${CLIENT_SECRET}' > /tmp/token_resp.txt || true
320+
-d 'client_secret=${CLIENT_SECRET}' > /tmp/token.json
317321
"
318-
RAW_JSON=$(kubectl -n keycloak exec pod/${CT_POD} -- cat /tmp/token_resp.txt || true)
322+
323+
echo "Copying token.json from cluster to runner..."
324+
kubectl -n keycloak cp ${CT_POD}:/tmp/token.json token.json || {
325+
echo "❌ Failed to copy token.json from curl pod"
326+
kubectl -n keycloak logs ${CT_POD} || true
327+
exit 1
328+
}
329+
319330
kubectl -n keycloak delete pod ${CT_POD} --ignore-not-found || true
320-
HTTP_CODE=$(printf "%s" "$RAW_JSON" | tail -n1)
321-
BODY=$(printf "%s" "$RAW_JSON" | sed '$d')
322-
if [ -z "$HTTP_CODE" ] || [ "$HTTP_CODE" -lt 200 ] || [ "$HTTP_CODE" -ge 300 ]; then
323-
printf "%.1024s\n" "$BODY"
331+
332+
if [ ! -s token.json ]; then
333+
echo "❌ token.json missing or empty"
324334
exit 1
325335
fi
326-
TOKEN=$(printf "%s" "$BODY" | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("access_token",""))' || true)
327-
printf '%s' "$TOKEN" > access_token.txt
336+
337+
cat token.json | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("access_token",""))' > access_token.txt
338+
339+
if [ ! -s access_token.txt ]; then
340+
echo "❌ No access_token found in token.json"
341+
cat token.json
342+
exit 1
343+
fi
344+
345+
echo "✅ Access token successfully fetched and saved as access_token.txt"
346+
head -c 60 access_token.txt && echo "..."
347+
348+
echo "Copying access_token.txt into Python pod..."
328349
if ! kubectl -n ${NS} cp access_token.txt pod/${POD}:/workspace/access_token.txt 2>/dev/null; then
329-
printf '%s' "$TOKEN" | kubectl -n ${NS} exec -i pod/${POD} -- tee /workspace/access_token.txt >/dev/null
350+
echo "Fallback: writing token into pod via stdin"
351+
TOKEN_CONTENT=$(cat access_token.txt)
352+
printf '%s' "$TOKEN_CONTENT" | kubectl -n ${NS} exec -i pod/${POD} -- tee /workspace/access_token.txt >/dev/null
330353
fi
331-
rm -f access_token.txt
332354
333-
# inside pod: wait for vertica TCP then run tests
334355
- name: Run tests inside python pod
335356
run: |
357+
set -euo pipefail
336358
NS=my-verticadb-operator
337359
POD=py-test-runner
338360
HOST=verticadb-sample-defaultsubcluster-0.my-verticadb-operator.svc.cluster.local
339361
DB=vdb
340362
USER=oauth_user
363+
364+
if [ ! -f access_token.txt ]; then
365+
echo "❌ Missing access_token.txt — token not created by previous step"
366+
exit 1
367+
fi
368+
341369
TOKEN=$(cat access_token.txt)
370+
if [ -z "$TOKEN" ]; then
371+
echo "❌ Empty token content"
372+
exit 1
373+
fi
342374
375+
echo "✅ Running tests inside pod (token length: ${#TOKEN})"
343376
kubectl -n ${NS} exec -i pod/${POD} -- bash -lc "
344377
set -euo pipefail
345378
cd /workspace
346-
python -m pip install --upgrade pip >/dev/null 2>&1 || true
379+
pip install --upgrade pip >/dev/null 2>&1 || true
347380
pip install tox pytest >/dev/null 2>&1 || true
348381
349382
export VP_TEST_OAUTH_ACCESS_TOKEN='${TOKEN}'
@@ -356,9 +389,10 @@ jobs:
356389
tox -e py
357390
"
358391
359-
392+
echo "Cleaning up test pod..."
360393
kubectl -n ${NS} delete pod ${POD} --ignore-not-found || true
361394
395+
362396
- name: Uninstall MinIO
363397
if: always()
364398
run: |

0 commit comments

Comments
 (0)