linux: integration-test: fix random test failure for test_bluetooth_hidpp_mouse

Sometime we found the errors shows below when pipeline test was running.

379s ERROR: test_bluetooth_hidpp_mouse (__main__.Tests.test_bluetooth_hidpp_mouse)
379s Logitech Bluetooth LE mouse with HID++ kernel support
379s ----------------------------------------------------------------------
379s Traceback (most recent call last):
379s   File "/usr/libexec/upower/integration-test.py", line 4380, in test_bluetooth_hidpp_mouse
379s     self.assertEventually(
379s     ~~~~~~~~~~~~~~~~~~~~~^
379s         lambda: self.get_dbus_dev_property(bat0_up, "Model"), value=alias
379s         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
379s     )
379s     ^
379s   File "/usr/libexec/upower/integration-test.py", line 399, in assertEventually
379s     if condition() == value:
379s        ~~~~~~~~~^^
379s   File "/usr/libexec/upower/integration-test.py", line 4381, in <lambda>
379s     lambda: self.get_dbus_dev_property(bat0_up, "Model"), value=alias
379s             ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
379s   File "/usr/libexec/upower/integration-test.py", line 316, in get_dbus_dev_property
379s     return self.dbus.call_sync(
379s            ~~~~~~~~~~~~~~~~~~~^
379s         UP,
379s         ^^^
379s     ...<7 lines>...
379s         None,
379s         ^^^^^
379s     ).unpack()[0]
379s     ^
379s gi.repository.GLib.GError: g-dbus-error-quark: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Object does not exist at path “/org/freedesktop/UPower/devices/mouse_dev_11_22_33_44_AA_BB” (19)
379s

The upower and bluez daemons were started after the udev was
initialized to avoid the random errors.
This commit is contained in:
Kate Hsuan 2025-07-29 14:15:25 +08:00
parent bdb05da4a1
commit fe36d9ee4a

View file

@ -4753,8 +4753,11 @@ class Tests(dbusmock.DBusTestCase):
def test_bluetooth_hidpp_mouse(self): def test_bluetooth_hidpp_mouse(self):
"""Logitech Bluetooth LE mouse with HID++ kernel support""" """Logitech Bluetooth LE mouse with HID++ kernel support"""
# Both sleep to ensure that bluez and upower are fully started
self.start_bluez() self.start_bluez()
time.sleep(5)
self.start_daemon() self.start_daemon()
time.sleep(5)
udevs = [] udevs = []
@ -4816,8 +4819,6 @@ class Tests(dbusmock.DBusTestCase):
self.assertEqual(len(devs), 1) self.assertEqual(len(devs), 1)
bat0_up = devs[0] bat0_up = devs[0]
time.sleep(5)
# Check we have the Bluetooth name # Check we have the Bluetooth name
self.assertEventually( self.assertEventually(
lambda: self.get_dbus_dev_property(bat0_up, "Model"), value=alias lambda: self.get_dbus_dev_property(bat0_up, "Model"), value=alias
@ -4856,7 +4857,7 @@ class Tests(dbusmock.DBusTestCase):
adapter = self.dbus_con.get_object("org.bluez", "/org/bluez/hci0") adapter = self.dbus_con.get_object("org.bluez", "/org/bluez/hci0")
adapter.RemoveDevice(bluez_dev_path) adapter.RemoveDevice(bluez_dev_path)
time.sleep(0.5) time.sleep(2)
devs = self.proxy.EnumerateDevices() devs = self.proxy.EnumerateDevices()
self.assertEqual(len(devs), 0) self.assertEqual(len(devs), 0)