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