[openstack-dev] [nova] fastest way to run individual tests ?

Sean Dague sean at dague.net
Thu Jun 12 11:07:37 UTC 2014


On 06/12/2014 06:59 AM, Daniel P. Berrange wrote:
> When in the middle of developing code for nova I'll typically not wish to
> the run the entire Nova test suite every time I have a bit of code to
> verify. I'll just want to run the single test case that deals with the
> code I'm hacking on.
> 
> I'm currently writing a 'test_hardware.py' test case for the NUMA work
> I'm dealing with. I can run that using 'run_tests.sh' or 'tox' by just
> passing the name of the test case. The test case in question takes a tiny
> fraction of a second to run, but the tox command above wastes 32 seconds
> faffing about before it runs the test itself, while run_tests.sh is not
> much better wasting 22 seconds.
> 
>    # tox -e py27  tests.virt.test_hardware
>    ...snip...
>    real	0m32.923s
>    user	0m22.083s
>    sys	0m4.377s
> 
> 
>    # time ./run_tests.sh tests.virt.test_hardware
>    ...snip...
>    real	0m22.075s
>    user	0m14.282s
>    sys	0m1.407s
> 
> 
> This is a really severe time penalty to incurr each time I want to run
> this tiny test (which is very frequently during dev).
> 
> Does anyone have any tip on how to actually run individual tests in an
> efficient manner. ie something that adds no more than 1 second penalty
> over & above the time to run the test itself. NB, assume that i've primed
> the virtual env with all prerequisite deps already.
> 
> Regards,
> Daniel

The overhead is in the fact that we have to discover the world, then
throw out the world.

You can actually run an individual test via invoking the testtools.run
directly:

> python -m testtools.run nova.tests.test_versions

(Also, when testr explodes because of an import error this is about the
only way to debug what's going on).

	-Sean

-- 
Sean Dague
http://dague.net

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140612/5c20d0c3/attachment.pgp>


More information about the OpenStack-dev mailing list