Skip to content

Commit

Permalink
Add a separate test case for LVMPV smaller than the block device
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechtrefny committed Jan 21, 2025
1 parent 211578a commit 9261d00
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/storage_tests/devices_test/lvm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,53 @@ def test_lvm_pvs_add_remove(self):
self.assertIsNotNone(vg)
self.assertEqual(len(vg.pvs), 1)
self.assertEqual(vg.pvs[0].name, pv2.name)

def test_lvm_pv_size(self):
disk = self.storage.devicetree.get_device_by_path(self.vdevs[0])
self.assertIsNotNone(disk)
self.storage.initialize_disk(disk)

pv = self.storage.new_partition(size=blivet.size.Size("100 MiB"), fmt_type="lvmpv",
parents=[disk])
self.storage.create_device(pv)

blivet.partitioning.do_partitioning(self.storage)

self.storage.do_it()
self.storage.reset()

pv = self.storage.devicetree.get_device_by_name(pv.name)
self.assertIsNotNone(pv)

pv.format.update_size_info()
self.assertTrue(pv.format.resizable)

ac = blivet.deviceaction.ActionResizeFormat(pv, blivet.size.Size("50 MiB"))
self.storage.devicetree.actions.add(ac)

self.storage.do_it()
self.storage.reset()

pv = self.storage.devicetree.get_device_by_name(pv.name)
self.assertIsNotNone(pv)
self.assertEqual(pv.format.size, blivet.size.Size("50 MiB"))
pv_size = self._get_pv_size(pv.path)
self.assertEqual(pv_size, pv.format.size)

vg = self.storage.new_vg(name=self.vgname, parents=[pv])
self.storage.create_device(vg)

self.storage.do_it()
self.storage.reset()

pv = self.storage.devicetree.get_device_by_name(pv.name)
self.assertIsNotNone(pv)
pv_size = self._get_pv_size(pv.path)
self.assertEqual(pv_size, pv.format.size)

vg = self.storage.devicetree.get_device_by_name(self.vgname)
self.assertIsNotNone(vg)
vg_size = self._get_vg_size(vg.name)
self.assertEqual(vg_size, vg.size)
vg_free = self._get_vg_free(vg.name)
self.assertEqual(vg_free, vg.free_space)

0 comments on commit 9261d00

Please sign in to comment.