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

Function TestTracingContext

pkg/scheduler/scheduler_test.go:236–265  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

234}
235
236func TestTracingContext(t *testing.T) {
237 scheduler, frontendClient, _ := setupScheduler(t, nil, false)
238
239 frontendLoop := initFrontendLoop(t, frontendClient, "frontend-12345")
240
241 closer, err := config.Configuration{}.InitGlobalTracer("test")
242 require.NoError(t, err)
243 defer closer.Close()
244
245 req := &schedulerpb.FrontendToScheduler{
246 Type: schedulerpb.ENQUEUE,
247 QueryID: 1,
248 UserID: "test",
249 HttpRequest: &httpgrpc.HTTPRequest{Method: "GET", Url: "/hello"},
250 FrontendAddress: "frontend-12345",
251 }
252
253 sp, _ := opentracing.StartSpanFromContext(context.Background(), "client")
254 opentracing.GlobalTracer().Inject(sp.Context(), opentracing.HTTPHeaders, (*httpgrpcutil.HttpgrpcHeadersCarrier)(req.HttpRequest))
255
256 frontendToScheduler(t, frontendLoop, req)
257
258 scheduler.pendingRequestsMu.Lock()
259 defer scheduler.pendingRequestsMu.Unlock()
260 require.Equal(t, 1, len(scheduler.pendingRequests))
261
262 for _, r := range scheduler.pendingRequests {
263 require.NotNil(t, r.parentSpanContext)
264 }
265}
266
267func TestSchedulerShutdown_FrontendLoop(t *testing.T) {
268 scheduler, frontendClient, _ := setupScheduler(t, nil, false)

Callers

nothing calls this directly

Calls 7

setupSchedulerFunction · 0.85
initFrontendLoopFunction · 0.85
frontendToSchedulerFunction · 0.85
CloseMethod · 0.65
EqualMethod · 0.65
InjectMethod · 0.45
ContextMethod · 0.45

Tested by

no test coverage detected