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