From 4a66adf94c4e01ca92dfe12cf8646d11acfc7176 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Fri, 11 Feb 2022 17:43:34 +0000 Subject: [PATCH] Group execution of SQL functional tests Functional SQL tests (MySQL and PostgreSQL) use the DB installed backend. To avoid overloading the DB engine, the test cases are grouped [1] together and executed by the same worker process. That will ensure those tests are not executed in parallel, interfering each other. All test classes ended in "MySQL" or "PostgreSQL" are now grouped. That means the tests implemented inside the same class are executed in the same worker, not in parallel. **HOWEVER**, that doesn't guarantee all test cases using the same database backend will run in the same worker serially. The FT job can still execute test cases from different classes, using the same DB backend, in two workers at the same time. This patch also fixes the ``TestReservation*`` classes to inherit from the parent classes in the correct order. That sets the "DRIVER" value to the expected one "mysql" or "postgresql". [1]https://review.opendev.org/c/openstack/neutron/+/785568 Closes-Bug: #1962594 Related-Bug: #1687027 Change-Id: I6bca7daf4d3e46071686bb62d5988ae314af8e7e --- ...test_c3e9d13c4367_add_binding_index_to_.py | 10 +++++----- neutron/tests/functional/db/test_ipam.py | 4 ++-- .../tests/functional/db/test_migrations.py | 20 +++++++++---------- .../tests/functional/objects/test_quota.py | 7 ++++--- tox.ini | 2 +- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/neutron/tests/functional/db/migrations/test_c3e9d13c4367_add_binding_index_to_.py b/neutron/tests/functional/db/migrations/test_c3e9d13c4367_add_binding_index_to_.py index 8668f3b33b5..51bfdbad0da 100644 --- a/neutron/tests/functional/db/migrations/test_c3e9d13c4367_add_binding_index_to_.py +++ b/neutron/tests/functional/db/migrations/test_c3e9d13c4367_add_binding_index_to_.py @@ -78,13 +78,13 @@ class NetworkDhcpAgentBindingMigrationMixin(object): self.assertEqual(list(range(1, 3)), sorted(binding_indices)) -class TestNetworkDhcpAgentBindingMigrationMysql( +class TestNetworkDhcpAgentBindingMigrationMySQL( NetworkDhcpAgentBindingMigrationMixin, - test_migrations.TestWalkMigrationsMysql): + test_migrations.TestWalkMigrationsMySQL): pass -class TestNetworkDhcpAgentBindingMigrationPsql( - NetworkDhcpAgentBindingMigrationMixin, - test_migrations.TestWalkMigrationsPsql): +class TestNetworkDhcpAgentBindingMigrationPostgreSQL( + NetworkDhcpAgentBindingMigrationMixin, + test_migrations.TestWalkMigrationsPostgreSQL): pass diff --git a/neutron/tests/functional/db/test_ipam.py b/neutron/tests/functional/db/test_ipam.py index b79a1957705..183ceacab2f 100644 --- a/neutron/tests/functional/db/test_ipam.py +++ b/neutron/tests/functional/db/test_ipam.py @@ -140,9 +140,9 @@ class IpamTestCase(testlib_api.SqlTestCase): self._create_port(self.port_id) -class TestIpamMySql(testlib_api.MySQLTestCaseMixin, IpamTestCase): +class TestIpamMySQL(testlib_api.MySQLTestCaseMixin, IpamTestCase): pass -class TestIpamPsql(testlib_api.PostgreSQLTestCaseMixin, IpamTestCase): +class TestIpamPostgreSQL(testlib_api.PostgreSQLTestCaseMixin, IpamTestCase): pass diff --git a/neutron/tests/functional/db/test_migrations.py b/neutron/tests/functional/db/test_migrations.py index 94d079a7229..037b6fdc811 100644 --- a/neutron/tests/functional/db/test_migrations.py +++ b/neutron/tests/functional/db/test_migrations.py @@ -340,7 +340,7 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync): msg='Offline contract migration scripts are forbidden for Ocata+') -class TestModelsMigrationsMysql(testlib_api.MySQLTestCaseMixin, +class TestModelsMigrationsMySQL(testlib_api.MySQLTestCaseMixin, _TestModelsMigrations, testlib_api.SqlTestCaseLight, functional_base.BaseLoggingTestCase): @@ -364,12 +364,12 @@ class TestModelsMigrationsMysql(testlib_api.MySQLTestCaseMixin, self.assertEqual(0, len(res), "%s non InnoDB tables created" % res) def test_models_sync(self): - super(TestModelsMigrationsMysql, self).test_models_sync() + super(TestModelsMigrationsMySQL, self).test_models_sync() -class TestModelsMigrationsPsql(testlib_api.PostgreSQLTestCaseMixin, - _TestModelsMigrations, - testlib_api.SqlTestCaseLight): +class TestModelsMigrationsPostgreSQL(testlib_api.PostgreSQLTestCaseMixin, + _TestModelsMigrations, + testlib_api.SqlTestCaseLight): pass @@ -575,7 +575,7 @@ class _TestWalkMigrations(object): migration.do_alembic_command(config, 'upgrade', dest) -class TestWalkMigrationsMysql(testlib_api.MySQLTestCaseMixin, +class TestWalkMigrationsMySQL(testlib_api.MySQLTestCaseMixin, _TestWalkMigrations, testlib_api.SqlTestCaseLight): @@ -589,10 +589,10 @@ class TestWalkMigrationsMysql(testlib_api.MySQLTestCaseMixin, # timeout is required only when for testing with 'mysql' backend. @test_base.set_timeout(600) def test_walk_versions(self): - super(TestWalkMigrationsMysql, self).test_walk_versions() + super(TestWalkMigrationsMySQL, self).test_walk_versions() -class TestWalkMigrationsPsql(testlib_api.PostgreSQLTestCaseMixin, - _TestWalkMigrations, - testlib_api.SqlTestCaseLight): +class TestWalkMigrationsPostgreSQL(testlib_api.PostgreSQLTestCaseMixin, + _TestWalkMigrations, + testlib_api.SqlTestCaseLight): pass diff --git a/neutron/tests/functional/objects/test_quota.py b/neutron/tests/functional/objects/test_quota.py index 10061acfabe..442caee1971 100644 --- a/neutron/tests/functional/objects/test_quota.py +++ b/neutron/tests/functional/objects/test_quota.py @@ -62,10 +62,11 @@ class _ReservationSql(testlib_api.SqlTestCase): self.assertIsInstance(res_map['port'], int) -class TestReservationMySQL(_ReservationSql, testlib_api.MySQLTestCaseMixin): +class TestReservationMySQL(testlib_api.MySQLTestCaseMixin, + _ReservationSql): pass -class TestReservationPostgreSQL(_ReservationSql, - testlib_api.PostgreSQLTestCaseMixin): +class TestReservationPostgreSQL(testlib_api.PostgreSQLTestCaseMixin, + _ReservationSql): pass diff --git a/tox.ini b/tox.ini index 87c99f6ca1a..a7ac5f52fd2 100644 --- a/tox.ini +++ b/tox.ini @@ -63,7 +63,7 @@ deps = {[testenv:functional]deps} commands = {toxinidir}/tools/deploy_rootwrap.sh {toxinidir} {envdir}/etc {envdir}/bin - stestr run --group_regex=neutron\.tests\.functional\.db\.test_migrations\.(TestModelsMigrationsPsql|TestModelsMigrationsMysql) {posargs} + stestr run --group_regex=(.*MySQL\.|.*PostgreSQL\.) {posargs} [testenv:dsvm-fullstack] setenv = {[testenv]setenv}