(t *testing.T)
| 150 | } |
| 151 | |
| 152 | func TestBlockRetentionOverride(t *testing.T) { |
| 153 | tempDir := t.TempDir() |
| 154 | |
| 155 | r, w, c, err := New(&Config{ |
| 156 | Backend: backend.Local, |
| 157 | Local: &local.Config{ |
| 158 | Path: path.Join(tempDir, "traces"), |
| 159 | }, |
| 160 | Block: &common.BlockConfig{ |
| 161 | BloomFP: 0.01, |
| 162 | BloomShardSizeBytes: 100_000, |
| 163 | Version: encoding.DefaultEncoding().Version(), |
| 164 | }, |
| 165 | WAL: &wal.Config{ |
| 166 | Filepath: path.Join(tempDir, "wal"), |
| 167 | }, |
| 168 | BlocklistPoll: 0, |
| 169 | }, nil, log.NewNopLogger()) |
| 170 | require.NoError(t, err) |
| 171 | |
| 172 | overrides := &mockOverrides{} |
| 173 | |
| 174 | ctx := context.Background() |
| 175 | err = c.EnableCompaction(ctx, &CompactorConfig{ |
| 176 | MaxCompactionRange: time.Hour, |
| 177 | BlockRetention: time.Hour, |
| 178 | CompactedBlockRetention: 0, |
| 179 | }, &mockSharder{}, overrides) |
| 180 | require.NoError(t, err) |
| 181 | |
| 182 | r.EnablePolling(ctx, &mockJobSharder{}, false) |
| 183 | |
| 184 | cutTestBlocks(t, w, testTenantID, 10, 10) |
| 185 | |
| 186 | // The test spans are all 1 second long, so we have to sleep to put all the |
| 187 | // data in the past |
| 188 | time.Sleep(time.Second) |
| 189 | |
| 190 | rw := r.(*readerWriter) |
| 191 | rw.pollBlocklist(ctx) |
| 192 | require.Equal(t, 10, len(rw.blocklist.Metas(testTenantID))) |
| 193 | |
| 194 | // Retention = 1 hour, does nothing |
| 195 | overrides.blockRetention = time.Hour |
| 196 | r.(*readerWriter).doRetention(ctx) |
| 197 | rw.pollBlocklist(ctx) |
| 198 | require.Equal(t, 10, len(rw.blocklist.Metas(testTenantID))) |
| 199 | |
| 200 | // Retention = 1 minute, still does nothing |
| 201 | overrides.blockRetention = time.Minute |
| 202 | r.(*readerWriter).doRetention(ctx) |
| 203 | rw.pollBlocklist(ctx) |
| 204 | require.Equal(t, 10, len(rw.blocklist.Metas(testTenantID))) |
| 205 | |
| 206 | // Retention = 1ns, deletes everything |
| 207 | overrides.blockRetention = time.Nanosecond |
| 208 | r.(*readerWriter).doRetention(ctx) |
| 209 | rw.pollBlocklist(ctx) |
nothing calls this directly
no test coverage detected