-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_setup.py
More file actions
151 lines (133 loc) · 3.99 KB
/
test_setup.py
File metadata and controls
151 lines (133 loc) · 3.99 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
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python3
"""
Quick test script to verify EdgeLab components work
Run this before docker compose to catch issues early
"""
import sys
import subprocess
import os
def test_docker():
"""Check if Docker is installed and running"""
print("Testing Docker installation...")
try:
result = subprocess.run(['docker', '--version'], capture_output=True, text=True)
if result.returncode == 0:
print(f" ✅ {result.stdout.strip()}")
return True
else:
print(" ❌ Docker not working")
return False
except FileNotFoundError:
print(" ❌ Docker not installed")
return False
def test_docker_compose():
"""Check if docker compose is available"""
print("Testing Docker Compose...")
try:
result = subprocess.run(['docker', 'compose', 'version'], capture_output=True, text=True)
if result.returncode == 0:
print(f" ✅ {result.stdout.strip()}")
return True
else:
print(" ❌ Docker Compose not working")
return False
except:
print(" ❌ Docker Compose not available")
return False
def test_python_version():
"""Check Python version"""
print("Testing Python version...")
version = sys.version_info
if version.major == 3 and version.minor >= 9:
print(f" ✅ Python {version.major}.{version.minor}.{version.micro}")
return True
else:
print(f" ⚠️ Python {version.major}.{version.minor} (recommend 3.9+)")
return True # not critical
def test_assignment_files():
"""Check if assignment JSON files exist"""
print("Testing assignment files...")
required = [
'assignments/python_two_sum.json',
'assignments/sql_top_salaries.json',
'assignments/java_palindrome.json'
]
all_exist = True
for f in required:
if os.path.exists(f):
print(f" ✅ {f}")
else:
print(f" ❌ Missing: {f}")
all_exist = False
return all_exist
def test_python_imports():
"""Check if required Python packages can be imported"""
print("Testing Python dependencies...")
packages = [
('flask', 'Flask'),
('flask_cors', 'Flask-CORS'),
]
all_ok = True
for module, name in packages:
try:
__import__(module)
print(f" ✅ {name}")
except ImportError:
print(f" ⚠️ {name} not installed (will be installed in Docker)")
# Not critical since docker will install
return True
def test_file_structure():
"""Check if required directories and files exist"""
print("Testing file structure...")
required = [
'api/app.py',
'api/database.py',
'api/executor.py',
'ui/streamlit_app.py',
'docker-compose.yml',
'Dockerfile.api',
'Dockerfile.ui'
]
all_exist = True
for f in required:
if os.path.exists(f):
print(f" ✅ {f}")
else:
print(f" ❌ Missing: {f}")
all_exist = False
return all_exist
def main():
print("=" * 50)
print("EdgeLab Pre-Flight Check")
print("=" * 50)
print()
tests = [
test_docker,
test_docker_compose,
test_python_version,
test_file_structure,
test_assignment_files,
test_python_imports
]
results = []
for test in tests:
result = test()
results.append(result)
print()
print("=" * 50)
if all(results):
print("✅ All checks passed!")
print()
print("Ready to launch:")
print(" docker compose up")
print()
return 0
else:
print("⚠️ Some checks failed")
print()
print("Critical issues must be fixed before running.")
print("Warning issues will be handled by Docker.")
print()
return 1
if __name__ == '__main__':
sys.exit(main())