fix(R-1250): the line-test hold waits until the held app has really slowed down before asking the agent
gates / gates (push) Successful in 51s

Measured on demo-hp 2026-10-27: qBittorrent 5.2.4 kept sending at full speed for ~14 s after its limit fell to
1 KiB/s; the agent reads the uplink 5-15 s after the call, so every test on request was refused "not quiet"
(four tries in an hour, 4.0-4.2 Mbit/s). waitDrained polls each held app's own upload (qBittorrent up_info_speed,
Transmission uploadSpeed) until <= 16 KiB/s twice, 2 s apart, at most 90 s; an unreadable speed waits 20 s.
Tests TestR1250_* (five), red-proved by four mutations.
This commit is contained in:
admin committed 2026-10-27 13:23:00 +01:00
1 parent 9b5bb0a9a6
commit 710ceace12
5 files changed
+289 -3

No files matched your search

@@ -20,6 +20,24 @@ type fakeTorrent struct {
writes []HeldLimit
failWrite bool
failRead bool
rates []int64 // UploadRate answers in order, the last one repeating; none = 0 (already quiet)
rateReads int
failRate bool
}
func (f *fakeTorrent) UploadRate(context.Context) (int64, error) {
f.rateReads++
if f.failRate {
return 0, errors.New("transfer/info: HTTP 404")
}
if len(f.rates) == 0 {
return 0, nil
}
i := f.rateReads - 1
if i >= len(f.rates) {
i = len(f.rates) - 1
}
return f.rates[i], nil
}
func (f *fakeTorrent) Stack() string {