- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
138 lines
5.2 KiB
Python
Executable File
138 lines
5.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Test de Démarrage Backend VWB
|
|
Auteur : Dom, Alice, Kiro - 8 janvier 2026
|
|
|
|
Ce script teste le démarrage du backend VWB.
|
|
"""
|
|
|
|
import subprocess
|
|
import time
|
|
import requests
|
|
import signal
|
|
import os
|
|
from typing import Optional
|
|
|
|
class Colors:
|
|
RED = '\033[0;31m'
|
|
GREEN = '\033[0;32m'
|
|
YELLOW = '\033[1;33m'
|
|
BLUE = '\033[0;34m'
|
|
PURPLE = '\033[0;35m'
|
|
CYAN = '\033[0;36m'
|
|
BOLD = '\033[1m'
|
|
NC = '\033[0m'
|
|
|
|
def test_backend_startup(timeout: int = 30) -> bool:
|
|
"""Teste le démarrage du backend VWB"""
|
|
print(f"{Colors.CYAN}🚀 Test de démarrage du backend VWB...{Colors.NC}")
|
|
|
|
# Changer vers le répertoire VWB
|
|
original_dir = os.getcwd()
|
|
vwb_dir = os.path.join(original_dir, "visual_workflow_builder")
|
|
backend_dir = os.path.join(vwb_dir, "backend")
|
|
|
|
if not os.path.exists(backend_dir):
|
|
print(f"{Colors.RED}❌ Répertoire backend non trouvé: {backend_dir}{Colors.NC}")
|
|
return False
|
|
|
|
try:
|
|
os.chdir(backend_dir)
|
|
|
|
# Activer l'environnement virtuel et lancer le backend
|
|
cmd = [
|
|
"bash", "-c",
|
|
"source ../../venv_v3/bin/activate && python3 app.py"
|
|
]
|
|
|
|
print(f"{Colors.YELLOW}⏳ Démarrage du backend (timeout: {timeout}s)...{Colors.NC}")
|
|
|
|
process = subprocess.Popen(
|
|
cmd,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
preexec_fn=os.setsid
|
|
)
|
|
|
|
# Attendre que le backend soit prêt
|
|
start_time = time.time()
|
|
backend_ready = False
|
|
|
|
while time.time() - start_time < timeout:
|
|
try:
|
|
# Tester l'endpoint de santé
|
|
response = requests.get("http://localhost:5002/health", timeout=2)
|
|
if response.status_code == 200:
|
|
print(f"{Colors.GREEN}✅ Backend prêt sur http://localhost:5002{Colors.NC}")
|
|
backend_ready = True
|
|
break
|
|
except requests.exceptions.RequestException:
|
|
pass
|
|
|
|
# Vérifier si le processus est encore en vie
|
|
if process.poll() is not None:
|
|
stdout, stderr = process.communicate()
|
|
print(f"{Colors.RED}❌ Le processus backend s'est arrêté{Colors.NC}")
|
|
print(f"STDOUT: {stdout.decode()}")
|
|
print(f"STDERR: {stderr.decode()}")
|
|
return False
|
|
|
|
time.sleep(1)
|
|
|
|
# Tester quelques endpoints
|
|
if backend_ready:
|
|
endpoints_to_test = [
|
|
("/health", "Health Check"),
|
|
("/api/workflows", "Workflows API"),
|
|
("/api/node-types", "Node Types API")
|
|
]
|
|
|
|
for endpoint, description in endpoints_to_test:
|
|
try:
|
|
response = requests.get(f"http://localhost:5002{endpoint}", timeout=5)
|
|
if response.status_code in [200, 404, 405]: # 404/405 sont OK pour certains endpoints
|
|
print(f"{Colors.GREEN}✅ {description}: {endpoint} (status: {response.status_code}){Colors.NC}")
|
|
else:
|
|
print(f"{Colors.YELLOW}⚠️ {description}: {endpoint} (status: {response.status_code}){Colors.NC}")
|
|
except Exception as e:
|
|
print(f"{Colors.RED}❌ {description}: {endpoint} - Erreur: {e}{Colors.NC}")
|
|
|
|
# Arrêter le processus
|
|
try:
|
|
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
|
|
process.wait(timeout=5)
|
|
except:
|
|
os.killpg(os.getpgid(process.pid), signal.SIGKILL)
|
|
|
|
os.chdir(original_dir)
|
|
return backend_ready
|
|
|
|
except Exception as e:
|
|
print(f"{Colors.RED}❌ Erreur lors du test de démarrage: {e}{Colors.NC}")
|
|
os.chdir(original_dir)
|
|
return False
|
|
|
|
def main():
|
|
"""Fonction principale"""
|
|
print(f"{Colors.PURPLE}{Colors.BOLD}")
|
|
print("╔════════════════════════════════════════════════════════════╗")
|
|
print("║ 🧪 Test de Démarrage Backend VWB ║")
|
|
print("║ Auteur : Dom, Alice, Kiro - 8 janvier 2026 ║")
|
|
print("╚════════════════════════════════════════════════════════════╝")
|
|
print(f"{Colors.NC}")
|
|
|
|
success = test_backend_startup()
|
|
|
|
if success:
|
|
print(f"\n{Colors.GREEN}{Colors.BOLD}🎉 BACKEND VWB FONCTIONNE CORRECTEMENT !{Colors.NC}")
|
|
print(f"\n{Colors.CYAN}Pour lancer le backend manuellement :{Colors.NC}")
|
|
print(f" cd visual_workflow_builder/backend")
|
|
print(f" source ../../venv_v3/bin/activate")
|
|
print(f" python3 app.py")
|
|
else:
|
|
print(f"\n{Colors.RED}{Colors.BOLD}❌ PROBLÈME AVEC LE BACKEND VWB{Colors.NC}")
|
|
print(f"Vérifiez les logs et les dépendances.")
|
|
|
|
if __name__ == "__main__":
|
|
main() |