Page MenuHomeSoftware Heritage

No OneTemporary

diff --git a/swh/vault/tests/conftest.py b/swh/vault/tests/conftest.py
index 23702ad..bbdb652 100644
--- a/swh/vault/tests/conftest.py
+++ b/swh/vault/tests/conftest.py
@@ -1,80 +1,88 @@
import glob
import os
+import subprocess
import pkg_resources.extern.packaging.version
import pytest
from pytest_postgresql import factories
from swh.core.utils import numfile_sortkey as sortkey
from swh.storage.tests import SQL_DIR as STORAGE_SQL_DIR
from swh.vault import get_vault
from swh.vault.tests import SQL_DIR
os.environ["LC_ALL"] = "C.UTF-8"
pytest_v = pkg_resources.get_distribution("pytest").parsed_version
if pytest_v < pkg_resources.extern.packaging.version.parse("3.9"):
@pytest.fixture
def tmp_path(request):
import pathlib
import tempfile
with tempfile.TemporaryDirectory() as tmpdir:
yield pathlib.Path(tmpdir)
def db_url(name, postgresql_proc):
return "postgresql://{user}@{host}:{port}/{dbname}".format(
host=postgresql_proc.host,
port=postgresql_proc.port,
user="postgres",
dbname=name,
)
postgresql2 = factories.postgresql("postgresql_proc", "tests2")
@pytest.fixture
def swh_vault(request, postgresql_proc, postgresql, postgresql2, tmp_path):
for sql_dir, pg in ((SQL_DIR, postgresql), (STORAGE_SQL_DIR, postgresql2)):
dump_files = os.path.join(sql_dir, "*.sql")
all_dump_files = sorted(glob.glob(dump_files), key=sortkey)
- cursor = pg.cursor()
for fname in all_dump_files:
- with open(fname) as fobj:
- # disable concurrent index creation since we run in a
- # transaction
- cursor.execute(fobj.read().replace("concurrently", ""))
- pg.commit()
+ subprocess.check_call(
+ [
+ "psql",
+ "--quiet",
+ "--no-psqlrc",
+ "-v",
+ "ON_ERROR_STOP=1",
+ "-d",
+ pg.dsn,
+ "-f",
+ fname,
+ ]
+ )
vault_config = {
"db": db_url("tests", postgresql_proc),
"storage": {
"cls": "local",
"db": db_url("tests2", postgresql_proc),
"objstorage": {
"cls": "pathslicing",
"args": {"root": str(tmp_path), "slicing": "0:1/1:5",},
},
},
"cache": {
"cls": "pathslicing",
"args": {
"root": str(tmp_path),
"slicing": "0:1/1:5",
"allow_delete": True,
},
},
"scheduler": {"cls": "remote", "args": {"url": "http://swh-scheduler:5008",},},
}
return get_vault("local", vault_config)
@pytest.fixture
def swh_storage(swh_vault):
return swh_vault.storage

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jun 21, 9:04 PM (4 w, 23 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3267133

Event Timeline