MCPcopy
hub / github.com/grafana/tempo / TestInstanceWALBackpressure

Function TestInstanceWALBackpressure

modules/livestore/instance_test.go:257–285  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

255}
256
257func 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
287func TestCutIdleTracesRespectsMaxBlockBytes(t *testing.T) {
288 inst, ls := defaultInstance(t)

Callers

nothing calls this directly

Calls 9

ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
defaultInstanceFunction · 0.85
pushTraceFunction · 0.85
cutIdleTracesMethod · 0.80
cutBlocksMethod · 0.80
backpressureMethod · 0.80
ContextMethod · 0.65
createWALBlockFunction · 0.50

Tested by

no test coverage detected