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

Function TestRetry_MarkBlockCompacted

tempodb/backend/gcs/gcs_test.go:149–191  ·  tempodb/backend/gcs/gcs_test.go::TestRetry_MarkBlockCompacted
(t *testing.T)

Source from the content-addressed store, hash-verified

147}
148
149func TestRetry_MarkBlockCompacted(t *testing.T) {
150 var reqCounts sync.Map
151
152 server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
153 switch r.URL.Path {
154 case "/b/blerg":
155 _, _ = w.Write([]byte(`{}`))
156 default:
157 val, _ := reqCounts.LoadOrStore(r.URL.Path, &atomic.Int32{})
158 if atomicCounter, ok := val.(*atomic.Int32); ok {
159 atomicCounter.Add(1)
160 }
161
162 // First two requests fail, third succeeds for each path.
163 if val.(*atomic.Int32).Load() <= 2 {
164 w.WriteHeader(503)
165 return
166 }
167 _, _ = w.Write([]byte(`{"done": true}`))
168 }
169 }))
170 server.StartTLS()
171 t.Cleanup(server.Close)
172
173 _, _, c, err := New(&Config{
174 BucketName: "blerg",
175 Insecure: true,
176 Endpoint: server.URL,
177 MaxRetries: 3,
178 })
179 require.NoError(t, err)
180
181 id, err := uuid.NewUUID()
182 require.NoError(t, err)
183
184 require.NoError(t, c.MarkBlockCompacted(id, "tenant"))
185
186 reqCounts.Range(func(key, value any) bool {
187 urlPath := key.(string)
188 require.Equal(t, int32(3), value.(*atomic.Int32).Load(), "should attempt 3 times for %s", urlPath)
189 return true
190 })
191}
192
193func TestRetry_ClearBlock(t *testing.T) {
194 var reqCounts sync.Map

Callers

nothing calls this directly

Calls 6

NewFunction · 0.70
WriteMethod · 0.65
AddMethod · 0.65
MarkBlockCompactedMethod · 0.65
WriteHeaderMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected