Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 1 | // Copyright 2021-2023 Open Networking Foundation (ONF) and the ONF Contributors |
| 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 | |
| 15 | // voltha-2.x e2e tests for openonu-go |
| 16 | // uses bbsim to simulate OLT/ONUs |
| 17 | |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 18 | // [TODO] Update syntax below to the latest supported |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 19 | library identifier: 'cord-jenkins-libraries@master', |
| 20 | retriever: modernSCM([ |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 21 | $class: 'GitSCMSource', |
| 22 | remote: 'https://gerrit.opencord.org/ci-management.git' |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 23 | ]) |
| 24 | |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -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 | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 29 | |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 30 | // ----------------------------------------------------------------------- |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -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 | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 33 | // ----------------------------------------------------------------------- |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 34 | String branchName() { |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 35 | String br = 'voltha-2.12' |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 36 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -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 CatchException |
| 44 | } |
| 45 | |
| 46 | return (br) |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | // ----------------------------------------------------------------------- |
Joey Armstrong | af4eef2 | 2023-08-25 16:14:45 -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 | // ----------------------------------------------------------------------- |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 54 | String pipelineVer() { |
| 55 | String version = '2563719757ee52af49cf9da3fe76ed4bb6877588' |
Joey Armstrong | af4eef2 | 2023-08-25 16:14:45 -0400 | [diff] [blame] | 56 | return(version) |
| 57 | } |
| 58 | |
| 59 | // ----------------------------------------------------------------------- |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 60 | // Intent: Due to lack of a reliable stack trace, construct a literal. |
Joey Armstrong | d0b5af0 | 2023-08-25 15:12:54 -0400 | [diff] [blame] | 61 | // Jenkins will re-write the call stack for serialization.S |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 62 | // ----------------------------------------------------------------------- |
Joey Armstrong | d0b5af0 | 2023-08-25 15:12:54 -0400 | [diff] [blame] | 63 | // Note: Hardcoded version string used to visualize changes in jenkins UI |
| 64 | // ----------------------------------------------------------------------- |
Joey Armstrong | af4eef2 | 2023-08-25 16:14:45 -0400 | [diff] [blame] | 65 | String getIam(String func) { |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 66 | String branchName = branchName() |
Joey Armstrong | af4eef2 | 2023-08-25 16:14:45 -0400 | [diff] [blame] | 67 | String version = pipelineVer() |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 68 | String src = [ |
| 69 | 'ci-management', |
| 70 | 'jjb', |
| 71 | 'pipeline', |
| 72 | 'voltha', |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 73 | branchName, |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 74 | 'bbsim-tests.groovy' |
| 75 | ].join('/') |
| 76 | |
Joey Armstrong | d0b5af0 | 2023-08-25 15:12:54 -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) |
| 79 | } |
| 80 | |
| 81 | // ----------------------------------------------------------------------- |
Joey Armstrong | af4eef2 | 2023-08-25 16:14:45 -0400 | [diff] [blame] | 82 | // Intent: Log progress message |
| 83 | // ----------------------------------------------------------------------- |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 84 | void enter(String name) { |
Joey Armstrong | af4eef2 | 2023-08-25 16:14:45 -0400 | [diff] [blame] | 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 | // ----------------------------------------------------------------------- |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 94 | void leave(String name) { |
Joey Armstrong | af4eef2 | 2023-08-25 16:14:45 -0400 | [diff] [blame] | 95 | // Announce ourselves for log usability |
| 96 | String iam = getIam(name) |
| 97 | println("${iam}: LEAVE") |
| 98 | return |
| 99 | } |
| 100 | |
| 101 | // ----------------------------------------------------------------------- |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -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 | ec1ae0a | 2023-08-23 21:51:45 -0400 | [diff] [blame] | 105 | Boolean isReleaseBranch(String name) { |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 106 | // List modifiers = ['-dev', '-pre', 'voltha-x.y.z-pre'] |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 107 | // if branchName in modifiers |
| 108 | return(name != 'master') // OR branchName.contains('-') |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | // ----------------------------------------------------------------------- |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -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 | af4eef2 | 2023-08-25 16:14:45 -0400 | [diff] [blame] | 131 | // Intent: Iterate over a list of test suites and invoke. |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 132 | // ----------------------------------------------------------------------- |
Joey Armstrong | af4eef2 | 2023-08-25 16:14:45 -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 | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 141 | String infraNamespace = 'default' |
| 142 | String volthaNamespace = 'voltha' |
| 143 | String logsDir = "$WORKSPACE/${testTarget}" |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 144 | |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 145 | // ----------------------------------------------------------------------- |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 146 | // Intent: Cleanup stale port-forwarding |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 147 | // ----------------------------------------------------------------------- |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 148 | stage('Cleanup') { |
| 149 | if (teardown) { |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 150 | timeout(15) { |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 151 | script { |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 152 | helmTeardown(['default', infraNamespace, volthaNamespace]) |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 153 | } |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 154 | } // timeout |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 155 | |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 156 | timeout(5) { |
| 157 | script { |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 158 | enter('Cleanup') |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 159 | cleanupPortForward() |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 160 | leave('Cleanup') |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 161 | } // script |
| 162 | } // timeout |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 163 | } // teardown |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 164 | }// stage('Cleanup') |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 165 | |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 166 | // ----------------------------------------------------------------------- |
| 167 | // ----------------------------------------------------------------------- |
Joey Armstrong | ec1ae0a | 2023-08-23 21:51:45 -0400 | [diff] [blame] | 168 | stage('Deploy common infrastructure') { |
| 169 | script { |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 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 : """ |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 185 | helm repo add onf https://charts.opencord.org |
| 186 | helm repo update |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 187 | |
| 188 | echo -e "\nwithMonitoring=[$withMonitoring]" |
| 189 | if [ ${withMonitoring} = true ] ; then |
| 190 | helm install nem-monitoring onf/nem-monitoring \ |
Joey Armstrong | 38a8783 | 2023-08-23 17:02:50 -0400 | [diff] [blame] | 191 | --set ${promargs} \ |
| 192 | --set ${dashargs} |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 193 | fi |
Joey Armstrong | 38a8783 | 2023-08-23 17:02:50 -0400 | [diff] [blame] | 194 | """) |
| 195 | } // script |
| 196 | } // stage('Deploy Common Infra') |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 197 | |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 198 | // ----------------------------------------------------------------------- |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 199 | // [TODO] Check onos_log output |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 200 | // ----------------------------------------------------------------------- |
Joey Armstrong | ec1ae0a | 2023-08-23 21:51:45 -0400 | [diff] [blame] | 201 | stage('Deploy Voltha') { |
| 202 | if (teardown) { |
| 203 | timeout(10) { |
| 204 | script { |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 205 | String iam = getIam('Deploy Voltha') |
| 206 | String onosLog = "${logsDir}/onos-voltha-startup-combined.log" |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 207 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 208 | sh(label : 'Launch kail-startup', |
| 209 | script : """ |
| 210 | mkdir -p "$logsDir" |
| 211 | touch "$onosLog" |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 212 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -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 | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 218 | Boolean localCharts = false |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 219 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 220 | if (volthaHelmChartsChange != '' |
| 221 | || gerritProject == 'voltha-helm-charts' |
| 222 | || isReleaseBranch(branch) // branch != 'master' |
| 223 | ) { |
| 224 | localCharts = true |
| 225 | } |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 226 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -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(', ')) |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 235 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -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 | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 251 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 252 | println("** ${iam} localHelmFlags = ${localHelmFlags}") |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 253 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 254 | if (gerritProject != '') { |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 255 | localHelmFlags += getVolthaImageFlags(gerritProject) |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 256 | } |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 257 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 258 | enter('volthaDeploy') |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -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 | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 269 | leave('volthaDeploy') |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 270 | } // script |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 271 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 272 | script { pgrep_port_forward() } |
Joey Armstrong | dddbbf9 | 2023-08-22 16:00:41 -0400 | [diff] [blame] | 273 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 274 | sh(label : 'Terminate kail-startup', |
| 275 | script : """ |
Joey Armstrong | 12a8c83 | 2023-08-28 16:50:24 -0400 | [diff] [blame] | 276 | if [[ \$(pgrep --count '_TAG=kail-startup') -gt 0 ]]; then |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 277 | pkill --uid \$(uid -u) --echo --list-full --full '_TAG=kail-startup' |
Joey Armstrong | 12a8c83 | 2023-08-28 16:50:24 -0400 | [diff] [blame] | 278 | fi |
Joey Armstrong | 664c55a | 2023-08-28 14:22:33 -0400 | [diff] [blame] | 279 | """) |
| 280 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 281 | sh(label : 'Lingering kail-startup check', |
| 282 | script : """ |
| 283 | pgrep --uid \$(uid -u) --list-full --full 'kail-startup' || true |
Joey Armstrong | 664c55a | 2023-08-28 14:22:33 -0400 | [diff] [blame] | 284 | """) |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 285 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 286 | // ----------------------------------------------------------------------- |
| 287 | // Bundle onos-voltha / kail logs |
| 288 | // ----------------------------------------------------------------------- |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 289 | sh( |
| 290 | label : 'Bundle logs: onos-voltha-startup-combined', |
| 291 | script : """ |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 292 | cat <<EOM |
| 293 | |
| 294 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 7ba23ac | 2023-08-29 15:21:53 -0400 | [diff] [blame] | 295 | ** Combine and compress voltha startup log(s) |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 296 | ** ----------------------------------------------------------------------- |
| 297 | EOM |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 298 | |
| 299 | pushd "${logsDir}" || { echo "ERROR: pushd $logsDir failed"; exit 1; } |
| 300 | gzip -k onos-voltha-startup-combined.log |
| 301 | rm onos-voltha-startup-combined.log |
| 302 | popd || { echo "ERROR: popd $logsDir failed"; exit 1; } |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 303 | """) |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 304 | } // timeout(10) |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 305 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 306 | // ----------------------------------------------------------------------- |
| 307 | // ----------------------------------------------------------------------- |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 308 | sh(label : 'while-true-port-forward', |
| 309 | """ |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 310 | 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"& |
| 311 | 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"& |
| 312 | 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"& |
| 313 | bbsimDmiPortFwd=50075 |
| 314 | for i in {0..${olts.toInteger() - 1}}; do |
| 315 | 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"& |
| 316 | ((bbsimDmiPortFwd++)) |
| 317 | done |
| 318 | if [ ${withMonitoring} = true ] ; then |
| 319 | 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"& |
| 320 | fi |
Joey Armstrong | 7ba23ac | 2023-08-29 15:21:53 -0400 | [diff] [blame] | 321 | # ps aux | grep port-forward |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 322 | """) |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 323 | // --------------------------------- |
| 324 | // Sanity check port-forward spawned |
| 325 | // --------------------------------- |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 326 | // [TODO] - Wait until forwarding successful else fatal |
| 327 | script { pgrep_port_forward() } |
Joey Armstrong | 5d65efe | 2023-08-25 09:43:18 -0400 | [diff] [blame] | 328 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 329 | // setting ONOS log level |
| 330 | script { |
| 331 | enter('setOnosLogLevels') |
| 332 | setOnosLogLevels([ |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 333 | onosNamespace: infraNamespace, |
| 334 | apps: [ |
| 335 | 'org.opencord.dhcpl2relay', |
| 336 | 'org.opencord.olt', |
| 337 | 'org.opencord.aaa', |
| 338 | 'org.opencord.maclearner', |
| 339 | 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager', |
| 340 | 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager' |
| 341 | ], |
| 342 | logLevel: logLevel |
| 343 | ]) |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 344 | leave('setOnosLogLevels') |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 345 | } // script |
| 346 | } // if (teardown) |
| 347 | } // stage('Deploy Voltha') |
| 348 | |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 349 | // ----------------------------------------------------------------------- |
| 350 | // ----------------------------------------------------------------------- |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 351 | stage("Run test ${testTarget} on workflow ${workflow}") { |
Joey Armstrong | ebc1802 | 2023-08-26 13:20:49 -0400 | [diff] [blame] | 352 | sh( |
| 353 | label : 'Monitor using mem_consumption.py', |
| 354 | script : """ |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 355 | echo -e "\n** Monitor using mem_consumption.py ?" |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 356 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 357 | if [ ${withMonitoring} = true ] ; then |
| 358 | cat <<EOM |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 359 | |
| 360 | ** ----------------------------------------------------------------------- |
| 361 | ** Monitoring memory usage with mem_consumption.py |
| 362 | ** ----------------------------------------------------------------------- |
| 363 | EOM |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 364 | mkdir -p "$WORKSPACE/voltha-pods-mem-consumption-${workflow}" |
| 365 | cd "$WORKSPACE/voltha-system-tests" |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 366 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 367 | echo '** Installing python virtualenv' |
| 368 | make venv-activate-patched |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 369 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 370 | # Collect initial memory consumption |
| 371 | set +u && source .venv/bin/activate && set -u |
| 372 | python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace} |
| 373 | fi |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 374 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 375 | echo -e '** Monitor memory consumption: LEAVE\n' |
| 376 | """) |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 377 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 378 | sh( |
| 379 | label : "make testTarget=[${testTarget}]", |
| 380 | script : """ |
| 381 | echo -e "\n** make testTarget=[${testTarget}]" |
| 382 | mkdir -p ${logsDir} |
| 383 | export ROBOT_MISC_ARGS="-d ${logsDir} ${params.extraRobotArgs} " |
| 384 | 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}" |
| 385 | export KVSTOREPREFIX=voltha/voltha_voltha |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 386 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 387 | make -C "$WORKSPACE/voltha-system-tests" ${testTarget} |
| 388 | """) |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 389 | |
| 390 | getPodsInfo("${logsDir}") |
| 391 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 392 | // [TODO] make conditional, bundle when logs are available |
Joey Armstrong | ebc1802 | 2023-08-26 13:20:49 -0400 | [diff] [blame] | 393 | sh( |
| 394 | label : 'Gather robot Framework logs', |
| 395 | script : """ |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 396 | echo -e '\n** Gather robot Framework logs: ENTER' |
Joey Armstrong | 7ba23ac | 2023-08-29 15:21:53 -0400 | [diff] [blame] | 397 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 398 | # set +e |
| 399 | # collect logs collected in the Robot Framework StartLogging keyword |
| 400 | cd "${logsDir}" |
Joey Armstrong | 7ba23ac | 2023-08-29 15:21:53 -0400 | [diff] [blame] | 401 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 402 | echo "** Available logs:" |
| 403 | /bin/ls -l "$logsDir" |
| 404 | echo |
Joey Armstrong | 7ba23ac | 2023-08-29 15:21:53 -0400 | [diff] [blame] | 405 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 406 | echo '** Bundle combined log' |
| 407 | gzip *-combined.log || true |
| 408 | rm -f *-combined.log || true |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 409 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 410 | echo -e '** Gather robot Framework logs: LEAVE\n' |
| 411 | """) |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 412 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 413 | // ----------------------------------------------------------------------- |
| 414 | // ----------------------------------------------------------------------- |
Joey Armstrong | ebc1802 | 2023-08-26 13:20:49 -0400 | [diff] [blame] | 415 | sh( |
| 416 | label : 'Monitor pod-mem-consumption', |
| 417 | script : """ |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 418 | echo -e '** Monitor pod-mem-consumption: ENTER' |
| 419 | if [ ${withMonitoring} = true ] ; then |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 420 | cat <<EOM |
| 421 | |
| 422 | ** ----------------------------------------------------------------------- |
| 423 | ** Monitoring pod-memory-consumption using mem_consumption.py |
| 424 | ** ----------------------------------------------------------------------- |
| 425 | EOM |
Joey Armstrong | f060aee | 2023-08-22 21:55:26 -0400 | [diff] [blame] | 426 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 427 | cd "$WORKSPACE/voltha-system-tests" |
Joey Armstrong | 38a8783 | 2023-08-23 17:02:50 -0400 | [diff] [blame] | 428 | |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 429 | echo '** Installing python virtualenv' |
| 430 | make venv-activate-patched |
| 431 | |
| 432 | # Collect memory consumption of voltha pods once all the tests are complete |
| 433 | set +u && source .venv/bin/activate && set -u |
| 434 | python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace} |
| 435 | fi |
| 436 | echo -e '** Monitor pod-mem-consumption: LEAVE\n' |
| 437 | """) |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 438 | } // stage |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 439 | |
| 440 | return |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 441 | } // execute_test() |
| 442 | |
| 443 | // ----------------------------------------------------------------------- |
| 444 | // ----------------------------------------------------------------------- |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 445 | void collectArtifacts(exitStatus) { |
Joey Armstrong | 6115fd6 | 2023-08-24 08:19:28 -0400 | [diff] [blame] | 446 | script { |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 447 | String iam = getIam('collectArtifacts') |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 448 | enter("exitStatus=${exitStatus}") |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 449 | |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 450 | println(""" |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 451 | |
| 452 | ** ----------------------------------------------------------------------- |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 453 | ** IAM: $iam |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 454 | ** collectArtifacts |
| 455 | ** ----------------------------------------------------------------------- |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 456 | """) |
| 457 | } |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 458 | |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 459 | getPodsInfo("$WORKSPACE/${exitStatus}") |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 460 | |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 461 | sh(label : 'kubectl logs > voltha.log', |
| 462 | script : """ |
| 463 | kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha \ |
| 464 | > $WORKSPACE/${exitStatus}/voltha.log |
| 465 | """) |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 466 | |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 467 | 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] | 468 | |
Joey Armstrong | ec1ae0a | 2023-08-23 21:51:45 -0400 | [diff] [blame] | 469 | script { |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 470 | enter('pkill _TAG=kail-startup') |
Joey Armstrong | 664c55a | 2023-08-28 14:22:33 -0400 | [diff] [blame] | 471 | sh(label : 'pgrep_proc - kill-pre', |
| 472 | script : """ |
Joey Armstrong | e9725b1 | 2023-08-28 18:15:12 -0400 | [diff] [blame] | 473 | pgrep --uid "\$(id -u)" --list-full --full 'kail-startup' || true |
Joey Armstrong | 664c55a | 2023-08-28 14:22:33 -0400 | [diff] [blame] | 474 | """) |
| 475 | sh(label : 'pkill_proc - kail', |
| 476 | script : """ |
Joey Armstrong | 12a8c83 | 2023-08-28 16:50:24 -0400 | [diff] [blame] | 477 | if [[ \$(pgrep --count '_TAG=kail') -gt 0 ]]; then |
| 478 | pkill --uid "\$(id -u)" --echo --full 'kail' |
| 479 | fi |
Joey Armstrong | 664c55a | 2023-08-28 14:22:33 -0400 | [diff] [blame] | 480 | """) |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 481 | leave('pkill _TAG=kail-startup') |
Joey Armstrong | ec1ae0a | 2023-08-23 21:51:45 -0400 | [diff] [blame] | 482 | } |
Joey Armstrong | dd0cd6b | 2023-08-25 17:27:56 -0400 | [diff] [blame] | 483 | |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 484 | enter('RobotPublisher') |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 485 | step([$class: 'RobotPublisher', |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 486 | disableArchiveOutput: false, |
| 487 | logFileName: '**/*/log*.html', |
| 488 | otherFiles: '', |
| 489 | outputFileName: '**/*/output*.xml', |
| 490 | outputPath: '.', |
| 491 | passThreshold: 100, |
| 492 | reportFileName: '**/*/report*.html', |
| 493 | unstableThreshold: 0, |
| 494 | onlyCritical: true]) |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 495 | leave('RobotPublisher') |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 496 | |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 497 | leave("exitStatus=${exitStatus}") |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 498 | return |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 499 | } |
| 500 | |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 501 | // ----------------------------------------------------------------------- |
| 502 | // Intent: main |
| 503 | // ----------------------------------------------------------------------- |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 504 | pipeline { |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 505 | /* no label, executor is determined by JJB */ |
| 506 | agent { |
| 507 | label "${params.buildNode}" |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 508 | } |
| 509 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 510 | options { |
| 511 | timeout(time: "${timeout}", unit: 'MINUTES') |
| 512 | } |
| 513 | |
| 514 | environment { |
| 515 | KUBECONFIG = "$HOME/.kube/kind-${clusterName}" |
| 516 | VOLTCONFIG = "$HOME/.volt/config" |
| 517 | PATH = "$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 518 | DIAGS_PROFILE = 'VOLTHA_PROFILE' |
| 519 | SSHPASS = 'karaf' |
| 520 | } |
| 521 | |
| 522 | stages { |
| 523 | stage('Download Code') { |
| 524 | steps { |
| 525 | getVolthaCode([ |
| 526 | branch: "${branch}", |
| 527 | gerritProject: "${gerritProject}", |
| 528 | gerritRefspec: "${gerritRefspec}", |
| 529 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 530 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 531 | ]) |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 532 | } |
| 533 | } |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 534 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 535 | stage('Build patch v1.1') { |
| 536 | // build the patch only if gerritProject is specified |
| 537 | when { |
| 538 | expression { return !gerritProject.isEmpty() } |
| 539 | } |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 540 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 541 | steps { |
| 542 | // NOTE that the correct patch has already been checked out |
| 543 | // during the getVolthaCode step |
| 544 | buildVolthaComponent("${gerritProject}") |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | // ----------------------------------------------------------------------- |
| 549 | // ----------------------------------------------------------------------- |
| 550 | stage('Install Kail') |
Joey Armstrong | 2b2010d | 2023-08-02 21:47:20 -0400 | [diff] [blame] | 551 | { |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 552 | steps |
Joey Armstrong | 2b2010d | 2023-08-02 21:47:20 -0400 | [diff] [blame] | 553 | { |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 554 | script |
| 555 | { |
| 556 | String cmd = [ |
| 557 | 'make', |
| 558 | '--no-print-directory', |
| 559 | '-C', "$WORKSPACE/voltha-system-tests", |
| 560 | "KAIL_PATH=\"$WORKSPACE/bin\"", |
| 561 | 'kail', |
| 562 | ].join(' ') |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 563 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 564 | println(" ** Running: ${cmd}") |
| 565 | sh("${cmd}") |
| 566 | } // script |
| 567 | } // steps |
| 568 | } // stage |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 569 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 570 | // ----------------------------------------------------------------------- |
| 571 | // ----------------------------------------------------------------------- |
| 572 | stage('Install Tools') { |
| 573 | steps { |
| 574 | script { |
| 575 | String branchName = branchName() |
| 576 | String iam = getIam('Install Tools') |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 577 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 578 | println("${iam}: ENTER (branch=$branch)") |
| 579 | installKind(branch) // needed early by stage(Cleanup) |
| 580 | println("${iam}: LEAVE (branch=$branch)") |
| 581 | } // script |
| 582 | } // steps |
| 583 | } // stage |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 584 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 585 | // ----------------------------------------------------------------------- |
| 586 | // ----------------------------------------------------------------------- |
| 587 | stage('Create K8s Cluster') { |
| 588 | steps { |
| 589 | script { |
| 590 | def clusterExists = sh( |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 591 | label : 'Create K8s Cluster', |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 592 | returnStdout: true, |
| 593 | script: """kind get clusters | grep "${clusterName}" | wc -l""") |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 594 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 595 | if (clusterExists.trim() == '0') { |
| 596 | createKubernetesCluster([nodes: 3, name: clusterName]) |
| 597 | } |
| 598 | } // script |
| 599 | } // steps |
| 600 | } // stage('Create K8s Cluster') |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 601 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 602 | // ----------------------------------------------------------------------- |
| 603 | // ----------------------------------------------------------------------- |
| 604 | stage('Replace voltctl') { |
| 605 | // if the project is voltctl, override the downloaded one with the built one |
| 606 | when { |
| 607 | expression { return gerritProject == 'voltctl' } |
| 608 | } |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 609 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 610 | // Hmmmm(?) where did the voltctl download happen ? |
| 611 | // Likely Makefile but would be helpful to document here. |
| 612 | steps { |
| 613 | script { |
| 614 | String iam = getIam('Replace voltctl') |
Joey Armstrong | 6115fd6 | 2023-08-24 08:19:28 -0400 | [diff] [blame] | 615 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 616 | println("${iam} Running: installVoltctl($branch)") |
| 617 | println("${iam}: ENTER") |
| 618 | installVoltctl("$branch") |
| 619 | println("${iam}: LEAVE") |
| 620 | } // script |
| 621 | } // step |
| 622 | } // stage |
Joey Armstrong | 268442d | 2023-08-22 17:16:10 -0400 | [diff] [blame] | 623 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 624 | // ----------------------------------------------------------------------- |
| 625 | // ----------------------------------------------------------------------- |
| 626 | stage('Load image in kind nodes') |
| 627 | { |
| 628 | when { |
| 629 | expression { return !gerritProject.isEmpty() } |
| 630 | } |
| 631 | steps { |
| 632 | loadToKind() |
| 633 | } // steps |
| 634 | } // stage |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 635 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 636 | // ----------------------------------------------------------------------- |
| 637 | // [TODO] verify testing output |
| 638 | // ----------------------------------------------------------------------- |
| 639 | stage('Parse and execute tests') |
| 640 | { |
| 641 | steps { |
| 642 | script { |
| 643 | // Announce ourselves for log usability |
| 644 | enter('Parse and execute tests') |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 645 | |
Joey Armstrong | ebc1802 | 2023-08-26 13:20:49 -0400 | [diff] [blame] | 646 | def tests = readYaml text: testTargets // typeof == Map (?) |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 647 | println("** [DEBUG]: tests=$tests") |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 648 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 649 | // Display expected tests for times when output goes dark |
| 650 | tests.eachWithIndex { test, idx -> |
| 651 | String target = test['target'] |
| 652 | println("** test[${idx}]: ${target}\n") |
| 653 | } |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 654 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 655 | println(''' |
Joey Armstrong | b29d561 | 2023-08-24 12:53:46 -0400 | [diff] [blame] | 656 | ** ----------------------------------------------------------------------- |
| 657 | ** NOTE: For odd/silent job failures verify a few details |
Joey Armstrong | 5d65efe | 2023-08-25 09:43:18 -0400 | [diff] [blame] | 658 | ** - All tests mentioned in the tests-to-run index were logged. |
Joey Armstrong | b29d561 | 2023-08-24 12:53:46 -0400 | [diff] [blame] | 659 | ** - Test suites display ENTER/LEAVE mesasge pairs. |
Joey Armstrong | 5d65efe | 2023-08-25 09:43:18 -0400 | [diff] [blame] | 660 | ** - Processing terminated prematurely when LEAVE strings are missing. |
Joey Armstrong | b29d561 | 2023-08-24 12:53:46 -0400 | [diff] [blame] | 661 | ** ----------------------------------------------------------------------- |
Joey Armstrong | be7c924 | 2023-08-24 16:20:31 -0400 | [diff] [blame] | 662 | ''') |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 663 | tests.eachWithIndex { test, idx -> |
| 664 | println "** readYaml test suite[$idx]) test=[${test}]" |
Joey Armstrong | f46b3ae | 2023-08-25 11:07:20 -0400 | [diff] [blame] | 665 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 666 | String target = test['target'] |
| 667 | String workflow = test['workflow'] |
| 668 | String flags = test['flags'] |
| 669 | Boolean teardown = test['teardown'].toBoolean() |
| 670 | Boolean logging = test['logging'].toBoolean() |
| 671 | String testLogging = (logging) ? 'True' : 'False' |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 672 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 673 | print(""" |
Joey Armstrong | 268442d | 2023-08-22 17:16:10 -0400 | [diff] [blame] | 674 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 38a8783 | 2023-08-23 17:02:50 -0400 | [diff] [blame] | 675 | ** 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] | 676 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 38a8783 | 2023-08-23 17:02:50 -0400 | [diff] [blame] | 677 | """) |
Joey Armstrong | 664c55a | 2023-08-28 14:22:33 -0400 | [diff] [blame] | 678 | |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 679 | try { |
Joey Armstrong | 6146f7e | 2023-08-28 09:05:38 -0400 | [diff] [blame] | 680 | enter("execute_test (target=$target)") |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 681 | execute_test(target, workflow, testLogging, teardown, flags) |
| 682 | } |
Joey Armstrong | 9341c9a | 2023-08-28 12:09:19 -0400 | [diff] [blame] | 683 | // groovylint-disable-next-line CatchException |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 684 | catch (Exception err) { |
Joey Armstrong | 14711b8 | 2023-09-08 12:33:25 -0400 | [diff] [blame] | 685 | String iamexc = getIam(test) |
Joey Armstrong | 9341c9a | 2023-08-28 12:09:19 -0400 | [diff] [blame] | 686 | println("** ${iamexc}: EXCEPTION ${err}") |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 687 | } |
| 688 | finally { |
| 689 | leave("execute_test (target=$target)") |
| 690 | } |
| 691 | } // for |
| 692 | // Premature exit if this message is not logged |
| 693 | leave('Parse and execute tests') |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 694 | } // script |
| 695 | } // steps |
Joey Armstrong | 7229d9b | 2023-08-25 18:03:13 -0400 | [diff] [blame] | 696 | } // stage |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 697 | } // stages |
| 698 | |
| 699 | post |
| 700 | { |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 701 | aborted { |
| 702 | collectArtifacts('aborted') |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 703 | script { cleanupPortForward() } |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 704 | } |
| 705 | failure { |
| 706 | collectArtifacts('failed') |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 707 | script { cleanupPortForward() } |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 708 | } |
| 709 | always { |
| 710 | collectArtifacts('always') |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame] | 711 | script { cleanupPortForward() } |
Joey Armstrong | 43cb15a | 2023-09-01 14:32:27 -0400 | [diff] [blame] | 712 | } |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 713 | } |
| 714 | } // pipeline |
| 715 | |
Joey Armstrong | 664c55a | 2023-08-28 14:22:33 -0400 | [diff] [blame] | 716 | // [EOF] |