From e2a861c801e575935276bb1ac7ba5e549f9224cb Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont (@ardumont)" Date: Thu, 29 Oct 2020 22:09:32 +0100 Subject: [PATCH] debian.tests: Fix test The scheduler fixture introduced truncates tables in between tests. The debian tests unfortunately share state and it broke when that changed. This fixes the test by avoiding the truncation of the scheduler db table "task". Ideally those tests need to be reworked to avoid sharing state between tests. [1] https://jenkins.softwareheritage.org/job/DLS/job/tests/1043 --- swh/lister/debian/tests/conftest.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/swh/lister/debian/tests/conftest.py b/swh/lister/debian/tests/conftest.py index 8adc690..4443ef8 100644 --- a/swh/lister/debian/tests/conftest.py +++ b/swh/lister/debian/tests/conftest.py @@ -3,13 +3,32 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +import os + import pytest from pytest_postgresql.janitor import DatabaseJanitor from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker +from swh.core.db.pytest_plugin import postgresql_fact from swh.lister.core.models import SQLBase + from swh.lister.debian import debian_init +import swh.scheduler + +SQL_DIR = os.path.join(os.path.dirname(swh.scheduler.__file__), "sql") +postgresql_scheduler = postgresql_fact( + "postgresql_proc", + db_name="scheduler-lister", + dump_files=os.path.join(SQL_DIR, "*.sql"), + # do not truncate the task tables, it's required in between test + no_truncate_tables={"dbversion", "priority_ratio", "task"}, +) + + +@pytest.fixture +def swh_scheduler_config(postgresql_scheduler): + return {"db": postgresql_scheduler.dsn} @pytest.fixture