Skip to content

Commit b68e231

Browse files
committed
Wait to stop receiving D-Bus signals in monitor script
We want to verify that stratisd is not sending more signals before we verify that the results are correct in the script itself. Don't delay when running the test, since the script will do the delay itself. Signed-off-by: mulhern <amulhern@redhat.com>
1 parent 7edb7e2 commit b68e231

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

scripts/monitor_dbus_signals.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@ def main():
429429

430430
except KeyboardInterrupt:
431431

432+
# isort: STDLIB
433+
import copy
434+
432435
class Diff: # pylint: disable=too-few-public-methods
433436
"""
434437
Diff between two different managed object results.
@@ -731,6 +734,18 @@ def _check():
731734
print(os.linesep.join(_CALLBACK_ERRORS))
732735
sys.exit(3)
733736

737+
# A sixteen second wait will make it virtually certain that
738+
# stratisd has a chance to do one of its 10 second timer passes on
739+
# pools and filesystems _and_ that the D-Bus task has at least one
740+
# second to send out any resulting signals.
741+
for _ in range(3):
742+
current = copy.deepcopy(_MO)
743+
time.sleep(15)
744+
if current == _MO:
745+
break
746+
else:
747+
sys.exit(4)
748+
734749
try:
735750
result = _check()
736751
except Exception as exco: # pylint: disable=broad-except

testlib/infra.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -543,19 +543,12 @@ def setUp(self):
543543
except FileNotFoundError as err:
544544
raise RuntimeError("monitor_dbus_signals script not found.") from err
545545

546-
def run_check(self, stop_time):
546+
def run_check(self):
547547
"""
548548
Stop the D-Bus monitor script and check the results.
549-
550-
:param int stop_time: the time the test completed
551549
"""
552550
trace = getattr(self, "trace", None)
553551
if trace is not None:
554-
# A sixteen second wait will make it virtually certain that
555-
# stratisd has a chance to do one of its 10 second timer passes on
556-
# pools and filesystems _and_ that the D-Bus task has at least one
557-
# second to send out any resulting signals.
558-
time.sleep(sleep_time(stop_time, 16))
559552
self.trace.send_signal(signal.SIGINT)
560553
(stdoutdata, stderrdata) = self.trace.communicate()
561554

@@ -677,7 +670,7 @@ def teardown(self):
677670
Run post-test checks after test is completed.
678671
"""
679672
stop_time = time.monotonic_ns()
680-
self.dbus_monitor.run_check(stop_time)
673+
self.dbus_monitor.run_check()
681674

682675
SysfsMonitor().run_check()
683676
SymlinkMonitor().run_check()

0 commit comments

Comments
 (0)