osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38258?usp=email )
(
1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: testenv: podman.exec_cmd: better error if stopped ......................................................................
testenv: podman.exec_cmd: better error if stopped
Testenv may try to run a comand in podman after the container was stopped, if there is a bug in the shutdown logic. Give a meaningful error in that case, instead of failing later on with a cryptic error in subprocess.run() because None was passed inside cmd (for the container name) instead of a string.
Change-Id: I29ebe200258a9a9ffb127ec8fa1260b7e2124c38 --- M _testenv/testenv/podman.py 1 file changed, 4 insertions(+), 0 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved pespin: Looks good to me, but someone else must approve
diff --git a/_testenv/testenv/podman.py b/_testenv/testenv/podman.py index 6d801fa..53806a4 100644 --- a/_testenv/testenv/podman.py +++ b/_testenv/testenv/podman.py @@ -131,6 +131,10 @@
def exec_cmd(cmd, podman_opts=[], cwd=None, env={}, *args, **kwargs): + if not container_name: + raise RuntimeError("Attempting to execute a command in podman, but the" + f" container isn't running anymore: {cmd}") + podman_opts = list(podman_opts) podman_opts += generate_env_podman(env) # Attach a fake tty (eclipse-titan won't print colored output otherwise)