Setup memory DB in test_cmd

Currently, test_cmd fails or not depending if
database_utils.setup_in_memory_db() was already called. It looks like
the test doesn't fail on Python 2, but it fails *sometimes* on
Python 3.

Maybe the tests are run in a diffrent order on Python 3 because of
the randomized hash function (it can be tried on Python 2 using -R
Python command line option).

The bug can been reproduced easily be running only test_cmd
on Python 2.7:

    $ . .tox/py27/bin/activate
    $ testr run barbican.tests.cmd.test_cmd
    ...
    FAIL: barbican.tests.cmd.test_cmd.WhenInvokingWorkerCommand.test_should_launch_service
    ...
    BarbicanException: No SQL connection configured

Change-Id: Ic68582193fa4a5002cab8333797eb3fe2881f051
This commit is contained in:
Victor Stinner
2016-06-21 12:02:54 +02:00
parent 873a2a5d94
commit c6342039cc

View File

@ -16,6 +16,7 @@ import mock
from barbican.cmd import retry_scheduler
from barbican.cmd import worker
from barbican.tests import database_utils
from barbican.tests.queue import test_keystone_listener
from barbican.tests import utils
@ -60,6 +61,7 @@ class WhenInvokingWorkerCommand(test_keystone_listener.UtilMixin,
def setUp(self):
super(WhenInvokingWorkerCommand, self).setUp()
database_utils.setup_in_memory_db()
@mock.patch('barbican.queue.init')
@mock.patch('barbican.queue.get_server')