diff --git a/tests_e2e/test_kubernetes.py b/tests_e2e/test_kubernetes.py index 663ce70..7eb95fb 100644 --- a/tests_e2e/test_kubernetes.py +++ b/tests_e2e/test_kubernetes.py @@ -860,10 +860,9 @@ def wait_for_easyhaproxy_discovery(kubectl_cmd: str, expected_host: str, timeout time.sleep(1) - # Step 4: Simple connectivity check to HAProxy - print(f" → Testing connectivity to HAProxy...") - retries = 3 - for attempt in range(retries): + # Step 4: Poll until the backend returns 200 (not just any response) + print(f" → Waiting for backend to return 200...") + while time.time() - start_time < timeout: try: result = subprocess.run( ["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}", @@ -873,17 +872,15 @@ def wait_for_easyhaproxy_discovery(kubectl_cmd: str, expected_host: str, timeout timeout=5 ) http_code = result.stdout.strip() - # Accept 200, 503 (backend may not be ready yet), or any response that proves HAProxy is responding - if http_code and http_code != "000": - print(f" ✓ HAProxy is responding (HTTP {http_code})") - # Give HAProxy a moment to stabilize after configuration reload - time.sleep(2) + if http_code == "200": + print(f" ✓ Backend is ready (HTTP 200)") return True + if http_code and http_code != "000": + print(f" … Backend not ready yet (HTTP {http_code}), retrying...") except Exception: pass - if attempt < retries - 1: - time.sleep(1) + time.sleep(1) # Check if we timed out if time.time() - start_time >= timeout: diff --git a/tests_e2e/test_swarm.py b/tests_e2e/test_swarm.py index 3f18c34..0d85d90 100644 --- a/tests_e2e/test_swarm.py +++ b/tests_e2e/test_swarm.py @@ -521,12 +521,6 @@ class TestSwarmBasicServices: assert response.status_code == 301 assert response.headers.get("location") == "https://host2.local/" - def test_haproxy_stats(self, swarm_basic_services): - """Test HAProxy stats interface is accessible.""" - from conftest import verify_haproxy_stats - verify_haproxy_stats() - - # ============================================================================= # Tests: plugins-combined.yml - Multiple Security Plugins in Swarm # ============================================================================= @@ -631,8 +625,3 @@ class TestSwarmPluginsCombined: assert response.status_code == 200, \ (f"Expected admin access from Docker ingress IP (in 10.0.0.0/8), " f"got {response.status_code}") - - def test_haproxy_stats(self, swarm_plugins_combined): - """Test HAProxy stats interface is accessible.""" - from conftest import verify_haproxy_stats - verify_haproxy_stats() \ No newline at end of file