diff options
author | Dominic Schlegel <dominic.schlegel@hostpoint.ch> | 2018-03-27 10:10:42 -0400 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2018-03-27 10:10:42 -0400 |
commit | 20e3ddab7f55c2bf5e700c69fd24a0ac2206dbcf (patch) | |
tree | 37fb7d7b6b27de671267ee5bd5c4fb1e9775127c /tests/unittests/test_util.py | |
parent | 4fe40704bfb998588d6a96b4a2773ddc9bd692ac (diff) | |
download | vyos-cloud-init-20e3ddab7f55c2bf5e700c69fd24a0ac2206dbcf.tar.gz vyos-cloud-init-20e3ddab7f55c2bf5e700c69fd24a0ac2206dbcf.zip |
FreeBSD: resizefs module now able to handle zfs/zpool.
Previously there was no support at all for zfs file system. With this
change it is now possible to use the resizefs module to grow a zpool to
its maximum partition size on FreeBSD.
LP: #1721243
Diffstat (limited to 'tests/unittests/test_util.py')
-rw-r--r-- | tests/unittests/test_util.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index 67d9607d..8685b8e2 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -366,6 +366,56 @@ class TestMountinfoParsing(helpers.ResourceUsingTestCase): expected = ('none', 'tmpfs', '/run/lock') self.assertEqual(expected, util.parse_mount_info('/run/lock', lines)) + @mock.patch('cloudinit.util.subp') + def test_get_device_info_from_zpool(self, zpool_output): + # mock subp command from util.get_mount_info_fs_on_zpool + zpool_output.return_value = ( + self.readResource('zpool_status_simple.txt'), '' + ) + # save function return values and do asserts + ret = util.get_device_info_from_zpool('vmzroot') + self.assertEqual('gpt/system', ret) + self.assertIsNotNone(ret) + + @mock.patch('cloudinit.util.subp') + def test_get_device_info_from_zpool_on_error(self, zpool_output): + # mock subp command from util.get_mount_info_fs_on_zpool + zpool_output.return_value = ( + self.readResource('zpool_status_simple.txt'), 'error' + ) + # save function return values and do asserts + ret = util.get_device_info_from_zpool('vmzroot') + self.assertIsNone(ret) + + @mock.patch('cloudinit.util.subp') + def test_parse_mount_with_ext(self, mount_out): + mount_out.return_value = (self.readResource('mount_parse_ext.txt'), '') + # this one is valid and exists in mount_parse_ext.txt + ret = util.parse_mount('/var') + self.assertEqual(('/dev/mapper/vg00-lv_var', 'ext4', '/var'), ret) + # another one that is valid and exists + ret = util.parse_mount('/') + self.assertEqual(('/dev/mapper/vg00-lv_root', 'ext4', '/'), ret) + # this one exists in mount_parse_ext.txt + ret = util.parse_mount('/sys/kernel/debug') + self.assertIsNone(ret) + # this one does not even exist in mount_parse_ext.txt + ret = util.parse_mount('/not/existing/mount') + self.assertIsNone(ret) + + @mock.patch('cloudinit.util.subp') + def test_parse_mount_with_zfs(self, mount_out): + mount_out.return_value = (self.readResource('mount_parse_zfs.txt'), '') + # this one is valid and exists in mount_parse_zfs.txt + ret = util.parse_mount('/var') + self.assertEqual(('vmzroot/ROOT/freebsd/var', 'zfs', '/var'), ret) + # this one is the root, valid and also exists in mount_parse_zfs.txt + ret = util.parse_mount('/') + self.assertEqual(('vmzroot/ROOT/freebsd', 'zfs', '/'), ret) + # this one does not even exist in mount_parse_ext.txt + ret = util.parse_mount('/not/existing/mount') + self.assertIsNone(ret) + class TestReadDMIData(helpers.FilesystemMockingTestCase): |