osmith has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/41862?usp=email )

Change subject: bts: testenv: check ulimit -r in prepare=
......................................................................

bts: testenv: check ulimit -r in prepare=

Don't respawning over and over again if osmo-bts-trx fails to start up
because the user isn't allowed to set the rtpriority. Show instructions
for fixing it instead.

Change-Id: I7bc1414f95e4a54a40eb7c6f7b3d6c83ce3500c6
---
M _testenv/README.md
A _testenv/data/scripts/require_ulimit_r.sh
M _testenv/testenv/podman.py
M bts/testenv_generic.cfg
M bts/testenv_hopping.cfg
M bts/testenv_oml.cfg
6 files changed, 31 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve




diff --git a/_testenv/README.md b/_testenv/README.md
index b62295e..a973b25 100644
--- a/_testenv/README.md
+++ b/_testenv/README.md
@@ -272,6 +272,11 @@
 * `TERM`:
   Is set to the same `TERM` passed to testenv with fallback to `dumb`.

+* `HOST_USER`:
+  When running in podman (`--podman`), this variable is set to the user that is
+  running podman. This is used in `_testenv/data/scripts/require_ulimit_r.sh`
+  to display a hint for setting the rtprio limit for this user.
+
 ## Eclipse-titan versions

 It is possible to change the eclipse-titan version that is used to build and
diff --git a/_testenv/data/scripts/require_ulimit_r.sh 
b/_testenv/data/scripts/require_ulimit_r.sh
new file mode 100755
index 0000000..eb4e0e2
--- /dev/null
+++ b/_testenv/data/scripts/require_ulimit_r.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+MIN=$1
+
+if [ -z "$MIN" ]; then
+       echo "usage: require_ulimit_r.sh MIN"
+       exit 1
+fi
+
+if [ -z "$USER" ]; then
+       USER="$HOST_USER"
+fi
+
+if [ $(ulimit -r) -lt $MIN ]; then
+       echo
+       echo "===================================================="
+       echo "Allow your user to set rtprio, logout and try again:"
+       echo "$ echo '$USER - rtprio $MIN' | sudo tee 
'/etc/security/limits.d/$USER-allow-rtprio.conf'"
+       echo "===================================================="
+       echo
+       exit 1
+fi
diff --git a/_testenv/testenv/podman.py b/_testenv/testenv/podman.py
index 2013699..79fc5b9 100644
--- a/_testenv/testenv/podman.py
+++ b/_testenv/testenv/podman.py
@@ -244,6 +244,8 @@
         "net.ipv4.conf.default.send_redirects=0",  # OS#6575
         "-e",
         "PODMAN=1",
+        "-e",
+        f"HOST_USER={os.getenv('USER')}",
     ]

     if testenv.args.binary_repo:
diff --git a/bts/testenv_generic.cfg b/bts/testenv_generic.cfg
index e04f89c..3b4a7f1 100644
--- a/bts/testenv_generic.cfg
+++ b/bts/testenv_generic.cfg
@@ -20,6 +20,7 @@
 package=osmocom-bb-trxcon

 [bts]
+prepare=require_ulimit_r.sh 30
 program=respawn.sh osmo-bts-trx
 make=osmo-bts
 package=osmo-bts
diff --git a/bts/testenv_hopping.cfg b/bts/testenv_hopping.cfg
index 9426457..3e1e1c9 100644
--- a/bts/testenv_hopping.cfg
+++ b/bts/testenv_hopping.cfg
@@ -23,6 +23,7 @@
 package=osmocom-bb-trxcon

 [bts]
+prepare=require_ulimit_r.sh 30
 program=respawn.sh osmo-bts-trx
 make=osmo-bts
 package=osmo-bts
diff --git a/bts/testenv_oml.cfg b/bts/testenv_oml.cfg
index b1268c6..1921536 100644
--- a/bts/testenv_oml.cfg
+++ b/bts/testenv_oml.cfg
@@ -14,7 +14,7 @@
 package=osmocom-bb-trxcon

 [bts]
-prepare=osmo-config-merge osmo-bts.cfg osmo-bts-oml.confmerge > 
osmo-bts-oml.cfg
+prepare=osmo-config-merge osmo-bts.cfg osmo-bts-oml.confmerge > 
osmo-bts-oml.cfg && require_ulimit_r.sh 30
 program=osmo-bts-trx -c osmo-bts-oml.cfg
 make=osmo-bts
 package=osmo-bts-trx libosmocore-utils

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/41862?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: I7bc1414f95e4a54a40eb7c6f7b3d6c83ce3500c6
Gerrit-Change-Number: 41862
Gerrit-PatchSet: 4
Gerrit-Owner: osmith <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-CC: laforge <[email protected]>

Reply via email to