Skip to content

Commit 54eeb5e

Browse files
test(eval): pin BatchSpanProcessor's schedule delay to avoid test flakiness
Copilot review comment: ExecutionSpanProcessor is a real BatchSpanProcessor with its own background worker thread, which auto-flushes every 5s by default (or when its queue fills). Tests asserting "not yet exported at this exact moment" could in principle flake if that worker thread woke up and exported on its own between a span ending and the assertion running. Push the processor's schedule delay to 1 hour right after construction so only the explicit force_flush() calls in these tests ever export anything, removing the wall-clock dependency entirely rather than relying on the worker thread simply not winning the race in practice. Co-Authored-By: Claude Sonnet 5 <[email protected]>
1 parent 7552722 commit 54eeb5e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

packages/uipath/tests/cli/eval/test_execution_span_race.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ def _make_processor() -> tuple[
5151
collector = ExecutionSpanCollector()
5252
processor = ExecutionSpanProcessor(exporter, collector)
5353

54+
# ExecutionSpanProcessor is a real BatchSpanProcessor with its default
55+
# 5s periodic auto-flush running on its own background thread. These
56+
# tests assert that a span is *not yet* exported at a specific moment,
57+
# so that background thread waking up and exporting on its own between
58+
# the span ending and the assertion would make the test flaky. Push its
59+
# schedule delay far beyond any test's runtime so only the explicit
60+
# `force_flush()` calls below ever export anything.
61+
batch_processor = processor._batch_processor
62+
batch_processor._schedule_delay_millis = 3600_000
63+
batch_processor._schedule_delay = 3600.0
64+
5465
provider = TracerProvider()
5566
provider.add_span_processor(processor)
5667
tracer = provider.get_tracer("test")

0 commit comments

Comments
 (0)