Skip to content

Commit

Permalink
tests: Remove udevadm settle from test_60_partitioning
Browse files Browse the repository at this point in the history
Should not be necessary anymore now that we're more predictable.
  • Loading branch information
tbzatek committed Jan 9, 2022
1 parent 0877da4 commit 6514f0d
Showing 1 changed file with 5 additions and 36 deletions.
41 changes: 5 additions & 36 deletions src/tests/dbus-tests/test_60_partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def _remove_format(self, device):
try:
device.Format('empty', d, dbus_interface=self.iface_prefix + '.Block')
except dbus.exceptions.DBusException:
self.udev_settle()
time.sleep(5)
device.Format('empty', d, dbus_interface=self.iface_prefix + '.Block')
pass

def _create_format(self, device, ftype):
device.Format(ftype, self.no_options, dbus_interface=self.iface_prefix + '.Block')
Expand All @@ -28,9 +26,7 @@ def _remove_partition(self, part):
try:
part.Delete(self.no_options, dbus_interface=self.iface_prefix + '.Partition')
except dbus.exceptions.DBusException:
self.udev_settle()
time.sleep(5)
part.Delete(self.no_options, dbus_interface=self.iface_prefix + '.Partition')
pass

def test_create_mbr_partition(self):
disk = self.get_object('/block_devices/' + os.path.basename(self.vdevs[0]))
Expand All @@ -55,7 +51,6 @@ def test_create_mbr_partition(self):
# create partition
path1 = disk.CreatePartition(dbus.UInt64(1024**2), dbus.UInt64(100 * 1024**2), part_type, '',
self.no_options, dbus_interface=self.iface_prefix + '.PartitionTable')
self.udev_settle()

part = self.bus.get_object(self.iface_prefix, path1)
self.assertIsNotNone(part)
Expand Down Expand Up @@ -103,7 +98,6 @@ def test_create_mbr_partition(self):
# create another partition
path2 = disk.CreatePartition(dbus.UInt64(1024**2 + (1024**2 + 100 * 1024**2)), dbus.UInt64(100 * 1024**2),
part_type, '', self.no_options, dbus_interface=self.iface_prefix + '.PartitionTable')
self.udev_settle()

part = self.bus.get_object(self.iface_prefix, path2)
self.assertIsNotNone(part)
Expand All @@ -113,7 +107,6 @@ def test_create_mbr_partition(self):
# create yet another partition
path3 = disk.CreatePartition(dbus.UInt64(1024**2 + 2 * (1024**2 + 100 * 1024**2)), dbus.UInt64(100 * 1024**2),
part_type, '', self.no_options, dbus_interface=self.iface_prefix + '.PartitionTable')
self.udev_settle()

part = self.bus.get_object(self.iface_prefix, path3)
self.assertIsNotNone(part)
Expand All @@ -140,7 +133,6 @@ def create_extended_partition(self, ext_options, log_options, part_type=''):
# create extended partition
ext_path = disk.CreatePartition(dbus.UInt64(1024**2), dbus.UInt64(150 * 1024**2), part_type, '',
ext_options, dbus_interface=self.iface_prefix + '.PartitionTable')
self.udev_settle()

ext_part = self.bus.get_object(self.iface_prefix, ext_path)
self.assertIsNotNone(ext_part)
Expand All @@ -163,7 +155,6 @@ def create_extended_partition(self, ext_options, log_options, part_type=''):
# create logical partition
log_path = disk.CreatePartition(dbus.UInt64(1024**2), dbus.UInt64(50 * 1024**2), '', '',
log_options, dbus_interface=self.iface_prefix + '.PartitionTable')
self.udev_settle()

log_part = self.bus.get_object(self.iface_prefix, log_path)
self.assertIsNotNone(log_part)
Expand All @@ -180,7 +171,6 @@ def create_extended_partition(self, ext_options, log_options, part_type=''):
# create one more logical partition
log_path2 = disk.CreatePartition(dbus.UInt64(dbus_offset.value + dbus_size.value), dbus.UInt64(50 * 1024**2), '', '',
log_options, dbus_interface=self.iface_prefix + '.PartitionTable')
self.udev_settle()

log_part2 = self.bus.get_object(self.iface_prefix, log_path2)
self.assertIsNotNone(log_part2)
Expand Down Expand Up @@ -210,7 +200,6 @@ def test_fill_with_primary_partitions(self):
# create primary partition
path = disk.CreatePartition(dbus.UInt64(offset + i * (offset + size)), dbus.UInt64(size), '', '',
options, dbus_interface=self.iface_prefix + '.PartitionTable')
self.udev_settle()

part = self.bus.get_object(self.iface_prefix, path)
self.assertIsNotNone(part)
Expand Down Expand Up @@ -241,7 +230,6 @@ def test_create_gpt_partition(self):
gpt_type, gpt_name,
self.no_options, dbus_interface=self.iface_prefix + '.PartitionTable')

self.udev_settle()
part = self.bus.get_object(self.iface_prefix, path)
self.assertIsNotNone(part)

Expand Down Expand Up @@ -376,7 +364,7 @@ def test_create_with_format_auto_type_gpt(self):
disk = self.get_object('/block_devices/' + os.path.basename(self.vdevs[0]))
self.assertIsNotNone(disk)

# create msdos partition table
# create gpt partition table
self._create_format(disk, 'gpt')

self.addCleanup(self._remove_format, disk)
Expand Down Expand Up @@ -414,9 +402,7 @@ def _remove_format(self, device):
try:
device.Format('empty', d, dbus_interface=self.iface_prefix + '.Block')
except dbus.exceptions.DBusException:
self.udev_settle()
time.sleep(5)
device.Format('empty', d, dbus_interface=self.iface_prefix + '.Block')
pass

def _create_format(self, device, ftype):
device.Format(ftype, self.no_options, dbus_interface=self.iface_prefix + '.Block')
Expand All @@ -425,9 +411,7 @@ def _remove_partition(self, part):
try:
part.Delete(self.no_options, dbus_interface=self.iface_prefix + '.Partition')
except dbus.exceptions.DBusException:
self.udev_settle()
time.sleep(5)
part.Delete(self.no_options, dbus_interface=self.iface_prefix + '.Partition')
pass

def _create_partition(self, disk, start=1024**2, size=100 * 1024**2, fmt='xfs', type=''):
if fmt:
Expand All @@ -439,7 +423,6 @@ def _create_partition(self, disk, start=1024**2, size=100 * 1024**2, fmt='xfs',
self.no_options,
dbus_interface=self.iface_prefix + '.PartitionTable')

self.udev_settle()
part = self.bus.get_object(self.iface_prefix, path)
self.assertIsNotNone(part)

Expand All @@ -457,8 +440,6 @@ def test_delete(self):

part.Delete(self.no_options, dbus_interface=self.iface_prefix + '.Partition')

self.udev_settle()

part_name = path.split('/')[-1]
disk_name = os.path.basename(self.vdevs[0])
part_syspath = '/sys/block/%s/%s' % (disk_name, part_name)
Expand Down Expand Up @@ -491,7 +472,6 @@ def test_dos_flags(self):
# set boot flag (10000000(2), 128(10), 0x80(16))
part.SetFlags(dbus.UInt64(128), self.no_options,
dbus_interface=self.iface_prefix + '.Partition')
self.udev_settle()

# test flags value on types
dbus_flags = self.get_property(part, '.Partition', 'Flags')
Expand Down Expand Up @@ -531,7 +511,6 @@ def test_gpt_flags(self):
# set legacy BIOS bootable flag (100(2), 4(10), 0x4(16))
part.SetFlags(dbus.UInt64(4), self.no_options,
dbus_interface=self.iface_prefix + '.Partition')
self.udev_settle()

# test flags value on types
dbus_flags = self.get_property(part, '.Partition', 'Flags')
Expand Down Expand Up @@ -572,7 +551,6 @@ def test_gpt_type(self):
home_guid = '933ac7e1-2eb4-4f13-b844-0e14e2aef915'
part.SetType(home_guid, self.no_options,
dbus_interface=self.iface_prefix + '.Partition')
self.udev_settle()

# test flags value on types
dbus_type = self.get_property(part, '.Partition', 'Type')
Expand Down Expand Up @@ -606,7 +584,6 @@ def test_dos_type(self):
part_type = '0x8e' # 'Linux LVM' type, see https://en.wikipedia.org/wiki/Partition_type#PID_8Eh
part.SetType(part_type, self.no_options,
dbus_interface=self.iface_prefix + '.Partition')
self.udev_settle()

# test flags value on types
dbus_type = self.get_property(part, '.Partition', 'Type')
Expand Down Expand Up @@ -649,8 +626,6 @@ def test_resize(self):
part.Resize(0, self.no_options,
dbus_interface=self.iface_prefix + '.Partition')

self.udev_settle()

part_offset.assertEqual(initial_offset)
max_size = part_size.value
part_size.assertGreater(initial_size)
Expand All @@ -660,8 +635,6 @@ def test_resize(self):
part.Resize(new_size, self.no_options,
dbus_interface=self.iface_prefix + '.Partition')

self.udev_settle()

part_offset.assertEqual(initial_offset)
# resize should guarantee at least the requested size
part_size.assertGreater(new_size - 1)
Expand All @@ -671,8 +644,6 @@ def test_resize(self):
part.Resize(max_size, self.no_options,
dbus_interface=self.iface_prefix + '.Partition')

self.udev_settle()

part_offset.assertEqual(initial_offset)
part_size.assertGreater(max_size - 1)
part_size.assertLess(disk_size.value)
Expand Down Expand Up @@ -700,8 +671,6 @@ def test_name(self):
part.SetName('test', self.no_options,
dbus_interface=self.iface_prefix + '.Partition')

self.udev_settle()

# test flags value on types
dbus_name = self.get_property(part, '.Partition', 'Name')
dbus_name.assertEqual('test')
Expand Down

0 comments on commit 6514f0d

Please sign in to comment.