diff options
author | lucasmoura <lucas.moura@canonical.com> | 2020-10-19 16:09:51 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-19 15:09:51 -0400 |
commit | b94962b558e929a365bcfad1ca9a9445eee575e8 (patch) | |
tree | c6e061054d84e2e5f580cf330a999745243b6061 /tests/integration_tests/modules/test_set_hostname.py | |
parent | 8766784f4b1d1f9f6a9094e1268e4accb811ea7f (diff) | |
download | vyos-cloud-init-b94962b558e929a365bcfad1ca9a9445eee575e8.tar.gz vyos-cloud-init-b94962b558e929a365bcfad1ca9a9445eee575e8.zip |
Add more integration tests (#615)
Translate the following tests from `cloud_tests` to the new integration test framework:
* test_runcmd.py
* seed_random_data.py
* set_hostname.py
* set_hostname_fqdn.py
* snap.py
* ssh_auth_key_fingerprints_disable.py
* ssh_auth_key_fingerprints_enable.py
* ssh_import_id.py
* ssh_keys_generate.py
* ssh_keys_provided.py
* timezone.py
* write_files.py
Diffstat (limited to 'tests/integration_tests/modules/test_set_hostname.py')
-rw-r--r-- | tests/integration_tests/modules/test_set_hostname.py | 46 |
1 files changed, 46 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..ff46feb9 --- /dev/null +++ b/tests/integration_tests/modules/test_set_hostname.py @@ -0,0 +1,46 @@ +"""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 +""" + + +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 |