From 0b499b1ef815f5e4e232ea62cd801067db6ce950 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Wed, 18 Jun 2025 09:34:18 -0400 Subject: [PATCH 1/2] Run workflow tests with different worker configs --- tests/helpers/__init__.py | 4 ++- tests/worker/test_workflow_worker_config.py | 34 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/worker/test_workflow_worker_config.py diff --git a/tests/helpers/__init__.py b/tests/helpers/__init__.py index a352877d5..9293a9200 100644 --- a/tests/helpers/__init__.py +++ b/tests/helpers/__init__.py @@ -28,6 +28,8 @@ UpdateMethodMultiParam, ) +DEFAULT_WORKER_KWARGS: dict[str, Any] = {} + def new_worker( client: Client, @@ -47,7 +49,7 @@ def new_worker( workflow_runner=workflow_runner, max_cached_workflows=max_cached_workflows, workflow_failure_exception_types=workflow_failure_exception_types, - **kwargs, + **(DEFAULT_WORKER_KWARGS | kwargs), ) diff --git a/tests/worker/test_workflow_worker_config.py b/tests/worker/test_workflow_worker_config.py new file mode 100644 index 000000000..94673bb5d --- /dev/null +++ b/tests/worker/test_workflow_worker_config.py @@ -0,0 +1,34 @@ +""" +Run tests in test_workflow.py with different worker configurations. +""" + +import inspect + +import pytest + +import tests.helpers +import tests.worker.test_workflow as test_workflow_module + +_worker_configs = [ + pytest.param( + { + "max_concurrent_workflow_tasks": 2, + "max_concurrent_workflow_task_polls": 2, + }, + id="max_concurrent_workflow_tasks_2_polls_2", + ), +] + + +@pytest.fixture(scope="module", autouse=True, params=_worker_configs) +def worker_config(request): + original_kwargs = tests.helpers.DEFAULT_WORKER_KWARGS.copy() + tests.helpers.DEFAULT_WORKER_KWARGS.update(request.param) + yield + tests.helpers.DEFAULT_WORKER_KWARGS.clear() + tests.helpers.DEFAULT_WORKER_KWARGS.update(original_kwargs) + + +for name, fn in inspect.getmembers(test_workflow_module, inspect.isfunction): + if name.startswith("test_"): + globals()[name] = fn From 8f62ca831bf07ba26dc5259a1b63817da94ad13e Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Wed, 18 Jun 2025 13:41:52 -0400 Subject: [PATCH 2/2] Add a worker config --- tests/worker/test_workflow_worker_config.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/worker/test_workflow_worker_config.py b/tests/worker/test_workflow_worker_config.py index 94673bb5d..d0ce60ad8 100644 --- a/tests/worker/test_workflow_worker_config.py +++ b/tests/worker/test_workflow_worker_config.py @@ -17,6 +17,13 @@ }, id="max_concurrent_workflow_tasks_2_polls_2", ), + pytest.param( + { + "max_concurrent_workflow_task_polls": 10, + "nonsticky_to_sticky_poll_ratio": 0.5, + }, + id="max_concurrent_workflow_task_polls_10_nonsticky_to_sticky_poll_ratio_0.5", + ), ]