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

Function TestDesc_Ready

ring/model_test.go:152–194  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func TestDesc_Ready(t *testing.T) {
153 now := time.Now()
154
155 r := &Desc{
156 Ingesters: map[string]InstanceDesc{
157 "ing1": {
158 Tokens: []uint32{100, 200, 300},
159 State: ACTIVE,
160 Timestamp: now.Unix(),
161 },
162 },
163 }
164
165 if err := r.IsReady(now, 10*time.Second); err != nil {
166 t.Fatal("expected ready, got", err)
167 }
168
169 if err := r.IsReady(now.Add(5*time.Minute), 10*time.Second); err == nil {
170 t.Fatal("expected !ready (no heartbeat from active ingester), but got no error")
171 }
172
173 r = &Desc{
174 Ingesters: map[string]InstanceDesc{
175 "ing1": {
176 State: ACTIVE,
177 Timestamp: now.Unix(),
178 },
179 },
180 }
181
182 if err := r.IsReady(now, 10*time.Second); err == nil {
183 t.Fatal("expected !ready (no tokens), but got no error")
184 }
185
186 r.Ingesters["some ingester"] = InstanceDesc{
187 Tokens: []uint32{12345},
188 Timestamp: now.Unix(),
189 }
190
191 if err := r.IsReady(now, 10*time.Second); err != nil {
192 t.Fatal("expected ready, got", err)
193 }
194}
195
196func TestDesc_getTokensByZone(t *testing.T) {
197 tests := map[string]struct {

Callers

nothing calls this directly

Calls 3

IsReadyMethod · 0.95
FatalMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected