osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38261?usp=email )


Change subject: testenv: clean_run_scripts: skip if podman stopped
......................................................................

testenv: clean_run_scripts: skip if podman stopped

Do not attempt to run the clean_run_scripts, if podman is being used and
the container has already been shutdown.

Change-Id: I3cc05aabd97b73b65c3089e8806f7a9b32e5975c
---
M _testenv/README.md
M _testenv/testenv/testdir.py
2 files changed, 12 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/61/38261/1

diff --git a/_testenv/README.md b/_testenv/README.md
index 983692c..09b12e8 100644
--- a/_testenv/README.md
+++ b/_testenv/README.md
@@ -57,7 +57,8 @@
   collisions when running a test with multiple configs
   (`rename_junit_xml_classname.sh`). See below for `PATH` and `PWD`. A
   `TESTENV_CLEAN_REASON` env var is set to `prepare`, `crashed` or `finished`
-  depending on when the script runs.
+  depending on when the script runs. The script will not run on crash if podman
+  is used, as the container gets shutdown beforehand.

 #### Component section

diff --git a/_testenv/testenv/testdir.py b/_testenv/testenv/testdir.py
index 242d17d..55f04d2 100644
--- a/_testenv/testenv/testdir.py
+++ b/_testenv/testenv/testdir.py
@@ -170,8 +170,14 @@
 def clean_run_scripts(reason="crashed"):
     global clean_scripts

-    for section, script in clean_scripts.items():
-        logging.info(f"Running {section} clean script (reason: {reason})")
-        env = {"TESTENV_CLEAN_REASON": reason}
-        testenv.cmd.run(script, cwd=os.path.join(testdir, section), env=env)
+    if not clean_scripts:
+        return
+    elif testenv.args.podman and not testenv.podman.is_running():
+        logging.debug("Skipping clean up scripts, podman container has already 
stopped")
+    else:
+        for section, script in clean_scripts.items():
+            logging.info(f"Running {section} clean script (reason: {reason})")
+            env = {"TESTENV_CLEAN_REASON": reason}
+            testenv.cmd.run(script, cwd=os.path.join(testdir, section), 
env=env)
+
     clean_scripts = {}

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38261?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I3cc05aabd97b73b65c3089e8806f7a9b32e5975c
Gerrit-Change-Number: 38261
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>

Reply via email to