Skip to content

Commit ed6c78f

Browse files
committed
tests: wait longer to make sure sanlock settled
Wait a bit longer to make sure sanlock is settled. Otherwise we have an invalid failure. Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
1 parent ab88c71 commit ed6c78f

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

tests/python_test.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,22 @@ def test_acquire_release_resource(tmpdir, sanlock_daemon, size, offset):
427427
sanlock.get_hosts(b"ls_name", 1)
428428
assert e.value.errno == errno.EAGAIN
429429

430-
time.sleep(1)
431-
host = sanlock.get_hosts(b"ls_name", 1)[0]
430+
# With iotimeout=1 the scan interval is 2*io_timeout=2s; HOST_LIVE requires
431+
# two scan cycles (the second sees the timestamp change), so ~4s minimum.
432+
# Poll for up to 10s to avoid flakiness.
433+
deadline = time.monotonic() + 10
434+
while True:
435+
try:
436+
host = sanlock.get_hosts(b"ls_name", 1)[0]
437+
except sanlock.SanlockException as e:
438+
if e.errno != errno.EAGAIN:
439+
raise
440+
else:
441+
if host["flags"] == sanlock.HOST_LIVE:
442+
break
443+
assert time.monotonic() < deadline, \
444+
f"Timed out waiting for HOST_LIVE, current flags: {host['flags']}"
445+
time.sleep(0.5)
432446
assert host["flags"] == sanlock.HOST_LIVE
433447

434448
disks = [(res_path, offset)]

0 commit comments

Comments
 (0)