File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,15 @@ To run integration tests:
42
42
pytest tests/integration
43
43
```
44
44
45
- They pull a Docker image and then run a container with a Trino server:
45
+ If you are already running a local Trino instance on the default port 8080, e.g.
46
+ through` docker run -d -p 8080:8080 --name trino --rm trinodb/trino:latest ` ,
47
+ the tests will automatically pick up this server instead of starting a new one
48
+ on a random port. This is especially helpful for debugging purposes as you can
49
+ inspect the executed queries through [ the Trino web ui] ( http://localhost:8080/ ) ,
50
+ it also saves you some time as the docker container won't have to be started.
51
+
52
+ By default, the tests pull a Docker image and then run a container with a Trino
53
+ server:
46
54
- the image is named ` trinodb/trino:${TRINO_VERSION} `
47
55
- the container is named ` trino-python-client-tests-{uuid4()[:7]} `
48
56
Original file line number Diff line number Diff line change 31
31
TRINO_PORT = 8080
32
32
33
33
34
+ def is_trino_available ():
35
+ with closing (socket .socket (socket .AF_INET , socket .SOCK_STREAM )) as sock :
36
+ sock .settimeout (2 )
37
+ result = sock .connect_ex ((TRINO_HOST , DEFAULT_PORT ))
38
+ if result == 0 :
39
+ return True
40
+
41
+
34
42
def get_local_port ():
35
43
with closing (socket .socket ()) as s :
36
44
s .bind (("localhost" , 0 ))
@@ -134,6 +142,10 @@ def stop_trino(container_id, proc):
134
142
135
143
@pytest .fixture (scope = "module" )
136
144
def run_trino ():
145
+ if is_trino_available ():
146
+ yield None , TRINO_HOST , DEFAULT_PORT
147
+ return
148
+
137
149
image_tag = os .environ .get ("TRINO_IMAGE" )
138
150
if not image_tag :
139
151
image_tag = get_default_trino_image_tag ()
You can’t perform that action at this time.
0 commit comments