(t *testing.T)
| 148 | } |
| 149 | |
| 150 | func 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 | |
| 176 | func TestFrontendEnqueueFailure(t *testing.T) { |
| 177 | f, _ := setupFrontend(t, func(f *Frontend, msg *schedulerpb.FrontendToScheduler) *schedulerpb.SchedulerToFrontend { |
nothing calls this directly
no test coverage detected