summaryrefslogtreecommitdiff
path: root/tests/integration_tests/modules
diff options
context:
space:
mode:
authorhamalq <81582959+hamalq@users.noreply.github.com>2021-04-15 16:45:12 -0700
committerGitHub <noreply@github.com>2021-04-15 18:45:12 -0500
commit45db197cfc7e3488baae7dc1053c45da070248f6 (patch)
tree91b0148c026c619e6f7f9f50064e6d07c1f47fac /tests/integration_tests/modules
parent0d90596b56db5d306125ead08c571fc8d44d528e (diff)
downloadvyos-cloud-init-45db197cfc7e3488baae7dc1053c45da070248f6.tar.gz
vyos-cloud-init-45db197cfc7e3488baae7dc1053c45da070248f6.zip
add prefer_fqdn_over_hostname config option (#859)
the above option allows the user to control the behavior of a distro hostname selection if both short hostname and FQDN are supplied. If `prefer_fqdn_over_hostname` is true the FQDN will be selected as hostname; if false the hostname will be selected LP: #1921004
Diffstat (limited to 'tests/integration_tests/modules')
-rw-r--r--tests/integration_tests/modules/test_set_hostname.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/integration_tests/modules/test_set_hostname.py b/tests/integration_tests/modules/test_set_hostname.py
index 2bfa403d..e7f7f6b6 100644
--- a/tests/integration_tests/modules/test_set_hostname.py
+++ b/tests/integration_tests/modules/test_set_hostname.py
@@ -24,6 +24,13 @@ hostname: cloudinit1
fqdn: cloudinit2.i9n.cloud-init.io
"""
+USER_DATA_PREFER_FQDN = """\
+#cloud-config
+prefer_fqdn_over_hostname: {}
+hostname: cloudinit1
+fqdn: cloudinit2.test.io
+"""
+
@pytest.mark.ci
class TestHostname:
@@ -33,6 +40,16 @@ class TestHostname:
hostname_output = client.execute("hostname")
assert "cloudinit2" in hostname_output.strip()
+ @pytest.mark.user_data(USER_DATA_PREFER_FQDN.format(True))
+ def test_prefer_fqdn(self, client):
+ hostname_output = client.execute("hostname")
+ assert "cloudinit2.test.io" in hostname_output.strip()
+
+ @pytest.mark.user_data(USER_DATA_PREFER_FQDN.format(False))
+ def test_prefer_short_hostname(self, client):
+ hostname_output = client.execute("hostname")
+ assert "cloudinit1" in hostname_output.strip()
+
@pytest.mark.user_data(USER_DATA_FQDN)
def test_hostname_and_fqdn(self, client):
hostname_output = client.execute("hostname")