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