(t *testing.T)
| 199 | } |
| 200 | |
| 201 | func TestBlockCleanup(t *testing.T) { |
| 202 | r, w, c, tempDir := testConfig(t, 0) |
| 203 | |
| 204 | err := c.EnableCompaction(context.Background(), &CompactorConfig{ |
| 205 | MaxCompactionRange: time.Hour, |
| 206 | BlockRetention: 0, |
| 207 | CompactedBlockRetention: 0, |
| 208 | }, &mockSharder{}, &mockOverrides{}) |
| 209 | require.NoError(t, err) |
| 210 | |
| 211 | r.EnablePolling(context.Background(), &mockJobSharder{}, false) |
| 212 | |
| 213 | ctx, cancel := context.WithCancel(context.Background()) |
| 214 | defer cancel() |
| 215 | |
| 216 | blockID := backend.NewUUID() |
| 217 | |
| 218 | wal := w.WAL() |
| 219 | |
| 220 | meta := &backend.BlockMeta{BlockID: blockID, TenantID: testTenantID} |
| 221 | head, err := wal.NewBlock(meta, model.CurrentEncoding) |
| 222 | assert.NoError(t, err) |
| 223 | |
| 224 | _, err = w.CompleteBlock(context.Background(), head) |
| 225 | assert.NoError(t, err) |
| 226 | |
| 227 | rw := r.(*readerWriter) |
| 228 | |
| 229 | // poll |
| 230 | rw.pollBlocklist(ctx) |
| 231 | |
| 232 | assert.Len(t, rw.blocklist.Metas(testTenantID), 1) |
| 233 | |
| 234 | os.RemoveAll(tempDir + "/traces/" + testTenantID) |
| 235 | |
| 236 | // poll |
| 237 | rw.pollBlocklist(ctx) |
| 238 | |
| 239 | m := rw.blocklist.Metas(testTenantID) |
| 240 | assert.Equal(t, 0, len(m)) |
| 241 | } |
| 242 | |
| 243 | func checkBlocklists(ctx context.Context, t *testing.T, expectedID uuid.UUID, expectedB int, expectedCB int, rw *readerWriter) { |
| 244 | rw.pollBlocklist(ctx) |
nothing calls this directly
no test coverage detected