MCPcopy
hub / github.com/kubernetes/client-go / TestSlowBackoff

Function TestSlowBackoff

util/flowcontrol/backoff_test.go:26–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestSlowBackoff(t *testing.T) {
27 id := "_idSlow"
28 tc := clock.NewFakeClock(time.Now())
29 step := time.Second
30 maxDuration := 50 * step
31
32 b := NewFakeBackOff(step, maxDuration, tc)
33 cases := []time.Duration{0, 1, 2, 4, 8, 16, 32, 50, 50, 50}
34 for ix, c := range cases {
35 tc.Step(step)
36 w := b.Get(id)
37 if w != c*step {
38 t.Errorf("input: '%d': expected %s, got %s", ix, c*step, w)
39 }
40 b.Next(id, tc.Now())
41 }
42
43 //Now confirm that the Reset cancels backoff.
44 b.Next(id, tc.Now())
45 b.Reset(id)
46 if b.Get(id) != 0 {
47 t.Errorf("Reset didn't clear the backoff.")
48 }
49
50}
51
52func TestBackoffReset(t *testing.T) {
53 id := "_idReset"

Callers

nothing calls this directly

Calls 6

NewFakeBackOffFunction · 0.85
NowMethod · 0.65
GetMethod · 0.65
ErrorfMethod · 0.65
NextMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected