Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_cassandra.py
Show First 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | def on_request(self, rf): | ||||
if hasattr(rf.message, "query"): | if hasattr(rf.message, "query"): | ||||
print() | print() | ||||
print(rf.message.query) | print(rf.message.query) | ||||
@pytest.fixture(scope="session") | @pytest.fixture(scope="session") | ||||
def keyspace(cassandra_cluster): | def keyspace(cassandra_cluster): | ||||
(hosts, port) = cassandra_cluster | (hosts, port) = cassandra_cluster | ||||
keyspace = os.urandom(10).hex() | keyspace = "test" + os.urandom(10).hex() | ||||
create_keyspace(hosts, keyspace, port) | create_keyspace(hosts, keyspace, port) | ||||
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 | ||||
Show All 13 Lines | storage_config = dict( | ||||
objstorage={"cls": "memory"}, | objstorage={"cls": "memory"}, | ||||
) | ) | ||||
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(f"TRUNCATE TABLE {keyspace}.{table}") | ||||
storage._cql_runner._cluster.shutdown() | storage._cql_runner._cluster.shutdown() | ||||
@pytest.mark.cassandra | @pytest.mark.cassandra | ||||
class TestCassandraStorage(_TestStorage): | class TestCassandraStorage(_TestStorage): | ||||
def test_config_wrong_consistency_should_raise(self): | def test_config_wrong_consistency_should_raise(self): | ||||
storage_config = dict( | storage_config = dict( | ||||
▲ Show 20 Lines • Show All 556 Lines • Show Last 20 Lines |