Skip to content

Commit b8e0ac0

Browse files
authored
Reverting the changes
1 parent f4b000c commit b8e0ac0

File tree

1 file changed

+42
-70
lines changed

1 file changed

+42
-70
lines changed

.github/workflows/ci.yaml

Lines changed: 42 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -256,63 +256,45 @@ jobs:
256256
GRANT AUTHENTICATION v_dbadmin_hash TO dbadmin;
257257
\"
258258
"
259-
- name: Add fake hosts for loadbalance tests
260-
run: |
261-
echo "127.0.0.1 invalidhost" | sudo tee -a /etc/hosts
262-
echo "127.0.0.1 invalidhost2" | sudo tee -a /etc/hosts
263-
264-
265-
- name: Run Python tests in-cluster
259+
- name: Run Python tests in-cluster (robust + execution)
266260
run: |
267261
set -euo pipefail
268262
NS=my-verticadb-operator
269263
SVC=verticadb-sample-defaultsubcluster
264+
LOCATOR="${SVC}.${NS}.svc.cluster.local:5433"
270265
POD=py-test-runner
271266
IMAGE=python:${{ matrix.python-version }}-slim
272-
267+
echo "📦 Ensuring namespace ${NS} exists..."
268+
kubectl get ns ${NS} >/dev/null 2>&1 || kubectl create ns ${NS}
273269
echo "⏳ Waiting for Vertica service endpoints..."
274270
WAIT_TIMEOUT=300
271+
INTERVAL=5
275272
deadline=$((SECONDS + WAIT_TIMEOUT))
276273
while [ $SECONDS -lt $deadline ]; do
277274
addrs=$(kubectl -n ${NS} get endpoints ${SVC} -o jsonpath='{.subsets[*].addresses[*].ip}' 2>/dev/null || true)
278-
[ -n "$addrs" ] && break || sleep 5
275+
[ -n "$addrs" ] && break || sleep ${INTERVAL}
279276
done
280-
281277
if [ -z "$addrs" ]; then
282-
echo "Vertica service endpoints not found"
283-
kubectl -n ${NS} get pods -o wide
284-
kubectl -n ${NS} get endpoints ${SVC} -o yaml
278+
echo "Vertica service endpoints not found"
279+
kubectl -n ${NS} get pods -o wide || true
280+
kubectl -n ${NS} get endpoints ${SVC} -o yaml || true
285281
exit 1
286282
fi
287-
288-
echo "Service endpoints ready: $addrs"
289-
290-
echo "Creating Python test pod..."
291-
kubectl -n ${NS} delete pod ${POD} --ignore-not-found --wait || true
283+
echo "🚀 Creating Python test pod..."
284+
kubectl -n ${NS} delete pod ${POD} --ignore-not-found || true
292285
kubectl -n ${NS} run ${POD} --image=${IMAGE} --restart=Never --command -- sleep infinity
293-
kubectl -n ${NS} wait --for=condition=Ready pod/${POD} --timeout=3m
294-
295-
echo "Copying repository into pod..."
286+
kubectl -n ${NS} wait --for=condition=Ready pod/${POD} --timeout=180s
287+
echo "📂 Copying repository into pod..."
296288
kubectl -n ${NS} exec -i pod/${POD} -- mkdir -p /workspace
297289
tar cf - . | kubectl -n ${NS} exec -i pod/${POD} -- tar xf - -C /workspace
298-
299-
echo "Installing dependencies..."
300-
kubectl -n ${NS} exec pod/${POD} -- bash -c '
301-
apt-get update -qq && \
302-
apt-get install -y -qq build-essential libssl-dev libpq-dev netcat-traditional curl
303-
'
304-
kubectl -n ${NS} exec pod/${POD} -- bash -c '
305-
python -m pip install --upgrade pip >/dev/null 2>&1 && \
306-
pip install tox pytest >/dev/null 2>&1
307-
'
308-
309-
echo "Fetching OAuth token from Keycloak..."
290+
echo "🧰 Installing dependencies..."
291+
kubectl -n ${NS} exec pod/${POD} -- bash -lc 'apt-get update -qq && apt-get install -y -qq build-essential libssl-dev libpq-dev netcat-traditional curl || true'
292+
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'
293+
echo "🔑 Fetching token from Keycloak..."
310294
CT_POD="curl-token-$$"
311-
kubectl -n keycloak delete pod ${CT_POD} --ignore-not-found --wait || true
312-
kubectl -n keycloak run ${CT_POD} --restart=Never \
313-
--image=curlimages/curl:latest --command -- sleep 180
314-
kubectl -n keycloak wait --for=condition=Ready pod/${CT_POD} --timeout=2m
315-
295+
kubectl -n keycloak delete pod ${CT_POD} --ignore-not-found || true
296+
kubectl -n keycloak run ${CT_POD} --restart=Never --image=curlimages/curl:latest --command -- sleep 120
297+
kubectl -n keycloak wait --for=condition=Ready pod/${CT_POD} --timeout=120s || true
316298
kubectl -n keycloak exec pod/${CT_POD} -- sh -c "
317299
curl -s -X POST 'http://keycloak.keycloak.svc.cluster.local:8080/realms/${REALM}/protocol/openid-connect/token' \
318300
-d 'client_id=${CLIENT_ID}' \
@@ -321,68 +303,58 @@ jobs:
321303
-d 'grant_type=password' \
322304
-d 'client_secret=${CLIENT_SECRET}' > /tmp/token.json
323305
"
324-
325306
kubectl -n keycloak cp ${CT_POD}:/tmp/token.json token.json || {
326-
echo "Failed to copy token.json"
327-
kubectl -n keycloak logs ${CT_POD}
307+
echo "Failed to copy token.json from curl pod"
308+
kubectl -n keycloak logs ${CT_POD} || true
328309
exit 1
329310
}
330311
kubectl -n keycloak delete pod ${CT_POD} --ignore-not-found || true
331-
332-
TOKEN=$(python3 -c 'import json; print(json.load(open("token.json")).get("access_token",""))')
312+
TOKEN=$(python3 -c 'import json; print(__import__("json").load(open("token.json")).get("access_token",""))')
333313
if [ -z "$TOKEN" ]; then
334-
echo "No access_token found"
314+
echo "No access_token found in token.json"
335315
cat token.json
336316
exit 1
337317
fi
338-
339318
echo "✅ Access token retrieved (length: ${#TOKEN})"
340-
341-
echo "🏃 Running Python tests..."
342-
kubectl -n ${NS} exec -i pod/${POD} -- bash -c "
319+
printf '%s' "$TOKEN" | kubectl -n ${NS} exec -i pod/${POD} -- tee /workspace/access_token.txt >/dev/null
320+
echo "🏃 Running Python tests inside pod..."
321+
kubectl -n ${NS} exec -i pod/${POD} -- bash -lc "
343322
set -euo pipefail
344323
cd /workspace
345-
346324
export VP_TEST_OAUTH_ACCESS_TOKEN='${TOKEN}'
347325
export VP_TEST_HOST='${SVC}.${NS}.svc.cluster.local'
348326
export VP_TEST_PORT=5433
349327
export VP_TEST_DATABASE='vdb'
350328
export VP_TEST_OAUTH_USER='oauth_user'
351329
export VP_TEST_USER='dbadmin'
352330
export VP_TEST_PASSWORD=''
353-
354-
echo '🔍 Testing Vertica connectivity...'
355-
nc -zv \${VP_TEST_HOST} \${VP_TEST_PORT} || {
356-
echo '❌ Cannot reach Vertica'
357-
exit 1
358-
}
359-
360-
echo '🔍 Verifying OAuth token...'
361-
INTROSPECT=\$(curl -s -X POST \
362-
http://keycloak.keycloak.svc.cluster.local:8080/realms/test/protocol/openid-connect/token/introspect \
331+
echo '🔍 Checking connectivity to Vertica...'
332+
if command -v nc >/dev/null 2>&1; then
333+
nc -zv \${VP_TEST_HOST} \${VP_TEST_PORT} || { echo '❌ Cannot reach Vertica host'; exit 1; }
334+
else
335+
timeout 5 bash -c 'cat < /dev/null > /dev/tcp/'\"\${VP_TEST_HOST}\"'/'\"\${VP_TEST_PORT}\"'' || { echo '❌ Cannot reach Vertica host'; exit 1; }
336+
fi
337+
echo 'Vertica reachable; performing token introspection...'
338+
INTROSPECT_OUTPUT=\$(curl -s -X POST http://keycloak.keycloak.svc.cluster.local:8080/realms/test/protocol/openid-connect/token/introspect \
363339
-d 'client_id=vertica' \
364340
-d 'client_secret=P9f8350QQIUhFfK1GF5sMhq4Dm3P6Sbs' \
365-
-d \"token=\${VP_TEST_OAUTH_ACCESS_TOKEN}\")
366-
367-
if echo \"\$INTROSPECT\" | grep -q '\"active\":true'; then
368-
echo '✅ Token is valid'
341+
-d 'token='\${VP_TEST_OAUTH_ACCESS_TOKEN})
342+
if echo \"\$INTROSPECT_OUTPUT\" | grep -q '\"active\":true'; then
343+
echo '✅ Token introspection successful (active=true)'
369344
else
370-
echo '❌ Token validation failed'
371-
echo \"\$INTROSPECT\"
345+
echo '❌ Token introspection failed:'
346+
echo \"\$INTROSPECT_OUTPUT\"
372347
exit 1
373348
fi
374-
375-
echo '🧪 Running test suite...'
349+
echo '🚦 Running pytest suite via tox...'
376350
tox -e py
377351
"
378-
379352
echo "🧹 Cleaning up test pod..."
380353
kubectl -n ${NS} delete pod ${POD} --ignore-not-found || true
381-
382354
- name: Uninstall MinIO
383355
if: always()
384356
run: |
385357
kubectl delete pod minio -n minio --ignore-not-found || true
386358
kubectl delete svc minio -n minio --ignore-not-found || true
387359
kubectl delete ns minio || true
388-
echo "MinIO cleanup complete"
360+
echo "MinIO cleanup complete"

0 commit comments

Comments
 (0)