Skip to content

Commit 95aa99d

Browse files
authored
Do not allocate TTY in tests if not needed (#2257)
1 parent f0ef7e3 commit 95aa99d

18 files changed

+3
-47
lines changed

tests/by_image/all-spark-notebook/test_spark_notebooks.py

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def test_nbconvert(container: TrackedContainer, test_file: str) -> None:
3333
timeout=60,
3434
no_warnings=False,
3535
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}},
36-
tty=True,
3736
command=["bash", "-c", command],
3837
)
3938
warnings = TrackedContainer.get_warnings(logs)

tests/by_image/base-notebook/test_container_options.py

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def test_nb_user_change(container: TrackedContainer) -> None:
3333
"""Container should change the username (`NB_USER`) of the default user."""
3434
nb_user = "nayvoj"
3535
container.run_detached(
36-
tty=True,
3736
user="root",
3837
environment=[f"NB_USER={nb_user}", "CHOWN_HOME=yes"],
3938
command=["bash", "-c", "sleep infinity"],

tests/by_image/base-notebook/test_healthcheck.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def get_healthy_status(
1717
user: str | None,
1818
) -> str:
1919
container.run_detached(
20-
tty=True,
2120
environment=env,
2221
command=cmd,
2322
user=user,

tests/by_image/base-notebook/test_ips.py

-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,5 @@ def test_ipv46(container: TrackedContainer, ipv6_network: str) -> None:
4141
container.run_detached(
4242
network=ipv6_network,
4343
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro,z"}},
44-
tty=True,
4544
)
4645
container.exec_cmd(f"python {cont_data_dir}/check_listening.py")

tests/by_image/base-notebook/test_pandoc.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def test_pandoc(container: TrackedContainer) -> None:
1111
"""Pandoc shall be able to convert MD to HTML."""
1212
logs = container.run_and_wait(
1313
timeout=10,
14-
tty=True,
1514
command=["bash", "-c", 'echo "**BOLD**" | pandoc'],
1615
)
1716
assert "<p><strong>BOLD</strong></p>" in logs

tests/by_image/base-notebook/test_start_container.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_tini_entrypoint(
7676
https://superuser.com/questions/632979/if-i-know-the-pid-number-of-a-process-how-can-i-get-its-name
7777
"""
7878
LOGGER.info(f"Test that {command} is launched as PID {pid} ...")
79-
container.run_detached(tty=True)
79+
container.run_detached()
8080
# Select the PID 1 and get the corresponding command
8181
output = container.exec_cmd(f"ps -p {pid} -o comm=")
8282
assert "ERROR" not in output

tests/by_image/docker-stacks-foundation/test_python_version.py

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def test_python_version(container: TrackedContainer) -> None:
1414
)
1515
logs = container.run_and_wait(
1616
timeout=5,
17-
tty=True,
1817
command=["python", "--version"],
1918
)
2019
python = next(line for line in logs.splitlines() if line.startswith("Python "))
@@ -28,7 +27,6 @@ def test_python_pinned_version(container: TrackedContainer) -> None:
2827
LOGGER.info(f"Checking that pinned python version is {EXPECTED_PYTHON_VERSION}.*")
2928
logs = container.run_and_wait(
3029
timeout=5,
31-
tty=True,
3230
command=["cat", "/opt/conda/conda-meta/pinned"],
3331
)
3432
assert f"python {EXPECTED_PYTHON_VERSION}.*" in logs

tests/by_image/docker-stacks-foundation/test_run_hooks.py

-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
def test_run_hooks_zero_args(container: TrackedContainer) -> None:
1313
logs = container.run_and_wait(
1414
timeout=5,
15-
tty=True,
1615
no_failure=False,
1716
command=["bash", "-c", "source /usr/local/bin/run-hooks.sh"],
1817
)
@@ -22,7 +21,6 @@ def test_run_hooks_zero_args(container: TrackedContainer) -> None:
2221
def test_run_hooks_two_args(container: TrackedContainer) -> None:
2322
logs = container.run_and_wait(
2423
timeout=5,
25-
tty=True,
2624
no_failure=False,
2725
command=[
2826
"bash",
@@ -36,7 +34,6 @@ def test_run_hooks_two_args(container: TrackedContainer) -> None:
3634
def test_run_hooks_missing_dir(container: TrackedContainer) -> None:
3735
logs = container.run_and_wait(
3836
timeout=5,
39-
tty=True,
4037
no_failure=False,
4138
command=[
4239
"bash",
@@ -50,7 +47,6 @@ def test_run_hooks_missing_dir(container: TrackedContainer) -> None:
5047
def test_run_hooks_dir_is_file(container: TrackedContainer) -> None:
5148
logs = container.run_and_wait(
5249
timeout=5,
53-
tty=True,
5450
no_failure=False,
5551
command=[
5652
"bash",
@@ -64,7 +60,6 @@ def test_run_hooks_dir_is_file(container: TrackedContainer) -> None:
6460
def test_run_hooks_empty_dir(container: TrackedContainer) -> None:
6561
container.run_and_wait(
6662
timeout=5,
67-
tty=True,
6863
command=[
6964
"bash",
7065
"-c",
@@ -91,7 +86,6 @@ def run_source_in_dir(
9186
return container.run_and_wait(
9287
timeout=5,
9388
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}},
94-
tty=True,
9589
no_failure=no_failure,
9690
command=["bash", "-c", command],
9791
)

tests/by_image/docker-stacks-foundation/test_units.py

-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,5 @@ def test_units(container: TrackedContainer) -> None:
3333
container.run_and_wait(
3434
timeout=30,
3535
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}},
36-
tty=True,
3736
command=["python", f"{cont_data_dir}/{test_file_name}"],
3837
)

tests/by_image/docker-stacks-foundation/test_user_options.py

-15
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def test_uid_change(container: TrackedContainer) -> None:
1515
"""Container should change the UID of the default user."""
1616
logs = container.run_and_wait(
1717
timeout=120, # usermod is slow so give it some time
18-
tty=True,
1918
user="root",
2019
environment=["NB_UID=1010"],
2120
command=["bash", "-c", "id && touch /opt/conda/test-file"],
@@ -27,7 +26,6 @@ def test_gid_change(container: TrackedContainer) -> None:
2726
"""Container should change the GID of the default user."""
2827
logs = container.run_and_wait(
2928
timeout=10,
30-
tty=True,
3129
user="root",
3230
environment=["NB_GID=110"],
3331
command=["id"],
@@ -40,7 +38,6 @@ def test_nb_user_change(container: TrackedContainer) -> None:
4038
"""Container should change the username (`NB_USER`) of the default user."""
4139
nb_user = "nayvoj"
4240
container.run_detached(
43-
tty=True,
4441
user="root",
4542
environment=[f"NB_USER={nb_user}", "CHOWN_HOME=yes"],
4643
command=["bash", "-c", "sleep infinity"],
@@ -87,7 +84,6 @@ def test_chown_extra(container: TrackedContainer) -> None:
8784
CHOWN_EXTRA list of folders."""
8885
logs = container.run_and_wait(
8986
timeout=120, # chown is slow so give it some time
90-
tty=True,
9187
user="root",
9288
environment=[
9389
"NB_UID=1010",
@@ -110,7 +106,6 @@ def test_chown_home(container: TrackedContainer) -> None:
110106
group to the current value of NB_UID and NB_GID."""
111107
logs = container.run_and_wait(
112108
timeout=120, # chown is slow so give it some time
113-
tty=True,
114109
user="root",
115110
environment=[
116111
"CHOWN_HOME=yes",
@@ -128,7 +123,6 @@ def test_sudo(container: TrackedContainer) -> None:
128123
"""Container should grant passwordless sudo to the default user."""
129124
logs = container.run_and_wait(
130125
timeout=10,
131-
tty=True,
132126
user="root",
133127
environment=["GRANT_SUDO=yes"],
134128
command=["sudo", "id"],
@@ -140,7 +134,6 @@ def test_sudo_path(container: TrackedContainer) -> None:
140134
"""Container should include /opt/conda/bin in the sudo secure_path."""
141135
logs = container.run_and_wait(
142136
timeout=10,
143-
tty=True,
144137
user="root",
145138
environment=["GRANT_SUDO=yes"],
146139
command=["sudo", "which", "jupyter"],
@@ -152,7 +145,6 @@ def test_sudo_path_without_grant(container: TrackedContainer) -> None:
152145
"""Container should include /opt/conda/bin in the sudo secure_path."""
153146
logs = container.run_and_wait(
154147
timeout=10,
155-
tty=True,
156148
user="root",
157149
command=["which", "jupyter"],
158150
)
@@ -224,7 +216,6 @@ def test_container_not_delete_bind_mount(
224216

225217
container.run_and_wait(
226218
timeout=5,
227-
tty=True,
228219
user="root",
229220
working_dir="/home/",
230221
environment=[
@@ -247,7 +238,6 @@ def test_jupyter_env_vars_to_unset(
247238
root_args = {"user": "root"} if enable_root else {}
248239
logs = container.run_and_wait(
249240
timeout=10,
250-
tty=True,
251241
environment=[
252242
"JUPYTER_ENV_VARS_TO_UNSET=SECRET_ANIMAL,UNUSED_ENV,SECRET_FRUIT",
253243
"FRUIT=bananas",
@@ -276,7 +266,6 @@ def test_secure_path(container: TrackedContainer, tmp_path: pathlib.Path) -> Non
276266

277267
logs = container.run_and_wait(
278268
timeout=5,
279-
tty=True,
280269
user="root",
281270
volumes={p: {"bind": "/usr/bin/python", "mode": "ro"}},
282271
command=["python", "--version"],
@@ -290,7 +279,6 @@ def test_startsh_multiple_exec(container: TrackedContainer) -> None:
290279
logs = container.run_and_wait(
291280
timeout=10,
292281
no_warnings=False,
293-
tty=True,
294282
user="root",
295283
environment=["GRANT_SUDO=yes"],
296284
command=["start.sh", "sudo", "id"],
@@ -308,7 +296,6 @@ def test_rootless_triplet_change(container: TrackedContainer) -> None:
308296
"""Container should change the username (`NB_USER`), the UID and the GID of the default user."""
309297
logs = container.run_and_wait(
310298
timeout=10,
311-
tty=True,
312299
user="root",
313300
environment=["NB_USER=root", "NB_UID=0", "NB_GID=0"],
314301
command=["id"],
@@ -322,7 +309,6 @@ def test_rootless_triplet_home(container: TrackedContainer) -> None:
322309
"""Container should change the home directory for triplet NB_USER=root, NB_UID=0, NB_GID=0."""
323310
logs = container.run_and_wait(
324311
timeout=10,
325-
tty=True,
326312
user="root",
327313
environment=["NB_USER=root", "NB_UID=0", "NB_GID=0"],
328314
command=["bash", "-c", "echo HOME=${HOME} && getent passwd root"],
@@ -335,7 +321,6 @@ def test_rootless_triplet_sudo(container: TrackedContainer) -> None:
335321
"""Container should not be started with sudo for triplet NB_USER=root, NB_UID=0, NB_GID=0."""
336322
logs = container.run_and_wait(
337323
timeout=10,
338-
tty=True,
339324
user="root",
340325
environment=["NB_USER=root", "NB_UID=0", "NB_GID=0"],
341326
command=["env"],

tests/by_image/minimal-notebook/test_nbconvert.py

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def test_nbconvert(
2727
logs = container.run_and_wait(
2828
timeout=30,
2929
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}},
30-
tty=True,
3130
command=["bash", "-c", command],
3231
)
3332
expected_file = f"{output_dir}/{test_file}.{output_format}"

tests/by_image/pyspark-notebook/test_spark.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def test_spark_shell(container: TrackedContainer) -> None:
1212
logs = container.run_and_wait(
1313
timeout=60,
1414
no_warnings=False,
15-
tty=True,
1615
command=["bash", "-c", 'spark-shell <<< "1+1"'],
1716
)
1817
warnings = TrackedContainer.get_warnings(logs)

tests/by_image/scipy-notebook/test_cython.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def test_cython(container: TrackedContainer) -> None:
1414
logs = container.run_and_wait(
1515
timeout=10,
1616
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}},
17-
tty=True,
1817
command=[
1918
"bash",
2019
"-c",

tests/by_image/scipy-notebook/test_extensions.py

-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,5 @@ def test_check_extension(container: TrackedContainer, extension: str) -> None:
2929
LOGGER.info(f"Checking the extension: {extension} ...")
3030
container.run_and_wait(
3131
timeout=10,
32-
tty=True,
3332
command=["jupyter", "labextension", "check", extension],
3433
)

tests/by_image/scipy-notebook/test_matplotlib.py

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def test_matplotlib(
4040
LOGGER.info(description)
4141
container.run_detached(
4242
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}},
43-
tty=True,
4443
command=["bash", "-c", "sleep infinity"],
4544
)
4645

tests/shared_checks/R_mimetype_check.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ def check_r_mimetypes(container: TrackedContainer) -> None:
1212
LOGGER.info("Test that R command can be executed ...")
1313
R_MIMETYPES_CHECK_CMD = 'if (length(getOption("jupyter.plot_mimetypes")) != 5) {stop("missing jupyter.plot_mimetypes")}'
1414
command = ["Rscript", "-e", R_MIMETYPES_CHECK_CMD]
15-
logs = container.run_and_wait(
16-
timeout=10,
17-
tty=True,
18-
command=command,
19-
)
15+
logs = container.run_and_wait(timeout=10, command=command)
2016
LOGGER.debug(f"{logs=}")
2117
# If there is any output after this it means there was an error
2218
assert logs.splitlines()[-1] == "Executing the command: " + " ".join(

tests/utils/conda_package_helper.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ def __init__(self, container: TrackedContainer):
4343
self.container = container
4444

4545
LOGGER.info(f"Starting container {self.container.image_name} ...")
46-
self.container.run_detached(
47-
tty=True,
48-
command=["bash", "-c", "sleep infinity"],
49-
)
46+
self.container.run_detached(command=["bash", "-c", "sleep infinity"])
5047

5148
self.requested: dict[str, set[str]] | None = None
5249
self.installed: dict[str, set[str]] | None = None

tests/utils/run_command.py

-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ def run_command(
1212
command: str,
1313
timeout: int = 5,
1414
) -> str:
15-
"""Runs the given package manager with its version argument."""
16-
1715
LOGGER.info(f"Test that the command '{command}' is working properly ...")
1816
return container.run_and_wait(
1917
timeout=timeout,
20-
tty=True,
2118
command=["bash", "-c", command],
2219
)

0 commit comments

Comments
 (0)