]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commit - src/allmydata/test/test_util.py
write node.url and portnum files atomically, to fix race in test_runner
authorBrian Warner <warner@lothar.com>
Mon, 14 May 2012 20:32:03 +0000 (13:32 -0700)
committerBrian Warner <warner@lothar.com>
Mon, 14 May 2012 22:03:14 +0000 (15:03 -0700)
commitc4d7b7b109b583b0c142bac9fae5d983f25fdd1c
tree2656988a4986f585de412f1d46857ee1700c1891
parentbf7e35146417e1e87952f0ca0cc36bd1d830a110
write node.url and portnum files atomically, to fix race in test_runner

Previously, test_runner sometimes fails because the _node_has_started()
poller fires after the portnum file has been opened, but before it has
actually been filled, allowing the test process to observe an empty file,
which flunks the test.

This adds a new fileutil.write_atomically() function (using the usual
write-to-.tmp-then-rename approach), and uses it for both node.url and
client.port . These files are written a bit before the node is really up and
running, but they're late enough for test_runner's purposes, which is to know
when it's safe to read client.port and use 'tahoe restart' (and therefore
SIGINT) to restart the node.

The current node/client code doesn't offer any better "are you really done
with startup" indicator.. the ideal approach would be to either watch the
logfile, or connect to its flogport, but both are a hassle. Changing the node
to write out a new "all done" file would be intrusive for regular
operations.
src/allmydata/node.py
src/allmydata/test/test_runner.py
src/allmydata/test/test_util.py
src/allmydata/util/fileutil.py
src/allmydata/webish.py