metallkart-erp/scripts/trigger-supervisor-http.sh
louis 11cc64698e test(supervisor): 10/10 detectors validated + cleanup complete
Seed 10 tagged cases (D1-D10), triggered via admin route in digest
mode: 10 AgentAction EXECUTED, 25 NotificationDelivery across 4
channels (ERP_IN_APP/PWA_PUSH/TELEGRAM/EMAIL). Escalation chain
validated. All test data cleaned up (81 rows deleted, 0 remaining).
Override function kept for future test runs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-29 02:26:35 +04:00

30 lines
1014 B
Bash

#!/bin/bash
set -e
cd /opt/erp/metallkart-erp
COOKIE_JAR=/tmp/mk-admin-cookies.txt
# Login (cookies HTTPOnly)
curl -s -X POST http://localhost:3001/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"gruart@cifem-rus.ru","password":"MetallKart2026!"}' \
-c "$COOKIE_JAR" -o /tmp/login-resp.json
echo "Login: $(cat /tmp/login-resp.json | head -c 100)"
echo "Cookies saved: $(wc -l < $COOKIE_JAR) lines"
# Trigger supervisor in digest mode (use cookies)
RESULT=$(curl -s -X POST http://localhost:3001/api/v1/admin/agent/supervisor/trigger-now \
-H "Content-Type: application/json" \
-b "$COOKIE_JAR" \
-d '{"mode":"digest"}')
echo "Trigger result: $RESULT"
# Check agent_actions
echo "--- Agent Actions (last 2 min) ---"
docker exec postgres-staging psql -U metallkart -d erp_staging -c "
SELECT id, type, status, \"relatedEntityType\", \"relatedEntityId\", LEFT(\"errorMessage\", 60) as err
FROM agent_actions WHERE \"createdAt\" >= NOW() - INTERVAL '2 min' ORDER BY id DESC
"