diff --git a/n8n/postsync-smoke-test.yaml b/n8n/postsync-smoke-test.yaml index d2b31f6..1a274db 100644 --- a/n8n/postsync-smoke-test.yaml +++ b/n8n/postsync-smoke-test.yaml @@ -15,18 +15,43 @@ spec: 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 ---" HEALTH=$(curl -sf --max-time 15 --retry 3 --retry-delay 5 --retry-all-errors \ - "$BASE/healthz") + "$BASE/healthz") || fail "GET /healthz unreachable" echo "$HEALTH" echo "$HEALTH" | grep -qF '"status":"ok"' \ - || { echo "FAIL: n8n health check did not return status ok"; exit 1; } + || fail "health response missing status:ok" echo "OK" + notify "[OK] n8n PostSync passed" echo "=== n8n: all smoke tests passed ===" diff --git a/n8n/secret-telegram-notify.yaml b/n8n/secret-telegram-notify.yaml new file mode 100644 index 0000000..2537896 --- /dev/null +++ b/n8n/secret-telegram-notify.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: telegram-notify + namespace: n8n +type: Opaque +data: + TELEGRAM_BOT_TOKEN: ODYxMTkxMzgwMjpBQUZsckZ0YzB2WUlTT2xpT19XOEI0Yy1XMXVlMGhHOUZpbw== + TELEGRAM_CHAT_ID: NTEzODQwNzY2Ng== diff --git a/openclaw/postsync-smoke-test.yaml b/openclaw/postsync-smoke-test.yaml new file mode 100644 index 0000000..cd555c4 --- /dev/null +++ b/openclaw/postsync-smoke-test.yaml @@ -0,0 +1,54 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: postsync-smoke-test + namespace: openclaw + 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://openclaw.openclaw.svc.cluster.local:18789" + + 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] openclaw PostSync: $1" + exit 1 + } + + echo "--- [1/1] GET / (HTTP 200) ---" + curl -sfL --max-time 15 --retry 3 --retry-delay 5 --retry-all-errors \ + "$BASE/" > /dev/null || fail "GET / returned non-200" + echo "OK" + + notify "[OK] openclaw PostSync passed" + echo "=== openclaw: all smoke tests passed ===" diff --git a/openclaw/secret-telegram-notify.yaml b/openclaw/secret-telegram-notify.yaml new file mode 100644 index 0000000..0941498 --- /dev/null +++ b/openclaw/secret-telegram-notify.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: telegram-notify + namespace: openclaw +type: Opaque +data: + TELEGRAM_BOT_TOKEN: ODYxMTkxMzgwMjpBQUZsckZ0YzB2WUlTT2xpT19XOEI0Yy1XMXVlMGhHOUZpbw== + TELEGRAM_CHAT_ID: NTEzODQwNzY2Ng== diff --git a/polymarket-bot/postsync-smoke-test.yaml b/polymarket-bot/postsync-smoke-test.yaml index ab55689..fec3c8f 100644 --- a/polymarket-bot/postsync-smoke-test.yaml +++ b/polymarket-bot/postsync-smoke-test.yaml @@ -15,6 +15,17 @@ spec: 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: - | @@ -22,22 +33,36 @@ spec: API="http://api.polymarket-bot.svc.cluster.local:8000" DASH="http://dashboard.polymarket-bot.svc.cluster.local:80" + 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] polymarket-bot PostSync: $1" + exit 1 + } + echo "--- [1/3] GET /api/summary ---" SUMMARY=$(curl -sf --max-time 15 --retry 3 --retry-delay 5 --retry-all-errors \ - "$API/api/summary") + "$API/api/summary") || fail "GET /api/summary unreachable" echo "$SUMMARY" echo "$SUMMARY" | grep -qE '"paper_mode"\s*:\s*true' \ - || { echo "FAIL: paper_mode is not true"; exit 1; } + || fail "paper_mode is not true" echo "OK" echo "--- [2/3] GET /api/trades?status=open ---" curl -sf --max-time 15 --retry 3 --retry-delay 5 --retry-all-errors \ - "$API/api/trades?status=open" > /dev/null + "$API/api/trades?status=open" > /dev/null || fail "GET /api/trades unreachable" echo "OK" echo "--- [3/3] Dashboard HTTP 200 ---" curl -sf --max-time 15 --retry 3 --retry-delay 5 --retry-all-errors \ - "$DASH/" > /dev/null + "$DASH/" > /dev/null || fail "dashboard returned non-200" echo "OK" + notify "[OK] polymarket-bot PostSync passed" echo "=== polymarket-bot: all smoke tests passed ===" diff --git a/polymarket-bot/secret-telegram-notify.yaml b/polymarket-bot/secret-telegram-notify.yaml new file mode 100644 index 0000000..93da634 --- /dev/null +++ b/polymarket-bot/secret-telegram-notify.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: telegram-notify + namespace: polymarket-bot +type: Opaque +data: + TELEGRAM_BOT_TOKEN: ODYxMTkxMzgwMjpBQUZsckZ0YzB2WUlTT2xpT19XOEI0Yy1XMXVlMGhHOUZpbw== + TELEGRAM_CHAT_ID: NTEzODQwNzY2Ng== diff --git a/portfolio/postsync-smoke-test.yaml b/portfolio/postsync-smoke-test.yaml index f68407f..f0da0a6 100644 --- a/portfolio/postsync-smoke-test.yaml +++ b/portfolio/postsync-smoke-test.yaml @@ -15,15 +15,40 @@ spec: 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://portfolio.portfolio.svc.cluster.local:80" + 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] portfolio PostSync: $1" + exit 1 + } + echo "--- [1/1] GET / (HTTP 200) ---" curl -sf --max-time 15 --retry 3 --retry-delay 5 --retry-all-errors \ - "$BASE/" > /dev/null + "$BASE/" > /dev/null || fail "GET / returned non-200" echo "OK" + notify "[OK] portfolio PostSync passed" echo "=== portfolio: all smoke tests passed ===" diff --git a/portfolio/secret-telegram-notify.yaml b/portfolio/secret-telegram-notify.yaml new file mode 100644 index 0000000..87f64f5 --- /dev/null +++ b/portfolio/secret-telegram-notify.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: telegram-notify + namespace: portfolio +type: Opaque +data: + TELEGRAM_BOT_TOKEN: ODYxMTkxMzgwMjpBQUZsckZ0YzB2WUlTT2xpT19XOEI0Yy1XMXVlMGhHOUZpbw== + TELEGRAM_CHAT_ID: NTEzODQwNzY2Ng== diff --git a/researchowl/postsync-smoke-test.yaml b/researchowl/postsync-smoke-test.yaml new file mode 100644 index 0000000..aae5922 --- /dev/null +++ b/researchowl/postsync-smoke-test.yaml @@ -0,0 +1,63 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: postsync-smoke-test + namespace: researchowl + annotations: + argocd.argoproj.io/hook: PostSync + argocd.argoproj.io/hook-delete-policy: HookSucceeded +spec: + ttlSecondsAfterFinished: 600 + backoffLimit: 0 + template: + spec: + serviceAccountName: smoke-test-reader + 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 + TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) + CACERT=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt + K8S_API="https://kubernetes.default.svc" + + 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] researchowl PostSync: $1" + exit 1 + } + + echo "--- [1/1] Deployment researchowl ready replicas ---" + DEPLOY=$(curl -sf --max-time 15 \ + --header "Authorization: Bearer $TOKEN" \ + --cacert "$CACERT" \ + "$K8S_API/apis/apps/v1/namespaces/researchowl/deployments/researchowl") \ + || fail "k8s API unreachable" + + READY=$(echo "$DEPLOY" | grep -o '"readyReplicas":[0-9]*' | grep -o '[0-9]*' || echo "0") + [ "${READY:-0}" -ge 1 ] || fail "readyReplicas=${READY:-0} (expected >= 1)" + echo "readyReplicas=$READY — OK" + + notify "[OK] researchowl PostSync passed — deployment ready" + echo "=== researchowl: all smoke tests passed ===" diff --git a/researchowl/rbac-smoke-test.yaml b/researchowl/rbac-smoke-test.yaml new file mode 100644 index 0000000..c39bd24 --- /dev/null +++ b/researchowl/rbac-smoke-test.yaml @@ -0,0 +1,31 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: smoke-test-reader + namespace: researchowl + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: smoke-test-reader + namespace: researchowl +rules: +- apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["get"] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: smoke-test-reader + namespace: researchowl +subjects: +- kind: ServiceAccount + name: smoke-test-reader + namespace: researchowl +roleRef: + kind: Role + name: smoke-test-reader + apiGroup: rbac.authorization.k8s.io diff --git a/researchowl/secret-telegram-notify.yaml b/researchowl/secret-telegram-notify.yaml new file mode 100644 index 0000000..7f11c80 --- /dev/null +++ b/researchowl/secret-telegram-notify.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: telegram-notify + namespace: researchowl +type: Opaque +data: + TELEGRAM_BOT_TOKEN: ODYxMTkxMzgwMjpBQUZsckZ0YzB2WUlTT2xpT19XOEI0Yy1XMXVlMGhHOUZpbw== + TELEGRAM_CHAT_ID: NTEzODQwNzY2Ng==