Files

77 lines
2.7 KiB
Python

import requests
import sys
import time
FRONTEND_URL = "http://localhost:8881"
BACKEND_URL = "http://localhost:5052"
def test_backend_direct():
print(f"Testing Backend Direct at {BACKEND_URL}...")
try:
# Trying a likely endpoint, or just root which might 404 but proves connectivity
resp = requests.get(f"{BACKEND_URL}/api/agents", timeout=5)
print(f"Backend Direct Status Code: {resp.status_code}")
if resp.status_code in [200, 401, 403, 404]:
print("✅ Backend is running and reachable directly.")
return True
else:
print(f"⚠️ Unexpected status code from Backend: {resp.status_code}")
return True
except Exception as e:
print(f"❌ Backend connection failed: {e}")
return False
def test_frontend_serve():
print(f"Testing Frontend Serve at {FRONTEND_URL}...")
try:
resp = requests.get(FRONTEND_URL, timeout=5)
print(f"Frontend Status Code: {resp.status_code}")
if resp.status_code == 200 and "<html" in resp.text.lower():
print("✅ Frontend is serving HTML.")
return True
else:
print(f"❌ Frontend check failed. Content snippet: {resp.text[:100]}")
return False
except Exception as e:
print(f"❌ Frontend connection failed: {e}")
return False
def test_frontend_proxy():
# Vite proxy: /api -> http://127.0.0.1:5052
url = f"{FRONTEND_URL}/api/agents"
print(f"Testing Frontend Proxy at {url}...")
try:
resp = requests.get(url, timeout=5)
print(f"Proxy Status Code: {resp.status_code}")
if resp.status_code in [200, 401, 403, 404]:
print("✅ Frontend Proxy to Backend is working.")
return True
elif resp.status_code == 502:
print("❌ Frontend Proxy 502 - Backend might be unreachable via Proxy.")
return False
elif resp.status_code == 504: # Gateway Timeout
print("❌ Frontend Proxy 504 - Backend timed out.")
return False
else:
print(f"⚠️ Unexpected status code: {resp.status_code}")
return True
except Exception as e:
print(f"❌ Frontend Proxy connection failed: {e}")
return False
if __name__ == "__main__":
print("Waiting 5 seconds for services to settle...")
time.sleep(5)
success = True
if not test_backend_direct(): success = False
if not test_frontend_serve(): success = False
if not test_frontend_proxy(): success = False
if success:
print("\n🎉 Local Verification PASSED!")
sys.exit(0)
else:
print("\n💥 Local Verification FAILED.")
sys.exit(1)