Refactor TrackedContainer run_detached/exec_cmd functions (#2256)

* Refactor TrackedContainer run_detached/exec_cmd functions

* Add get_logs() method

* Small fixes

* Make get_health() a method

* Remove kwargs, always print output

* Small fixes
This commit is contained in:
Ayaz Salikhov
2025-03-21 10:05:00 +00:00
committed by GitHub
parent a916806f2e
commit dcd1c457d3
15 changed files with 78 additions and 129 deletions

View File

@@ -38,18 +38,16 @@ def test_matplotlib(
cont_data_dir = "/home/jovyan/data"
output_dir = "/tmp"
LOGGER.info(description)
running_container = container.run_detached(
container.run_detached(
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}},
tty=True,
command=["bash", "-c", "sleep infinity"],
)
command = f"python {cont_data_dir}/{test_file}"
exec_result = running_container.exec_run(command)
LOGGER.debug(exec_result.output.decode())
assert exec_result.exit_code == 0, f"Command {command} failed"
container.exec_cmd(command)
# Checking if the file is generated
# https://stackoverflow.com/a/15895594/4413446
command = f"test -s {output_dir}/{expected_file}"
exec_result = running_container.exec_run(command)
LOGGER.debug(exec_result.output.decode())
assert exec_result.exit_code == 0, f"Command {command} failed"
container.exec_cmd(command)