(t *testing.T)
| 211 | } |
| 212 | |
| 213 | func TestBlockRetentionOverrideDisabled(t *testing.T) { |
| 214 | tempDir := t.TempDir() |
| 215 | |
| 216 | r, w, c, err := New(&Config{ |
| 217 | Backend: backend.Local, |
| 218 | Local: &local.Config{ |
| 219 | Path: path.Join(tempDir, "traces"), |
| 220 | }, |
| 221 | Block: &common.BlockConfig{ |
| 222 | BloomFP: 0.01, |
| 223 | BloomShardSizeBytes: 100_000, |
| 224 | Version: encoding.DefaultEncoding().Version(), |
| 225 | }, |
| 226 | WAL: &wal.Config{ |
| 227 | Filepath: path.Join(tempDir, "wal"), |
| 228 | }, |
| 229 | BlocklistPoll: 0, |
| 230 | }, nil, log.NewNopLogger()) |
| 231 | require.NoError(t, err) |
| 232 | |
| 233 | overrides := &mockOverrides{ |
| 234 | disabled: true, |
| 235 | } |
| 236 | |
| 237 | ctx := context.Background() |
| 238 | err = c.EnableCompaction(ctx, &CompactorConfig{ |
| 239 | MaxCompactionRange: time.Hour, |
| 240 | BlockRetention: time.Hour, |
| 241 | CompactedBlockRetention: 0, |
| 242 | }, &mockSharder{}, overrides) |
| 243 | require.NoError(t, err) |
| 244 | |
| 245 | r.EnablePolling(ctx, &mockJobSharder{}, false) |
| 246 | |
| 247 | cutTestBlocks(t, w, testTenantID, 10, 10) |
| 248 | |
| 249 | // The test spans are all 1 second long, so we have to sleep to put all the |
| 250 | // data in the past |
| 251 | time.Sleep(time.Second) |
| 252 | |
| 253 | rw := r.(*readerWriter) |
| 254 | rw.pollBlocklist(ctx) |
| 255 | require.Equal(t, 10, len(rw.blocklist.Metas(testTenantID))) |
| 256 | |
| 257 | time.Sleep(10 * time.Millisecond) |
| 258 | |
| 259 | // Retention = 1ns, deletes everything |
| 260 | overrides.blockRetention = time.Nanosecond |
| 261 | r.(*readerWriter).doRetention(ctx) |
| 262 | rw.pollBlocklist(ctx) |
| 263 | require.Equal(t, 10, len(rw.blocklist.Metas(testTenantID))) |
| 264 | } |
| 265 | |
| 266 | func TestRetainWithConfig(t *testing.T) { |
| 267 | for _, enc := range encoding.AllEncodingsForWrites() { |
nothing calls this directly
no test coverage detected