Skip to content

Replaced python container launcher with GHA service #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
services:
trino:
image: trinodb/trino:360
ports:
- 8080:8080
strategy:
fail-fast: false
matrix:
python-version: [
3.6,
3.7,
3.8,
3.9,
]
python-version:
- 3.6
- 3.7
- 3.8
- 3.9
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,9 @@ When the code is ready, submit a Pull Request.

## Running Tests

There is a helper scripts, `run`, that provides commands to run tests.
Type `./run tests` to run both unit and integration tests.
`trino-python-client` uses [pytest](https://pytest.org/) for its tests.

`trino-python-client` uses [pytest](https://pytest.org/) for its tests. To run
only unit tests, type:
To run unit tests, type:

```
$ pytest tests
Expand All @@ -161,15 +159,17 @@ use `tox` (see the configuration in `tox.ini`):
$ tox
```

To run integration tests:
A Trino container is required to run integration tests, type:

```
$ pytest integration_tests
$ docker run --rm -p 8080:8080 trinodb/trino:355
```

They pull a Docker image and then run a container with a Trino server:
- the image is named `trinodb/trino:${TRINO_VERSION}`
- the container is named `trino-python-client-tests-{uuid4()[:7]}`
To run integration tests, type:

```
$ pytest integration_tests
```

## Releasing

Expand Down
219 changes: 0 additions & 219 deletions integration_tests/conftest.py

This file was deleted.

48 changes: 33 additions & 15 deletions integration_tests/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,50 @@
import math
from datetime import datetime

from requests.exceptions import ConnectionError
from requests import Session
import pytest
import pytz

import trino
from conftest import TRINO_VERSION
from trino.exceptions import TrinoQueryError
from trino.transaction import IsolationLevel


@pytest.fixture
def trino_connection(run_trino):
_, host, port = run_trino
HOST = 'localhost'
PORT = 8080
TRINO_VERSION = '360' # The Trino server version used for integration tests


@pytest.fixture(scope="session")
def trino_start():
url = f'http://{HOST}:{PORT}/v1/info'
session = Session()
while True:
try:
response = session.get(url)
if not response.json().get('starting'):
break
except ConnectionError:
pass


@pytest.fixture
def trino_connection(trino_start):
yield trino.dbapi.Connection(
host=host, port=port, user="test", source="test", max_attempts=1
host=HOST,
port=PORT,
user="test",
source="test",
max_attempts=1
)


@pytest.fixture
def trino_connection_with_transaction(run_trino):
_, host, port = run_trino

def trino_connection_with_transaction(trino_start):
yield trino.dbapi.Connection(
host=host,
port=port,
host=HOST,
port=PORT,
user="test",
source="test",
max_attempts=1,
Expand Down Expand Up @@ -304,17 +323,16 @@ def test_cancel_query(trino_connection):
assert "Cancel query failed; no running query" in str(cancel_error.value)


def test_session_properties(run_trino):
_, host, port = run_trino

def test_session_properties():
connection = trino.dbapi.Connection(
host=host,
port=port,
host=HOST,
port=PORT,
user="test",
source="test",
session_properties={"query_max_run_time": "10m", "query_priority": "1"},
max_attempts=1,
)

cur = connection.cursor()
cur.execute("SHOW SESSION")
rows = cur.fetchall()
Expand Down