diff options
author | Julia Kreger <juliaashleykreger@gmail.com> | 2020-06-16 16:45:43 -0700 |
---|---|---|
committer | Julia Kreger <juliaashleykreger@gmail.com> | 2020-06-23 20:27:41 +0000 |
commit | 159ab9f0ce7bec756f77bcec49331d0eefdd78f2 (patch) | |
tree | 5888e5074e8859a5c3e087e995d833de7cf8af6e /ironic_python_agent/tests | |
parent | c5b97eb781cf9851f9abe87a1500b4da55b8bde8 (diff) | |
download | ironic-python-agent-159ab9f0ce7bec756f77bcec49331d0eefdd78f2.tar.gz |
Add full download retries
Instead of just trying to get the connection and handler
for the download, lets try to retry the whole action of
of downloading.
Change-Id: I9217792d32e6f33c70f146a9b7d3ef58c5644d8a
Diffstat (limited to 'ironic_python_agent/tests')
-rw-r--r-- | ironic_python_agent/tests/unit/extensions/test_standby.py | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/ironic_python_agent/tests/unit/extensions/test_standby.py b/ironic_python_agent/tests/unit/extensions/test_standby.py index 5f88ffa8..05e39d94 100644 --- a/ironic_python_agent/tests/unit/extensions/test_standby.py +++ b/ironic_python_agent/tests/unit/extensions/test_standby.py @@ -1186,6 +1186,8 @@ class TestStandbyExtension(base.IronicAgentTest): @mock.patch('requests.get', autospec=True) def test_stream_raw_image_onto_device_write_error(self, requests_mock, open_mock, md5_mock): + self.config(image_download_connection_timeout=1) + self.config(image_download_connection_retry_interval=0) image_info = _build_fake_image_info() response = requests_mock.return_value response.status_code = 200 @@ -1199,12 +1201,20 @@ class TestStandbyExtension(base.IronicAgentTest): self.assertRaises(errors.ImageDownloadError, self.agent_extension._stream_raw_image_onto_device, image_info, '/dev/foo') - requests_mock.assert_called_once_with(image_info['urls'][0], - cert=None, verify=True, - stream=True, proxies={}, - timeout=60) - # Assert write was only called once and failed! - file_mock.write.assert_called_once_with('some') + calls = [mock.call('http://example.org', cert=None, proxies={}, + stream=True, timeout=1, verify=True), + mock.call().iter_content(mock.ANY), + mock.call('http://example.org', cert=None, proxies={}, + stream=True, timeout=1, verify=True), + mock.call().iter_content(mock.ANY), + mock.call('http://example.org', cert=None, proxies={}, + stream=True, timeout=1, verify=True), + mock.call().iter_content(mock.ANY)] + requests_mock.assert_has_calls(calls) + write_calls = [mock.call('some'), + mock.call('some'), + mock.call('some')] + file_mock.write.assert_has_calls(write_calls) @mock.patch('ironic_lib.disk_utils.fix_gpt_partition', autospec=True) @mock.patch('hashlib.md5', autospec=True) @@ -1238,6 +1248,7 @@ class TestStandbyExtension(base.IronicAgentTest): return self self.config(image_download_connection_timeout=1) + self.config(image_download_connection_retry_interval=0) image_info = _build_fake_image_info() file_mock = mock.Mock() open_mock.return_value.__enter__.return_value = file_mock @@ -1250,11 +1261,19 @@ class TestStandbyExtension(base.IronicAgentTest): self.agent_extension._stream_raw_image_onto_device, image_info, '/dev/foo') - requests_mock.assert_called_once_with(image_info['urls'][0], - cert=None, verify=True, - stream=True, proxies={}, - timeout=1) - file_mock.write.assert_called_once_with('meow') + + calls = [mock.call(image_info['urls'][0], cert=None, verify=True, + stream=True, proxies={}, timeout=1), + mock.call(image_info['urls'][0], cert=None, verify=True, + stream=True, proxies={}, timeout=1), + mock.call(image_info['urls'][0], cert=None, verify=True, + stream=True, proxies={}, timeout=1)] + requests_mock.assert_has_calls(calls) + + write_calls = [mock.call('meow'), + mock.call('meow'), + mock.call('meow')] + file_mock.write.assert_has_calls(write_calls) fix_gpt_mock.assert_not_called() def test__message_format_partition_bios(self): |