Skip to content
Snippets Groups Projects
Commit 095409cf authored by Mohammad Torkashvand's avatar Mohammad Torkashvand
Browse files

Add pytest-xdist for parallel test execution

parent b32b70b0
No related branches found
No related tags found
No related merge requests found
Pipeline #89762 failed
This commit is part of merge request !292. Comments created here will be created in the context of that merge request.
...@@ -36,6 +36,10 @@ run-tox-pipeline: ...@@ -36,6 +36,10 @@ run-tox-pipeline:
- pip install virtualenv - pip install virtualenv
- virtualenv venv - virtualenv venv
- . venv/bin/activate - . venv/bin/activate
# Grant all privileges and superuser to nwa
- psql -U postgres -c "ALTER USER nwa WITH SUPERUSER;"
- psql -U postgres -c "ALTER USER nwa CREATEDB CREATEROLE;"
- psql -U postgres -c "GRANT ALL ON SCHEMA public TO nwa;"
script: script:
- pip install tox - pip install tox
......
...@@ -23,3 +23,4 @@ sphinx-rtd-theme==2.0.0 ...@@ -23,3 +23,4 @@ sphinx-rtd-theme==2.0.0
urllib3_mock==0.3.3 urllib3_mock==0.3.3
pytest-asyncio==0.23.6 pytest-asyncio==0.23.6
pre-commit~=3.7.0 pre-commit~=3.7.0
pytest-xdist==3.6.1
\ No newline at end of file
...@@ -142,8 +142,12 @@ def data_config_filename() -> str: ...@@ -142,8 +142,12 @@ def data_config_filename() -> str:
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def db_uri(): def db_uri():
"""Provide the database uri configuration to run the migration on.""" """Provide a unique database URI for each pytest-xdist worker, or a default URI if running without xdist."""
return os.environ.get("DATABASE_URI_TEST", "postgresql://nwa:nwa@localhost/gso-test-db") worker_id = os.getenv("PYTEST_XDIST_WORKER")
if worker_id:
return f"postgresql://nwa:nwa@localhost/gso-test-db_{worker_id}"
return "postgresql://nwa:nwa@localhost/gso-test-db"
def run_migrations(db_uri: str) -> None: def run_migrations(db_uri: str) -> None:
...@@ -281,7 +285,7 @@ def partner_factory(): ...@@ -281,7 +285,7 @@ def partner_factory():
return _create_partner return _create_partner
@pytest.fixture(scope="session") @pytest.fixture()
def geant_partner(partner_factory): def geant_partner(partner_factory):
return partner_factory(name="GEANT-TEST", email="goat-test@geant.org") return partner_factory(name="GEANT-TEST", email="goat-test@geant.org")
......
...@@ -17,14 +17,7 @@ deps = ...@@ -17,14 +17,7 @@ deps =
-r requirements.txt -r requirements.txt
commands = commands =
ruff check --respect-gitignore --preview . pytest -n auto {posargs}
ruff format --respect-gitignore --preview --check .
mypy .
coverage erase
coverage run --source gso --omit="gso/migrations/*" -m pytest {posargs}
coverage xml
coverage html
sh -c "if [ $SKIP_ALL_TESTS -eq 1 ]; then echo 'Skipping coverage report'; else coverage report --fail-under 80; fi"
allowlist_externals = allowlist_externals =
sh sh
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment