221 lines
7.0 KiB
YAML
221 lines
7.0 KiB
YAML
# ===================================================================
|
|
# Docker Compose - Ping Service Testing
|
|
# Trace-Bullet Testing Setup für Ping Service Backend
|
|
# ===================================================================
|
|
# Usage:
|
|
# Start testing environment: docker-compose -f docker-compose-ping-test.yml up -d
|
|
# Stop and cleanup: docker-compose -f docker-compose-ping-test.yml down -v
|
|
# ===================================================================
|
|
|
|
services:
|
|
# ===================================================================
|
|
# Datenbank (PostgreSQL) - Minimale Konfiguration für Tests
|
|
# ===================================================================
|
|
postgres-test:
|
|
image: postgres:16-alpine
|
|
container_name: ping-test-postgres
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-testuser}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-testpass}
|
|
POSTGRES_DB: ${POSTGRES_DB:-pingtest}
|
|
ports:
|
|
- "5433:5432" # Anderer Port um Konflikte zu vermeiden
|
|
volumes:
|
|
- postgres-test-data:/var/lib/postgresql/data
|
|
networks:
|
|
- ping-test-network
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-testuser} -d ${POSTGRES_DB:-pingtest}"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 3
|
|
start_period: 10s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Redis Cache - Für Event Store und Caching
|
|
# ===================================================================
|
|
redis-test:
|
|
image: redis:7-alpine
|
|
container_name: ping-test-redis
|
|
ports:
|
|
- "6380:6379" # Anderer Port um Konflikte zu vermeiden
|
|
volumes:
|
|
- redis-test-data:/data
|
|
command: redis-server --appendonly yes
|
|
networks:
|
|
- ping-test-network
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 3
|
|
start_period: 10s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Service Discovery (Consul) - Für Service Registration
|
|
# ===================================================================
|
|
consul-test:
|
|
image: hashicorp/consul:1.15
|
|
container_name: ping-test-consul
|
|
ports:
|
|
- "8501:8500" # Anderer Port um Konflikte zu vermeiden
|
|
command: agent -server -ui -node=test-server -bootstrap-expect=1 -client=0.0.0.0
|
|
networks:
|
|
- ping-test-network
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8500/v1/status/leader"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 3
|
|
start_period: 10s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Monitoring (Prometheus) - Für Metriken
|
|
# ===================================================================
|
|
prometheus-test:
|
|
image: prom/prometheus:v2.47.0
|
|
container_name: ping-test-prometheus
|
|
ports:
|
|
- "9091:9090" # Anderer Port um Konflikte zu vermeiden
|
|
volumes:
|
|
- prometheus-test-data:/prometheus
|
|
- ./config/prometheus-test.yml:/etc/prometheus/prometheus.yml:ro
|
|
command:
|
|
- '--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=24h'
|
|
- '--web.enable-lifecycle'
|
|
networks:
|
|
- ping-test-network
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9090/-/healthy"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 3
|
|
start_period: 15s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Ping Service - Der zu testende Service
|
|
# ===================================================================
|
|
ping-service:
|
|
build:
|
|
context: .
|
|
dockerfile: dockerfiles/services/ping-service/Dockerfile
|
|
args:
|
|
SPRING_PROFILES_ACTIVE: test
|
|
container_name: ping-test-service
|
|
environment:
|
|
# Spring Konfiguration
|
|
SPRING_PROFILES_ACTIVE: test
|
|
SERVER_PORT: 8082
|
|
|
|
# Consul Konfiguration
|
|
CONSUL_HOST: consul-test
|
|
CONSUL_PORT: 8500
|
|
CONSUL_ENABLED: true
|
|
|
|
# Datenbank Konfiguration
|
|
DB_HOST: postgres-test
|
|
DB_PORT: 5432
|
|
DB_NAME: ${POSTGRES_DB:-pingtest}
|
|
DB_USER: ${POSTGRES_USER:-testuser}
|
|
DB_PASSWORD: ${POSTGRES_PASSWORD:-testpass}
|
|
|
|
# Redis Konfiguration
|
|
REDIS_EVENT_STORE_HOST: redis-test
|
|
REDIS_EVENT_STORE_PORT: 6379
|
|
REDIS_EVENT_STORE_PASSWORD: ""
|
|
|
|
# JVM Optimierungen für Testing
|
|
JAVA_OPTS: "-Xmx512m -XX:+UseG1GC -Dspring.profiles.active=test"
|
|
|
|
# Debug Modus aktivieren
|
|
DEBUG: ${DEBUG:-false}
|
|
ports:
|
|
- "8082:8082"
|
|
- "5005:5005" # Debug Port
|
|
depends_on:
|
|
consul-test:
|
|
condition: service_healthy
|
|
postgres-test:
|
|
condition: service_healthy
|
|
redis-test:
|
|
condition: service_healthy
|
|
networks:
|
|
- ping-test-network
|
|
healthcheck:
|
|
test: ["CMD", "curl", "--fail", "http://localhost:8082/actuator/health"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 30s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Test Utilities - Hilfscontainer für Tests
|
|
# ===================================================================
|
|
test-runner:
|
|
image: curlimages/curl:latest
|
|
container_name: ping-test-runner
|
|
depends_on:
|
|
ping-service:
|
|
condition: service_healthy
|
|
networks:
|
|
- ping-test-network
|
|
command: |
|
|
sh -c '
|
|
echo "=== Ping Service Test Suite ==="
|
|
echo "Warte auf Service-Start..."
|
|
sleep 10
|
|
|
|
echo "=== Health Check Test ==="
|
|
curl -v http://ping-service:8082/actuator/health
|
|
echo ""
|
|
|
|
echo "=== Info Endpoint Test ==="
|
|
curl -v http://ping-service:8082/actuator/info
|
|
echo ""
|
|
|
|
echo "=== Circuit Breaker Status Test ==="
|
|
curl -v http://ping-service:8082/actuator/circuitbreakers
|
|
echo ""
|
|
|
|
echo "=== Prometheus Metrics Test ==="
|
|
curl -v http://ping-service:8082/actuator/prometheus
|
|
echo ""
|
|
|
|
echo "=== Service Discovery Test (Consul) ==="
|
|
curl -v http://consul-test:8500/v1/agent/services
|
|
echo ""
|
|
|
|
echo "=== Alle Tests abgeschlossen ==="
|
|
'
|
|
profiles: ["test"]
|
|
|
|
# ===================================================================
|
|
# Volumes für persistente Daten
|
|
# ===================================================================
|
|
volumes:
|
|
postgres-test-data:
|
|
driver: local
|
|
redis-test-data:
|
|
driver: local
|
|
prometheus-test-data:
|
|
driver: local
|
|
|
|
# ===================================================================
|
|
# Isoliertes Test-Netzwerk
|
|
# ===================================================================
|
|
networks:
|
|
ping-test-network:
|
|
driver: bridge
|
|
ipam:
|
|
config:
|
|
- subnet: 172.20.0.0/16
|