(t *testing.T)
| 285 | } |
| 286 | |
| 287 | func TestCutIdleTracesRespectsMaxBlockBytes(t *testing.T) { |
| 288 | inst, ls := defaultInstance(t) |
| 289 | |
| 290 | inst.Cfg.MaxBlockBytes = 5 * 1024 * 1024 // 5 Mb |
| 291 | |
| 292 | // Push enough traces to require multiple blocks. |
| 293 | traceCount := 100 // that will be around 119Mb |
| 294 | traceIDs := make([][]byte, 0, traceCount) |
| 295 | traces := make([]*tempopb.Trace, 0, traceCount) |
| 296 | |
| 297 | for range traceCount { |
| 298 | id := test.ValidTraceID(nil) |
| 299 | tr := test.MakeTraceWithSpanCount(50, 100, id) |
| 300 | pushTrace(t.Context(), t, inst, tr, id) |
| 301 | traceIDs = append(traceIDs, id) |
| 302 | traces = append(traces, tr) |
| 303 | } |
| 304 | |
| 305 | ls.cutOneInstanceToWal(t.Context(), inst, true) |
| 306 | for i := 0; i < traceCount; i += 5 { |
| 307 | requireTraceInLiveStore(t, ls, traceIDs[i], traces[i]) |
| 308 | } |
| 309 | |
| 310 | // Verify no WAL block exceeds MaxBlockBytes. |
| 311 | walBlocksNum := len(inst.blocks.Load().walBlocks) |
| 312 | assert.Greater(t, walBlocksNum, 2, "expected multiple WAL blocks") |
| 313 | for id, blk := range inst.blocks.Load().walBlocks { |
| 314 | // block size estimation can be x5 off, so we check that that block size at least makes sense |
| 315 | assert.LessOrEqual(t, blk.DataLength(), inst.Cfg.MaxBlockBytes*5, |
| 316 | "WAL block %s exceeds MaxBlockBytes: %d > %d", id, blk.DataLength(), inst.Cfg.MaxBlockBytes) |
| 317 | } |
| 318 | |
| 319 | // with no new traces, number of WAL blocks should not increase after another cut to WAL |
| 320 | ls.cutOneInstanceToWal(t.Context(), inst, true) |
| 321 | assert.Equal(t, walBlocksNum, len(inst.blocks.Load().walBlocks), "expected no new WAL blocks after cut to WAL with no new traces") |
| 322 | |
| 323 | require.NoError(t, services.StopAndAwaitTerminated(t.Context(), ls)) |
| 324 | } |
nothing calls this directly
no test coverage detected