Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7124370
D6339.id23047.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
D6339.id23047.diff
View Options
diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,13 @@
*.csv
+*.dump
*.egg*
*.log
+*.mypy*
*.prof
*.zip
*.orig
*.bak
-.coverage
+.coverage*
.tox
.vscode
__pycache__
diff --git a/pytest.ini b/pytest.ini
--- a/pytest.ini
+++ b/pytest.ini
@@ -4,3 +4,8 @@
mongodb_fixture_dir = swh/provenance/tests/data/mongo
mongodb_engine = mongomock
mongodb_dbname = test
+
+postgresql_postgres_options = -N 500
+
+rabbitmq_host = localhost
+rabbitmq_port = 5672
diff --git a/requirements-test.txt b/requirements-test.txt
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,5 +1,6 @@
pytest
pytest-mongodb
+pytest-rabbitmq
swh.loader.git >= 0.8
swh.journal >= 0.8
types-Werkzeug
diff --git a/swh/provenance/tests/conftest.py b/swh/provenance/tests/conftest.py
--- a/swh/provenance/tests/conftest.py
+++ b/swh/provenance/tests/conftest.py
@@ -64,7 +64,7 @@
return ProvenanceStorageRPCClient
-@pytest.fixture(params=["mongodb", "postgresql", "rpcapi"])
+@pytest.fixture(params=["mongodb", "postgresql", "rpcapi", "rabbitmq"])
def provenance_storage(
request: SubRequest,
provenance_postgresqldb: Dict[str, str],
@@ -81,10 +81,32 @@
elif request.param == "mongodb":
from swh.provenance.mongo.backend import ProvenanceStorageMongoDb
+ # TODO: improve MongoDb initialization so that `get_provenance_storage` can be
+ # used and remote test case is also supported with underlying MongoDb storage.
mongodb_storage = ProvenanceStorageMongoDb(mongodb)
yield mongodb_storage
mongodb_storage.close()
+ elif request.param == "rabbitmq":
+ from swh.provenance.api.client import ProvenanceStorageRabbitMQClient
+ from swh.provenance.api.server import ProvenanceStorageRabbitMQServer
+
+ request.getfixturevalue("rabbitmq") # loaded to ensure server is up
+ url = "amqp://guest:guest@localhost:5672/%2f"
+ storage_config = {
+ "cls": "postgresql",
+ "db": provenance_postgresqldb,
+ "raise_on_commit": True,
+ }
+ server = ProvenanceStorageRabbitMQServer(url, storage_config)
+ client = ProvenanceStorageRabbitMQClient(url, storage_config)
+ assert isinstance(client, ProvenanceStorageInterface)
+
+ server.start()
+ yield client
+ client.close()
+ server.stop()
+
else:
# in test sessions, we DO want to raise any exception occurring at commit time
storage = get_provenance_storage(
diff --git a/tox.ini b/tox.ini
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist=black,flake8,mypy,py3
+envlist = black,flake8,mypy,py3
[testenv]
extras =
@@ -11,6 +11,7 @@
{envsitepackagesdir}/swh/provenance \
--cov={envsitepackagesdir}/swh/provenance \
--cov-branch {posargs}
+passenv = HOME # required by pytest-rabbitmq
[testenv:black]
skip_install = true
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 21 2024, 8:45 AM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216487
Attached To
D6339: Add support for remote backend on existing storage tests
Event Timeline
Log In to Comment