# If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' # cx_Oracle blob support can only address up to sys.maxint on # 32-bit systems, 4GB otherwise. blob_size = min(sys.maxint, 1<<32) suite.addTest(storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), large_blob_size=(not shared_blob_dir) and blob_size + 100, )) return suite if __name__=='__main__': logging.basicConfig() unittest.main(defaultTest="test_suite")
def _add_driver_to_suite(self, suite, layer_prefix, driver_available): for klass in self._make_check_classes(): klass = self._new_class_for_driver(klass, driver_available) suite.addTest(unittest.makeSuite(klass, "check")) for klass in self._make_test_classes(): klass = self._new_class_for_driver(klass, driver_available) suite.addTest(unittest.makeSuite(klass)) for klass in self._make_zodbconvert_classes(): suite.addTest(unittest.makeSuite( self._new_class_for_driver(klass, driver_available))) for klass in self.extra_test_classes: suite.addTest(unittest.makeSuite( self._new_class_for_driver(klass, driver_available))) from relstorage.tests.blob.testblob import storage_reusable_suite from relstorage.options import Options from relstorage.storage import RelStorage for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): # TODO: Make any of the tests that are needing this # subclass StorageCreatingMixin so we unify where # that's handled. history_layer = MinimalTestLayer( '%s%s' % ( 'Shared' if shared_blob_dir else 'Unshared', 'HistoryPreserving' if keep_history else 'HistoryFree', ), suite.layer.__module__ + '.' + suite.layer.__name__ + '.blobs', suite.layer ) layer_name = history_layer.__name__ def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): if not driver_available: raise unittest.SkipTest(str(driver_available)) assert 'driver' not in kw kw['driver'] = driver_available.driver_name db = self.db_names[name] if not keep_history: db += '_hf' options = Options( keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter_maker = self.use_adapter() adapter_maker.driver_name = driver_available.driver_name adapter = adapter_maker.make_adapter(options, db) __traceback_info__ = adapter, options storage = RelStorage(adapter, name=name, options=options) storage.zap_all() return storage prefix = '%s_%s' % ( layer_prefix, layer_name ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir blob_suite = storage_reusable_suite( prefix, create_storage, keep_history=keep_history, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, test_blob_cache=(not shared_blob_dir), # PostgreSQL blob chunks are max 2GB in size large_blob_size=(not shared_blob_dir) and (self.large_blob_size) + 100, storage_is_available=driver_available ) blob_suite.layer.__bases__ = blob_suite.layer.__bases__ + (history_layer,) blob_suite.layer.__module__ = "%s.%s" % ( history_layer.__module__, history_layer.__name__) suite.addTest(blob_suite) return suite
def test_suite(): import relstorage.adapters.postgresql as _adapter try: _adapter.select_driver() except ImportError: import warnings warnings.warn("No PostgreSQL driver is available, so PostgreSQL tests disabled") return unittest.TestSuite() suite = unittest.TestSuite() for klass in [ HPPostgreSQLTests, HPPostgreSQLToFile, HPPostgreSQLFromFile, HFPostgreSQLTests, HFPostgreSQLToFile, HFPostgreSQLFromFile, ]: suite.addTest(unittest.makeSuite(klass, "check")) suite.addTest(unittest.makeSuite(HPPostgreSQLDestZODBConvertTests)) suite.addTest(unittest.makeSuite(HPPostgreSQLSrcZODBConvertTests)) import ZODB.blob from .util import RUNNING_ON_CI if RUNNING_ON_CI or os.environ.get("RS_PG_SMALL_BLOB"): # Avoid creating 2GB blobs to be friendly to neighbors # and to run fast (2GB blobs take about 4 minutes on Travis # CI as-of June 2016) # XXX: This is dirty. from relstorage.adapters.postgresql.mover import PostgreSQLObjectMover as ObjectMover assert hasattr(ObjectMover, 'postgresql_blob_chunk_maxsize') ObjectMover.postgresql_blob_chunk_maxsize = 1024 * 1024 * 10 large_blob_size = ObjectMover.postgresql_blob_chunk_maxsize * 2 else: large_blob_size = 1<<31 from relstorage.tests.blob.testblob import storage_reusable_suite from relstorage.tests.util import shared_blob_dir_choices for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): from relstorage.storage import RelStorage from relstorage.adapters.postgresql import PostgreSQLAdapter db = db_names[name] if not keep_history: db += '_hf' dsn = ('dbname=%s user=relstoragetest ' 'password=relstoragetest' % db) options = Options( keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter = PostgreSQLAdapter(dsn=dsn, options=options) storage = RelStorage(adapter, name=name, options=options) storage.zap_all(slow=True) return storage prefix = 'PostgreSQL%s%s' % ( (shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' suite.addTest(storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), # PostgreSQL blob chunks are max 2GB in size large_blob_size=(not shared_blob_dir) and (large_blob_size) + 100, )) return suite
def test_suite(): import relstorage.adapters.mysql as _adapter try: _adapter.select_driver() except ImportError: import warnings warnings.warn("No MySQL driver is available, so MySQL tests disabled") return unittest.TestSuite() suite = unittest.TestSuite() for klass in [ HPMySQLTests, HPMySQLToFile, HPMySQLFromFile, HFMySQLTests, HFMySQLToFile, HFMySQLFromFile, ]: suite.addTest(unittest.makeSuite(klass, "check")) suite.addTest(unittest.makeSuite(HPMySQLDestZODBConvertTests)) suite.addTest(unittest.makeSuite(HPMySQLSrcZODBConvertTests)) import ZODB.blob from relstorage.tests.blob.testblob import storage_reusable_suite from relstorage.tests.util import shared_blob_dir_choices for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): from relstorage.storage import RelStorage from relstorage.adapters.mysql import MySQLAdapter db = db_names[name] if not keep_history: db += '_hf' options = Options( keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter = MySQLAdapter( options=options, db=db, user='******', passwd='relstoragetest', ) storage = RelStorage(adapter, name=name, options=options) storage.zap_all() return storage prefix = 'MySQL%s%s' % ( (shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' # MySQL is limited to the blob_chunk_size as there is no # native blob streaming support. (Note: this depends on # the max_allowed_packet size on the server as well as the driver; both # values default to 1MB. But umysqldb needs 1.3MB max_allowed_packet size # to send multiple 1MB chunks. So keep it small.) blob_size = Options().blob_chunk_size suite.addTest(storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), large_blob_size=(not shared_blob_dir) and blob_size + 100 )) return suite
def test_suite(): # pylint:disable=too-many-locals import relstorage.adapters.oracle as _adapter try: _adapter.select_driver() except ImportError: import warnings warnings.warn("cx_Oracle is not importable, so Oracle tests disabled") return unittest.TestSuite() suite = unittest.TestSuite() for klass in [ HPOracleTests, HPOracleToFile, HPOracleFromFile, HFOracleTests, HFOracleToFile, HFOracleFromFile, ]: suite.addTest(unittest.makeSuite(klass, "check")) from .util import RUNNING_ON_CI if RUNNING_ON_CI or os.environ.get("RS_ORCL_SMALL_BLOB"): # cx_Oracle blob support can only address up to sys.maxint on # 32-bit systems, 4GB otherwise. This takes a great deal of time, however, # so allow tuning it down. from relstorage.adapters.oracle.mover import OracleObjectMover as ObjectMover assert hasattr(ObjectMover, 'oracle_blob_chunk_maxsize') ObjectMover.oracle_blob_chunk_maxsize = 1024 * 1024 * 10 large_blob_size = ObjectMover.oracle_blob_chunk_maxsize * 2 else: large_blob_size = min(sys.maxsize, 1<<32) from relstorage.tests.blob.testblob import storage_reusable_suite dsn = os.environ.get('ORACLE_TEST_DSN', 'XE') from relstorage.tests.util import shared_blob_dir_choices for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): from relstorage.storage import RelStorage from relstorage.adapters.oracle import OracleAdapter db = db_names[name] if not keep_history: db += '_hf' options = Options( keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter = OracleAdapter( user=db, password='******', dsn=dsn, options=options, ) storage = RelStorage(adapter, name=name, options=options) storage.zap_all() return storage prefix = 'Oracle%s%s' % ( (shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' blob_size = large_blob_size suite.addTest(storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), large_blob_size=(not shared_blob_dir) and blob_size + 100, )) return suite
def test_suite(): # pylint:disable=too-many-locals import relstorage.adapters.oracle as _adapter try: _adapter.select_driver() except ImportError: import warnings warnings.warn("cx_Oracle is not importable, so Oracle tests disabled") return unittest.TestSuite() suite = unittest.TestSuite() for klass in [ HPOracleTests, HPOracleToFile, HPOracleFromFile, HFOracleTests, HFOracleToFile, HFOracleFromFile, ]: suite.addTest(unittest.makeSuite(klass, "check")) from .util import RUNNING_ON_CI if RUNNING_ON_CI or os.environ.get("RS_ORCL_SMALL_BLOB"): # cx_Oracle blob support can only address up to sys.maxint on # 32-bit systems, 4GB otherwise. This takes a great deal of time, however, # so allow tuning it down. from relstorage.adapters.oracle.mover import OracleObjectMover as ObjectMover assert hasattr(ObjectMover, 'oracle_blob_chunk_maxsize') ObjectMover.oracle_blob_chunk_maxsize = 1024 * 1024 * 10 large_blob_size = ObjectMover.oracle_blob_chunk_maxsize * 2 else: large_blob_size = min(sys.maxsize, 1 << 32) from relstorage.tests.blob.testblob import storage_reusable_suite dsn = os.environ.get('ORACLE_TEST_DSN', 'XE') from relstorage.tests.util import shared_blob_dir_choices for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): from relstorage.storage import RelStorage from relstorage.adapters.oracle import OracleAdapter db = db_names[name] if not keep_history: db += '_hf' options = Options(keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter = OracleAdapter( user=db, password='******', dsn=dsn, options=options, ) storage = RelStorage(adapter, name=name, options=options) storage.zap_all() return storage prefix = 'Oracle%s%s' % ( (shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' blob_size = large_blob_size suite.addTest( storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), large_blob_size=(not shared_blob_dir) and blob_size + 100, )) return suite
def test_suite(): try: import MySQLdb except ImportError: e = sys.exc_info()[1] import warnings warnings.warn("MySQLdb is not importable, so MySQL tests disabled") return unittest.TestSuite() suite = unittest.TestSuite() for klass in [ HPMySQLTests, HPMySQLToFile, HPMySQLFromFile, HFMySQLTests, HFMySQLToFile, HFMySQLFromFile, ]: suite.addTest(unittest.makeSuite(klass, "check")) try: import ZODB.blob except ImportError: # ZODB < 3.8 pass else: from relstorage.tests.blob.testblob import storage_reusable_suite from relstorage.tests.util import shared_blob_dir_choices for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): from relstorage.storage import RelStorage from relstorage.adapters.mysql import MySQLAdapter db = db_names[name] if not keep_history: db += '_hf' options = Options( keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter = MySQLAdapter( options=options, db=db, user='******', passwd='relstoragetest', ) storage = RelStorage(adapter, name=name, options=options) storage.zap_all() return storage prefix = 'MySQL%s%s' % ( (shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' # MySQL is limited to the blob_chunk_size as there is no # native blob streaming support. blob_size = Options().blob_chunk_size suite.addTest(storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), large_blob_size=(not shared_blob_dir) and blob_size + 100 )) return suite
test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' # cx_Oracle blob support can only address up to sys.maxint on # 32-bit systems, 4GB otherwise. blob_size = min(sys.maxint, 1 << 32) suite.addTest( storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), large_blob_size=(not shared_blob_dir) and blob_size + 100, )) return suite if __name__ == '__main__': logging.basicConfig() unittest.main(defaultTest="test_suite")
def test_suite(): try: import psycopg2 except ImportError: e = sys.exc_info()[1] import warnings warnings.warn( "psycopg2 is not importable, so PostgreSQL tests disabled") return unittest.TestSuite() suite = unittest.TestSuite() for klass in [ HPPostgreSQLTests, HPPostgreSQLToFile, HPPostgreSQLFromFile, HFPostgreSQLTests, HFPostgreSQLToFile, HFPostgreSQLFromFile, ]: suite.addTest(unittest.makeSuite(klass, "check")) try: import ZODB.blob except ImportError: # ZODB < 3.8 pass else: from relstorage.tests.blob.testblob import storage_reusable_suite from relstorage.tests.util import shared_blob_dir_choices for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): from relstorage.storage import RelStorage from relstorage.adapters.postgresql import PostgreSQLAdapter db = db_names[name] if not keep_history: db += '_hf' dsn = ('dbname=%s user=relstoragetest ' 'password=relstoragetest' % db) options = Options( keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter = PostgreSQLAdapter(dsn=dsn, options=options) storage = RelStorage(adapter, name=name, options=options) storage.zap_all() return storage prefix = 'PostgreSQL%s%s' % ( (shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' suite.addTest(storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), # PostgreSQL blob chunks are max 2GB in size large_blob_size=(not shared_blob_dir) and (1 << 31) + 100, # todo replace )) return suite
def _add_driver_to_suite(self, driver_name, suite, is_available): for klass in self._make_check_classes(): klass = self._new_class_for_driver(driver_name, klass, is_available) suite.addTest(unittest.makeSuite(klass, "check")) for klass in self._make_zodbconvert_classes(): suite.addTest(unittest.makeSuite( self._new_class_for_driver(driver_name, klass, is_available))) from relstorage.tests.blob.testblob import storage_reusable_suite from relstorage.options import Options from relstorage.storage import RelStorage for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): if not is_available: raise unittest.SkipTest("Driver %s is not installed" % (driver_name,)) assert driver_name not in kw kw['driver'] = driver_name db = self.db_names[name] if not keep_history: db += '_hf' options = Options( keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter_maker = self.use_adapter() adapter = adapter_maker.make_adapter(options, db) storage = RelStorage(adapter, name=name, options=options) storage.zap_all(slow=True) return storage prefix = '%s%s%s_%s' % ( self.__name__, 'Shared' if shared_blob_dir else 'Unshared', 'WithHistory' if keep_history else 'NoHistory', driver_name.replace(' ', '').replace('/', '_'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' suite.addTest(storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), # PostgreSQL blob chunks are max 2GB in size large_blob_size=(not shared_blob_dir) and (self.large_blob_size) + 100, storage_is_available=is_available )) return suite
# If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' suite.addTest( storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), # PostgreSQL blob chunks are max 2GB in size large_blob_size=(not shared_blob_dir) and (1 << 31) + 100, )) return suite if __name__ == '__main__': logging.basicConfig() unittest.main(defaultTest="test_suite")
(shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' suite.addTest(storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), # PostgreSQL blob chunks are max 2GB in size large_blob_size=(not shared_blob_dir) and (1<<31) + 100, )) return suite if __name__=='__main__': logging.basicConfig() unittest.main(defaultTest="test_suite")
def test_suite(): import relstorage.adapters.postgresql as _adapter try: _adapter.select_driver() except ImportError: import warnings warnings.warn( "No PostgreSQL driver is available, so PostgreSQL tests disabled") return unittest.TestSuite() suite = unittest.TestSuite() for klass in [ HPPostgreSQLTests, HPPostgreSQLToFile, HPPostgreSQLFromFile, HFPostgreSQLTests, HFPostgreSQLToFile, HFPostgreSQLFromFile, ]: suite.addTest(unittest.makeSuite(klass, "check")) suite.addTest(unittest.makeSuite(HPPostgreSQLDestZODBConvertTests)) suite.addTest(unittest.makeSuite(HPPostgreSQLSrcZODBConvertTests)) import ZODB.blob from .util import RUNNING_ON_CI if RUNNING_ON_CI or os.environ.get("RS_PG_SMALL_BLOB"): # Avoid creating 2GB blobs to be friendly to neighbors # and to run fast (2GB blobs take about 4 minutes on Travis # CI as-of June 2016) # XXX: This is dirty. from relstorage.adapters.postgresql.mover import PostgreSQLObjectMover as ObjectMover assert hasattr(ObjectMover, 'postgresql_blob_chunk_maxsize') ObjectMover.postgresql_blob_chunk_maxsize = 1024 * 1024 * 10 large_blob_size = ObjectMover.postgresql_blob_chunk_maxsize * 2 else: large_blob_size = 1 << 31 from relstorage.tests.blob.testblob import storage_reusable_suite from relstorage.tests.util import shared_blob_dir_choices for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): from relstorage.storage import RelStorage from relstorage.adapters.postgresql import PostgreSQLAdapter db = db_names[name] if not keep_history: db += '_hf' dsn = ('dbname=%s user=relstoragetest ' 'password=relstoragetest' % db) options = Options(keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter = PostgreSQLAdapter(dsn=dsn, options=options) storage = RelStorage(adapter, name=name, options=options) storage.zap_all(slow=True) return storage prefix = 'PostgreSQL%s%s' % ( (shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' suite.addTest( storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), # PostgreSQL blob chunks are max 2GB in size large_blob_size=(not shared_blob_dir) and (large_blob_size) + 100, )) return suite
def test_suite(): try: import psycopg2 except ImportError: e = sys.exc_info()[1] import warnings warnings.warn( "psycopg2 is not importable, so PostgreSQL tests disabled") return unittest.TestSuite() suite = unittest.TestSuite() for klass in [ HPPostgreSQLTests, HPPostgreSQLToFile, HPPostgreSQLFromFile, HFPostgreSQLTests, HFPostgreSQLToFile, HFPostgreSQLFromFile, ]: suite.addTest(unittest.makeSuite(klass, "check")) try: import ZODB.blob except ImportError: # ZODB < 3.8 pass else: from relstorage.tests.blob.testblob import storage_reusable_suite from relstorage.tests.util import shared_blob_dir_choices for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): from relstorage.storage import RelStorage from relstorage.adapters.postgresql import PostgreSQLAdapter db = db_names[name] if not keep_history: db += '_hf' dsn = ('dbname=%s user=relstoragetest ' 'password=relstoragetest' % db) options = Options(keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter = PostgreSQLAdapter(dsn=dsn, options=options) storage = RelStorage(adapter, name=name, options=options) storage.zap_all() return storage prefix = 'PostgreSQL%s%s' % ( (shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' suite.addTest( storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), # PostgreSQL blob chunks are max 2GB in size large_blob_size=(not shared_blob_dir) and (1 << 31) + 100, # todo replace )) return suite
def test_suite(): import relstorage.adapters.mysql as _adapter try: _adapter.select_driver() except ImportError: import warnings warnings.warn("No MySQL driver is available, so MySQL tests disabled") return unittest.TestSuite() suite = unittest.TestSuite() for klass in [ HPMySQLTests, HPMySQLToFile, HPMySQLFromFile, HFMySQLTests, HFMySQLToFile, HFMySQLFromFile, ]: suite.addTest(unittest.makeSuite(klass, "check")) suite.addTest(unittest.makeSuite(HPMySQLDestZODBConvertTests)) suite.addTest(unittest.makeSuite(HPMySQLSrcZODBConvertTests)) suite.addTest(unittest.makeSuite(TestOIDAllocator)) from relstorage.tests.blob.testblob import storage_reusable_suite from relstorage.tests.util import shared_blob_dir_choices for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): from relstorage.storage import RelStorage from relstorage.adapters.mysql import MySQLAdapter db = db_names[name] if not keep_history: db += '_hf' options = Options(keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter = MySQLAdapter( options=options, db=db, user='******', passwd='relstoragetest', ) storage = RelStorage(adapter, name=name, options=options) storage.zap_all() return storage prefix = 'MySQL%s%s' % ( (shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' # MySQL is limited to the blob_chunk_size as there is no # native blob streaming support. (Note: this depends on # the max_allowed_packet size on the server as well as the driver; both # values default to 1MB. But umysqldb needs 1.3MB max_allowed_packet size # to send multiple 1MB chunks. So keep it small.) blob_size = Options().blob_chunk_size suite.addTest( storage_reusable_suite(prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), large_blob_size=(not shared_blob_dir) and blob_size + 100)) return suite
def test_suite(): try: import cx_Oracle except ImportError: e = sys.exc_info()[1] import warnings warnings.warn("cx_Oracle is not importable, so Oracle tests disabled") return unittest.TestSuite() suite = unittest.TestSuite() for klass in [ HPOracleTests, HPOracleToFile, HPOracleFromFile, HFOracleTests, HFOracleToFile, HFOracleFromFile, ]: suite.addTest(unittest.makeSuite(klass, "check")) try: import ZODB.blob except ImportError: # ZODB < 3.8 pass else: from relstorage.tests.blob.testblob import storage_reusable_suite dsn = os.environ.get('ORACLE_TEST_DSN', 'XE') from relstorage.tests.util import shared_blob_dir_choices for shared_blob_dir in shared_blob_dir_choices: for keep_history in (False, True): def create_storage(name, blob_dir, shared_blob_dir=shared_blob_dir, keep_history=keep_history, **kw): from relstorage.storage import RelStorage from relstorage.adapters.oracle import OracleAdapter db = db_names[name] if not keep_history: db += '_hf' options = Options( keep_history=keep_history, shared_blob_dir=shared_blob_dir, blob_dir=os.path.abspath(blob_dir), **kw) adapter = OracleAdapter( user=db, password='******', dsn=dsn, options=options, ) storage = RelStorage(adapter, name=name, options=options) storage.zap_all() return storage prefix = 'Oracle%s%s' % ( (shared_blob_dir and 'Shared' or 'Unshared'), (keep_history and 'WithHistory' or 'NoHistory'), ) # If the blob directory is a cache, don't test packing, # since packing can not remove blobs from all caches. test_packing = shared_blob_dir if keep_history: pack_test_name = 'blob_packing.txt' else: pack_test_name = 'blob_packing_history_free.txt' # cx_Oracle blob support can only address up to sys.maxint on # 32-bit systems, 4GB otherwise. blob_size = min(sys.maxint, 1<<32) suite.addTest(storage_reusable_suite( prefix, create_storage, test_blob_storage_recovery=True, test_packing=test_packing, test_undo=keep_history, pack_test_name=pack_test_name, test_blob_cache=(not shared_blob_dir), large_blob_size=(not shared_blob_dir) and blob_size + 100, )) return suite