Page MenuHomeSoftware Heritage

D2615.id.diff
No OneTemporary

D2615.id.diff

diff --git a/swh/storage/cassandra/schema.py b/swh/storage/cassandra/schema.py
--- a/swh/storage/cassandra/schema.py
+++ b/swh/storage/cassandra/schema.py
@@ -186,6 +186,10 @@
PRIMARY KEY (({main_algo}), {other_algos})
);'''
+TABLES = ('content revision revision_parent release directory '
+ 'directory_entry snapshot snapshot_branch origin_visit '
+ 'origin tool_by_uuid tool object_count').split()
+
HASH_ALGORITHMS = ['sha1', 'sha1_git', 'sha256', 'blake2s256']
for main_algo in HASH_ALGORITHMS:
@@ -194,3 +198,5 @@
other_algos=', '.join(
[algo for algo in HASH_ALGORITHMS if algo != main_algo])
))
+
+ TABLES.append('content_by_%s' % main_algo)
diff --git a/swh/storage/tests/test_cassandra.py b/swh/storage/tests/test_cassandra.py
--- a/swh/storage/tests/test_cassandra.py
+++ b/swh/storage/tests/test_cassandra.py
@@ -13,6 +13,7 @@
from swh.storage import get_storage
from swh.storage.cassandra import create_keyspace
+from swh.storage.cassandra.schema import TABLES
from swh.storage.tests.test_storage import TestStorage as _TestStorage
from swh.storage.tests.test_storage import TestStorageGeneratedData \
@@ -127,16 +128,23 @@
print(rf.message.query)
+@pytest.fixture(scope='session')
+def keyspace(cassandra_cluster):
+ (hosts, port) = cassandra_cluster
+ keyspace = os.urandom(10).hex()
+
+ create_keyspace(hosts, keyspace, port)
+
+ return keyspace
+
+
# tests are executed using imported classes (TestStorage and
# TestStorageGeneratedData) using overloaded swh_storage fixture
# below
@pytest.fixture
-def swh_storage(cassandra_cluster):
+def swh_storage(cassandra_cluster, keyspace):
(hosts, port) = cassandra_cluster
- keyspace = os.urandom(10).hex()
-
- create_keyspace(hosts, keyspace, port)
storage = get_storage(
'cassandra',
@@ -153,8 +161,8 @@
yield storage
- storage._cql_runner._session.execute(
- 'DROP KEYSPACE "%s"' % keyspace)
+ for table in TABLES:
+ storage._cql_runner._session.execute('TRUNCATE TABLE "%s"' % table)
@pytest.mark.cassandra

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 30, 8:57 AM (23 h, 1 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3222038

Event Timeline