Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7122800
D4322.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D4322.diff
View Options
diff --git a/requirements-swh.txt b/requirements-swh.txt
--- a/requirements-swh.txt
+++ b/requirements-swh.txt
@@ -1,2 +1,2 @@
-swh.core[db,http] >= 0.3
+swh.core[db,http] >= 0.5
swh.storage >= 0.11.1
diff --git a/swh/scheduler/pytest_plugin.py b/swh/scheduler/pytest_plugin.py
--- a/swh/scheduler/pytest_plugin.py
+++ b/swh/scheduler/pytest_plugin.py
@@ -4,46 +4,38 @@
# See top-level LICENSE file for more information
from datetime import timedelta
-import glob
import os
from celery.contrib.testing import worker
from celery.contrib.testing.app import TestApp, setup_default_app
import pkg_resources
import pytest
-from pytest_postgresql import factories
-from swh.core.utils import numfile_sortkey as sortkey
+from swh.core.db.pytest_plugin import postgresql_fact
import swh.scheduler
from swh.scheduler import get_scheduler
SQL_DIR = os.path.join(os.path.dirname(swh.scheduler.__file__), "sql")
-DUMP_FILES = os.path.join(SQL_DIR, "*.sql")
# celery tasks for testing purpose; tasks themselves should be
# in swh/scheduler/tests/tasks.py
TASK_NAMES = ["ping", "multiping", "add", "error", "echo"]
-postgresql_scheduler = factories.postgresql("postgresql_proc", db_name="scheduler")
+postgresql_scheduler = postgresql_fact(
+ "postgresql_proc",
+ db_name="scheduler",
+ dump_files=os.path.join(SQL_DIR, "*.sql"),
+ no_truncate_tables={"dbversion", "priority_ratio"},
+)
@pytest.fixture
def swh_scheduler_config(request, postgresql_scheduler):
- scheduler_config = {
+ return {
"db": postgresql_scheduler.dsn,
}
- all_dump_files = sorted(glob.glob(DUMP_FILES), key=sortkey)
-
- cursor = postgresql_scheduler.cursor()
- for fname in all_dump_files:
- with open(fname) as fobj:
- cursor.execute(fobj.read())
- postgresql_scheduler.commit()
-
- return scheduler_config
-
@pytest.fixture
def swh_scheduler(swh_scheduler_config):
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 17 2024, 1:41 AM (13 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3221144
Attached To
D4322: scheduler.pytest_plugin: Make scheduler tests faster
Event Timeline
Log In to Comment