Skip to content

Commit

Permalink
Make test dynamic wrt to CPU count
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmakait committed Jul 28, 2023
1 parent a977aa7 commit 645b184
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions distributed/deploy/tests/test_adaptive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 645b184

Please sign in to comment.