diff --git a/base-notebook/test/test_container_options.py b/base-notebook/test/test_container_options.py index 8e49ee41..5803008c 100644 --- a/base-notebook/test/test_container_options.py +++ b/base-notebook/test/test_container_options.py @@ -15,7 +15,13 @@ def test_cli_args(container, http_client): resp = http_client.get("http://localhost:8888") resp.raise_for_status() logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + warnings = [ + warning for warning in logs.split("\n") if warning.startswith("WARNING") + ] LOGGER.debug(logs) + assert len(warnings) == 1 + assert warnings[0].startswith("WARNING: Jupyter Notebook deprecation notice") assert "login_submit" not in resp.text @@ -24,7 +30,7 @@ def test_unsigned_ssl(container, http_client): """Container should generate a self-signed SSL certificate and notebook server should use it to enable HTTPS. """ - container.run(environment=["GEN_CERT=yes"]) + c = container.run(environment=["GEN_CERT=yes"]) # NOTE: The requests.Session backing the http_client fixture does not retry # properly while the server is booting up. An SSL handshake error seems to # abort the retry logic. Forcing a long sleep for the moment until I have @@ -33,6 +39,13 @@ def test_unsigned_ssl(container, http_client): resp = http_client.get("https://localhost:8888", verify=False) resp.raise_for_status() assert "login_submit" in resp.text + logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + warnings = [ + warning for warning in logs.split("\n") if warning.startswith("WARNING") + ] + assert len(warnings) == 1 + assert warnings[0].startswith("WARNING: Jupyter Notebook deprecation notice") def test_uid_change(container): @@ -45,6 +58,9 @@ def test_uid_change(container): ) # usermod is slow so give it some time rv = c.wait(timeout=120) + logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs assert rv == 0 or rv["StatusCode"] == 0 assert "uid=1010(jovyan)" in c.logs(stdout=True).decode("utf-8") @@ -60,6 +76,8 @@ def test_gid_change(container): rv = c.wait(timeout=10) assert rv == 0 or rv["StatusCode"] == 0 logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs assert "gid=110(jovyan)" in logs assert "groups=110(jovyan),100(users)" in logs @@ -79,6 +97,8 @@ def test_nb_user_change(container): time.sleep(10) LOGGER.info(f"Checking if the user is changed to {nb_user} by the start script ...") output = running_container.logs(stdout=True).decode("utf-8") + assert "ERROR" not in output + assert "WARNING" not in output assert ( f"username: jovyan -> {nb_user}" in output ), f"User is not changed to {nb_user}" @@ -134,6 +154,8 @@ def test_chown_extra(container): rv = c.wait(timeout=120) assert rv == 0 or rv["StatusCode"] == 0 logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs assert "/home/jovyan/.bashrc:1010:101" in logs assert "/opt/conda/bin/jupyter:1010:101" in logs @@ -156,6 +178,8 @@ def test_chown_home(container): rv = c.wait(timeout=120) assert rv == 0 or rv["StatusCode"] == 0 logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs assert "/home/kitten/.bashrc:1010:101" in logs @@ -169,7 +193,10 @@ def test_sudo(container): ) rv = c.wait(timeout=10) assert rv == 0 or rv["StatusCode"] == 0 - assert "uid=0(root)" in c.logs(stdout=True).decode("utf-8") + logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs + assert "uid=0(root)" in logs def test_sudo_path(container): @@ -183,6 +210,8 @@ def test_sudo_path(container): rv = c.wait(timeout=10) assert rv == 0 or rv["StatusCode"] == 0 logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs assert logs.rstrip().endswith("/opt/conda/bin/jupyter") @@ -196,6 +225,8 @@ def test_sudo_path_without_grant(container): rv = c.wait(timeout=10) assert rv == 0 or rv["StatusCode"] == 0 logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs assert logs.rstrip().endswith("/opt/conda/bin/jupyter") @@ -211,6 +242,8 @@ def test_group_add(container, tmpdir): rv = c.wait(timeout=5) assert rv == 0 or rv["StatusCode"] == 0 logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs assert "uid=1010 gid=1010 groups=1010,100(users)" in logs @@ -235,6 +268,9 @@ def test_container_not_delete_bind_mount(container, tmp_path): command=["start.sh", "ls"], ) rv = c.wait(timeout=5) + logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs assert rv == 0 or rv["StatusCode"] == 0 assert p.read_text() == "some-content" assert len(list(tmp_path.iterdir())) == 1 @@ -264,4 +300,6 @@ def test_jupyter_env_vars_to_unset_as_root(container, enable_root): rv = c.wait(timeout=10) assert rv == 0 or rv["StatusCode"] == 0 logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs assert "I like bananas and stuff, and love to keep secrets!" in logs diff --git a/base-notebook/test/test_package_managers.py b/base-notebook/test/test_package_managers.py index 7c96a73d..62ebaadf 100644 --- a/base-notebook/test/test_package_managers.py +++ b/base-notebook/test/test_package_managers.py @@ -29,6 +29,8 @@ def test_package_manager(container, package_manager, version_arg): rv = c.wait(timeout=5) logs = c.logs(stdout=True).decode("utf-8") LOGGER.debug(logs) + assert "ERROR" not in logs + assert "WARNING" not in logs assert ( rv == 0 or rv["StatusCode"] == 0 ), f"Package manager {package_manager} not working" diff --git a/base-notebook/test/test_pandoc.py b/base-notebook/test/test_pandoc.py index f0e33ab8..5c8d33b1 100644 --- a/base-notebook/test/test_pandoc.py +++ b/base-notebook/test/test_pandoc.py @@ -14,5 +14,7 @@ def test_pandoc(container): ) c.wait(timeout=10) logs = c.logs(stdout=True).decode("utf-8") + assert "ERROR" not in logs + assert "WARNING" not in logs LOGGER.debug(logs) assert "

BOLD

" in logs diff --git a/base-notebook/test/test_python.py b/base-notebook/test/test_python.py index 7dc8ef1f..67cecf82 100644 --- a/base-notebook/test/test_python.py +++ b/base-notebook/test/test_python.py @@ -16,6 +16,8 @@ def test_python_version(container, python_next_version="3.10"): ) cmd = c.exec_run("python --version") output = cmd.output.decode("utf-8") + assert "ERROR" not in output + assert "WARNING" not in output actual_python_version = version.parse(output.split()[1]) assert actual_python_version < version.parse( python_next_version diff --git a/base-notebook/test/test_start_container.py b/base-notebook/test/test_start_container.py index d3eec46d..81a131a5 100644 --- a/base-notebook/test/test_start_container.py +++ b/base-notebook/test/test_start_container.py @@ -27,6 +27,15 @@ def test_start_notebook(container, http_client, env, expected_server): resp = http_client.get("http://localhost:8888") logs = c.logs(stdout=True).decode("utf-8") LOGGER.debug(logs) + assert "ERROR" not in logs + if expected_server != "notebook": + assert "WARNING" not in logs + else: + warnings = [ + warning for warning in logs.split("\n") if warning.startswith("WARNING") + ] + assert len(warnings) == 1 + assert warnings[0].startswith("WARNING: Jupyter Notebook deprecation notice") assert resp.status_code == 200, "Server is not listening" assert ( f"Executing the command: jupyter {expected_server}" in logs @@ -51,4 +60,6 @@ def test_tini_entrypoint(container, pid=1, command="tini"): # Select the PID 1 and get the corresponding command cmd = c.exec_run(f"ps -p {pid} -o comm=") output = cmd.output.decode("utf-8").strip("\n") + assert "ERROR" not in output + assert "WARNING" not in output assert output == command, f"{command} shall be launched as pid {pid}, got {output}"