-
Notifications
You must be signed in to change notification settings - Fork 32
feat: add --wait to racreset #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
093c005
feat: add --wait to racreset
sadsfae f80b915
chore: fix tests, add doc mention
sadsfae f3e118a
chore: further fix test coverage
sadsfae b1db697
chore: add poll_helpers test
sadsfae e1516e6
chore: adust tests and PR feedback, increase default retries to 30.
sadsfae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| import asyncio | ||
| from unittest.mock import MagicMock, patch | ||
| from badfish.main import Badfish | ||
| from tests.test_base import TestBase | ||
|
|
||
|
|
||
| class TestPollHelpers(TestBase): | ||
| @patch("badfish.main.HTTPClient") | ||
| def test_poll_until_ready_timeout(self, mock_http_client): | ||
| logger = MagicMock() | ||
| badfish = Badfish("test-host", "user", "pass", logger, 2) | ||
|
|
||
| async def always_false(): | ||
| return False | ||
|
|
||
| async def run_test(): | ||
| return await badfish.poll_until_ready(always_false, "test service", sleep_interval=0) | ||
|
|
||
| result = asyncio.get_event_loop().run_until_complete(run_test()) | ||
|
|
||
| assert result is False | ||
| logger.warning.assert_called_once_with("test service did not become ready within timeout.") | ||
|
|
||
| @patch("badfish.main.HTTPClient") | ||
| def test_poll_until_ready_success(self, mock_http_client): | ||
| logger = MagicMock() | ||
| badfish = Badfish("test-host", "user", "pass", logger, 5) | ||
|
|
||
| call_count = [0] | ||
|
|
||
| async def check_after_attempts(): | ||
| call_count[0] += 1 | ||
| return call_count[0] >= 3 | ||
|
|
||
| async def run_test(): | ||
| return await badfish.poll_until_ready(check_after_attempts, "test service", sleep_interval=0) | ||
|
|
||
| result = asyncio.get_event_loop().run_until_complete(run_test()) | ||
|
|
||
| assert result is True | ||
| logger.info.assert_any_call("Polling for test service") | ||
| logger.info.assert_any_call("test service is ready.") |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.