summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoraswinrajamannar <39812128+aswinrajamannar@users.noreply.github.com>2021-08-10 12:28:00 -0700
committerGitHub <noreply@github.com>2021-08-10 14:28:00 -0500
commitd3271217e2745fb0e3405bd093b61c39fe0708a7 (patch)
tree8d140da5c47638db090305bddf558bfe3e918591 /tests
parentc62cb3af59abc464380011c106b31879181e7c45 (diff)
downloadvyos-cloud-init-d3271217e2745fb0e3405bd093b61c39fe0708a7.tar.gz
vyos-cloud-init-d3271217e2745fb0e3405bd093b61c39fe0708a7.zip
Azure: Limit polling network metadata on connection errors (#961)
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_datasource/test_azure.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
index 3bf8fdb2..63eaf384 100644
--- a/tests/unittests/test_datasource/test_azure.py
+++ b/tests/unittests/test_datasource/test_azure.py
@@ -2825,7 +2825,8 @@ class TestPreprovisioningHotAttachNics(CiTestCase):
@mock.patch(MOCKPATH + 'EphemeralDHCPv4')
def test_check_if_nic_is_primary_retries_on_failures(
self, m_dhcpv4, m_imds):
- """Retry polling for network metadata on all failures except timeout"""
+ """Retry polling for network metadata on all failures except timeout
+ and network unreachable errors"""
dsa = dsaz.DataSourceAzure({}, distro=None, paths=self.paths)
lease = {
'interface': 'eth9', 'fixed-address': '192.168.2.9',
@@ -2854,8 +2855,13 @@ class TestPreprovisioningHotAttachNics(CiTestCase):
error = url_helper.UrlError(cause=cause, code=410)
eth0Retries.append(exc_cb("No goal state.", error))
else:
- cause = requests.Timeout('Fake connection timeout')
for _ in range(0, 10):
+ # We are expected to retry for a certain period for both
+ # timeout errors and network unreachable errors.
+ if _ < 5:
+ cause = requests.Timeout('Fake connection timeout')
+ else:
+ cause = requests.ConnectionError('Network Unreachable')
error = url_helper.UrlError(cause=cause)
eth1Retries.append(exc_cb("Connection timeout", error))
# Should stop retrying after 10 retries