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