MCPcopy
hub / github.com/grafana/tempo / TestRetry_ClearBlock

Function TestRetry_ClearBlock

tempodb/backend/gcs/gcs_test.go:193–266  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

191}
192
193func TestRetry_ClearBlock(t *testing.T) {
194 var reqCounts sync.Map
195
196 type requestInfo struct {
197 method string
198 count int32
199 }
200
201 server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
202 switch r.URL.Path {
203 case "/b/blerg":
204 _, _ = w.Write([]byte(`{}`))
205 default:
206 // Increment the request count for this path
207
208 val, _ := reqCounts.LoadOrStore(r.URL.Path, &requestInfo{method: r.Method})
209 info := val.(*requestInfo)
210 count := atomic.AddInt32(&info.count, 1)
211
212 // First two requests fail, third succeeds for each path.
213 if count <= 2 {
214 atomic.AddInt32(&count, 1)
215 w.WriteHeader(503)
216 return
217 }
218
219 switch r.Method {
220 case http.MethodDelete:
221 _, _ = w.Write([]byte(`{"done": true}`))
222 case http.MethodGet:
223 _, _ = w.Write([]byte(`
224 {
225 "kind": "storage#objects",
226 "items": [
227 {"name": "tenant/8d1b6283-ec0c-11f0-b403-c4c6e623a3a3/meta.json", "bucket": "blerg", "size": "123"},
228 {"name": "tenant/8d1b6283-ec0c-11f0-b403-c4c6e623a3a3/compacted.meta.json", "bucket": "blerg", "size": "124"}
229 ]
230 }
231 `))
232
233 }
234 }
235 }))
236 server.StartTLS()
237 t.Cleanup(server.Close)
238
239 _, _, c, err := New(&Config{
240 BucketName: "blerg",
241 Insecure: true,
242 Endpoint: server.URL,
243 MaxRetries: 3,
244 })
245 require.NoError(t, err)
246
247 id, err := uuid.NewUUID()
248 require.NoError(t, err)
249
250 require.NoError(t, c.ClearBlock(id, "tenant"))

Callers

nothing calls this directly

Calls 5

NewFunction · 0.70
WriteMethod · 0.65
ClearBlockMethod · 0.65
WriteHeaderMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected