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

Function TestManagerEntersStopStateEventually

services/manager_test.go:209–230  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

207}
208
209func TestManagerEntersStopStateEventually(t *testing.T) {
210 t.Parallel()
211
212 s1 := serviceThatStopsOnItsOwnAfterTimeout(200 * time.Millisecond)
213 s2 := serviceThatStopsOnItsOwnAfterTimeout(300 * time.Millisecond)
214 gl := newGatheringManagerListener(t)
215
216 m, err := NewManager(s1, s2)
217 require.NoError(t, err)
218 m.AddListener(gl)
219
220 // start all services
221 require.NoError(t, m.StartAsync(context.Background()))
222
223 require.NoError(t, m.AwaitHealthy(context.Background()))
224
225 // both services stop after short time, so this manager will become stopped
226 require.NoError(t, m.AwaitStopped(context.Background()))
227
228 require.NoError(t, gl.AwaitTerminated(context.Background()))
229 require.Equal(t, []string{"healthy", "stopped"}, gl.log)
230}
231
232func TestManagerAwaitWithContextCancellation(t *testing.T) {
233 t.Parallel()

Callers

nothing calls this directly

Calls 9

AddListenerMethod · 0.95
StartAsyncMethod · 0.95
AwaitHealthyMethod · 0.95
AwaitStoppedMethod · 0.95
NewManagerFunction · 0.70
AwaitTerminatedMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected