MCPcopy
hub / github.com/grafana/dskit / TestWatchKeyNoRateLimit

Function TestWatchKeyNoRateLimit

kv/consul/client_test.go:68–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestWatchKeyNoRateLimit(t *testing.T) {
69 c, closer := NewInMemoryClientWithConfig(codec.String{}, Config{
70 WatchKeyRateLimit: 0,
71 }, testLogger{}, prometheus.NewPedanticRegistry())
72 t.Cleanup(func() {
73 assert.NoError(t, closer.Close())
74 })
75
76 const key = "test"
77 const max = 100
78
79 ch := writeValuesToKV(t, c, key, 0, max, time.Millisecond)
80 observed := observeValueForSomeTime(t, c, key, 500*time.Millisecond)
81
82 // wait until updater finishes
83 <-ch
84
85 // With no limit, we should see most written values (we can lose some values if watching
86 // code is busy while multiple new values are written)
87 if len(observed) < 3*max/4 {
88 t.Error("Expected at least 3/4 of all values, got", observed)
89 }
90}
91
92func TestReset(t *testing.T) {
93 c, closer := NewInMemoryClient(codec.String{}, testLogger{}, prometheus.NewPedanticRegistry())

Callers

nothing calls this directly

Calls 5

writeValuesToKVFunction · 0.85
observeValueForSomeTimeFunction · 0.85
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected