Merge "Extend timeout for database migration tests"
This commit is contained in:
commit
8b39e1cee6
@ -34,6 +34,7 @@ from sqlalchemy.engine import reflection
|
||||
|
||||
from cinder.db import migration
|
||||
import cinder.db.sqlalchemy.migrate_repo
|
||||
from cinder.tests.unit import utils as test_utils
|
||||
|
||||
|
||||
class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
||||
@ -348,6 +349,10 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
||||
self.assertIn('destination_project_id', volume_transfer.c)
|
||||
self.assertIn('accepted', volume_transfer.c)
|
||||
|
||||
# NOTE: this test becomes slower with each addition of new DB migration.
|
||||
# 'pymysql' works much slower on slow nodes than 'psycopg2'. And such
|
||||
# timeout mostly required for testing of 'mysql' backend.
|
||||
@test_utils.set_timeout(300)
|
||||
def test_walk_versions(self):
|
||||
self.walk_versions(False, False)
|
||||
self.assert_each_foreign_key_is_part_of_an_index()
|
||||
@ -371,6 +376,7 @@ class TestMysqlMigrations(test_fixtures.OpportunisticDBTestMixin,
|
||||
FIXTURE = test_fixtures.MySQLOpportunisticFixture
|
||||
BOOL_TYPE = sqlalchemy.dialects.mysql.TINYINT
|
||||
|
||||
@test_utils.set_timeout(300)
|
||||
def test_mysql_innodb(self):
|
||||
"""Test that table creation on mysql only builds InnoDB tables."""
|
||||
# add this to the global lists to make reset work with it, it's removed
|
||||
|
@ -14,6 +14,7 @@
|
||||
#
|
||||
|
||||
import datetime
|
||||
import fixtures
|
||||
import socket
|
||||
import sys
|
||||
import uuid
|
||||
@ -23,6 +24,7 @@ from oslo_config import cfg
|
||||
from oslo_service import loopingcall
|
||||
from oslo_utils import timeutils
|
||||
import oslo_versionedobjects
|
||||
import six
|
||||
|
||||
from cinder.common import constants
|
||||
from cinder import context
|
||||
@ -534,3 +536,23 @@ def create_populated_cluster(ctxt, num_services, num_down_svcs=0, **values):
|
||||
for i in range(num_services)
|
||||
]
|
||||
return cluster, svcs
|
||||
|
||||
|
||||
def set_timeout(timeout):
|
||||
"""Timeout decorator for unit test methods.
|
||||
|
||||
Use this decorator for tests that are expected to pass in very specific
|
||||
amount of time, not common for all other tests.
|
||||
It can have either big or small value.
|
||||
"""
|
||||
|
||||
def _decorator(f):
|
||||
|
||||
@six.wraps(f)
|
||||
def _wrapper(self, *args, **kwargs):
|
||||
self.useFixture(fixtures.Timeout(timeout, gentle=True))
|
||||
return f(self, *args, **kwargs)
|
||||
|
||||
return _wrapper
|
||||
|
||||
return _decorator
|
||||
|
Loading…
Reference in New Issue
Block a user