Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions tools/failure-inject/cpusteal/cpusteal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
)

// TestRun_HonorsDuration pins the duration contract: a 100ms request
// must complete in [95ms, 500ms] window — lower bound is the busy-loop
// minimum, upper bound is the scheduling-slack ceiling beyond which
// the harness is misbehaving.
// must busy-loop at least that long and must terminate — the upper
// bound is a hang sentinel, not a perf bound, so it is generous
// enough to absorb GH Actions runner contention.
func TestRun_HonorsDuration(t *testing.T) {
t.Parallel()
start := time.Now()
Expand All @@ -25,12 +25,14 @@ func TestRun_HonorsDuration(t *testing.T) {
}))
elapsed := time.Since(start)
require.GreaterOrEqual(t, elapsed, 95*time.Millisecond, "must busy-loop for at least the requested duration")
require.Less(t, elapsed, 500*time.Millisecond, "must not run substantially past the requested duration")
require.Less(t, elapsed, 2*time.Second, "must terminate (hang sentinel; not a perf bound)")
}

// TestRun_HonorsContextCancellation pins the early-exit contract: a
// cancelled context returns context.Canceled within ~50ms regardless
// of the configured Duration.
// cancelled context returns context.Canceled and Run terminates. The
// upper bound is a hang sentinel, not a perf bound — context-cancel
// responsiveness under runner contention can vary by an order of
// magnitude. Tighten only after sustained CI evidence.
func TestRun_HonorsContextCancellation(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -45,7 +47,7 @@ func TestRun_HonorsContextCancellation(t *testing.T) {
})
elapsed := time.Since(start)
require.ErrorIs(t, err, context.Canceled)
require.Less(t, elapsed, 250*time.Millisecond, "must abort quickly on context cancel")
require.Less(t, elapsed, 2*time.Second, "must terminate on cancel (hang sentinel; not a perf bound)")
}

// TestRun_RejectsZeroDuration pins the input-validation contract.
Expand Down