Check base-notebook test logs for ERROR/WARNING

This commit is contained in:
Ben Mares
2021-12-11 16:48:19 +01:00
parent b4aab84201
commit 709206ac87
5 changed files with 57 additions and 2 deletions

View File

@@ -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

View File

@@ -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"

View File

@@ -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 "<p><strong>BOLD</strong></p>" in logs

View File

@@ -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

View File

@@ -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}"