summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Alvares Gomes <lucasagomes@gmail.com>2019-01-08 16:04:31 +0000
committerLucas Alvares Gomes <lucasagomes@gmail.com>2019-01-15 16:18:19 +0000
commit29d07bec1694b05287aa175bc4de10a5dc04965e (patch)
tree1efe29d2e457ea0c17b0fa5096633101f3d99ddb
parent04e446f9f9e6a0e2e3ac0e382ee5d6617064cb3c (diff)
Functional: Workaround database failures
This patch inherited and modified the mehtod that creates the database for the functional tests to: 1. Make it atomic by using a lock 2. Removed the singleton nature of it. Prior to this patch, the tests kept a single shared in-memory database. Now, each test will have its own in-memory database. 3. Handle the DBNonExistentTable for failures in the cleanUp() method while deleting the db tables. Partial-Bug: #1808146 Change-Id: I90a50fe1284078f5a5719da54599d4cddc5bd06f Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
Notes
Notes (review): Code-Review+1: Reedip <rbanerje@redhat.com> Code-Review+2: Daniel Alvarez <dalvarez@redhat.com> Workflow+1: Daniel Alvarez <dalvarez@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 16 Jan 2019 13:46:39 +0000 Reviewed-on: https://review.openstack.org/629248 Project: openstack/networking-ovn Branch: refs/heads/master
-rw-r--r--networking_ovn/tests/functional/base.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/networking_ovn/tests/functional/base.py b/networking_ovn/tests/functional/base.py
index d4b78e4..c4c4877 100644
--- a/networking_ovn/tests/functional/base.py
+++ b/networking_ovn/tests/functional/base.py
@@ -20,9 +20,13 @@ import mock
20from neutron.conf.plugins.ml2 import config 20from neutron.conf.plugins.ml2 import config
21from neutron.plugins.ml2.drivers import type_geneve # noqa 21from neutron.plugins.ml2.drivers import type_geneve # noqa
22from neutron.tests.unit.plugins.ml2 import test_plugin 22from neutron.tests.unit.plugins.ml2 import test_plugin
23from neutron.tests.unit import testlib_api
23from neutron_lib.plugins import constants 24from neutron_lib.plugins import constants
24from neutron_lib.plugins import directory 25from neutron_lib.plugins import directory
26from oslo_concurrency import lockutils
25from oslo_config import cfg 27from oslo_config import cfg
28from oslo_db import exception as os_db_exc
29from oslo_db.sqlalchemy import provision
26from oslo_log import log 30from oslo_log import log
27from oslo_utils import uuidutils 31from oslo_utils import uuidutils
28from ovsdbapp.backend.ovs_idl import command 32from ovsdbapp.backend.ovs_idl import command
@@ -41,6 +45,7 @@ LOG = log.getLogger(__name__)
41# This is the directory from which infra fetches log files for functional tests 45# This is the directory from which infra fetches log files for functional tests
42DEFAULT_LOG_DIR = os.path.join(os.environ.get('OS_LOG_PATH', '/tmp'), 46DEFAULT_LOG_DIR = os.path.join(os.environ.get('OS_LOG_PATH', '/tmp'),
43 'dsvm-functional-logs') 47 'dsvm-functional-logs')
48SQL_FIXTURE_LOCK = 'sql_fixture_lock'
44 49
45 50
46class AddFakeChassisCommand(command.BaseCommand): 51class AddFakeChassisCommand(command.BaseCommand):
@@ -79,6 +84,27 @@ class ConnectionFixture(fixtures.Fixture):
79 self.connection.stop() 84 self.connection.stop()
80 85
81 86
87class OVNSqlFixture(testlib_api.StaticSqlFixture):
88
89 @classmethod
90 @lockutils.synchronized(SQL_FIXTURE_LOCK)
91 def _init_resources(cls):
92 cls.schema_resource = provision.SchemaResource(
93 provision.DatabaseResource("sqlite"),
94 cls._generate_schema, teardown=False)
95 dependency_resources = {}
96 for name, resource in cls.schema_resource.resources:
97 dependency_resources[name] = resource.getResource()
98 cls.schema_resource.make(dependency_resources)
99 cls.engine = dependency_resources['database'].engine
100
101 def _delete_from_schema(self, engine):
102 try:
103 super(OVNSqlFixture, self)._delete_from_schema(engine)
104 except os_db_exc.DBNonExistentTable:
105 pass
106
107
82class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase): 108class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase):
83 109
84 # Please see networking_ovn/tests/contrib/gate_hook.sh. 110 # Please see networking_ovn/tests/contrib/gate_hook.sh.
@@ -117,6 +143,16 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase):
117 self._start_ovsdb_server_and_idls() 143 self._start_ovsdb_server_and_idls()
118 self._start_ovn_northd() 144 self._start_ovn_northd()
119 145
146 # FIXME(lucasagomes): Workaround for
147 # https://bugs.launchpad.net/networking-ovn/+bug/1808146. We should
148 # investigate and properly fix the problem. This method is just a
149 # workaround to alleviate the gate for now and should not be considered
150 # a proper fix.
151 def _setup_database_fixtures(self):
152 fixture = OVNSqlFixture()
153 self.useFixture(fixture)
154 self.engine = fixture.engine
155
120 def get_additional_service_plugins(self): 156 def get_additional_service_plugins(self):
121 p = super(TestOVNFunctionalBase, self).get_additional_service_plugins() 157 p = super(TestOVNFunctionalBase, self).get_additional_service_plugins()
122 p.update({'revision_plugin_name': 'revisions'}) 158 p.update({'revision_plugin_name': 'revisions'})