From c115f1604a294ec60a839526e33a2d62c0a4667e Mon Sep 17 00:00:00 2001 From: Hendrik Makait Date: Tue, 8 Nov 2022 17:31:39 +0100 Subject: [PATCH 1/2] Improve test with parametrization --- distributed/tests/test_steal.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/distributed/tests/test_steal.py b/distributed/tests/test_steal.py index 4c69b24e7f..55db82c6bf 100644 --- a/distributed/tests/test_steal.py +++ b/distributed/tests/test_steal.py @@ -1371,14 +1371,24 @@ def func(*args): assert (ntasks_per_worker < ideal * 1.5).all(), (ideal, ntasks_per_worker) -def test_balance_steal_communication_heavy_tasks(): - dependencies = {"a": 10, "b": 10} +@pytest.mark.parametrize( + "cost, ntasks, expect_steal", + [ + pytest.param(10, 5, False, id="not enough work to steal"), + pytest.param(10, 10, True, id="enough work to steal"), + pytest.param(20, 10, False, id="not enough work for increased price"), + ], +) +def test_balance_expensive_tasks(cost, ntasks, expect_steal): + dependencies = {"a": cost, "b": cost} dependency_placement = [["a"], ["b"]] - task_placement = [[["a", "b"]] * 10, []] + task_placement = [[["a", "b"]] * ntasks, []] def _correct_placement(actual): actual_task_counts = [len(placed) for placed in actual] - return sum(actual_task_counts) == 10 and actual_task_counts[1] > 0 + return sum(actual_task_counts) == ntasks and ( + (actual_task_counts[1] > 0) == expect_steal + ) _run_dependency_balance_test( dependencies, From 5db40eb4e6227806b9bdf766d41b9269e8a58bcd Mon Sep 17 00:00:00 2001 From: Hendrik Makait Date: Tue, 8 Nov 2022 18:14:05 +0100 Subject: [PATCH 2/2] Naming is hard --- distributed/tests/test_steal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributed/tests/test_steal.py b/distributed/tests/test_steal.py index 55db82c6bf..f0df021cbd 100644 --- a/distributed/tests/test_steal.py +++ b/distributed/tests/test_steal.py @@ -1376,7 +1376,7 @@ def func(*args): [ pytest.param(10, 5, False, id="not enough work to steal"), pytest.param(10, 10, True, id="enough work to steal"), - pytest.param(20, 10, False, id="not enough work for increased price"), + pytest.param(20, 10, False, id="not enough work for increased cost"), ], ) def test_balance_expensive_tasks(cost, ntasks, expect_steal):