Skip to content

[Feature]: Configurable params for built-in workloads #184

Description

@mrhillsman

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:

  1. Add param getter methods with defaults
  2. Convert systemd unit constant → method with fmt.Sprintf
  3. 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:

  1. go test ./internal/workloads/... — all param tests pass
  2. go test ./... — full suite passes
  3. Manual: run with params: {cpu-load-percent: "50"} and verify cloud-init output shows --cpu-load 50

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.size/XLDenotes a PR that changes 500-999 lines, ignoring generated files.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions