summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorMoustafa Moustafa <momousta@microsoft.com>2020-06-03 13:39:48 -0700
committerGitHub <noreply@github.com>2020-06-03 14:39:48 -0600
commit56f1939061392c848268ae063908bf2188f07373 (patch)
tree180812b5f92f67f820e3700258a7a66ba4c55fca /tests/unittests
parentd53921ea3396c8301c65cad3abf04b4542d4b7a0 (diff)
downloadvyos-cloud-init-56f1939061392c848268ae063908bf2188f07373.tar.gz
vyos-cloud-init-56f1939061392c848268ae063908bf2188f07373.zip
Enhance poll imds logging (#365)
Improving the debugability of this code path by logging the thrown exception details for the non 404 exceptions. Retry IMDS on HTTP Error 404 and 410, re-run DHCP on other exceptions.
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_datasource/test_azure.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
index d8d812e3..b9f4d8fd 100644
--- a/tests/unittests/test_datasource/test_azure.py
+++ b/tests/unittests/test_datasource/test_azure.py
@@ -1951,11 +1951,12 @@ class TestPreprovisioningPollIMDS(CiTestCase):
self.tries += 1
if self.tries == 1:
raise requests.Timeout('Fake connection timeout')
- elif self.tries == 2:
+ elif self.tries in (2, 3):
response = requests.Response()
- response.status_code = 404
+ response.status_code = 404 if self.tries == 2 else 410
raise requests.exceptions.HTTPError(
- "fake 404", response=response)
+ "fake {}".format(response.status_code),
+ response=response)
# Third try should succeed and stop retries or redhcp
return mock.MagicMock(status_code=200, text="good", content="good")
@@ -1967,7 +1968,7 @@ class TestPreprovisioningPollIMDS(CiTestCase):
self.assertEqual(report_ready_func.call_count, 1)
report_ready_func.assert_called_with(lease=lease)
self.assertEqual(3, m_dhcpv4.call_count, 'Expected 3 DHCP calls')
- self.assertEqual(3, self.tries, 'Expected 3 total reads from IMDS')
+ self.assertEqual(4, self.tries, 'Expected 4 total reads from IMDS')
def test_poll_imds_report_ready_false(self,
report_ready_func, fake_resp,