From b85221abd3ea8d5bd8b46861fe46b7c3e5f9d0f0 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Fri, 5 Jun 2026 09:21:04 +0200 Subject: [PATCH 1/3] test: retry flaky webhook E2E test on platform-side timeouts The server Actor blocks until the platform delivers the webhook fired by the client's ACTOR_RUN_SUCCEEDED event, so when delivery is delayed past the run timeout the run ends as TIMED-OUT. Add pytest-rerunfailures and mark test_actor_adds_webhook_and_receives_event with @pytest.mark.flaky(reruns=2) so this platform-side flake is retried rather than failing CI. --- pyproject.toml | 1 + tests/e2e/test_actor_api_helpers.py | 7 +++++++ uv.lock | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index d17bdc01..6985c643 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,6 +78,7 @@ dev = [ "pytest-asyncio<2.0.0", "pytest-cov<8.0.0", "pytest-httpserver<2.0.0", + "pytest-rerunfailures<16.0.0", "pytest-timeout<3.0.0", "pytest-xdist<4.0.0", "pytest<10.0.0", diff --git a/tests/e2e/test_actor_api_helpers.py b/tests/e2e/test_actor_api_helpers.py index 3747dd3b..f086e313 100644 --- a/tests/e2e/test_actor_api_helpers.py +++ b/tests/e2e/test_actor_api_helpers.py @@ -4,6 +4,8 @@ import json from typing import TYPE_CHECKING +import pytest + from apify_shared.consts import ActorPermissionLevel from crawlee._utils.crypto import crypto_random_object_id @@ -387,6 +389,11 @@ async def main() -> None: assert reboot_counter['value'] == 2 +# This E2E test relies on the Apify platform delivering a webhook (fired by the client Actor's `ACTOR_RUN_SUCCEEDED` +# event) to the server Actor's container. The server Actor blocks until that webhook arrives, so when platform-side +# delivery is delayed past the run timeout, the server run ends as `TIMED-OUT` and the test fails. This is a +# platform-timing flake outside the SDK's control, so we retry it a couple of times before giving up. +@pytest.mark.flaky(reruns=2) async def test_actor_adds_webhook_and_receives_event( make_actor: MakeActorFunction, run_actor: RunActorFunction, diff --git a/uv.lock b/uv.lock index e1354c0b..4c325dd7 100644 --- a/uv.lock +++ b/uv.lock @@ -72,6 +72,7 @@ dev = [ { name = "pytest-asyncio" }, { name = "pytest-cov" }, { name = "pytest-httpserver" }, + { name = "pytest-rerunfailures" }, { name = "pytest-timeout" }, { name = "pytest-xdist" }, { name = "ruff" }, @@ -114,6 +115,7 @@ dev = [ { name = "pytest-asyncio", specifier = "<2.0.0" }, { name = "pytest-cov", specifier = "<8.0.0" }, { name = "pytest-httpserver", specifier = "<2.0.0" }, + { name = "pytest-rerunfailures", specifier = "<16.0.0" }, { name = "pytest-timeout", specifier = "<3.0.0" }, { name = "pytest-xdist", specifier = "<4.0.0" }, { name = "ruff", specifier = "~=0.15.0" }, @@ -1927,6 +1929,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ec/df/0bdf90b84c6a586a9fd2b509523a3ab26b1cc1b1dba2fb62a32e4411ea9e/pytest_httpserver-1.1.5-py3-none-any.whl", hash = "sha256:ee83feb587ab652c0c6729598db2820e9048233bac8df756818b7845a1621d0a", size = 23330, upload-time = "2026-02-14T13:27:22.119Z" }, ] +[[package]] +name = "pytest-rerunfailures" +version = "15.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "packaging" }, + { name = "pytest" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a0/78/e6e358545537a8e82c4dc91e72ec0d6f80546a3786dd27c76b06ca09db77/pytest_rerunfailures-15.1.tar.gz", hash = "sha256:c6040368abd7b8138c5b67288be17d6e5611b7368755ce0465dda0362c8ece80", size = 26981, upload-time = "2025-05-08T06:36:33.483Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f3/30/11d836ff01c938969efa319b4ebe2374ed79d28043a12bfc908577aab9f3/pytest_rerunfailures-15.1-py3-none-any.whl", hash = "sha256:f674c3594845aba8b23c78e99b1ff8068556cc6a8b277f728071fdc4f4b0b355", size = 13274, upload-time = "2025-05-08T06:36:32.029Z" }, +] + [[package]] name = "pytest-timeout" version = "2.4.0" From aabd126aad8b4f5e232fc58b18d2f9507fc7c913 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Fri, 5 Jun 2026 09:24:26 +0200 Subject: [PATCH 2/3] chore: allow pytest-rerunfailures <17.0.0 --- pyproject.toml | 2 +- uv.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6985c643..7141802c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,7 @@ dev = [ "pytest-asyncio<2.0.0", "pytest-cov<8.0.0", "pytest-httpserver<2.0.0", - "pytest-rerunfailures<16.0.0", + "pytest-rerunfailures<17.0.0", "pytest-timeout<3.0.0", "pytest-xdist<4.0.0", "pytest<10.0.0", diff --git a/uv.lock b/uv.lock index 4c325dd7..fe11ef14 100644 --- a/uv.lock +++ b/uv.lock @@ -115,7 +115,7 @@ dev = [ { name = "pytest-asyncio", specifier = "<2.0.0" }, { name = "pytest-cov", specifier = "<8.0.0" }, { name = "pytest-httpserver", specifier = "<2.0.0" }, - { name = "pytest-rerunfailures", specifier = "<16.0.0" }, + { name = "pytest-rerunfailures", specifier = "<17.0.0" }, { name = "pytest-timeout", specifier = "<3.0.0" }, { name = "pytest-xdist", specifier = "<4.0.0" }, { name = "ruff", specifier = "~=0.15.0" }, From 7a41aeda1b78d64e73da33e36af6cf0e88359780 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Fri, 5 Jun 2026 09:26:43 +0200 Subject: [PATCH 3/3] test: bump webhook flaky reruns to 3 and trim the comment --- tests/e2e/test_actor_api_helpers.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/e2e/test_actor_api_helpers.py b/tests/e2e/test_actor_api_helpers.py index f086e313..0be7c2b8 100644 --- a/tests/e2e/test_actor_api_helpers.py +++ b/tests/e2e/test_actor_api_helpers.py @@ -389,11 +389,9 @@ async def main() -> None: assert reboot_counter['value'] == 2 -# This E2E test relies on the Apify platform delivering a webhook (fired by the client Actor's `ACTOR_RUN_SUCCEEDED` -# event) to the server Actor's container. The server Actor blocks until that webhook arrives, so when platform-side -# delivery is delayed past the run timeout, the server run ends as `TIMED-OUT` and the test fails. This is a -# platform-timing flake outside the SDK's control, so we retry it a couple of times before giving up. -@pytest.mark.flaky(reruns=2) +# Flaky: the server Actor blocks until the platform delivers the client's `ACTOR_RUN_SUCCEEDED` webhook; when +# delivery is delayed past the run timeout, the run ends as `TIMED-OUT`. Platform-side, outside our control, so retry. +@pytest.mark.flaky(reruns=3) async def test_actor_adds_webhook_and_receives_event( make_actor: MakeActorFunction, run_actor: RunActorFunction,