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