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

Function TestServerStopViaContext

pkg/cortex/server_service_test.go:15–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestServerStopViaContext(t *testing.T) {
16 // server registers some metrics to default registry
17 savedRegistry := prometheus.DefaultRegisterer
18 prometheus.DefaultRegisterer = prometheus.NewRegistry()
19 defer func() {
20 prometheus.DefaultRegisterer = savedRegistry
21 }()
22
23 serv, err := server.New(server.Config{HTTPListenNetwork: server.DefaultNetwork})
24 require.NoError(t, err)
25
26 ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
27 defer cancel()
28
29 s := NewServerService(serv, func() []services.Service { return nil })
30 require.NoError(t, s.StartAsync(ctx))
31
32 // should terminate soon, since context has short timeout
33 require.NoError(t, s.AwaitTerminated(context.Background()))
34}
35
36func TestServerStopViaShutdown(t *testing.T) {
37 // server registers some metrics to default registry

Callers

nothing calls this directly

Calls 3

NewServerServiceFunction · 0.85
StartAsyncMethod · 0.65
AwaitTerminatedMethod · 0.65

Tested by

no test coverage detected