summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobert Schweikert <rjschwei@suse.com>2017-11-27 19:05:52 -0500
committerScott Moser <smoser@ubuntu.com>2018-01-24 09:52:58 -0500
commitb28ab78089d362c5c6cab985feee0f5f84c9db44 (patch)
tree85b0d7ecd54d7227d4526629ff9ca421bd9a29fc /tests
parent8a9421421497b3e7c05589c62389745d565c6633 (diff)
downloadvyos-cloud-init-b28ab78089d362c5c6cab985feee0f5f84c9db44.tar.gz
vyos-cloud-init-b28ab78089d362c5c6cab985feee0f5f84c9db44.zip
btrfs: support resizing if root is mounted ro.
Resize of btrfs fails if the mount point for the file system we are trying to resize, i.e. the root of the filesystem is read only. With this change we use a known (currently snapper specific) rw location to work around a flaw that blocks resizing of the ro filesystem. LP: #1734787
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_handler/test_handler_resizefs.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/unittests/test_handler/test_handler_resizefs.py b/tests/unittests/test_handler/test_handler_resizefs.py
index 29d5574d..5aa3c498 100644
--- a/tests/unittests/test_handler/test_handler_resizefs.py
+++ b/tests/unittests/test_handler/test_handler_resizefs.py
@@ -1,7 +1,7 @@
# This file is part of cloud-init. See LICENSE file for license information.
from cloudinit.config.cc_resizefs import (
- can_skip_resize, handle, maybe_get_writable_device_path)
+ can_skip_resize, handle, maybe_get_writable_device_path, _resize_btrfs)
from collections import namedtuple
import logging
@@ -293,5 +293,25 @@ class TestMaybeGetDevicePathAsWritableBlock(CiTestCase):
" per kernel cmdline",
self.logs.getvalue())
+ @mock.patch('cloudinit.util.mount_is_read_write')
+ @mock.patch('cloudinit.config.cc_resizefs.os.path.isdir')
+ def test_resize_btrfs_mount_is_ro(self, m_is_dir, m_is_rw):
+ """Do not resize / directly if it is read-only. (LP: #1734787)."""
+ m_is_rw.return_value = False
+ m_is_dir.return_value = True
+ self.assertEqual(
+ ('btrfs', 'filesystem', 'resize', 'max', '//.snapshots'),
+ _resize_btrfs("/", "/dev/sda1"))
+
+ @mock.patch('cloudinit.util.mount_is_read_write')
+ @mock.patch('cloudinit.config.cc_resizefs.os.path.isdir')
+ def test_resize_btrfs_mount_is_rw(self, m_is_dir, m_is_rw):
+ """Do not resize / directly if it is read-only. (LP: #1734787)."""
+ m_is_rw.return_value = True
+ m_is_dir.return_value = True
+ self.assertEqual(
+ ('btrfs', 'filesystem', 'resize', 'max', '/'),
+ _resize_btrfs("/", "/dev/sda1"))
+
# vi: ts=4 expandtab