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