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

Function TestFrontendRetryEnqueue

pkg/frontend/v2/frontend_test.go:150–174  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func TestFrontendRetryEnqueue(t *testing.T) {
151 // Frontend uses worker concurrency to compute number of retries. We use one less failure.
152 failures := atomic.NewInt64(testFrontendWorkerConcurrency - 1)
153 const (
154 body = "hello world"
155 userID = "test"
156 )
157
158 f, _ := setupFrontend(t, func(f *Frontend, msg *schedulerpb.FrontendToScheduler) *schedulerpb.SchedulerToFrontend {
159 fail := failures.Dec()
160 if fail >= 0 {
161 return &schedulerpb.SchedulerToFrontend{Status: schedulerpb.SHUTTING_DOWN}
162 }
163
164 go sendResponseWithDelay(f, 100*time.Millisecond, userID, msg.QueryID, &httpgrpc.HTTPResponse{
165 Code: 200,
166 Body: []byte(body),
167 })
168
169 return &schedulerpb.SchedulerToFrontend{Status: schedulerpb.OK}
170 }, 0)
171
172 _, err := f.RoundTripGRPC(user.InjectOrgID(context.Background(), userID), &httpgrpc.HTTPRequest{})
173 require.NoError(t, err)
174}
175
176func TestFrontendEnqueueFailure(t *testing.T) {
177 f, _ := setupFrontend(t, func(f *Frontend, msg *schedulerpb.FrontendToScheduler) *schedulerpb.SchedulerToFrontend {

Callers

nothing calls this directly

Calls 4

sendResponseWithDelayFunction · 0.85
DecMethod · 0.80
setupFrontendFunction · 0.70
RoundTripGRPCMethod · 0.65

Tested by

no test coverage detected