Files
docker-stacks/tests/base-notebook/test_healthcheck.py
Muhammad Aji Muharrom 0d324bc0b3 Parameterize healthcheck by internal port (#1859)
* Use the JUPYTER_PORT environment variable to configure server port

- Remove port setting in jupyter_server_config.py
- Declare the $JUPYTER_PORT env on the base Dockerfile
- Use it for HEALTHCHECK

* Add test case for JUPYTER_PORT env variable

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update documentation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update style

* Better wording

* Better wording

* Add test for custom internal port

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Parametrize internal port test case

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Try to fix test

* Better tests

Co-authored-by: Muhammad Aji Muharrom <ajimuharrom@uchicago.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@gmail.com>
2023-01-24 11:19:39 +04:00

36 lines
965 B
Python

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import logging
import time
from typing import Optional
import pytest # type: ignore
from tests.conftest import TrackedContainer, get_health
LOGGER = logging.getLogger(__name__)
@pytest.mark.parametrize(
"env",
[
None,
["DOCKER_STACKS_JUPYTER_CMD=lab"],
["DOCKER_STACKS_JUPYTER_CMD=notebook"],
["DOCKER_STACKS_JUPYTER_CMD=server"],
["DOCKER_STACKS_JUPYTER_CMD=nbclassic"],
["RESTARTABLE=yes"],
["JUPYTER_PORT=8171"],
["JUPYTER_PORT=8117", "DOCKER_STACKS_JUPYTER_CMD=notebook"],
],
)
def test_health(container: TrackedContainer, env: Optional[list[str]]) -> None:
running_container = container.run_detached(
tty=True,
environment=env,
)
# sleeping some time to let the server start
time.sleep(15)
assert get_health(running_container) == "healthy"