blob: b6b99f836e10f2d0af497f48ffcc7508d63767db [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 Armstrong46bfeea2023-07-31 10:39:25 -040064// NOTE: installKind temporarily disabled:
65// o error makes little sense, install.Kind.{groovy,sh} exist in vars/
66// o jenkins shared library -- checked out on server disk is stale
67// 2 changesets behind current ?!?!
68// o Disable call for now to revive the pipeline.
69// 10:26:05 org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
70// 10:26:05 WorkflowScript: 73: unexpected token: installKind @ line 73, column 2.
71// 10:26:05 installKind(name)
72// 10:26:05 ^
73// -----------------------------------------------------------------------
Joey Armstrong53cebea2023-07-26 10:35:53 -040074Boolean install_kind(String name)
Joey Armstrong06a68372023-07-24 16:37:16 -040075{
76 String iam = getIam('installKind')
77 Boolean ans = False
78
79 println("** ${iam}: ENTER")
80 try
81 {
Joey Armstrong93374962023-07-31 16:23:24 -040082 println("** ${iam} Running installKind(name): ENTER")
83 installKind(name)
84 println("** ${iam} Running installKind(name): LEAVE")
Joey Armstrong06a68372023-07-24 16:37:16 -040085 ans = True // iff
86 }
87 catch (Exception err)
88 {
89 ans = False
90 println("** ${iam}: EXCEPTION ${err}")
91 throw err
92 }
93 finally
94 {
95 println("** ${iam}: ENTER")
96 }
Joey Armstrong53cebea2023-07-26 10:35:53 -040097
Joey Armstrong06a68372023-07-24 16:37:16 -040098 return(ans)
99}
100
101// -----------------------------------------------------------------------
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400102// Intent:
103// -----------------------------------------------------------------------
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400104def execute_test(testTarget, workflow, testLogging, teardown, testSpecificHelmFlags = "")
105{
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500106 def infraNamespace = "default"
107 def volthaNamespace = "voltha"
108 def logsDir = "$WORKSPACE/${testTarget}"
Joey Armstrong293e16b2022-11-26 20:16:33 -0500109
110 stage('IAM')
111 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400112 script
113 {
Joey Armstrong06a68372023-07-24 16:37:16 -0400114 // Announce ourselves for log usability
115 String iam = getIam('execute_test')
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400116 println("${iam}: ENTER")
117 println("${iam}: LEAVE")
Joey Armstrong84adc542023-04-11 14:47:34 -0400118 }
Joey Armstrong293e16b2022-11-26 20:16:33 -0500119 }
120
121 stage('Cleanup') {
Joey Armstrong84adc542023-04-11 14:47:34 -0400122 if (teardown) {
123 timeout(15) {
124 script {
125 helmTeardown(["default", infraNamespace, volthaNamespace])
126 }
127 timeout(1) {
128 sh returnStdout: false, script: '''
Hardik Windlassec9341b2021-06-07 11:58:29 +0000129 # remove orphaned port-forward from different namespaces
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400130 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 +0000131 '''
Joey Armstrong84adc542023-04-11 14:47:34 -0400132 }
133 }
134 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000135 }
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500136
Joey Armstrong53cebea2023-07-26 10:35:53 -0400137 stage ('Install Kail')
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500138 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400139 // VOL-4926 - Is voltha-system-tests available ?
140 String cmd = [
141 'make',
142 '-C', "$WORKSPACE/voltha-system-tests",
143 "KAIL_PATH=\"$WORKSPACE/bin\"",
144 'kail',
145 ].join(' ')
146 println(" ** Running: ${cmd}:\n")
Joey Armstrongbeef4cd2023-01-18 09:59:58 -0500147 sh("${cmd}")
Joey Armstrong53cebea2023-07-26 10:35:53 -0400148 // if (! my_install_kail())
Joey Armstrong06a68372023-07-24 16:37:16 -0400149 // throw new Exception('installKail() failed')
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500150 }
151
Joey Armstrong53cebea2023-07-26 10:35:53 -0400152 stage ('Install Kind')
153 {
154 steps
155 {
156 install_kind(branch_name)
157 }
158 }
Joey Armstrong06a68372023-07-24 16:37:16 -0400159
Joey Armstrong06a68372023-07-24 16:37:16 -0400160 stage('Deploy common infrastructure')
161 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400162 sh '''
Hardik Windlasse1660492022-03-14 15:12:46 +0000163 helm repo add onf https://charts.opencord.org
164 helm repo update
165 if [ ${withMonitoring} = true ] ; then
166 helm install nem-monitoring onf/nem-monitoring \
167 --set prometheus.alertmanager.enabled=false,prometheus.pushgateway.enabled=false \
168 --set kpi_exporter.enabled=false,dashboards.xos=false,dashboards.onos=false,dashboards.aaa=false,dashboards.voltha=false
169 fi
170 '''
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500171 }
172
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400173 stage('Deploy Voltha')
174 {
175 if (teardown)
176 {
177 timeout(10)
178 {
179 script
180 {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000181 sh """
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700182 mkdir -p ${logsDir}
183 _TAG=kail-startup kail -n ${infraNamespace} -n ${volthaNamespace} > ${logsDir}/onos-voltha-startup-combined.log &
Hardik Windlassec9341b2021-06-07 11:58:29 +0000184 """
185
186 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
187 def localCharts = false
Joey Armstrong53cebea2023-07-26 10:35:53 -0400188
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400189 if (volthaHelmChartsChange != ""
190 || gerritProject == "voltha-helm-charts"
191 || isReleaseBranch(branch) // branch != 'master'
192 ) {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000193 localCharts = true
194 }
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400195 Boolean is_release = isReleaseBranch(branch)
196 println(" ** localCharts=${localCharts}, branch_name=${branch_name}, isReleaseBranch=${is_release}")
Hardik Windlassec9341b2021-06-07 11:58:29 +0000197
198 // NOTE temporary workaround expose ONOS node ports
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400199 def localHelmFlags = extraHelmFlags.trim()
200 + " --set global.log_level=${logLevel.toUpperCase()} "
201 + " --set onos-classic.onosSshPort=30115 "
202 + " --set onos-classic.onosApiPort=30120 "
203 + " --set onos-classic.onosOfPort=31653 "
204 + " --set onos-classic.individualOpenFlowNodePorts=true "
205 + testSpecificHelmFlags
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800206
Hardik Windlassec9341b2021-06-07 11:58:29 +0000207 if (gerritProject != "") {
208 localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}")
209 }
210
211 volthaDeploy([
212 infraNamespace: infraNamespace,
213 volthaNamespace: volthaNamespace,
214 workflow: workflow.toLowerCase(),
Hardik Windlass2b164342022-02-28 03:50:48 +0000215 withMacLearning: enableMacLearning.toBoolean(),
Hardik Windlassec9341b2021-06-07 11:58:29 +0000216 extraHelmFlags: localHelmFlags,
217 localCharts: localCharts,
218 bbsimReplica: olts.toInteger(),
219 dockerRegistry: registry,
220 ])
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700221 }
Matteo Scandolofcfc60d2021-02-24 09:06:48 -0800222
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400223 // -----------------------------------------------------------------------
224 // Intent: Replacing P_IDS with pgrep/pkill is a step forward.
225 // Why not simply use a pid file, capture _TAG=kail-startup above
226 // Grep runs the risk of terminating stray commands (??-good <=> bad-??)
227 // -----------------------------------------------------------------------
228 println('Try out the pgrep/pkill commands')
229 def stream = sh(
230 returnStatus:false,
231 returnStdout:true,
232 script: '''pgrep --list-full kail-startup || true'''
233 )
234 println("** pgrep output: ${stream}")
235
236 // -----------------------------------------------------------------------
237 // stop logging
238 // -----------------------------------------------------------------------
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700239 sh """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000240 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')"
241 if [ -n "\$P_IDS" ]; then
242 echo \$P_IDS
243 for P_ID in \$P_IDS; do
244 kill -9 \$P_ID
245 done
246 fi
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700247 cd ${logsDir}
Hardik Windlassec9341b2021-06-07 11:58:29 +0000248 gzip -k onos-voltha-startup-combined.log
249 rm onos-voltha-startup-combined.log
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700250 """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000251 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400252
253 sh """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000254 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"&
255 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"&
256 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"&
257 bbsimDmiPortFwd=50075
258 for i in {0..${olts.toInteger() - 1}}; do
259 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"&
260 ((bbsimDmiPortFwd++))
261 done
Hardik Windlass3bb089a2022-03-22 17:56:03 +0000262 if [ ${withMonitoring} = true ] ; then
263 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"&
264 fi
Hardik Windlassec9341b2021-06-07 11:58:29 +0000265 ps aux | grep port-forward
266 """
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500267
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400268 // setting ONOS log level
269 script
270 {
271 setOnosLogLevels([
272 onosNamespace: infraNamespace,
273 apps: [
274 'org.opencord.dhcpl2relay',
275 'org.opencord.olt',
276 'org.opencord.aaa',
277 'org.opencord.maclearner',
278 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
279 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
280 ],
281 logLevel: logLevel
282 ])
283 } // script
284 } // if (teardown)
285 } // stage('Deploy Voltha')
286
287 stage('Run test ' + testTarget + ' on ' + workflow + ' workFlow')
288 {
289 sh """
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000290 if [ ${withMonitoring} = true ] ; then
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500291 mkdir -p "$WORKSPACE/voltha-pods-mem-consumption-${workflow}"
292 cd "$WORKSPACE/voltha-system-tests"
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400293 make venv-activate-script
294 set +u && source .venv/bin/activate && set -u
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000295 # Collect initial memory consumption
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400296 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 +0000297 fi
Hardik Windlasse1660492022-03-14 15:12:46 +0000298 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400299
300 sh """
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700301 mkdir -p ${logsDir}
Hardik Windlassd62442d2021-11-30 10:51:20 +0000302 export ROBOT_MISC_ARGS="-d ${logsDir} ${params.extraRobotArgs} "
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700303 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 +0000304 export KVSTOREPREFIX=voltha/voltha_voltha
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800305
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400306 make -C "$WORKSPACE/voltha-system-tests" ${testTarget}
Hardik Windlass72947302021-06-14 10:36:57 +0000307 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400308
309 getPodsInfo("${logsDir}")
310
311 sh """
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400312 # set +e
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000313 # collect logs collected in the Robot Framework StartLogging keyword
314 cd ${logsDir}
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400315 gzip *-combined.log
316 rm -f *-combined.log
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000317 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400318
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000319 sh """
320 if [ ${withMonitoring} = true ] ; then
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500321 cd "$WORKSPACE/voltha-system-tests"
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400322 make venv-activate-script
323 set +u && source .venv/bin/activate && set -u
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000324 # Collect memory consumption of voltha pods once all the tests are complete
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400325 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 +0000326 fi
327 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400328 } // stage
329} // execute_test()
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800330
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400331// -----------------------------------------------------------------------
332// -----------------------------------------------------------------------
333def collectArtifacts(exitStatus)
334{
Hardik Windlassec9341b2021-06-07 11:58:29 +0000335 getPodsInfo("$WORKSPACE/${exitStatus}")
336 sh """
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400337 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log
Hardik Windlassec9341b2021-06-07 11:58:29 +0000338 """
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000339 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 +0000340 sh '''
341 sync
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400342 [[ $(pgrep --count kail) -gt 0 ]] && pkill --echo kail
Hardik Windlassec9341b2021-06-07 11:58:29 +0000343 which voltctl
344 md5sum $(which voltctl)
345 '''
346 step([$class: 'RobotPublisher',
347 disableArchiveOutput: false,
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700348 logFileName: "**/*/log*.html",
Hardik Windlassec9341b2021-06-07 11:58:29 +0000349 otherFiles: '',
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700350 outputFileName: "**/*/output*.xml",
Hardik Windlassec9341b2021-06-07 11:58:29 +0000351 outputPath: '.',
352 passThreshold: 100,
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700353 reportFileName: "**/*/report*.html",
Andrea Campanellaabc09772021-06-16 12:08:57 +0200354 unstableThreshold: 0,
355 onlyCritical: true]);
Hardik Windlassec9341b2021-06-07 11:58:29 +0000356}
357
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800358pipeline {
359
360 /* no label, executor is determined by JJB */
361 agent {
362 label "${params.buildNode}"
363 }
364 options {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000365 timeout(time: "${timeout}", unit: 'MINUTES')
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800366 }
367 environment {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000368 KUBECONFIG="$HOME/.kube/kind-${clusterName}"
369 VOLTCONFIG="$HOME/.volt/config"
370 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Hardik Windlassec9341b2021-06-07 11:58:29 +0000371 DIAGS_PROFILE="VOLTHA_PROFILE"
Matteo Scandolo35ac7822021-10-28 18:08:54 -0700372 SSHPASS="karaf"
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800373 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000374 stages {
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800375 stage('Download Code') {
376 steps {
377 getVolthaCode([
378 branch: "${branch}",
379 gerritProject: "${gerritProject}",
380 gerritRefspec: "${gerritRefspec}",
381 volthaSystemTestsChange: "${volthaSystemTestsChange}",
382 volthaHelmChartsChange: "${volthaHelmChartsChange}",
383 ])
384 }
385 }
Joey Armstrong84adc542023-04-11 14:47:34 -0400386
387 stage('Build patch v1.1')
388 {
389 // build the patch only if gerritProject is specified
390 when
391 {
392 expression
393 {
394 return !gerritProject.isEmpty()
395 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000396 }
Joey Armstrong06a68372023-07-24 16:37:16 -0400397
398 steps
399 {
400 // NOTE that the correct patch has already been checked out
401 // during the getVolthaCode step
402 buildVolthaComponent("${gerritProject}")
403 }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800404 }
Joey Armstronged161f72023-04-11 13:16:59 -0400405
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400406 stage('Create K8s Cluster')
407 {
Joey Armstrongbf492922023-04-13 17:05:09 -0400408 steps
Joey Armstrong84adc542023-04-11 14:47:34 -0400409 {
Joey Armstrongbf492922023-04-13 17:05:09 -0400410 script
Joey Armstrong84adc542023-04-11 14:47:34 -0400411 {
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400412 def clusterExists = sh(
Joey Armstrongbf492922023-04-13 17:05:09 -0400413 returnStdout: true,
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400414 script: """kind get clusters | grep "${clusterName}" | wc -l""")
Joey Armstrongbf492922023-04-13 17:05:09 -0400415
416 if (clusterExists.trim() == "0")
417 {
418 createKubernetesCluster([nodes: 3, name: clusterName])
419 }
420 } // script
421 } // steps
422 } // stage('Create K8s Cluster')
Joey Armstrong84adc542023-04-11 14:47:34 -0400423
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400424 stage('Replace voltctl')
425 {
Joey Armstrong06a68372023-07-24 16:37:16 -0400426 // if the project is voltctl, override the downloaded one with the built one
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400427 when {
428 expression {
429 return gerritProject == "voltctl"
430 }
431 }
Joey Armstrong53cebea2023-07-26 10:35:53 -0400432
Joey Armstrong06a68372023-07-24 16:37:16 -0400433 // Hmmmm(?) where did the voltctl download happen ?
434 // Likely Makefile but would be helpful to document here.
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400435 steps
Joey Armstrong06a68372023-07-24 16:37:16 -0400436 {
437 println("${iam} Running: installVoltctl($branch)")
438 installVoltctl("$branch")
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400439 } // steps
440 } // stage
Hardik Windlassec9341b2021-06-07 11:58:29 +0000441
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400442 stage('Load image in kind nodes')
443 {
444 when {
445 expression {
446 return !gerritProject.isEmpty()
447 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000448 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400449 steps {
450 loadToKind()
451 }
Matteo Scandolo29597f02021-02-12 10:53:57 -0800452 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400453
454 stage('Parse and execute tests')
455 {
456 steps {
457 script {
458 def tests = readYaml text: testTargets
459
460 for(int i = 0;i<tests.size();i++) {
461 def test = tests[i]
462 def target = test["target"]
463 def workflow = test["workflow"]
464 def flags = test["flags"]
465 def teardown = test["teardown"].toBoolean()
466 def logging = test["logging"].toBoolean()
467 def testLogging = 'False'
468 if (logging) {
469 testLogging = 'True'
470 }
471 println "Executing test ${target} on workflow ${workflow} with logging ${testLogging} and extra flags ${flags}"
472 execute_test(target, workflow, testLogging, teardown, flags)
473 }
474 }
475 }
476 } // stage
477 } // stages
Joey Armstrong84adc542023-04-11 14:47:34 -0400478
479 post
480 {
481 aborted { collectArtifacts('aborted') }
482 failure { collectArtifacts('failed') }
Joey Armstrongbf492922023-04-13 17:05:09 -0400483 always { collectArtifacts('always') }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800484 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400485} // pipeline
Joey Armstronged161f72023-04-11 13:16:59 -0400486
487// EOF