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

Function TestSchedulerMaxOutstandingRequests

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

Source from the content-addressed store, hash-verified

318}
319
320func TestSchedulerMaxOutstandingRequests(t *testing.T) {
321 _, frontendClient, _ := setupScheduler(t, nil, false)
322
323 for i := range testMaxOutstandingPerTenant {
324 // coming from different frontends
325 fl := initFrontendLoop(t, frontendClient, fmt.Sprintf("frontend-%d", i))
326 require.NoError(t, fl.Send(&schedulerpb.FrontendToScheduler{
327 Type: schedulerpb.ENQUEUE,
328 QueryID: uint64(i),
329 UserID: "test", // for same user.
330 HttpRequest: &httpgrpc.HTTPRequest{},
331 }))
332
333 msg, err := fl.Recv()
334 require.NoError(t, err)
335 require.True(t, msg.Status == schedulerpb.OK)
336 }
337
338 // One more query from the same user will trigger an error.
339 fl := initFrontendLoop(t, frontendClient, "extra-frontend")
340 require.NoError(t, fl.Send(&schedulerpb.FrontendToScheduler{
341 Type: schedulerpb.ENQUEUE,
342 QueryID: 0,
343 UserID: "test",
344 HttpRequest: &httpgrpc.HTTPRequest{Method: "GET", Url: "/hello"},
345 }))
346
347 msg, err := fl.Recv()
348 require.NoError(t, err)
349 require.True(t, msg.Status == schedulerpb.TOO_MANY_REQUESTS_PER_TENANT)
350}
351
352func TestSchedulerForwardsErrorToFrontend(t *testing.T) {
353 _, frontendClient, querierClient := setupScheduler(t, nil, false)

Callers

nothing calls this directly

Calls 4

setupSchedulerFunction · 0.85
initFrontendLoopFunction · 0.85
SendMethod · 0.65
RecvMethod · 0.65

Tested by

no test coverage detected