From c2c37272bf788aac63399127cddd487dc0f15c38 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Fri, 12 Oct 2018 12:35:10 +0200 Subject: [PATCH] [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 --- neutron/tests/base.py | 16 ++++++++++++++++ neutron/tests/functional/db/test_migrations.py | 13 ++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/neutron/tests/base.py b/neutron/tests/base.py index c9dc3cfc04f..789d4c22b9c 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -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) diff --git a/neutron/tests/functional/db/test_migrations.py b/neutron/tests/functional/db/test_migrations.py index caf0e649d4b..baca2a28b15 100644 --- a/neutron/tests/functional/db/test_migrations.py +++ b/neutron/tests/functional/db/test_migrations.py @@ -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,