Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_cassandra.py
Show All 16 Lines | |||||
from cassandra.cluster import NoHostAvailable | from cassandra.cluster import NoHostAvailable | ||||
import pytest | import pytest | ||||
from swh.core.api.classes import stream_results | from swh.core.api.classes import stream_results | ||||
from swh.model import from_disk | from swh.model import from_disk | ||||
from swh.model.model import Directory, DirectoryEntry, Snapshot, SnapshotBranch | from swh.model.model import Directory, DirectoryEntry, Snapshot, SnapshotBranch | ||||
from swh.storage import get_storage | from swh.storage import get_storage | ||||
from swh.storage.cassandra import create_keyspace | from swh.storage.cassandra import create_keyspace | ||||
from swh.storage.cassandra.cql import BATCH_INSERT_MAX_SIZE | from swh.storage.cassandra.cql import BATCH_INSERT_MAX_SIZE, SELECT_MISSING_ALGOS | ||||
from swh.storage.cassandra.model import ContentRow, ExtIDRow | from swh.storage.cassandra.model import ContentRow, ExtIDRow | ||||
from swh.storage.cassandra.schema import HASH_ALGORITHMS, TABLES | from swh.storage.cassandra.schema import HASH_ALGORITHMS, TABLES | ||||
from swh.storage.cassandra.storage import DIRECTORY_ENTRIES_INSERT_ALGOS | from swh.storage.cassandra.storage import DIRECTORY_ENTRIES_INSERT_ALGOS | ||||
from swh.storage.tests.storage_data import StorageData | from swh.storage.tests.storage_data import StorageData | ||||
from swh.storage.tests.storage_tests import ( | from swh.storage.tests.storage_tests import ( | ||||
TestStorageGeneratedData as _TestStorageGeneratedData, | TestStorageGeneratedData as _TestStorageGeneratedData, | ||||
) | ) | ||||
from swh.storage.tests.storage_tests import TestStorage as _TestStorage | from swh.storage.tests.storage_tests import TestStorage as _TestStorage | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | def keyspace(cassandra_cluster): | ||||
return keyspace | return keyspace | ||||
# tests are executed using imported classes (TestStorage and | # tests are executed using imported classes (TestStorage and | ||||
# TestStorageGeneratedData) using overloaded swh_storage fixture | # TestStorageGeneratedData) using overloaded swh_storage fixture | ||||
# below | # below | ||||
@pytest.fixture | @pytest.fixture(params=SELECT_MISSING_ALGOS) | ||||
def swh_storage_backend_config(cassandra_cluster, keyspace): | def swh_storage_backend_config(cassandra_cluster, keyspace, request): | ||||
(hosts, port) = cassandra_cluster | (hosts, port) = cassandra_cluster | ||||
storage_config = dict( | storage_config = dict( | ||||
cls="cassandra", | cls="cassandra", | ||||
hosts=hosts, | hosts=hosts, | ||||
port=port, | port=port, | ||||
keyspace=keyspace, | keyspace=keyspace, | ||||
journal_writer={"cls": "memory"}, | journal_writer={"cls": "memory"}, | ||||
objstorage={"cls": "memory"}, | objstorage={"cls": "memory"}, | ||||
select_missing_algo=request.param, | |||||
) | ) | ||||
yield storage_config | yield storage_config | ||||
storage = get_storage(**storage_config) | storage = get_storage(**storage_config) | ||||
for table in TABLES: | for table in TABLES: | ||||
storage._cql_runner._session.execute('TRUNCATE TABLE "%s"' % table) | storage._cql_runner._session.execute('TRUNCATE TABLE "%s"' % table) | ||||
▲ Show 20 Lines • Show All 508 Lines • Show Last 20 Lines |