anderson-ufrj
commited on
Commit
·
b026c73
1
Parent(s):
7f22630
test: add quick connectivity verification test
Browse files- test_quick_connectivity.py +62 -0
test_quick_connectivity.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
⚡ Teste Rápido de Conectividade
|
| 4 |
+
Verifica rapidamente se os serviços estão online
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import asyncio
|
| 8 |
+
import httpx
|
| 9 |
+
|
| 10 |
+
# URLs dos serviços
|
| 11 |
+
BACKEND_URL = "https://neural-thinker-cidadao-ai-backend.hf.space"
|
| 12 |
+
MODELS_URL = "https://neural-thinker-cidadao-ai-models.hf.space"
|
| 13 |
+
|
| 14 |
+
async def quick_test():
|
| 15 |
+
"""🚀 Teste rápido de conectividade"""
|
| 16 |
+
print("⚡ TESTE RÁPIDO DE CONECTIVIDADE")
|
| 17 |
+
print("=" * 50)
|
| 18 |
+
|
| 19 |
+
async with httpx.AsyncClient(timeout=15.0) as client:
|
| 20 |
+
|
| 21 |
+
# Test Backend
|
| 22 |
+
print(f"🔍 Testando Backend: {BACKEND_URL}")
|
| 23 |
+
try:
|
| 24 |
+
response = await client.get(f"{BACKEND_URL}")
|
| 25 |
+
if response.status_code == 200:
|
| 26 |
+
data = response.json()
|
| 27 |
+
print(f" ✅ Backend ONLINE - {data.get('status', 'N/A')}")
|
| 28 |
+
print(f" 🤖 Agentes: {list(data.get('agents', {}).keys())}")
|
| 29 |
+
else:
|
| 30 |
+
print(f" ❌ Backend retornou: {response.status_code}")
|
| 31 |
+
except Exception as e:
|
| 32 |
+
print(f" ❌ Backend OFFLINE: {str(e)}")
|
| 33 |
+
|
| 34 |
+
# Test Models
|
| 35 |
+
print(f"🤖 Testando Models: {MODELS_URL}")
|
| 36 |
+
try:
|
| 37 |
+
response = await client.get(f"{MODELS_URL}/")
|
| 38 |
+
if response.status_code == 200:
|
| 39 |
+
data = response.json()
|
| 40 |
+
print(f" ✅ Models ONLINE - {data.get('api', 'N/A')}")
|
| 41 |
+
else:
|
| 42 |
+
print(f" ❌ Models retornou: {response.status_code}")
|
| 43 |
+
except Exception as e:
|
| 44 |
+
print(f" ❌ Models OFFLINE: {str(e)}")
|
| 45 |
+
|
| 46 |
+
# Test Backend → Models integration (via backend status)
|
| 47 |
+
print(f"🔄 Testando Integração via Backend Status:")
|
| 48 |
+
try:
|
| 49 |
+
response = await client.get(f"{BACKEND_URL}/api/status")
|
| 50 |
+
if response.status_code == 200:
|
| 51 |
+
data = response.json()
|
| 52 |
+
cache_info = data.get('performance', {}).get('cache', {})
|
| 53 |
+
print(f" ✅ Backend Status OK")
|
| 54 |
+
print(f" 📊 Cache: {cache_info.get('total_entries', 0)} entries")
|
| 55 |
+
print(f" 🎯 API Version: {data.get('version', 'N/A')}")
|
| 56 |
+
else:
|
| 57 |
+
print(f" ❌ Backend Status: {response.status_code}")
|
| 58 |
+
except Exception as e:
|
| 59 |
+
print(f" ❌ Backend Status Error: {str(e)}")
|
| 60 |
+
|
| 61 |
+
if __name__ == "__main__":
|
| 62 |
+
asyncio.run(quick_test())
|