Simple bash script to verify all Docker containers are running
and all critical API endpoints are responding.
Usage: ./verify_system.sh
Checks:
- 8 Docker containers health status
- 5 API endpoints responsiveness
- Overall system readiness for testing
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
87 lines
2.9 KiB
Bash
Executable File
87 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# E-Voting System Verification Script
|
|
# Checks all system components are healthy
|
|
|
|
echo "╔════════════════════════════════════════════════════════════╗"
|
|
echo "║ E-Voting System - Health Check ║"
|
|
echo "╚════════════════════════════════════════════════════════════╝"
|
|
echo ""
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
PASSED=0
|
|
FAILED=0
|
|
|
|
# Function to check service
|
|
check_service() {
|
|
local name=$1
|
|
local url=$2
|
|
|
|
if curl -s "$url" > /dev/null 2>&1; then
|
|
echo -e "${GREEN}✓${NC} $name"
|
|
((PASSED++))
|
|
else
|
|
echo -e "${RED}✗${NC} $name"
|
|
((FAILED++))
|
|
fi
|
|
}
|
|
|
|
# Function to check docker container
|
|
check_container() {
|
|
local name=$1
|
|
|
|
if docker compose ps | grep -q "$name.*healthy"; then
|
|
echo -e "${GREEN}✓${NC} $name - HEALTHY"
|
|
((PASSED++))
|
|
else
|
|
echo -e "${RED}✗${NC} $name - NOT HEALTHY"
|
|
((FAILED++))
|
|
fi
|
|
}
|
|
|
|
echo "🐳 DOCKER CONTAINERS"
|
|
echo "────────────────────────────────────────────────────────────"
|
|
check_container "backend"
|
|
check_container "frontend"
|
|
check_container "mariadb"
|
|
check_container "bootnode"
|
|
check_container "validator_1"
|
|
check_container "validator_2"
|
|
check_container "validator_3"
|
|
check_container "adminer"
|
|
|
|
echo ""
|
|
echo "🔌 API ENDPOINTS"
|
|
echo "────────────────────────────────────────────────────────────"
|
|
check_service "Backend Health" "http://localhost:8000/health"
|
|
check_service "Frontend" "http://localhost:3000"
|
|
check_service "Elections (Active)" "http://localhost:8000/api/elections/active"
|
|
check_service "Elections (Upcoming)" "http://localhost:8000/api/elections/upcoming"
|
|
check_service "Elections (Completed)" "http://localhost:8000/api/elections/completed"
|
|
|
|
echo ""
|
|
echo "📊 SUMMARY"
|
|
echo "────────────────────────────────────────────────────────────"
|
|
TOTAL=$((PASSED + FAILED))
|
|
echo "Tests Passed: ${GREEN}$PASSED${NC}/$TOTAL"
|
|
|
|
if [ $FAILED -eq 0 ]; then
|
|
echo -e "${GREEN}✓ All systems operational${NC}"
|
|
echo ""
|
|
echo "🚀 Ready for testing!"
|
|
echo " Frontend: http://localhost:3000"
|
|
echo " API Docs: http://localhost:8000/docs"
|
|
exit 0
|
|
else
|
|
echo -e "${RED}✗ $FAILED system(s) not responding${NC}"
|
|
echo ""
|
|
echo "⚠️ Please check Docker status:"
|
|
docker compose ps
|
|
exit 1
|
|
fi
|