From d57bf9590d1407362e3b7029192d0e181fb11818 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Wed, 17 Jan 2024 02:11:44 +0400 Subject: [PATCH] Adjust sleep times (#2080) * Adjust sleep times * Update test_start_container.py * Update test_healthcheck.py * Update pluto_check.py --- images/base-notebook/Dockerfile | 2 +- tests/base-notebook/test_healthcheck.py | 36 +++++++++++-------------- tests/pluto_check.py | 2 +- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/images/base-notebook/Dockerfile b/images/base-notebook/Dockerfile index fd6a42801c..07903b9437 100644 --- a/images/base-notebook/Dockerfile +++ b/images/base-notebook/Dockerfile @@ -68,7 +68,7 @@ RUN fix-permissions /etc/jupyter/ # 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=5s --timeout=3s --start-period=5s --retries=3 \ +HEALTHCHECK --interval=3s --timeout=1s --start-period=3s --retries=3 \ CMD /etc/jupyter/docker_healthcheck.py || exit 1 # Switch back to jovyan to avoid accidental container runs as root diff --git a/tests/base-notebook/test_healthcheck.py b/tests/base-notebook/test_healthcheck.py index 2e572019b3..d5874c9a3c 100644 --- a/tests/base-notebook/test_healthcheck.py +++ b/tests/base-notebook/test_healthcheck.py @@ -67,13 +67,11 @@ def test_healthy( user=user, ) - # sleeping some time to let the server start - time_spent = 0.0 - wait_time = 0.1 - time_limit = 15 - while time_spent < time_limit: - time.sleep(wait_time) - time_spent += wait_time + # giving some time to let the server start + finish_time = time.time() + 10 + sleep_time = 0.1 + while time.time() < finish_time: + time.sleep(sleep_time) if get_health(running_container) == "healthy": return @@ -114,13 +112,11 @@ def test_healthy_with_proxy( user=user, ) - # sleeping some time to let the server start - time_spent = 0.0 - wait_time = 0.1 - time_limit = 15 - while time_spent < time_limit: - time.sleep(wait_time) - time_spent += wait_time + # giving some time to let the server start + finish_time = time.time() + 10 + sleep_time = 0.1 + while time.time() < finish_time: + time.sleep(sleep_time) if get_health(running_container) == "healthy": return @@ -152,13 +148,11 @@ def test_not_healthy( command=cmd, ) - # sleeping some time to let the server start - time_spent = 0.0 - wait_time = 0.1 - time_limit = 15 - while time_spent < time_limit: - time.sleep(wait_time) - time_spent += wait_time + # giving some time to let the server start + finish_time = time.time() + 5 + sleep_time = 0.1 + while time.time() < finish_time: + time.sleep(sleep_time) if get_health(running_container) == "healthy": raise RuntimeError("Container should not be healthy for this testcase") diff --git a/tests/pluto_check.py b/tests/pluto_check.py index ebb558b4be..48116db472 100644 --- a/tests/pluto_check.py +++ b/tests/pluto_check.py @@ -24,7 +24,7 @@ def check_pluto_proxy( ports={"8888/tcp": host_port}, ) # Give the server a bit of time to start - time.sleep(3) + time.sleep(2) resp = http_client.get(f"http://localhost:{host_port}/pluto?token={token}") resp.raise_for_status() assert "Pluto.jl notebooks" in resp.text, "Pluto.jl text not found in /pluto page"