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

Function TestIngester_ShutdownHandler

pkg/ingester/lifecycle_test.go:96–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func TestIngester_ShutdownHandler(t *testing.T) {
97 for _, unregister := range []bool{false, true} {
98 t.Run(fmt.Sprintf("unregister=%t", unregister), func(t *testing.T) {
99 registry := prometheus.NewRegistry()
100 config := defaultIngesterTestConfig(t)
101 config.LifecyclerConfig.UnregisterOnShutdown = unregister
102 ingester, err := prepareIngesterWithBlocksStorage(t, config, registry)
103 require.NoError(t, err)
104 require.NoError(t, services.StartAndAwaitRunning(context.Background(), ingester))
105
106 // Make sure the ingester has been added to the ring.
107 test.Poll(t, 100*time.Millisecond, 1, func() any {
108 return numTokens(config.LifecyclerConfig.RingConfig.KVStore.Mock, "localhost", RingKey)
109 })
110
111 recorder := httptest.NewRecorder()
112 ingester.ShutdownHandler(recorder, nil)
113 require.Equal(t, http.StatusNoContent, recorder.Result().StatusCode)
114
115 // Make sure the ingester has been removed from the ring even when UnregisterFromRing is false.
116 test.Poll(t, 100*time.Millisecond, 0, func() any {
117 return numTokens(config.LifecyclerConfig.RingConfig.KVStore.Mock, "localhost", RingKey)
118 })
119 })
120 }
121}
122
123// numTokens determines the number of tokens owned by the specified
124// address

Callers

nothing calls this directly

Calls 8

StartAndAwaitRunningFunction · 0.92
PollFunction · 0.92
numTokensFunction · 0.70
RunMethod · 0.65
ShutdownHandlerMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected