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

Function TestManagerCannotStartIfAllServicesArentNew

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

Source from the content-addressed store, hash-verified

141}
142
143func TestManagerCannotStartIfAllServicesArentNew(t *testing.T) {
144 t.Parallel()
145
146 s1 := serviceThatDoesntDoAnything()
147 s2 := serviceThatDoesntDoAnything()
148 s3 := serviceThatDoesntDoAnything()
149 gl := newGatheringManagerListener(t)
150
151 m, err := NewManager(s1, s2, s3)
152 require.NoError(t, err)
153
154 m.AddListener(gl)
155
156 // start first service
157 require.NoError(t, s1.StartAsync(context.Background()))
158 // will fail while starting s1, and then s2 and s3 won't be started at all (they are started sequentially)
159 require.Error(t, m.StartAsync(context.Background()))
160
161 m.StopAsync()
162 require.NoError(t, m.AwaitStopped(context.Background()))
163
164 require.NoError(t, gl.AwaitTerminated(context.Background()))
165 require.Equal(t, []string{"stopped"}, gl.log)
166}
167
168func TestManagerThatFailsToStart(t *testing.T) {
169 t.Parallel()

Callers

nothing calls this directly

Calls 11

AddListenerMethod · 0.95
StartAsyncMethod · 0.95
StopAsyncMethod · 0.95
AwaitStoppedMethod · 0.95
NewManagerFunction · 0.70
StartAsyncMethod · 0.65
AwaitTerminatedMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected