test: wait for async write-budget release after pipeline shutdown (#10530)

Shutdown drops the sealed-chunk map references, but an in-flight
uploader goroutine holds the final reference and releases its budget
slot only after reacquiring chunksLock. Asserting Used()==0 immediately
after Shutdown races those releases on slow runners. Poll with a bounded
deadline instead.
This commit is contained in:
Chris Lu
2026-08-01 20:04:40 -07:00
committed by GitHub
parent de00091765
commit c21d92b70a
@@ -160,6 +160,12 @@ func TestWriteBufferCap_SharedAcrossPipelines(t *testing.T) {
if got := observedMax.Load(); got > capBytes {
t.Fatalf("observed Used()=%d exceeded cap=%d", got, capBytes)
}
// An uploader goroutine releases its budget slot only after reacquiring
// chunksLock post-Shutdown, so the last releases may land asynchronously.
drainDeadline := time.Now().Add(5 * time.Second)
for acc.Used() != 0 && time.Now().Before(drainDeadline) {
time.Sleep(2 * time.Millisecond)
}
if got := acc.Used(); got != 0 {
t.Fatalf("expected 0 used after shutdown, got %d", got)
}