osmith submitted this change.

View Change

Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve fixeria: Looks good to me, approved
hlr: testenv: fix running pyhss from debian pkg

Move the run_in_venv.sh script that is only used by pyhss from the
generic location _testenv/data/scripts/run_in_venv.sh to
hlr/pyhss/run_in_venv.sh and hardcode the path
/opt/venvs/pyhss/bin/activate in there when running from binary
packages. This is the path used in the binary package in the Osmocom
OBS, the default path from dh_virtualenv. The package doesn't install
pyhss_gsup etc. to /usr/bin, as these are usually not meant to be
directly started without the systemd services that have the
/opt/venvs/pyhss path hardcoded.

Also put 'export PYHSS_CONFIG=config.yaml' in there, now that
the script is pyhss specific.

Related: https://dh-virtualenv.readthedocs.io/en/1.2.1/usage.html
Change-Id: I0cdf1a9f220ddd2ef0866d0d11d1e3f6056a1cba
---
D _testenv/data/scripts/run_in_venv.sh
A hlr/pyhss/run_in_venv.sh
M hlr/testenv_pyhss.cfg
3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/_testenv/data/scripts/run_in_venv.sh b/_testenv/data/scripts/run_in_venv.sh
deleted file mode 100755
index b953a36..0000000
--- a/_testenv/data/scripts/run_in_venv.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh -e
-if [ -n "$TESTENV_INSTALL_DIR" ]; then
- . "$TESTENV_INSTALL_DIR"/venv/bin/activate
-fi
-
-"$@"
diff --git a/hlr/pyhss/run_in_venv.sh b/hlr/pyhss/run_in_venv.sh
new file mode 100755
index 0000000..a145a7d
--- /dev/null
+++ b/hlr/pyhss/run_in_venv.sh
@@ -0,0 +1,12 @@
+#!/bin/sh -e
+export PYHSS_CONFIG=config.yaml
+
+if [ "$TESTENV_INSTALL_DIR" = "/" ]; then
+ # Installed via debian package
+ . /opt/venvs/pyhss/bin/activate
+else
+ # Built with osmo-dev
+ . "$TESTENV_INSTALL_DIR"/venv/bin/activate
+fi
+
+"$@"
diff --git a/hlr/testenv_pyhss.cfg b/hlr/testenv_pyhss.cfg
index 4666d2d..9e9d430 100644
--- a/hlr/testenv_pyhss.cfg
+++ b/hlr/testenv_pyhss.cfg
@@ -5,14 +5,14 @@
copy=pyhss/HLR_Tests.cfg

[pyhss_gsup]
-program=PYHSS_CONFIG=config.yaml run_in_venv.sh pyhss_gsup
+program=./run_in_venv.sh pyhss_gsup
setup=wait_for_port.py -p 4222
make=pyhss
package=pyhss
-copy=pyhss/config.yaml
+copy=pyhss/config.yaml pyhss/run_in_venv.sh

[pyhss_api]
-program=cd ../pyhss_gsup && PYHSS_CONFIG=config.yaml run_in_venv.sh pyhss_api
+program=cd ../pyhss_gsup && ./run_in_venv.sh pyhss_api
setup=./setup_db.sh
make=pyhss
package=pyhss

To view, visit change 41372. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I0cdf1a9f220ddd2ef0866d0d11d1e3f6056a1cba
Gerrit-Change-Number: 41372
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>