#!/bin/bash # Local test script to verify cgroup grouping # Run from project root: ./test/local-test.sh set -e echo "Building collector..." go build -o bin/collector ./cmd/collector echo "" echo "Testing cgroup parsing on current system..." echo "Current process cgroup:" cat /proc/self/cgroup 2>/dev/null || echo "Cannot read /proc/self/cgroup (expected on macOS)" echo "" echo "Running collector for 10 seconds with cgroup grouping..." echo "Press Ctrl+C to stop early" echo "" # Set up test environment variables # Map common process names to container names export CGROUP_PROCESS_MAP='{"bash":"shell","collector":"collector","zsh":"shell"}' export CGROUP_LIMITS='{"shell":{"cpu":"2","memory":"4Gi"},"collector":{"cpu":"1","memory":"1Gi"}}' # Run collector timeout 10 ./bin/collector \ --interval=2s \ --top=5 \ --log-format=json \ 2>/dev/null || true echo "" echo "Test complete!" echo "" echo "Note: On macOS, cgroup paths will be empty since cgroups are a Linux feature." echo "To test properly, run in a Linux container or VM."