Spaces:
Running
Running
bigwolfe
commited on
Commit
·
468eaec
1
Parent(s):
5806c2c
Remove debug script from integration tests directory
Browse files
backend/tests/integration/debug_endpoints.py
DELETED
|
@@ -1,169 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""Debug script to check which endpoints are working."""
|
| 3 |
-
|
| 4 |
-
import requests
|
| 5 |
-
import json
|
| 6 |
-
from urllib.parse import urljoin
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
def test_endpoint(url, method="GET", headers=None, data=None, timeout=5):
|
| 10 |
-
"""Test a single endpoint and return detailed results."""
|
| 11 |
-
try:
|
| 12 |
-
if method.upper() == "GET":
|
| 13 |
-
response = requests.get(url, headers=headers, timeout=timeout)
|
| 14 |
-
elif method.upper() == "POST":
|
| 15 |
-
response = requests.post(url, headers=headers, json=data, timeout=timeout)
|
| 16 |
-
|
| 17 |
-
return {
|
| 18 |
-
"status": "SUCCESS",
|
| 19 |
-
"status_code": response.status_code,
|
| 20 |
-
"response": response.text[:500], # Limit response length
|
| 21 |
-
"headers": dict(response.headers),
|
| 22 |
-
}
|
| 23 |
-
except requests.exceptions.ConnectionError:
|
| 24 |
-
return {"status": "CONNECTION_ERROR", "error": "Cannot connect to server"}
|
| 25 |
-
except requests.exceptions.Timeout:
|
| 26 |
-
return {"status": "TIMEOUT", "error": "Request timed out"}
|
| 27 |
-
except Exception as e:
|
| 28 |
-
return {"status": "ERROR", "error": str(e)}
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
def check_all_endpoints():
|
| 32 |
-
"""Check all possible endpoints systematically."""
|
| 33 |
-
|
| 34 |
-
print("🔍 Debugging Endpoint Availability")
|
| 35 |
-
print("=" * 60)
|
| 36 |
-
|
| 37 |
-
# Define test cases
|
| 38 |
-
test_cases = [
|
| 39 |
-
# FastAPI Server (Port 8000)
|
| 40 |
-
{
|
| 41 |
-
"name": "FastAPI Health",
|
| 42 |
-
"url": "http://localhost:8000/health",
|
| 43 |
-
"method": "GET",
|
| 44 |
-
},
|
| 45 |
-
{"name": "FastAPI Root", "url": "http://localhost:8000/", "method": "GET"},
|
| 46 |
-
{
|
| 47 |
-
"name": "FastAPI API Root",
|
| 48 |
-
"url": "http://localhost:8000/api/",
|
| 49 |
-
"method": "GET",
|
| 50 |
-
},
|
| 51 |
-
# MCP Server (Port 8001)
|
| 52 |
-
{"name": "MCP Root", "url": "http://localhost:8001/", "method": "GET"},
|
| 53 |
-
{"name": "MCP Endpoint", "url": "http://localhost:8001/mcp", "method": "GET"},
|
| 54 |
-
{
|
| 55 |
-
"name": "MCP Health (if exists)",
|
| 56 |
-
"url": "http://localhost:8001/health",
|
| 57 |
-
"method": "GET",
|
| 58 |
-
},
|
| 59 |
-
# MCP Protocol Tests
|
| 60 |
-
{
|
| 61 |
-
"name": "MCP Initialize",
|
| 62 |
-
"url": "http://localhost:8001/mcp",
|
| 63 |
-
"method": "POST",
|
| 64 |
-
"headers": {
|
| 65 |
-
"Authorization": "Bearer local-dev-token",
|
| 66 |
-
"Content-Type": "application/json",
|
| 67 |
-
"Accept": "application/json, text/event-stream",
|
| 68 |
-
},
|
| 69 |
-
"data": {
|
| 70 |
-
"jsonrpc": "2.0",
|
| 71 |
-
"id": 1,
|
| 72 |
-
"method": "initialize",
|
| 73 |
-
"params": {
|
| 74 |
-
"protocolVersion": "2024-11-05",
|
| 75 |
-
"capabilities": {},
|
| 76 |
-
"clientInfo": {"name": "debug-client", "version": "1.0.0"},
|
| 77 |
-
},
|
| 78 |
-
},
|
| 79 |
-
},
|
| 80 |
-
{
|
| 81 |
-
"name": "MCP Tools List",
|
| 82 |
-
"url": "http://localhost:8001/mcp",
|
| 83 |
-
"method": "POST",
|
| 84 |
-
"headers": {
|
| 85 |
-
"Authorization": "Bearer local-dev-token",
|
| 86 |
-
"Content-Type": "application/json",
|
| 87 |
-
"Accept": "application/json, text/event-stream",
|
| 88 |
-
},
|
| 89 |
-
"data": {"jsonrpc": "2.0", "id": 2, "method": "tools/list"},
|
| 90 |
-
},
|
| 91 |
-
]
|
| 92 |
-
|
| 93 |
-
results = {}
|
| 94 |
-
|
| 95 |
-
for test in test_cases:
|
| 96 |
-
print(f"\n🧪 Testing: {test['name']}")
|
| 97 |
-
print(f" URL: {test['url']}")
|
| 98 |
-
print(f" Method: {test['method']}")
|
| 99 |
-
|
| 100 |
-
result = test_endpoint(
|
| 101 |
-
url=test["url"],
|
| 102 |
-
method=test["method"],
|
| 103 |
-
headers=test.get("headers"),
|
| 104 |
-
data=test.get("data"),
|
| 105 |
-
)
|
| 106 |
-
|
| 107 |
-
results[test["name"]] = result
|
| 108 |
-
|
| 109 |
-
if result["status"] == "SUCCESS":
|
| 110 |
-
print(f" ✅ Status: {result['status_code']}")
|
| 111 |
-
if result["response"]:
|
| 112 |
-
# Try to pretty print JSON
|
| 113 |
-
try:
|
| 114 |
-
json_resp = json.loads(result["response"])
|
| 115 |
-
print(f" 📄 Response: {json.dumps(json_resp, indent=2)[:200]}...")
|
| 116 |
-
except:
|
| 117 |
-
print(f" 📄 Response: {result['response'][:100]}...")
|
| 118 |
-
else:
|
| 119 |
-
print(f" ❌ {result['status']}: {result.get('error', 'Unknown error')}")
|
| 120 |
-
|
| 121 |
-
print("\n" + "=" * 60)
|
| 122 |
-
print("📊 SUMMARY")
|
| 123 |
-
print("=" * 60)
|
| 124 |
-
|
| 125 |
-
working = []
|
| 126 |
-
not_working = []
|
| 127 |
-
|
| 128 |
-
for name, result in results.items():
|
| 129 |
-
if result["status"] == "SUCCESS" and result.get("status_code", 0) < 400:
|
| 130 |
-
working.append(name)
|
| 131 |
-
else:
|
| 132 |
-
not_working.append(name)
|
| 133 |
-
|
| 134 |
-
print(f"\n✅ WORKING ({len(working)}):")
|
| 135 |
-
for name in working:
|
| 136 |
-
status_code = results[name].get("status_code", "N/A")
|
| 137 |
-
print(f" - {name} (HTTP {status_code})")
|
| 138 |
-
|
| 139 |
-
print(f"\n❌ NOT WORKING ({len(not_working)}):")
|
| 140 |
-
for name in not_working:
|
| 141 |
-
result = results[name]
|
| 142 |
-
if result["status"] == "SUCCESS":
|
| 143 |
-
print(f" - {name} (HTTP {result.get('status_code', 'N/A')})")
|
| 144 |
-
else:
|
| 145 |
-
print(f" - {name} ({result['status']})")
|
| 146 |
-
|
| 147 |
-
print(f"\n🔧 RECOMMENDATIONS:")
|
| 148 |
-
|
| 149 |
-
# Check if any server is running
|
| 150 |
-
fastapi_working = any("FastAPI" in name for name in working)
|
| 151 |
-
mcp_working = any("MCP" in name for name in working)
|
| 152 |
-
|
| 153 |
-
if not fastapi_working:
|
| 154 |
-
print(" - Start FastAPI server: cd backend && python main.py")
|
| 155 |
-
|
| 156 |
-
if not mcp_working:
|
| 157 |
-
print(
|
| 158 |
-
" - Start MCP server: cd backend && MCP_TRANSPORT=http MCP_PORT=8001 python -m src.mcp.server"
|
| 159 |
-
)
|
| 160 |
-
|
| 161 |
-
if not working:
|
| 162 |
-
print(" - Check if any servers are running: netstat -ano | findstr :8000")
|
| 163 |
-
print(" - Check if any servers are running: netstat -ano | findstr :8001")
|
| 164 |
-
|
| 165 |
-
return results
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
if __name__ == "__main__":
|
| 169 |
-
check_all_endpoints()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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