Problem Statement
Built-in workloads (CPU, memory, disk, database, network) have hardcoded values in their systemd unit constants (e.g., stress-ng --cpu 0 --cpu-method all). Some workloads (TPS, chaos-*) already read from WorkloadConfig.Params, but the core workloads do not. Users cannot tune workload behavior (e.g., CPU stress from 100% to 90%) without modifying source code.
Proposed Solution
Parameterize all built-in workloads using the existing getter-with-default pattern from chaos workloads (e.g., chaos_network.go:latencyMs()). Each workload gets param getter methods; systemd unit constants become methods that interpolate values via fmt.Sprintf.
Params per workload:
- CPU (
internal/workloads/cpu.go): cpu-load-percent (default 100), cpu-method (default all)
- Memory (
internal/workloads/memory.go): memory-percent (default 80), vm-stressors (default 1), vm-method (default all)
- Disk (
internal/workloads/disk.go): block-size-rw (default 4k), block-size-seq (default 128k), rwmixread (default 70), numjobs (default 4), runtime (default 300)
- Database (
internal/workloads/database.go): scale-factor (default 10), clients (default 4), duration (default 300)
- Network (
internal/workloads/network.go): parallel-streams (default 4), test-duration (default 60)
Implementation pattern per workload:
- Add param getter methods with defaults
- Convert systemd unit constant → method with
fmt.Sprintf
- Unit tests for getter defaults/overrides and generated output
Alternatives Considered
Environment variable overrides in the systemd units — rejected because it bypasses the existing Params mechanism and doesn't compose with the config file.
Area
Workloads
Architecture Layer
Layer 3 - Workload Definitions (workloads, registry)
Additional Context
Affected files:
internal/workloads/cpu.go
internal/workloads/memory.go
internal/workloads/disk.go
internal/workloads/database.go
internal/workloads/network.go
- Corresponding
_test.go files
Verification:
go test ./internal/workloads/... — all param tests pass
go test ./... — full suite passes
- Manual: run with
params: {cpu-load-percent: "50"} and verify cloud-init output shows --cpu-load 50
Problem Statement
Built-in workloads (CPU, memory, disk, database, network) have hardcoded values in their systemd unit constants (e.g.,
stress-ng --cpu 0 --cpu-method all). Some workloads (TPS, chaos-*) already read fromWorkloadConfig.Params, but the core workloads do not. Users cannot tune workload behavior (e.g., CPU stress from 100% to 90%) without modifying source code.Proposed Solution
Parameterize all built-in workloads using the existing getter-with-default pattern from chaos workloads (e.g.,
chaos_network.go:latencyMs()). Each workload gets param getter methods; systemd unit constants become methods that interpolate values viafmt.Sprintf.Params per workload:
internal/workloads/cpu.go):cpu-load-percent(default100),cpu-method(defaultall)internal/workloads/memory.go):memory-percent(default80),vm-stressors(default1),vm-method(defaultall)internal/workloads/disk.go):block-size-rw(default4k),block-size-seq(default128k),rwmixread(default70),numjobs(default4),runtime(default300)internal/workloads/database.go):scale-factor(default10),clients(default4),duration(default300)internal/workloads/network.go):parallel-streams(default4),test-duration(default60)Implementation pattern per workload:
fmt.SprintfAlternatives Considered
Environment variable overrides in the systemd units — rejected because it bypasses the existing
Paramsmechanism and doesn't compose with the config file.Area
Workloads
Architecture Layer
Layer 3 - Workload Definitions (workloads, registry)
Additional Context
Affected files:
internal/workloads/cpu.gointernal/workloads/memory.gointernal/workloads/disk.gointernal/workloads/database.gointernal/workloads/network.go_test.gofilesVerification:
go test ./internal/workloads/...— all param tests passgo test ./...— full suite passesparams: {cpu-load-percent: "50"}and verify cloud-init output shows--cpu-load 50