osmith has submitted this change. (
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37887?usp=email )
Change subject: testenv: add TESTENV_REBUILD_OUTDATED_IMAGE
......................................................................
testenv: add TESTENV_REBUILD_OUTDATED_IMAGE
Add an environment variable that allows rebuilding the podman image
whenever it appears to be outdated. This is useful when working on the
Dockerfile. As requested by Pau.
Change-Id: Ia1243320b6d310c69ef9291cca69a1594b1a8a70
---
M _testenv/README.md
M _testenv/testenv/podman.py
2 files changed, 25 insertions(+), 8 deletions(-)
Approvals:
laforge: Looks good to me, approved
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/_testenv/README.md b/_testenv/README.md
index 5eee2d2..4886786 100644
--- a/_testenv/README.md
+++ b/_testenv/README.md
@@ -133,6 +133,12 @@
Set the directory for sources of Osmocom components. The default is the
directory above your osmo-ttcn3-hacks.git clone.
+* `TESTENV_REBUILD_OUTDATED_IMAGE`:
+ Automatically rebuild the outdated image, instead of only displaying a
+ warning. This is not the default because rebuilding it takes some time and is
+ oftentimes not needed (e.g. if a dependency was added that is not relevant to
+ the testsuite that the user is currently testing).
+
* `TESTENV_NO_IMAGE_UP_TO_DATE_CHECK`:
Do not compare the timestamp of `data/podman/Dockerfile` with the date of the
podman image. This check does not work on jenkins where we always have
diff --git a/_testenv/testenv/podman.py b/_testenv/testenv/podman.py
index a972d95..2668b0d 100644
--- a/_testenv/testenv/podman.py
+++ b/_testenv/testenv/podman.py
@@ -52,13 +52,14 @@
return mtime < created
-def image_build():
- if image_exists() and image_up_to_date():
- logging.debug(f"Podman image is up-to-date: {image_name}")
- if testenv.args.force:
- logging.debug("Building anyway since --force was used")
- else:
- return
+def image_build(check_existing=True):
+ if check_existing:
+ if image_exists() and image_up_to_date():
+ logging.debug(f"Podman image is up-to-date: {image_name}")
+ if testenv.args.force:
+ logging.debug("Building anyway since --force was used")
+ else:
+ return
logging.info(f"Building podman image: {image_name}")
testenv.cmd.run(
@@ -110,7 +111,17 @@
if not image_exists():
raise testenv.NoTraceException("Missing podman image, run 'testenv.py
init podman' first to build it")
if not image_up_to_date():
- logging.warning("The podman image might be outdated, consider running
'testenv.py init podman' to rebuild it")
+ if os.environ.get("TESTENV_REBUILD_OUTDATED_IMAGE") == "1":
+ logging.warning("The podman image is outdated, rebuilding it...
(TESTENV_REBUILD_OUTDATED_IMAGE=1)")
+ image_build(False)
+ else:
+ # Rebuilding the image takes some time, and oftentimes it is not
+ # needed. So by default don't force the user to rebuild it, just
+ # show a warning.
+ logging.warning(
+ "The podman image might be outdated, consider running
'testenv.py init podman' to rebuild it"
+ )
+ logging.debug("Set TESTENV_REBUILD_OUTDATED_IMAGE=1 to rebuild it
automatically")
atexit.register(stop)
--
To view, visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37887?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ia1243320b6d310c69ef9291cca69a1594b1a8a70
Gerrit-Change-Number: 37887
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>