From 0ea3aa0a4ec2fa949b3cc68ff0a37e32ae10184d Mon Sep 17 00:00:00 2001 From: Alexis Bruneteau Date: Fri, 7 Nov 2025 18:16:12 +0100 Subject: [PATCH] chore: Add system health check verification script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- e-voting-system/verify_system.sh | 86 ++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 e-voting-system/verify_system.sh diff --git a/e-voting-system/verify_system.sh b/e-voting-system/verify_system.sh new file mode 100755 index 0000000..04991c1 --- /dev/null +++ b/e-voting-system/verify_system.sh @@ -0,0 +1,86 @@ +#!/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