package host import ( "testing" "time" "github.com/carlosframework/platform/internal/hostops" ) // M7: an idle reset worker backs off its bucket listing instead of listing // every second per box, and returns to the fast poll once a request appears. func TestPlan9M7ResetWorkerBacksOffIdleListing(t *testing.T) { poll := resetPollMin var got []time.Duration for range 6 { poll = nextResetPoll(poll, 0) got = append(got, poll) } want := []time.Duration{2 * time.Second, 4 * time.Second, 8 * time.Second, 8 * time.Second, 8 * time.Second, 8 * time.Second} for i := range want { if got[i] != want[i] { t.Fatalf("idle polls = %v, want %v", got, want) } } // A new request still dispatches early in its lifetime. if resetPollMax > hostops.WakeResetLifetime/8 { t.Fatalf("idle poll %v is too long for a %v request", resetPollMax, hostops.WakeResetLifetime) } if poll = nextResetPoll(poll, 1); poll != resetPollMin { t.Fatalf("a listed request kept the slow poll: %v", poll) } }