diff options
author | aswinrajamannar <39812128+aswinrajamannar@users.noreply.github.com> | 2021-08-20 15:53:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-20 16:53:18 -0600 |
commit | 3ec8ddde0d1d2fd8597f7d2915baa3e328552ab1 (patch) | |
tree | ca76749caeeb00faccfd1c7668868ceb2ed74ced /tests | |
parent | 7d3f5d750f6111c2716143364ea33486df67c927 (diff) | |
download | vyos-cloud-init-3ec8ddde0d1d2fd8597f7d2915baa3e328552ab1.tar.gz vyos-cloud-init-3ec8ddde0d1d2fd8597f7d2915baa3e328552ab1.zip |
Azure: During primary nic detection, check interface status continuously before rebinding again (#990)
Add 10 second polling loop in wait_for_link_up after performing
an unbind and re-bind of primary NIC in hv_netvsc driver.
Also reduce cloud-init logging levels to debug for these operations.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_datasource/test_azure.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py index 03609c3d..851cf82e 100644 --- a/tests/unittests/test_datasource/test_azure.py +++ b/tests/unittests/test_datasource/test_azure.py @@ -2912,19 +2912,29 @@ class TestPreprovisioningHotAttachNics(CiTestCase): @mock.patch('cloudinit.net.read_sys_net') @mock.patch('cloudinit.distros.networking.LinuxNetworking.try_set_link_up') def test_wait_for_link_up_checks_link_after_sleep( - self, m_is_link_up, m_read_sys_net, m_writefile, m_is_up): + self, m_try_set_link_up, m_read_sys_net, m_writefile, m_is_up): """Waiting for link to be up should return immediately if the link is already up.""" distro_cls = distros.fetch('ubuntu') distro = distro_cls('ubuntu', {}, self.paths) dsa = dsaz.DataSourceAzure({}, distro=distro, paths=self.paths) - m_is_link_up.return_value = False - m_is_up.return_value = True + m_try_set_link_up.return_value = False + + callcount = 0 + + def is_up_mock(key): + nonlocal callcount + if callcount == 0: + callcount += 1 + return False + return True + + m_is_up.side_effect = is_up_mock dsa.wait_for_link_up("eth0") - self.assertEqual(2, m_is_link_up.call_count) - self.assertEqual(1, m_is_up.call_count) + self.assertEqual(2, m_try_set_link_up.call_count) + self.assertEqual(2, m_is_up.call_count) @mock.patch(MOCKPATH + 'util.write_file') @mock.patch('cloudinit.net.read_sys_net') |