diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-23 13:20:01 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-23 13:20:01 +0200 |
| commit | 95441bb43ef1ea6d003cd3b4143bbaee70f797d6 (patch) | |
| tree | 55890376bb0081264249bead577c425ffba009df | |
| parent | 425d725048ee2f6225a093db719ced0fab54cdbc (diff) | |
integrationtests: add opt-in parallel execution mode
| -rw-r--r-- | Magefile.go | 30 | ||||
| -rw-r--r-- | integrationtests/README.md | 12 | ||||
| -rw-r--r-- | integrationtests/helpers_test.go | 9 |
3 files changed, 51 insertions, 0 deletions
diff --git a/Magefile.go b/Magefile.go index 4a49f42..d5c454e 100644 --- a/Magefile.go +++ b/Magefile.go @@ -38,6 +38,9 @@ const ( typesGoPath = "internal/types/generated_types.go" typesHeaderPath = "internal/c/types.h" VMLINUXPath = "internal/c/vmlinux.h" + integrationParallel = "INTEGRATION_PARALLEL" + integrationParallelN = "8" + integrationParallelE = "IOR_INTEGRATION_PARALLEL" ) // Default builds the project. @@ -281,6 +284,33 @@ func IntegrationTest() error { ) } +// IntegrationTestParallel builds everything and runs integration tests in parallel. +// Set INTEGRATION_PARALLEL to tune `go test -parallel` (default: 8). +func IntegrationTestParallel() error { + mg.SerialDeps(All) + if err := buildWorkloadBinary(); err != nil { + return err + } + fmt.Println("Running integration tests in parallel (requires root)...") + env := goEnv() + forwardEnv(env, "HOME", "GOPATH", "GOMODCACHE") + env[integrationParallelE] = "1" + + parallel := os.Getenv(integrationParallel) + if parallel == "" { + parallel = integrationParallelN + } + + return runGoTestWithProgress(env, + "./integrationtests/...", + "-failfast", + "-timeout=30m", + "-count=1", + "-parallel", parallel, + "-json", + ) +} + func buildWorkloadBinary() error { fmt.Println("Building ioworkload binary...") if err := sh.RunWithV(goEnv(), "go", "build", "-o", workloadBinaryName, workloadSourcePath); err != nil { diff --git a/integrationtests/README.md b/integrationtests/README.md index 741d14d..8de7439 100644 --- a/integrationtests/README.md +++ b/integrationtests/README.md @@ -19,6 +19,18 @@ This builds everything (ior, ioworkload) and runs the test suite with `sudo`. Tests automatically skip with `t.Skip` when not running as root. +To opt into parallel scenario execution: + +```bash +mage integrationTestParallel +``` + +Tune parallelism by setting `INTEGRATION_PARALLEL` (default `8`), for example: + +```bash +INTEGRATION_PARALLEL=4 mage integrationTestParallel +``` + ## Structure - `cmd/ioworkload/` — Standalone binary performing known I/O patterns diff --git a/integrationtests/helpers_test.go b/integrationtests/helpers_test.go index 7db54b2..5f60f0f 100644 --- a/integrationtests/helpers_test.go +++ b/integrationtests/helpers_test.go @@ -11,6 +11,7 @@ const ( workloadBinaryDefault = "../ioworkload" bpfObjectDefault = "../ior.bpf.o" defaultDuration = 10 + parallelEnvVar = "IOR_INTEGRATION_PARALLEL" ) func newTestHarness(t *testing.T) TestHarness { @@ -48,6 +49,7 @@ func writeScript(t *testing.T, dir, name, content string) string { func runScenario(t *testing.T, scenario string, expected []ExpectedEvent) { t.Helper() + enableParallelIfRequested(t) h := newTestHarness(t) result, pid, err := h.Run(scenario, defaultDuration) if err != nil { @@ -58,3 +60,10 @@ func runScenario(t *testing.T, scenario string, expected []ExpectedEvent) { AssertNoUnexpectedComm(t, result, "ioworkload") AssertEventsPresent(t, result, expected) } + +func enableParallelIfRequested(t *testing.T) { + t.Helper() + if os.Getenv(parallelEnvVar) == "1" { + t.Parallel() + } +} |
