]> arthur.barton.de Git - bup.git/commit
tests: tclient: fix buffering behaviour in the test
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 13 Aug 2020 13:20:33 +0000 (15:20 +0200)
committerRob Browning <rlb@defaultvalue.org>
Sat, 15 Aug 2020 01:14:22 +0000 (20:14 -0500)
commitde03a2d81530c2bc0495b2c45a210d035192c2b9
tree48172b088fd8175cff3ec911350cf93fb8548754
parent07f74364b1854810f814e81e73822f35b7677318
tests: tclient: fix buffering behaviour in the test

If the objects we write are small enough to be at least
partially buffered instead of written out to the server
connection, the test will hang in the loop as the data
hasn't made it to the server yet, which therefore can't
make a suggestion yet.

In normal non-testing scenarios this isn't an issue as
the connection is flushed before every new read(), and
thus if the client actually needs to wait for something
from the server, it'll have flushed before. Here, we're
directly poking at the internals by using has_input(),
and nothing causes a flush, causing the above scenario.

Fix this by some more ugly poking at the internals and
flush the connection before we go into the loop.

While at it, also avoid hanging there forever and break
out of the loop if one second passed without receiving
anything from the server - that should be long enough
for it to hash the two objects and respond. Also, add a
time.sleep() there to avoid busy spinning which takes
CPU cycles from the server that needs to be hashing the
object.

Reported-by: Robert Edmonds <edmonds@debian.org>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
lib/bup/t/tclient.py