Skip to content

Commit

Permalink
Merge pull request #212 from omnivector-solutions/ASP-2438-speed-up-t…
Browse files Browse the repository at this point in the history
…ests-on-the-api

ASP-2438 Speed up tests on Jobbergate API
  • Loading branch information
fschuch committed Jan 4, 2023
2 parents 2fabe2a + 914b330 commit e8fed2d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 24 deletions.
45 changes: 23 additions & 22 deletions .github/workflows/test_on_push.yaml
@@ -1,4 +1,4 @@
name: 'Test'
name: "Test"

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
jobs:
api-tests:
name: "jobbergate-api tests"
runs-on: "ubuntu-latest"
runs-on: "ubuntu-20.04"
services:
test-db:
image: postgres
Expand All @@ -25,14 +25,15 @@ jobs:
ports:
- 5433:5432
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- uses: Gr1N/setup-poetry@v7
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry==1.1.14
- uses: actions/setup-python@v4
with:
poetry-version: 1.1.14
python-version: "3.8"
architecture: "x64"
cache: "poetry"
cache-dependency-path: jobbergate-api/poetry.lock
- name: "run quality control checks"
working-directory: jobbergate-api
env:
Expand All @@ -41,25 +42,25 @@ jobs:
TEST_DATABASE_USER: test
TEST_DATABASE_PSWD: test-pswd
TEST_DATABASE_NAME: test-jobbergate
POETRY_HTTP_BASIC_PYPICLOUD_USERNAME: admin
POETRY_HTTP_BASIC_PYPICLOUD_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: make qa
run: |
poetry env use "3.8"
make qa
cli-tests:
name: "jobbergate-cli tests"
runs-on: "ubuntu-20.04"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry==1.1.14
- uses: actions/setup-python@v4
with:
python-version: "3.6"
architecture: 'x64'
- uses: Gr1N/setup-poetry@v7
with:
poetry-version: 1.1.14
architecture: "x64"
cache: "poetry"
cache-dependency-path: jobbergate-cli/poetry.lock
- name: "run quality control checks"
working-directory: jobbergate-cli
env:
POETRY_HTTP_BASIC_PYPICLOUD_USERNAME: admin
POETRY_HTTP_BASIC_PYPICLOUD_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: make qa
run: |
poetry env use "3.6"
make qa
Expand Up @@ -14,6 +14,10 @@
from jobbergate_api.apps.permissions import Permissions
from jobbergate_api.storage import database, fetch_instance

# Force the async event loop at the app to begin.
# Since this is a time consuming fixture, it is just used where strict necessary.
pytestmark = pytest.mark.usefixtures("startup_event_force")


@pytest.mark.asyncio
async def test_create_application(
Expand Down
Expand Up @@ -18,6 +18,10 @@
from jobbergate_api.apps.permissions import Permissions
from jobbergate_api.storage import database

# Force the async event loop at the app to begin.
# Since this is a time consuming fixture, it is just used where strict necessary.
pytestmark = pytest.mark.usefixtures("startup_event_force")


@pytest.fixture
def job_script_data_as_string():
Expand Down
Expand Up @@ -16,6 +16,10 @@
from jobbergate_api.apps.permissions import Permissions
from jobbergate_api.storage import database

# Force the async event loop at the app to begin.
# Since this is a time consuming fixture, it is just used where strict necessary.
pytestmark = pytest.mark.usefixtures("startup_event_force")


@pytest.mark.asyncio
async def test_create_job_submission__with_client_id_in_token(
Expand Down
3 changes: 1 addition & 2 deletions jobbergate-api/jobbergate_api/tests/conftest.py
Expand Up @@ -56,8 +56,7 @@ async def enforce_empty_database(database_engine):
metadata.drop_all(database_engine)


@pytest.fixture(autouse=True)
@pytest.mark.enforce_empty_database()
@pytest.fixture()
async def startup_event_force():
"""
Force the async event loop to begin.
Expand Down
4 changes: 4 additions & 0 deletions jobbergate-api/jobbergate_api/tests/test_pagination.py
Expand Up @@ -12,6 +12,10 @@
from jobbergate_api.pagination import Pagination, Response, package_response
from jobbergate_api.storage import database

# Force the async event loop at the app to begin.
# Since this is a time consuming fixture, it is just used where strict necessary.
pytestmark = pytest.mark.usefixtures("startup_event_force")


def test_init_fails_on_invalid_parameters():
"""
Expand Down
4 changes: 4 additions & 0 deletions jobbergate-api/jobbergate_api/tests/test_storage.py
Expand Up @@ -10,6 +10,10 @@
from jobbergate_api.metadata import metadata
from jobbergate_api.storage import build_db_url, database, sort_clause

# Force the async event loop at the app to begin.
# Since this is a time consuming fixture, it is just used where strict necessary.
pytestmark = pytest.mark.usefixtures("startup_event_force")


def test_build_db_url__creates_database_url_from_parts(tweak_settings):
"""
Expand Down

0 comments on commit e8fed2d

Please sign in to comment.