summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorChris Patterson <cpatterson@microsoft.com>2022-01-31 16:35:10 -0500
committerGitHub <noreply@github.com>2022-01-31 15:35:10 -0600
commit902aa44e6f4d267b5a7a59abb463f7b22c8d14d8 (patch)
tree42f26da8d24abfda5ba452f8b7769ada126b68fe /tests/unittests
parent0362abcd762d1bc3a359e7514113683b76d79352 (diff)
downloadvyos-cloud-init-902aa44e6f4d267b5a7a59abb463f7b22c8d14d8.tar.gz
vyos-cloud-init-902aa44e6f4d267b5a7a59abb463f7b22c8d14d8.zip
sources/azure: refactor _report_ready_if_needed and _poll_imds (#1222)
Refactor _report_ready_if_needed() to work for both Savable PPS and Runnable PPS: * rename _report_ready_if_needed() to _report_ready_for_pps() * return interface name from lease to support _poll_imds() behavior without changing it. * fixes an issue where reporting ready return value was silently ignored for Savable PPS. * add explicit handling for failure to obtain DHCP lease to result in sources.InvalidMetaDataException. Refactor _poll_imds(): * use _report_ready_for_pps() for reporting ready, removing this logic to simplify loop logic. * move netlink and vnetswitch out of while loop to simplify loop logic, leaving only reprovision polling in loop. * add explicit handling for failure to obtain DHCP lease and retry in the next iteration. Signed-off-by: Chris Patterson cpatterson@microsoft.com
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/sources/test_azure.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/tests/unittests/sources/test_azure.py b/tests/unittests/sources/test_azure.py
index 5581492e..c3d599bc 100644
--- a/tests/unittests/sources/test_azure.py
+++ b/tests/unittests/sources/test_azure.py
@@ -3213,10 +3213,8 @@ class TestPreprovisioningPollIMDS(CiTestCase):
dsaz.BUILTIN_DS_CONFIG["data_dir"] = self.waagent_d
@mock.patch("time.sleep", mock.MagicMock())
- @mock.patch(MOCKPATH + "EphemeralDHCPv4WithReporting", autospec=True)
def test_poll_imds_re_dhcp_on_timeout(
self,
- m_dhcpv4,
m_report_ready,
m_request,
m_media_switch,
@@ -3236,7 +3234,6 @@ class TestPreprovisioningPollIMDS(CiTestCase):
m_media_switch.return_value = None
dhcp_ctx = mock.MagicMock(lease=lease)
dhcp_ctx.obtain_lease.return_value = lease
- m_dhcpv4.return_value = dhcp_ctx
self.tries = 0
@@ -3260,7 +3257,7 @@ class TestPreprovisioningPollIMDS(CiTestCase):
dsa._poll_imds()
self.assertEqual(m_report_ready.call_count, 1)
m_report_ready.assert_called_with(lease=lease)
- self.assertEqual(3, m_dhcpv4.call_count, "Expected 3 DHCP calls")
+ self.assertEqual(3, m_dhcp.call_count, "Expected 3 DHCP calls")
self.assertEqual(4, self.tries, "Expected 4 total reads from IMDS")
@mock.patch("os.path.isfile")