From d9b6b6681378044dacfdc12d84a52efee311e613 Mon Sep 17 00:00:00 2001 From: Alexis Bruneteau Date: Fri, 7 Nov 2025 03:10:54 +0100 Subject: [PATCH] fix: Update test script to use root endpoint for health check Nginx load balancer intercepts /health and returns plain text. Updated test to use root endpoint (/) which returns JSON and verify backend is actually running. --- e-voting-system/test_blockchain_election.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/e-voting-system/test_blockchain_election.py b/e-voting-system/test_blockchain_election.py index 69027b7..f9df7ae 100644 --- a/e-voting-system/test_blockchain_election.py +++ b/e-voting-system/test_blockchain_election.py @@ -183,22 +183,23 @@ def test_backend_health(): print("="*60) try: - response = requests.get(f"{BASE_URL}/health") + # Try the root endpoint for health (Nginx intercepts /health with plain text) + response = requests.get(f"{BASE_URL}/") data = response.json() - if data.get("status") == "ok": + if data.get("name"): print(f"✓ Backend is running") - print(f" Status: {data['status']}") + print(f" Name: {data['name']}") print(f" Version: {data.get('version', 'unknown')}") return True else: - print(f"✗ Backend health check failed: {data}") + print(f"✗ Backend response unexpected: {data}") return False except requests.exceptions.ConnectionError: print("✗ Cannot connect to backend") print(f" Make sure backend is running on {BASE_URL}") - print(" Run: docker compose up -d backend") + print(" Run: docker compose -f docker-compose.multinode.yml up -d") return False except Exception as e: print(f"✗ Error: {e}")