mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 18:47:20 +01:00
Merge pull request #892 from seaweedfs/test/hostlimit-window-bound
hostlimit: test, the no-progress window bound starts at the admission
This commit is contained in:
commit
4b96d9940b
1 file changed
+10
-3
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user