Skip to content

Commit 19063c8

Browse files
hpoechepaul-gerber-svg
authored andcommitted
Test server liveness through API call
Previously the docker daemon was used to determine if a docker container is alive. This is a weak criterion as this is already checked by the "Wait for container and sever initialization" step. We changed the liveness check to rely on the `/description` endpoint that all services are required to implement. A status `200 OK` is interpreted as alive. The `X_API_VERSION` that is necessary for the path of the curl call, is introduced as environment variable.
1 parent 9fe445e commit 19063c8

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

.github/workflows/pr.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ concurrency:
1212
env:
1313
X_PYTHON_MIN_VERSION: "3.10"
1414
X_PYTHON_MAX_VERSION: "3.12"
15+
X_API_VERSION: "v3.1"
1516

1617
jobs:
1718
check-python-versions:
@@ -350,17 +351,17 @@ jobs:
350351
docker build -t basyx-python-${{ matrix.service }} -f Dockerfile ../../..
351352
- name: Run container
352353
run: |
353-
docker run -d --name basyx-python-${{ matrix.service }} basyx-python-${{ matrix.service }}
354+
docker run -d --name basyx-python-${{ matrix.service }} -p 9080:80 basyx-python-${{ matrix.service }}
354355
- name: Wait for container and server initialization
355356
run: |
356357
timeout 30s bash -c '
357358
until docker logs basyx-python-${{ matrix.service }} 2>&1 | grep -q "INFO success: quit_on_failure entered RUNNING state"; do
358359
sleep 2
359360
done
360361
'
361-
- name: Check if container is running
362+
- name: Check if service is alive
362363
run: |
363-
docker inspect --format='{{.State.Running}}' basyx-python-${{ matrix.service }} | grep true
364+
curl -f http://localhost:9080/api/${{ env.X_API_VERSION }}/description
364365
- name: Stop and remove the container
365366
run: |
366367
docker stop basyx-python-${{ matrix.service }} && docker rm basyx-python-${{ matrix.service }}

0 commit comments

Comments
 (0)