Skip to content

Commit

Permalink
Print container logs if service fails to start
Browse files Browse the repository at this point in the history
When a Docker container fails to start properly, the integration tests fail
with a timeout error. In that case, we will print container logs for
debugging.
  • Loading branch information
danielhollas committed Jul 22, 2024
1 parent 122efe1 commit 15b96b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-test-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
run: echo "JUPYTER_TOKEN=$(openssl rand -hex 32)" >> $GITHUB_ENV

- name: Run pytest for Chrome
run: pytest --driver Chrome tests_integration/
run: pytest -sv --driver Chrome tests_integration/
env:
QE_IMAGE: ${{ env.IMAGE }}@${{ steps.build-upload.outputs.digest }}

Expand Down
17 changes: 10 additions & 7 deletions tests_integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,22 @@ def nb_user(aiidalab_exec):


@pytest.fixture(scope="session")
def notebook_service(docker_ip, docker_services):
def notebook_service(docker_compose, docker_ip, docker_services):
"""Ensure that HTTP service is up and responsive."""

# `port_for` takes a container port and returns the corresponding host port
port = docker_services.port_for("aiidalab", 8888)
url = f"http://{docker_ip}:{port}"
token = os.environ.get("JUPYTER_TOKEN", "testtoken")
docker_services.wait_until_responsive(
# The timeout is very high for this test, because the installation of pseudo libraries.
timeout=180.0,
pause=0.1,
check=lambda: is_responsive(url),
)
try:
docker_services.wait_until_responsive(
timeout=180.0,
pause=1.0,
check=lambda: is_responsive(url),
)
except Exception as e:
print(docker_compose.execute("logs").decode().strip())
pytest.exit(e)
return url, token


Expand Down

0 comments on commit 15b96b7

Please sign in to comment.