diff options
author | Mina Galić <freebsd@igalic.co> | 2023-05-16 19:37:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-16 13:37:07 -0500 |
commit | 21006925f17815fc79e9a15f80088b1585e6f1a6 (patch) | |
tree | 8274fc5220345b73a4470291735b17cfe25f46cd /tests/unittests/config/test_cc_growpart.py | |
parent | ffdb7a7d5fd78b9f64d2f4d9686236b56fa9503d (diff) | |
download | cloud-init-git-21006925f17815fc79e9a15f80088b1585e6f1a6.tar.gz |
FreeBSD: add ResizeGrowFS class to cc_growpart (#2334)
this FreeBSD specific resizer resizes the root partition and grows the
Filesystem all in one.
All we have to do is call ``service growfs onestart``
Document behaviour: especially that growfs will insert a swap partition
if none is present, unless instructed otherwise.
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'tests/unittests/config/test_cc_growpart.py')
-rw-r--r-- | tests/unittests/config/test_cc_growpart.py | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/tests/unittests/config/test_cc_growpart.py b/tests/unittests/config/test_cc_growpart.py index f9bee391..3a79da62 100644 --- a/tests/unittests/config/test_cc_growpart.py +++ b/tests/unittests/config/test_cc_growpart.py @@ -141,7 +141,6 @@ class TestConfig(TestCase): with mock.patch.object( subp, "subp", return_value=(HELP_GROWPART_NO_RESIZE, "") ) as mockobj: - config = {"growpart": {"mode": "auto"}} self.handle(self.name, config, self.cloud, self.args) @@ -178,7 +177,9 @@ class TestConfig(TestCase): with mock.patch.object( subp, "subp", return_value=(HELP_GROWPART_RESIZE, "") ) as mockobj: - ret = cc_growpart.resizer_factory(mode="auto", distro=mock.Mock()) + ret = cc_growpart.resizer_factory( + mode="auto", distro=mock.Mock(), devices=["/"] + ) self.assertIsInstance(ret, cc_growpart.ResizeGrowPart) mockobj.assert_called_once_with( @@ -203,8 +204,9 @@ class TestConfig(TestCase): with mock.patch.object( subp, "subp", return_value=(HELP_GROWPART_RESIZE, "") ) as mockobj: - - ret = cc_growpart.resizer_factory(mode="auto", distro=mock.Mock()) + ret = cc_growpart.resizer_factory( + mode="auto", distro=mock.Mock(), devices=["/"] + ) self.assertIsInstance(ret, cc_growpart.ResizeGrowPart) diskdev = "/dev/sdb" partnum = 1 @@ -223,12 +225,31 @@ class TestConfig(TestCase): ] ) + @mock.patch.dict("os.environ", clear=True) + @mock.patch.object(os.path, "isfile", return_value=True) + def test_mode_use_growfs_on_root(self, m_isfile): + with mock.patch.object( + subp, "subp", return_value=("File not found", "") + ) as mockobj: + ret = cc_growpart.resizer_factory( + mode="auto", distro=mock.Mock(), devices=["/"] + ) + self.assertIsInstance(ret, cc_growpart.ResizeGrowFS) + + mockobj.assert_has_calls( + [ + mock.call(["growpart", "--help"], env={"LANG": "C"}), + ] + ) + @mock.patch.dict("os.environ", {"LANG": "cs_CZ.UTF-8"}, clear=True) def test_mode_auto_falls_back_to_gpart(self): with mock.patch.object( subp, "subp", return_value=("", HELP_GPART) ) as mockobj: - ret = cc_growpart.resizer_factory(mode="auto", distro=mock.Mock()) + ret = cc_growpart.resizer_factory( + mode="auto", distro=mock.Mock(), devices=["/"] + ) self.assertIsInstance(ret, cc_growpart.ResizeGpart) mockobj.assert_has_calls( @@ -271,7 +292,9 @@ class TestConfig(TestCase): self.handle(self.name, {}, self.cloud, self.args) - factory.assert_called_once_with("auto", self.distro) + factory.assert_called_once_with( + "auto", distro=self.distro, devices=["/"] + ) rsdevs.assert_called_once_with(myresizer, ["/"]) |