[Twisted-Python] Ticket Hall of Shame - Current Loser: Brian Warner

glyph at divmod.com glyph at divmod.com
Fri Jan 12 13:31:02 MST 2007

On 08:00 pm, exarkun at divmod.com wrote:
>On Fri, 12 Jan 2007 10:54:10 -0800, Scott Lamb <slamb at slamb.org> wrote:

>>(1) create a test that likely fails by running many, many times. It'd  bog 
>>down the test suite.
>>(2) create a test that might fail sometime, maybe.
>>(3) add instrumentation to the main code solely for the purpose of  the 
>>test (break twisted's kneecap before the race).
>>(4) just say "clearly[*] if event A happens between lines X and Y,  then it 
>>is handled improperly."
>>I prefer #4.
>I think this actually varies from case to case.  For a problem where all
>of the relevant critical points cannot be hooked or mocked or stubbed or
>what have you, then a combination of #2 and #4 seems correct to me.  You
>should be able to demonstrate that a real problem does exist by adding a
>test which will fail eventually when run repeatedly (eg, using trial -u)
>and which runs for orders of magnitude longer without failing once a fix
>has been applied.

Race conditions are tricky, but in every case it is worth _trying_ to mock/stub/hook the code as it already is to demonstrate it deterministically.  It isn't always possible with a reasonable amount of effort, but very often it is actually quite easy.  As you do it more, it gets easier to figure out the trickier cases.

In any case, writing a test (which runs quickly) to be used with trial -u is a pretty low bar.  There are some extremely rare cases (mostly involving threading infrastructure) where those tests take a long time to fail, but even there it is usually possible to make them *succeed* reliably.

>Always feel free to file the ticket before figuring any of this out, by
>the way.  It is still possible that it will strike someone else's fancy
>and the rest of the work will be taken care of for you. :)

And of course this is always true.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20070112/2f60ca07/attachment.html>

More information about the Twisted-Python mailing list