tests: Fix race condition in memory-monitor-dbus.test
This fixes a race condition which frequently caused the
memory-monitor-dbus.py
test to fail.
The registration of the LowMemoryMonitor
object on the bus, and the
GMemoryMonitorDBus
’s connection to the warning signal raced, such that
it was possible for the mock LowMemoryMonitor
to emit a warning signal
before the GMemoryMonitorDBus
proxy was listening, and hence the proxy
would never see the signal.
Fix this by explicitly synchronising the two before proceeding to the tests.
Make the same changes in the memory-monitor-portal.py
test too, even
though that one was not failing. This should remove the need for a 2s
wait on every test run.
There are also some related cleanups in the related Python tests.
Here’s an example of a series of successful pipelines using these changes:
And here’s an example of the prior failure:
Closes #2887 (closed)