-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add two new flock config parameters to let us start monkeys in batches with waits in between: * `start_batch_size`: the number of monkeys to start in each batch * `start_batch_wait`: the amount of time to wait in between starting batches
- Loading branch information
Showing
6 changed files
with
250 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### New features | ||
|
||
- Add `start_batch_size` and `start_batch_wait` flock config parameters to allow starting monkeys in a more slow and controlled way. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Tests for flock functionality.""" | ||
|
||
from time import perf_counter | ||
|
||
import pytest | ||
import respx | ||
from httpx import AsyncClient | ||
|
||
from ..support.gafaelfawr import mock_gafaelfawr | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_batched_start( | ||
client: AsyncClient, | ||
respx_mock: respx.Router, | ||
) -> None: | ||
mock_gafaelfawr(respx_mock) | ||
|
||
# Set up our mocked business. This will wait for all batches to have | ||
# attempted to start. | ||
start = perf_counter() | ||
r = await client.put( | ||
"/mobu/flocks", | ||
json={ | ||
"name": "test", | ||
"count": 10, | ||
"start_batch_size": 3, | ||
"start_batch_wait": "1s", | ||
"user_spec": {"username_prefix": "bot-mobu-testuser"}, | ||
"scopes": ["exec:notebook"], | ||
"business": { | ||
"type": "EmptyLoop", | ||
}, | ||
}, | ||
) | ||
end = perf_counter() | ||
|
||
assert r.status_code == 201 | ||
|
||
# Make sure it took at least as much time as the total of the waits | ||
elapsed = end - start | ||
assert elapsed > 3 |