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 | 5353d31 | 2024-02-09 19:03:03 -0500 | [diff] [blame^] | 487 | dotkube(['debug':false]) |
Joey Armstrong | cd41912 | 2023-08-07 14:56:39 -0400 | [diff] [blame] | 488 | getPodsInfo("$WORKSPACE/${exitStatus}") |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 489 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 490 | sh(label : 'kubectl logs > voltha.log', |
| 491 | script : """ |
| 492 | kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha \ |
| 493 | > $WORKSPACE/${exitStatus}/voltha.log |
| 494 | """) |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 495 | |
Joey Armstrong | cd41912 | 2023-08-07 14:56:39 -0400 | [diff] [blame] | 496 | 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] | 497 | |
Joey Armstrong | bccfa4b | 2023-09-27 17:34:22 -0400 | [diff] [blame] | 498 | script { killKailStartup('collectArtifacts') } |
| 499 | script { findPublishedLogs() } |
Joey Armstrong | 97a8b88 | 2023-08-02 16:08:52 -0400 | [diff] [blame] | 500 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 501 | enter('RobotPublisher') |
Joey Armstrong | cd41912 | 2023-08-07 14:56:39 -0400 | [diff] [blame] | 502 | step([$class: 'RobotPublisher', |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 503 | disableArchiveOutput: false, |
| 504 | logFileName: '**/*/log*.html', |
| 505 | otherFiles: '', |
| 506 | outputFileName: '**/*/output*.xml', |
| 507 | outputPath: '.', |
| 508 | passThreshold: 100, |
| 509 | reportFileName: '**/*/report*.html', |
| 510 | unstableThreshold: 0, |
| 511 | onlyCritical: true]) |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 512 | leave('RobotPublisher') |
Joey Armstrong | cd41912 | 2023-08-07 14:56:39 -0400 | [diff] [blame] | 513 | |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 514 | leave("exitStatus=${exitStatus}") |
Joey Armstrong | cd41912 | 2023-08-07 14:56:39 -0400 | [diff] [blame] | 515 | return |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 516 | } |
| 517 | |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 518 | // ----------------------------------------------------------------------- |
| 519 | // Intent: main |
| 520 | // ----------------------------------------------------------------------- |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 521 | pipeline { |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 522 | /* no label, executor is determined by JJB */ |
| 523 | agent { |
| 524 | label "${params.buildNode}" |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 525 | } |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 526 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 527 | options { |
| 528 | timeout(time: "${timeout}", unit: 'MINUTES') |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 529 | } |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 530 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 531 | environment { |
| 532 | KUBECONFIG = "$HOME/.kube/kind-${clusterName}" |
| 533 | VOLTCONFIG = "$HOME/.volt/config" |
| 534 | PATH = "$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 535 | DIAGS_PROFILE = 'VOLTHA_PROFILE' |
| 536 | SSHPASS = 'karaf' |
| 537 | } |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 538 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 539 | stages { |
| 540 | stage('Download Code') { |
Joey Armstrong | f404b64 | 2023-08-04 14:39:13 -0400 | [diff] [blame] | 541 | steps { |
Joey Armstrong | def9c40 | 2024-01-30 18:05:29 -0500 | [diff] [blame] | 542 | enter('getVolthaCode') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 543 | getVolthaCode([ |
| 544 | branch: "${branch}", |
| 545 | gerritProject: "${gerritProject}", |
| 546 | gerritRefspec: "${gerritRefspec}", |
| 547 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 548 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 549 | ]) |
Joey Armstrong | def9c40 | 2024-01-30 18:05:29 -0500 | [diff] [blame] | 550 | leave('getVolthaCode') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 551 | } |
| 552 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 553 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 554 | stage('Build patch v1.1') { |
| 555 | // build the patch only if gerritProject is specified |
| 556 | when { |
| 557 | expression { return !gerritProject.isEmpty() } |
| 558 | } |
| 559 | |
| 560 | steps { |
Joey Armstrong | def9c40 | 2024-01-30 18:05:29 -0500 | [diff] [blame] | 561 | enter('buildVolthaComponent') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 562 | // NOTE that the correct patch has already been checked out |
| 563 | // during the getVolthaCode step |
| 564 | buildVolthaComponent("${gerritProject}") |
Joey Armstrong | def9c40 | 2024-01-30 18:05:29 -0500 | [diff] [blame] | 565 | leave('buildVolthaComponent') |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 566 | } |
| 567 | } |
| 568 | |
| 569 | // ----------------------------------------------------------------------- |
| 570 | // ----------------------------------------------------------------------- |
| 571 | stage('Install Kail') |
| 572 | { |
| 573 | steps |
| 574 | { |
| 575 | script |
| 576 | { |
| 577 | String cmd = [ |
| 578 | 'make', |
| 579 | '--no-print-directory', |
| 580 | '-C', "$WORKSPACE/voltha-system-tests", |
| 581 | "KAIL_PATH=\"$WORKSPACE/bin\"", |
| 582 | 'kail', |
| 583 | ].join(' ') |
| 584 | |
| 585 | println(" ** Running: ${cmd}") |
| 586 | sh("${cmd}") |
| 587 | } // script |
| 588 | } // steps |
| 589 | } // stage |
| 590 | |
| 591 | // ----------------------------------------------------------------------- |
| 592 | // ----------------------------------------------------------------------- |
| 593 | stage('Install Tools') { |
| 594 | steps { |
| 595 | script { |
| 596 | String branchName = branchName() |
| 597 | String iam = getIam('Install Tools') |
| 598 | |
| 599 | println("${iam}: ENTER (branch=$branch)") |
| 600 | installKind(branch) // needed early by stage(Cleanup) |
| 601 | println("${iam}: LEAVE (branch=$branch)") |
| 602 | } // script |
| 603 | } // steps |
| 604 | } // stage |
| 605 | |
| 606 | // ----------------------------------------------------------------------- |
| 607 | // ----------------------------------------------------------------------- |
| 608 | stage('Create K8s Cluster') { |
| 609 | steps { |
| 610 | script { |
| 611 | def clusterExists = sh( |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 612 | label : 'Create K8s Cluster', |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 613 | returnStdout: true, |
| 614 | script: """kind get clusters | grep "${clusterName}" | wc -l""") |
| 615 | |
| 616 | if (clusterExists.trim() == '0') { |
| 617 | createKubernetesCluster([nodes: 3, name: clusterName]) |
| 618 | } |
| 619 | } // script |
| 620 | } // steps |
| 621 | } // stage('Create K8s Cluster') |
| 622 | |
| 623 | // ----------------------------------------------------------------------- |
| 624 | // ----------------------------------------------------------------------- |
| 625 | stage('Replace voltctl') { |
| 626 | // if the project is voltctl, override the downloaded one with the built one |
| 627 | when { |
| 628 | expression { return gerritProject == 'voltctl' } |
| 629 | } |
| 630 | |
| 631 | // Hmmmm(?) where did the voltctl download happen ? |
| 632 | // Likely Makefile but would be helpful to document here. |
| 633 | steps { |
| 634 | script { |
| 635 | String iam = getIam('Replace voltctl') |
| 636 | |
| 637 | println("${iam} Running: installVoltctl($branch)") |
| 638 | println("${iam}: ENTER") |
| 639 | installVoltctl("$branch") |
| 640 | println("${iam}: LEAVE") |
| 641 | } // script |
| 642 | } // step |
| 643 | } // stage |
| 644 | |
| 645 | // ----------------------------------------------------------------------- |
| 646 | // ----------------------------------------------------------------------- |
| 647 | stage('Load image in kind nodes') |
| 648 | { |
| 649 | when { |
| 650 | expression { return !gerritProject.isEmpty() } |
| 651 | } |
| 652 | steps { |
| 653 | loadToKind() |
| 654 | } // steps |
| 655 | } // stage |
| 656 | |
| 657 | // ----------------------------------------------------------------------- |
| 658 | // [TODO] verify testing output |
| 659 | // ----------------------------------------------------------------------- |
| 660 | stage('Parse and execute tests') |
| 661 | { |
| 662 | steps { |
| 663 | script { |
| 664 | // Announce ourselves for log usability |
| 665 | enter('Parse and execute tests') |
| 666 | |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 667 | def tests = readYaml text: testTargets // typeof == Map (?) |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 668 | println("** [DEBUG]: tests=$tests") |
| 669 | |
| 670 | // Display expected tests for times when output goes dark |
| 671 | tests.eachWithIndex { test, idx -> |
| 672 | String target = test['target'] |
| 673 | println("** test[${idx}]: ${target}\n") |
| 674 | } |
| 675 | |
| 676 | println(''' |
| 677 | ** ----------------------------------------------------------------------- |
| 678 | ** NOTE: For odd/silent job failures verify a few details |
| 679 | ** - All tests mentioned in the tests-to-run index were logged. |
| 680 | ** - Test suites display ENTER/LEAVE mesasge pairs. |
| 681 | ** - Processing terminated prematurely when LEAVE strings are missing. |
| 682 | ** ----------------------------------------------------------------------- |
| 683 | ''') |
| 684 | tests.eachWithIndex { test, idx -> |
| 685 | println "** readYaml test suite[$idx]) test=[${test}]" |
| 686 | |
Joey Armstrong | f404b64 | 2023-08-04 14:39:13 -0400 | [diff] [blame] | 687 | String target = test['target'] |
| 688 | String workflow = test['workflow'] |
| 689 | String flags = test['flags'] |
| 690 | Boolean teardown = test['teardown'].toBoolean() |
| 691 | Boolean logging = test['logging'].toBoolean() |
| 692 | String testLogging = (logging) ? 'True' : 'False' |
| 693 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 694 | print(""" |
Joey Armstrong | 268442d | 2023-08-22 17:16:10 -0400 | [diff] [blame] | 695 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 696 | ** 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] | 697 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 268442d | 2023-08-22 17:16:10 -0400 | [diff] [blame] | 698 | """) |
| 699 | |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 700 | try { |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 701 | enter("execute_test (target=$target)") |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 702 | execute_test(target, workflow, testLogging, teardown, flags) |
| 703 | } |
Joey Armstrong | 9341c9a | 2023-08-28 12:09:19 -0400 | [diff] [blame] | 704 | // groovylint-disable-next-line CatchException |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 705 | catch (Exception err) { |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 706 | String iamexc = getIam(test) |
Joey Armstrong | 9341c9a | 2023-08-28 12:09:19 -0400 | [diff] [blame] | 707 | println("** ${iamexc}: EXCEPTION ${err}") |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 708 | } |
| 709 | finally { |
| 710 | leave("execute_test (target=$target)") |
| 711 | } |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 712 | } // for |
Joey Armstrong | 0251e96 | 2023-08-25 20:51:31 -0400 | [diff] [blame] | 713 | // Premature exit if this message is not logged |
| 714 | leave('Parse and execute tests') |
Joey Armstrong | b65ada3 | 2023-08-03 12:50:20 -0400 | [diff] [blame] | 715 | } // script |
| 716 | } // steps |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 717 | } // stage |
| 718 | } // stages |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 719 | |
| 720 | post |
Joey Armstrong | bccfa4b | 2023-09-27 17:34:22 -0400 | [diff] [blame] | 721 | { // https://www.jenkins.io/doc/book/pipeline/syntax/#post |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 722 | aborted { |
| 723 | collectArtifacts('aborted') |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 724 | } |
| 725 | failure { |
| 726 | collectArtifacts('failed') |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 727 | } |
| 728 | always { |
| 729 | collectArtifacts('always') |
Joey Armstrong | bccfa4b | 2023-09-27 17:34:22 -0400 | [diff] [blame] | 730 | } |
| 731 | cleanup { |
Joey Armstrong | 9f66e3f | 2023-09-20 16:29:29 -0400 | [diff] [blame] | 732 | script { cleanupPortForward() } |
| 733 | } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 734 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 735 | } // pipeline |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 736 | |
Joey Armstrong | 664c55a | 2023-08-28 14:22:33 -0400 | [diff] [blame] | 737 | // [EOF] |