feat: add comprehensive testing mechanism for dashboard features
Deploy Dashboard (Dev) / deploy-dev (push) Failing after 2m0s
Run Tests / Backend Tests (push) Failing after 4m26s
Run Tests / Frontend Tests (push) Failing after 49s
Run Tests / Test Summary (push) Failing after 15s
Run Tests / Backend Tests (pull_request) Failing after 6m9s
Run Tests / Frontend Tests (pull_request) Failing after 3m54s
Run Tests / Test Summary (pull_request) Failing after 15s
Deploy Dashboard (Dev) / deploy-dev (push) Failing after 2m0s
Run Tests / Backend Tests (push) Failing after 4m26s
Run Tests / Frontend Tests (push) Failing after 49s
Run Tests / Test Summary (push) Failing after 15s
Run Tests / Backend Tests (pull_request) Failing after 6m9s
Run Tests / Frontend Tests (pull_request) Failing after 3m54s
Run Tests / Test Summary (pull_request) Failing after 15s
- Add smoke test script for post-deployment verification - Add health monitoring script with Telegram alerts - Add backend integration tests for conversation tracker API - Add frontend tests to verify correct API paths - Update CI/CD workflows to enforce test failures and run smoke tests - Add comprehensive testing documentation This testing mechanism will catch issues like the double /api/ prefix bug before they reach users.
This commit is contained in:
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
# Monitor dashboard health and send alerts
|
||||
# Run via cron: */5 * * * * /volume1/repos/nas-tools/scripts/monitor-dashboard-health.sh
|
||||
|
||||
PROD_URL="http://nas.jimmygan.com:4000"
|
||||
DEV_URL="http://nas.jimmygan.com:4001"
|
||||
ALERT_FILE="/tmp/dashboard-health-alert-sent"
|
||||
LOG_DIR="/volume1/repos/nas-tools/logs"
|
||||
|
||||
# Create log directory if it doesn't exist
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
check_endpoint() {
|
||||
local url=$1
|
||||
local name=$2
|
||||
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" "$url/api/health" --max-time 5)
|
||||
|
||||
if [ "$response" != "200" ]; then
|
||||
echo "$(date): ❌ $name health check failed (HTTP $response)"
|
||||
return 1
|
||||
fi
|
||||
echo "$(date): ✅ $name health check passed"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Check production
|
||||
if ! check_endpoint "$PROD_URL" "Production"; then
|
||||
if [ ! -f "$ALERT_FILE" ]; then
|
||||
# Send alert only once until issue is resolved
|
||||
/volume1/repos/nas-tools/notify.sh "⚠️ Dashboard Production Health Check Failed - HTTP endpoint not responding"
|
||||
touch "$ALERT_FILE"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check dev (non-critical, just log)
|
||||
if ! check_endpoint "$DEV_URL" "Dev"; then
|
||||
echo "$(date): ⚠️ Dev dashboard health check failed (non-critical)"
|
||||
fi
|
||||
|
||||
# Clear alert file if checks pass
|
||||
if [ -f "$ALERT_FILE" ]; then
|
||||
rm -f "$ALERT_FILE"
|
||||
/volume1/repos/nas-tools/notify.sh "✅ Dashboard Production Health Restored"
|
||||
fi
|
||||
|
||||
echo "$(date): ✅ All health checks passed"
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
# Smoke test for dashboard deployment
|
||||
# Usage: ./smoke-test-dashboard.sh [dev|prod]
|
||||
|
||||
set -e
|
||||
|
||||
ENV=${1:-dev}
|
||||
if [ "$ENV" = "dev" ]; then
|
||||
BASE_URL="http://nas.jimmygan.com:4001"
|
||||
CONTAINER="nas-dashboard-dev"
|
||||
else
|
||||
BASE_URL="http://nas.jimmygan.com:4000"
|
||||
CONTAINER="nas-dashboard"
|
||||
fi
|
||||
|
||||
echo "=== Dashboard Smoke Test ($ENV) ==="
|
||||
echo "Base URL: $BASE_URL"
|
||||
echo ""
|
||||
|
||||
# Test 1: Health check
|
||||
echo "1. Testing health endpoint..."
|
||||
HEALTH=$(curl -s "$BASE_URL/api/health" --max-time 5)
|
||||
if echo "$HEALTH" | grep -q '"status":"ok"'; then
|
||||
echo "✅ Health check passed"
|
||||
else
|
||||
echo "❌ Health check failed: $HEALTH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test 2: Frontend loads
|
||||
echo "2. Testing frontend loads..."
|
||||
FRONTEND=$(curl -s "$BASE_URL/" --max-time 5 | grep -c "NAS Dashboard" || echo "0")
|
||||
if [ "$FRONTEND" -gt 0 ]; then
|
||||
echo "✅ Frontend loads"
|
||||
else
|
||||
echo "❌ Frontend failed to load"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test 3: API endpoints respond (should require auth)
|
||||
echo "3. Testing API endpoints require auth..."
|
||||
DATES=$(curl -s "$BASE_URL/api/conversations/dates" --max-time 5)
|
||||
if echo "$DATES" | grep -q "Not authenticated"; then
|
||||
echo "✅ Conversation tracker API requires auth"
|
||||
else
|
||||
echo "❌ Unexpected response: $DATES"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test 4: Check for double /api/ prefix bug
|
||||
echo "4. Testing for double /api/ prefix bug..."
|
||||
DOUBLE_API=$(curl -s -o /dev/null -w "%{http_code}" "$BASE_URL/api/api/conversations/dates" --max-time 5)
|
||||
if [ "$DOUBLE_API" = "404" ]; then
|
||||
echo "✅ No double /api/ prefix bug"
|
||||
else
|
||||
echo "⚠️ Warning: /api/api/ path returned $DOUBLE_API (should be 404)"
|
||||
fi
|
||||
|
||||
# Test 5: Container health
|
||||
echo "5. Checking container health..."
|
||||
HEALTH_STATUS=$(ssh nas "/volume1/@appstore/ContainerManager/usr/bin/docker inspect --format='{{.State.Health.Status}}' $CONTAINER" 2>/dev/null || echo "unknown")
|
||||
if [ "$HEALTH_STATUS" = "healthy" ]; then
|
||||
echo "✅ Container is healthy"
|
||||
else
|
||||
echo "❌ Container health: $HEALTH_STATUS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test 6: Check recent logs for errors
|
||||
echo "6. Checking for recent errors in logs..."
|
||||
ERROR_COUNT=$(ssh nas "/volume1/@appstore/ContainerManager/usr/bin/docker logs $CONTAINER --tail 50 2>&1 | grep -c 'ERROR' || echo 0")
|
||||
if [ "$ERROR_COUNT" -lt 5 ]; then
|
||||
echo "✅ No critical errors in recent logs ($ERROR_COUNT errors)"
|
||||
else
|
||||
echo "⚠️ Warning: Found $ERROR_COUNT errors in recent logs"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== All smoke tests passed! ==="
|
||||
Reference in New Issue
Block a user