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

Function TestSchedulerMetrics

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

Source from the content-addressed store, hash-verified

410}
411
412func TestSchedulerMetrics(t *testing.T) {
413 reg := prometheus.NewPedanticRegistry()
414
415 scheduler, frontendClient, _ := setupScheduler(t, reg, false)
416
417 frontendLoop := initFrontendLoop(t, frontendClient, "frontend-12345")
418 frontendToScheduler(t, frontendLoop, &schedulerpb.FrontendToScheduler{
419 Type: schedulerpb.ENQUEUE,
420 QueryID: 1,
421 UserID: "test",
422 HttpRequest: &httpgrpc.HTTPRequest{Method: "GET", Url: "/hello"},
423 })
424 frontendToScheduler(t, frontendLoop, &schedulerpb.FrontendToScheduler{
425 Type: schedulerpb.ENQUEUE,
426 QueryID: 1,
427 UserID: "another",
428 HttpRequest: &httpgrpc.HTTPRequest{Method: "GET", Url: "/hello"},
429 })
430
431 require.NoError(t, promtest.GatherAndCompare(reg, strings.NewReader(`
432 # HELP cortex_query_scheduler_queue_length Number of queries in the queue.
433 # TYPE cortex_query_scheduler_queue_length gauge
434 cortex_query_scheduler_queue_length{priority="0",type="fifo",user="another"} 1
435 cortex_query_scheduler_queue_length{priority="0",type="fifo",user="test"} 1
436 # HELP cortex_request_queue_requests_total Total number of query requests going to the request queue.
437 # TYPE cortex_request_queue_requests_total counter
438 cortex_request_queue_requests_total{priority="0",user="another"} 1
439 cortex_request_queue_requests_total{priority="0",user="test"} 1
440 `), "cortex_query_scheduler_queue_length", "cortex_request_queue_requests_total"))
441
442 scheduler.cleanupMetricsForInactiveUser("test")
443
444 require.NoError(t, promtest.GatherAndCompare(reg, strings.NewReader(`
445 # HELP cortex_query_scheduler_queue_length Number of queries in the queue.
446 # TYPE cortex_query_scheduler_queue_length gauge
447 cortex_query_scheduler_queue_length{priority="0",type="fifo",user="another"} 1
448 # HELP cortex_request_queue_requests_total Total number of query requests going to the request queue.
449 # TYPE cortex_request_queue_requests_total counter
450 cortex_request_queue_requests_total{priority="0",user="another"} 1
451 `), "cortex_query_scheduler_queue_length", "cortex_request_queue_requests_total"))
452}
453
454// TestQuerierLoopClient_WithLogicalPlan tests to see if the scheduler enqueues the fragment
455// with the expected QueryID, logical plan, and other fragment meta-data

Callers

nothing calls this directly

Calls 4

setupSchedulerFunction · 0.85
initFrontendLoopFunction · 0.85
frontendToSchedulerFunction · 0.85

Tested by

no test coverage detected