summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2020-07-10 08:08:44 -0500
committerGitHub <noreply@github.com>2020-07-10 09:08:44 -0400
commit3d06abc2e0017436dadbf9c26fefa9f95368db9a (patch)
treec4aded5d47ee8c1162bcc5b4487edaaa3ac533db /tests
parente753141fc7844e68b1f380d26fb3d250eb464ff7 (diff)
downloadvyos-cloud-init-3d06abc2e0017436dadbf9c26fefa9f95368db9a.tar.gz
vyos-cloud-init-3d06abc2e0017436dadbf9c26fefa9f95368db9a.zip
cc_mounts: handle missing fstab (#484)
Do not fail if /etc/fstab is not present. Some images, like container rootfs may not include this file by default. LP: #1886531
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_handler/test_handler_mounts.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/unittests/test_handler/test_handler_mounts.py b/tests/unittests/test_handler/test_handler_mounts.py
index b643e3ae..e193f4d4 100644
--- a/tests/unittests/test_handler/test_handler_mounts.py
+++ b/tests/unittests/test_handler/test_handler_mounts.py
@@ -183,6 +183,18 @@ class TestFstabHandling(test_helpers.FilesystemMockingTestCase):
return dev
+ def test_no_fstab(self):
+ """ Handle images which do not include an fstab. """
+ self.assertFalse(os.path.exists(cc_mounts.FSTAB_PATH))
+ fstab_expected_content = (
+ '%s\tnone\tswap\tsw,comment=cloudconfig\t'
+ '0\t0\n' % (self.swap_path,)
+ )
+ cc_mounts.handle(None, {}, self.mock_cloud, self.mock_log, [])
+ with open(cc_mounts.FSTAB_PATH, 'r') as fd:
+ fstab_new_content = fd.read()
+ self.assertEqual(fstab_expected_content, fstab_new_content)
+
def test_swap_integrity(self):
'''Ensure that the swap file is correctly created and can
swapon successfully. Fixing the corner case of: