test/common: add a slight stall in tearDown

With the new Foolscap-0.11.0 (which changed the way connections are
established), I'm seeing DirtyReactorErrors getting thrown by
allmydata.test.test_system.SystemTest.test_filesystem_with_cli_in_subprocess
, on a host that has three IP addresses (one is 127.0.0.1, two is wifi,
three is a VPN). The test itself is getting skipped because bin/tahoe
isn't in the expected place, but by that point, the nodes have already
been launched and have established connections over one of the three
hints (probably 127.0.0.1). The test terminates so quickly that the
connections to the other two addresses have not finished being
abandoned. The extra stall seems to give Foolscap enough time to reap
the cancelled connections and makes the DRT go away.

I think an offline test, or maybe one with a single external IP address,
wouldn't hit this case.

Arbitrary stalls are never very satisfactory, of course. Usually there
is some threshold delay value, below which it fails reliably, above
which it works on my own machine (for now). This one is weird: the
threshold seems to be below the resolution of the system clock. Stalling
for one nanosecond was enough to fix the problem, but using a simple
fireEventually() didn't work.
This commit is contained in:
Brian Warner 2016-04-07 20:59:42 -10:00
parent 8279d919f3
commit bb7184163e

View File

@ -453,7 +453,8 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
def tearDown(self):
log.msg("shutting down SystemTest services")
d = self.sparent.stopService()
d = self.stall(0.001)
d.addCallback(lambda _: self.sparent.stopService())
d.addBoth(flush_but_dont_ignore)
return d