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

Function TestIngesterRestart

pkg/ingester/lifecycle_test.go:63–94  ·  view source on GitHub ↗

TestIngesterRestart tests a restarting ingester doesn't keep adding more tokens.

(t *testing.T)

Source from the content-addressed store, hash-verified

61
62// TestIngesterRestart tests a restarting ingester doesn't keep adding more tokens.
63func TestIngesterRestart(t *testing.T) {
64 config := defaultIngesterTestConfig(t)
65 config.LifecyclerConfig.UnregisterOnShutdown = false
66
67 {
68 ingester, err := prepareIngesterWithBlocksStorage(t, config, prometheus.NewRegistry())
69 require.NoError(t, err)
70 require.NoError(t, services.StartAndAwaitRunning(context.Background(), ingester))
71 time.Sleep(100 * time.Millisecond)
72 // Doesn't actually unregister due to UnregisterFromRing: false.
73 require.NoError(t, services.StopAndAwaitTerminated(context.Background(), ingester))
74 }
75
76 test.Poll(t, 100*time.Millisecond, 1, func() any {
77 return numTokens(config.LifecyclerConfig.RingConfig.KVStore.Mock, "localhost", RingKey)
78 })
79
80 {
81 ingester, err := prepareIngesterWithBlocksStorage(t, config, prometheus.NewRegistry())
82 require.NoError(t, err)
83 require.NoError(t, services.StartAndAwaitRunning(context.Background(), ingester))
84 time.Sleep(100 * time.Millisecond)
85 // Doesn't actually unregister due to UnregisterFromRing: false.
86 require.NoError(t, services.StopAndAwaitTerminated(context.Background(), ingester))
87 }
88
89 time.Sleep(200 * time.Millisecond)
90
91 test.Poll(t, 100*time.Millisecond, 1, func() any {
92 return numTokens(config.LifecyclerConfig.RingConfig.KVStore.Mock, "localhost", RingKey)
93 })
94}
95
96func TestIngester_ShutdownHandler(t *testing.T) {
97 for _, unregister := range []bool{false, true} {

Callers

nothing calls this directly

Calls 6

StartAndAwaitRunningFunction · 0.92
StopAndAwaitTerminatedFunction · 0.92
PollFunction · 0.92
numTokensFunction · 0.70

Tested by

no test coverage detected