mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-18 18:58:22 +00:00
CI: Add daily periodics to CI
Change-Id: I26933e73928e091ae72e838c02f4f2ec7c3983d6
This commit is contained in:
@@ -21,6 +21,6 @@ for a in "$@" ; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
runner() {
|
runner() {
|
||||||
( set -x ; "$@" )
|
( set -x ; ${@} )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -134,13 +134,12 @@ pipeline {
|
|||||||
def groupName = testGroup.name
|
def groupName = testGroup.name
|
||||||
def groupDir = testGroup.dir
|
def groupDir = testGroup.dir
|
||||||
def groupTestcmd = testGroup.testcmd
|
def groupTestcmd = testGroup.testcmd
|
||||||
def testsuiteUrl = env.GERRIT_PROJECT_URL.replaceAll(/${GERRIT_PROJECT}$/, "testsuite")
|
def testsuiteUrl = env.GERRIT_PROJECT_URL.replaceAll(/\/(Security-)?[^\/]+$/, "/\$1testsuite")
|
||||||
|
|
||||||
parallelTasks[groupName] = {
|
parallelTasks[groupName] = {
|
||||||
stage (groupName) {
|
stage (groupName) {
|
||||||
|
|
||||||
img.inside("${dockerOptions} --name ${BUILD_TAG}-${groupName}") {
|
img.inside("${dockerOptions} --name ${BUILD_TAG}-${groupName}") {
|
||||||
sh "printenv | sort"
|
|
||||||
|
|
||||||
lock("${JOB_NAME}.${NODE_NAME}.installer") {
|
lock("${JOB_NAME}.${NODE_NAME}.installer") {
|
||||||
sh 'sudo ./tests/CI/installAsterisk.sh --user-group=jenkins:users'
|
sh 'sudo ./tests/CI/installAsterisk.sh --user-group=jenkins:users'
|
||||||
|
32
tests/CI/periodic-dailyTestGroups.json
Normal file
32
tests/CI/periodic-dailyTestGroups.json
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "ari ",
|
||||||
|
"dir": "tests/CI/output/ari",
|
||||||
|
"testcmd": "-t tests/rest_api/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pjsip ",
|
||||||
|
"dir": "tests/CI/output/pjsip",
|
||||||
|
"testcmd": "-t tests/channels/pjsip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sip ",
|
||||||
|
"dir": "tests/CI/output/sip",
|
||||||
|
"testcmd": "-t tests/channels/SIP"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "iax2_locl",
|
||||||
|
"dir": "tests/CI/output/iax2_local",
|
||||||
|
"testcmd": " -t tests/channels/iax2 -t tests/channels/local"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "agi-apps ",
|
||||||
|
"dir": "tests/CI/output/agi-apps",
|
||||||
|
"testcmd": " -t tests/agi -t tests/apps -t blind-transfer-parkingtimeout"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "other ",
|
||||||
|
"dir": "tests/CI/output/other",
|
||||||
|
"testcmd": " -T tests/(apps|agi|blind-transfer-parkingtimeout|rest_api|channels|realtime|example|skeleton_test|remote-test)"
|
||||||
|
}
|
||||||
|
]
|
129
tests/CI/periodics-daily.jenkinsfile
Normal file
129
tests/CI/periodics-daily.jenkinsfile
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* This pipeline is the "template" for the Asterisk Periodic 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) * * *'
|
||||||
|
}
|
||||||
|
|
||||||
|
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 outputdir = "tests/CI/output/Testsuite"
|
||||||
|
def img = docker.image(randomImage)
|
||||||
|
img.pull()
|
||||||
|
|
||||||
|
stage ("Build") {
|
||||||
|
img.inside(dockerOptions + " --name ${BUILD_TAG}-build") {
|
||||||
|
echo 'Building..'
|
||||||
|
env.CCACHE_DIR = "/srv/cache/ccache"
|
||||||
|
sh "./tests/CI/buildAsterisk.sh --output-dir=${outputdir} --cache-dir=/srv/cache"
|
||||||
|
|
||||||
|
archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,
|
||||||
|
artifacts: "${outputdir}/*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def testGroups = readJSON file: "tests/CI/periodic-dailyTestGroups.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(/\/(Security-)?[^\/]+$/, "/\$1testsuite")
|
||||||
|
|
||||||
|
parallelTasks[groupName] = {
|
||||||
|
stage (groupName) {
|
||||||
|
|
||||||
|
img.inside("${dockerOptions} --name ${BUILD_TAG}-${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
|
||||||
|
|
||||||
|
echo "Group result d: ${currentBuild.currentResult}"
|
||||||
|
}
|
||||||
|
echo "Group result s: ${currentBuild.currentResult}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -7,7 +7,8 @@ pushd $TESTSUITE_DIR
|
|||||||
|
|
||||||
./cleanup-test-remnants.sh
|
./cleanup-test-remnants.sh
|
||||||
export PYTHONPATH=./lib/python/
|
export PYTHONPATH=./lib/python/
|
||||||
runner ./runtests.py --cleanup ${TEST_COMMAND} | contrib/scripts/pretty_print --no-color --no-timer --term-width=120 --show-errors || :
|
echo "Running tests ${TEST_COMMAND}"
|
||||||
|
./runtests.py --cleanup ${TEST_COMMAND} | contrib/scripts/pretty_print --no-color --no-timer --term-width=120 --show-errors || :
|
||||||
|
|
||||||
if [ -f core* ] ; then
|
if [ -f core* ] ; then
|
||||||
echo "*** Found a core file after running unit tests ***"
|
echo "*** Found a core file after running unit tests ***"
|
||||||
|
@@ -50,16 +50,18 @@ OUTPUTFILE=${OUTPUT_XML:-${OUTPUTDIR}/unittests-results.xml}
|
|||||||
|
|
||||||
rm -rf $ASTETCDIR/extensions.{ael,lua} || :
|
rm -rf $ASTETCDIR/extensions.{ael,lua} || :
|
||||||
|
|
||||||
runner sudo $ASTERISK ${USER_GROUP:+-U ${USER_GROUP%%:*} -G ${USER_GROUP##*:}} -gn -C $CONFFILE
|
set -x
|
||||||
|
sudo $ASTERISK ${USER_GROUP:+-U ${USER_GROUP%%:*} -G ${USER_GROUP##*:}} -gn -C $CONFFILE
|
||||||
sleep 3
|
sleep 3
|
||||||
runner $ASTERISK -rx "core waitfullybooted" -C $CONFFILE
|
$ASTERISK -rx "core waitfullybooted" -C $CONFFILE
|
||||||
sleep 1
|
sleep 1
|
||||||
runner $ASTERISK -rx "${TEST_COMMAND:-test execute all}" -C $CONFFILE
|
$ASTERISK -rx "${TEST_COMMAND:-test execute all}" -C $CONFFILE
|
||||||
runner $ASTERISK -rx "test show results failed" -C $CONFFILE
|
$ASTERISK -rx "test show results failed" -C $CONFFILE
|
||||||
runner $ASTERISK -rx "test generate results xml $OUTPUTFILE" -C $CONFFILE
|
$ASTERISK -rx "test generate results xml $OUTPUTFILE" -C $CONFFILE
|
||||||
runner $ASTERISK -rx "core stop now" -C $CONFFILE
|
$ASTERISK -rx "core stop now" -C $CONFFILE
|
||||||
|
|
||||||
runner rsync -vaH $DESTDIR/var/log/asterisk/. $OUTPUTDIR
|
runner rsync -vaH $DESTDIR/var/log/asterisk/. $OUTPUTDIR
|
||||||
|
set +x
|
||||||
|
|
||||||
[ x"$USER_GROUP" != x ] && sudo chown -R $USER_GROUP $OUTPUTDIR
|
[ x"$USER_GROUP" != x ] && sudo chown -R $USER_GROUP $OUTPUTDIR
|
||||||
if [ -f core* ] ; then
|
if [ -f core* ] ; then
|
||||||
|
Reference in New Issue
Block a user