Merge "Allow more time for DB migration tests" into stable/mitaka
This commit is contained in:
commit
6f3869d136
|
@ -1,4 +1,8 @@
|
|||
[DEFAULT]
|
||||
test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_LOG_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./neutron/tests/unit} $LISTOPT $IDOPTION
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||
OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \
|
||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \
|
||||
${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./neutron/tests/unit} $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
|
|
|
@ -424,3 +424,34 @@ class PluginFixture(fixtures.Fixture):
|
|||
if plugin() and not isinstance(plugin(), mock.Base):
|
||||
raise AssertionError(
|
||||
'The plugin for this test was not deallocated.')
|
||||
|
||||
|
||||
class Timeout(fixtures.Fixture):
|
||||
"""Setup per test timeouts.
|
||||
|
||||
In order to avoid test deadlocks we support setting up a test
|
||||
timeout parameter read from the environment. In almost all
|
||||
cases where the timeout is reached this means a deadlock.
|
||||
|
||||
A scaling factor allows extremely long tests to specify they
|
||||
need more time.
|
||||
"""
|
||||
|
||||
def __init__(self, timeout=None, scaling=1):
|
||||
super(Timeout, self).__init__()
|
||||
if timeout is None:
|
||||
timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
|
||||
try:
|
||||
self.test_timeout = int(timeout)
|
||||
except ValueError:
|
||||
# If timeout value is invalid do not set a timeout.
|
||||
self.test_timeout = 0
|
||||
if scaling >= 1:
|
||||
self.test_timeout *= scaling
|
||||
else:
|
||||
raise ValueError('scaling value must be >= 1')
|
||||
|
||||
def setUp(self):
|
||||
super(Timeout, self).setUp()
|
||||
if self.test_timeout > 0:
|
||||
self.useFixture(fixtures.Timeout(self.test_timeout, gentle=True))
|
||||
|
|
|
@ -27,6 +27,7 @@ import neutron.db.migration as migration_help
|
|||
from neutron.db.migration.alembic_migrations import external
|
||||
from neutron.db.migration import cli as migration
|
||||
from neutron.db.migration.models import head as head_models
|
||||
from neutron.tests import base as ntest_base
|
||||
from neutron.tests.common import base
|
||||
|
||||
cfg.CONF.import_opt('core_plugin', 'neutron.common.config')
|
||||
|
@ -99,6 +100,8 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync):
|
|||
- wrong value.
|
||||
'''
|
||||
|
||||
TIMEOUT_SCALING_FACTOR = 4
|
||||
|
||||
def setUp(self):
|
||||
super(_TestModelsMigrations, self).setUp()
|
||||
self.cfg = self.useFixture(config_fixture.Config())
|
||||
|
@ -106,6 +109,10 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync):
|
|||
self.alembic_config = migration.get_neutron_config()
|
||||
self.alembic_config.neutron_config = cfg.CONF
|
||||
|
||||
# Migration tests can take a long time
|
||||
self.useFixture(
|
||||
ntest_base.Timeout(scaling=self.TIMEOUT_SCALING_FACTOR))
|
||||
|
||||
def db_sync(self, engine):
|
||||
cfg.CONF.set_override('connection', engine.url, group='database')
|
||||
migration.do_alembic_command(self.alembic_config, 'upgrade', 'heads')
|
||||
|
|
Loading…
Reference in New Issue