diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-21 20:16:19 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-21 20:18:41 +0200 |
| commit | e51b8571bc192e7122f25a3d05a6407dfa8a6998 (patch) | |
| tree | 81e7e1fbe1c9e0a91d033b1aded00b4273502313 /integrationtests/helpers_test.go | |
| parent | 2f0ac27ec92840cab408e5f5a71d225be070cc0f (diff) | |
Add ior crash/timeout harness tests (task 343)
- Add waitBoth unit tests: ior exit error, ior timeout, both timeout,
both succeed — using real processes (true/false/sleep)
- Add TestIorCrashReportsError: full harness test with fake ior binary
that exits with error, verifying error mentions 'ior' and workload PID
is returned
- Add TestIorStartFailureCleansUpWorkload: verifies workload process is
killed when ior binary doesn't exist, checking with signal 0
- Refactor waitBoth to accept grace duration parameter for testability
(production code passes iorShutdownGrace, tests use 500ms)
- Fix pipe drain in startWorkload: drain remaining stdout after reading
PID so cmd.Wait() doesn't block on pending I/O
- Add writeScript helper to helpers_test.go for creating fake binaries
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c8162-c1cf-7612-b8f5-84c61e3d2021
Diffstat (limited to 'integrationtests/helpers_test.go')
| -rw-r--r-- | integrationtests/helpers_test.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/integrationtests/helpers_test.go b/integrationtests/helpers_test.go index edf57b9..7db54b2 100644 --- a/integrationtests/helpers_test.go +++ b/integrationtests/helpers_test.go @@ -36,6 +36,16 @@ func absPath(t *testing.T, rel string) string { return p } +// writeScript creates an executable shell script in dir and returns its path. +func writeScript(t *testing.T, dir, name, content string) string { + t.Helper() + path := filepath.Join(dir, name) + if err := os.WriteFile(path, []byte("#!/bin/sh\n"+content+"\n"), 0o755); err != nil { + t.Fatalf("write script %s: %v", name, err) + } + return path +} + func runScenario(t *testing.T, scenario string, expected []ExpectedEvent) { t.Helper() h := newTestHarness(t) |
