From 8622491c29f30862a1a1d7ad2cba023981acc8ce Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 6 Nov 2017 17:39:00 -0500 Subject: tests: integration test cleanup and full pass of nocloud-kvm. Integration test harness changes: * Enable collection of console log in nocloud-kvm and lxd. * Collect the console log to results for all test runs. * change 'tmpfile' to pick name locally instead of using 'mktemp'. * drop the 'instance' attribute from nocloud-kvm Image and demote LXDImage.instance to a private attribute. This is because Images do not actually have instances. (LXDImage internally uses a booted system to modify the image). * Add 'TargetBase' as a superclass of Image and Instance providing implementations of execute, read_data, write_data, pull_file, and push_file. These all depend on an implementation of _execute. * Improve '_execute' implementations to support accepting stdin. * execute supports 'rcs=False' meaning 'do not raise exception'. * Drop support for pylxd < 2.2. older versions cannot determine exit code of 'execute', which makes them unusable. * make NoCloudKVMInstance._execute run as root via sudo. This required some changes so that 'hostname' could be reverse-looked up in order to avoid sudo taking a long time (~20 seconds). * re-use existing ssh connection in nocloud-kvm. Test changes here: * do not use /tmp, but rather /var/tmp (LP: #1707222) * make keys_to_console assertions more strict. * change user test cases to always add default (ubuntu) user so that nocloud-kvm's execute which operates over ssh can work. --- tests/cloud_tests/testcases/modules/set_hostname_fqdn.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/cloud_tests/testcases/modules/set_hostname_fqdn.py') diff --git a/tests/cloud_tests/testcases/modules/set_hostname_fqdn.py b/tests/cloud_tests/testcases/modules/set_hostname_fqdn.py index 398f3d40..08ceae01 100644 --- a/tests/cloud_tests/testcases/modules/set_hostname_fqdn.py +++ b/tests/cloud_tests/testcases/modules/set_hostname_fqdn.py @@ -7,20 +7,24 @@ from tests.cloud_tests.testcases import base class TestHostnameFqdn(base.CloudTestCase): """Test Hostname module.""" + ex_hostname = "cloudinit1" + ex_fqdn = "cloudinit2.i9n.brickies.net" + def test_hostname(self): """Test hostname output.""" out = self.get_data_file('hostname') - self.assertIn('myhostname', out) + self.assertIn(self.ex_hostname, out) def test_hostname_fqdn(self): """Test hostname fqdn output.""" out = self.get_data_file('fqdn') - self.assertIn('host.myorg.com', out) + self.assertIn(self.ex_fqdn, out) def test_hosts(self): """Test /etc/hosts file.""" out = self.get_data_file('hosts') - self.assertIn('127.0.1.1 host.myorg.com myhostname', out) + self.assertIn('127.0.1.1 %s %s' % (self.ex_fqdn, self.ex_hostname), + out) self.assertIn('127.0.0.1 localhost', out) # vi: ts=4 expandtab -- cgit v1.2.3 From b6deb1d851100a79a89d3c66e74df7bc7efff68c Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 7 Nov 2017 21:35:23 -0500 Subject: Replace the temporary i9n.brickies.net with i9n.cloud-init.io. We had used some dns records in i9n.brickies.net (my personal domain) as a temporary solution until we got names registered in the cloud-init.io namespace. We now have CNAME records for: ubuntu.i9n.cloud-init.io cloudinit1.cloud-init.io cloudinit2.cloud-init.io --- tests/cloud_tests/instances/nocloudkvm.py | 4 +--- tests/cloud_tests/testcases/modules/set_hostname_fqdn.py | 3 ++- tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/cloud_tests/testcases/modules/set_hostname_fqdn.py') diff --git a/tests/cloud_tests/instances/nocloudkvm.py b/tests/cloud_tests/instances/nocloudkvm.py index 2427c856..cc825800 100644 --- a/tests/cloud_tests/instances/nocloudkvm.py +++ b/tests/cloud_tests/instances/nocloudkvm.py @@ -15,10 +15,8 @@ from tests.cloud_tests import util # This domain contains reverse lookups for hostnames that are used. # The primary reason is so sudo will return quickly when it attempts # to look up the hostname. i9n is just short for 'integration'. -# use i9n.brickies.net until i9n.cloud-init.io is populated: -# https://portal.admin.canonical.com/107125 # see also bug 1730744 for why we had to do this. -CI_DOMAIN = "i9n.brickies.net" +CI_DOMAIN = "i9n.cloud-init.io" class NoCloudKVMInstance(base.Instance): diff --git a/tests/cloud_tests/testcases/modules/set_hostname_fqdn.py b/tests/cloud_tests/testcases/modules/set_hostname_fqdn.py index 08ceae01..eb6f0650 100644 --- a/tests/cloud_tests/testcases/modules/set_hostname_fqdn.py +++ b/tests/cloud_tests/testcases/modules/set_hostname_fqdn.py @@ -1,6 +1,7 @@ # This file is part of cloud-init. See LICENSE file for license information. """cloud-init Integration Test Verify Script.""" +from tests.cloud_tests.instances.nocloudkvm import CI_DOMAIN from tests.cloud_tests.testcases import base @@ -8,7 +9,7 @@ class TestHostnameFqdn(base.CloudTestCase): """Test Hostname module.""" ex_hostname = "cloudinit1" - ex_fqdn = "cloudinit2.i9n.brickies.net" + ex_fqdn = "cloudinit2." + CI_DOMAIN def test_hostname(self): """Test hostname output.""" diff --git a/tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml b/tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml index 5320ac57..a85ee79e 100644 --- a/tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml +++ b/tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml @@ -7,7 +7,8 @@ cloud_config: | #cloud-config manage_etc_hosts: true hostname: cloudinit1 - fqdn: cloudinit2.i9n.brickies.net + # this needs changing if CI_DOMAIN were updated. + fqdn: cloudinit2.i9n.cloud-init.io collect_scripts: hosts: | #!/bin/bash -- cgit v1.2.3