Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:openSUSE:Factory:rpmlint:tests
udisks2
0001-tests-Add-offline-and-online-filesystem-gr...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-tests-Add-offline-and-online-filesystem-grow-tests.patch of Package udisks2
From c73288f465107567d91be2658a68c61e5f3f5a16 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek <tbzatek@redhat.com> Date: Tue, 22 Aug 2023 14:19:05 +0200 Subject: [PATCH] tests: Add offline and online filesystem grow tests --- src/tests/dbus-tests/test_80_filesystem.py | 81 +++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/src/tests/dbus-tests/test_80_filesystem.py b/src/tests/dbus-tests/test_80_filesystem.py index 59946720..87d63922 100644 --- a/src/tests/dbus-tests/test_80_filesystem.py +++ b/src/tests/dbus-tests/test_80_filesystem.py @@ -314,7 +314,7 @@ class UdisksFSTestCase(udiskstestcase.UdisksTestCase): rpr, _ = manager.CanRepair(self._fs_signature) except: rpr = chk = rep = False - if not (rpr and chk and rep) or mode & (1 << 1) == 0: + if not (rpr and chk and rep) or mode & BlockDev.FSResizeFlags.OFFLINE_SHRINK == 0: self.skipTest('Cannot check, offline-shrink and repair %s filesystem' % self._fs_signature) disk = self.get_object('/block_devices/' + os.path.basename(self.vdevs[0])) @@ -344,6 +344,85 @@ class UdisksFSTestCase(udiskstestcase.UdisksTestCase): self.assertTrue(block_fs.Check(self.no_options, dbus_interface=self.iface_prefix + '.Filesystem')) self.get_property(block_fs, '.Filesystem', 'Size').assertAlmostEqual(size // 2, delta=1024**2) + def _test_grow(self, online): + TMP_SIZE_1 = 500 * 1024**2 + TMP_SIZE_2 = 2 * TMP_SIZE_1 + + self._check_can_create() + + if not self._can_mount: + self.skipTest('Cannot mount %s filesystem' % self._fs_signature) + + if not self._can_query_size: + self.skipTest('Cannot determine size of %s filesystem' % self._fs_signature) + + manager = self.get_interface(self.get_object('/Manager'), '.Manager') + try: + res, mode, _ = manager.CanResize(self._fs_signature) + except: + res = False + mode = 0 + if not res: + self.skipTest('Cannot resize %s filesystem' % self._fs_signature) + if online and mode & BlockDev.FSResizeFlags.ONLINE_GROW == 0: + self.skipTest('Cannot online-grow %s filesystem' % self._fs_signature) + if not online and mode & BlockDev.FSResizeFlags.OFFLINE_GROW == 0: + self.skipTest('Cannot offline-grow %s filesystem' % self._fs_signature) + + with tempfile.NamedTemporaryFile(prefix="udisks_test", delete=True, mode='w+b') as temp: + temp.truncate(TMP_SIZE_1) + loop_dev_obj_path = manager.LoopSetup(temp.fileno(), self.no_options) + loop_dev_obj = self.get_object(loop_dev_obj_path) + _, loop_dev = loop_dev_obj_path.rsplit("/", 1) + self.addCleanup(self.run_command, 'losetup --detach /dev/%s' % loop_dev) + + # check the initial size + bsize = self.get_property(loop_dev_obj, '.Block', 'Size') + bsize.assertEqual(TMP_SIZE_1) + + # create filesystem + loop_dev_obj.Format(self._fs_signature, self.no_options, dbus_interface=self.iface_prefix + '.Block') + fssize = self.get_property(loop_dev_obj, '.Filesystem', 'Size') + fssize.assertAlmostEqual(TMP_SIZE_1, delta=1024**2) + + # not mounted + mounts = self.get_property(loop_dev_obj, '.Filesystem', 'MountPoints') + mounts.assertLen(0) + + # mount it + if online: + d = dbus.Dictionary(signature='sv') + if self._fs_name: + d['fstype'] = self._fs_name + mnt_path = loop_dev_obj.Mount(d, dbus_interface=self.iface_prefix + '.Filesystem') + self.addCleanup(self.try_unmount, mnt_path) + self.addCleanup(self.try_unmount, '/dev/%s' % loop_dev) + + # resize the loop device + temp.truncate(TMP_SIZE_2) + self.run_command('losetup -c /dev/%s' % loop_dev) + time.sleep(2) + bsize = self.get_property(loop_dev_obj, '.Block', 'Size') + bsize.assertEqual(TMP_SIZE_2) + fssize = self.get_property(loop_dev_obj, '.Filesystem', 'Size') + fssize.assertAlmostEqual(TMP_SIZE_1, delta=1024**2) + + # perform the grow + loop_dev_obj.Resize(dbus.UInt64(TMP_SIZE_2), self.no_options, dbus_interface=self.iface_prefix + '.Filesystem') + fssize = self.get_property(loop_dev_obj, '.Filesystem', 'Size') + fssize.assertAlmostEqual(TMP_SIZE_2, delta=1024**2) + + # unmount + if online: + loop_dev_obj.Unmount(self.no_options, dbus_interface=self.iface_prefix + '.Filesystem') + self.assertFalse(os.path.ismount(mnt_path)) + + def test_online_grow(self): + self._test_grow(True) + + def test_offline_grow(self): + self._test_grow(True) + def test_size(self): self._check_can_create() -- 2.42.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor