<p>Michael Bradeen <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18690">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Michael Bradeen: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">CI: Use virtual environment for testsuite<br><br>As part of the move to Python3, the testsuite is now designed<br>to work with a virtual environment.<br><br>This change is to have runTestsuite use the venv method if<br>possible and fall back if it can't. If the script is run from<br>an externally activated virtual enviroment, then use that and<br>don't try either method.<br><br>Change-Id: I9724c446d67a5ee9e550644e4a78739de823536e<br>---<br>A tests/CI/extras.txt<br>A tests/CI/requirements.txt<br>M tests/CI/runTestsuite.sh<br>3 files changed, 49 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/CI/extras.txt b/tests/CI/extras.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..36428be</span><br><span>--- /dev/null</span><br><span>+++ b/tests/CI/extras.txt</span><br><span>@@ -0,0 +1,2 @@</span><br><span style="color: hsl(120, 100%, 40%);">+https://github.com/asterisk/starpy/archive/refs/heads/1.1.zip</span><br><span style="color: hsl(120, 100%, 40%);">+https://github.com/asterisk/yappcap/archive/refs/heads/master.zip</span><br><span>diff --git a/tests/CI/requirements.txt b/tests/CI/requirements.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..b233fa4</span><br><span>--- /dev/null</span><br><span>+++ b/tests/CI/requirements.txt</span><br><span>@@ -0,0 +1,26 @@</span><br><span style="color: hsl(120, 100%, 40%);">+attrs==21.4.0</span><br><span style="color: hsl(120, 100%, 40%);">+autobahn==21.2.1</span><br><span style="color: hsl(120, 100%, 40%);">+Automat==20.2.0</span><br><span style="color: hsl(120, 100%, 40%);">+certifi==2021.10.8</span><br><span style="color: hsl(120, 100%, 40%);">+cffi==1.15.0</span><br><span style="color: hsl(120, 100%, 40%);">+charset-normalizer==2.0.12</span><br><span style="color: hsl(120, 100%, 40%);">+constantly==15.1.0</span><br><span style="color: hsl(120, 100%, 40%);">+construct==2.10.68</span><br><span style="color: hsl(120, 100%, 40%);">+cryptography==37.0.2</span><br><span style="color: hsl(120, 100%, 40%);">+Cython==0.29.28</span><br><span style="color: hsl(120, 100%, 40%);">+hyperlink==21.0.0</span><br><span style="color: hsl(120, 100%, 40%);">+idna==3.3</span><br><span style="color: hsl(120, 100%, 40%);">+incremental==21.3.0</span><br><span style="color: hsl(120, 100%, 40%);">+lxml==4.8.0</span><br><span style="color: hsl(120, 100%, 40%);">+netifaces>=0.10.4</span><br><span style="color: hsl(120, 100%, 40%);">+pycparser==2.21</span><br><span style="color: hsl(120, 100%, 40%);">+PyYAML==6.0</span><br><span style="color: hsl(120, 100%, 40%);">+PyXB==1.2.6</span><br><span style="color: hsl(120, 100%, 40%);">+rawsocket==0.2</span><br><span style="color: hsl(120, 100%, 40%);">+requests==2.27.1</span><br><span style="color: hsl(120, 100%, 40%);">+six==1.16.0</span><br><span style="color: hsl(120, 100%, 40%);">+Twisted==22.4.0</span><br><span style="color: hsl(120, 100%, 40%);">+txaio==22.2.1</span><br><span style="color: hsl(120, 100%, 40%);">+typing_extensions==4.1.1</span><br><span style="color: hsl(120, 100%, 40%);">+urllib3==1.26.9</span><br><span style="color: hsl(120, 100%, 40%);">+zope.interface==5.4.0</span><br><span>diff --git a/tests/CI/runTestsuite.sh b/tests/CI/runTestsuite.sh</span><br><span>index 466991a..423783a 100755</span><br><span>--- a/tests/CI/runTestsuite.sh</span><br><span>+++ b/tests/CI/runTestsuite.sh</span><br><span>@@ -12,13 +12,33 @@</span><br><span> </span><br><span> pushd $TESTSUITE_DIR</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+if [[ "$VIRTUAL_ENV" != "" ]]</span><br><span style="color: hsl(120, 100%, 40%);">+then</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Detected activated virtual environment:"</span><br><span style="color: hsl(120, 100%, 40%);">+ echo $VIRTUAL_ENV</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Skipping creation of new environment"</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+ python3 -m venv ${TESTSUITE_DIR}/.venv</span><br><span style="color: hsl(120, 100%, 40%);">+ source ${TESTSUITE_DIR}/.venv/bin/activate</span><br><span style="color: hsl(120, 100%, 40%);">+ if [[ "$VIRTUAL_ENV" != "" ]]</span><br><span style="color: hsl(120, 100%, 40%);">+ then</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Successfully activated virtual environment:"</span><br><span style="color: hsl(120, 100%, 40%);">+ echo $VIRTUAL_ENV</span><br><span style="color: hsl(120, 100%, 40%);">+ python -m pip install --upgrade pip</span><br><span style="color: hsl(120, 100%, 40%);">+ python -m pip install -r ${CIDIR}/requirements.txt</span><br><span style="color: hsl(120, 100%, 40%);">+ python -m pip install -r ${CIDIR}/extras.txt</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Virtual environment failed, attempting fall-back method"</span><br><span style="color: hsl(120, 100%, 40%);">+ export PYTHONPATH=./lib/python/</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ./cleanup-test-remnants.sh</span><br><span> </span><br><span> if [ $REALTIME -eq 1 ] ; then</span><br><span> $CIDIR/setupRealtime.sh --initialize-db=${INITIALIZE_DB:?0}</span><br><span> fi</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-export PYTHONPATH=./lib/python/</span><br><span> echo "Running tests ${TESTSUITE_COMMAND} ${AST_WORK_DIR:+with work directory ${AST_WORK_DIR}}"</span><br><span> ./runtests.py --cleanup --timeout=${TEST_TIMEOUT} ${TESTSUITE_COMMAND} | contrib/scripts/pretty_print --no-color --no-timer --term-width=120 --show-errors || :</span><br><span> </span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18690">change 18690</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/18690"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: development/16/python3 </div>
<div style="display:none"> Gerrit-Change-Id: I9724c446d67a5ee9e550644e4a78739de823536e </div>
<div style="display:none"> Gerrit-Change-Number: 18690 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>