Skip to content

Commit 682b932

Browse files
author
Blair Drummond
committed
fix: add NB_PREFIX to tests
1 parent d1a2c58 commit 682b932

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

Diff for: conftest.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,25 @@ class TrackedContainer(object):
5050
Docker client instance
5151
image_name: str
5252
Name of the docker image to launch
53+
nb_prefix: str, optional
54+
The NB_PREFIX arg, the base url for the server
5355
**kwargs: dict, optional
5456
Default keyword arguments to pass to docker.DockerClient.containers.run
5557
"""
5658

57-
def __init__(self, docker_client, image_name, **kwargs):
59+
def __init__(self, docker_client, image_name, nb_prefix="/notebook/user/name", **kwargs):
5860
self.container = None
5961
self.docker_client = docker_client
6062
self.image_name = image_name
6163
self.kwargs = kwargs
6264

65+
if not 'environment' in self.kwargs:
66+
self.kwargs['environment'] = {}
67+
68+
# This base_url is important for kubeflow testing
69+
self.kwargs['environment']['NB_PREFIX'] = nb_prefix
70+
71+
6372
def run(self, **kwargs):
6473
"""Runs a docker container using the preconfigured image name
6574
and a mix of the preconfigured container options and those passed

Diff for: output/remote-desktop/start-remote-desktop.sh

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ cat $HOME/.vnc/*.log
9696
./utils/launch.sh --web $(pwd) --vnc --unix-target=$VNC_SOCKET --listen 5678
9797
) &
9898

99+
NB_PREFIX=${NB_PREFIX:-/vnc}
99100
sed -i "s~\${NB_PREFIX}~$NB_PREFIX~g" /etc/nginx/nginx.conf
100101

101102
nginx

Diff for: resources/remote-desktop/start-remote-desktop.sh

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ cat $HOME/.vnc/*.log
9696
./utils/launch.sh --web $(pwd) --vnc --unix-target=$VNC_SOCKET --listen 5678
9797
) &
9898

99+
NB_PREFIX=${NB_PREFIX:-/}
99100
sed -i "s~\${NB_PREFIX}~$NB_PREFIX~g" /etc/nginx/nginx.conf
100101

101102
nginx

Diff for: tests/general/test_notebook.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
import logging
44

55
LOGGER = logging.getLogger(__name__)
6+
ENV = {
7+
"NB_PREFIX":"/notebook/username/test",
8+
}
69

710
def test_server_alive(container, http_client, url="http://localhost:8888"):
811
"""Notebook server should eventually appear with a recognizable page."""
12+
13+
url = "{}{}/".format(url, container.kwargs['environment']['NB_PREFIX'])
14+
915
LOGGER.info("Running test_server_alive")
1016
LOGGER.info("launching the container")
1117
container.run()
@@ -14,15 +20,16 @@ def test_server_alive(container, http_client, url="http://localhost:8888"):
1420
resp.raise_for_status()
1521
LOGGER.debug(f"got text from url: {resp.text}")
1622

17-
# Not sure why but some flavors of JupyterLab images don't hit all of these.
23+
# Not sure why but some flavors of JupyterLab images don't hit all of these.
1824
# Trying to catch several different acceptable looks.
1925
# Also accepting RStudio
20-
# TODO: This general test accepts many different images.
26+
# TODO: This general test accepts many different images.
2127
# Could refactor to have specific tests that are more pointed
2228
assert any((
2329
"<title>JupyterLab" in resp.text,
2430
"<title>Jupyter Notebook</title>" in resp.text,
2531
"<title>RStudio:" in resp.text, # RStudio
2632
'<html lang="en" class="noVNC_loading">' in resp.text, # remote-desktop using noVNC
33+
'<html lang="fr" class="noVNC_loading">' in resp.text, # remote-desktop using noVNC
2734
'<span id="running_list_info">Currently running Jupyter processes</span>' in resp.text,
2835
)), "Image does not appear to start to JupyterLab page. Try starting yourself and browsing to it to see what is happening"

0 commit comments

Comments
 (0)