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

Function TestMetricShutdown

util/workqueue/metrics_test.go:38–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36func (m *testMetrics) updateUnfinishedWork() { m.updateCalled <- struct{}{} }
37
38func TestMetricShutdown(t *testing.T) {
39 ch := make(chan struct{})
40 m := &testMetrics{
41 updateCalled: ch,
42 }
43 c := clock.NewFakeClock(time.Now())
44 q := newQueue(c, m, time.Millisecond)
45 for !c.HasWaiters() {
46 // Wait for the go routine to call NewTicker()
47 time.Sleep(time.Millisecond)
48 }
49
50 c.Step(time.Millisecond)
51 <-ch
52 q.ShutDown()
53
54 c.Step(time.Hour)
55 select {
56 default:
57 return
58 case <-ch:
59 t.Errorf("Unexpected update after shutdown was called.")
60 }
61}
62
63type testMetric struct {
64 inc int64

Callers

nothing calls this directly

Calls 5

newQueueFunction · 0.85
NowMethod · 0.65
SleepMethod · 0.65
ShutDownMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected