]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
CI: Add weekly REF_DEBUG testsuite run
authorGeorge Joseph <gjoseph@digium.com>
Mon, 16 Jul 2018 14:13:40 +0000 (08:13 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Mon, 16 Jul 2018 15:56:06 +0000 (09:56 -0600)
Change-Id: I5b581d0a0d1d1bb9b38961d40b112fb448355037

tests/CI/buildAsterisk.sh
tests/CI/ref_debug.jenkinsfile [new file with mode: 0644]
tests/CI/ref_debugTestGroups.json [new file with mode: 0644]

index 85f347cc64738a44650131dd584e077f770a275f..9840d859e5a7d25b0c3310893966a4ed157bdbdd 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/env bash
 
 CIDIR=$(dirname $(readlink -fn $0))
+REF_DEBUG=0
 source $CIDIR/ci.functions
 
 gen_cats() {
@@ -70,6 +71,9 @@ runner ${MAKE} menuselect.makeopts
 
 runner menuselect/menuselect `gen_mods enable DONT_OPTIMIZE BETTER_BACKTRACES MALLOC_DEBUG DO_CRASH TEST_FRAMEWORK` menuselect.makeopts
 runner menuselect/menuselect `gen_mods disable COMPILE_DOUBLE BUILD_NATIVE` menuselect.makeopts
+if [ $REF_DEBUG -eq 1 ] ; then
+       runner menuselect/menuselect --enable REF_DEBUG menuselect.makeopts
+fi
 
 cat_enables="MENUSELECT_BRIDGES MENUSELECT_CEL MENUSELECT_CDR"
 cat_enables+=" MENUSELECT_CHANNELS MENUSELECT_CODECS MENUSELECT_FORMATS MENUSELECT_FUNCS"
diff --git a/tests/CI/ref_debug.jenkinsfile b/tests/CI/ref_debug.jenkinsfile
new file mode 100644 (file)
index 0000000..45a1c6a
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * This pipeline is the "template" for the Asterisk REF_DEBUG Tests multi-branch
+ * parent job.  Jenkins will automatically scan the branches in the "asterisk"
+ * or "Security-asterisk" projects in Gerrit and automatically create a branch-
+ * specific job for each branch it finds this file in.
+ *
+ * This file starts as a declarative pipeline because with a declarative
+ * pipeline, you can define the trigger in the pipeline file.  This keeps
+ * everything in one place.  We transition to scripted pipeline later on because
+ * we need to dynamically determine which docker image we're going to use and
+ * you can't do that in a delcarative pipeline.
+ */
+pipeline {
+       triggers {
+               cron 'H H(0-4) * * 0'
+       }
+       
+       agent {
+               /* All of the stages need to be performed on a docker host */
+               label "swdev-docker"
+       }
+
+       stages {
+               stage ("->") {
+                       steps {
+                               /* Here's where we switch to scripted pipeline */
+                               script {
+                                       stage ("Checkout") {
+                                               sh "sudo chown -R jenkins:users ."  
+                                               sh "printenv | sort"
+                                               sh "sudo tests/CI/setupJenkinsEnvironment.sh"
+                                       }
+
+                                       def images = env.DOCKER_IMAGES.split(' ')
+                                       def r = currentBuild.startTimeInMillis % images.length
+                                       def ri = images[(int)r]
+                                       def randomImage = env.DOCKER_REGISTRY + "/" + ri
+                                       def dockerOptions = "--ulimit core=0 --ulimit nofile=10240 " +
+                                               " -v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw " +
+                                               " --entrypoint=''"
+                                       def bt = env.BUILD_TAG.replaceAll(/[^a-zA-Z0-9_.-]/, '-')
+                                       def outputdir = "tests/CI/output/Testsuite"
+                                       def img = docker.image(randomImage)
+                                       img.pull()
+
+                                       stage ("Build") {
+                                               img.inside(dockerOptions + " --name ${bt}-build") {
+                                                       echo 'Building..'
+                                                       env.CCACHE_DIR = "/srv/cache/ccache"
+                                                       sh "./tests/CI/buildAsterisk.sh --ref-debug --output-dir=${outputdir} --cache-dir=/srv/cache"
+
+                                                       archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,
+                                                               artifacts: "${outputdir}/*"
+                                               }
+                                       }
+
+                                       def testGroups = readJSON file: "tests/CI/ref_debugTestGroups.json"
+                                       def parallelTasks = [ : ]
+
+                                       for (def testGroup in testGroups) {
+                                               /*
+                                                * Because each task is a Groovy closure, we need to
+                                                * keep local references to some variables.
+                                                */
+                                               def groupName = testGroup.name
+                                               def groupDir = testGroup.dir
+                                               def groupTestcmd = testGroup.testcmd
+                                               def testsuiteUrl = env.GIT_URL.replaceAll(/\/[^\/]+$/, "/\$1testsuite")
+
+                                               parallelTasks[groupName] = {
+                                                       stage (groupName) {
+
+                                                               img.inside("${dockerOptions} --name ${bt}-${groupName}") {
+
+                                                                       lock("${JOB_NAME}.${NODE_NAME}.installer") {
+                                                                               sh 'sudo ./tests/CI/installAsterisk.sh  --user-group=jenkins:users'
+                                                                       }
+
+                                                                       sh "sudo rm -rf ${groupDir} || : "
+                                                                       
+                                                                       checkout scm: [$class: 'GitSCM',
+                                                                               branches: [[name: "${BRANCH_NAME}"]],
+                                                                                       extensions: [
+                                                                                               [$class: 'RelativeTargetDirectory', relativeTargetDir: groupDir],
+                                                                                               [$class: 'CloneOption',
+                                                                                                       noTags: true,
+                                                                                                       depth: 10,
+                                                                                                       honorRefspec: true,
+                                                                                                       shallow: true
+                                                                                               ],
+                                                                                       ],
+                                                                                       userRemoteConfigs: [[url: testsuiteUrl]]
+                                                                               ]
+
+                                                                       sh "sudo tests/CI/runTestsuite.sh --testsuite-dir='${groupDir}' --test-command='${groupTestcmd}'"
+
+                                                                       archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: true,
+                                                                               artifacts: "${groupDir}/asterisk-test-suite-report.xml, ${groupDir}/logs/**, ${groupDir}/core*.txt"
+
+                                                                       junit testResults: "${groupDir}/asterisk-test-suite-report.xml",
+                                                                               healthScaleFactor: 1.0,
+                                                                               keepLongStdio: true
+                                                               }
+                                                       }
+                                               }
+                                       }
+                                       parallel parallelTasks
+                               }
+                       }
+               }
+       }
+       post {
+               cleanup {
+                       sh "sudo make distclean 2&>/dev/null || : "
+                       sh "sudo rm -rf tests/CI/output  2&>/dev/null || : "
+               }
+               success {
+                       echo "Reporting ${currentBuild.currentResult} Passed"
+               }
+               failure {
+                       echo "Reporting ${currentBuild.currentResult}: Failed: Fatal Error"
+               }
+               unstable {
+                       echo "Reporting ${currentBuild.currentResult}: Failed: Tests Failed"
+               }
+       }
+}
diff --git a/tests/CI/ref_debugTestGroups.json b/tests/CI/ref_debugTestGroups.json
new file mode 100644 (file)
index 0000000..b8c8e9b
--- /dev/null
@@ -0,0 +1,32 @@
+[
+       {
+               "name": "ari ",
+               "dir": "tests/CI/output/ari",
+               "testcmd": "-t tests/rest_api/"
+       },
+       {
+               "name": "pjs ",
+               "dir": "tests/CI/output/pjsip",
+               "testcmd": "-t tests/channels/pjsip"
+       },
+       {
+               "name": "sip ",
+               "dir": "tests/CI/output/sip",
+               "testcmd": "-t tests/channels/SIP"
+       },
+       {
+               "name": "iax ",
+               "dir": "tests/CI/output/iax2_local",
+               "testcmd": " -t tests/channels/iax2 -t tests/channels/local"
+       },
+       {
+               "name": "apps",
+               "dir": "tests/CI/output/agi-apps",
+               "testcmd": " -t tests/agi -t tests/apps -t blind-transfer-parkingtimeout"
+       },
+       {
+               "name": "othr",
+               "dir": "tests/CI/output/other",
+               "testcmd": " -T tests/(apps|agi|blind-transfer-parkingtimeout|rest_api|channels|realtime|example|skeleton_test|remote-test)"
+       }
+]