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

Function TestCancelRequestInProgress

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

Source from the content-addressed store, hash-verified

201}
202
203func TestCancelRequestInProgress(t *testing.T) {
204 scheduler, frontendClient, querierClient := setupScheduler(t, nil, false)
205
206 frontendLoop := initFrontendLoop(t, frontendClient, "frontend-12345")
207 frontendToScheduler(t, frontendLoop, &schedulerpb.FrontendToScheduler{
208 Type: schedulerpb.ENQUEUE,
209 QueryID: 1,
210 UserID: "test",
211 HttpRequest: &httpgrpc.HTTPRequest{Method: "GET", Url: "/hello"},
212 })
213
214 querierLoop, err := querierClient.QuerierLoop(context.Background())
215 require.NoError(t, err)
216 require.NoError(t, querierLoop.Send(&schedulerpb.QuerierToScheduler{QuerierID: "querier-1"}))
217
218 _, err = querierLoop.Recv()
219 require.NoError(t, err)
220
221 // At this point, scheduler assumes that querier is processing the request (until it receives empty QuerierToScheduler message back).
222 // Simulate frontend disconnect.
223 require.NoError(t, frontendLoop.CloseSend())
224
225 // Add a little sleep to make sure that scheduler notices frontend disconnect.
226 time.Sleep(500 * time.Millisecond)
227
228 // Report back end of request processing. This should return error, since the QuerierLoop call has finished on scheduler.
229 // Note: testing on querierLoop.Context() cancellation didn't work :(
230 err = querierLoop.Send(&schedulerpb.QuerierToScheduler{})
231 require.Error(t, err)
232
233 verifyNoPendingRequestsLeft(t, scheduler)
234}
235
236func TestTracingContext(t *testing.T) {
237 scheduler, frontendClient, _ := setupScheduler(t, nil, false)

Callers

nothing calls this directly

Calls 9

setupSchedulerFunction · 0.85
initFrontendLoopFunction · 0.85
frontendToSchedulerFunction · 0.85
QuerierLoopMethod · 0.65
SendMethod · 0.65
RecvMethod · 0.65
CloseSendMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected