summaryrefslogtreecommitdiff
path: root/tests/cloud_tests/testcases
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-11-06 17:39:00 -0500
committerScott Moser <smoser@brickies.net>2017-11-06 17:39:00 -0500
commit8622491c29f30862a1a1d7ad2cba023981acc8ce (patch)
tree597b08c4ca66575cc9567263030876814999beeb /tests/cloud_tests/testcases
parentbe8e3d3c5b5d3d6a3d222383a58fd5feecead7b7 (diff)
downloadvyos-cloud-init-8622491c29f30862a1a1d7ad2cba023981acc8ce.tar.gz
vyos-cloud-init-8622491c29f30862a1a1d7ad2cba023981acc8ce.zip
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.
Diffstat (limited to 'tests/cloud_tests/testcases')
-rw-r--r--tests/cloud_tests/testcases/examples/run_commands.yaml4
-rw-r--r--tests/cloud_tests/testcases/modules/keys_to_console.py8
-rw-r--r--tests/cloud_tests/testcases/modules/runcmd.yaml4
-rw-r--r--tests/cloud_tests/testcases/modules/set_hostname.py4
-rw-r--r--tests/cloud_tests/testcases/modules/set_hostname.yaml3
-rw-r--r--tests/cloud_tests/testcases/modules/set_hostname_fqdn.py10
-rw-r--r--tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml4
-rw-r--r--tests/cloud_tests/testcases/modules/set_password_expire.py2
-rw-r--r--tests/cloud_tests/testcases/modules/set_password_expire.yaml2
-rw-r--r--tests/cloud_tests/testcases/modules/set_password_list.yaml1
-rw-r--r--tests/cloud_tests/testcases/modules/set_password_list_string.yaml1
-rw-r--r--tests/cloud_tests/testcases/modules/ssh_auth_key_fingerprints_disable.py8
-rw-r--r--tests/cloud_tests/testcases/modules/ssh_auth_key_fingerprints_disable.yaml1
-rw-r--r--tests/cloud_tests/testcases/modules/ssh_keys_generate.py5
-rw-r--r--tests/cloud_tests/testcases/modules/ssh_keys_generate.yaml6
-rw-r--r--tests/cloud_tests/testcases/modules/ssh_keys_provided.py11
-rw-r--r--tests/cloud_tests/testcases/modules/ssh_keys_provided.yaml6
17 files changed, 27 insertions, 53 deletions
diff --git a/tests/cloud_tests/testcases/examples/run_commands.yaml b/tests/cloud_tests/testcases/examples/run_commands.yaml
index b0e311ba..f80eb8ce 100644
--- a/tests/cloud_tests/testcases/examples/run_commands.yaml
+++ b/tests/cloud_tests/testcases/examples/run_commands.yaml
@@ -7,10 +7,10 @@ enabled: False
cloud_config: |
#cloud-config
runcmd:
- - echo cloud-init run cmd test > /tmp/run_cmd
+ - echo cloud-init run cmd test > /var/tmp/run_cmd
collect_scripts:
run_cmd: |
#!/bin/bash
- cat /tmp/run_cmd
+ cat /var/tmp/run_cmd
# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/keys_to_console.py b/tests/cloud_tests/testcases/modules/keys_to_console.py
index 88b6812e..07f38112 100644
--- a/tests/cloud_tests/testcases/modules/keys_to_console.py
+++ b/tests/cloud_tests/testcases/modules/keys_to_console.py
@@ -10,13 +10,13 @@ class TestKeysToConsole(base.CloudTestCase):
def test_excluded_keys(self):
"""Test excluded keys missing."""
out = self.get_data_file('syslog')
- self.assertNotIn('DSA', out)
- self.assertNotIn('ECDSA', out)
+ self.assertNotIn('(DSA)', out)
+ self.assertNotIn('(ECDSA)', out)
def test_expected_keys(self):
"""Test expected keys exist."""
out = self.get_data_file('syslog')
- self.assertIn('ED25519', out)
- self.assertIn('RSA', out)
+ self.assertIn('(ED25519)', out)
+ self.assertIn('(RSA)', out)
# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/runcmd.yaml b/tests/cloud_tests/testcases/modules/runcmd.yaml
index 04e5a050..8309a883 100644
--- a/tests/cloud_tests/testcases/modules/runcmd.yaml
+++ b/tests/cloud_tests/testcases/modules/runcmd.yaml
@@ -4,10 +4,10 @@
cloud_config: |
#cloud-config
runcmd:
- - echo cloud-init run cmd test > /tmp/run_cmd
+ - echo cloud-init run cmd test > /var/tmp/run_cmd
collect_scripts:
run_cmd: |
#!/bin/bash
- cat /tmp/run_cmd
+ cat /var/tmp/run_cmd
# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/set_hostname.py b/tests/cloud_tests/testcases/modules/set_hostname.py
index 6e96a75c..1dbe64c2 100644
--- a/tests/cloud_tests/testcases/modules/set_hostname.py
+++ b/tests/cloud_tests/testcases/modules/set_hostname.py
@@ -7,9 +7,11 @@ from tests.cloud_tests.testcases import base
class TestHostname(base.CloudTestCase):
"""Test hostname module."""
+ ex_hostname = "cloudinit2"
+
def test_hostname(self):
"""Test hostname command shows correct output."""
out = self.get_data_file('hostname')
- self.assertIn('myhostname', out)
+ self.assertIn(self.ex_hostname, out)
# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/set_hostname.yaml b/tests/cloud_tests/testcases/modules/set_hostname.yaml
index c96344cf..071fb220 100644
--- a/tests/cloud_tests/testcases/modules/set_hostname.yaml
+++ b/tests/cloud_tests/testcases/modules/set_hostname.yaml
@@ -5,7 +5,8 @@ required_features:
- hostname
cloud_config: |
#cloud-config
- hostname: myhostname
+ hostname: cloudinit2
+
collect_scripts:
hosts: |
#!/bin/bash
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
diff --git a/tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml b/tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml
index daf75931..5320ac57 100644
--- a/tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml
+++ b/tests/cloud_tests/testcases/modules/set_hostname_fqdn.yaml
@@ -6,8 +6,8 @@ required_features:
cloud_config: |
#cloud-config
manage_etc_hosts: true
- hostname: myhostname
- fqdn: host.myorg.com
+ hostname: cloudinit1
+ fqdn: cloudinit2.i9n.brickies.net
collect_scripts:
hosts: |
#!/bin/bash
diff --git a/tests/cloud_tests/testcases/modules/set_password_expire.py b/tests/cloud_tests/testcases/modules/set_password_expire.py
index a1c3aa08..967aca7b 100644
--- a/tests/cloud_tests/testcases/modules/set_password_expire.py
+++ b/tests/cloud_tests/testcases/modules/set_password_expire.py
@@ -18,6 +18,6 @@ class TestPasswordExpire(base.CloudTestCase):
def test_sshd_config(self):
"""Test sshd config allows passwords."""
out = self.get_data_file('sshd_config')
- self.assertIn('PasswordAuthentication no', out)
+ self.assertIn('PasswordAuthentication yes', out)
# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/set_password_expire.yaml b/tests/cloud_tests/testcases/modules/set_password_expire.yaml
index 789604b0..ba6344b9 100644
--- a/tests/cloud_tests/testcases/modules/set_password_expire.yaml
+++ b/tests/cloud_tests/testcases/modules/set_password_expire.yaml
@@ -6,7 +6,9 @@ required_features:
cloud_config: |
#cloud-config
chpasswd: { expire: True }
+ ssh_pwauth: yes
users:
+ - default
- name: tom
password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
lock_passwd: false
diff --git a/tests/cloud_tests/testcases/modules/set_password_list.yaml b/tests/cloud_tests/testcases/modules/set_password_list.yaml
index a2a89c9d..fd3e1e44 100644
--- a/tests/cloud_tests/testcases/modules/set_password_list.yaml
+++ b/tests/cloud_tests/testcases/modules/set_password_list.yaml
@@ -5,6 +5,7 @@ cloud_config: |
#cloud-config
ssh_pwauth: yes
users:
+ - default
- name: tom
# md5 gotomgo
passwd: "$1$S7$tT1BEDIYrczeryDQJfdPe0"
diff --git a/tests/cloud_tests/testcases/modules/set_password_list_string.yaml b/tests/cloud_tests/testcases/modules/set_password_list_string.yaml
index c2a0f631..e9fe54b0 100644
--- a/tests/cloud_tests/testcases/modules/set_password_list_string.yaml
+++ b/tests/cloud_tests/testcases/modules/set_password_list_string.yaml
@@ -5,6 +5,7 @@ cloud_config: |
#cloud-config
ssh_pwauth: yes
users:
+ - default
- name: tom
# md5 gotomgo
passwd: "$1$S7$tT1BEDIYrczeryDQJfdPe0"
diff --git a/tests/cloud_tests/testcases/modules/ssh_auth_key_fingerprints_disable.py b/tests/cloud_tests/testcases/modules/ssh_auth_key_fingerprints_disable.py
index 82223217..e7329d48 100644
--- a/tests/cloud_tests/testcases/modules/ssh_auth_key_fingerprints_disable.py
+++ b/tests/cloud_tests/testcases/modules/ssh_auth_key_fingerprints_disable.py
@@ -13,12 +13,4 @@ class TestSshKeyFingerprintsDisable(base.CloudTestCase):
self.assertIn('Skipping module named ssh-authkey-fingerprints, '
'logging of ssh fingerprints disabled', out)
- def test_syslog(self):
- """Verify output of syslog."""
- out = self.get_data_file('syslog')
- self.assertNotRegex(out, r'256 SHA256:.*(ECDSA)')
- self.assertNotRegex(out, r'256 SHA256:.*(ED25519)')
- self.assertNotRegex(out, r'1024 SHA256:.*(DSA)')
- self.assertNotRegex(out, r'2048 SHA256:.*(RSA)')
-
# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/ssh_auth_key_fingerprints_disable.yaml b/tests/cloud_tests/testcases/modules/ssh_auth_key_fingerprints_disable.yaml
index 746653ec..d93893e2 100644
--- a/tests/cloud_tests/testcases/modules/ssh_auth_key_fingerprints_disable.yaml
+++ b/tests/cloud_tests/testcases/modules/ssh_auth_key_fingerprints_disable.yaml
@@ -5,7 +5,6 @@ required_features:
- syslog
cloud_config: |
#cloud-config
- ssh_genkeytypes: []
no_ssh_fingerprints: true
collect_scripts:
syslog: |
diff --git a/tests/cloud_tests/testcases/modules/ssh_keys_generate.py b/tests/cloud_tests/testcases/modules/ssh_keys_generate.py
index fd6d9ba5..b68f5565 100644
--- a/tests/cloud_tests/testcases/modules/ssh_keys_generate.py
+++ b/tests/cloud_tests/testcases/modules/ssh_keys_generate.py
@@ -9,11 +9,6 @@ class TestSshKeysGenerate(base.CloudTestCase):
# TODO: Check cloud-init-output for the correct keys being generated
- def test_ubuntu_authorized_keys(self):
- """Test passed in key is not in list for ubuntu."""
- out = self.get_data_file('auth_keys_ubuntu')
- self.assertEqual('', out)
-
def test_dsa_public(self):
"""Test dsa public key not generated."""
out = self.get_data_file('dsa_public')
diff --git a/tests/cloud_tests/testcases/modules/ssh_keys_generate.yaml b/tests/cloud_tests/testcases/modules/ssh_keys_generate.yaml
index 659fd939..0a7adf62 100644
--- a/tests/cloud_tests/testcases/modules/ssh_keys_generate.yaml
+++ b/tests/cloud_tests/testcases/modules/ssh_keys_generate.yaml
@@ -10,12 +10,6 @@ cloud_config: |
- ed25519
authkey_hash: sha512
collect_scripts:
- auth_keys_root: |
- #!/bin/bash
- cat /root/.ssh/authorized_keys
- auth_keys_ubuntu: |
- #!/bin/bash
- cat /home/ubuntu/ssh/authorized_keys
dsa_public: |
#!/bin/bash
cat /etc/ssh/ssh_host_dsa_key.pub
diff --git a/tests/cloud_tests/testcases/modules/ssh_keys_provided.py b/tests/cloud_tests/testcases/modules/ssh_keys_provided.py
index 544649da..add3f469 100644
--- a/tests/cloud_tests/testcases/modules/ssh_keys_provided.py
+++ b/tests/cloud_tests/testcases/modules/ssh_keys_provided.py
@@ -7,17 +7,6 @@ from tests.cloud_tests.testcases import base
class TestSshKeysProvided(base.CloudTestCase):
"""Test ssh keys module."""
- def test_ubuntu_authorized_keys(self):
- """Test passed in key is not in list for ubuntu."""
- out = self.get_data_file('auth_keys_ubuntu')
- self.assertEqual('', out)
-
- def test_root_authorized_keys(self):
- """Test passed in key is in authorized list for root."""
- out = self.get_data_file('auth_keys_root')
- self.assertIn('lzrkPqONphoZx0LDV86w7RUz1ksDzAdcm0tvmNRFMN1a0frDs50'
- '6oA3aWK0oDk4Nmvk8sXGTYYw3iQSkOvDUUlIsqdaO+w==', out)
-
def test_dsa_public(self):
"""Test dsa public key passed in."""
out = self.get_data_file('dsa_public')
diff --git a/tests/cloud_tests/testcases/modules/ssh_keys_provided.yaml b/tests/cloud_tests/testcases/modules/ssh_keys_provided.yaml
index 5ceb3623..41f63550 100644
--- a/tests/cloud_tests/testcases/modules/ssh_keys_provided.yaml
+++ b/tests/cloud_tests/testcases/modules/ssh_keys_provided.yaml
@@ -71,12 +71,6 @@ cloud_config: |
-----END EC PRIVATE KEY-----
ecdsa_public: ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFsS5Tvky/IC/dXhE/afxxUG6kdQOvdQJCYGZN42OZqWasYF+L3IG+3/wrV7jOrNrL3AyagHl6+lpPDiSXDMcpQ= root@xenial-lxd
collect_scripts:
- auth_keys_root: |
- #!/bin/bash
- cat /root/.ssh/authorized_keys
- auth_keys_ubuntu: |
- #!/bin/bash
- cat /home/ubuntu/ssh/authorized_keys
dsa_public: |
#!/bin/bash
cat /etc/ssh/ssh_host_dsa_key.pub