-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_deployment.py
More file actions
executable file
·141 lines (113 loc) · 4.07 KB
/
Copy pathtest_deployment.py
File metadata and controls
executable file
·141 lines (113 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env python3
"""
Test script for The Cognisphere deployment verification.
"""
import requests
import json
import time
import sys
def test_backend(base_url="http://localhost:8000"):
"""Test backend endpoints."""
print(f"Testing backend at {base_url}")
tests = [
("/", "Root endpoint"),
("/healthz", "Health check"),
("/docs", "API documentation"),
("/simulate", "Simulation endpoint"),
("/graph", "Graph data")
]
results = {}
for endpoint, description in tests:
try:
url = f"{base_url}{endpoint}"
response = requests.get(url, timeout=5)
if response.status_code == 200:
print(f"✅ {description}: OK")
results[endpoint] = "OK"
else:
print(f"❌ {description}: HTTP {response.status_code}")
results[endpoint] = f"HTTP {response.status_code}"
except requests.exceptions.RequestException as e:
print(f"❌ {description}: {str(e)}")
results[endpoint] = str(e)
return results
def test_frontend(base_url="http://localhost:5173"):
"""Test frontend accessibility."""
print(f"\nTesting frontend at {base_url}")
try:
response = requests.get(base_url, timeout=5)
if response.status_code == 200:
print("✅ Frontend: OK")
return "OK"
else:
print(f"❌ Frontend: HTTP {response.status_code}")
return f"HTTP {response.status_code}"
except requests.exceptions.RequestException as e:
print(f"❌ Frontend: {str(e)}")
return str(e)
def test_simulation_engine():
"""Test simulation engine functionality."""
print("\nTesting simulation engine...")
try:
# Import simulation components
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), 'backend'))
from simulation.engine import SimulationEngine
from simulation.world import World
from backend.adapters.llm import MockLLMAdapter
# Create a small test simulation
world = World(num_agents=5)
llm_adapter = MockLLMAdapter()
engine = SimulationEngine(world, llm_adapter)
# Run a few ticks
for i in range(3):
engine.advance_tick()
print("✅ Simulation engine: OK")
return "OK"
except Exception as e:
print(f"❌ Simulation engine: {str(e)}")
return str(e)
def main():
"""Run all tests."""
print("The Cognisphere Deployment Test")
print("=" * 40)
# Test local deployment
backend_results = test_backend()
frontend_result = test_frontend()
simulation_result = test_simulation_engine()
# Summary
print("\n" + "=" * 40)
print("DEPLOYMENT TEST SUMMARY")
print("=" * 40)
all_ok = True
print("\nBackend Tests:")
for endpoint, result in backend_results.items():
status = "✅" if result == "OK" else "❌"
print(f" {status} {endpoint}: {result}")
if result != "OK":
all_ok = False
print(f"\nFrontend Test:")
status = "✅" if frontend_result == "OK" else "❌"
print(f" {status} Frontend: {frontend_result}")
if frontend_result != "OK":
all_ok = False
print(f"\nSimulation Test:")
status = "✅" if simulation_result == "OK" else "❌"
print(f" {status} Simulation: {simulation_result}")
if simulation_result != "OK":
all_ok = False
print("\n" + "=" * 40)
if all_ok:
print("🎉 ALL TESTS PASSED!")
print("The Cognisphere is ready for deployment!")
else:
print("⚠️ Some tests failed. Check the errors above.")
print("\nNext Steps:")
print("1. Create GitHub repository")
print("2. Set up Render.com backend")
print("3. Configure GitHub secrets")
print("4. Push to trigger auto-deployment")
return 0 if all_ok else 1
if __name__ == "__main__":
sys.exit(main())