From 975628e853d2ad260afdde4cf10565c4987bc31c Mon Sep 17 00:00:00 2001 From: pingqiu Date: Tue, 1 Dec 2026 12:39:46 -0800 Subject: [PATCH] hostlimit: test, the no-progress window bound starts at the admission The window's timer starts inside Admit; a first admission publishes and syncs the host configuration, which a loaded runner can stretch to hundreds of milliseconds. The upper bound is now measured from Admit's return; the lower bound still from before it. The failure message prints the admission's duration. Co-Authored-By: Claude Opus 5.5 --- .../core/hostlimit/limiter_progress_test.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/seaweed-block/core/hostlimit/limiter_progress_test.go b/seaweed-block/core/hostlimit/limiter_progress_test.go index 08df88edfd..543d65a353 100644 --- a/seaweed-block/core/hostlimit/limiter_progress_test.go +++ b/seaweed-block/core/hostlimit/limiter_progress_test.go @@ -7,7 +7,10 @@ import ( ) // A hold whose work reports no progress is revoked within its no-progress -// window W: not before W, and not much after it. +// window W: not before W, and not much after it. The window starts inside +// Admit, so "not before" is measured from before Admit and "not much after" +// from its return: the admission's own file-system work (a first admission +// publishes and syncs the host configuration) is not counted against W. func TestStalledHoldIsRevokedWithinTheWindow(t *testing.T) { c := testConfig(t) c.NoProgress = 100 * time.Millisecond @@ -18,11 +21,15 @@ func TestStalledHoldIsRevokedWithinTheWindow(t *testing.T) { if err != nil { t.Fatal(err) } + admitted := time.Now() defer l.Release(x) select { case at := <-revoked: - if d := at.Sub(start); d < 80*time.Millisecond || d > 400*time.Millisecond { - t.Fatalf("revoked after %s, want about the window (%s)", d, c.NoProgress) + if d := at.Sub(start); d < 80*time.Millisecond { + t.Fatalf("revoked %s after the admission began, before the window (%s)", d, c.NoProgress) + } + if d := at.Sub(admitted); d > 400*time.Millisecond { + t.Fatalf("revoked %s after the admission returned, want about the window (%s); the admission took %s", d, c.NoProgress, admitted.Sub(start)) } case <-time.After(2 * time.Second): t.Fatalf("a stalled hold was not revoked within its no-progress window (%s)", c.NoProgress)