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..d0ce60ad8 --- /dev/null +++ b/tests/worker/test_workflow_worker_config.py @@ -0,0 +1,41 @@ +""" +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.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", + ), +] + + +@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