Skip to content

Commit

Permalink
tests: Make test-disconnect more robust
Browse files Browse the repository at this point in the history
On a heavily-loaded CI machine, test-disconnect.sh failed on at least
one machine when a single h.poll(-1) was not sufficient to read the
entire response packet from nbdkit.  Make the test more robust by
looping the poll when needed.
  • Loading branch information
ebblake committed Nov 1, 2022
1 parent 6a7def7 commit b90d47f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
17 changes: 11 additions & 6 deletions tests/test-disconnect-tls.sh
Expand Up @@ -73,22 +73,27 @@ h.set_tls_psk_file("keys.psk")
h.set_tls_username("qemu")
h.connect_unix("'"$sock"'")
def waitfor(cookie):
while True:
c = h.aio_peek_command_completed()
if c:
break
h.poll(-1)
assert c == cookie
buf = nbd.Buffer(1)
c1 = h.aio_pread(buf, 1)
c2 = h.aio_pwrite(buf, 2)
h.poll(-1)
assert h.aio_peek_command_completed() == c2
waitfor(c2)
h.aio_command_completed(c2)
c3 = h.aio_pread(buf, 3)
h.poll(-1)
assert h.aio_peek_command_completed() == c3
waitfor(c3)
try:
h.aio_command_completed(c3)
assert False
except nbd.Error as ex:
assert ex.errnum == errno.ESHUTDOWN
h.poll(-1)
assert h.aio_peek_command_completed() == c1
waitfor(c1)
h.aio_command_completed(c1)
h.shutdown()
'
Expand Down
17 changes: 11 additions & 6 deletions tests/test-disconnect.sh
Expand Up @@ -53,22 +53,27 @@ pid=`cat disconnect.pid`
nbdsh -u "nbd+unix:///?socket=$sock" -c '
import errno
def waitfor(cookie):
while True:
c = h.aio_peek_command_completed()
if c:
break
h.poll(-1)
assert c == cookie
buf = nbd.Buffer(1)
c1 = h.aio_pread(buf, 1)
c2 = h.aio_pwrite(buf, 2)
h.poll(-1)
assert h.aio_peek_command_completed() == c2
waitfor(c2)
h.aio_command_completed(c2)
c3 = h.aio_pread(buf, 3)
h.poll(-1)
assert h.aio_peek_command_completed() == c3
waitfor(c3)
try:
h.aio_command_completed(c3)
assert False
except nbd.Error as ex:
assert ex.errnum == errno.ESHUTDOWN
h.poll(-1)
assert h.aio_peek_command_completed() == c1
waitfor(c1)
h.aio_command_completed(c1)
h.shutdown()
'
Expand Down

0 comments on commit b90d47f

Please sign in to comment.