Code review comment for lp:~allenap/launchpad/isolate-tests

Revision history for this message
Jonathan Lange (jml) wrote :

2010/3/9 Gavin Panella <email address hidden>:
>> On Mon, Mar 08, 2010 at 06:14:32PM -0000, Gavin Panella wrote:
>> > Gavin Panella has proposed merging lp:~allenap/launchpad/isolate-tests into
>> lp:launchpad/devel.
>> >
>> > Requested reviews:
>> >   Canonical Launchpad Engineering (launchpad): code
>> > Related bugs:
>> >   #491870 Use Twisted's thread support instead of the threading module in
>> checkwatches
>> >   https://bugs.launchpad.net/bugs/491870
>> >
>> >
>> > Implement a new class - ZopeIsolatedTestCase - that can be used as a
>> > mixin with more interesting TestCase subclasses. It runs each test
>> > method in a forked sub-process, passing the results back to the parent
>> > process with subunit. This is needed to safely run tests that need to,
>> > for example, start the Twisted reactor, which cannot be safely restarted
>> >    in the same process once stopped.
>> >
>> > This branch also uses ZopeIsolatedTestCase with a couple of job runner
>> > tests. Additionally, one of these tests, TestJobCronScript, has been
>> > fixed to override the command line arguments passed to the script class
>> > (otherwise sys.argv is used, which is stuffed with arguments passed to
>> > bin/test).
>>
>>     vote needsinfo
>>
>> If the job runner tests ran fine previously, why is this
>> ZopeIsolatedTestCase needed?
>
> Jono once told me - and an IRC discussion between Aaron, Jono and
> myself yesterday reconfirmed this - that reactor restarting is not
> supported, and is considered by Twisted developers to not be a working
> feature right now. They want it to work, but it's not high on the
> list. Jono suggested subunit.IsolatedTestCase as a possible solution.
>

To be clear, this kind of solution (run tests in their own
subprocesses) is hardly ever used within the Twisted world, since it's
considered good practice there for asynchronous APIs to return
Deferreds, and to test things at that level. It's extremely rare to
have application code that needs to start and stop the reactor.

jml

« Back to merge proposal