<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/9431">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Jenkins2: Verified
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">CI: Add daily periodics to CI<br><br>Change-Id: I26933e73928e091ae72e838c02f4f2ec7c3983d6<br>---<br>M tests/CI/ci.functions<br>M tests/CI/gates.jenkinsfile<br>A tests/CI/periodic-dailyTestGroups.json<br>A tests/CI/periodics-daily.jenkinsfile<br>M tests/CI/runTestsuite.sh<br>M tests/CI/runUnittests.sh<br>6 files changed, 173 insertions(+), 10 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/CI/ci.functions b/tests/CI/ci.functions</span><br><span>index f3de16e..55c460e 100644</span><br><span>--- a/tests/CI/ci.functions</span><br><span>+++ b/tests/CI/ci.functions</span><br><span>@@ -21,6 +21,6 @@</span><br><span> done</span><br><span> </span><br><span> runner() {</span><br><span style="color: hsl(0, 100%, 40%);">- ( set -x ; "$@" )</span><br><span style="color: hsl(120, 100%, 40%);">+ ( set -x ; ${@} )</span><br><span> }</span><br><span> </span><br><span>diff --git a/tests/CI/gates.jenkinsfile b/tests/CI/gates.jenkinsfile</span><br><span>index 183fac1..7df6a8e 100644</span><br><span>--- a/tests/CI/gates.jenkinsfile</span><br><span>+++ b/tests/CI/gates.jenkinsfile</span><br><span>@@ -134,13 +134,12 @@</span><br><span> def groupName = testGroup.name</span><br><span> def groupDir = testGroup.dir</span><br><span> def groupTestcmd = testGroup.testcmd</span><br><span style="color: hsl(0, 100%, 40%);">- def testsuiteUrl = env.GERRIT_PROJECT_URL.replaceAll(/${GERRIT_PROJECT}$/, "testsuite")</span><br><span style="color: hsl(120, 100%, 40%);">+ def testsuiteUrl = env.GERRIT_PROJECT_URL.replaceAll(/\/(Security-)?[^\/]+$/, "/\$1testsuite")</span><br><span> </span><br><span> parallelTasks[groupName] = {</span><br><span> stage (groupName) {</span><br><span> </span><br><span> img.inside("${dockerOptions} --name ${BUILD_TAG}-${groupName}") {</span><br><span style="color: hsl(0, 100%, 40%);">- sh "printenv | sort"</span><br><span> </span><br><span> lock("${JOB_NAME}.${NODE_NAME}.installer") {</span><br><span> sh 'sudo ./tests/CI/installAsterisk.sh --user-group=jenkins:users'</span><br><span>diff --git a/tests/CI/periodic-dailyTestGroups.json b/tests/CI/periodic-dailyTestGroups.json</span><br><span>new file mode 100644</span><br><span>index 0000000..4e60ba0</span><br><span>--- /dev/null</span><br><span>+++ b/tests/CI/periodic-dailyTestGroups.json</span><br><span>@@ -0,0 +1,32 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ "name": "ari ",</span><br><span style="color: hsl(120, 100%, 40%);">+ "dir": "tests/CI/output/ari",</span><br><span style="color: hsl(120, 100%, 40%);">+ "testcmd": "-t tests/rest_api/"</span><br><span style="color: hsl(120, 100%, 40%);">+ },</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ "name": "pjsip ",</span><br><span style="color: hsl(120, 100%, 40%);">+ "dir": "tests/CI/output/pjsip",</span><br><span style="color: hsl(120, 100%, 40%);">+ "testcmd": "-t tests/channels/pjsip"</span><br><span style="color: hsl(120, 100%, 40%);">+ },</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ "name": "sip ",</span><br><span style="color: hsl(120, 100%, 40%);">+ "dir": "tests/CI/output/sip",</span><br><span style="color: hsl(120, 100%, 40%);">+ "testcmd": "-t tests/channels/SIP"</span><br><span style="color: hsl(120, 100%, 40%);">+ },</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ "name": "iax2_locl",</span><br><span style="color: hsl(120, 100%, 40%);">+ "dir": "tests/CI/output/iax2_local",</span><br><span style="color: hsl(120, 100%, 40%);">+ "testcmd": " -t tests/channels/iax2 -t tests/channels/local"</span><br><span style="color: hsl(120, 100%, 40%);">+ },</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ "name": "agi-apps ",</span><br><span style="color: hsl(120, 100%, 40%);">+ "dir": "tests/CI/output/agi-apps",</span><br><span style="color: hsl(120, 100%, 40%);">+ "testcmd": " -t tests/agi -t tests/apps -t blind-transfer-parkingtimeout"</span><br><span style="color: hsl(120, 100%, 40%);">+ },</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ "name": "other ",</span><br><span style="color: hsl(120, 100%, 40%);">+ "dir": "tests/CI/output/other",</span><br><span style="color: hsl(120, 100%, 40%);">+ "testcmd": " -T tests/(apps|agi|blind-transfer-parkingtimeout|rest_api|channels|realtime|example|skeleton_test|remote-test)"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+]</span><br><span>diff --git a/tests/CI/periodics-daily.jenkinsfile b/tests/CI/periodics-daily.jenkinsfile</span><br><span>new file mode 100644</span><br><span>index 0000000..b84334a</span><br><span>--- /dev/null</span><br><span>+++ b/tests/CI/periodics-daily.jenkinsfile</span><br><span>@@ -0,0 +1,129 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This pipeline is the "template" for the Asterisk Periodic Tests multi-branch</span><br><span style="color: hsl(120, 100%, 40%);">+ * parent job. Jenkins will automatically scan the branches in the "asterisk"</span><br><span style="color: hsl(120, 100%, 40%);">+ * or "Security-asterisk" projects in Gerrit and automatically create a branch-</span><br><span style="color: hsl(120, 100%, 40%);">+ * specific job for each branch it finds this file in.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file starts as a declarative pipeline because with a declarative</span><br><span style="color: hsl(120, 100%, 40%);">+ * pipeline, you can define the trigger in the pipeline file. This keeps</span><br><span style="color: hsl(120, 100%, 40%);">+ * everything in one place. We transition to scripted pipeline later on because</span><br><span style="color: hsl(120, 100%, 40%);">+ * we need to dynamically determine which docker image we're going to use and</span><br><span style="color: hsl(120, 100%, 40%);">+ * you can't do that in a delcarative pipeline.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+pipeline {</span><br><span style="color: hsl(120, 100%, 40%);">+ triggers {</span><br><span style="color: hsl(120, 100%, 40%);">+ cron 'H H(0-4) * * *'</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ agent {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* All of the stages need to be performed on a docker host */</span><br><span style="color: hsl(120, 100%, 40%);">+ label "swdev-docker"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ stages {</span><br><span style="color: hsl(120, 100%, 40%);">+ stage ("->") {</span><br><span style="color: hsl(120, 100%, 40%);">+ steps {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Here's where we switch to scripted pipeline */</span><br><span style="color: hsl(120, 100%, 40%);">+ script {</span><br><span style="color: hsl(120, 100%, 40%);">+ stage ("Checkout") {</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo chown -R jenkins:users ." </span><br><span style="color: hsl(120, 100%, 40%);">+ sh "printenv | sort"</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo tests/CI/setupJenkinsEnvironment.sh"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def images = env.DOCKER_IMAGES.split(' ')</span><br><span style="color: hsl(120, 100%, 40%);">+ def r = currentBuild.startTimeInMillis % images.length</span><br><span style="color: hsl(120, 100%, 40%);">+ def ri = images[(int)r]</span><br><span style="color: hsl(120, 100%, 40%);">+ def randomImage = env.DOCKER_REGISTRY + "/" + ri</span><br><span style="color: hsl(120, 100%, 40%);">+ def dockerOptions = "--ulimit core=0 --ulimit nofile=10240 " +</span><br><span style="color: hsl(120, 100%, 40%);">+ " -v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw " +</span><br><span style="color: hsl(120, 100%, 40%);">+ " --entrypoint=''"</span><br><span style="color: hsl(120, 100%, 40%);">+ def outputdir = "tests/CI/output/Testsuite"</span><br><span style="color: hsl(120, 100%, 40%);">+ def img = docker.image(randomImage)</span><br><span style="color: hsl(120, 100%, 40%);">+ img.pull()</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ stage ("Build") {</span><br><span style="color: hsl(120, 100%, 40%);">+ img.inside(dockerOptions + " --name ${BUILD_TAG}-build") {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo 'Building..'</span><br><span style="color: hsl(120, 100%, 40%);">+ env.CCACHE_DIR = "/srv/cache/ccache"</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "./tests/CI/buildAsterisk.sh --output-dir=${outputdir} --cache-dir=/srv/cache"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,</span><br><span style="color: hsl(120, 100%, 40%);">+ artifacts: "${outputdir}/*"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def testGroups = readJSON file: "tests/CI/periodic-dailyTestGroups.json"</span><br><span style="color: hsl(120, 100%, 40%);">+ def parallelTasks = [ : ]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ for (def testGroup in testGroups) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Because each task is a Groovy closure, we need to</span><br><span style="color: hsl(120, 100%, 40%);">+ * keep local references to some variables.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ def groupName = testGroup.name</span><br><span style="color: hsl(120, 100%, 40%);">+ def groupDir = testGroup.dir</span><br><span style="color: hsl(120, 100%, 40%);">+ def groupTestcmd = testGroup.testcmd</span><br><span style="color: hsl(120, 100%, 40%);">+ def testsuiteUrl = env.GIT_URL.replaceAll(/\/(Security-)?[^\/]+$/, "/\$1testsuite")</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ parallelTasks[groupName] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ stage (groupName) {</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ img.inside("${dockerOptions} --name ${BUILD_TAG}-${groupName}") {</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ lock("${JOB_NAME}.${NODE_NAME}.installer") {</span><br><span style="color: hsl(120, 100%, 40%);">+ sh 'sudo ./tests/CI/installAsterisk.sh --user-group=jenkins:users'</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo rm -rf ${groupDir} || : "</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ checkout scm: [$class: 'GitSCM',</span><br><span style="color: hsl(120, 100%, 40%);">+ branches: [[name: "${BRANCH_NAME}"]],</span><br><span style="color: hsl(120, 100%, 40%);">+ extensions: [</span><br><span style="color: hsl(120, 100%, 40%);">+ [$class: 'RelativeTargetDirectory', relativeTargetDir: groupDir],</span><br><span style="color: hsl(120, 100%, 40%);">+ [$class: 'CloneOption',</span><br><span style="color: hsl(120, 100%, 40%);">+ noTags: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ depth: 10,</span><br><span style="color: hsl(120, 100%, 40%);">+ honorRefspec: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ shallow: true</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ userRemoteConfigs: [[url: testsuiteUrl]]</span><br><span style="color: hsl(120, 100%, 40%);">+ ]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo tests/CI/runTestsuite.sh --testsuite-dir='${groupDir}' --test-command='${groupTestcmd}'"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ artifacts: "${groupDir}/asterisk-test-suite-report.xml, ${groupDir}/logs/**, ${groupDir}/core*.txt"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ junit testResults: "${groupDir}/asterisk-test-suite-report.xml",</span><br><span style="color: hsl(120, 100%, 40%);">+ healthScaleFactor: 1.0,</span><br><span style="color: hsl(120, 100%, 40%);">+ keepLongStdio: true</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Group result d: ${currentBuild.currentResult}"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Group result s: ${currentBuild.currentResult}"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ parallel parallelTasks</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ post {</span><br><span style="color: hsl(120, 100%, 40%);">+ cleanup {</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo make distclean 2&>/dev/null || : "</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo rm -rf tests/CI/output 2&>/dev/null || : "</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ success {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Reporting ${currentBuild.currentResult} Passed"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ failure {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Reporting ${currentBuild.currentResult}: Failed: Fatal Error"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ unstable {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Reporting ${currentBuild.currentResult}: Failed: Tests Failed"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/tests/CI/runTestsuite.sh b/tests/CI/runTestsuite.sh</span><br><span>index 5c7a479..d295421 100755</span><br><span>--- a/tests/CI/runTestsuite.sh</span><br><span>+++ b/tests/CI/runTestsuite.sh</span><br><span>@@ -7,7 +7,8 @@</span><br><span> </span><br><span> ./cleanup-test-remnants.sh</span><br><span> export PYTHONPATH=./lib/python/</span><br><span style="color: hsl(0, 100%, 40%);">-runner ./runtests.py --cleanup ${TEST_COMMAND} | contrib/scripts/pretty_print --no-color --no-timer --term-width=120 --show-errors || :</span><br><span style="color: hsl(120, 100%, 40%);">+echo "Running tests ${TEST_COMMAND}"</span><br><span style="color: hsl(120, 100%, 40%);">+./runtests.py --cleanup ${TEST_COMMAND} | contrib/scripts/pretty_print --no-color --no-timer --term-width=120 --show-errors || :</span><br><span> </span><br><span> if [ -f core* ] ; then</span><br><span> echo "*** Found a core file after running unit tests ***"</span><br><span>diff --git a/tests/CI/runUnittests.sh b/tests/CI/runUnittests.sh</span><br><span>index e8a8f2c..19f96c4 100755</span><br><span>--- a/tests/CI/runUnittests.sh</span><br><span>+++ b/tests/CI/runUnittests.sh</span><br><span>@@ -50,16 +50,18 @@</span><br><span> </span><br><span> rm -rf $ASTETCDIR/extensions.{ael,lua} || :</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-runner sudo $ASTERISK ${USER_GROUP:+-U ${USER_GROUP%%:*} -G ${USER_GROUP##*:}} -gn -C $CONFFILE</span><br><span style="color: hsl(120, 100%, 40%);">+set -x</span><br><span style="color: hsl(120, 100%, 40%);">+sudo $ASTERISK ${USER_GROUP:+-U ${USER_GROUP%%:*} -G ${USER_GROUP##*:}} -gn -C $CONFFILE</span><br><span> sleep 3</span><br><span style="color: hsl(0, 100%, 40%);">-runner $ASTERISK -rx "core waitfullybooted" -C $CONFFILE</span><br><span style="color: hsl(120, 100%, 40%);">+$ASTERISK -rx "core waitfullybooted" -C $CONFFILE</span><br><span> sleep 1</span><br><span style="color: hsl(0, 100%, 40%);">-runner $ASTERISK -rx "${TEST_COMMAND:-test execute all}" -C $CONFFILE</span><br><span style="color: hsl(0, 100%, 40%);">-runner $ASTERISK -rx "test show results failed" -C $CONFFILE</span><br><span style="color: hsl(0, 100%, 40%);">-runner $ASTERISK -rx "test generate results xml $OUTPUTFILE" -C $CONFFILE</span><br><span style="color: hsl(0, 100%, 40%);">-runner $ASTERISK -rx "core stop now" -C $CONFFILE</span><br><span style="color: hsl(120, 100%, 40%);">+$ASTERISK -rx "${TEST_COMMAND:-test execute all}" -C $CONFFILE</span><br><span style="color: hsl(120, 100%, 40%);">+$ASTERISK -rx "test show results failed" -C $CONFFILE</span><br><span style="color: hsl(120, 100%, 40%);">+$ASTERISK -rx "test generate results xml $OUTPUTFILE" -C $CONFFILE</span><br><span style="color: hsl(120, 100%, 40%);">+$ASTERISK -rx "core stop now" -C $CONFFILE</span><br><span> </span><br><span> runner rsync -vaH $DESTDIR/var/log/asterisk/. $OUTPUTDIR</span><br><span style="color: hsl(120, 100%, 40%);">+set +x</span><br><span> </span><br><span> [ x"$USER_GROUP" != x ] && sudo chown -R $USER_GROUP $OUTPUTDIR</span><br><span> if [ -f core* ] ; then</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9431">change 9431</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/9431"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I26933e73928e091ae72e838c02f4f2ec7c3983d6 </div>
<div style="display:none"> Gerrit-Change-Number: 9431 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>