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

Function startLifecycler

ring/ring_test.go:4042–4071  ·  view source on GitHub ↗
(t *testing.T, cfg Config, heartbeat time.Duration, lifecyclerID int, zones int)

Source from the content-addressed store, hash-verified

4040}
4041
4042func startLifecycler(t *testing.T, cfg Config, heartbeat time.Duration, lifecyclerID int, zones int) *Lifecycler {
4043 lcCfg := LifecyclerConfig{
4044 RingConfig: cfg,
4045 NumTokens: 16,
4046 HeartbeatPeriod: heartbeat,
4047 HeartbeatTimeout: time.Minute,
4048 ObservePeriod: 0,
4049 JoinAfter: 0,
4050 Zone: fmt.Sprintf("zone-%d", lifecyclerID%zones),
4051 Addr: fmt.Sprintf("addr-%d", lifecyclerID),
4052 ID: fmt.Sprintf("instance-%d", lifecyclerID),
4053 UnregisterOnShutdown: true,
4054 }
4055
4056 lc, err := NewLifecycler(lcCfg, &noopFlushTransferer{}, "test", "test", false, log.NewNopLogger(), nil)
4057 require.NoError(t, err)
4058
4059 lc.AddListener(services.NewListener(nil, nil, nil, nil, func(_ services.State, failure error) {
4060 t.Log("lifecycler", lifecyclerID, "failed:", failure)
4061 t.Fail()
4062 }))
4063
4064 require.NoError(t, services.StartAndAwaitRunning(context.Background(), lc))
4065
4066 t.Cleanup(func() {
4067 _ = services.StopAndAwaitTerminated(context.Background(), lc)
4068 })
4069
4070 return lc
4071}
4072
4073// This test checks if shuffle-sharded ring can be reused, and whether it receives
4074// updates from "main" ring.

Callers 2

TestRingUpdatesFunction · 0.85

Calls 7

NewListenerFunction · 0.92
StartAndAwaitRunningFunction · 0.92
StopAndAwaitTerminatedFunction · 0.92
NewLifecyclerFunction · 0.85
FailMethod · 0.80
AddListenerMethod · 0.65
LogMethod · 0.45

Tested by

no test coverage detected