Skip to content

Commit 0682a76

Browse files
authored
Merge pull request #37 from arangodb/parallel-tests
Run tests on multiple clusters in parallel
2 parents 6c3688a + 29a69e9 commit 0682a76

File tree

1 file changed

+52
-21
lines changed

1 file changed

+52
-21
lines changed

Jenkinsfile.groovy

+52-21
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,50 @@ def notifySlack(String buildStatus = 'STARTED') {
1919
slackSend(color: color, channel: '#status-k8s', message: msg)
2020
}
2121

22+
def kubeConfigRoot = "/home/jenkins/.kube"
23+
24+
def buildTestSteps(String kubeConfigRoot, String kubeconfig) {
25+
return {
26+
timestamps {
27+
lock("${kubeconfig}-${params.TESTNAMESPACE}-${env.GIT_COMMIT}") {
28+
withCredentials([string(credentialsId: 'ENTERPRISEIMAGE', variable: 'DEFAULTENTERPRISEIMAGE')]) {
29+
withEnv([
30+
"ENTERPRISEIMAGE=${params.ENTERPRISEIMAGE}",
31+
"IMAGETAG=${env.GIT_COMMIT}",
32+
"KUBECONFIG=${kubeConfigRoot}/${kubeconfig}",
33+
"LONG=${params.LONG ? 1 : 0}",
34+
"PUSHIMAGES=1",
35+
"TESTNAMESPACE=${params.TESTNAMESPACE}-${env.GIT_COMMIT}",
36+
]) {
37+
sh "make run-tests"
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
45+
def buildCleanupSteps(String kubeConfigRoot, String kubeconfig) {
46+
return {
47+
timestamps {
48+
withEnv([
49+
"KUBECONFIG=${kubeConfigRoot}/${kubeconfig}",
50+
"TESTNAMESPACE=${params.TESTNAMESPACE}-${env.GIT_COMMIT}",
51+
]) {
52+
sh "make cleanup-tests"
53+
}
54+
}
55+
}
56+
}
57+
2258
pipeline {
2359
options {
2460
buildDiscarder(logRotator(daysToKeepStr: '7', numToKeepStr: '10'))
2561
}
2662
agent any
2763
parameters {
2864
booleanParam(name: 'LONG', defaultValue: false, description: 'Execute long running tests')
29-
string(name: 'KUBECONFIG', defaultValue: '/home/jenkins/.kube/scw-183a3b', description: 'KUBECONFIG controls which k8s cluster is used', )
65+
string(name: 'KUBECONFIGS', defaultValue: 'scw-183a3b,c11', description: 'KUBECONFIGS is a comma separated list of Kubernetes configuration files (relative to /home/jenkins/.kube) on which the tests are run', )
3066
string(name: 'TESTNAMESPACE', defaultValue: 'jenkins', description: 'TESTNAMESPACE sets the kubernetes namespace to ru tests in (this must be short!!)', )
3167
string(name: 'ENTERPRISEIMAGE', defaultValue: '', description: 'ENTERPRISEIMAGE sets the docker image used for enterprise tests)', )
3268
}
@@ -36,44 +72,39 @@ pipeline {
3672
timestamps {
3773
withEnv([
3874
"IMAGETAG=${env.GIT_COMMIT}",
75+
"LONG=${params.LONG ? 1 : 0}",
76+
"PUSHIMAGES=1",
3977
]) {
4078
sh "make"
4179
sh "make run-unit-tests"
80+
sh "make docker-test"
4281
}
4382
}
4483
}
4584
}
4685
stage('Test') {
4786
steps {
48-
timestamps {
49-
lock("${params.TESTNAMESPACE}-${env.GIT_COMMIT}") {
50-
withCredentials([string(credentialsId: 'ENTERPRISEIMAGE', variable: 'DEFAULTENTERPRISEIMAGE')]) {
51-
withEnv([
52-
"ENTERPRISEIMAGE=${params.ENTERPRISEIMAGE}",
53-
"IMAGETAG=${env.GIT_COMMIT}",
54-
"KUBECONFIG=${params.KUBECONFIG}",
55-
"LONG=${params.LONG ? 1 : 0}",
56-
"PUSHIMAGES=1",
57-
"TESTNAMESPACE=${params.TESTNAMESPACE}-${env.GIT_COMMIT}",
58-
]) {
59-
sh "make run-tests"
60-
}
61-
}
87+
script {
88+
def configs = "${params.KUBECONFIGS}".split(",")
89+
def testTasks = [:]
90+
for (kubeconfig in configs) {
91+
testTasks["${kubeconfig}"] = buildTestSteps(kubeConfigRoot, kubeconfig)
6292
}
93+
parallel testTasks
6394
}
6495
}
6596
}
6697
}
6798

6899
post {
69100
always {
70-
timestamps {
71-
withEnv([
72-
"KUBECONFIG=${params.KUBECONFIG}",
73-
"TESTNAMESPACE=${params.TESTNAMESPACE}-${env.GIT_COMMIT}",
74-
]) {
75-
sh "make cleanup-tests"
101+
script {
102+
def configs = "${params.KUBECONFIGS}".split(",")
103+
def cleanupTasks = [:]
104+
for (kubeconfig in configs) {
105+
cleanupTasks["${kubeconfig}"] = buildCleanupSteps(kubeConfigRoot, kubeconfig)
76106
}
107+
parallel cleanupTasks
77108
}
78109
}
79110
failure {

0 commit comments

Comments
 (0)