blob: fc4b661da4d5fc9666559bc68c0d2d22ee989b6c [file] [log] [blame]
Joey Armstrong8c6f6482023-01-12 12:31:44 -05001// Copyright 2021-2023 Open Networking Foundation (ONF) and the ONF Contributors
Matteo Scandolo42f6e572021-01-25 15:11:34 -08002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Hardik Windlassec9341b2021-06-07 11:58:29 +000015// voltha-2.x e2e tests for openonu-go
Matteo Scandolo42f6e572021-01-25 15:11:34 -080016// uses bbsim to simulate OLT/ONUs
17
Joey Armstronge5aae1c2023-07-24 14:11:20 -040018// [TODO] Update syntax below to the latest supported
Matteo Scandoloa156b572021-02-04 11:52:18 -080019library identifier: 'cord-jenkins-libraries@master',
20 retriever: modernSCM([
21 $class: 'GitSCMSource',
22 remote: 'https://gerrit.opencord.org/ci-management.git'
23])
24
Joey Armstronge5aae1c2023-07-24 14:11:20 -040025//------------------//
26//---] GLOBAL [---//
27//------------------//
Hardik Windlassec9341b2021-06-07 11:58:29 +000028def clusterName = "kind-ci"
Joey Armstronge5aae1c2023-07-24 14:11:20 -040029String branch_name = 'master'
Hardik Windlassec9341b2021-06-07 11:58:29 +000030
Joey Armstronge5aae1c2023-07-24 14:11:20 -040031// -----------------------------------------------------------------------
Joey Armstrong06a68372023-07-24 16:37:16 -040032// Intent: Due to lack of a reliable stack trace, construct a literal.
33// Jenkins will re-write the call stack for serialization.
34// -----------------------------------------------------------------------
35def getIam(String func)
36{
37 String src = [
38 'ci-management',
39 'jjb',
40 'pipeline',
41 'voltha',
42 branch_name,
43 'bbsim-tests.groovy'
44 ].join('/')
45
46 String iam = [src, func].join('::')
47 return iam
48}
49
50// -----------------------------------------------------------------------
Joey Armstronge5aae1c2023-07-24 14:11:20 -040051// Intent: Determine if working on a release branch.
52// Note: Conditional is legacy, should also check for *-dev or *-pre
53// -----------------------------------------------------------------------
54Boolean isReleaseBranch(String name)
55{
56 // List modifiers = ['-dev', '-pre', 'voltha-x.y.z-pre']
57 // if branch_name in modifiers
58 return(name != 'master') // OR branch_name.contains('-')
59}
60
61// -----------------------------------------------------------------------
Joey Armstrong06a68372023-07-24 16:37:16 -040062// Intent: Phase helper method
63// -----------------------------------------------------------------------
Joey Armstrong53cebea2023-07-26 10:35:53 -040064Boolean install_kind(String name)
Joey Armstrong06a68372023-07-24 16:37:16 -040065{
66 String iam = getIam('installKind')
67 Boolean ans = False
68
69 println("** ${iam}: ENTER")
70 try
71 {
72 println("** ${iam} Running: installKind() { debug:true }"
Joey Armstrong53cebea2023-07-26 10:35:53 -040073 installKind(name)
Joey Armstrong06a68372023-07-24 16:37:16 -040074 println("** ${iam}: Ran to completion")
75 ans = True // iff
76 }
77 catch (Exception err)
78 {
79 ans = False
80 println("** ${iam}: EXCEPTION ${err}")
81 throw err
82 }
83 finally
84 {
85 println("** ${iam}: ENTER")
86 }
Joey Armstrong53cebea2023-07-26 10:35:53 -040087
Joey Armstrong06a68372023-07-24 16:37:16 -040088 return(ans)
89}
90
91// -----------------------------------------------------------------------
Joey Armstronge5aae1c2023-07-24 14:11:20 -040092// Intent:
93// -----------------------------------------------------------------------
Joey Armstrong2d5a7c12023-04-13 09:37:42 -040094def execute_test(testTarget, workflow, testLogging, teardown, testSpecificHelmFlags = "")
95{
Joey Armstrong8c6f6482023-01-12 12:31:44 -050096 def infraNamespace = "default"
97 def volthaNamespace = "voltha"
98 def logsDir = "$WORKSPACE/${testTarget}"
Joey Armstrong293e16b2022-11-26 20:16:33 -050099
100 stage('IAM')
101 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400102 script
103 {
Joey Armstrong06a68372023-07-24 16:37:16 -0400104 // Announce ourselves for log usability
105 String iam = getIam('execute_test')
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400106 println("${iam}: ENTER")
107 println("${iam}: LEAVE")
Joey Armstrong84adc542023-04-11 14:47:34 -0400108 }
Joey Armstrong293e16b2022-11-26 20:16:33 -0500109 }
110
111 stage('Cleanup') {
Joey Armstrong84adc542023-04-11 14:47:34 -0400112 if (teardown) {
113 timeout(15) {
114 script {
115 helmTeardown(["default", infraNamespace, volthaNamespace])
116 }
117 timeout(1) {
118 sh returnStdout: false, script: '''
Hardik Windlassec9341b2021-06-07 11:58:29 +0000119 # remove orphaned port-forward from different namespaces
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400120 ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9
Hardik Windlassec9341b2021-06-07 11:58:29 +0000121 '''
Joey Armstrong84adc542023-04-11 14:47:34 -0400122 }
123 }
124 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000125 }
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500126
Joey Armstrong53cebea2023-07-26 10:35:53 -0400127 stage ('Install Kail')
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500128 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400129 // VOL-4926 - Is voltha-system-tests available ?
130 String cmd = [
131 'make',
132 '-C', "$WORKSPACE/voltha-system-tests",
133 "KAIL_PATH=\"$WORKSPACE/bin\"",
134 'kail',
135 ].join(' ')
136 println(" ** Running: ${cmd}:\n")
Joey Armstrongbeef4cd2023-01-18 09:59:58 -0500137 sh("${cmd}")
Joey Armstrong53cebea2023-07-26 10:35:53 -0400138 // if (! my_install_kail())
Joey Armstrong06a68372023-07-24 16:37:16 -0400139 // throw new Exception('installKail() failed')
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500140 }
141
Joey Armstrong53cebea2023-07-26 10:35:53 -0400142 stage ('Install Kind')
143 {
144 steps
145 {
146 install_kind(branch_name)
147 }
148 }
Joey Armstrong06a68372023-07-24 16:37:16 -0400149
Joey Armstrong06a68372023-07-24 16:37:16 -0400150 stage('Deploy common infrastructure')
151 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400152 sh '''
Hardik Windlasse1660492022-03-14 15:12:46 +0000153 helm repo add onf https://charts.opencord.org
154 helm repo update
155 if [ ${withMonitoring} = true ] ; then
156 helm install nem-monitoring onf/nem-monitoring \
157 --set prometheus.alertmanager.enabled=false,prometheus.pushgateway.enabled=false \
158 --set kpi_exporter.enabled=false,dashboards.xos=false,dashboards.onos=false,dashboards.aaa=false,dashboards.voltha=false
159 fi
160 '''
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500161 }
162
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400163 stage('Deploy Voltha')
164 {
165 if (teardown)
166 {
167 timeout(10)
168 {
169 script
170 {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000171 sh """
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700172 mkdir -p ${logsDir}
173 _TAG=kail-startup kail -n ${infraNamespace} -n ${volthaNamespace} > ${logsDir}/onos-voltha-startup-combined.log &
Hardik Windlassec9341b2021-06-07 11:58:29 +0000174 """
175
176 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
177 def localCharts = false
Joey Armstrong53cebea2023-07-26 10:35:53 -0400178
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400179 if (volthaHelmChartsChange != ""
180 || gerritProject == "voltha-helm-charts"
181 || isReleaseBranch(branch) // branch != 'master'
182 ) {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000183 localCharts = true
184 }
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400185 Boolean is_release = isReleaseBranch(branch)
186 println(" ** localCharts=${localCharts}, branch_name=${branch_name}, isReleaseBranch=${is_release}")
Hardik Windlassec9341b2021-06-07 11:58:29 +0000187
188 // NOTE temporary workaround expose ONOS node ports
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400189 def localHelmFlags = extraHelmFlags.trim()
190 + " --set global.log_level=${logLevel.toUpperCase()} "
191 + " --set onos-classic.onosSshPort=30115 "
192 + " --set onos-classic.onosApiPort=30120 "
193 + " --set onos-classic.onosOfPort=31653 "
194 + " --set onos-classic.individualOpenFlowNodePorts=true "
195 + testSpecificHelmFlags
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800196
Hardik Windlassec9341b2021-06-07 11:58:29 +0000197 if (gerritProject != "") {
198 localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}")
199 }
200
201 volthaDeploy([
202 infraNamespace: infraNamespace,
203 volthaNamespace: volthaNamespace,
204 workflow: workflow.toLowerCase(),
Hardik Windlass2b164342022-02-28 03:50:48 +0000205 withMacLearning: enableMacLearning.toBoolean(),
Hardik Windlassec9341b2021-06-07 11:58:29 +0000206 extraHelmFlags: localHelmFlags,
207 localCharts: localCharts,
208 bbsimReplica: olts.toInteger(),
209 dockerRegistry: registry,
210 ])
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700211 }
Matteo Scandolofcfc60d2021-02-24 09:06:48 -0800212
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400213 // -----------------------------------------------------------------------
214 // Intent: Replacing P_IDS with pgrep/pkill is a step forward.
215 // Why not simply use a pid file, capture _TAG=kail-startup above
216 // Grep runs the risk of terminating stray commands (??-good <=> bad-??)
217 // -----------------------------------------------------------------------
218 println('Try out the pgrep/pkill commands')
219 def stream = sh(
220 returnStatus:false,
221 returnStdout:true,
222 script: '''pgrep --list-full kail-startup || true'''
223 )
224 println("** pgrep output: ${stream}")
225
226 // -----------------------------------------------------------------------
227 // stop logging
228 // -----------------------------------------------------------------------
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700229 sh """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000230 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')"
231 if [ -n "\$P_IDS" ]; then
232 echo \$P_IDS
233 for P_ID in \$P_IDS; do
234 kill -9 \$P_ID
235 done
236 fi
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700237 cd ${logsDir}
Hardik Windlassec9341b2021-06-07 11:58:29 +0000238 gzip -k onos-voltha-startup-combined.log
239 rm onos-voltha-startup-combined.log
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700240 """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000241 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400242
243 sh """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000244 JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-voltha-api" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/voltha-voltha-api 55555:55555; done"&
245 JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-infra-etcd" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-etcd 2379:2379; done"&
246 JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-infra-kafka" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-kafka 9092:9092; done"&
247 bbsimDmiPortFwd=50075
248 for i in {0..${olts.toInteger() - 1}}; do
249 JENKINS_NODE_COOKIE="dontKillMe" _TAG="bbsim\${i}" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/bbsim\${i} \${bbsimDmiPortFwd}:50075; done"&
250 ((bbsimDmiPortFwd++))
251 done
Hardik Windlass3bb089a2022-03-22 17:56:03 +0000252 if [ ${withMonitoring} = true ] ; then
253 JENKINS_NODE_COOKIE="dontKillMe" _TAG="nem-monitoring-prometheus-server" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n default svc/nem-monitoring-prometheus-server 31301:80; done"&
254 fi
Hardik Windlassec9341b2021-06-07 11:58:29 +0000255 ps aux | grep port-forward
256 """
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500257
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400258 // setting ONOS log level
259 script
260 {
261 setOnosLogLevels([
262 onosNamespace: infraNamespace,
263 apps: [
264 'org.opencord.dhcpl2relay',
265 'org.opencord.olt',
266 'org.opencord.aaa',
267 'org.opencord.maclearner',
268 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
269 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
270 ],
271 logLevel: logLevel
272 ])
273 } // script
274 } // if (teardown)
275 } // stage('Deploy Voltha')
276
277 stage('Run test ' + testTarget + ' on ' + workflow + ' workFlow')
278 {
279 sh """
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000280 if [ ${withMonitoring} = true ] ; then
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500281 mkdir -p "$WORKSPACE/voltha-pods-mem-consumption-${workflow}"
282 cd "$WORKSPACE/voltha-system-tests"
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400283 make venv-activate-script
284 set +u && source .venv/bin/activate && set -u
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000285 # Collect initial memory consumption
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400286 python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace}
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000287 fi
Hardik Windlasse1660492022-03-14 15:12:46 +0000288 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400289
290 sh """
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700291 mkdir -p ${logsDir}
Hardik Windlassd62442d2021-11-30 10:51:20 +0000292 export ROBOT_MISC_ARGS="-d ${logsDir} ${params.extraRobotArgs} "
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700293 ROBOT_MISC_ARGS+="-v ONOS_SSH_PORT:30115 -v ONOS_REST_PORT:30120 -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace} -v container_log_dir:${logsDir} -v logging:${testLogging}"
Hardik Windlass72947302021-06-14 10:36:57 +0000294 export KVSTOREPREFIX=voltha/voltha_voltha
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800295
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400296 make -C "$WORKSPACE/voltha-system-tests" ${testTarget}
Hardik Windlass72947302021-06-14 10:36:57 +0000297 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400298
299 getPodsInfo("${logsDir}")
300
301 sh """
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400302 # set +e
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000303 # collect logs collected in the Robot Framework StartLogging keyword
304 cd ${logsDir}
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400305 gzip *-combined.log
306 rm -f *-combined.log
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000307 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400308
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000309 sh """
310 if [ ${withMonitoring} = true ] ; then
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500311 cd "$WORKSPACE/voltha-system-tests"
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400312 make venv-activate-script
313 set +u && source .venv/bin/activate && set -u
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000314 # Collect memory consumption of voltha pods once all the tests are complete
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400315 python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace}
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000316 fi
317 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400318 } // stage
319} // execute_test()
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800320
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400321// -----------------------------------------------------------------------
322// -----------------------------------------------------------------------
323def collectArtifacts(exitStatus)
324{
Hardik Windlassec9341b2021-06-07 11:58:29 +0000325 getPodsInfo("$WORKSPACE/${exitStatus}")
326 sh """
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400327 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log
Hardik Windlassec9341b2021-06-07 11:58:29 +0000328 """
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000329 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html,**/voltha-pods-mem-consumption-att/*,**/voltha-pods-mem-consumption-dt/*,**/voltha-pods-mem-consumption-tt/*'
Hardik Windlassec9341b2021-06-07 11:58:29 +0000330 sh '''
331 sync
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400332 [[ $(pgrep --count kail) -gt 0 ]] && pkill --echo kail
Hardik Windlassec9341b2021-06-07 11:58:29 +0000333 which voltctl
334 md5sum $(which voltctl)
335 '''
336 step([$class: 'RobotPublisher',
337 disableArchiveOutput: false,
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700338 logFileName: "**/*/log*.html",
Hardik Windlassec9341b2021-06-07 11:58:29 +0000339 otherFiles: '',
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700340 outputFileName: "**/*/output*.xml",
Hardik Windlassec9341b2021-06-07 11:58:29 +0000341 outputPath: '.',
342 passThreshold: 100,
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700343 reportFileName: "**/*/report*.html",
Andrea Campanellaabc09772021-06-16 12:08:57 +0200344 unstableThreshold: 0,
345 onlyCritical: true]);
Hardik Windlassec9341b2021-06-07 11:58:29 +0000346}
347
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800348pipeline {
349
350 /* no label, executor is determined by JJB */
351 agent {
352 label "${params.buildNode}"
353 }
354 options {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000355 timeout(time: "${timeout}", unit: 'MINUTES')
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800356 }
357 environment {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000358 KUBECONFIG="$HOME/.kube/kind-${clusterName}"
359 VOLTCONFIG="$HOME/.volt/config"
360 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Hardik Windlassec9341b2021-06-07 11:58:29 +0000361 DIAGS_PROFILE="VOLTHA_PROFILE"
Matteo Scandolo35ac7822021-10-28 18:08:54 -0700362 SSHPASS="karaf"
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800363 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000364 stages {
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800365 stage('Download Code') {
366 steps {
367 getVolthaCode([
368 branch: "${branch}",
369 gerritProject: "${gerritProject}",
370 gerritRefspec: "${gerritRefspec}",
371 volthaSystemTestsChange: "${volthaSystemTestsChange}",
372 volthaHelmChartsChange: "${volthaHelmChartsChange}",
373 ])
374 }
375 }
Joey Armstrong84adc542023-04-11 14:47:34 -0400376
377 stage('Build patch v1.1')
378 {
379 // build the patch only if gerritProject is specified
380 when
381 {
382 expression
383 {
384 return !gerritProject.isEmpty()
385 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000386 }
Joey Armstrong06a68372023-07-24 16:37:16 -0400387
388 steps
389 {
390 // NOTE that the correct patch has already been checked out
391 // during the getVolthaCode step
392 buildVolthaComponent("${gerritProject}")
393 }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800394 }
Joey Armstronged161f72023-04-11 13:16:59 -0400395
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400396 stage('Create K8s Cluster')
397 {
Joey Armstrongbf492922023-04-13 17:05:09 -0400398 steps
Joey Armstrong84adc542023-04-11 14:47:34 -0400399 {
Joey Armstrongbf492922023-04-13 17:05:09 -0400400 script
Joey Armstrong84adc542023-04-11 14:47:34 -0400401 {
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400402 def clusterExists = sh(
Joey Armstrongbf492922023-04-13 17:05:09 -0400403 returnStdout: true,
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400404 script: """kind get clusters | grep "${clusterName}" | wc -l""")
Joey Armstrongbf492922023-04-13 17:05:09 -0400405
406 if (clusterExists.trim() == "0")
407 {
408 createKubernetesCluster([nodes: 3, name: clusterName])
409 }
410 } // script
411 } // steps
412 } // stage('Create K8s Cluster')
Joey Armstrong84adc542023-04-11 14:47:34 -0400413
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400414 stage('Replace voltctl')
415 {
Joey Armstrong06a68372023-07-24 16:37:16 -0400416 // if the project is voltctl, override the downloaded one with the built one
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400417 when {
418 expression {
419 return gerritProject == "voltctl"
420 }
421 }
Joey Armstrong53cebea2023-07-26 10:35:53 -0400422
Joey Armstrong06a68372023-07-24 16:37:16 -0400423 // Hmmmm(?) where did the voltctl download happen ?
424 // Likely Makefile but would be helpful to document here.
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400425 steps
Joey Armstrong06a68372023-07-24 16:37:16 -0400426 {
427 println("${iam} Running: installVoltctl($branch)")
428 installVoltctl("$branch")
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400429 } // steps
430 } // stage
Hardik Windlassec9341b2021-06-07 11:58:29 +0000431
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400432 stage('Load image in kind nodes')
433 {
434 when {
435 expression {
436 return !gerritProject.isEmpty()
437 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000438 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400439 steps {
440 loadToKind()
441 }
Matteo Scandolo29597f02021-02-12 10:53:57 -0800442 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400443
444 stage('Parse and execute tests')
445 {
446 steps {
447 script {
448 def tests = readYaml text: testTargets
449
450 for(int i = 0;i<tests.size();i++) {
451 def test = tests[i]
452 def target = test["target"]
453 def workflow = test["workflow"]
454 def flags = test["flags"]
455 def teardown = test["teardown"].toBoolean()
456 def logging = test["logging"].toBoolean()
457 def testLogging = 'False'
458 if (logging) {
459 testLogging = 'True'
460 }
461 println "Executing test ${target} on workflow ${workflow} with logging ${testLogging} and extra flags ${flags}"
462 execute_test(target, workflow, testLogging, teardown, flags)
463 }
464 }
465 }
466 } // stage
467 } // stages
Joey Armstrong84adc542023-04-11 14:47:34 -0400468
469 post
470 {
471 aborted { collectArtifacts('aborted') }
472 failure { collectArtifacts('failed') }
Joey Armstrongbf492922023-04-13 17:05:09 -0400473 always { collectArtifacts('always') }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800474 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400475} // pipeline
Joey Armstronged161f72023-04-11 13:16:59 -0400476
477// EOF