diff options
author | zsdc <taras@vyos.io> | 2020-12-25 17:52:03 +0200 |
---|---|---|
committer | zsdc <taras@vyos.io> | 2020-12-25 17:52:03 +0200 |
commit | 526c2760b85ff625a10f4a1c9ba83759d8de1441 (patch) | |
tree | c7a87d78a7944dd6a9d02544d1605f3a7d77e313 /tests/integration_tests/modules/test_set_hostname.py | |
parent | 66dc53b1b3f8786f3bbb25e914c1dc8161af0494 (diff) | |
parent | 47f4229ebcef9f83df8b549bb869a2dbf6dff17c (diff) | |
download | vyos-cloud-init-526c2760b85ff625a10f4a1c9ba83759d8de1441.tar.gz vyos-cloud-init-526c2760b85ff625a10f4a1c9ba83759d8de1441.zip |
T2117: Cloud-init updated to 20.4
Merged with 20.4 tag from the upstream Cloud-init repository
Diffstat (limited to 'tests/integration_tests/modules/test_set_hostname.py')
-rw-r--r-- | tests/integration_tests/modules/test_set_hostname.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/integration_tests/modules/test_set_hostname.py b/tests/integration_tests/modules/test_set_hostname.py new file mode 100644 index 00000000..2bfa403d --- /dev/null +++ b/tests/integration_tests/modules/test_set_hostname.py @@ -0,0 +1,47 @@ +"""Integration test for the set_hostname module. + +This module specify two tests: One updates only the hostname and the other +one updates the hostname and fqdn of the system. For both of these tests +we will check is the changes requested by the user data are being respected +after the system is boot. + +(This is ported from +``tests/cloud_tests/testcases/modules/set_hostname.yaml`` and +``tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml``.)""" + +import pytest + + +USER_DATA_HOSTNAME = """\ +#cloud-config +hostname: cloudinit2 +""" + +USER_DATA_FQDN = """\ +#cloud-config +manage_etc_hosts: true +hostname: cloudinit1 +fqdn: cloudinit2.i9n.cloud-init.io +""" + + +@pytest.mark.ci +class TestHostname: + + @pytest.mark.user_data(USER_DATA_HOSTNAME) + def test_hostname(self, client): + hostname_output = client.execute("hostname") + assert "cloudinit2" in hostname_output.strip() + + @pytest.mark.user_data(USER_DATA_FQDN) + def test_hostname_and_fqdn(self, client): + hostname_output = client.execute("hostname") + assert "cloudinit1" in hostname_output.strip() + + fqdn_output = client.execute("hostname --fqdn") + assert "cloudinit2.i9n.cloud-init.io" in fqdn_output.strip() + + host_output = client.execute("grep ^127 /etc/hosts") + assert '127.0.1.1 {} {}'.format( + fqdn_output, hostname_output) in host_output + assert '127.0.0.1 localhost' in host_output |