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