summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-12-12 11:41:26 -0700
committerChad Smith <chad.smith@canonical.com>2017-12-12 11:41:26 -0700
commita30a3bb5baec4da1d8f91385849e9b5b826678bf (patch)
tree97de1d1ee870bda999f6fd44b71d97c5252e73af /tests/unittests
parentb63ee73da874de68ff2019570e12df2a39d4626b (diff)
downloadvyos-cloud-init-a30a3bb5baec4da1d8f91385849e9b5b826678bf.tar.gz
vyos-cloud-init-a30a3bb5baec4da1d8f91385849e9b5b826678bf.zip
ds-identify: failure in NoCloud due to unset variable usage.
The previous OVF datasource change added a debug message that referenced an un-used variable. The failure path would be triggered if an image was booted with a iso9660 filesystem attached to a device that was not a cdrom. A unit test is added for the specific failure found. Additional safety to avoid 'cidata' labels is also added to the OVF checker. LP: #1737704
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_ds_identify.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
index 3f1a6712..c9234edd 100644
--- a/tests/unittests/test_ds_identify.py
+++ b/tests/unittests/test_ds_identify.py
@@ -27,6 +27,14 @@ TYPE=ext4
PARTUUID=30c65c77-e07d-4039-b2fb-88b1fb5fa1fc
"""
+# this is a Ubuntu 18.04 disk.img output (dual uefi and bios bootable)
+BLKID_UEFI_UBUNTU = [
+ {'DEVNAME': 'vda1', 'TYPE': 'ext4', 'PARTUUID': uuid4(), 'UUID': uuid4()},
+ {'DEVNAME': 'vda14', 'PARTUUID': uuid4()},
+ {'DEVNAME': 'vda15', 'TYPE': 'vfat', 'LABEL': 'UEFI', 'PARTUUID': uuid4(),
+ 'UUID': '5F55-129B'}]
+
+
POLICY_FOUND_ONLY = "search,found=all,maybe=none,notfound=disabled"
POLICY_FOUND_OR_MAYBE = "search,found=all,maybe=all,notfound=disabled"
DI_DEFAULT_POLICY = "search,found=all,maybe=all,notfound=enabled"
@@ -340,6 +348,10 @@ class TestDsIdentify(CiTestCase):
self._check_via_dict(
ovf_cdrom_by_label, rc=RC_FOUND, dslist=['OVF', DS_NONE])
+ def test_default_nocloud_as_vdb_iso9660(self):
+ """NoCloud is found with iso9660 filesystem on non-cdrom disk."""
+ self._test_ds_found('NoCloud')
+
def blkid_out(disks=None):
"""Convert a list of disk dictionaries into blkid content."""
@@ -422,6 +434,19 @@ VALID_CFG = {
'files': {P_PRODUCT_SERIAL: 'GoogleCloud-8f2e88f\n'},
'mocks': [MOCK_VIRT_IS_KVM],
},
+ 'NoCloud': {
+ 'ds': 'NoCloud',
+ 'mocks': [
+ MOCK_VIRT_IS_KVM,
+ {'name': 'blkid', 'ret': 0,
+ 'out': blkid_out(
+ BLKID_UEFI_UBUNTU +
+ [{'DEVNAME': 'vdb', 'TYPE': 'iso9660', 'LABEL': 'cidata'}])},
+ ],
+ 'files': {
+ 'dev/vdb': 'pretend iso content for cidata\n',
+ }
+ },
'OpenStack': {
'ds': 'OpenStack',
'files': {P_PRODUCT_NAME: 'OpenStack Nova\n'},