-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_local.py
More file actions
93 lines (77 loc) · 3.08 KB
/
Copy pathtest_local.py
File metadata and controls
93 lines (77 loc) · 3.08 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
#!/usr/bin/env python3
# Copyright (c) 2024-2026 Alain Prasquier - Supervaize.com. All rights reserved.
#
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, you can obtain one at
# https://mozilla.org/MPL/2.0/.
# Copyright (c) 2024-2026 Alain Prasquier - Supervaize.com. All rights reserved.
#
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, you can obtain one at
# https://mozilla.org/MPL/2.0/.
"""
Local Docker Testing Script
This script demonstrates how to test Supervaizer deployments locally using Docker.
"""
import subprocess
import sys
from pathlib import Path
def main() -> None:
"""Run local Docker tests."""
print("🐳 Supervaizer Local Docker Testing")
print("=" * 50)
# Check if we're in a Supervaizer project
if not Path("supervaizer_control.py").exists():
print("❌ Error: supervaizer_control.py not found")
print(" Please run this script from a Supervaizer project directory")
sys.exit(1)
# Check if Docker is available
try:
subprocess.run(["docker", "--version"], check=True, capture_output=True)
print("✅ Docker is available")
except (subprocess.CalledProcessError, FileNotFoundError):
print("❌ Error: Docker is not available")
print(" Please install Docker and ensure it's running")
sys.exit(1)
# Check if docker-compose is available
try:
subprocess.run(["docker-compose", "--version"], check=True, capture_output=True)
print("✅ Docker Compose is available")
except (subprocess.CalledProcessError, FileNotFoundError):
print("❌ Error: Docker Compose is not available")
print(" Please install Docker Compose")
sys.exit(1)
print("\n🚀 Starting local test...")
# Run the test command
try:
cmd = [
sys.executable,
"-m",
"supervaizer",
"deploy",
"local",
"--port",
"8000",
"--generate-api-key",
"--verbose",
]
print(f"Running: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
print("\n✅ Local test completed successfully!")
print("\n📋 Next steps:")
print(" • Visit http://localhost:8000/docs for API documentation")
print(" • Visit http://localhost:8000/.well-known/health for health check")
print(
" • Run 'docker-compose -f .deployment/docker-compose.yml down' to stop"
)
except subprocess.CalledProcessError as e:
print(f"\n❌ Test failed with exit code {e.returncode}")
print("\n🔍 Troubleshooting:")
print(
" • Check Docker logs: docker-compose -f .deployment/docker-compose.yml logs"
)
print(" • Ensure port 8000 is not in use")
print(" • Verify supervaizer_control.py is properly configured")
sys.exit(1)
if __name__ == "__main__":
main()