TestSameIDCompaction is a bit gross in that it has a bad dependency with on the /pkg/model module to do a full e2e compaction/combination test.
(t *testing.T, targetBlockVersion string)
| 227 | // TestSameIDCompaction is a bit gross in that it has a bad dependency with on the /pkg/model |
| 228 | // module to do a full e2e compaction/combination test. |
| 229 | func testSameIDCompaction(t *testing.T, targetBlockVersion string) { |
| 230 | tempDir := t.TempDir() |
| 231 | |
| 232 | r, w, c, err := New(&Config{ |
| 233 | Backend: backend.Local, |
| 234 | Pool: &pool.Config{ |
| 235 | MaxWorkers: 10, |
| 236 | QueueDepth: 100, |
| 237 | }, |
| 238 | Local: &local.Config{ |
| 239 | Path: path.Join(tempDir, "traces"), |
| 240 | }, |
| 241 | Block: &common.BlockConfig{ |
| 242 | BloomFP: .01, |
| 243 | BloomShardSizeBytes: 100_000, |
| 244 | Version: targetBlockVersion, |
| 245 | RowGroupSizeBytes: 30_000_000, |
| 246 | }, |
| 247 | WAL: &wal.Config{ |
| 248 | Filepath: path.Join(tempDir, "wal"), |
| 249 | }, |
| 250 | BlocklistPoll: 0, |
| 251 | }, nil, log.NewNopLogger()) |
| 252 | require.NoError(t, err) |
| 253 | |
| 254 | ctx := context.Background() |
| 255 | err = c.EnableCompaction(ctx, &CompactorConfig{ |
| 256 | MaxCompactionRange: 24 * time.Hour, |
| 257 | BlockRetention: 0, |
| 258 | CompactedBlockRetention: 0, |
| 259 | }, &mockSharder{}, &mockOverrides{}) |
| 260 | require.NoError(t, err) |
| 261 | |
| 262 | r.EnablePolling(ctx, &mockJobSharder{}, true) |
| 263 | |
| 264 | wal := w.WAL() |
| 265 | require.NoError(t, err) |
| 266 | |
| 267 | dec := model.MustNewSegmentDecoder(v1.Encoding) |
| 268 | |
| 269 | blockCount := 5 |
| 270 | recordCount := 100 |
| 271 | |
| 272 | // make a bunch of sharded requests |
| 273 | allReqs := make([][][]byte, 0, recordCount) |
| 274 | allIDs := make([][]byte, 0, recordCount) |
| 275 | sharded := 0 |
| 276 | for i := 0; i < recordCount; i++ { |
| 277 | id := test.ValidTraceID(nil) |
| 278 | |
| 279 | requestShards := rand.Intn(blockCount) + 1 |
| 280 | reqs := make([][]byte, 0, requestShards) |
| 281 | for j := 0; j < requestShards; j++ { |
| 282 | buff, err := dec.PrepareForWrite(test.MakeTrace(1, id), 0, 0) |
| 283 | require.NoError(t, err) |
| 284 | |
| 285 | buff2, err := dec.ToObject([][]byte{buff}) |
| 286 | require.NoError(t, err) |
no test coverage detected