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