53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
import requests
|
|
import sys
|
|
|
|
BASE_URL = "http://192.168.100.230:8890"
|
|
|
|
def test_frontend():
|
|
print(f"Testing Frontend at {BASE_URL}...")
|
|
try:
|
|
resp = requests.get(BASE_URL, timeout=5)
|
|
print(f"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_backend_proxy():
|
|
# Attempt to hit an API endpoint. Even 401/403 is good because it means Nginx proxied to Flask.
|
|
# If Nginx fails to proxy, it might return 502 Bad Gateway.
|
|
url = f"{BASE_URL}/api/agents"
|
|
print(f"Testing Backend Proxy at {url}...")
|
|
try:
|
|
resp = requests.get(url, timeout=5)
|
|
print(f"Status Code: {resp.status_code}")
|
|
if resp.status_code in [200, 401, 403, 404]: # 404 might come from Flask if path wrong, but 502 is bad.
|
|
print("✅ Backend is reachable via Nginx proxy.")
|
|
return True
|
|
elif resp.status_code == 502:
|
|
print("❌ Nginx 502 Bad Gateway - Backend container might be down or unreachable.")
|
|
return False
|
|
else:
|
|
print(f"⚠️ Unexpected status code: {resp.status_code}")
|
|
return True # Still technically reachable
|
|
except Exception as e:
|
|
print(f"❌ Backend connection failed: {e}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
success = True
|
|
if not test_frontend(): success = False
|
|
if not test_backend_proxy(): success = False
|
|
|
|
if success:
|
|
print("\n🎉 Deployment Verification PASSED!")
|
|
sys.exit(0)
|
|
else:
|
|
print("\n💥 Deployment Verification FAILED.")
|
|
sys.exit(1)
|