From 645b18404e0dcc293c56bcbe42991c86dea48411 Mon Sep 17 00:00:00 2001 From: Hendrik Makait Date: Fri, 28 Jul 2023 19:04:51 +0200 Subject: [PATCH] Make test dynamic wrt to CPU count --- distributed/deploy/tests/test_adaptive.py | 25 +++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/distributed/deploy/tests/test_adaptive.py b/distributed/deploy/tests/test_adaptive.py index 68a6179c5d..0f0818bff9 100644 --- a/distributed/deploy/tests/test_adaptive.py +++ b/distributed/deploy/tests/test_adaptive.py @@ -315,19 +315,26 @@ async def _test(): adapt = cluster.adapt( interval="20ms", minimum=2, target_duration=target_duration ) + # FIXME: LocalCluster is starting workers with CPU_COUNT threads + # each + # The default target duration is set to 1s + max_scaleup = 5 + n_tasks = target_duration * dask.system.CPU_COUNT * max_scaleup async with Client(cluster, asynchronous=True) as client: await client.wait_for_workers(2) - futures = client.map(slowinc, range(100), delay=0.3) + futures = client.map(slowinc, range(n_tasks), delay=0.3) await wait(futures) - # FIXME: LocalCluster is starting workers with CPU_COUNT threads - # each - max_expected = math.ceil(100 / target_duration / dask.system.CPU_COUNT) - _max_scaleup = max(msg[1].get("n", -1) for msg in adapt.log) - _min_scaleup = min(msg[1].get("n", math.inf) for msg in adapt.log) - assert _max_scaleup <= max_expected - assert _max_scaleup > 2 - assert _min_scaleup >= 2 + scaleup_recommendations = [ + msg[1]["n"] for msg in adapt.log if msg[1].get("status") == "up" + ] + + assert ( + 2 + <= min(scaleup_recommendations) + < max(scaleup_recommendations) + <= max_scaleup + ) _test()