(t *testing.T)
| 255 | } |
| 256 | |
| 257 | func TestInstanceWALBackpressure(t *testing.T) { |
| 258 | inst, ls := defaultInstance(t) |
| 259 | // Disable live traces backpressure so we only test WAL backpressure. |
| 260 | inst.Cfg.MaxLiveTracesBytes = 0 |
| 261 | |
| 262 | // Build up WAL blocks: push a trace, flush to head, cut to WAL. |
| 263 | createWALBlock := func() { |
| 264 | id := test.ValidTraceID(nil) |
| 265 | pushTrace(t.Context(), t, inst, test.MakeTrace(1, id), id) |
| 266 | drained, cutErr := inst.cutIdleTraces(t.Context(), true) |
| 267 | require.NoError(t, cutErr) |
| 268 | require.True(t, drained, "should drain live traces in one iteration") |
| 269 | walID, err := inst.cutBlocks(t.Context(), true) |
| 270 | require.NoError(t, err) |
| 271 | require.NotEqual(t, walID, [16]byte{}) |
| 272 | } |
| 273 | |
| 274 | // At the limit, no backpressure. |
| 275 | for range walBackpressureLimit { |
| 276 | createWALBlock() |
| 277 | } |
| 278 | require.False(t, inst.backpressure(t.Context()), "expected no backpressure at %d WAL blocks", walBackpressureLimit) |
| 279 | |
| 280 | // One more WAL block should trigger backpressure. |
| 281 | createWALBlock() |
| 282 | require.True(t, inst.backpressure(t.Context()), "expected backpressure at %d WAL blocks", walBackpressureLimit+1) |
| 283 | |
| 284 | require.NoError(t, services.StopAndAwaitTerminated(t.Context(), ls)) |
| 285 | } |
| 286 | |
| 287 | func TestCutIdleTracesRespectsMaxBlockBytes(t *testing.T) { |
| 288 | inst, ls := defaultInstance(t) |
nothing calls this directly
no test coverage detected