]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Ensure no "db" related functional/fullstack tests are skipped in the gate
authorCedric Brandily <zzelle@gmail.com>
Tue, 9 Jun 2015 16:00:58 +0000 (16:00 +0000)
committerCedric Brandily <zzelle@gmail.com>
Mon, 15 Jun 2015 09:18:03 +0000 (11:18 +0200)
Currently neutron uses MySQLTestCase[1] and
PostgreSQLOpportunisticTestCase[2] for functional and fullstack tests
using a real MySQL/PostgreSQL database. These classes skip tests when
the db is unavailable (db not installed/configured, missing packages,
etc.) which is fine when tests are runned by developers but not when
runned by the gate jobs.

This change updates MySQLTestCase[1] and defines PostgreSQLTestCase[1]
as PostgreSQL oslo.db test class wrapper: when the db is unavailable,
these classes ensure tests will:

* fail in the gate (dsvm-functional, dsvm-fullstack jobs),
* be skipped by default otherwise (functional, fullstack jobs).

[1] neutron.tests.common.base
[2] oslo_db.sqlalchemy.test_base

Closes-Bug: #1404093
Change-Id: I77b12e728ce9a7b0222c3df081842635f6375a3e

neutron/tests/common/base.py
neutron/tests/functional/db/test_ipam.py
neutron/tests/functional/db/test_migrations.py

index d1541a63901dfb03cd63d2c1fa74643d503f939d..8c89f9be76ef5be6dceca369b8a3bf1d1cbe1622 100644 (file)
@@ -110,5 +110,17 @@ class MySQLTestCase(test_base.DbTestCase):
     """Base test class for MySQL tests.
 
     Enforce the supported driver, which is PyMySQL.
+    If the MySQL db is unavailable then this test is skipped, unless
+    OS_FAIL_ON_MISSING_DEPS is enabled.
     """
     FIXTURE = PyMySQLFixture
+    SKIP_ON_UNAVAILABLE_DB = not base.bool_from_env('OS_FAIL_ON_MISSING_DEPS')
+
+
+class PostgreSQLTestCase(test_base.PostgreSQLOpportunisticTestCase):
+    """Base test class for PostgreSQL tests.
+
+    If the PostgreSQL db is unavailable then this test is skipped, unless
+    OS_FAIL_ON_MISSING_DEPS is enabled.
+    """
+    SKIP_ON_UNAVAILABLE_DB = not base.bool_from_env('OS_FAIL_ON_MISSING_DEPS')
index c8cb98212a78f10fcc862057dfb1ce4ed02e695e..02dcd20781f648136ee680ca2bd84587c700e6eb 100644 (file)
@@ -15,7 +15,6 @@
 
 from oslo_config import cfg
 from oslo_db.sqlalchemy import session
-from oslo_db.sqlalchemy import test_base
 import testtools
 
 from neutron.api.v2 import attributes
@@ -214,7 +213,7 @@ class TestIpamMySql(common_base.MySQLTestCase, base.BaseTestCase,
         self.configure_test()
 
 
-class TestIpamPsql(test_base.PostgreSQLOpportunisticTestCase,
+class TestIpamPsql(common_base.PostgreSQLTestCase,
                    base.BaseTestCase, IpamTestCase):
 
     def setUp(self):
index a7a9b386890ec889e58be8645c03ac8928c654de..ad3fd85953453731cfddd7f27015f1d1aefb4bce 100644 (file)
@@ -214,7 +214,7 @@ class TestModelsMigrationsMysql(_TestModelsMigrations,
 
 
 class TestModelsMigrationsPsql(_TestModelsMigrations,
-                               test_base.PostgreSQLOpportunisticTestCase):
+                               base.PostgreSQLTestCase):
     pass