MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestWatchKeyNoRateLimit

Function TestWatchKeyNoRateLimit

pkg/ring/kv/consul/client_test.go:146–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144}
145
146func TestWatchKeyNoRateLimit(t *testing.T) {
147 c, closer := NewInMemoryClientWithConfig(codec.String{}, Config{
148 WatchKeyRateLimit: 0,
149 }, testLogger{}, prometheus.NewPedanticRegistry())
150 t.Cleanup(func() {
151 assert.NoError(t, closer.Close())
152 })
153
154 const key = "test"
155 const max = 100
156
157 ch := writeValuesToKV(t, c, key, 0, max, time.Millisecond)
158 observed := observeValueForSomeTime(t, c, key, 500*time.Millisecond)
159
160 // wait until updater finishes
161 <-ch
162
163 // With no limit, we should see most written values (we can lose some values if watching
164 // code is busy while multiple new values are written)
165 if len(observed) < 3*max/4 {
166 t.Error("Expected at least 3/4 of all values, got", observed)
167 }
168}
169
170func TestReset(t *testing.T) {
171 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