[Functional] Increase test_timeout for db migration tests

In Neutron we hit quite often same issue as Manila, see [1] for
details.
It looks that solution for this problem may be increase timeout
for test_walk_version functional tests.
Higher timeout will be applied for tests for both pgsql and mysql
backends but it is mostly needed for mysql because 'pymysql' works
much slower on slow nodes than 'psycopg2'

This patch adds also new decorator to set individual timeout for
tests.

[1] https://bugs.launchpad.net/manila/+bug/1501272

Change-Id: I5f344af6dc3e5a6ee5f52c250b6c719e1b43e02d
Closes-Bug: #1687027
This commit is contained in:
Slawek Kaplonski 2018-10-12 12:35:10 +02:00
parent 57a0181c35
commit c2c37272bf
2 changed files with 28 additions and 1 deletions

View File

@ -109,6 +109,22 @@ def unstable_test(reason):
return decor
def set_timeout(timeout):
"""Timeout decorator for 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 decor(f):
@functools.wraps(f)
def inner(self, *args, **kwargs):
self.useFixture(fixtures.Timeout(timeout, gentle=True))
return f(self, *args, **kwargs)
return inner
return decor
def get_rootwrap_cmd():
return os.environ.get('OS_ROOTWRAP_CMD', SUDO_CMD)

View File

@ -577,7 +577,18 @@ class _TestWalkMigrations(object):
class TestWalkMigrationsMysql(testlib_api.MySQLTestCaseMixin,
_TestWalkMigrations,
testlib_api.SqlTestCaseLight):
pass
# NOTE(slaweq): this workaround is taken from Manila patch:
# https://review.openstack.org/#/c/291397/
# Set 5 minutes timeout for case of running it on
# very slow nodes/VMs. Note, that this test becomes slower with each
# addition of new DB migration. On fast nodes it can take about 5-10
# secs having Mitaka set of migrations. 'pymysql' works much slower
# on slow nodes than 'psycopg2' and because of that this increased
# timeout is required only when for testing with 'mysql' backend.
@test_base.set_timeout(300)
def test_walk_versions(self):
super(TestWalkMigrationsMysql, self).test_walk_versions()
class TestWalkMigrationsPsql(testlib_api.PostgreSQLTestCaseMixin,