Skip to content

Commit c053aa6

Browse files
committed
Add some logs to help debug test flaking with timeouts
1 parent da45161 commit c053aa6

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

tests/contrib/test_opentelemetry.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,21 +588,28 @@ async def test_opentelemetry_safe_detach(client: Client):
588588

589589
with LogCapturer().logs_captured(opentelemetry.context.logger) as capturer:
590590
try:
591+
print("===== in detach test")
591592
handle = await client.start_workflow(
592593
CacheEvictionTearDownWorkflow.run,
593594
id=f"wf-{uuid.uuid4()}",
594595
task_queue=worker.task_queue,
595596
)
596597

597598
# CacheEvictionTearDownWorkflow requires 3 signals to be sent
599+
print("===== signal 1")
598600
await handle.signal(CacheEvictionTearDownWorkflow.signal)
601+
print("===== signal 2")
599602
await handle.signal(CacheEvictionTearDownWorkflow.signal)
603+
print("===== signal 3")
600604
await handle.signal(CacheEvictionTearDownWorkflow.signal)
601605

606+
print("===== awaiting result")
602607
await handle.result()
603608
finally:
604609
sys.unraisablehook = old_hook
605610

611+
print("===== inspecting logs")
612+
606613
# Confirm at least 1 exception
607614
if len(hook_calls) < 1:
608615
logging.warning(
@@ -615,6 +622,6 @@ def otel_context_error(record: logging.LogRecord) -> bool:
615622
and "Failed to detach context" in record.message
616623
)
617624

618-
assert (
619-
capturer.find(otel_context_error) is None
620-
), "Detach from context message should not be logged"
625+
assert capturer.find(otel_context_error) is None, (
626+
"Detach from context message should not be logged"
627+
)

tests/helpers/cache_eviction.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,23 @@ async def run(self) -> None:
4646
# Let's also start something in the background that we never wait on
4747
asyncio.create_task(asyncio.sleep(1000))
4848
try:
49+
print("----- in evict workflow")
4950
# Wait for signal count to reach 2
5051
await asyncio.sleep(0.01)
52+
print("----- waiting for signal")
5153
await workflow.wait_condition(lambda: self._signal_count > 1)
5254
finally:
5355
# This finally, on eviction, is actually called but the command
5456
# should be ignored
57+
print("----- sleeping")
5558
await asyncio.sleep(0.01)
59+
print("----- waiting for signals 2 & 3")
5660
await workflow.wait_condition(lambda: self._signal_count > 2)
5761
# Cancel gather tasks and wait on them, but ignore the errors
5862
for task in tasks:
5963
task.cancel()
64+
65+
print("----- evict workflow ending")
6066
await gather_fut
6167

6268
@workflow.signal

0 commit comments

Comments
 (0)