Skip to content

Commit 2ca9253

Browse files
author
Josh Howard
committed
Replaced python container launcher with GHA service
1 parent 416d798 commit 2ca9253

File tree

4 files changed

+38
-251
lines changed

4 files changed

+38
-251
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ on: [push, pull_request]
55
jobs:
66
build:
77
runs-on: ubuntu-latest
8+
services:
9+
trino:
10+
image: trinodb/trino:355
11+
ports:
12+
- 8080:8080
813
strategy:
914
fail-fast: false
1015
matrix:
11-
python-version: [
12-
3.5,
13-
3.6,
14-
3.7,
15-
3.8,
16-
3.9,
17-
]
16+
python-version:
17+
- 3.5
18+
- 3.6
19+
- 3.7
20+
- 3.8
21+
- 3.9
1822
steps:
1923
- uses: actions/checkout@v2
2024
- uses: actions/setup-python@v2

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,9 @@ When the code is ready, submit a Pull Request.
142142

143143
## Running Tests
144144

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

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

151149
```
152150
$ pytest tests
@@ -161,15 +159,17 @@ use `tox` (see the configuration in `tox.ini`):
161159
$ tox
162160
```
163161

164-
To run integration tests:
162+
A Trino container is required to run integration tests, type:
165163

166164
```
167-
$ pytest integration_tests
165+
$ docker run --rm -p 8080:8080 trinodb/trino:355
168166
```
169167

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

174174
## Releasing
175175

integration_tests/conftest.py

Lines changed: 0 additions & 219 deletions
This file was deleted.

integration_tests/test_dbapi.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,30 @@
1616
import pytz
1717

1818
import trino
19-
from conftest import TRINO_VERSION
2019
from trino.exceptions import TrinoQueryError
2120
from trino.transaction import IsolationLevel
2221

2322

24-
@pytest.fixture
25-
def trino_connection(run_trino):
26-
_, host, port = run_trino
23+
HOST = "localhost"
24+
PORT = 8080
25+
2726

27+
@pytest.fixture
28+
def trino_connection():
2829
yield trino.dbapi.Connection(
29-
host=host, port=port, user="test", source="test", max_attempts=1
30+
host=HOST,
31+
port=PORT,
32+
user="test",
33+
source="test",
34+
max_attempts=1
3035
)
3136

3237

3338
@pytest.fixture
34-
def trino_connection_with_transaction(run_trino):
35-
_, host, port = run_trino
36-
39+
def trino_connection_with_transaction():
3740
yield trino.dbapi.Connection(
38-
host=host,
39-
port=port,
41+
host=HOST,
42+
port=PORT,
4043
user="test",
4144
source="test",
4245
max_attempts=1,
@@ -50,7 +53,7 @@ def test_select_query(trino_connection):
5053
rows = cur.fetchall()
5154
assert len(rows) > 0
5255
row = rows[0]
53-
assert row[2] == TRINO_VERSION
56+
assert row[2] == '355'
5457
columns = dict([desc[:2] for desc in cur.description])
5558
assert columns["node_id"] == "varchar"
5659
assert columns["http_uri"] == "varchar"
@@ -304,17 +307,16 @@ def test_cancel_query(trino_connection):
304307
assert "Cancel query failed; no running query" in str(cancel_error.value)
305308

306309

307-
def test_session_properties(run_trino):
308-
_, host, port = run_trino
309-
310+
def test_session_properties():
310311
connection = trino.dbapi.Connection(
311-
host=host,
312-
port=port,
312+
host=HOST,
313+
port=PORT,
313314
user="test",
314315
source="test",
315316
session_properties={"query_max_run_time": "10m", "query_priority": "1"},
316317
max_attempts=1,
317318
)
319+
318320
cur = connection.cursor()
319321
cur.execute("SHOW SESSION")
320322
rows = cur.fetchall()

0 commit comments

Comments
 (0)