summaryrefslogtreecommitdiff
path: root/tests/unittests/test_datasource
diff options
context:
space:
mode:
authorAnh Vo <anhvo@microsoft.com>2020-07-22 12:51:01 -0400
committerGitHub <noreply@github.com>2020-07-22 10:51:01 -0600
commitd600f47e91b904243263358324c413c4f7e5cf50 (patch)
treeb55154aa39c84867885d50e4dbbeeeaf76ed7ff7 /tests/unittests/test_datasource
parent995f8adf00509e5d2aefc9f0680c3c4894ae6666 (diff)
downloadvyos-cloud-init-d600f47e91b904243263358324c413c4f7e5cf50.tar.gz
vyos-cloud-init-d600f47e91b904243263358324c413c4f7e5cf50.zip
azure: disable bouncing hostname when setting hostname fails (#494)
DataSourceAzure: Gracefully handle the case of set hostname failure during provisioning
Diffstat (limited to 'tests/unittests/test_datasource')
-rw-r--r--tests/unittests/test_datasource/test_azure.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
index a99cbd41..96bcc7a2 100644
--- a/tests/unittests/test_datasource/test_azure.py
+++ b/tests/unittests/test_datasource/test_azure.py
@@ -1524,6 +1524,17 @@ class TestAzureBounce(CiTestCase):
self.assertEqual(0, self.set_hostname.call_count)
+ @mock.patch(MOCKPATH + 'perform_hostname_bounce')
+ def test_set_hostname_failed_disable_bounce(
+ self, perform_hostname_bounce):
+ cfg = {'set_hostname': True, 'hostname_bounce': {'policy': 'force'}}
+ self.get_hostname.return_value = "old-hostname"
+ self.set_hostname.side_effect = Exception
+ data = self.get_ovf_env_with_dscfg('some-hostname', cfg)
+ self._get_ds(data).get_data()
+
+ self.assertEqual(0, perform_hostname_bounce.call_count)
+
class TestLoadAzureDsDir(CiTestCase):
"""Tests for load_azure_ds_dir."""