Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7163482
D2615.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D2615.id.diff
View Options
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
Details
Attached
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
Attached To
D2615: Make tests reuse the same keyspace/schema instead of recreating it for each test.
Event Timeline
Log In to Comment