veza/scripts/archive/test-phase-3bis.sh
2025-12-12 21:34:34 -05:00

267 lines
12 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Script de test pour Phase 3bis : Frontend + Stream Server
# Usage: ./scripts/test-phase-3bis.sh
set -e # Exit on error
echo "═══════════════════════════════════════════════════════════"
echo "🧪 PHASE 3BIS - TESTS FRONTEND & STREAM SERVER"
echo "═══════════════════════════════════════════════════════════"
echo ""
# Couleurs pour output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Répertoire du projet
PROJECT_DIR="/home/senke/Documents/veza-full-stack"
cd "$PROJECT_DIR"
echo "📍 Répertoire : $(pwd)"
echo ""
# ============================================================================
# ÉTAPE 1 : REBUILD FRONTEND LOCAL (optionnel, recommandé pour debug)
# ============================================================================
echo "════════════════════════════════════════════════════════════"
echo "ÉTAPE 1 : Rebuild Frontend (local)"
echo "════════════════════════════════════════════════════════════"
read -p "Voulez-vous rebuilder le frontend en local ? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "🔨 Rebuild frontend avec npm..."
chmod +x scripts/rebuild-frontend.sh
./scripts/rebuild-frontend.sh
echo -e "${GREEN}✅ Frontend rebuildé${NC}"
else
echo "⏭️ Skip rebuild local (sera fait dans docker build)"
fi
echo ""
# ============================================================================
# ÉTAPE 2 : ARRÊT COMPLET
# ============================================================================
echo "════════════════════════════════════════════════════════════"
echo "ÉTAPE 2 : Arrêt de tous les conteneurs"
echo "════════════════════════════════════════════════════════════"
docker compose down -v
echo -e "${GREEN}✅ Conteneurs arrêtés${NC}"
echo ""
# ============================================================================
# ÉTAPE 3 : REBUILD DOCKER (SANS CACHE)
# ============================================================================
echo "════════════════════════════════════════════════════════════"
echo "ÉTAPE 3 : Rebuild Docker (frontend + stream-server)"
echo "════════════════════════════════════════════════════════════"
echo "🔨 Build frontend (sans cache)..."
docker compose build --no-cache frontend
echo ""
echo "🔨 Build stream-server (sans cache)..."
docker compose build --no-cache stream-server
echo -e "${GREEN}✅ Images Docker rebuildées${NC}"
echo ""
# ============================================================================
# ÉTAPE 4 : DÉMARRAGE COMPLET
# ============================================================================
echo "════════════════════════════════════════════════════════════"
echo "ÉTAPE 4 : Démarrage de tous les services"
echo "════════════════════════════════════════════════════════════"
docker compose up -d --build
echo -e "${GREEN}✅ Services démarrés${NC}"
echo ""
# ============================================================================
# ÉTAPE 5 : ATTENTE HEALTHCHECK (90 secondes)
# ============================================================================
echo "════════════════════════════════════════════════════════════"
echo "ÉTAPE 5 : Attente healthchecks (90s)"
echo "════════════════════════════════════════════════════════════"
echo "⏳ Attente de 90 secondes pour les healthchecks..."
for i in {90..1}; do
echo -ne "\r⏱ $i secondes restantes... "
sleep 1
done
echo -e "\n"
# ============================================================================
# ÉTAPE 6 : VÉRIFICATION STATUS
# ============================================================================
echo "════════════════════════════════════════════════════════════"
echo "ÉTAPE 6 : Vérification du statut des conteneurs"
echo "════════════════════════════════════════════════════════════"
docker compose ps
echo ""
# Vérifier individuellement chaque service
echo "📊 Vérification individuelle :"
echo ""
# Backend
if docker compose ps backend-api | grep -q "healthy"; then
echo -e " ${GREEN}✅ backend-api : HEALTHY${NC}"
else
echo -e " ${RED}❌ backend-api : NOT HEALTHY${NC}"
fi
# Chat
if docker compose ps chat-server | grep -q "healthy"; then
echo -e " ${GREEN}✅ chat-server : HEALTHY${NC}"
else
echo -e " ${RED}❌ chat-server : NOT HEALTHY${NC}"
fi
# Stream
if docker compose ps stream-server | grep -q "healthy"; then
echo -e " ${GREEN}✅ stream-server : HEALTHY${NC}"
else
echo -e " ${YELLOW}⚠️ stream-server : NOT HEALTHY YET (check logs)${NC}"
fi
# Frontend
if docker compose ps frontend | grep -q "Up"; then
if docker compose ps frontend | grep -q "healthy"; then
echo -e " ${GREEN}✅ frontend : HEALTHY${NC}"
else
echo -e " ${YELLOW}⚠️ frontend : UP but not healthy yet${NC}"
fi
else
echo -e " ${RED}❌ frontend : NOT RUNNING${NC}"
fi
echo ""
# ============================================================================
# ÉTAPE 7 : LOGS DÉTAILLÉS
# ============================================================================
echo "════════════════════════════════════════════════════════════"
echo "ÉTAPE 7 : Logs détaillés (dernières 80 lignes)"
echo "════════════════════════════════════════════════════════════"
echo ""
echo "──────────────────────────────────────────────────────────"
echo "📋 Stream Server Logs"
echo "──────────────────────────────────────────────────────────"
docker logs --tail=80 veza-stream-server-local
echo ""
echo "──────────────────────────────────────────────────────────"
echo "📋 Frontend Logs"
echo "──────────────────────────────────────────────────────────"
docker logs --tail=80 veza-frontend-local
echo ""
# ============================================================================
# ÉTAPE 8 : TESTS CURL
# ============================================================================
echo "════════════════════════════════════════════════════════════"
echo "ÉTAPE 8 : Tests HTTP"
echo "════════════════════════════════════════════════════════════"
echo ""
echo "1⃣ Backend API Health"
if curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/health | grep -q "200"; then
echo -e " ${GREEN}✅ http://localhost:8080/health → 200 OK${NC}"
else
echo -e " ${RED}❌ http://localhost:8080/health → FAILED${NC}"
fi
echo ""
echo "2⃣ Stream Server Health"
STREAM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8082/health)
if [ "$STREAM_STATUS" = "200" ]; then
echo -e " ${GREEN}✅ http://localhost:8082/health → 200 OK${NC}"
echo " 📄 Response:"
curl -s http://localhost:8082/health | jq '.' 2>/dev/null || curl -s http://localhost:8082/health
else
echo -e " ${RED}❌ http://localhost:8082/health → $STREAM_STATUS${NC}"
echo " 🔍 Tentative avec curl -v :"
curl -v http://localhost:8082/health 2>&1 | tail -20
fi
echo ""
echo "3⃣ Frontend Health"
if curl -s -o /dev/null -w "%{http_code}" http://localhost:5176/health | grep -q "200"; then
echo -e " ${GREEN}✅ http://localhost:5176/health → 200 OK${NC}"
else
echo -e " ${RED}❌ http://localhost:5176/health → FAILED${NC}"
fi
echo ""
echo "4⃣ Frontend Homepage"
FRONTEND_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5176/)
if [ "$FRONTEND_STATUS" = "200" ]; then
echo -e " ${GREEN}✅ http://localhost:5176/ → 200 OK${NC}"
echo " 📄 Contenu (premiers 200 chars) :"
curl -s http://localhost:5176/ | head -c 200
echo ""
else
echo -e " ${RED}❌ http://localhost:5176/ → $FRONTEND_STATUS${NC}"
fi
echo ""
echo "5⃣ Frontend Proxy /api"
PROXY_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5176/api/v1/health)
if [ "$PROXY_STATUS" = "200" ]; then
echo -e " ${GREEN}✅ http://localhost:5176/api/v1/health → 200 OK (proxy OK)${NC}"
else
echo -e " ${YELLOW}⚠️ http://localhost:5176/api/v1/health → $PROXY_STATUS${NC}"
fi
echo ""
# ============================================================================
# ÉTAPE 9 : RÉSUMÉ
# ============================================================================
echo "════════════════════════════════════════════════════════════"
echo "📊 RÉSUMÉ PHASE 3BIS"
echo "════════════════════════════════════════════════════════════"
echo ""
echo "Services démarrés :"
docker compose ps --format "table {{.Name}}\t{{.Status}}" | head -10
echo ""
echo "Prochaines actions :"
echo ""
echo " Si tout est ✅ HEALTHY :"
echo " → Ouvrir http://localhost:5176 dans le navigateur"
echo " → Tester login/register"
echo " → Passer à Phase 4 (tests E2E)"
echo ""
echo " Si frontend ❌ ou stream-server ❌ :"
echo " → Consulter docs/PHASE_3BIS_CORRECTION_GUIDE.md"
echo " → Vérifier les logs détaillés ci-dessus"
echo " → Exécuter les commandes de debugging"
echo ""
echo "════════════════════════════════════════════════════════════"
echo "✅ Tests Phase 3bis terminés"
echo "════════════════════════════════════════════════════════════"