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