-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #874 from jiridanek/jd_spinner_check
RHOAIENG-11156: chore(tests/containers/jupyterlab): check that the JuyterLab index.html contains the spinner code
- Loading branch information
Showing
5 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
63 changes: 63 additions & 0 deletions
63
tests/containers/workbenches/jupyterlab/jupyterlab_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import requests | ||
|
||
import allure | ||
import pytest | ||
|
||
from tests.containers import docker_utils | ||
from tests.containers.workbenches.workbench_image_test import WorkbenchContainer, skip_if_not_workbench_image | ||
|
||
if TYPE_CHECKING: | ||
import docker.models.images | ||
|
||
|
||
class TestJupyterLabImage: | ||
"""Tests for JupyterLab Workbench images in this repository.""" | ||
|
||
APP_ROOT_HOME = "/opt/app-root/src" | ||
|
||
@allure.issue("RHOAIENG-11156") | ||
@allure.description("Check that the HTML for the spinner is contained in the initial page.") | ||
def test_spinner_html_loaded(self, image: str) -> None: | ||
skip_if_not_jupyterlab_image(image) | ||
|
||
container = WorkbenchContainer(image=image, user=4321, group_add=[0]) | ||
# if no env is specified, the image will run | ||
# > 4321 3334 3319 0 10:36 pts/0 00:00:01 /mnt/rosetta /opt/app-root/bin/python3.11 /opt/app-root/bin/jupyter-lab | ||
# > --ServerApp.root_dir=/opt/app-root/src --ServerApp.ip= --ServerApp.allow_origin=* --ServerApp.open_browser=False | ||
# which does not let us open a notebook and get a spinner, we need to disable auth at a minimum | ||
|
||
# These NOTEBOOK_ARGS are what ODH Dashboard uses, | ||
# and we also have them in the Kustomize test files for Makefile tests | ||
container.with_env("NOTEBOOK_ARGS", "\n".join([ | ||
"--ServerApp.port=8888", | ||
"--ServerApp.token=''", | ||
"--ServerApp.password=''", | ||
"--ServerApp.base_url=/notebook/opendatahub/jovyan", | ||
"--ServerApp.quit_button=False", | ||
"""--ServerApp.tornado_settings={"user":"jovyan","hub_host":"https://opendatahub.io","hub_prefix":"/notebookController/jovyan"}"""])) | ||
try: | ||
# we changed base_url, and wait_for_readiness=True would attempt connections to / | ||
container.start(wait_for_readiness=False) | ||
container._connect(base_url="/notebook/opendatahub/jovyan") | ||
|
||
host_ip = container.get_container_host_ip() | ||
host_port = container.get_exposed_port(container.port) | ||
response = requests.get(f"http://{host_ip}:{host_port}/notebook/opendatahub/jovyan") | ||
assert response.status_code == 200 | ||
assert "text/html" in response.headers["content-type"] | ||
assert 'class="pf-v6-c-spinner"' in response.text | ||
finally: | ||
docker_utils.NotebookContainer(container).stop(timeout=0) | ||
|
||
|
||
def skip_if_not_jupyterlab_image(image: str) -> docker.models.images.Image: | ||
image_metadata = skip_if_not_workbench_image(image) | ||
if "-jupyter-" not in image_metadata.labels['name']: | ||
pytest.skip( | ||
f"Image {image} does not have '-jupyter-' in {image_metadata.labels['name']=}'") | ||
|
||
return image_metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters