]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
CI: Use virtual environment for testsuite
authorMike Bradeen <mbradeen@sangoma.com>
Fri, 24 Jun 2022 17:19:20 +0000 (11:19 -0600)
committerMike Bradeen <mbradeen@sangoma.com>
Mon, 27 Jun 2022 19:44:21 +0000 (13:44 -0600)
As part of the move to Python3, the testsuite is now designed
to work with a virtual environment.

This change is to have runTestsuite use the venv method if
possible and fall back if it can't.  If the script is run from
an externally activated virtual enviroment, then use that and
don't try either method.

Change-Id: I9724c446d67a5ee9e550644e4a78739de823536e

tests/CI/extras.txt [new file with mode: 0644]
tests/CI/requirements.txt [new file with mode: 0644]
tests/CI/runTestsuite.sh

diff --git a/tests/CI/extras.txt b/tests/CI/extras.txt
new file mode 100644 (file)
index 0000000..36428be
--- /dev/null
@@ -0,0 +1,2 @@
+https://github.com/asterisk/starpy/archive/refs/heads/1.1.zip
+https://github.com/asterisk/yappcap/archive/refs/heads/master.zip
diff --git a/tests/CI/requirements.txt b/tests/CI/requirements.txt
new file mode 100644 (file)
index 0000000..b233fa4
--- /dev/null
@@ -0,0 +1,26 @@
+attrs==21.4.0
+autobahn==21.2.1
+Automat==20.2.0
+certifi==2021.10.8
+cffi==1.15.0
+charset-normalizer==2.0.12
+constantly==15.1.0
+construct==2.10.68
+cryptography==37.0.2
+Cython==0.29.28
+hyperlink==21.0.0
+idna==3.3
+incremental==21.3.0
+lxml==4.8.0
+netifaces>=0.10.4
+pycparser==2.21
+PyYAML==6.0
+PyXB==1.2.6
+rawsocket==0.2
+requests==2.27.1
+six==1.16.0
+Twisted==22.4.0
+txaio==22.2.1
+typing_extensions==4.1.1
+urllib3==1.26.9
+zope.interface==5.4.0
index 466991a44c53f9caef6615db8c06e770472828f0..423783ad7d551eedb1baf52d3e14025e965b098b 100755 (executable)
@@ -12,13 +12,33 @@ fi
 
 pushd $TESTSUITE_DIR
 
+if [[ "$VIRTUAL_ENV" != "" ]]
+then
+               echo "Detected activated virtual environment:"
+               echo $VIRTUAL_ENV
+               echo "Skipping creation of new environment"
+else
+       python3 -m venv ${TESTSUITE_DIR}/.venv
+       source ${TESTSUITE_DIR}/.venv/bin/activate
+       if [[ "$VIRTUAL_ENV" != "" ]]
+       then
+               echo "Successfully activated virtual environment:"
+               echo $VIRTUAL_ENV
+               python -m pip install --upgrade pip
+               python -m pip install -r ${CIDIR}/requirements.txt
+               python -m pip install -r ${CIDIR}/extras.txt
+       else
+               echo "Virtual environment failed, attempting fall-back method"
+               export PYTHONPATH=./lib/python/
+       fi
+fi
+
 ./cleanup-test-remnants.sh
 
 if [ $REALTIME -eq 1 ] ; then
        $CIDIR/setupRealtime.sh --initialize-db=${INITIALIZE_DB:?0}
 fi
 
-export PYTHONPATH=./lib/python/
 echo "Running tests ${TESTSUITE_COMMAND} ${AST_WORK_DIR:+with work directory ${AST_WORK_DIR}}"
 ./runtests.py --cleanup --timeout=${TEST_TIMEOUT} ${TESTSUITE_COMMAND} | contrib/scripts/pretty_print --no-color --no-timer --term-width=120 --show-errors || :