From 2a1cd45ebf2fe1202cf312224728ec0db8cc791f Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Fri, 30 Dec 2022 11:08:27 +0200 Subject: [PATCH] Pin jupyter_server>=2.0.0 (#1853) * Pin jupyter_server==2.0.0 * Update scipy-notebook/Dockerfile Co-authored-by: Erik Sundell * Fix test * Fix test * Test healthcheck properly * Fix typing Co-authored-by: Erik Sundell --- base-notebook/Dockerfile | 2 +- scipy-notebook/Dockerfile | 2 ++ tests/base-notebook/test_healthcheck.py | 18 ++++++++++++++++++ tests/base-notebook/test_packages.py | 1 + tests/conftest.py | 6 ++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/base-notebook/test_healthcheck.py diff --git a/base-notebook/Dockerfile b/base-notebook/Dockerfile index f5390d39..9804ddb2 100644 --- a/base-notebook/Dockerfile +++ b/base-notebook/Dockerfile @@ -68,7 +68,7 @@ RUN sed -re "s/c.ServerApp/c.NotebookApp/g" \ # HEALTHCHECK documentation: https://docs.docker.com/engine/reference/builder/#healthcheck # This healtcheck works well for `lab`, `notebook`, `nbclassic`, `server` and `retro` jupyter commands # https://github.com/jupyter/docker-stacks/issues/915#issuecomment-1068528799 -HEALTHCHECK --interval=15s --timeout=3s --start-period=5s --retries=3 \ +HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=3 \ CMD wget -O- --no-verbose --tries=1 --no-check-certificate \ http${GEN_CERT:+s}://localhost:8888${JUPYTERHUB_SERVICE_PREFIX:-/}api || exit 1 diff --git a/scipy-notebook/Dockerfile b/scipy-notebook/Dockerfile index bf166a2a..50da6109 100644 --- a/scipy-notebook/Dockerfile +++ b/scipy-notebook/Dockerfile @@ -39,6 +39,8 @@ RUN mamba install --quiet --yes \ 'h5py' \ 'ipympl'\ 'ipywidgets' \ + # Temporary fix for: https://github.com/jupyter/docker-stacks/issues/1851 + 'jupyter_server>=2.0.0' \ 'matplotlib-base' \ 'numba' \ 'numexpr' \ diff --git a/tests/base-notebook/test_healthcheck.py b/tests/base-notebook/test_healthcheck.py new file mode 100644 index 00000000..68f4e291 --- /dev/null +++ b/tests/base-notebook/test_healthcheck.py @@ -0,0 +1,18 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +import logging +import time + +from tests.conftest import TrackedContainer, get_health + +LOGGER = logging.getLogger(__name__) + + +def test_health(container: TrackedContainer) -> None: + running_container = container.run_detached( + tty=True, + ) + # sleeping some time to let the server start + time.sleep(10) + assert get_health(running_container) == "healthy" diff --git a/tests/base-notebook/test_packages.py b/tests/base-notebook/test_packages.py index f7cbe7d1..fe33f9d6 100644 --- a/tests/base-notebook/test_packages.py +++ b/tests/base-notebook/test_packages.py @@ -69,6 +69,7 @@ EXCLUDED_PACKAGES = [ "ca-certificates", "conda-forge::blas[build=openblas]", "hdf5", + "jupyter_server[version='>", # Temporary fix for: https://github.com/jupyter/docker-stacks/issues/1851 "openssl", "protobuf", "python", diff --git a/tests/conftest.py b/tests/conftest.py index fd4e4704..f7a538a8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -24,6 +24,12 @@ def find_free_port() -> str: return s.getsockname()[1] # type: ignore +def get_health(container: Container) -> str: + api_client = docker.APIClient() + inspect_results = api_client.inspect_container(container.name) + return inspect_results["State"]["Health"]["Status"] # type: ignore + + @pytest.fixture(scope="session") def http_client() -> requests.Session: """Requests session with retries and backoff."""