Fix integration test ordering: move new tests before exit, add runbook execution flow
This commit is contained in:
@@ -146,32 +146,6 @@ code=$(curl -s -o /dev/null -w "%{http_code}" "$(url 3002 /api/v1/dashboard)" \
|
|||||||
resp=$(api GET 3002 /api/v1/stacks "$DRIFT_TOKEN")
|
resp=$(api GET 3002 /api/v1/stacks "$DRIFT_TOKEN")
|
||||||
echo "$resp" | grep -q "\[\]" && check "List stacks (empty)" "pass" || check "List stacks" "fail"
|
echo "$resp" | grep -q "\[\]" && check "List stacks (empty)" "pass" || check "List stacks" "fail"
|
||||||
|
|
||||||
# ─── Cross-service: API Key generation ───
|
|
||||||
echo -e "\n${YELLOW}Cross-service: API Key Auth${NC}"
|
|
||||||
resp=$(api POST 3003 /api/v1/auth/api-keys "$ALERT_TOKEN" -d "{}")
|
|
||||||
API_KEY=$(echo "$resp" | grep -o '"api_key":"[^"]*' | cut -d'"' -f4)
|
|
||||||
if [ -n "$API_KEY" ]; then
|
|
||||||
check "Generate API key" "pass"
|
|
||||||
# Use API key to hit an endpoint
|
|
||||||
code=$(curl -s -o /dev/null -w "%{http_code}" "$(url 3003 /api/v1/incidents)" \
|
|
||||||
-H "X-API-Key: $API_KEY")
|
|
||||||
[ "$code" = "200" ] && check "Auth via API key" "pass" || check "Auth via API key (HTTP $code)" "fail"
|
|
||||||
else
|
|
||||||
check "Generate API key" "fail"
|
|
||||||
check "Auth via API key (skipped)" "fail"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Summary
|
|
||||||
echo ""
|
|
||||||
echo -e "${YELLOW}═══════════════════════════${NC}"
|
|
||||||
if [ "$PASSED" -eq "$TOTAL" ]; then
|
|
||||||
echo -e "${GREEN}ALL PASSED: $PASSED/$TOTAL${NC}"
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo -e "${RED}$PASSED/$TOTAL passed ($((TOTAL - PASSED)) failed)${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ─── P3 Webhook Secrets Management ───
|
# ─── P3 Webhook Secrets Management ───
|
||||||
echo -e "\n${YELLOW}P3 Webhook Secrets Management (:3003)${NC}"
|
echo -e "\n${YELLOW}P3 Webhook Secrets Management (:3003)${NC}"
|
||||||
|
|
||||||
@@ -202,3 +176,55 @@ echo "$resp" | grep -q "drift_score" && check "Stack drift history" "pass" || ch
|
|||||||
code=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE "$(url 3002 /api/v1/stacks/vpc-prod)" \
|
code=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE "$(url 3002 /api/v1/stacks/vpc-prod)" \
|
||||||
-H "Authorization: Bearer $DRIFT_TOKEN")
|
-H "Authorization: Bearer $DRIFT_TOKEN")
|
||||||
[ "$code" = "200" ] && check "Delete stack" "pass" || check "Delete stack (HTTP $code)" "fail"
|
[ "$code" = "200" ] && check "Delete stack" "pass" || check "Delete stack (HTTP $code)" "fail"
|
||||||
|
|
||||||
|
# ─── P6 Runbook Execution ───
|
||||||
|
echo -e "\n${YELLOW}P6 Runbook Execution (:3006)${NC}"
|
||||||
|
|
||||||
|
# Get the runbook ID we created earlier
|
||||||
|
RUNBOOK_ID=$(api GET 3006 /api/v1/runbooks "$RUN_TOKEN" | grep -o '"id":"[^"]*' | head -1 | cut -d'"' -f4)
|
||||||
|
if [ -n "$RUNBOOK_ID" ]; then
|
||||||
|
resp=$(api POST 3006 "/api/v1/runbooks/$RUNBOOK_ID/execute" "$RUN_TOKEN" \
|
||||||
|
-d '{"dry_run":true,"variables":{"target":"web-01"}}')
|
||||||
|
echo "$resp" | grep -q "pending\|execution_id" && check "Execute runbook (dry run)" "pass" || check "Execute runbook (dry run)" "fail"
|
||||||
|
|
||||||
|
EXEC_ID=$(echo "$resp" | grep -o '"execution_id":"[^"]*' | cut -d'"' -f4)
|
||||||
|
if [ -n "$EXEC_ID" ]; then
|
||||||
|
resp=$(api GET 3006 "/api/v1/executions/$EXEC_ID" "$RUN_TOKEN")
|
||||||
|
echo "$resp" | grep -q "pending\|dry_run" && check "Get execution status" "pass" || check "Get execution status" "fail"
|
||||||
|
else
|
||||||
|
check "Get execution status (no exec ID)" "fail"
|
||||||
|
fi
|
||||||
|
|
||||||
|
resp=$(api GET 3006 "/api/v1/runbooks/$RUNBOOK_ID/executions" "$RUN_TOKEN")
|
||||||
|
echo "$resp" | grep -q "executions\|$EXEC_ID" && check "List runbook executions" "pass" || check "List runbook executions" "fail"
|
||||||
|
else
|
||||||
|
check "Execute runbook (no runbook found)" "fail"
|
||||||
|
check "Get execution status (skipped)" "fail"
|
||||||
|
check "List runbook executions (skipped)" "fail"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ─── Cross-service: API Key generation ───
|
||||||
|
echo -e "\n${YELLOW}Cross-service: API Key Auth${NC}"
|
||||||
|
resp=$(api POST 3003 /api/v1/auth/api-keys "$ALERT_TOKEN" -d "{}")
|
||||||
|
API_KEY=$(echo "$resp" | grep -o '"api_key":"[^"]*' | cut -d'"' -f4)
|
||||||
|
if [ -n "$API_KEY" ]; then
|
||||||
|
check "Generate API key" "pass"
|
||||||
|
# Use API key to hit an endpoint
|
||||||
|
code=$(curl -s -o /dev/null -w "%{http_code}" "$(url 3003 /api/v1/incidents)" \
|
||||||
|
-H "X-API-Key: $API_KEY")
|
||||||
|
[ "$code" = "200" ] && check "Auth via API key" "pass" || check "Auth via API key (HTTP $code)" "fail"
|
||||||
|
else
|
||||||
|
check "Generate API key" "fail"
|
||||||
|
check "Auth via API key (skipped)" "fail"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
echo ""
|
||||||
|
echo -e "${YELLOW}═══════════════════════════${NC}"
|
||||||
|
if [ "$PASSED" -eq "$TOTAL" ]; then
|
||||||
|
echo -e "${GREEN}ALL PASSED: $PASSED/$TOTAL${NC}"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo -e "${RED}$PASSED/$TOTAL passed ($((TOTAL - PASSED)) failed)${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user