Skip to content

Commit 98641e1

Browse files
test(profiling): try to unflake test_resource_not_collected (#16280)
## Description This is an attempt at making a test less flaky (not sure why it's flaky to be honest, so hard to fix for real). Also, drive-by change to make a test print samples on failure for future debugging/unflaking.
1 parent a158707 commit 98641e1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tests/profiling/collector/test_asyncio_weak_links.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def loc(fn: str, file: str = "", line: int = -1) -> pprof_utils.StackLocation:
7878
# loc("Task-1"),
7979
],
8080
),
81+
print_samples_on_failure=True,
8182
)
8283

8384
# We should see a stack for Task-1 / parent / Task-awaited / awaited / sleep
@@ -96,4 +97,5 @@ def loc(fn: str, file: str = "", line: int = -1) -> pprof_utils.StackLocation:
9697
# loc("Task-1"),
9798
],
9899
),
100+
print_samples_on_failure=True,
99101
)

tests/profiling/collector/test_stack.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,10 +828,13 @@ def test_resource_not_collected(tmp_path: Path, tracer: Tracer) -> None:
828828
ddup.upload()
829829

830830
with stack.StackCollector(tracer=tracer):
831+
# Give the Profiler some time to start
832+
time.sleep(0.1)
833+
831834
resource = str(uuid.uuid4())
832835
span_type = ext.SpanTypes.WEB
833836
with tracer.start_span("foobar", activate=True, resource=resource, span_type=span_type) as span:
834-
_fib(28)
837+
_fib(35)
835838

836839
ddup.upload(tracer=tracer)
837840

@@ -847,7 +850,7 @@ def test_resource_not_collected(tmp_path: Path, tracer: Tracer) -> None:
847850
pprof_utils.StackLocation(
848851
filename=os.path.basename(__file__),
849852
function_name=test_name,
850-
line_no=test_resource_not_collected.__code__.co_firstlineno + 14,
853+
line_no=test_resource_not_collected.__code__.co_firstlineno + 17,
851854
)
852855
],
853856
),

0 commit comments

Comments
 (0)