diff --git a/.github/workflows/python-CI.yml b/.github/workflows/python-CI.yml index ab11e13718..344815be02 100644 --- a/.github/workflows/python-CI.yml +++ b/.github/workflows/python-CI.yml @@ -166,11 +166,19 @@ jobs: strategy: matrix: py: [ 3.9, 3.12 ] + db: [ sqlite, postgresql ] os: [ ubuntu-latest, windows-latest, macos-13 ] + exclude: + - db: postgresql + os: windows-latest + - db: postgresql + os: macos-13 + env: + CI_TEST_DB_BACKEND: ${{ matrix.db }} services: postgres: # Applying this workaround: https://github.com/actions/runner/issues/822 - image: ${{ (matrix.os == 'ubuntu-latest') && 'postgres:12' || '' }} + image: ${{ (matrix.db == 'postgresql') && 'postgres:12' || '' }} env: POSTGRES_PASSWORD: phoenix options: >- diff --git a/.github/workflows/python-cron.yml b/.github/workflows/python-cron.yml index 4160c6942b..249bdb2266 100644 --- a/.github/workflows/python-cron.yml +++ b/.github/workflows/python-cron.yml @@ -8,6 +8,8 @@ on: jobs: integration-test: runs-on: ubuntu-latest + env: + CI_TEST_DB_BACKEND: postgresql services: postgres: image: postgres:12 diff --git a/tests/integration/_helpers.py b/tests/integration/_helpers.py index b4ad8364d7..baf13293c0 100644 --- a/tests/integration/_helpers.py +++ b/tests/integration/_helpers.py @@ -656,13 +656,7 @@ def _random_schema( url: URL, ) -> Iterator[str]: engine = create_engine(url.set(drivername="postgresql+psycopg")) - try: - engine.connect().close() - except OperationalError as exc: - if "too many clients" in str(exc): - pass - else: - pytest.skip(f"PostgreSQL unavailable: {exc}") + engine.connect().close() engine.dispose() schema = f"_{secrets.token_hex(15)}" yield schema diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 1bd602d468..8c7fb8febd 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -58,18 +58,14 @@ def _(used: List[int]) -> Iterator[int]: return _([]) -@pytest.fixture( - scope="session", - params=[ - pytest.param("sqlite:///:memory:", id="sqlite"), - pytest.param( - "postgresql://127.0.0.1:5432/postgres?user=postgres&password=phoenix", - id="postgresql", - ), - ], -) +@pytest.fixture(scope="session") def _sql_database_url(request: SubRequest) -> URL: - return make_url(request.param) + backend = os.getenv("CI_TEST_DB_BACKEND") + if not backend or backend == "sqlite": + return make_url("sqlite:///:memory:") + if backend == "postgresql": + return make_url("postgresql://127.0.0.1:5432/postgres?user=postgres&password=phoenix") + pytest.fail(f"Unknown database backend: {backend}") @pytest.fixture(scope="session", params=["http", "grpc"]) diff --git a/tox.ini b/tox.ini index 1b0eca55be..2697b2493f 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,8 @@ commands = ; pytest -ra -x {posargs:.} [testenv:ci_integration_tests] +pass_env = + CI_TEST_DB_BACKEND changedir = tests/integration deps = -r requirements/integration-tests.txt @@ -63,6 +65,8 @@ commands = ; pytest {posargs:.} [testenv:integration_tests] +pass_env = + CI_TEST_DB_BACKEND changedir = tests/integration deps = -r requirements/integration-tests.txt