- 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>
227 lines
7.9 KiB
Python
Executable File
227 lines
7.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Test de Lancement Rapide - RPA Vision V3
|
|
Auteur : Dom, Alice, Kiro - 8 janvier 2026
|
|
|
|
Ce script teste le lancement rapide des services principaux.
|
|
"""
|
|
|
|
import subprocess
|
|
import time
|
|
import requests
|
|
import signal
|
|
import os
|
|
from typing import List, Dict
|
|
|
|
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 print_header():
|
|
print(f"{Colors.PURPLE}{Colors.BOLD}")
|
|
print("╔════════════════════════════════════════════════════════════╗")
|
|
print("║ 🚀 Test de Lancement Rapide - RPA Vision V3 ║")
|
|
print("║ Vérification des services principaux ║")
|
|
print("╚════════════════════════════════════════════════════════════╝")
|
|
print(f"{Colors.NC}")
|
|
|
|
def test_service_startup(service_name: str, port: int, timeout: int = 30) -> bool:
|
|
"""Teste si un service démarre correctement sur un port donné"""
|
|
print(f"{Colors.CYAN}🔍 Test de {service_name} sur le port {port}...{Colors.NC}")
|
|
|
|
start_time = time.time()
|
|
while time.time() - start_time < timeout:
|
|
try:
|
|
response = requests.get(f"http://localhost:{port}", timeout=2)
|
|
if response.status_code in [200, 404]: # 404 est OK pour certains services
|
|
print(f"{Colors.GREEN}✓ {service_name} répond sur le port {port}{Colors.NC}")
|
|
return True
|
|
except requests.exceptions.RequestException:
|
|
pass
|
|
time.sleep(1)
|
|
|
|
print(f"{Colors.RED}✗ {service_name} ne répond pas sur le port {port} après {timeout}s{Colors.NC}")
|
|
return False
|
|
|
|
def test_visual_workflow_builder():
|
|
"""Test spécifique du Visual Workflow Builder"""
|
|
print(f"\n{Colors.BLUE}[1/3] Test du Visual Workflow Builder{Colors.NC}")
|
|
print("=" * 50)
|
|
|
|
# Changer vers le répertoire VWB
|
|
original_dir = os.getcwd()
|
|
vwb_dir = os.path.join(original_dir, "visual_workflow_builder")
|
|
|
|
if not os.path.exists(vwb_dir):
|
|
print(f"{Colors.RED}✗ Répertoire VWB non trouvé{Colors.NC}")
|
|
return False
|
|
|
|
try:
|
|
os.chdir(vwb_dir)
|
|
|
|
# Lancer le script start_full.sh en arrière-plan
|
|
print(f"{Colors.CYAN}🚀 Lancement du VWB...{Colors.NC}")
|
|
process = subprocess.Popen(
|
|
["./start_full.sh"],
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
preexec_fn=os.setsid
|
|
)
|
|
|
|
# Attendre un peu pour le démarrage
|
|
time.sleep(10)
|
|
|
|
# Tester les services
|
|
backend_ok = test_service_startup("VWB Backend", 5002, 20)
|
|
frontend_ok = test_service_startup("VWB Frontend", 3000, 30)
|
|
|
|
# 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)
|
|
|
|
if backend_ok and frontend_ok:
|
|
print(f"{Colors.GREEN}✓ Visual Workflow Builder fonctionne correctement{Colors.NC}")
|
|
return True
|
|
else:
|
|
print(f"{Colors.YELLOW}⚠ Visual Workflow Builder partiellement fonctionnel{Colors.NC}")
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"{Colors.RED}✗ Erreur lors du test VWB : {e}{Colors.NC}")
|
|
os.chdir(original_dir)
|
|
return False
|
|
|
|
def test_main_services():
|
|
"""Test des services principaux"""
|
|
print(f"\n{Colors.BLUE}[2/3] Test des Services Principaux{Colors.NC}")
|
|
print("=" * 50)
|
|
|
|
try:
|
|
# Lancer les services principaux
|
|
print(f"{Colors.CYAN}🚀 Lancement des services principaux...{Colors.NC}")
|
|
process = subprocess.Popen(
|
|
["./run.sh", "--all"],
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
preexec_fn=os.setsid
|
|
)
|
|
|
|
# Attendre le démarrage
|
|
time.sleep(15)
|
|
|
|
# Tester les services
|
|
api_ok = test_service_startup("API REST", 8000, 20)
|
|
dashboard_ok = test_service_startup("Dashboard", 5001, 20)
|
|
|
|
# Arrêter les services
|
|
try:
|
|
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
|
|
process.wait(timeout=5)
|
|
except:
|
|
os.killpg(os.getpgid(process.pid), signal.SIGKILL)
|
|
|
|
if api_ok and dashboard_ok:
|
|
print(f"{Colors.GREEN}✓ Services principaux fonctionnent correctement{Colors.NC}")
|
|
return True
|
|
else:
|
|
print(f"{Colors.YELLOW}⚠ Services principaux partiellement fonctionnels{Colors.NC}")
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"{Colors.RED}✗ Erreur lors du test des services principaux : {e}{Colors.NC}")
|
|
return False
|
|
|
|
def test_environment_readiness():
|
|
"""Test de l'état de préparation de l'environnement"""
|
|
print(f"\n{Colors.BLUE}[3/3] Test de Préparation de l'Environnement{Colors.NC}")
|
|
print("=" * 50)
|
|
|
|
try:
|
|
# Test de l'environnement
|
|
result = subprocess.run(
|
|
["./run.sh", "--check"],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=30
|
|
)
|
|
|
|
if result.returncode == 0:
|
|
print(f"{Colors.GREEN}✓ Environnement prêt{Colors.NC}")
|
|
return True
|
|
else:
|
|
print(f"{Colors.YELLOW}⚠ Environnement avec avertissements{Colors.NC}")
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"{Colors.RED}✗ Erreur lors du test d'environnement : {e}{Colors.NC}")
|
|
return False
|
|
|
|
def cleanup_processes():
|
|
"""Nettoie tous les processus qui pourraient traîner"""
|
|
print(f"{Colors.YELLOW}🧹 Nettoyage des processus...{Colors.NC}")
|
|
|
|
# Tuer les processus sur les ports connus
|
|
ports = [3000, 5001, 5002, 8000]
|
|
for port in ports:
|
|
try:
|
|
subprocess.run(f"lsof -ti:{port} | xargs -r kill -9",
|
|
shell=True, capture_output=True)
|
|
except:
|
|
pass
|
|
|
|
print(f"{Colors.GREEN}✓ Nettoyage terminé{Colors.NC}")
|
|
|
|
def main():
|
|
"""Fonction principale"""
|
|
print_header()
|
|
|
|
# Nettoyer d'abord
|
|
cleanup_processes()
|
|
|
|
# Exécuter les tests
|
|
results = {}
|
|
results["Visual Workflow Builder"] = test_visual_workflow_builder()
|
|
results["Services Principaux"] = test_main_services()
|
|
results["Environnement"] = test_environment_readiness()
|
|
|
|
# Nettoyer à la fin
|
|
cleanup_processes()
|
|
|
|
# Rapport final
|
|
print(f"\n{Colors.PURPLE}{Colors.BOLD}📊 RAPPORT DE TEST DE LANCEMENT{Colors.NC}")
|
|
print("=" * 60)
|
|
|
|
total_tests = len(results)
|
|
passed_tests = sum(results.values())
|
|
|
|
for test_name, result in results.items():
|
|
status = f"{Colors.GREEN}✓ RÉUSSI{Colors.NC}" if result else f"{Colors.RED}✗ ÉCHEC{Colors.NC}"
|
|
print(f" {test_name:<30} {status}")
|
|
|
|
success_rate = (passed_tests / total_tests) * 100
|
|
print(f"\nTaux de réussite : {success_rate:.1f}%")
|
|
|
|
if success_rate >= 80:
|
|
print(f"\n{Colors.GREEN}{Colors.BOLD}🎉 SYSTÈME PRÊT POUR UTILISATION !{Colors.NC}")
|
|
print(f"\n{Colors.CYAN}Pour lancer le système complet :{Colors.NC}")
|
|
print(f" ./run.sh --full")
|
|
print(f"\n{Colors.CYAN}Pour lancer seulement le VWB :{Colors.NC}")
|
|
print(f" cd visual_workflow_builder && ./start_full.sh")
|
|
else:
|
|
print(f"\n{Colors.YELLOW}{Colors.BOLD}⚠ SYSTÈME NÉCESSITE DES AJUSTEMENTS{Colors.NC}")
|
|
print(f"Vérifiez les logs et les dépendances.")
|
|
|
|
if __name__ == "__main__":
|
|
main() |