Ejemplo n.º 1
0
 def _load_backend(self):
     with self._lock:
         if not self._backend:
             # Import the untranslated name if we don't have a mapping
             backend_path = self._backend_mapping.get(self._backend_name,
                                                      self._backend_name)
             backend_mod = importutils.import_module(backend_path)
             self._backend = backend_mod.get_backend()
Ejemplo n.º 2
0
 def _load_backend(self):
     with self._lock:
         if not self._backend:
             # Import the untranslated name if we don't have a mapping
             backend_path = self._backend_mapping.get(
                 self._backend_name, self._backend_name)
             backend_mod = importutils.import_module(backend_path)
             self._backend = backend_mod.get_backend()
Ejemplo n.º 3
0
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

"""Unit tests for DB API."""

import mock
from oslo.config import cfg

from oslo.db import api
from oslo.db import exception
from oslo.db.openstack.common import importutils
from tests import utils as test_utils

sqla = importutils.import_module("sqlalchemy")


def get_backend():
    return DBAPI()


class DBAPI(object):
    def _api_raise(self, *args, **kwargs):
        """Simulate raising a database-has-gone-away error

        This method creates a fake OperationalError with an ID matching
        a valid MySQL "database has gone away" situation. It also decrements
        the error_counter so that we can artificially keep track of
        how many times this function is called by the wrapper. When
        error_counter reaches zero, this function returns True, simulating
Ejemplo n.º 4
0
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

"""Unit tests for DB API."""

import mock

from oslo.db import api
from oslo.db import exception
from oslo.db.openstack.common import importutils
from tests import utils as test_utils

sqla = importutils.import_module('sqlalchemy')


def get_backend():
    return DBAPI()


class DBAPI(object):
    def _api_raise(self, *args, **kwargs):
        """Simulate raising a database-has-gone-away error

        This method creates a fake OperationalError with an ID matching
        a valid MySQL "database has gone away" situation. It also decrements
        the error_counter so that we can artificially keep track of
        how many times this function is called by the wrapper. When
        error_counter reaches zero, this function returns True, simulating
Ejemplo n.º 5
0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
"""Unit tests for DB API."""

import mock

from oslo.db import api
from oslo.db import exception
from oslo.db.openstack.common import importutils
from tests import utils as test_utils

sqla = importutils.import_module('sqlalchemy')


def get_backend():
    return DBAPI()


class DBAPI(object):
    def _api_raise(self, *args, **kwargs):
        """Simulate raising a database-has-gone-away error

        This method creates a fake OperationalError with an ID matching
        a valid MySQL "database has gone away" situation. It also decrements
        the error_counter so that we can artificially keep track of
        how many times this function is called by the wrapper. When
        error_counter reaches zero, this function returns True, simulating