diff --git a/.env.ping-test b/.env.ping-test deleted file mode 100644 index 92874efd..00000000 --- a/.env.ping-test +++ /dev/null @@ -1,10 +0,0 @@ -# Database Configuration -POSTGRES_USER=mytestuser -POSTGRES_PASSWORD=mytestpassword -POSTGRES_DB=mypingtest - -# Debug Configuration -DEBUG=true - -# JVM Configuration -JAVA_OPTS='-Xmx1g -XX:+UseG1GC -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005' diff --git a/README-PING-TEST.md b/README-PING-TEST.md deleted file mode 100644 index 5cff92b0..00000000 --- a/README-PING-TEST.md +++ /dev/null @@ -1,354 +0,0 @@ -# Ping Service Testing Setup - Trace-Bullet Backend Testing - -## Übersicht - -Dieses Docker Compose Setup ermöglicht das isolierte Testen des **Ping Service Backends** im Rahmen der Trace-Bullet Implementierung. Es stellt eine minimale, aber vollständige Testumgebung bereit, die alle notwendigen Abhängigkeiten enthält, ohne die Hauptentwicklungsumgebung zu beeinträchtigen. - -## Architektur - -``` -┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ -│ Ping Service │ │ Consul │ │ PostgreSQL │ -│ Port: 8082 │◄──►│ Port: 8501 │ │ Port: 5433 │ -│ (Test Target) │ │ (Discovery) │ │ (Database) │ -└─────────────────┘ └─────────────────┘ └─────────────────┘ - │ │ │ - ▼ ▼ ▼ -┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ -│ Prometheus │ │ Redis │ │ Test Runner │ -│ Port: 9091 │ │ Port: 6380 │ │ (Automated) │ -│ (Monitoring) │ │ (Cache) │ │ (Tests) │ -└─────────────────┘ └─────────────────┘ └─────────────────┘ -``` - -## Enthaltene Services - -### 1. **Ping Service** (Hauptkomponente) -- **Port**: 8082 -- **Debug Port**: 5005 (falls DEBUG=true) -- **Health Check**: `/actuator/health` -- **Metriken**: `/actuator/prometheus` -- **Circuit Breaker**: `/actuator/circuitbreakers` - -### 2. **PostgreSQL Test-Datenbank** -- **Port**: 5433 (um Konflikte mit der Hauptdatenbank zu vermeiden) -- **Database**: `pingtest` -- **User**: `testuser` -- **Password**: `testpass` - -### 3. **Redis Cache** -- **Port**: 6380 (um Konflikte zu vermeiden) -- **Verwendung**: Event Store und Caching - -### 4. **Consul Service Discovery** -- **Port**: 8501 (um Konflikte zu vermeiden) -- **Web UI**: http://localhost:8501 -- **Verwendung**: Service Registration und Discovery - -### 5. **Prometheus Monitoring** -- **Port**: 9091 (um Konflikte zu vermeiden) -- **Web UI**: http://localhost:9091 -- **Verwendung**: Metriken-Sammlung und Monitoring - -### 6. **Test Runner** (Optional) -- Automatisierte Tests für alle Endpoints -- Läuft nur mit `--profile test` - -## Schnellstart - -### 1. Umgebung starten -```bash -# Basis-Setup starten (ohne automatische Tests) -docker-compose -f docker-compose-ping-test.yml up -d - -# Mit automatischen Tests -docker-compose -f docker-compose-ping-test.yml --profile test up -d -``` - -### 2. Status prüfen -```bash -# Alle Container-Status anzeigen -docker-compose -f docker-compose-ping-test.yml ps - -# Logs des Ping Service anzeigen -docker-compose -f docker-compose-ping-test.yml logs -f ping-service - -# Health Checks aller Services -docker-compose -f docker-compose-ping-test.yml ps --format "table {{.Service}}\t{{.Status}}\t{{.Ports}}" -``` - -### 3. Manuelle Tests durchführen - -#### Health Check -```bash -curl http://localhost:8082/actuator/health -``` - -#### Service Info -```bash -curl http://localhost:8082/actuator/info -``` - -#### Circuit Breaker Status -```bash -curl http://localhost:8082/actuator/circuitbreakers -``` - -#### Prometheus Metriken -```bash -curl http://localhost:8082/actuator/prometheus -``` - -### 4. Umgebung stoppen und aufräumen -```bash -# Services stoppen -docker-compose -f docker-compose-ping-test.yml down - -# Services stoppen und Volumes löschen -docker-compose -f docker-compose-ping-test.yml down -v - -# Zusätzlich Images löschen -docker-compose -f docker-compose-ping-test.yml down -v --rmi all -``` - -## Erweiterte Konfiguration - -### Umgebungsvariablen - -Erstellen Sie eine `.env.ping-test` Datei für benutzerdefinierte Konfiguration: - -```bash -# Database Configuration -POSTGRES_USER=mytestuser -POSTGRES_PASSWORD=mytestpassword -POSTGRES_DB=mypingtest - -# Debug Configuration -DEBUG=true - -# JVM Configuration -JAVA_OPTS=-Xmx1g -XX:+UseG1GC -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -``` - -Laden Sie die Konfiguration: -```bash -docker-compose -f docker-compose-ping-test.yml --env-file .env.ping-test up -d -``` - -### Debug-Modus aktivieren - -1. **Debug-Modus starten:** -```bash -DEBUG=true docker-compose -f docker-compose-ping-test.yml up -d ping-service -``` - -2. **IDE mit Remote Debug verbinden:** - - Host: `localhost` - - Port: `5005` - - Typ: `Attach to remote JVM` - -## Monitoring und Überwachung - -### Prometheus Dashboard -- URL: http://localhost:9091 -- Verfügbare Metriken: - - `http_server_requests_seconds` - - `jvm_memory_used_bytes` - - `resilience4j_circuitbreaker_state` - - Custom Application Metriken - -### Consul Web UI -- URL: http://localhost:8501 -- Zeigt registrierte Services -- Service Health Status -- Service Discovery Informationen - -## Troubleshooting - -### Häufige Probleme - -#### 1. **Port-Konflikte** -```bash -# Prüfen Sie, welche Ports bereits verwendet werden -netstat -tlnp | grep -E ':(8082|5433|6380|8501|9091)' - -# Oder mit ss -ss -tlnp | grep -E ':(8082|5433|6380|8501|9091)' -``` - -#### 2. **Service startet nicht** -```bash -# Detaillierte Logs anzeigen -docker-compose -f docker-compose-ping-test.yml logs ping-service - -# Container Status prüfen -docker inspect ping-test-service -``` - -#### 3. **Consul Connection Probleme** -```bash -# Consul Logs prüfen -docker-compose -f docker-compose-ping-test.yml logs consul-test - -# Consul Services anzeigen -curl http://localhost:8501/v1/agent/services -``` - -#### 4. **Database Connection Issues** -```bash -# PostgreSQL Logs -docker-compose -f docker-compose-ping-test.yml logs postgres-test - -# Direkte Verbindung testen -docker exec -it ping-test-postgres psql -U testuser -d pingtest -``` - -### Performance-Optimierung - -#### 1. **Speicher-Limits setzen** -```yaml -# In docker-compose-ping-test.yml ergänzen: -services: - ping-service: - deploy: - resources: - limits: - memory: 1G - reservations: - memory: 512M -``` - -#### 2. **Build-Cache nutzen** -```bash -# Build mit Cache -docker-compose -f docker-compose-ping-test.yml build --parallel - -# Build ohne Cache (bei Problemen) -docker-compose -f docker-compose-ping-test.yml build --no-cache ping-service -``` - -## Test-Szenarien - -### 1. **Circuit Breaker Tests** -```bash -# Circuit Breaker Status abrufen -curl http://localhost:8082/actuator/circuitbreakers - -# Mehrfache Requests senden um Circuit Breaker zu testen -for i in {1..10}; do - curl -w "Response time: %{time_total}s\n" http://localhost:8082/actuator/health - sleep 1 -done -``` - -### 2. **Load Testing** -```bash -# Mit Apache Bench (falls installiert) -ab -n 100 -c 10 http://localhost:8082/actuator/health - -# Mit curl (einfacher Loop) -for i in {1..50}; do - curl -s http://localhost:8082/actuator/health > /dev/null & -done -wait -``` - -### 3. **Service Discovery Tests** -```bash -# Service Registration prüfen -curl http://localhost:8501/v1/agent/services | jq . - -# Health Checks in Consul -curl http://localhost:8501/v1/health/service/ping-service | jq . -``` - -## Continuous Integration - -### GitHub Actions Beispiel -```yaml -name: Ping Service Tests -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Start Test Environment - run: | - docker-compose -f docker-compose-ping-test.yml up -d - - - name: Wait for Services - run: | - timeout 300 bash -c 'until curl -f http://localhost:8082/actuator/health; do sleep 5; done' - - - name: Run Tests - run: | - docker-compose -f docker-compose-ping-test.yml --profile test up test-runner - - - name: Cleanup - run: | - docker-compose -f docker-compose-ping-test.yml down -v -``` - -## Best Practices - -### 1. **Vor dem Testen** -- Stellen Sie sicher, dass keine anderen Services auf den Test-Ports laufen -- Überprüfen Sie verfügbaren Speicher und CPU-Ressourcen -- Löschen Sie alte Test-Volumes bei Bedarf - -### 2. **Während des Testens** -- Nutzen Sie die Health Check Endpoints -- Überwachen Sie Logs in Echtzeit -- Prüfen Sie Metriken in Prometheus - -### 3. **Nach dem Testen** -- Stoppen und entfernen Sie Test-Container -- Löschen Sie Test-Volumes um Speicher zu sparen -- Dokumentieren Sie gefundene Issues - -## Erweiterungen - -### Zusätzliche Services hinzufügen -Um weitere Services zu testen, erweitern Sie die `docker-compose-ping-test.yml`: - -```yaml -services: - another-service: - build: - context: . - dockerfile: path/to/Dockerfile - depends_on: - - ping-service - networks: - - ping-test-network -``` - -### Grafana für erweiterte Visualisierung -```yaml -services: - grafana-test: - image: grafana/grafana:latest - ports: - - "3001:3000" - environment: - - GF_SECURITY_ADMIN_PASSWORD=admin - networks: - - ping-test-network -``` - -## Support - -Bei Problemen oder Fragen: -1. Prüfen Sie die Logs: `docker-compose -f docker-compose-ping-test.yml logs` -2. Überprüfen Sie die Container-Status: `docker-compose -f docker-compose-ping-test.yml ps` -3. Konsultieren Sie die Hauptdokumentation in `README.md` -4. Überprüfen Sie die Service-spezifische Konfiguration in `temp/ping-service/src/main/resources/application.yml` - ---- - -**Erstellt für**: Meldestelle Projekt - Ping Service Trace-Bullet Testing -**Version**: 1.0.0 -**Datum**: 2025-09-08 diff --git a/client/src/commonMain/kotlin/at/mocode/App.kt b/client/src/commonMain/kotlin/at/mocode/App.kt index 567135a3..7e8c89f1 100644 --- a/client/src/commonMain/kotlin/at/mocode/App.kt +++ b/client/src/commonMain/kotlin/at/mocode/App.kt @@ -84,7 +84,10 @@ fun App() { coroutineScope.launch { pingState = PingState.Loading try { - val response: PingResponse = httpClient.get("http://localhost:8082/ping").body() + // Direkter Aufruf des Ping-Service + //val response: PingResponse = httpClient.get("http://localhost:8082/ping").body() + // NEU: Aufruf über das Gateway + val response: PingResponse = httpClient.get("http://localhost:8081/api/ping").body() pingState = PingState.Success(response) } catch (e: Exception) { pingState = PingState.Error(e.message ?: "Unknown error occurred") @@ -136,6 +139,7 @@ fun App() { } } } + is PingState.Error -> { Card( modifier = Modifier @@ -158,6 +162,7 @@ fun App() { } } } + else -> { // Idle or Loading state - no additional display needed } diff --git a/docker-compose.clients.yml b/docker-compose.clients.yml index b5f54b63..3a70d313 100644 --- a/docker-compose.clients.yml +++ b/docker-compose.clients.yml @@ -99,7 +99,7 @@ services: environment: SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-dev} SERVER_PORT: ${AUTH_SERVICE_PORT:-8087} - KEYCLOAK_SERVER_URL: http://keycloak:8081 + KEYCLOAK_SERVER_URL: http://keycloak:8080 KEYCLOAK_REALM: meldestelle KEYCLOAK_CLIENT_ID: meldestelle-auth-service KEYCLOAK_CLIENT_SECRET: ${KEYCLOAK_CLIENT_SECRET:-auth-service-secret} @@ -174,4 +174,4 @@ volumes: # =================================================================== networks: meldestelle-network: - external: false + external: true diff --git a/docker-compose.yml b/docker-compose.yml index 3a2bd8fe..454a01ca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -67,7 +67,7 @@ services: KC_DB_USERNAME: ${POSTGRES_USER:-meldestelle} KC_DB_PASSWORD: ${POSTGRES_PASSWORD:-meldestelle} ports: - - "8180:8081" + - "8180:8080" depends_on: postgres: condition: service_healthy @@ -77,7 +77,7 @@ services: networks: - meldestelle-network healthcheck: - test: [ "CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8081/" ] + test: [ "CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/" ] interval: 10s timeout: 5s retries: 3 @@ -235,47 +235,6 @@ services: start_period: 30s restart: unless-stopped - # =================================================================== - # Ping Service (Health Check & Test Service) - # =================================================================== - ping-service: - build: - context: . - dockerfile: dockerfiles/services/ping-service/Dockerfile - container_name: meldestelle-ping-service - environment: - SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-dev} - SERVER_PORT: ${PING_SERVICE_PORT:-8082} - CONSUL_HOST: consul - CONSUL_PORT: ${CONSUL_PORT:-8500} - CONSUL_ENABLED: true - DB_HOST: postgres - DB_PORT: 5432 - DB_NAME: ${POSTGRES_DB:-meldestelle} - DB_USER: ${POSTGRES_USER:-meldestelle} - DB_PASSWORD: ${POSTGRES_PASSWORD:-meldestelle} - REDIS_EVENT_STORE_HOST: redis - REDIS_EVENT_STORE_PORT: 6379 - REDIS_EVENT_STORE_PASSWORD: ${REDIS_PASSWORD:-} - ports: - - "${PING_SERVICE_PORT:-8082}:${PING_SERVICE_PORT:-8082}" - depends_on: - consul: - condition: service_healthy - postgres: - condition: service_healthy - redis: - condition: service_healthy - networks: - - meldestelle-network - healthcheck: - test: ["CMD", "curl", "--fail", "http://localhost:${PING_SERVICE_PORT:-8082}/actuator/health"] - interval: 15s - timeout: 5s - retries: 3 - start_period: 30s - restart: unless-stopped - # =================================================================== # Volumes # =================================================================== diff --git a/test-services-startup.sh b/sanity-check.sh similarity index 57% rename from test-services-startup.sh rename to sanity-check.sh index 3e26325a..f10377c2 100755 --- a/test-services-startup.sh +++ b/sanity-check.sh @@ -18,6 +18,10 @@ TIMEOUT_SECONDS=300 HEALTH_CHECK_INTERVAL=10 MAX_RETRIES=30 +# NEU: Alle Compose-Dateien zentral definieren +COMPOSE_FILES="-f docker-compose.yml -f docker-compose.services.yml -f docker-compose.clients.yml" + + # Logging functions log_info() { echo -e "${BLUE}[INFO]${NC} $1" @@ -45,7 +49,9 @@ wait_for_health_check() { log_info "Waiting for $service_name health check at $health_url" while [ $attempt -le $max_attempts ]; do - if curl -f -s --max-time 5 "$health_url" > /dev/null 2>&1; then + # ALT: if curl -f -s --max-time 5 "$health_url" > /dev/null 2>&1; then + # NEU: Die Option -L wurde hinzugefügt, um HTTP-Redirects zu folgen. + if curl -f -s -L --max-time 5 "$health_url" > /dev/null 2>&1; then log_success "$service_name is healthy (attempt $attempt/$max_attempts)" return 0 fi @@ -79,83 +85,34 @@ check_service_logs() { } # Function to test infrastructure services -test_infrastructure_services() { +test_all_services() { log_info "=========================================" - log_info "Testing Infrastructure Services" + log_info "Starting All Meldestelle Services" log_info "=========================================" - # Start infrastructure services - log_info "Starting infrastructure services..." - # Use docker directly since docker-compose has system issues - log_info "Note: Using docker run directly due to docker-compose system issues" - - # Create network if it doesn't exist - docker network create meldestelle-network 2>/dev/null || true - - # Start PostgreSQL - docker run -d --name meldestelle-postgres \ - --network meldestelle-network \ - -e POSTGRES_USER=meldestelle \ - -e POSTGRES_PASSWORD=meldestelle \ - -e POSTGRES_DB=meldestelle \ - -p 5432:5432 \ - postgres:16-alpine 2>/dev/null || log_info "PostgreSQL container already exists" - - # Start Redis - docker run -d --name meldestelle-redis \ - --network meldestelle-network \ - -p 6379:6379 \ - redis:7-alpine redis-server --appendonly yes 2>/dev/null || log_info "Redis container already exists" - - # Start Consul - docker run -d --name meldestelle-consul \ - --network meldestelle-network \ - -p 8500:8500 \ - hashicorp/consul:1.15 agent -server -ui -node=server-1 -bootstrap-expect=1 -client=0.0.0.0 2>/dev/null || log_info "Consul container already exists" - - # Start Prometheus - docker run -d --name meldestelle-prometheus \ - --network meldestelle-network \ - -p 9090:9090 \ - prom/prometheus:v2.47.0 \ - --config.file=/etc/prometheus/prometheus.yml \ - --storage.tsdb.path=/prometheus \ - --web.console.libraries=/etc/prometheus/console_libraries \ - --web.console.templates=/etc/prometheus/consoles \ - --storage.tsdb.retention.time=200h \ - --web.enable-lifecycle 2>/dev/null || log_info "Prometheus container already exists" - - # Start Grafana - docker run -d --name meldestelle-grafana \ - --network meldestelle-network \ - -p 3000:3000 \ - -e GF_SECURITY_ADMIN_USER=admin \ - -e GF_SECURITY_ADMIN_PASSWORD=admin \ - grafana/grafana:10.1.0 2>/dev/null || log_info "Grafana container already exists" - - # Start Keycloak - docker run -d --name meldestelle-keycloak \ - --network meldestelle-network \ - -p 8180:8080 \ - -e KEYCLOAK_ADMIN=admin \ - -e KEYCLOAK_ADMIN_PASSWORD=admin \ - quay.io/keycloak/keycloak:23.0 start-dev 2>/dev/null || log_info "Keycloak container already exists" + # Start ALL services using all compose files + log_info "Starting full environment with docker-compose..." + # ALT: docker compose up -d + docker compose $COMPOSE_FILES up -d # Give services time to initialize - log_info "Waiting 30 seconds for services to initialize..." - sleep 30 + log_info "Waiting 45 seconds for services to initialize..." + sleep 45 - # Wait for services to be ready - local services=( + # ========================================= + # CHECK INFRASTRUCTURE + # ========================================= + log_info "--- Checking Infrastructure Services ---" + local infra_services=( "postgres:http://localhost:5432:PostgreSQL" "redis:redis://localhost:6379:Redis" "consul:http://localhost:8500/v1/status/leader:Consul" "prometheus:http://localhost:9090/-/healthy:Prometheus" "grafana:http://localhost:3000/api/health:Grafana" - "keycloak:http://localhost:8180/health/ready:Keycloak" + "keycloak:http://localhost:8180/:Keycloak" ) - for service_info in "${services[@]}"; do + for service_info in "${infra_services[@]}"; do # Parse service info: service_name:health_url:description # Extract service name (everything before first colon) service_name=$(echo "$service_info" | cut -d':' -f1) @@ -188,95 +145,58 @@ test_infrastructure_services() { else wait_for_health_check "$description" "$health_url" $MAX_RETRIES || return 1 fi - check_service_logs "$description" "meldestelle-$service_name" done - log_success "All infrastructure services are healthy!" -} -# Function to test API Gateway -test_api_gateway() { - log_info "=========================================" - log_info "Testing API Gateway" - log_info "=========================================" - - # Start API Gateway - log_info "Starting API Gateway..." - docker-compose up -d api-gateway - - # Wait for API Gateway to be ready + # ========================================= + # CHECK API GATEWAY + # ========================================= + log_info "--- Checking API Gateway ---" wait_for_health_check "API Gateway" "http://localhost:8081/actuator/health" $MAX_RETRIES || return 1 - - # Check specific actuator endpoints - local endpoints=("health" "info" "metrics") - for endpoint in "${endpoints[@]}"; do - local url="http://localhost:8081/actuator/$endpoint" - if curl -f -s --max-time 5 "$url" > /dev/null 2>&1; then - log_success "API Gateway $endpoint endpoint is accessible" - else - log_warning "API Gateway $endpoint endpoint is not accessible at $url" - fi - done - check_service_logs "API Gateway" "meldestelle-api-gateway" log_success "API Gateway is healthy!" -} -# Function to test application services -test_application_services() { - log_info "=========================================" - log_info "Testing Application Services" - log_info "=========================================" - - # Start application services - log_info "Starting application services..." - docker-compose -f docker-compose.yml -f docker-compose.services.yml up -d - - # Define application services with their health check URLs + # ========================================= + # CHECK APPLICATION SERVICES + # ========================================= + log_info "--- Checking Application Services ---" local app_services=( "ping-service:http://localhost:8082/actuator/health:Ping Service" - "members-service:http://localhost:8083/actuator/health:Members Service" - "horses-service:http://localhost:8084/actuator/health:Horses Service" - "events-service:http://localhost:8085/actuator/health:Events Service" - "masterdata-service:http://localhost:8086/actuator/health:Masterdata Service" ) + # Note: Add other services like members-service here when they are enabled for service_info in "${app_services[@]}"; do IFS=':' read -r service_name health_url description <<< "$service_info" wait_for_health_check "$description" "$health_url" $MAX_RETRIES || return 1 check_service_logs "$description" "meldestelle-$service_name" done - log_success "All application services are healthy!" -} -# Function to test client services -test_client_services() { - log_info "=========================================" - log_info "Testing Client Services" - log_info "=========================================" - - # Start client services - log_info "Starting client services..." - docker-compose -f docker-compose.yml -f docker-compose.services.yml -f docker-compose.clients.yml up -d - - # Define client services with their health check URLs + # ========================================= + # CHECK CLIENT SERVICES + # ========================================= + log_info "--- Checking Client Services ---" local client_services=( - "web-app:http://localhost:3000/health:Web Application" + "web-app:http://localhost:4000/health:Web Application" "auth-server:http://localhost:8087/actuator/health:Auth Server" - "monitoring-server:http://localhost:8088/actuator/health:Monitoring Server" ) + # Note: Add other client services here when enabled for service_info in "${client_services[@]}"; do - IFS=':' read -r service_name health_url description <<< "$service_info" + # ... (parsing logic remains the same) + service_name=$(echo "$service_info" | cut -d':' -f1) + health_url=$(echo "$service_info" | cut -d':' -f2) + description=$(echo "$service_info" | cut -d':' -f3) wait_for_health_check "$description" "$health_url" $MAX_RETRIES || return 1 + # Use the container name from docker-compose.clients.yml (e.g., meldestelle-web-app) check_service_logs "$description" "meldestelle-$service_name" done - log_success "All client services are healthy!" } +# ENTFERNT: test_api_gateway, test_application_services, test_client_services wurden in test_all_services integriert. + # Function to test network connectivity test_network_connectivity() { log_info "=========================================" @@ -328,18 +248,21 @@ cleanup() { log_info "Cleaning up test environment" log_info "=========================================" - log_info "Stopping and removing test containers..." + log_info "Stopping and removing all test containers..." - # Stop and remove containers if they exist - local containers=("meldestelle-postgres" "meldestelle-redis" "meldestelle-consul" "meldestelle-prometheus" "meldestelle-grafana" "meldestelle-keycloak" "meldestelle-api-gateway") + # Use the same files to tear down the environment + docker compose $COMPOSE_FILES down --remove-orphans -v - for container in "${containers[@]}"; do - if docker ps -a --format '{{.Names}}' | grep -q "^${container}$"; then - log_info "Stopping and removing $container" - docker stop "$container" >/dev/null 2>&1 || true - docker rm "$container" >/dev/null 2>&1 || true - fi - done +# # Stop and remove containers if they exist +# local containers=("meldestelle-postgres" "meldestelle-redis" "meldestelle-consul" "meldestelle-prometheus" "meldestelle-grafana" "meldestelle-keycloak" "meldestelle-api-gateway") +# +# for container in "${containers[@]}"; do +# if docker ps -a --format '{{.Names}}' | grep -q "^${container}$"; then +# log_info "Stopping and removing $container" +# docker stop "$container" >/dev/null 2>&1 || true +# docker rm "$container" >/dev/null 2>&1 || true +# fi +# done # Remove network if it exists docker network rm meldestelle-network >/dev/null 2>&1 || true @@ -357,10 +280,7 @@ main() { trap cleanup EXIT # Run tests in sequence - test_infrastructure_services || exit 1 - test_api_gateway || exit 1 - test_application_services || exit 1 - test_client_services || exit 1 + test_all_services || exit 1 test_network_connectivity || exit 1 # Generate report @@ -374,17 +294,8 @@ main() { # Parse command line arguments case "${1:-}" in - "infrastructure") - test_infrastructure_services - ;; - "gateway") - test_api_gateway - ;; - "services") - test_application_services - ;; - "clients") - test_client_services + "all") + test_all_services ;; "network") test_network_connectivity diff --git a/scripts/test/test_gateway.sh b/scripts/test/test_gateway.sh index bfd373c7..bb7a2f4e 100755 --- a/scripts/test/test_gateway.sh +++ b/scripts/test/test_gateway.sh @@ -22,7 +22,7 @@ source "$SCRIPT_DIR/../utils/common.sh" || { readonly GATEWAY_MODULE="infrastructure:gateway" readonly GATEWAY_JAR="infrastructure/gateway/build/libs/gateway-1.0.0.jar" -readonly GATEWAY_PORT="${GATEWAY_PORT:-8080}" +readonly GATEWAY_PORT="${GATEWAY_PORT:-8081}" readonly GATEWAY_HOST="${GATEWAY_HOST:-localhost}" readonly GATEWAY_BASE_URL="http://${GATEWAY_HOST}:${GATEWAY_PORT}"