summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_handler_resizefs.py
diff options
context:
space:
mode:
authorHongjiang Zhang <honzhan@microsoft.com>2017-01-13 15:08:22 +0800
committerScott Moser <smoser@brickies.net>2017-05-10 12:54:42 -0400
commit0a71d5a870b416f2c86c8bc196004bb3fc0768a0 (patch)
treec6c0ce43c09a7426186c699b0da8113ab8479395 /tests/unittests/test_handler/test_handler_resizefs.py
parent370a04e8d7b530c1ef8280e15eb628ff6880c736 (diff)
downloadvyos-cloud-init-0a71d5a870b416f2c86c8bc196004bb3fc0768a0.tar.gz
vyos-cloud-init-0a71d5a870b416f2c86c8bc196004bb3fc0768a0.zip
FreeBSD: improvements and fixes for use on Azure
This patch targets to make FreeBSD 10.3 or 11 work on Azure. The modifications abide by the rule of: * making as less modification as possible * delegate to the distro or datasource where possible. The main modifications are: 1. network configuration improvements, and movement into distro path. 2. Fix setting of password. Password setting through "pw" can only work through pipe. 3. Add 'root:wheel' to syslog_fix_perms field. 4. Support resizing default file system (ufs) 5. copy cloud.cfg for freebsd to /etc/cloud/cloud.cfg rather than /usr/local/etc/cloud/cloud.cfg. 6. Azure specific changes: a. When reading the azure endpoint, search in a different path and read a different option name (option-245 vs. unknown-245). so, the lease file path should be generated according to platform. b. adjust the handling of ephemeral mounts for ufs filesystem and for finding the ephemeral device. c. fix mounting of cdrom LP: #1636345
Diffstat (limited to 'tests/unittests/test_handler/test_handler_resizefs.py')
-rw-r--r--tests/unittests/test_handler/test_handler_resizefs.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/unittests/test_handler/test_handler_resizefs.py b/tests/unittests/test_handler/test_handler_resizefs.py
new file mode 100644
index 00000000..52591b8b
--- /dev/null
+++ b/tests/unittests/test_handler/test_handler_resizefs.py
@@ -0,0 +1,59 @@
+# This file is part of cloud-init. See LICENSE file for license information.
+
+from cloudinit.config import cc_resizefs
+
+import textwrap
+import unittest
+
+try:
+ from unittest import mock
+except ImportError:
+ import mock
+
+
+class TestResizefs(unittest.TestCase):
+ def setUp(self):
+ super(TestResizefs, self).setUp()
+ self.name = "resizefs"
+
+ @mock.patch('cloudinit.config.cc_resizefs._get_dumpfs_output')
+ @mock.patch('cloudinit.config.cc_resizefs._get_gpart_output')
+ def test_skip_ufs_resize(self, gpart_out, dumpfs_out):
+ fs_type = "ufs"
+ resize_what = "/"
+ devpth = "/dev/da0p2"
+ dumpfs_out.return_value = (
+ "# newfs command for / (/dev/label/rootfs)\n"
+ "newfs -O 2 -U -a 4 -b 32768 -d 32768 -e 4096 "
+ "-f 4096 -g 16384 -h 64 -i 8192 -j -k 6408 -m 8 "
+ "-o time -s 58719232 /dev/label/rootfs\n")
+ gpart_out.return_value = textwrap.dedent("""\
+ => 40 62914480 da0 GPT (30G)
+ 40 1024 1 freebsd-boot (512K)
+ 1064 58719232 2 freebsd-ufs (28G)
+ 58720296 3145728 3 freebsd-swap (1.5G)
+ 61866024 1048496 - free - (512M)
+ """)
+ res = cc_resizefs.can_skip_resize(fs_type, resize_what, devpth)
+ self.assertTrue(res)
+
+ @mock.patch('cloudinit.config.cc_resizefs._get_dumpfs_output')
+ @mock.patch('cloudinit.config.cc_resizefs._get_gpart_output')
+ def test_skip_ufs_resize_roundup(self, gpart_out, dumpfs_out):
+ fs_type = "ufs"
+ resize_what = "/"
+ devpth = "/dev/da0p2"
+ dumpfs_out.return_value = (
+ "# newfs command for / (/dev/label/rootfs)\n"
+ "newfs -O 2 -U -a 4 -b 32768 -d 32768 -e 4096 "
+ "-f 4096 -g 16384 -h 64 -i 8192 -j -k 368 -m 8 "
+ "-o time -s 297080 /dev/label/rootfs\n")
+ gpart_out.return_value = textwrap.dedent("""\
+ => 34 297086 da0 GPT (145M)
+ 34 297086 1 freebsd-ufs (145M)
+ """)
+ res = cc_resizefs.can_skip_resize(fs_type, resize_what, devpth)
+ self.assertTrue(res)
+
+
+# vi: ts=4 expandtab