Skip to content

Commit d824821

Browse files
authored
Fix flaky TMPRL1104 duration-log assertions in test_extstore (#1628)
1 parent aec285a commit d824821

1 file changed

Lines changed: 14 additions & 28 deletions

File tree

tests/worker/test_extstore.py

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,13 @@ def _tmprl1104_records(capturer: LogCapturer) -> list[logging.LogRecord]:
624624
return capturer.find_all(lambda r: r.getMessage().startswith("[TMPRL1104]"))
625625

626626

627+
# Accept any duration-bucket wording: a loaded host can push a trivial task past 5s.
628+
_TMPRL1104_DURATION_MESSAGE = re.compile(
629+
r"\[TMPRL1104\] [^:]+:\d+:\d+ Workflow task "
630+
r"(?:duration information|exceeded \d+ seconds) \("
631+
)
632+
633+
627634
async def _expected_payload_size(
628635
converter: temporalio.converter.DataConverter, value: object
629636
) -> int:
@@ -655,10 +662,7 @@ async def test_tmprl1104_no_extstore(env: WorkflowEnvironment) -> None:
655662
records = _tmprl1104_records(capturer)
656663
assert len(records) == 1
657664
record = records[0]
658-
assert re.match(
659-
r"\[TMPRL1104\] [^:]+:\d+:\d+ Workflow task duration information \(",
660-
record.getMessage(),
661-
)
665+
assert _TMPRL1104_DURATION_MESSAGE.match(record.getMessage())
662666
assert hasattr(record, "workflow_task_duration")
663667
assert hasattr(record, "event_id")
664668
# No external storage — download/upload fields must be absent
@@ -710,20 +714,14 @@ async def test_tmprl1104_with_extstore_download(env: WorkflowEnvironment) -> Non
710714
assert len(records) == 2
711715

712716
# WFT 1: retrieves the externalized workflow input
713-
assert re.match(
714-
r"\[TMPRL1104\] [^:]+:\d+:\d+ Workflow task duration information \(",
715-
records[0].getMessage(),
716-
)
717+
assert _TMPRL1104_DURATION_MESSAGE.match(records[0].getMessage())
717718
assert getattr(records[0], "payload_download_count") == 1
718719
assert getattr(records[0], "payload_download_size") == expected_input_size
719720
assert getattr(records[0], "payload_download_duration") > timedelta(0)
720721
assert not hasattr(records[0], "payload_upload_count")
721722

722723
# WFT 2: activity result is small — no external storage
723-
assert re.match(
724-
r"\[TMPRL1104\] [^:]+:\d+:\d+ Workflow task duration information \(",
725-
records[1].getMessage(),
726-
)
724+
assert _TMPRL1104_DURATION_MESSAGE.match(records[1].getMessage())
727725
assert not hasattr(records[1], "payload_download_count")
728726
assert not hasattr(records[1], "payload_upload_count")
729727

@@ -768,18 +766,12 @@ async def test_tmprl1104_with_extstore_upload(env: WorkflowEnvironment) -> None:
768766
assert len(records) == 2
769767

770768
# WFT 1: small input — no external storage
771-
assert re.match(
772-
r"\[TMPRL1104\] [^:]+:\d+:\d+ Workflow task duration information \(",
773-
records[0].getMessage(),
774-
)
769+
assert _TMPRL1104_DURATION_MESSAGE.match(records[0].getMessage())
775770
assert not hasattr(records[0], "payload_download_count")
776771
assert not hasattr(records[0], "payload_upload_count")
777772

778773
# WFT 2: workflow returns large result → uploaded
779-
assert re.match(
780-
r"\[TMPRL1104\] [^:]+:\d+:\d+ Workflow task duration information \(",
781-
records[1].getMessage(),
782-
)
774+
assert _TMPRL1104_DURATION_MESSAGE.match(records[1].getMessage())
783775
assert not hasattr(records[1], "payload_download_count")
784776
assert getattr(records[1], "payload_upload_count") == 1
785777
assert getattr(records[1], "payload_upload_size") == expected_output_size
@@ -830,20 +822,14 @@ async def test_tmprl1104_with_extstore_download_and_upload(
830822
assert len(records) == 2
831823

832824
# WFT 1: retrieves externalized workflow input
833-
assert re.match(
834-
r"\[TMPRL1104\] [^:]+:\d+:\d+ Workflow task duration information \(",
835-
records[0].getMessage(),
836-
)
825+
assert _TMPRL1104_DURATION_MESSAGE.match(records[0].getMessage())
837826
assert getattr(records[0], "payload_download_count") == 1
838827
assert getattr(records[0], "payload_download_size") == expected_input_size
839828
assert getattr(records[0], "payload_download_duration") > timedelta(0)
840829
assert not hasattr(records[0], "payload_upload_count")
841830

842831
# WFT 2: uploads externalized workflow result
843-
assert re.match(
844-
r"\[TMPRL1104\] [^:]+:\d+:\d+ Workflow task duration information \(",
845-
records[1].getMessage(),
846-
)
832+
assert _TMPRL1104_DURATION_MESSAGE.match(records[1].getMessage())
847833
assert not hasattr(records[1], "payload_download_count")
848834
assert getattr(records[1], "payload_upload_count") == 1
849835
assert getattr(records[1], "payload_upload_size") == expected_output_size

0 commit comments

Comments
 (0)