Joey Armstrong | 56fdfec | 2024-03-01 13:43:36 -0500 | [diff] [blame] | 1 | // ----------------------------------------------------------------------- |
| 2 | // Copyright 2021-2024 Open Networking Foundation Contributors |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
Joey Armstrong | 56fdfec | 2024-03-01 13:43:36 -0500 | [diff] [blame] | 15 | // ----------------------------------------------------------------------- |
| 16 | // SPDX-FileCopyrightText: 2021-2024 Open Networking Foundation Contributors |
| 17 | // SPDX-License-Identifier: Apache-2.0 |
| 18 | // ----------------------------------------------------------------------- |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 19 | // voltha-2.x e2e tests for openonu-go |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 20 | // uses bbsim to simulate OLT/ONUs |
Joey Armstrong | 56fdfec | 2024-03-01 13:43:36 -0500 | [diff] [blame] | 21 | // ----------------------------------------------------------------------- |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 22 | |
Joey Armstrong | bccfa4b | 2023-09-27 17:34:22 -0400 | [diff] [blame] | 23 | // [TODO] Update library() to the latest DSL syntax supported by jenkins |
Matteo Scandolo | a156b57 | 2021-02-04 11:52:18 -0800 | [diff] [blame] | 24 | library identifier: 'cord-jenkins-libraries@master', |
| 25 | retriever: modernSCM([ |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 26 | $class: 'GitSCMSource', |
| 27 | remote: 'https://gerrit.opencord.org/ci-management.git' |
Matteo Scandolo | a156b57 | 2021-02-04 11:52:18 -0800 | [diff] [blame] | 28 | ]) |
| 29 | |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 30 | //------------------// |
| 31 | //---] GLOBAL [---// |
| 32 | //------------------// |
Joey Armstrong | e9725b1 | 2023-08-28 18:15:12 -0400 | [diff] [blame] | 33 | String clusterName = 'kind-ci' |
Joey Armstrong | f076c31 | 2023-08-01 17:17:10 -0400 | [diff] [blame] | 34 | |
| 35 | // ----------------------------------------------------------------------- |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 36 | // Intent: Return branch name for the script. A hardcoded value is used |
| 37 | // as a guarantee release jobs are running in an expected sandbox. |
Joey Armstrong | f076c31 | 2023-08-01 17:17:10 -0400 | [diff] [blame] | 38 | // ----------------------------------------------------------------------- |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 39 | String branchName() { |
Eric Ball | 0885465 | 2024-11-01 16:59:40 -0700 | [diff] [blame] | 40 | String br = 'python312-update' |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 41 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 42 | // "${branch}" is assigned by jenkins |
| 43 | if (br != branch) { |
| 44 | String err = [ |
| 45 | 'ERROR: Detected invalid branch', |
Roger Luethi | 92354bf | 2023-10-05 09:22:19 +0200 | [diff] [blame] | 46 | "(expected=[${br}] != found=[${branch}])" |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 47 | ].join(' ') |
| 48 | throw new Exception(err) // groovylint-disable-line ThrowException |
| 49 | } |
| 50 | |
| 51 | return (br) |
Joey Armstrong | f076c31 | 2023-08-01 17:17:10 -0400 | [diff] [blame] | 52 | } |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 53 | |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 54 | // ----------------------------------------------------------------------- |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 55 | // Intent: Due to lack of a reliable stack trace, construct a literal. |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 56 | // Jenkins will re-write the call stack for serialization.S |
| 57 | // ----------------------------------------------------------------------- |
| 58 | // Note: Hardcoded version string used to visualize changes in jenkins UI |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 59 | // ----------------------------------------------------------------------- |
Joey Armstrong | 97a8b88 | 2023-08-02 16:08:52 -0400 | [diff] [blame] | 60 | String getIam(String func) { |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 61 | String branchName = branchName() |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 62 | String src = [ |
| 63 | 'ci-management', |
| 64 | 'jjb', |
| 65 | 'pipeline', |
| 66 | 'voltha', |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 67 | branchName, |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 68 | 'bbsim-tests.groovy' |
| 69 | ].join('/') |
| 70 | |
Joey Armstrong | bccfa4b | 2023-09-27 17:34:22 -0400 | [diff] [blame] | 71 | String name = [src, func].join('::') |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 72 | return(name) |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | // ----------------------------------------------------------------------- |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 76 | // Intent: Log progress message |
| 77 | // ----------------------------------------------------------------------- |
| 78 | void enter(String name) { |
| 79 | // Announce ourselves for log usability |
| 80 | String iam = getIam(name) |
| 81 | println("${iam}: ENTER") |
| 82 | return |
| 83 | } |
| 84 | |
| 85 | // ----------------------------------------------------------------------- |
| 86 | // Intent: Log progress message |
| 87 | // ----------------------------------------------------------------------- |
| 88 | void leave(String name) { |
| 89 | // Announce ourselves for log usability |
| 90 | String iam = getIam(name) |
| 91 | println("${iam}: LEAVE") |
| 92 | return |
| 93 | } |
| 94 | |
| 95 | // ----------------------------------------------------------------------- |
Joey Armstrong | f023276 | 2024-02-11 17:23:04 -0500 | [diff] [blame] | 96 | // Intent: Display a message with visibility for logging |
| 97 | // ----------------------------------------------------------------------- |
| 98 | String banner(String message) { |
| 99 | String iam = getIam('banner') |
| 100 | |
| 101 | println(""" |
| 102 | |
| 103 | ** ----------------------------------------------------------------------- |
| 104 | ** IAM: $iam |
| 105 | ** ${message} |
| 106 | ** ----------------------------------------------------------------------- |
| 107 | """) |
| 108 | return |
| 109 | } |
| 110 | |
| 111 | // ----------------------------------------------------------------------- |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 112 | // Intent: Determine if working on a release branch. |
| 113 | // Note: Conditional is legacy, should also check for *-dev or *-pre |
| 114 | // ----------------------------------------------------------------------- |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 115 | Boolean isReleaseBranch(String name) { |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 116 | // List modifiers = ['-dev', '-pre', 'voltha-x.y.z-pre'] |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 117 | // if branchName in modifiers |
Eric Ball | 0885465 | 2024-11-01 16:59:40 -0700 | [diff] [blame] | 118 | return(name != 'master' && name != 'python312-update') // OR branchName.contains('-') |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | // ----------------------------------------------------------------------- |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 122 | // Intent: Terminate orphaned port-forward from different namespaces |
| 123 | // ----------------------------------------------------------------------- |
| 124 | void cleanupPortForward() { |
| 125 | enter('cleanupPortForward') |
| 126 | |
| 127 | Map pkpfArgs =\ |
| 128 | [ |
| 129 | 'banner' : true, // display banner for logging |
| 130 | 'show_procs' : true, // display procs under consideration |
| 131 | 'filler' : true // fix conditional trailing comma |
| 132 | ] |
| 133 | |
| 134 | // 'kubectl.*port-forward' |
| 135 | pkill_port_forward('port-forward', pkpfArgs) |
| 136 | leave('cleanupPortForward') |
| 137 | return |
| 138 | } |
| 139 | |
Joey Armstrong | bccfa4b | 2023-09-27 17:34:22 -0400 | [diff] [blame] | 140 | // find . \( -name 'log*.html' -o -name 'output*.xml' -o -name 'report*.html' \) -p |
| 141 | // ----------------------------------------------------------------------- |
| 142 | // Intent: Display contents of the logs directory |
| 143 | // ----------------------------------------------------------------------- |
| 144 | // [TODO] |
| 145 | // o where-4-art-thou logs directory ? |
| 146 | // o Replace find {logfile} command with /bin/ls {logdir} when found. |
| 147 | // Individual logs may be missing due to failure, show what is available. |
| 148 | // ----------------------------------------------------------------------- |
| 149 | void findPublishedLogs() { |
| 150 | String iam = 'findPublishedLogs' |
| 151 | |
| 152 | enter(iam) |
| 153 | sh(label : iam, |
| 154 | script : """ |
| 155 | find . -name 'output.xml' -print |
| 156 | """) |
| 157 | leave(iam) |
| 158 | return |
| 159 | } |
| 160 | |
| 161 | // ----------------------------------------------------------------------- |
| 162 | // Intent: Terminate kail-startup process launched earlier |
| 163 | // ----------------------------------------------------------------------- |
| 164 | // :param caller: Name of parent calling function (debug context) |
| 165 | // :type caller: String, optional |
| 166 | // :returns: none |
| 167 | // :rtype: void |
| 168 | // ----------------------------------------------------------------------- |
| 169 | void killKailStartup(String caller='') { |
| 170 | String iam = "killKailStartup (caller=$caller)" |
| 171 | |
| 172 | enter(iam) |
| 173 | sh(label : 'Terminate kail-startup', |
| 174 | script : """ |
| 175 | if [[ \$(pgrep --count '_TAG=kail-startup') -gt 0 ]]; then |
| 176 | pkill --uid \$(id -u) --echo --list-full --full '_TAG=kail-startup' |
| 177 | fi |
| 178 | """) |
| 179 | leave(iam) |
| 180 | return |
| 181 | } |
| 182 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 183 | // ----------------------------------------------------------------------- |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 184 | // Intent: Iterate over a list of test suites and invoke. |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 185 | // ----------------------------------------------------------------------- |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 186 | void execute_test\ |
| 187 | ( |
| 188 | String testTarget, // functional-single-kind-dt |
| 189 | String workflow, // dt |
| 190 | String testLogging, // 'True' |
| 191 | Boolean teardown, // true |
| 192 | String testSpecificHelmFlags='' |
| 193 | ) { |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 194 | String infraNamespace = 'default' |
| 195 | String volthaNamespace = 'voltha' |
| 196 | String logsDir = "$WORKSPACE/${testTarget}" |
Joey Armstrong | 293e16b | 2022-11-26 20:16:33 -0500 | [diff] [blame] | 197 | |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 198 | // ----------------------------------------------------------------------- |
Joey Armstrong | 268442d | 2023-08-22 17:16:10 -0400 | [diff] [blame] | 199 | // Intent: Cleanup stale port-forwarding |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 200 | // ----------------------------------------------------------------------- |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 201 | stage('Cleanup') { |
| 202 | if (teardown) { |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 203 | timeout(15) { |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 204 | script { |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 205 | helmTeardown(['default', infraNamespace, volthaNamespace]) |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 206 | } |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 207 | } // timeout |
| 208 | |
| 209 | timeout(5) { |
| 210 | script { |
| 211 | enter('Cleanup') |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 212 | cleanupPortForward() |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 213 | leave('Cleanup') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 214 | } // script |
| 215 | } // timeout |
| 216 | } // teardown |
| 217 | } // stage('Cleanup') |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 218 | |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 219 | // ----------------------------------------------------------------------- |
| 220 | // ----------------------------------------------------------------------- |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 221 | stage('Deploy common infrastructure') { |
| 222 | script { |
| 223 | local dashargs = [ |
| 224 | 'kpi_exporter.enabled=false', |
| 225 | 'dashboards.xos=false', |
| 226 | 'dashboards.onos=false', |
| 227 | 'dashboards.aaa=false', |
| 228 | 'dashboards.voltha=false', |
| 229 | ].join(',') |
| 230 | |
| 231 | local promargs = [ |
| 232 | 'prometheus.alertmanager.enabled=false', |
| 233 | 'prometheus.pushgateway.enabled=false', |
| 234 | ].join(',') |
| 235 | |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 236 | sh(label : 'Deploy common infrastructure', |
| 237 | script : """ |
Hardik Windlass | e166049 | 2022-03-14 15:12:46 +0000 | [diff] [blame] | 238 | helm repo add onf https://charts.opencord.org |
| 239 | helm repo update |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 240 | |
| 241 | echo -e "\nwithMonitoring=[$withMonitoring]" |
Hardik Windlass | e166049 | 2022-03-14 15:12:46 +0000 | [diff] [blame] | 242 | if [ ${withMonitoring} = true ] ; then |
| 243 | helm install nem-monitoring onf/nem-monitoring \ |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 244 | --set ${promargs} \ |
| 245 | --set ${dashargs} |
Hardik Windlass | e166049 | 2022-03-14 15:12:46 +0000 | [diff] [blame] | 246 | fi |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 247 | """) |
| 248 | } // script |
| 249 | } // stage('Deploy Common Infra') |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 250 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 251 | // ----------------------------------------------------------------------- |
| 252 | // [TODO] Check onos_log output |
| 253 | // ----------------------------------------------------------------------- |
| 254 | stage('Deploy Voltha') { |
| 255 | if (teardown) { |
| 256 | timeout(10) { |
| 257 | script { |
| 258 | String iam = getIam('Deploy Voltha') |
| 259 | String onosLog = "${logsDir}/onos-voltha-startup-combined.log" |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 260 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 261 | sh(label : 'Launch kail-startup', |
| 262 | script : """ |
| 263 | mkdir -p "$logsDir" |
| 264 | touch "$onosLog" |
Joey Armstrong | f404b64 | 2023-08-04 14:39:13 -0400 | [diff] [blame] | 265 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 266 | _TAG=kail-startup kail -n ${infraNamespace} -n ${volthaNamespace} > "$onosLog" & |
| 267 | """) |
| 268 | |
| 269 | // if we're downloading a voltha-helm-charts patch, |
| 270 | // install from a local copy of the charts |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 271 | Boolean localCharts = false |
Joey Armstrong | f404b64 | 2023-08-04 14:39:13 -0400 | [diff] [blame] | 272 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 273 | if (volthaHelmChartsChange != '' |
| 274 | || gerritProject == 'voltha-helm-charts' |
| 275 | || isReleaseBranch(branch) // branch != 'master' |
| 276 | ) { |
| 277 | localCharts = true |
| 278 | } |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 279 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 280 | String branchName = branchName() |
| 281 | Boolean isRelease = isReleaseBranch(branch) |
| 282 | println([ |
| 283 | " ** localCharts=${localCharts}", |
| 284 | "branchName=${branchName}", |
| 285 | "branch=${branch}", |
| 286 | "branch=isReleaseBranch=${isRelease}", |
| 287 | ].join(', ')) |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 288 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 289 | // ----------------------------------------------------------------------- |
| 290 | // Rewrite localHelmFlags using array join, moving code around and |
| 291 | // refactoring into standalone functions |
| 292 | // ----------------------------------------------------------------------- |
| 293 | // NOTE temporary workaround expose ONOS node ports |
| 294 | // ----------------------------------------------------------------------- |
| 295 | String localHelmFlags = [ |
| 296 | extraHelmFlags.trim(), |
| 297 | "--set global.log_level=${logLevel.toUpperCase()}", |
| 298 | '--set onos-classic.onosSshPort=30115', |
| 299 | '--set onos-classic.onosApiPort=30120', |
| 300 | '--set onos-classic.onosOfPort=31653', |
| 301 | '--set onos-classic.individualOpenFlowNodePorts=true', |
| 302 | testSpecificHelmFlags |
| 303 | ].join(' ') |
Joey Armstrong | 28e86ee | 2023-08-03 15:22:29 -0400 | [diff] [blame] | 304 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 305 | println("** ${iam} localHelmFlags = ${localHelmFlags}") |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 306 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 307 | if (gerritProject != '') { |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 308 | localHelmFlags += getVolthaImageFlags(gerritProject) |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 309 | } |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 310 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 311 | enter('volthaDeploy') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 312 | volthaDeploy([ |
| 313 | infraNamespace: infraNamespace, |
| 314 | volthaNamespace: volthaNamespace, |
| 315 | workflow: workflow.toLowerCase(), |
| 316 | withMacLearning: enableMacLearning.toBoolean(), |
| 317 | extraHelmFlags: localHelmFlags, |
| 318 | localCharts: localCharts, |
| 319 | bbsimReplica: olts.toInteger(), |
| 320 | dockerRegistry: registry, |
| 321 | ]) |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 322 | leave('volthaDeploy') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 323 | } // script |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 324 | |
Joey Armstrong | 1b7cc79 | 2023-09-26 14:19:21 -0400 | [diff] [blame] | 325 | // Display spawned procs |
| 326 | script { |
| 327 | enter('bbsim-tests::pgrep_port_forward::0') |
| 328 | pgrep_port_forward('port-forw') |
| 329 | leave('bbsim-tests::pgrep_port_forward::0') |
Joey Armstrong | bccfa4b | 2023-09-27 17:34:22 -0400 | [diff] [blame] | 330 | |
| 331 | killKailStartup('Deploy Voltha') |
Joey Armstrong | 1b7cc79 | 2023-09-26 14:19:21 -0400 | [diff] [blame] | 332 | } |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 333 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 334 | // ----------------------------------------------------------------------- |
| 335 | // Bundle onos-voltha / kail logs |
| 336 | // ----------------------------------------------------------------------- |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 337 | sh( |
| 338 | label : 'Bundle logs: onos-voltha-startup-combined', |
| 339 | script : """ |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 340 | cat <<EOM |
| 341 | |
| 342 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 7ba23ac | 2023-08-29 15:21:53 -0400 | [diff] [blame] | 343 | ** Combine and compress voltha startup log(s) |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 344 | ** ----------------------------------------------------------------------- |
| 345 | EOM |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 346 | |
| 347 | pushd "${logsDir}" || { echo "ERROR: pushd $logsDir failed"; exit 1; } |
| 348 | gzip -k onos-voltha-startup-combined.log |
| 349 | rm onos-voltha-startup-combined.log |
| 350 | popd || { echo "ERROR: popd $logsDir failed"; exit 1; } |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 351 | """) |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 352 | } // timeout(10) |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 353 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 354 | // ----------------------------------------------------------------------- |
| 355 | // ----------------------------------------------------------------------- |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 356 | sh(label : 'while-true-port-forward', |
Roger Luethi | cebf79a | 2023-09-28 09:41:45 +0200 | [diff] [blame] | 357 | script : """ |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 358 | 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"& |
| 359 | bbsimDmiPortFwd=50075 |
| 360 | for i in {0..${olts.toInteger() - 1}}; do |
| 361 | 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"& |
| 362 | ((bbsimDmiPortFwd++)) |
| 363 | done |
Hardik Windlass | 3bb089a | 2022-03-22 17:56:03 +0000 | [diff] [blame] | 364 | if [ ${withMonitoring} = true ] ; then |
| 365 | 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"& |
| 366 | fi |
Joey Armstrong | 7ba23ac | 2023-08-29 15:21:53 -0400 | [diff] [blame] | 367 | # ps aux | grep port-forward |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 368 | """) |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 369 | // --------------------------------- |
| 370 | // Sanity check port-forward spawned |
| 371 | // --------------------------------- |
Joey Armstrong | 1b7cc79 | 2023-09-26 14:19:21 -0400 | [diff] [blame] | 372 | script { |
| 373 | enter('bbsim-tests::pgrep_port_forward::1') |
| 374 | pgrep_port_forward('port-forw') |
| 375 | leave('bbsim-tests::pgrep_port_forward::1') |
| 376 | } |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 377 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 378 | // setting ONOS log level |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 379 | script { |
| 380 | enter('setOnosLogLevels') |
| 381 | setOnosLogLevels([ |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 382 | onosNamespace: infraNamespace, |
| 383 | apps: [ |
| 384 | 'org.opencord.dhcpl2relay', |
| 385 | 'org.opencord.olt', |
| 386 | 'org.opencord.aaa', |
| 387 | 'org.opencord.maclearner', |
| 388 | 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager', |
| 389 | 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager' |
| 390 | ], |
| 391 | logLevel: logLevel |
| 392 | ]) |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 393 | leave('setOnosLogLevels') |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 394 | } // script |
| 395 | } // if (teardown) |
| 396 | } // stage('Deploy Voltha') |
| 397 | |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 398 | // ----------------------------------------------------------------------- |
| 399 | // ----------------------------------------------------------------------- |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 400 | stage("Run test ${testTarget} on workflow ${workflow}") { |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 401 | sh( |
| 402 | label : 'Monitor using mem_consumption.py', |
| 403 | script : """ |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 404 | echo -e "\n** Monitor using mem_consumption.py ?" |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 405 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 406 | if [ ${withMonitoring} = true ] ; then |
| 407 | cat <<EOM |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 408 | |
| 409 | ** ----------------------------------------------------------------------- |
| 410 | ** Monitoring memory usage with mem_consumption.py |
| 411 | ** ----------------------------------------------------------------------- |
| 412 | EOM |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 413 | mkdir -p "$WORKSPACE/voltha-pods-mem-consumption-${workflow}" |
| 414 | cd "$WORKSPACE/voltha-system-tests" |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 415 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 416 | echo '** Installing python virtualenv' |
| 417 | make venv-activate-patched |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 418 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 419 | # Collect initial memory consumption |
| 420 | set +u && source .venv/bin/activate && set -u |
| 421 | python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace} |
| 422 | fi |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 423 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 424 | echo -e '** Monitor memory consumption: LEAVE\n' |
| 425 | """) |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 426 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 427 | sh( |
| 428 | label : "make testTarget=[${testTarget}]", |
| 429 | script : """ |
| 430 | echo -e "\n** make testTarget=[${testTarget}]" |
| 431 | mkdir -p ${logsDir} |
| 432 | export ROBOT_MISC_ARGS="-d ${logsDir} ${params.extraRobotArgs} " |
| 433 | 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}" |
| 434 | export KVSTOREPREFIX=voltha/voltha_voltha |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 435 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 436 | make -C "$WORKSPACE/voltha-system-tests" ${testTarget} |
| 437 | """) |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 438 | |
| 439 | getPodsInfo("${logsDir}") |
| 440 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 441 | // [TODO] make conditional, bundle when logs are available |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 442 | sh( |
| 443 | label : 'Gather robot Framework logs', |
| 444 | script : """ |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 445 | echo -e '\n** Gather robot Framework logs: ENTER' |
Joey Armstrong | 7ba23ac | 2023-08-29 15:21:53 -0400 | [diff] [blame] | 446 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 447 | # set +e |
| 448 | # collect logs collected in the Robot Framework StartLogging keyword |
| 449 | cd "${logsDir}" |
Joey Armstrong | 7ba23ac | 2023-08-29 15:21:53 -0400 | [diff] [blame] | 450 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 451 | echo "** Available logs:" |
| 452 | /bin/ls -l "$logsDir" |
| 453 | echo |
Joey Armstrong | 7ba23ac | 2023-08-29 15:21:53 -0400 | [diff] [blame] | 454 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 455 | echo '** Bundle combined log' |
| 456 | gzip *-combined.log || true |
| 457 | rm -f *-combined.log || true |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 458 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 459 | echo -e '** Gather robot Framework logs: LEAVE\n' |
| 460 | """) |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 461 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 462 | // ----------------------------------------------------------------------- |
| 463 | // ----------------------------------------------------------------------- |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 464 | sh( |
| 465 | label : 'Monitor pod-mem-consumption', |
| 466 | script : """ |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 467 | echo -e '** Monitor pod-mem-consumption: ENTER' |
| 468 | if [ ${withMonitoring} = true ] ; then |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 469 | cat <<EOM |
| 470 | |
| 471 | ** ----------------------------------------------------------------------- |
| 472 | ** Monitoring pod-memory-consumption using mem_consumption.py |
| 473 | ** ----------------------------------------------------------------------- |
| 474 | EOM |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 475 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 476 | cd "$WORKSPACE/voltha-system-tests" |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 477 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 478 | echo '** Installing python virtualenv' |
| 479 | make venv-activate-patched |
| 480 | |
| 481 | # Collect memory consumption of voltha pods once all the tests are complete |
| 482 | set +u && source .venv/bin/activate && set -u |
| 483 | python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace} |
| 484 | fi |
| 485 | echo -e '** Monitor pod-mem-consumption: LEAVE\n' |
| 486 | """) |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 487 | } // stage |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 488 | |
| 489 | return |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 490 | } // execute_test() |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 491 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 492 | // ----------------------------------------------------------------------- |
| 493 | // ----------------------------------------------------------------------- |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 494 | void collectArtifacts(exitStatus) { |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 495 | script { |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 496 | enter("exitStatus=${exitStatus}") |
Joey Armstrong | f023276 | 2024-02-11 17:23:04 -0500 | [diff] [blame] | 497 | banner('collectArtifacts') |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 498 | } |
Joey Armstrong | daa1f0a | 2024-04-03 18:07:59 -0400 | [diff] [blame] | 499 | |
Joey Armstrong | cd41912 | 2023-08-07 14:56:39 -0400 | [diff] [blame] | 500 | getPodsInfo("$WORKSPACE/${exitStatus}") |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 501 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 502 | sh(label : 'kubectl logs > voltha.log', |
| 503 | script : """ |
| 504 | kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha \ |
| 505 | > $WORKSPACE/${exitStatus}/voltha.log |
| 506 | """) |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 507 | |
Joey Armstrong | cd41912 | 2023-08-07 14:56:39 -0400 | [diff] [blame] | 508 | archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html,**/voltha-pods-mem-consumption-att/*,**/voltha-pods-mem-consumption-dt/*,**/voltha-pods-mem-consumption-tt/*' |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 509 | |
Joey Armstrong | bccfa4b | 2023-09-27 17:34:22 -0400 | [diff] [blame] | 510 | script { killKailStartup('collectArtifacts') } |
| 511 | script { findPublishedLogs() } |
Joey Armstrong | 97a8b88 | 2023-08-02 16:08:52 -0400 | [diff] [blame] | 512 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 513 | enter('RobotPublisher') |
Joey Armstrong | cd41912 | 2023-08-07 14:56:39 -0400 | [diff] [blame] | 514 | step([$class: 'RobotPublisher', |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 515 | disableArchiveOutput: false, |
| 516 | logFileName: '**/*/log*.html', |
| 517 | otherFiles: '', |
| 518 | outputFileName: '**/*/output*.xml', |
| 519 | outputPath: '.', |
| 520 | passThreshold: 100, |
| 521 | reportFileName: '**/*/report*.html', |
| 522 | unstableThreshold: 0, |
| 523 | onlyCritical: true]) |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 524 | leave('RobotPublisher') |
Joey Armstrong | cd41912 | 2023-08-07 14:56:39 -0400 | [diff] [blame] | 525 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 526 | leave("exitStatus=${exitStatus}") |
Joey Armstrong | cd41912 | 2023-08-07 14:56:39 -0400 | [diff] [blame] | 527 | return |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 528 | } |
| 529 | |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 530 | // ----------------------------------------------------------------------- |
| 531 | // Intent: main |
| 532 | // ----------------------------------------------------------------------- |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 533 | pipeline { |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 534 | /* no label, executor is determined by JJB */ |
| 535 | agent { |
| 536 | label "${params.buildNode}" |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 537 | } |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 538 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 539 | options { |
| 540 | timeout(time: "${timeout}", unit: 'MINUTES') |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 541 | } |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 542 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 543 | environment { |
| 544 | KUBECONFIG = "$HOME/.kube/kind-${clusterName}" |
| 545 | VOLTCONFIG = "$HOME/.volt/config" |
| 546 | PATH = "$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 547 | DIAGS_PROFILE = 'VOLTHA_PROFILE' |
| 548 | SSHPASS = 'karaf' |
| 549 | } |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 550 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 551 | stages { |
Joey Armstrong | f392221 | 2024-07-22 17:11:02 -0400 | [diff] [blame] | 552 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 553 | stage('Download Code') { |
Joey Armstrong | f404b64 | 2023-08-04 14:39:13 -0400 | [diff] [blame] | 554 | steps { |
Joey Armstrong | def9c40 | 2024-01-30 18:05:29 -0500 | [diff] [blame] | 555 | enter('getVolthaCode') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 556 | getVolthaCode([ |
| 557 | branch: "${branch}", |
| 558 | gerritProject: "${gerritProject}", |
| 559 | gerritRefspec: "${gerritRefspec}", |
| 560 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 561 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 562 | ]) |
Joey Armstrong | def9c40 | 2024-01-30 18:05:29 -0500 | [diff] [blame] | 563 | leave('getVolthaCode') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 564 | } |
| 565 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 566 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 567 | stage('Build patch v1.1') { |
| 568 | // build the patch only if gerritProject is specified |
| 569 | when { |
| 570 | expression { return !gerritProject.isEmpty() } |
| 571 | } |
| 572 | |
| 573 | steps { |
Joey Armstrong | def9c40 | 2024-01-30 18:05:29 -0500 | [diff] [blame] | 574 | enter('buildVolthaComponent') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 575 | // NOTE that the correct patch has already been checked out |
| 576 | // during the getVolthaCode step |
| 577 | buildVolthaComponent("${gerritProject}") |
Joey Armstrong | def9c40 | 2024-01-30 18:05:29 -0500 | [diff] [blame] | 578 | leave('buildVolthaComponent') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 579 | } |
| 580 | } |
| 581 | |
| 582 | // ----------------------------------------------------------------------- |
| 583 | // ----------------------------------------------------------------------- |
| 584 | stage('Install Kail') |
| 585 | { |
| 586 | steps |
| 587 | { |
| 588 | script |
| 589 | { |
| 590 | String cmd = [ |
| 591 | 'make', |
| 592 | '--no-print-directory', |
| 593 | '-C', "$WORKSPACE/voltha-system-tests", |
| 594 | "KAIL_PATH=\"$WORKSPACE/bin\"", |
| 595 | 'kail', |
| 596 | ].join(' ') |
| 597 | |
| 598 | println(" ** Running: ${cmd}") |
| 599 | sh("${cmd}") |
| 600 | } // script |
| 601 | } // steps |
| 602 | } // stage |
| 603 | |
| 604 | // ----------------------------------------------------------------------- |
| 605 | // ----------------------------------------------------------------------- |
Joey Armstrong | f392221 | 2024-07-22 17:11:02 -0400 | [diff] [blame] | 606 | stage('Install kubectl') |
| 607 | { |
| 608 | steps |
| 609 | { |
| 610 | script |
| 611 | { |
| 612 | String cmd = [ |
| 613 | 'make', |
| 614 | '--no-print-directory', |
| 615 | '-C', "$WORKSPACE", |
| 616 | "KUBECTL_PATH=\"$WORKSPACE/bin\"", |
| 617 | 'kubectl', |
| 618 | ].join(' ') |
| 619 | |
| 620 | println(" ** Running: ${cmd}") |
| 621 | sh("${cmd}") |
| 622 | } // script |
| 623 | } // steps |
| 624 | } // stage |
| 625 | |
| 626 | // ----------------------------------------------------------------------- |
| 627 | // ----------------------------------------------------------------------- |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 628 | stage('Install Tools') { |
| 629 | steps { |
| 630 | script { |
| 631 | String branchName = branchName() |
| 632 | String iam = getIam('Install Tools') |
| 633 | |
| 634 | println("${iam}: ENTER (branch=$branch)") |
| 635 | installKind(branch) // needed early by stage(Cleanup) |
| 636 | println("${iam}: LEAVE (branch=$branch)") |
| 637 | } // script |
| 638 | } // steps |
| 639 | } // stage |
| 640 | |
| 641 | // ----------------------------------------------------------------------- |
| 642 | // ----------------------------------------------------------------------- |
| 643 | stage('Create K8s Cluster') { |
| 644 | steps { |
| 645 | script { |
| 646 | def clusterExists = sh( |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 647 | label : 'Create K8s Cluster', |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 648 | returnStdout: true, |
| 649 | script: """kind get clusters | grep "${clusterName}" | wc -l""") |
| 650 | |
| 651 | if (clusterExists.trim() == '0') { |
| 652 | createKubernetesCluster([nodes: 3, name: clusterName]) |
| 653 | } |
| 654 | } // script |
| 655 | } // steps |
| 656 | } // stage('Create K8s Cluster') |
| 657 | |
| 658 | // ----------------------------------------------------------------------- |
| 659 | // ----------------------------------------------------------------------- |
| 660 | stage('Replace voltctl') { |
| 661 | // if the project is voltctl, override the downloaded one with the built one |
| 662 | when { |
| 663 | expression { return gerritProject == 'voltctl' } |
| 664 | } |
| 665 | |
| 666 | // Hmmmm(?) where did the voltctl download happen ? |
| 667 | // Likely Makefile but would be helpful to document here. |
| 668 | steps { |
| 669 | script { |
| 670 | String iam = getIam('Replace voltctl') |
| 671 | |
| 672 | println("${iam} Running: installVoltctl($branch)") |
| 673 | println("${iam}: ENTER") |
| 674 | installVoltctl("$branch") |
| 675 | println("${iam}: LEAVE") |
| 676 | } // script |
| 677 | } // step |
| 678 | } // stage |
| 679 | |
| 680 | // ----------------------------------------------------------------------- |
| 681 | // ----------------------------------------------------------------------- |
| 682 | stage('Load image in kind nodes') |
| 683 | { |
| 684 | when { |
| 685 | expression { return !gerritProject.isEmpty() } |
| 686 | } |
| 687 | steps { |
| 688 | loadToKind() |
| 689 | } // steps |
| 690 | } // stage |
| 691 | |
| 692 | // ----------------------------------------------------------------------- |
| 693 | // [TODO] verify testing output |
| 694 | // ----------------------------------------------------------------------- |
| 695 | stage('Parse and execute tests') |
| 696 | { |
| 697 | steps { |
| 698 | script { |
| 699 | // Announce ourselves for log usability |
| 700 | enter('Parse and execute tests') |
| 701 | |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 702 | def tests = readYaml text: testTargets // typeof == Map (?) |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 703 | println("** [DEBUG]: tests=$tests") |
| 704 | |
| 705 | // Display expected tests for times when output goes dark |
| 706 | tests.eachWithIndex { test, idx -> |
| 707 | String target = test['target'] |
| 708 | println("** test[${idx}]: ${target}\n") |
| 709 | } |
| 710 | |
| 711 | println(''' |
| 712 | ** ----------------------------------------------------------------------- |
| 713 | ** NOTE: For odd/silent job failures verify a few details |
| 714 | ** - All tests mentioned in the tests-to-run index were logged. |
| 715 | ** - Test suites display ENTER/LEAVE mesasge pairs. |
| 716 | ** - Processing terminated prematurely when LEAVE strings are missing. |
| 717 | ** ----------------------------------------------------------------------- |
| 718 | ''') |
| 719 | tests.eachWithIndex { test, idx -> |
| 720 | println "** readYaml test suite[$idx]) test=[${test}]" |
| 721 | |
Joey Armstrong | f404b64 | 2023-08-04 14:39:13 -0400 | [diff] [blame] | 722 | String target = test['target'] |
| 723 | String workflow = test['workflow'] |
| 724 | String flags = test['flags'] |
| 725 | Boolean teardown = test['teardown'].toBoolean() |
| 726 | Boolean logging = test['logging'].toBoolean() |
| 727 | String testLogging = (logging) ? 'True' : 'False' |
| 728 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 729 | print(""" |
Joey Armstrong | 268442d | 2023-08-22 17:16:10 -0400 | [diff] [blame] | 730 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 731 | ** Executing test ${target} on workflow ${workflow} with logging ${testLogging} and extra flags ${flags} |
Joey Armstrong | 268442d | 2023-08-22 17:16:10 -0400 | [diff] [blame] | 732 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 268442d | 2023-08-22 17:16:10 -0400 | [diff] [blame] | 733 | """) |
| 734 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 735 | try { |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 736 | enter("execute_test (target=$target)") |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 737 | execute_test(target, workflow, testLogging, teardown, flags) |
| 738 | } |
Joey Armstrong | 9341c9a | 2023-08-28 12:09:19 -0400 | [diff] [blame] | 739 | // groovylint-disable-next-line CatchException |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 740 | catch (Exception err) { |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 741 | String iamexc = getIam(test) |
Joey Armstrong | 9341c9a | 2023-08-28 12:09:19 -0400 | [diff] [blame] | 742 | println("** ${iamexc}: EXCEPTION ${err}") |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 743 | } |
| 744 | finally { |
| 745 | leave("execute_test (target=$target)") |
| 746 | } |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 747 | } // for |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 748 | // Premature exit if this message is not logged |
| 749 | leave('Parse and execute tests') |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 750 | } // script |
| 751 | } // steps |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 752 | } // stage |
| 753 | } // stages |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 754 | |
| 755 | post |
Joey Armstrong | bccfa4b | 2023-09-27 17:34:22 -0400 | [diff] [blame] | 756 | { // https://www.jenkins.io/doc/book/pipeline/syntax/#post |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 757 | aborted { |
| 758 | collectArtifacts('aborted') |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 759 | } |
| 760 | failure { |
| 761 | collectArtifacts('failed') |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 762 | } |
| 763 | always { |
| 764 | collectArtifacts('always') |
Joey Armstrong | bccfa4b | 2023-09-27 17:34:22 -0400 | [diff] [blame] | 765 | } |
| 766 | cleanup { |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 767 | script { cleanupPortForward() } |
| 768 | } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 769 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 770 | } // pipeline |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 771 | |
Joey Armstrong | 664c55a | 2023-08-28 14:22:33 -0400 | [diff] [blame] | 772 | // [EOF] |