carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "testing"
5 "time"
6
7 "github.com/carlosframework/platform/internal/hostops"
8)
9
10// M7: an idle reset worker backs off its bucket listing instead of listing
11// every second per box, and returns to the fast poll once a request appears.
12func TestPlan9M7ResetWorkerBacksOffIdleListing(t *testing.T) {
13 poll := resetPollMin
14 var got []time.Duration
15 for range 6 {
16 poll = nextResetPoll(poll, 0)
17 got = append(got, poll)
18 }
19 want := []time.Duration{2 * time.Second, 4 * time.Second, 8 * time.Second, 8 * time.Second, 8 * time.Second, 8 * time.Second}
20 for i := range want {
21 if got[i] != want[i] {
22 t.Fatalf("idle polls = %v, want %v", got, want)
23 }
24 }
25 // A new request still dispatches early in its lifetime.
26 if resetPollMax > hostops.WakeResetLifetime/8 {
27 t.Fatalf("idle poll %v is too long for a %v request", resetPollMax, hostops.WakeResetLifetime)
28 }
29 if poll = nextResetPoll(poll, 1); poll != resetPollMin {
30 t.Fatalf("a listed request kept the slow poll: %v", poll)
31 }
32}
33