|
| 1 | +# Test Profiling Tools |
| 2 | + |
| 3 | +Collect and analyze heap/CPU profiles during operator-controller tests. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +# Start profiling |
| 9 | +make start-profiling/baseline |
| 10 | + |
| 11 | +# Run tests |
| 12 | +make test-e2e |
| 13 | + |
| 14 | +# Stop and analyze |
| 15 | +make stop-profiling |
| 16 | + |
| 17 | +# View report |
| 18 | +cat test-profiles/baseline/analysis.md |
| 19 | + |
| 20 | +# Compare runs |
| 21 | +./bin/test-profile compare baseline optimized |
| 22 | +cat test-profiles/comparisons/baseline-vs-optimized.md |
| 23 | +``` |
| 24 | + |
| 25 | +## Commands |
| 26 | + |
| 27 | +```bash |
| 28 | +# Build |
| 29 | +make build-test-profiler |
| 30 | + |
| 31 | +# Run test with profiling |
| 32 | +./bin/test-profile run <name> [test-target] |
| 33 | + |
| 34 | +# Start/stop daemon |
| 35 | +./bin/test-profile start [name] # Daemonizes automatically |
| 36 | +./bin/test-profile stop |
| 37 | + |
| 38 | +# Analyze/compare |
| 39 | +./bin/test-profile analyze <name> |
| 40 | +./bin/test-profile compare <baseline> <optimized> |
| 41 | +./bin/test-profile collect # Single snapshot |
| 42 | +``` |
| 43 | + |
| 44 | +## Configuration |
| 45 | + |
| 46 | +```bash |
| 47 | +# Define components to profile (optional - defaults to operator-controller and catalogd) |
| 48 | +# Format: "name:namespace:deployment:port;name2:namespace2:deployment2:port2" |
| 49 | +export TEST_PROFILE_COMPONENTS="operator-controller:olmv1-system:operator-controller-controller-manager:6060;catalogd:olmv1-system:catalogd-controller-manager:6060" |
| 50 | + |
| 51 | +# Profile custom applications |
| 52 | +export TEST_PROFILE_COMPONENTS="my-app:my-ns:my-deployment:8080;api-server:api-ns:api-deployment:9090" |
| 53 | + |
| 54 | +# Other settings |
| 55 | +export TEST_PROFILE_INTERVAL=10 # seconds between collections |
| 56 | +export TEST_PROFILE_CPU_DURATION=10 # CPU profiling duration in seconds |
| 57 | +export TEST_PROFILE_MODE=both # both|heap|cpu |
| 58 | +export TEST_PROFILE_DIR=./test-profiles # output directory |
| 59 | +export TEST_PROFILE_TEST_TARGET=test-e2e # make target to run |
| 60 | +``` |
| 61 | + |
| 62 | +**Component Configuration:** |
| 63 | +- Each component needs a `/debug/pprof` endpoint (standard Go pprof) |
| 64 | +- Local ports are automatically assigned to avoid conflicts |
| 65 | +- Default: operator-controller and catalogd in olmv1-system namespace |
| 66 | + |
| 67 | +## Output |
| 68 | + |
| 69 | +``` |
| 70 | +test-profiles/ |
| 71 | +├── <name>/ |
| 72 | +│ ├── operator-controller/{heap,cpu}*.pprof |
| 73 | +│ ├── catalogd/{heap,cpu}*.pprof |
| 74 | +│ ├── profiler.log |
| 75 | +│ └── analysis.md |
| 76 | +└── comparisons/<name>-vs-<name>.md |
| 77 | +``` |
| 78 | + |
| 79 | +## Interactive Analysis |
| 80 | + |
| 81 | +```bash |
| 82 | +cd test-profiles/<name>/operator-controller |
| 83 | +go tool pprof -top heap23.pprof |
| 84 | +go tool pprof -base=heap0.pprof -top heap23.pprof |
| 85 | +go tool pprof -text heap23.pprof | grep -i openapi |
| 86 | +``` |
| 87 | + |
| 88 | +## Requirements |
| 89 | + |
| 90 | +**Runtime:** |
| 91 | +- Kubernetes cluster access (via kubeconfig) |
| 92 | + |
| 93 | +**Build:** |
| 94 | +- go 1.24+ |
| 95 | +- make |
0 commit comments