# Docker Compose stress test with receiver # See README.md "Docker Compose" section for the full token workflow. # # This test: # 1. Starts the metrics receiver (with read-token and hmac-key) # 2. You generate a scoped push token via POST /api/v1/token # 3. Start the collector with COLLECTOR_PUSH_TOKEN set # 4. Runs heavy CPU/memory workloads in multiple containers with shared PID namespace # 5. Collector gathers metrics and pushes summary to receiver on shutdown # # To trigger the push, stop the collector gracefully: # docker compose -f test/docker/docker-compose-stress.yaml stop collector services: # Metrics receiver - stores summaries in SQLite receiver: build: context: ../.. dockerfile: Dockerfile target: receiver ports: - "9080:8080" environment: - DB_PATH=/data/metrics.db - RECEIVER_READ_TOKEN=dummyreadtoken - RECEIVER_HMAC_KEY=dummyhmackey volumes: - receiver-data:/data healthcheck: test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/health"] interval: 5s timeout: 3s retries: 3 # Heavy CPU workload - uses stress-ng (owns the PID namespace) cpu-stress: image: alexeiled/stress-ng:latest command: - --cpu - "3" - --timeout - "300s" - --metrics-brief deploy: resources: limits: cpus: "2.0" memory: 128M # This container owns the PID namespace # Memory-intensive workload - shares PID namespace with cpu-stress mem-stress: image: alexeiled/stress-ng:latest command: - --vm - "2" - --vm-bytes - "64M" - --timeout - "300s" - --metrics-brief deploy: resources: limits: cpus: "0.5" memory: 256M pid: "service:cpu-stress" depends_on: - cpu-stress # IO workload - continuous disk writes io-stress: image: busybox:latest command: - /bin/sh - -c - | echo "IO stress started" # 'dd' will be our identifiable process while true; do dd if=/dev/zero of=/tmp/testfile bs=1M count=100 2>/dev/null rm -f /tmp/testfile done deploy: resources: limits: cpus: "0.5" memory: 128M pid: "service:cpu-stress" depends_on: - cpu-stress # Resource collector - pushes to receiver on shutdown collector: build: context: ../.. dockerfile: Dockerfile target: collector command: - --interval=2s - --top=10 - --log-format=json - --push-endpoint=http://receiver:8080/api/v1/metrics environment: # Push token — pass via COLLECTOR_PUSH_TOKEN from host env COLLECTOR_PUSH_TOKEN: "${COLLECTOR_PUSH_TOKEN}" # Execution context for the receiver GITHUB_REPOSITORY_OWNER: "test-org" GITHUB_REPOSITORY: "test-org/stress-test" GITHUB_WORKFLOW: "stress-test-workflow" GITHUB_JOB: "heavy-workload" GITHUB_RUN_ID: "stress-run-001" # Cgroup configuration # stress-ng-cpu is the worker process name for CPU stress # stress-ng-vm is the worker process name for memory stress CGROUP_PROCESS_MAP: '{"stress-ng-cpu":"cpu-stress","stress-ng-vm":"mem-stress","dd":"io-stress","resource-collec":"collector"}' CGROUP_LIMITS: '{"cpu-stress":{"cpu":"1","memory":"128Mi"},"mem-stress":{"cpu":"500m","memory":"256Mi"},"io-stress":{"cpu":"500m","memory":"128Mi"},"collector":{"cpu":"200m","memory":"64Mi"}}' deploy: resources: limits: cpus: "0.2" memory: 64M pid: "service:cpu-stress" depends_on: receiver: condition: service_healthy cpu-stress: condition: service_started volumes: receiver-data: