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