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