[Asterisk-code-review] CI: Add PQ Stress jenkinsfile and update to get conf from environment (asterisk[16])

George Joseph asteriskteam at digium.com
Fri Feb 7 09:33:18 CST 2020


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13733 )


Change subject: CI: Add PQ Stress jenkinsfile and update to get conf from environment
......................................................................

CI: Add PQ Stress jenkinsfile and update to get conf from environment

Change-Id: I54a80ad59b80f5e1e10e291cc2ae0b2c2a5b30d4
---
M tests/CI/pq.jenkinsfile
A tests/CI/pq_stress.jenkinsfile
2 files changed, 176 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/33/13733/1

diff --git a/tests/CI/pq.jenkinsfile b/tests/CI/pq.jenkinsfile
index 9f45817..61ad5dd 100644
--- a/tests/CI/pq.jenkinsfile
+++ b/tests/CI/pq.jenkinsfile
@@ -70,7 +70,7 @@
 					}
 
 					def testGroups
-					configFileProvider([configFile(fileId: 'asterisk_pq_tests', variable: 'PQ_TESTS')]) {
+					configFileProvider([configFile(fileId: env.PQ_GATE_TESTS_CONFIG, variable: 'PQ_TESTS')]) {
 					echo "Retrieved config file from ${env.PQ_TESTS}"
 						testGroups = readJSON file: env.PQ_TESTS
 					}
diff --git a/tests/CI/pq_stress.jenkinsfile b/tests/CI/pq_stress.jenkinsfile
new file mode 100644
index 0000000..cecc62b
--- /dev/null
+++ b/tests/CI/pq_stress.jenkinsfile
@@ -0,0 +1,175 @@
+/*
+ * This pipeline is the "template" for running the internal private testsuite
+ * tests against Asterisk.
+ *
+ * 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.
+ */
+def timeoutTime = 3
+def timeoutUnits = 'HOURS'
+if (env.TIMEOUT_STRESS) {
+	def _timeout = env.TIMEOUT_STRESS.split()
+	timeoutTime = _timeout[0].toInteger()
+	timeoutUnits = _timeout[1]
+}
+
+pipeline {
+	options {
+		timestamps()
+		timeout(time: timeoutTime, unit: timeoutUnits)
+	}
+
+	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 {
+					manager.createSummary("/plugin/workflow-job/images/48x48/pipelinejob.png").appendText("Docker Host: ${NODE_NAME}", false)
+
+					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 = "--privileged --ulimit core=0 --ulimit nofile=10240 " +
+						" --tmpfs /tmp:exec,size=1G -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/asterisk"
+
+					manager.createSummary("/plugin/workflow-job/images/48x48/pipelinejob.png").appendText("Docker Image: ${randomImage}", false)
+					def img = docker.image(randomImage)
+					img.pull()
+
+					img.inside(dockerOptions + " --name ${bt}-build") {
+						stage ("Build") {
+							echo 'Building..'
+							env.CCACHE_DIR = "/srv/cache/ccache"
+							sh "./tests/CI/buildAsterisk.sh --branch-name=${BRANCH_NAME} --output-dir=${outputdir} --cache-dir=/srv/cache"
+
+							archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,
+								artifacts: "${outputdir}/*"
+						}
+						stage ("Install") {
+							echo 'Installing..'
+							sh "sudo ./tests/CI/installAsterisk.sh --branch-name=${BRANCH_NAME}  --user-group=jenkins:users"
+						}
+					}
+
+					def stressTests
+					configFileProvider([configFile(fileId: env.PQ_STRESS_TESTS_CONFIG, variable: 'PQ_STRESS_TESTS')]) {
+					echo "Retrieved config file from ${env.PQ_STRESS_TEST}"
+						stressTests = readJSON file: env.PQ_STRESS_TESTS
+					}
+
+					for (def stressTest in stressTests) {
+
+						def testGroups
+						configFileProvider([configFile(fileId: stressTest, variable: 'PQ_STRESS_TEST')]) {
+						echo "Retrieved config file from ${env.PQ_STRESS_TEST}"
+							 testGroups = readJSON file: env.PQ_STRESS_TEST
+						}
+
+						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 groupRunTestsuiteOptions = testGroup.runTestsuiteOptions
+							def testsuiteUrl = "http://gerrit.asterisk.org/testsuite"
+							def privateTestsuiteUrl = "http://gerrit.digium.internal/r/private-testsuite-tests"
+
+							parallelTasks[groupName] = {
+								stage (groupName) {
+
+									img.inside("${dockerOptions} --name ${bt}-${groupName}") {
+
+										lock("${JOB_NAME}.${NODE_NAME}.installer") {
+											sh "sudo ./tests/CI/installAsterisk.sh --uninstall-all --branch-name=${BRANCH_NAME} --user-group=jenkins:users"
+										}
+
+										sh "sudo rm -rf ${groupDir} || : "
+
+										checkout scm: [$class: 'GitSCM',
+											branches: [[name: "master"]],
+											extensions: [
+												[$class: 'RelativeTargetDirectory', relativeTargetDir: groupDir],
+												[$class: 'CloneOption',
+													noTags: true,
+													depth: 10,
+													honorRefspec: true,
+													shallow: true
+												],
+											],
+											userRemoteConfigs: [[url: testsuiteUrl]]
+										]
+
+										checkout scm: [$class: 'GitSCM',
+										branches: [[name: 'master']],
+											extensions: [
+												[$class: 'RelativeTargetDirectory', relativeTargetDir: "${groupDir}/tests/custom"],
+												[$class: 'CloneOption',
+													noTags: true,
+													depth: 10,
+													honorRefspec: true,
+													shallow: true
+												],
+											],
+											userRemoteConfigs: [[url: privateTestsuiteUrl]]
+										]
+
+										sh "sudo tests/CI/runTestsuite.sh ${groupRunTestsuiteOptions} --testsuite-dir='${groupDir}' --testsuite-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 >/dev/null 2>&1 || : "
+			sh "sudo rm -rf tests/CI/output >/dev/null 2>&1 || : "
+		}
+		success {
+			echo "Reporting ${currentBuild.currentResult} Passed"
+		}
+		failure {
+			echo "Reporting ${currentBuild.currentResult}: Failed: Fatal Error"
+		}
+		unstable {
+			echo "Reporting ${currentBuild.currentResult}: Failed: Tests Failed"
+		}
+	}
+}

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13733
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I54a80ad59b80f5e1e10e291cc2ae0b2c2a5b30d4
Gerrit-Change-Number: 13733
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200207/39a67f33/attachment-0001.html>


More information about the asterisk-code-review mailing list