Files
k8s-manifests/n8n/postsync-smoke-test.yaml
2026-05-20 14:14:43 +00:00

62 lines
1.8 KiB
YAML

apiVersion: batch/v1
kind: Job
metadata:
name: postsync-smoke-test
namespace: n8n
annotations:
argocd.argoproj.io/hook: PostSync
argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
ttlSecondsAfterFinished: 600
backoffLimit: 0
template:
spec:
restartPolicy: Never
containers:
- name: smoke-test
image: curlimages/curl:latest
env:
- name: TELEGRAM_BOT_TOKEN
valueFrom:
secretKeyRef:
name: telegram-notify
key: TELEGRAM_BOT_TOKEN
- name: TELEGRAM_CHAT_ID
valueFrom:
secretKeyRef:
name: telegram-notify
key: TELEGRAM_CHAT_ID
command: ["/bin/sh", "-c"]
args:
- |
set -e
BASE="http://n8n.n8n.svc.cluster.local:5678"
notify() {
curl -s --max-time 10 -X POST \
"https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
-d "chat_id=${TELEGRAM_CHAT_ID}" \
--data-urlencode "text=$1" \
> /dev/null || true
}
fail() {
notify "[FAIL] n8n PostSync: $1"
exit 1
}
echo "--- [1/1] GET /healthz ---"
RESULT=""
for i in $(seq 1 12); do
RESULT=$(curl -sf --max-time 10 "$BASE/healthz" 2>/dev/null) && break
echo "Waiting... (attempt $i/12)"
sleep 5
done
[ -n "$RESULT" ] || fail "GET /healthz unreachable after 60s"
echo "$RESULT"
echo "$RESULT" | grep -qF '"status":"ok"' || fail "healthz did not return status ok"
echo "OK"
notify "[OK] n8n PostSync passed"
echo "=== n8n: all smoke tests passed ==="