← Back to team overview

openstack team mailing list archive

Re: Errors running individual tests that call into the database

 

On Mon, Jun 11, 2012 at 05:51:44PM +0100, Daniel P. Berrange wrote:
> On Mon, Jun 11, 2012 at 05:04:51PM +0100, John Garbutt wrote:
> > Hi,
> > 
> > I am trying to run tests like "test_xenapi" and "test_libvirt" by
> > themselves do things like:
> >    nosetests test_xenapi
> > But it does work, I get DB errors relating to missing tables.
> > However, I can successfully run all the tests.
> > 
> > The way I understand it:
> >  - nova.tests.__init__.py setup() does the database setup
> >  - nova.test.py TestCase.setUp() does the resetting of the db
> >  It is almost like doing "nosetests test_asdf" skips the database
> > setup in nova.tests.__init__.py, is that correct?
> > 
> > Any ideas on how to run tests individually, but still get the
> > database correclty initialized? Am I just calling the tests incorrectly?
> 
> I don't know the answer to your question, but I found this regression in
> functionality was caused by the following commit:
> 
>   commit cf31b789927cedfd08c67dcf207b4a10ce2b1db6
>   Author: Monty Taylor <mordred@xxxxxxxxxxxx>
>   Date:   Sun Jun 3 13:03:21 2012 -0400
> 
>     Finalize tox config.
>     
>     Shrink tox.ini to the new short version.
>     Fix the test cases to be able to be run in nosetets plus the
>     openstack.nose_plugin, which finally removes the need for
>     nova/testing/runner.py
>     Also, now we'll just output directly to stdout, which will
>     make nose collect the trace logging directly and either output
>     it at the end of the run, or inject it into the xunit output
>     appropriately.
>     
>     Change-Id: I1456e18a11a840145492038108bdfe812c8230d1
> 
> Before that commit, it was possible to just invoke something like
> 
>    ./run_tests.sh -N -P test_libvirt
> 
> from the nova top level GIT directory to run an individual test suite.

After examining that commit I discovered that the old testing/runner.py
file have a bit of magic to auto-prefix nova.tests onto any args:

     # If any argument looks like a test name but doesn't have "nova.tests" in
     # front of it, automatically add that so we don't have to type as much
     for i, arg in enumerate(argv):
         if arg.startswith('test_'):
             argv[i] = 'nova.tests.%s' % arg

Since we lost this, you now have to fully specify the names of the
individual tests you want to run. eg this works for me:

  ./run_tests.sh -N -P nova.tests.test_libvirt


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


Follow ups

References