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

Function TestWaitInstanceState_TimeoutOnError

pkg/ring/util_test.go:296–314  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

294}
295
296func TestWaitInstanceState_TimeoutOnError(t *testing.T) {
297 t.Parallel()
298
299 const (
300 instanceID = "test"
301 timeoutDuration = time.Second
302 )
303
304 ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration)
305 defer cancel()
306
307 ring := &RingMock{}
308 ring.On("GetInstanceState", mock.Anything, mock.Anything).Return(PENDING, errors.New("instance not found in the ring"))
309
310 err := WaitInstanceState(ctx, ring, instanceID, ACTIVE)
311
312 assert.Equal(t, context.DeadlineExceeded, err)
313 ring.AssertCalled(t, "GetInstanceState", instanceID)
314}
315
316func TestWaitInstanceState_ExitsAfterActualStateEqualsState(t *testing.T) {
317 t.Parallel()

Callers

nothing calls this directly

Calls 2

WaitInstanceStateFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected