Merge "Test fetching backends via entry points"
This commit is contained in:
@@ -16,10 +16,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import contextlib
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
from taskflow.persistence import backends
|
||||
from taskflow.persistence.backends import impl_dir
|
||||
from taskflow import test
|
||||
from taskflow.tests.unit.persistence import base
|
||||
@@ -45,3 +47,20 @@ class DirPersistenceTest(test.TestCase, base.PersistenceTestMixin):
|
||||
if self.path and os.path.isdir(self.path):
|
||||
shutil.rmtree(self.path)
|
||||
self.path = None
|
||||
|
||||
def test_dir_persistence_entry_point(self):
|
||||
conf = {
|
||||
'connection': 'dir:',
|
||||
'path': self.path
|
||||
}
|
||||
backend = backends.fetch(conf)
|
||||
self.assertIsInstance(backend, impl_dir.DirBackend)
|
||||
backend.close()
|
||||
|
||||
def test_file_persistence_entry_point(self):
|
||||
conf = {
|
||||
'connection': 'file:',
|
||||
'path': self.path
|
||||
}
|
||||
with contextlib.closing(backends.fetch(conf)) as be:
|
||||
self.assertIsInstance(be, impl_dir.DirBackend)
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import contextlib
|
||||
|
||||
from taskflow.persistence import backends
|
||||
from taskflow.persistence.backends import impl_memory
|
||||
from taskflow import test
|
||||
from taskflow.tests.unit.persistence import base
|
||||
@@ -34,3 +37,8 @@ class MemoryPersistenceTest(test.TestCase, base.PersistenceTestMixin):
|
||||
conn.clear_all()
|
||||
self._backend = None
|
||||
super(MemoryPersistenceTest, self).tearDown()
|
||||
|
||||
def test_memory_persistence_entry_point(self):
|
||||
conf = {'connection': 'memory:'}
|
||||
with contextlib.closing(backends.fetch(conf)) as be:
|
||||
self.assertIsInstance(be, impl_memory.MemoryBackend)
|
||||
|
||||
@@ -50,6 +50,7 @@ except ImportError:
|
||||
# Testing will try to run against these two mysql library variants.
|
||||
MYSQL_VARIANTS = ('mysqldb', 'pymysql')
|
||||
|
||||
from taskflow.persistence import backends
|
||||
from taskflow import test
|
||||
from taskflow.tests.unit.persistence import base
|
||||
from taskflow.utils import lock_utils
|
||||
@@ -261,3 +262,26 @@ class PostgresPersistenceTest(BackendPersistenceTestMixin, test.TestCase):
|
||||
if engine is not None:
|
||||
engine.dispose()
|
||||
return _get_connect_string('postgres', USER, PASSWD, database=DATABASE)
|
||||
|
||||
|
||||
@testtools.skipIf(not SQLALCHEMY_AVAILABLE, 'sqlalchemy is not available')
|
||||
class SQLBackendFetchingTest(test.TestCase):
|
||||
|
||||
def test_sqlite_persistence_entry_point(self):
|
||||
conf = {'connection': 'sqlite:///'}
|
||||
with contextlib.closing(backends.fetch(conf)) as be:
|
||||
self.assertIsInstance(be, impl_sqlalchemy.SQLAlchemyBackend)
|
||||
|
||||
@testtools.skipIf(not _postgres_exists(), 'postgres is not available')
|
||||
def test_mysql_persistence_entry_point(self):
|
||||
uri = "mysql://%s:%s@localhost/%s" % (USER, PASSWD, DATABASE)
|
||||
conf = {'connection': uri}
|
||||
with contextlib.closing(backends.fetch(conf)) as be:
|
||||
self.assertIsInstance(be, impl_sqlalchemy.SQLAlchemyBackend)
|
||||
|
||||
@testtools.skipIf(not _mysql_exists(), 'mysql is not available')
|
||||
def test_postgres_persistence_entry_point(self):
|
||||
uri = "postgresql://%s:%s@localhost/%s" % (USER, PASSWD, DATABASE)
|
||||
conf = {'connection': uri}
|
||||
with contextlib.closing(backends.fetch(conf)) as be:
|
||||
self.assertIsInstance(be, impl_sqlalchemy.SQLAlchemyBackend)
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import contextlib
|
||||
|
||||
from taskflow.persistence import backends
|
||||
from taskflow.persistence.backends import impl_zookeeper
|
||||
from taskflow import test
|
||||
from taskflow.tests.unit.persistence import base
|
||||
@@ -38,3 +41,8 @@ class ZkPersistenceTest(test.TestCase, base.PersistenceTestMixin):
|
||||
super(ZkPersistenceTest, self).tearDown()
|
||||
conn = self._get_connection()
|
||||
conn.clear_all()
|
||||
|
||||
def test_zk_persistence_entry_point(self):
|
||||
conf = {'connection': 'zookeeper:'}
|
||||
with contextlib.closing(backends.fetch(conf)) as be:
|
||||
self.assertIsInstance(be, impl_zookeeper.ZkBackend)
|
||||
|
||||
Reference in New Issue
Block a user