(t *testing.T)
| 410 | } |
| 411 | |
| 412 | func 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 |
nothing calls this directly
no test coverage detected