blob: a7c21eff6a8114d6987d15f62892601da8b4eecc [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//------------------//
Joey Armstrong97a8b882023-08-02 16:08:52 -040028def clusterName = 'kind-ci'
Joey Armstrongf076c312023-08-01 17:17:10 -040029
30// -----------------------------------------------------------------------
Joey Armstrong0e0a42b2023-08-02 21:04:21 -040031// Intent:
Joey Armstrongf076c312023-08-01 17:17:10 -040032// -----------------------------------------------------------------------
33String getBranchName() {
34 String name = 'master'
Joey Armstrong0e0a42b2023-08-02 21:04:21 -040035
36 // [TODO] Sanity check the target branch
37 // if (name != jenkins.branch) { fatal }
Joey Armstrongf076c312023-08-01 17:17:10 -040038 return(name)
39}
Hardik Windlassec9341b2021-06-07 11:58:29 +000040
Joey Armstronge5aae1c2023-07-24 14:11:20 -040041// -----------------------------------------------------------------------
Joey Armstrong06a68372023-07-24 16:37:16 -040042// Intent: Due to lack of a reliable stack trace, construct a literal.
43// Jenkins will re-write the call stack for serialization.
44// -----------------------------------------------------------------------
Joey Armstrong97a8b882023-08-02 16:08:52 -040045String getIam(String func) {
Joey Armstrongf076c312023-08-01 17:17:10 -040046 String branch_name = getBranchName()
Joey Armstrong06a68372023-07-24 16:37:16 -040047 String src = [
48 'ci-management',
49 'jjb',
50 'pipeline',
51 'voltha',
Joey Armstrong97a8b882023-08-02 16:08:52 -040052 branch_name,
Joey Armstrong06a68372023-07-24 16:37:16 -040053 'bbsim-tests.groovy'
54 ].join('/')
55
Joey Armstrong0e0a42b2023-08-02 21:04:21 -040056 String name = [src, func].join('::')
57 return(name)
Joey Armstrong06a68372023-07-24 16:37:16 -040058}
59
60// -----------------------------------------------------------------------
Joey Armstronge5aae1c2023-07-24 14:11:20 -040061// Intent: Determine if working on a release branch.
62// Note: Conditional is legacy, should also check for *-dev or *-pre
63// -----------------------------------------------------------------------
64Boolean isReleaseBranch(String name)
65{
66 // List modifiers = ['-dev', '-pre', 'voltha-x.y.z-pre']
67 // if branch_name in modifiers
68 return(name != 'master') // OR branch_name.contains('-')
69}
70
71// -----------------------------------------------------------------------
72// Intent:
73// -----------------------------------------------------------------------
Joey Armstrong2d5a7c12023-04-13 09:37:42 -040074def execute_test(testTarget, workflow, testLogging, teardown, testSpecificHelmFlags = "")
75{
Joey Armstrong8c6f6482023-01-12 12:31:44 -050076 def infraNamespace = "default"
77 def volthaNamespace = "voltha"
78 def logsDir = "$WORKSPACE/${testTarget}"
Joey Armstrong293e16b2022-11-26 20:16:33 -050079
80 stage('IAM')
81 {
Joey Armstrong84adc542023-04-11 14:47:34 -040082 script
83 {
Joey Armstrong97a8b882023-08-02 16:08:52 -040084 // Announce ourselves for log usability
85 String iam = getIam('execute_test')
86 println("${iam}: ENTER")
87 println("${iam}: LEAVE")
Joey Armstrong84adc542023-04-11 14:47:34 -040088 }
Joey Armstrong293e16b2022-11-26 20:16:33 -050089 }
Joey Armstrongf076c312023-08-01 17:17:10 -040090
Joey Armstrong0e0a42b2023-08-02 21:04:21 -040091 // -----------------------------------------------------------------------
92 // -----------------------------------------------------------------------
Joey Armstrongf076c312023-08-01 17:17:10 -040093 stage('Cleanup')
94 {
Joey Armstrong84adc542023-04-11 14:47:34 -040095 if (teardown) {
96 timeout(15) {
97 script {
98 helmTeardown(["default", infraNamespace, volthaNamespace])
99 }
100 timeout(1) {
101 sh returnStdout: false, script: '''
Hardik Windlassec9341b2021-06-07 11:58:29 +0000102 # remove orphaned port-forward from different namespaces
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400103 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 +0000104 '''
Joey Armstrong84adc542023-04-11 14:47:34 -0400105 }
106 }
107 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000108 }
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500109
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400110 // -----------------------------------------------------------------------
111 // -----------------------------------------------------------------------
Joey Armstrong06a68372023-07-24 16:37:16 -0400112 stage('Deploy common infrastructure')
113 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400114 sh '''
Hardik Windlasse1660492022-03-14 15:12:46 +0000115 helm repo add onf https://charts.opencord.org
116 helm repo update
117 if [ ${withMonitoring} = true ] ; then
118 helm install nem-monitoring onf/nem-monitoring \
119 --set prometheus.alertmanager.enabled=false,prometheus.pushgateway.enabled=false \
120 --set kpi_exporter.enabled=false,dashboards.xos=false,dashboards.onos=false,dashboards.aaa=false,dashboards.voltha=false
121 fi
122 '''
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500123 }
124
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400125 stage('Deploy Voltha')
126 {
Joey Armstrong97a8b882023-08-02 16:08:52 -0400127 if (teardown)
128 {
129 timeout(10)
130 {
131 script
132 {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000133 sh """
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700134 mkdir -p ${logsDir}
135 _TAG=kail-startup kail -n ${infraNamespace} -n ${volthaNamespace} > ${logsDir}/onos-voltha-startup-combined.log &
Hardik Windlassec9341b2021-06-07 11:58:29 +0000136 """
137
138 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
139 def localCharts = false
Joey Armstrong53cebea2023-07-26 10:35:53 -0400140
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400141 if (volthaHelmChartsChange != ""
Joey Armstrong97a8b882023-08-02 16:08:52 -0400142 || gerritProject == "voltha-helm-charts"
143 || isReleaseBranch(branch) // branch != 'master'
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400144 ) {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000145 localCharts = true
146 }
Joey Armstrong97a8b882023-08-02 16:08:52 -0400147 String branch_name = getBranchName()
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400148 Boolean is_release = isReleaseBranch(branch)
Joey Armstrong97a8b882023-08-02 16:08:52 -0400149 println([
150 " ** localCharts=${localCharts}",
151 "branch_name=${branch_name}",
152 "branch=${branch}",
153 "branch=isReleaseBranch=${is_release}",
154 ].join(', '))
Hardik Windlassec9341b2021-06-07 11:58:29 +0000155
156 // NOTE temporary workaround expose ONOS node ports
Joey Armstrong97a8b882023-08-02 16:08:52 -0400157 def localHelmFlags = extraHelmFlags.trim()
158 + " --set global.log_level=${logLevel.toUpperCase()} "
159 + " --set onos-classic.onosSshPort=30115 "
160 + " --set onos-classic.onosApiPort=30120 "
161 + " --set onos-classic.onosOfPort=31653 "
162 + " --set onos-classic.individualOpenFlowNodePorts=true "
163 + testSpecificHelmFlags
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800164
Hardik Windlassec9341b2021-06-07 11:58:29 +0000165 if (gerritProject != "") {
166 localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}")
167 }
168
169 volthaDeploy([
170 infraNamespace: infraNamespace,
171 volthaNamespace: volthaNamespace,
172 workflow: workflow.toLowerCase(),
Hardik Windlass2b164342022-02-28 03:50:48 +0000173 withMacLearning: enableMacLearning.toBoolean(),
Hardik Windlassec9341b2021-06-07 11:58:29 +0000174 extraHelmFlags: localHelmFlags,
175 localCharts: localCharts,
176 bbsimReplica: olts.toInteger(),
177 dockerRegistry: registry,
178 ])
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700179 }
Matteo Scandolofcfc60d2021-02-24 09:06:48 -0800180
Joey Armstrong97a8b882023-08-02 16:08:52 -0400181 // -----------------------------------------------------------------------
182 // Intent: Replacing P_IDS with pgrep/pkill is a step forward.
183 // Why not simply use a pid file, capture _TAG=kail-startup above
184 // Grep runs the risk of terminating stray commands (??-good <=> bad-??)
185 // -----------------------------------------------------------------------
186 echo 'Try out pgrep/pkill commands'
187 def stream = sh(
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400188 returnStatus:false,
189 returnStdout:true,
Joey Armstrong97a8b882023-08-02 16:08:52 -0400190 script: '''pgrep --list-full kail-startup || true'''
191 )
192 println("** pgrep output: ${stream}")
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400193
Joey Armstrong97a8b882023-08-02 16:08:52 -0400194 // -----------------------------------------------------------------------
195 // stop logging
196 // -----------------------------------------------------------------------
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700197 sh """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000198 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')"
199 if [ -n "\$P_IDS" ]; then
200 echo \$P_IDS
201 for P_ID in \$P_IDS; do
202 kill -9 \$P_ID
203 done
204 fi
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700205 cd ${logsDir}
Hardik Windlassec9341b2021-06-07 11:58:29 +0000206 gzip -k onos-voltha-startup-combined.log
207 rm onos-voltha-startup-combined.log
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700208 """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000209 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400210
211 sh """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000212 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"&
213 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"&
214 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"&
215 bbsimDmiPortFwd=50075
216 for i in {0..${olts.toInteger() - 1}}; do
217 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"&
218 ((bbsimDmiPortFwd++))
219 done
Hardik Windlass3bb089a2022-03-22 17:56:03 +0000220 if [ ${withMonitoring} = true ] ; then
221 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"&
222 fi
Hardik Windlassec9341b2021-06-07 11:58:29 +0000223 ps aux | grep port-forward
224 """
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500225
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400226 // setting ONOS log level
227 script
228 {
229 setOnosLogLevels([
230 onosNamespace: infraNamespace,
231 apps: [
232 'org.opencord.dhcpl2relay',
233 'org.opencord.olt',
234 'org.opencord.aaa',
235 'org.opencord.maclearner',
236 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
237 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
238 ],
239 logLevel: logLevel
240 ])
241 } // script
242 } // if (teardown)
243 } // stage('Deploy Voltha')
244
245 stage('Run test ' + testTarget + ' on ' + workflow + ' workFlow')
246 {
247 sh """
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000248 if [ ${withMonitoring} = true ] ; then
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500249 mkdir -p "$WORKSPACE/voltha-pods-mem-consumption-${workflow}"
250 cd "$WORKSPACE/voltha-system-tests"
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400251 make venv-activate-script
252 set +u && source .venv/bin/activate && set -u
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000253 # Collect initial memory consumption
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400254 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 +0000255 fi
Hardik Windlasse1660492022-03-14 15:12:46 +0000256 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400257
258 sh """
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700259 mkdir -p ${logsDir}
Hardik Windlassd62442d2021-11-30 10:51:20 +0000260 export ROBOT_MISC_ARGS="-d ${logsDir} ${params.extraRobotArgs} "
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700261 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 +0000262 export KVSTOREPREFIX=voltha/voltha_voltha
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800263
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400264 make -C "$WORKSPACE/voltha-system-tests" ${testTarget}
Hardik Windlass72947302021-06-14 10:36:57 +0000265 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400266
267 getPodsInfo("${logsDir}")
268
269 sh """
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400270 # set +e
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000271 # collect logs collected in the Robot Framework StartLogging keyword
272 cd ${logsDir}
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400273 gzip *-combined.log
274 rm -f *-combined.log
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000275 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400276
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000277 sh """
278 if [ ${withMonitoring} = true ] ; then
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500279 cd "$WORKSPACE/voltha-system-tests"
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400280 make venv-activate-script
281 set +u && source .venv/bin/activate && set -u
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000282 # Collect memory consumption of voltha pods once all the tests are complete
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400283 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 +0000284 fi
285 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400286 } // stage
287} // execute_test()
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800288
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400289// -----------------------------------------------------------------------
290// -----------------------------------------------------------------------
291def collectArtifacts(exitStatus)
292{
Joey Armstrong97a8b882023-08-02 16:08:52 -0400293 echo '''
294
295** -----------------------------------------------------------------------
296** collectArtifacts
297** -----------------------------------------------------------------------
298'''
299
Hardik Windlassec9341b2021-06-07 11:58:29 +0000300 getPodsInfo("$WORKSPACE/${exitStatus}")
Joey Armstrong97a8b882023-08-02 16:08:52 -0400301
Hardik Windlassec9341b2021-06-07 11:58:29 +0000302 sh """
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400303 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log
Hardik Windlassec9341b2021-06-07 11:58:29 +0000304 """
Joey Armstrong97a8b882023-08-02 16:08:52 -0400305
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000306 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html,**/voltha-pods-mem-consumption-att/*,**/voltha-pods-mem-consumption-dt/*,**/voltha-pods-mem-consumption-tt/*'
Joey Armstrong97a8b882023-08-02 16:08:52 -0400307
Hardik Windlassec9341b2021-06-07 11:58:29 +0000308 sh '''
309 sync
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400310 [[ $(pgrep --count kail) -gt 0 ]] && pkill --echo kail
Hardik Windlassec9341b2021-06-07 11:58:29 +0000311 which voltctl
312 md5sum $(which voltctl)
313 '''
Joey Armstrong97a8b882023-08-02 16:08:52 -0400314
Hardik Windlassec9341b2021-06-07 11:58:29 +0000315 step([$class: 'RobotPublisher',
316 disableArchiveOutput: false,
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700317 logFileName: "**/*/log*.html",
Hardik Windlassec9341b2021-06-07 11:58:29 +0000318 otherFiles: '',
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700319 outputFileName: "**/*/output*.xml",
Hardik Windlassec9341b2021-06-07 11:58:29 +0000320 outputPath: '.',
321 passThreshold: 100,
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700322 reportFileName: "**/*/report*.html",
Andrea Campanellaabc09772021-06-16 12:08:57 +0200323 unstableThreshold: 0,
324 onlyCritical: true]);
Hardik Windlassec9341b2021-06-07 11:58:29 +0000325}
326
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800327pipeline {
328
329 /* no label, executor is determined by JJB */
330 agent {
331 label "${params.buildNode}"
332 }
333 options {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000334 timeout(time: "${timeout}", unit: 'MINUTES')
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800335 }
336 environment {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000337 KUBECONFIG="$HOME/.kube/kind-${clusterName}"
338 VOLTCONFIG="$HOME/.volt/config"
339 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Hardik Windlassec9341b2021-06-07 11:58:29 +0000340 DIAGS_PROFILE="VOLTHA_PROFILE"
Matteo Scandolo35ac7822021-10-28 18:08:54 -0700341 SSHPASS="karaf"
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800342 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000343 stages {
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800344 stage('Download Code') {
345 steps {
346 getVolthaCode([
347 branch: "${branch}",
348 gerritProject: "${gerritProject}",
349 gerritRefspec: "${gerritRefspec}",
350 volthaSystemTestsChange: "${volthaSystemTestsChange}",
351 volthaHelmChartsChange: "${volthaHelmChartsChange}",
352 ])
353 }
354 }
Joey Armstrong84adc542023-04-11 14:47:34 -0400355
356 stage('Build patch v1.1')
357 {
358 // build the patch only if gerritProject is specified
359 when
360 {
361 expression
362 {
363 return !gerritProject.isEmpty()
364 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000365 }
Joey Armstrong06a68372023-07-24 16:37:16 -0400366
Joey Armstrong97a8b882023-08-02 16:08:52 -0400367 steps
368 {
369 // NOTE that the correct patch has already been checked out
370 // during the getVolthaCode step
371 buildVolthaComponent("${gerritProject}")
Joey Armstrong06a68372023-07-24 16:37:16 -0400372 }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800373 }
Joey Armstronged161f72023-04-11 13:16:59 -0400374
Joey Armstrong97a8b882023-08-02 16:08:52 -0400375 // -----------------------------------------------------------------------
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400376 // -----------------------------------------------------------------------
377 stage ('Install Kail')
378 {
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400379 steps
380 {
381 script
382 {
383 String cmd = [
384 'make',
Joey Armstrong9f184d32023-08-03 11:34:48 -0400385 '--no-print-directory',
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400386 '-C', "$WORKSPACE/voltha-system-tests",
387 "KAIL_PATH=\"$WORKSPACE/bin\"",
388 'kail',
389 ].join(' ')
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400390
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400391 println(" ** Running: ${cmd}:\n")
392 sh("${cmd}")
393 } // script
394 } // steps
395 } // stage
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400396
397 // -----------------------------------------------------------------------
Joey Armstrong97a8b882023-08-02 16:08:52 -0400398 // -----------------------------------------------------------------------
399 stage ('Install Kind')
400 {
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400401 steps
402 {
403 script
404 {
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400405
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400406 String cmd = [
407 'make',
Joey Armstrong9f184d32023-08-03 11:34:48 -0400408 '--no-print-directory',
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400409 '-C', "$WORKSPACE/voltha-system-tests",
410 "KIND_PATH=\"$WORKSPACE/bin\"",
411 'install-command-kind',
412 ].join(' ')
413
414 println(" ** Running: ${cmd}:\n")
415 sh("${cmd}")
416 } // script
417 } // steps
418 } // stage
Joey Armstrong97a8b882023-08-02 16:08:52 -0400419
420 // -----------------------------------------------------------------------
421 // -----------------------------------------------------------------------
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400422 stage('Create K8s Cluster')
423 {
Joey Armstrongf076c312023-08-01 17:17:10 -0400424 steps
425 {
426 script
Joey Armstrong84adc542023-04-11 14:47:34 -0400427 {
Joey Armstrong97a8b882023-08-02 16:08:52 -0400428 def clusterExists = sh(
Joey Armstrongf076c312023-08-01 17:17:10 -0400429 returnStdout: true,
430 script: """kind get clusters | grep "${clusterName}" | wc -l""")
Joey Armstrongbf492922023-04-13 17:05:09 -0400431
Joey Armstrongf076c312023-08-01 17:17:10 -0400432 if (clusterExists.trim() == "0")
433 {
434 createKubernetesCluster([nodes: 3, name: clusterName])
435 }
436 } // script
437 } // steps
438 } // stage('Create K8s Cluster')
Joey Armstrong84adc542023-04-11 14:47:34 -0400439
Joey Armstrong97a8b882023-08-02 16:08:52 -0400440 // -----------------------------------------------------------------------
441 // -----------------------------------------------------------------------
442 stage('Replace voltctl')
443 {
444 // if the project is voltctl, override the downloaded one with the built one
445 when {
446 expression {
447 return gerritProject == "voltctl"
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400448 }
Matteo Scandolo29597f02021-02-12 10:53:57 -0800449 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400450
Joey Armstrong97a8b882023-08-02 16:08:52 -0400451 // Hmmmm(?) where did the voltctl download happen ?
452 // Likely Makefile but would be helpful to document here.
453 steps
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400454 {
Joey Armstrong97a8b882023-08-02 16:08:52 -0400455 println("${iam} Running: installVoltctl($branch)")
456 installVoltctl("$branch")
457 } // steps
458 } // stage
459
460 // -----------------------------------------------------------------------
461 // -----------------------------------------------------------------------
462 stage('Load image in kind nodes')
463 {
464 when {
465 expression {
466 return !gerritProject.isEmpty()
467 }
468 }
469 steps {
470 loadToKind()
471 } // steps
472 } // stage
473
474 // -----------------------------------------------------------------------
475 // -----------------------------------------------------------------------
476 stage('Parse and execute tests')
477 {
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400478 steps {
479 script {
480 def tests = readYaml text: testTargets
481
482 for(int i = 0;i<tests.size();i++) {
483 def test = tests[i]
484 def target = test["target"]
485 def workflow = test["workflow"]
486 def flags = test["flags"]
487 def teardown = test["teardown"].toBoolean()
488 def logging = test["logging"].toBoolean()
489 def testLogging = 'False'
490 if (logging) {
491 testLogging = 'True'
492 }
493 println "Executing test ${target} on workflow ${workflow} with logging ${testLogging} and extra flags ${flags}"
494 execute_test(target, workflow, testLogging, teardown, flags)
495 }
496 }
497 }
498 } // stage
499 } // stages
Joey Armstrong84adc542023-04-11 14:47:34 -0400500
501 post
502 {
503 aborted { collectArtifacts('aborted') }
504 failure { collectArtifacts('failed') }
Joey Armstrongbf492922023-04-13 17:05:09 -0400505 always { collectArtifacts('always') }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800506 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400507} // pipeline
Joey Armstronged161f72023-04-11 13:16:59 -0400508
509// EOF