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

Function TestLeaveOnStoppingDelegate

ring/basic_lifecycler_delegates_test.go:19–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestLeaveOnStoppingDelegate(t *testing.T) {
20 onStoppingCalled := false
21
22 ctx := context.Background()
23 cfg := prepareBasicLifecyclerConfig()
24
25 testDelegate := &mockDelegate{
26 onStopping: func(l *BasicLifecycler) {
27 assert.Equal(t, LEAVING, l.GetState())
28 onStoppingCalled = true
29 },
30 }
31
32 leaveDelegate := NewLeaveOnStoppingDelegate(testDelegate, log.NewNopLogger())
33 lifecycler, _, err := prepareBasicLifecyclerWithDelegate(t, cfg, leaveDelegate)
34 require.NoError(t, err)
35 require.NoError(t, services.StartAndAwaitRunning(ctx, lifecycler))
36
37 assert.NoError(t, services.StopAndAwaitTerminated(ctx, lifecycler))
38 assert.True(t, onStoppingCalled)
39}
40
41func TestTokensPersistencyDelegate_ShouldSkipTokensLoadingIfFileDoesNotExist(t *testing.T) {
42 // Create a temporary file and immediately delete it.

Callers

nothing calls this directly

Calls 7

StartAndAwaitRunningFunction · 0.92
StopAndAwaitTerminatedFunction · 0.92
EqualMethod · 0.45
GetStateMethod · 0.45

Tested by

no test coverage detected