Skip to content
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

Fix flaky test: increase timeout and relax assertion #1994

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/utils/test_extension_process_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_handle_process_completion_should_return_process_output(self):

def test_handle_process_completion_should_raise_on_timeout(self):
command = "sleep 1m"
timeout = 5
timeout = 20
with tempfile.TemporaryFile(dir=self.tmp_dir, mode="w+b") as stdout:
with tempfile.TemporaryFile(dir=self.tmp_dir, mode="w+b") as stderr:
with patch('time.sleep') as mock_sleep:
Expand All @@ -135,7 +135,9 @@ def test_handle_process_completion_should_raise_on_timeout(self):

# We're mocking sleep to avoid prolonging the test execution time, but we still want to make sure
# we're "waiting" the correct amount of time before killing the process and raising an exception
self.assertEqual(mock_sleep.call_count, timeout)
# Due to an extra call to sleep at some point in the call stack which only happens sometimes,
# we are relaxing this assertion to allow +/- 2 sleep calls.
self.assertTrue(abs(mock_sleep.call_count - timeout) <= 2)

self.assertEqual(context_manager.exception.code, ExtensionErrorCodes.PluginHandlerScriptTimedout)
self.assertIn("Timeout({0})".format(timeout), ustr(context_manager.exception))
Expand Down