Run functional tests with memory persistence

We are currently running functional tests with the memory DB persistence
plugin to ensure that the migrations run successfully, but this means
that we could be hiding issues on drivers that are not 100% compatible
with the persistence plugin mechanism, because the DB plugin still has
the SQLAlchemy implementation behind, which other plugins don't.

This patch first initializes cinderlib with the memory DB plugin to test
the DB migrations, and then replaces it with the memory plugin to ensure
driver compatibility by default.

We can still run the tests using the Memory DB persistence model setting
the CL_FTEST_MEMORY_PERSISTENCE environmental variable to false.

To ensure we are constantly testing both we run the LVM gate job with
Memory DB persistence and the Ceph gate with Memory persistence.

Related-Bug: #1821898
Change-Id: Id98c827ffadf2c47ff835afa8b0f83dddacb54fa
This commit is contained in:
Gorka Eguileor
2019-03-27 20:16:31 +01:00
parent bcf071097e
commit c97367d89d
2 changed files with 24 additions and 1 deletions

View File

@@ -46,6 +46,13 @@
- openstack/cinder
pre-run: playbooks/setup-lvm.yaml
nodeset: centos-7
vars:
tox_environment:
CL_FTEST_MEMORY_PERSISTENCE: "false"
# These come from great-great-grandparent tox job
NOSE_WITH_HTML_OUTPUT: 1
NOSE_HTML_OUT_FILE: nose_results.html
NOSE_WITH_XUNIT: 1
- job:
name: cinderlib-ceph-functional

View File

@@ -19,6 +19,7 @@ import subprocess
import tempfile
from oslo_config import cfg
from oslo_utils import strutils
import six
import unittest2
import yaml
@@ -50,12 +51,18 @@ def test_all_backends(cls):
return cls
def get_bool_env(param_string, default=False):
param = os.environ.get(param_string, default)
return strutils.bool_from_string(param, strict=True)
class BaseFunctTestCase(unittest2.TestCase):
FNULL = open(os.devnull, 'w')
CONFIG_FILE = os.environ.get('CL_FTEST_CFG', '/etc/cinder/cinder.conf')
PRECISION = os.environ.get('CL_FTEST_PRECISION', 0)
LOGGING_ENABLED = os.environ.get('CL_FTEST_LOGGING', False)
LOGGING_ENABLED = get_bool_env('CL_FTEST_LOGGING', False)
ROOT_HELPER = os.environ.get('CL_FTEST_ROOT_HELPER', 'sudo')
MEMORY_PERSISTENCE = get_bool_env('CL_FTEST_MEMORY_PERSISTENCE', True)
tests_config = None
@classmethod
@@ -90,6 +97,15 @@ class BaseFunctTestCase(unittest2.TestCase):
disable_logs=not config['logs'],
persistence_config={'storage': 'memory_db'})
if cls.MEMORY_PERSISTENCE:
# Now replace it with the memory plugin for the tests to ensure the
# Cinder driver is compatible with the persistence plugin
# mechanism, as the DB plugin could hide issues.
cinderlib.Backend.global_initialization = False
cinderlib.setup(root_helper=cls.ROOT_HELPER,
disable_logs=not config['logs'],
persistence_config={'storage': 'memory'})
# Initialize backends
cls.backends = [cinderlib.Backend(**cfg) for cfg in
config['backends']]