blob: c05661464124a5e352ce97dad21a7c18170388ed [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 Armstrongf076c312023-08-01 17:17:10 -040029
30// -----------------------------------------------------------------------
31// -----------------------------------------------------------------------
32String getBranchName() {
33 String name = 'master'
34 return(name)
35}
Hardik Windlassec9341b2021-06-07 11:58:29 +000036
Joey Armstronge5aae1c2023-07-24 14:11:20 -040037// -----------------------------------------------------------------------
Joey Armstrong06a68372023-07-24 16:37:16 -040038// Intent: Due to lack of a reliable stack trace, construct a literal.
39// Jenkins will re-write the call stack for serialization.
40// -----------------------------------------------------------------------
41def getIam(String func)
42{
Joey Armstrongf076c312023-08-01 17:17:10 -040043 String branch_name = getBranchName()
Joey Armstrong06a68372023-07-24 16:37:16 -040044 String src = [
45 'ci-management',
46 'jjb',
47 'pipeline',
48 'voltha',
49 branch_name,
50 'bbsim-tests.groovy'
51 ].join('/')
52
53 String iam = [src, func].join('::')
54 return iam
55}
56
57// -----------------------------------------------------------------------
Joey Armstronge5aae1c2023-07-24 14:11:20 -040058// Intent: Determine if working on a release branch.
59// Note: Conditional is legacy, should also check for *-dev or *-pre
60// -----------------------------------------------------------------------
61Boolean isReleaseBranch(String name)
62{
63 // List modifiers = ['-dev', '-pre', 'voltha-x.y.z-pre']
64 // if branch_name in modifiers
65 return(name != 'master') // OR branch_name.contains('-')
66}
67
68// -----------------------------------------------------------------------
Joey Armstrong06a68372023-07-24 16:37:16 -040069// Intent: Phase helper method
70// -----------------------------------------------------------------------
Joey Armstrong46bfeea2023-07-31 10:39:25 -040071// NOTE: installKind temporarily disabled:
72// o error makes little sense, install.Kind.{groovy,sh} exist in vars/
73// o jenkins shared library -- checked out on server disk is stale
74// 2 changesets behind current ?!?!
75// o Disable call for now to revive the pipeline.
76// 10:26:05 org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
77// 10:26:05 WorkflowScript: 73: unexpected token: installKind @ line 73, column 2.
78// 10:26:05 installKind(name)
79// 10:26:05 ^
80// -----------------------------------------------------------------------
Joey Armstrong53cebea2023-07-26 10:35:53 -040081Boolean install_kind(String name)
Joey Armstrong06a68372023-07-24 16:37:16 -040082{
83 String iam = getIam('installKind')
84 Boolean ans = False
85
86 println("** ${iam}: ENTER")
87 try
88 {
Joey Armstrong93374962023-07-31 16:23:24 -040089 println("** ${iam} Running installKind(name): ENTER")
90 installKind(name)
91 println("** ${iam} Running installKind(name): LEAVE")
Joey Armstrong06a68372023-07-24 16:37:16 -040092 ans = True // iff
93 }
94 catch (Exception err)
95 {
96 ans = False
97 println("** ${iam}: EXCEPTION ${err}")
98 throw err
99 }
100 finally
101 {
102 println("** ${iam}: ENTER")
103 }
Joey Armstrong53cebea2023-07-26 10:35:53 -0400104
Joey Armstrong06a68372023-07-24 16:37:16 -0400105 return(ans)
106}
107
108// -----------------------------------------------------------------------
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400109// Intent:
110// -----------------------------------------------------------------------
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400111def execute_test(testTarget, workflow, testLogging, teardown, testSpecificHelmFlags = "")
112{
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500113 def infraNamespace = "default"
114 def volthaNamespace = "voltha"
115 def logsDir = "$WORKSPACE/${testTarget}"
Joey Armstrong293e16b2022-11-26 20:16:33 -0500116
Joey Armstrongf076c312023-08-01 17:17:10 -0400117 /*
Joey Armstrong293e16b2022-11-26 20:16:33 -0500118 stage('IAM')
119 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400120 script
121 {
Joey Armstrong06a68372023-07-24 16:37:16 -0400122 // Announce ourselves for log usability
123 String iam = getIam('execute_test')
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400124 println("${iam}: ENTER")
125 println("${iam}: LEAVE")
Joey Armstrong84adc542023-04-11 14:47:34 -0400126 }
Joey Armstrong293e16b2022-11-26 20:16:33 -0500127 }
Joey Armstrongf076c312023-08-01 17:17:10 -0400128 */
129
130 stage('Cleanup')
131 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400132 if (teardown) {
133 timeout(15) {
134 script {
135 helmTeardown(["default", infraNamespace, volthaNamespace])
136 }
137 timeout(1) {
138 sh returnStdout: false, script: '''
Hardik Windlassec9341b2021-06-07 11:58:29 +0000139 # remove orphaned port-forward from different namespaces
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400140 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 +0000141 '''
Joey Armstrong84adc542023-04-11 14:47:34 -0400142 }
143 }
144 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000145 }
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500146
Joey Armstrong53cebea2023-07-26 10:35:53 -0400147 stage ('Install Kail')
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500148 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400149 // VOL-4926 - Is voltha-system-tests available ?
150 String cmd = [
151 'make',
152 '-C', "$WORKSPACE/voltha-system-tests",
153 "KAIL_PATH=\"$WORKSPACE/bin\"",
154 'kail',
155 ].join(' ')
156 println(" ** Running: ${cmd}:\n")
Joey Armstrongbeef4cd2023-01-18 09:59:58 -0500157 sh("${cmd}")
Joey Armstrong53cebea2023-07-26 10:35:53 -0400158 // if (! my_install_kail())
Joey Armstrong06a68372023-07-24 16:37:16 -0400159 // throw new Exception('installKail() failed')
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500160 }
161
Joey Armstrong53cebea2023-07-26 10:35:53 -0400162 stage ('Install Kind')
163 {
164 steps
165 {
Joey Armstrongf076c312023-08-01 17:17:10 -0400166 String branch_name = getBranchName()
Joey Armstrong53cebea2023-07-26 10:35:53 -0400167 install_kind(branch_name)
168 }
169 }
Joey Armstrong06a68372023-07-24 16:37:16 -0400170
Joey Armstrong06a68372023-07-24 16:37:16 -0400171 stage('Deploy common infrastructure')
172 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400173 sh '''
Hardik Windlasse1660492022-03-14 15:12:46 +0000174 helm repo add onf https://charts.opencord.org
175 helm repo update
176 if [ ${withMonitoring} = true ] ; then
177 helm install nem-monitoring onf/nem-monitoring \
178 --set prometheus.alertmanager.enabled=false,prometheus.pushgateway.enabled=false \
179 --set kpi_exporter.enabled=false,dashboards.xos=false,dashboards.onos=false,dashboards.aaa=false,dashboards.voltha=false
180 fi
181 '''
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500182 }
183
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400184 stage('Deploy Voltha')
185 {
186 if (teardown)
187 {
188 timeout(10)
189 {
190 script
191 {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000192 sh """
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700193 mkdir -p ${logsDir}
194 _TAG=kail-startup kail -n ${infraNamespace} -n ${volthaNamespace} > ${logsDir}/onos-voltha-startup-combined.log &
Hardik Windlassec9341b2021-06-07 11:58:29 +0000195 """
196
197 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
198 def localCharts = false
Joey Armstrong53cebea2023-07-26 10:35:53 -0400199
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400200 if (volthaHelmChartsChange != ""
201 || gerritProject == "voltha-helm-charts"
202 || isReleaseBranch(branch) // branch != 'master'
203 ) {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000204 localCharts = true
205 }
Joey Armstrongf076c312023-08-01 17:17:10 -0400206 String branch_name = getBranchName()
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400207 Boolean is_release = isReleaseBranch(branch)
Joey Armstrongf076c312023-08-01 17:17:10 -0400208 println([
209 " ** localCharts=${localCharts}",
210 "branch_name=${branch_name}",
211 "branch=${branch}",
212 "branch=isReleaseBranch=${is_release}",
213 ].join(', '))
Hardik Windlassec9341b2021-06-07 11:58:29 +0000214
215 // NOTE temporary workaround expose ONOS node ports
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400216 def localHelmFlags = extraHelmFlags.trim()
217 + " --set global.log_level=${logLevel.toUpperCase()} "
218 + " --set onos-classic.onosSshPort=30115 "
219 + " --set onos-classic.onosApiPort=30120 "
220 + " --set onos-classic.onosOfPort=31653 "
221 + " --set onos-classic.individualOpenFlowNodePorts=true "
222 + testSpecificHelmFlags
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800223
Hardik Windlassec9341b2021-06-07 11:58:29 +0000224 if (gerritProject != "") {
225 localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}")
226 }
227
228 volthaDeploy([
229 infraNamespace: infraNamespace,
230 volthaNamespace: volthaNamespace,
231 workflow: workflow.toLowerCase(),
Hardik Windlass2b164342022-02-28 03:50:48 +0000232 withMacLearning: enableMacLearning.toBoolean(),
Hardik Windlassec9341b2021-06-07 11:58:29 +0000233 extraHelmFlags: localHelmFlags,
234 localCharts: localCharts,
235 bbsimReplica: olts.toInteger(),
236 dockerRegistry: registry,
237 ])
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700238 }
Matteo Scandolofcfc60d2021-02-24 09:06:48 -0800239
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400240 // -----------------------------------------------------------------------
241 // Intent: Replacing P_IDS with pgrep/pkill is a step forward.
242 // Why not simply use a pid file, capture _TAG=kail-startup above
243 // Grep runs the risk of terminating stray commands (??-good <=> bad-??)
244 // -----------------------------------------------------------------------
245 println('Try out the pgrep/pkill commands')
246 def stream = sh(
247 returnStatus:false,
248 returnStdout:true,
249 script: '''pgrep --list-full kail-startup || true'''
250 )
251 println("** pgrep output: ${stream}")
252
253 // -----------------------------------------------------------------------
254 // stop logging
255 // -----------------------------------------------------------------------
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700256 sh """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000257 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')"
258 if [ -n "\$P_IDS" ]; then
259 echo \$P_IDS
260 for P_ID in \$P_IDS; do
261 kill -9 \$P_ID
262 done
263 fi
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700264 cd ${logsDir}
Hardik Windlassec9341b2021-06-07 11:58:29 +0000265 gzip -k onos-voltha-startup-combined.log
266 rm onos-voltha-startup-combined.log
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700267 """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000268 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400269
270 sh """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000271 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"&
272 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"&
273 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"&
274 bbsimDmiPortFwd=50075
275 for i in {0..${olts.toInteger() - 1}}; do
276 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"&
277 ((bbsimDmiPortFwd++))
278 done
Hardik Windlass3bb089a2022-03-22 17:56:03 +0000279 if [ ${withMonitoring} = true ] ; then
280 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"&
281 fi
Hardik Windlassec9341b2021-06-07 11:58:29 +0000282 ps aux | grep port-forward
283 """
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500284
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400285 // setting ONOS log level
286 script
287 {
288 setOnosLogLevels([
289 onosNamespace: infraNamespace,
290 apps: [
291 'org.opencord.dhcpl2relay',
292 'org.opencord.olt',
293 'org.opencord.aaa',
294 'org.opencord.maclearner',
295 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
296 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
297 ],
298 logLevel: logLevel
299 ])
300 } // script
301 } // if (teardown)
302 } // stage('Deploy Voltha')
303
304 stage('Run test ' + testTarget + ' on ' + workflow + ' workFlow')
305 {
306 sh """
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000307 if [ ${withMonitoring} = true ] ; then
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500308 mkdir -p "$WORKSPACE/voltha-pods-mem-consumption-${workflow}"
309 cd "$WORKSPACE/voltha-system-tests"
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400310 make venv-activate-script
311 set +u && source .venv/bin/activate && set -u
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000312 # Collect initial memory consumption
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400313 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 +0000314 fi
Hardik Windlasse1660492022-03-14 15:12:46 +0000315 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400316
317 sh """
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700318 mkdir -p ${logsDir}
Hardik Windlassd62442d2021-11-30 10:51:20 +0000319 export ROBOT_MISC_ARGS="-d ${logsDir} ${params.extraRobotArgs} "
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700320 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 +0000321 export KVSTOREPREFIX=voltha/voltha_voltha
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800322
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400323 make -C "$WORKSPACE/voltha-system-tests" ${testTarget}
Hardik Windlass72947302021-06-14 10:36:57 +0000324 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400325
326 getPodsInfo("${logsDir}")
327
328 sh """
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400329 # set +e
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000330 # collect logs collected in the Robot Framework StartLogging keyword
331 cd ${logsDir}
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400332 gzip *-combined.log
333 rm -f *-combined.log
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000334 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400335
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000336 sh """
337 if [ ${withMonitoring} = true ] ; then
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500338 cd "$WORKSPACE/voltha-system-tests"
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400339 make venv-activate-script
340 set +u && source .venv/bin/activate && set -u
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000341 # Collect memory consumption of voltha pods once all the tests are complete
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400342 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 +0000343 fi
344 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400345 } // stage
346} // execute_test()
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800347
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400348// -----------------------------------------------------------------------
349// -----------------------------------------------------------------------
350def collectArtifacts(exitStatus)
351{
Hardik Windlassec9341b2021-06-07 11:58:29 +0000352 getPodsInfo("$WORKSPACE/${exitStatus}")
353 sh """
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400354 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log
Hardik Windlassec9341b2021-06-07 11:58:29 +0000355 """
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000356 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 +0000357 sh '''
358 sync
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400359 [[ $(pgrep --count kail) -gt 0 ]] && pkill --echo kail
Hardik Windlassec9341b2021-06-07 11:58:29 +0000360 which voltctl
361 md5sum $(which voltctl)
362 '''
363 step([$class: 'RobotPublisher',
364 disableArchiveOutput: false,
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700365 logFileName: "**/*/log*.html",
Hardik Windlassec9341b2021-06-07 11:58:29 +0000366 otherFiles: '',
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700367 outputFileName: "**/*/output*.xml",
Hardik Windlassec9341b2021-06-07 11:58:29 +0000368 outputPath: '.',
369 passThreshold: 100,
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700370 reportFileName: "**/*/report*.html",
Andrea Campanellaabc09772021-06-16 12:08:57 +0200371 unstableThreshold: 0,
372 onlyCritical: true]);
Hardik Windlassec9341b2021-06-07 11:58:29 +0000373}
374
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800375pipeline {
376
377 /* no label, executor is determined by JJB */
378 agent {
379 label "${params.buildNode}"
380 }
381 options {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000382 timeout(time: "${timeout}", unit: 'MINUTES')
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800383 }
384 environment {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000385 KUBECONFIG="$HOME/.kube/kind-${clusterName}"
386 VOLTCONFIG="$HOME/.volt/config"
387 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Hardik Windlassec9341b2021-06-07 11:58:29 +0000388 DIAGS_PROFILE="VOLTHA_PROFILE"
Matteo Scandolo35ac7822021-10-28 18:08:54 -0700389 SSHPASS="karaf"
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800390 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000391 stages {
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800392 stage('Download Code') {
393 steps {
394 getVolthaCode([
395 branch: "${branch}",
396 gerritProject: "${gerritProject}",
397 gerritRefspec: "${gerritRefspec}",
398 volthaSystemTestsChange: "${volthaSystemTestsChange}",
399 volthaHelmChartsChange: "${volthaHelmChartsChange}",
400 ])
401 }
402 }
Joey Armstrong84adc542023-04-11 14:47:34 -0400403
404 stage('Build patch v1.1')
405 {
406 // build the patch only if gerritProject is specified
407 when
408 {
409 expression
410 {
411 return !gerritProject.isEmpty()
412 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000413 }
Joey Armstrong06a68372023-07-24 16:37:16 -0400414
415 steps
416 {
417 // NOTE that the correct patch has already been checked out
418 // during the getVolthaCode step
419 buildVolthaComponent("${gerritProject}")
420 }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800421 }
Joey Armstronged161f72023-04-11 13:16:59 -0400422
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400423 stage('Create K8s Cluster')
424 {
Joey Armstrongf076c312023-08-01 17:17:10 -0400425 steps
426 {
427 script
Joey Armstrong84adc542023-04-11 14:47:34 -0400428 {
Joey Armstrongf076c312023-08-01 17:17:10 -0400429 def clusterExists = sh(
430 returnStdout: true,
431 script: """kind get clusters | grep "${clusterName}" | wc -l""")
Joey Armstrongbf492922023-04-13 17:05:09 -0400432
Joey Armstrongf076c312023-08-01 17:17:10 -0400433 if (clusterExists.trim() == "0")
434 {
435 createKubernetesCluster([nodes: 3, name: clusterName])
436 }
437 } // script
438 } // steps
439 } // stage('Create K8s Cluster')
Joey Armstrong84adc542023-04-11 14:47:34 -0400440
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400441 stage('Replace voltctl')
442 {
Joey Armstrong06a68372023-07-24 16:37:16 -0400443 // if the project is voltctl, override the downloaded one with the built one
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400444 when {
445 expression {
446 return gerritProject == "voltctl"
447 }
448 }
Joey Armstrong53cebea2023-07-26 10:35:53 -0400449
Joey Armstrong06a68372023-07-24 16:37:16 -0400450 // Hmmmm(?) where did the voltctl download happen ?
451 // Likely Makefile but would be helpful to document here.
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400452 steps
Joey Armstrong06a68372023-07-24 16:37:16 -0400453 {
454 println("${iam} Running: installVoltctl($branch)")
455 installVoltctl("$branch")
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400456 } // steps
457 } // stage
Hardik Windlassec9341b2021-06-07 11:58:29 +0000458
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400459 stage('Load image in kind nodes')
460 {
461 when {
462 expression {
463 return !gerritProject.isEmpty()
464 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000465 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400466 steps {
467 loadToKind()
468 }
Matteo Scandolo29597f02021-02-12 10:53:57 -0800469 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400470
471 stage('Parse and execute tests')
472 {
473 steps {
474 script {
475 def tests = readYaml text: testTargets
476
477 for(int i = 0;i<tests.size();i++) {
478 def test = tests[i]
479 def target = test["target"]
480 def workflow = test["workflow"]
481 def flags = test["flags"]
482 def teardown = test["teardown"].toBoolean()
483 def logging = test["logging"].toBoolean()
484 def testLogging = 'False'
485 if (logging) {
486 testLogging = 'True'
487 }
488 println "Executing test ${target} on workflow ${workflow} with logging ${testLogging} and extra flags ${flags}"
489 execute_test(target, workflow, testLogging, teardown, flags)
490 }
491 }
492 }
493 } // stage
494 } // stages
Joey Armstrong84adc542023-04-11 14:47:34 -0400495
496 post
497 {
498 aborted { collectArtifacts('aborted') }
499 failure { collectArtifacts('failed') }
Joey Armstrongbf492922023-04-13 17:05:09 -0400500 always { collectArtifacts('always') }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800501 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400502} // pipeline
Joey Armstronged161f72023-04-11 13:16:59 -0400503
504// EOF