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 | 008cfaf | 2023-08-18 14:49:06 -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" |
| 180 | echo "** kail-startup ENTER: $(date)" > "$onos_log" |
| 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 | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 188 | // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts |
| 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 { |
| 252 | println('Try out pgrep/pkill commands') |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 253 | sh('''pgrep --list-full kail-startup || true''') |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 254 | } |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 255 | |
| 256 | // ----------------------------------------------------------------------- |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 257 | // stop logging |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 258 | // ----------------------------------------------------------------------- |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 259 | sh """ |
| 260 | P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')" |
| 261 | if [ -n "\$P_IDS" ]; then |
| 262 | echo \$P_IDS |
| 263 | for P_ID in \$P_IDS; do |
| 264 | kill -9 \$P_ID |
| 265 | done |
| 266 | fi |
| 267 | cd ${logsDir} |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 268 | echo "** kail-startup LEAVE: $(date)" >> "${logsDir}/onos-voltha-startup-combined.log" |
| 269 | |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 270 | gzip -k onos-voltha-startup-combined.log |
| 271 | rm onos-voltha-startup-combined.log |
| 272 | """ |
| 273 | } |
| 274 | |
| 275 | sh """ |
| 276 | 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"& |
| 277 | 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"& |
| 278 | 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"& |
| 279 | bbsimDmiPortFwd=50075 |
| 280 | for i in {0..${olts.toInteger() - 1}}; do |
| 281 | 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"& |
| 282 | ((bbsimDmiPortFwd++)) |
| 283 | done |
| 284 | if [ ${withMonitoring} = true ] ; then |
| 285 | 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"& |
| 286 | fi |
| 287 | ps aux | grep port-forward |
| 288 | """ |
| 289 | |
| 290 | // setting ONOS log level |
| 291 | script |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 292 | { |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 293 | println('** setOnosLogLevels: ENTER') |
| 294 | setOnosLogLevels([ |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 295 | onosNamespace: infraNamespace, |
| 296 | apps: [ |
| 297 | 'org.opencord.dhcpl2relay', |
| 298 | 'org.opencord.olt', |
| 299 | 'org.opencord.aaa', |
| 300 | 'org.opencord.maclearner', |
| 301 | 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager', |
| 302 | 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager' |
| 303 | ], |
| 304 | logLevel: logLevel |
| 305 | ]) |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 306 | println('** setOnosLogLevels: LEAVE') |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 307 | } // script |
| 308 | } // if (teardown) |
| 309 | } // stage('Deploy Voltha') |
| 310 | |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 311 | stage("Run test ${testTarget} on workflow ${workflow}") |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 312 | { |
| 313 | sh """ |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 314 | echo -e "\n** Monitor using mem_consumption.py ?" |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 315 | if [ ${withMonitoring} = true ] ; then |
| 316 | mkdir -p "$WORKSPACE/voltha-pods-mem-consumption-${workflow}" |
| 317 | cd "$WORKSPACE/voltha-system-tests" |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 318 | make venv-activate-script |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 319 | set +u && source .venv/bin/activate && set -u |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 320 | # Collect initial memory consumption |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 321 | 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] | 322 | fi |
| 323 | """ |
| 324 | |
| 325 | sh """ |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 326 | echo -e "\n** make testTarget=[${testTarget}]" |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 327 | mkdir -p ${logsDir} |
| 328 | export ROBOT_MISC_ARGS="-d ${logsDir} ${params.extraRobotArgs} " |
| 329 | 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}" |
| 330 | export KVSTOREPREFIX=voltha/voltha_voltha |
| 331 | |
Joey Armstrong | 0eb8bd8 | 2023-07-10 13:26:25 -0400 | [diff] [blame] | 332 | make -C "$WORKSPACE/voltha-system-tests" ${testTarget} |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 333 | """ |
| 334 | |
| 335 | getPodsInfo("${logsDir}") |
| 336 | |
| 337 | sh """ |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 338 | echo -e '\n** Gather robot Framework logs: ENTER' |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 339 | # set +e |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 340 | # collect logs collected in the Robot Framework StartLogging keyword |
| 341 | cd ${logsDir} |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 342 | gzip *-combined.log |
| 343 | rm -f *-combined.log |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 344 | |
| 345 | echo -e '** Gather robot Framework logs: LEAVE\n' |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 346 | """ |
| 347 | |
| 348 | sh """ |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 349 | echo -e '** Monitor pod-mem-consumption: ENTER' |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 350 | if [ ${withMonitoring} = true ] ; then |
| 351 | cd "$WORKSPACE/voltha-system-tests" |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 352 | make venv-activate-script |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 353 | set +u && source .venv/bin/activate && set -u |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 354 | # Collect memory consumption of voltha pods once all the tests are complete |
Joey Armstrong | 0eb8bd8 | 2023-07-10 13:26:25 -0400 | [diff] [blame] | 355 | 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] | 356 | fi |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 357 | echo -e '** Monitor pod-mem-consumption: LEAVE\n' |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 358 | """ |
| 359 | } // stage |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 360 | |
| 361 | return |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 362 | } // execute_test() |
| 363 | |
| 364 | // ----------------------------------------------------------------------- |
| 365 | // ----------------------------------------------------------------------- |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 366 | def collectArtifacts(exitStatus) { |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 367 | String iam = getIam('execute_test') |
| 368 | |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 369 | echo ''' |
| 370 | |
| 371 | ** ----------------------------------------------------------------------- |
| 372 | ** collectArtifacts |
| 373 | ** ----------------------------------------------------------------------- |
| 374 | ''' |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 375 | println("${iam}: ENTER (exitStatus=${exitStatus})") |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 376 | |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 377 | getPodsInfo("$WORKSPACE/${exitStatus}") |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 378 | |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 379 | sh """ |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 380 | 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] | 381 | """ |
Joey Armstrong | 66fcb4e | 2023-08-11 12:09:24 -0400 | [diff] [blame] | 382 | |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 383 | 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] | 384 | |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 385 | sh(returnStdout:true, script: ''' |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 386 | sync |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 387 | echo '** Running: pgrep --list-full kail-startup (ENTER)' |
| 388 | pgrep --list-full 'kail-startup' || true |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 389 | [[ $(pgrep --count kail) -gt 0 ]] && pkill --echo kail |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 390 | echo '** Running: pgrep --list-full kail-startup (LEAVE)' |
| 391 | ''') |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 392 | |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 393 | println("${iam}: ENTER RobotPublisher") |
| 394 | step([$class: 'RobotPublisher', |
| 395 | disableArchiveOutput: false, |
| 396 | logFileName: '**/*/log*.html', |
| 397 | otherFiles: '', |
| 398 | outputFileName: '**/*/output*.xml', |
| 399 | outputPath: '.', |
| 400 | passThreshold: 100, |
| 401 | reportFileName: '**/*/report*.html', |
| 402 | unstableThreshold: 0, |
| 403 | onlyCritical: true]); |
| 404 | println("${iam}: LEAVE RobotPublisher") |
| 405 | |
| 406 | println("${iam}: LEAVE (exitStatus=${exitStatus})") |
| 407 | return |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 408 | } |
| 409 | |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 410 | // ----------------------------------------------------------------------- |
| 411 | // Intent: main |
| 412 | // ----------------------------------------------------------------------- |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 413 | pipeline { |
| 414 | |
| 415 | /* no label, executor is determined by JJB */ |
| 416 | agent { |
| 417 | label "${params.buildNode}" |
| 418 | } |
| 419 | options { |
| 420 | timeout(time: "${timeout}", unit: 'MINUTES') |
| 421 | } |
| 422 | environment { |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 423 | KUBECONFIG = "$HOME/.kube/kind-${clusterName}" |
| 424 | VOLTCONFIG = "$HOME/.volt/config" |
| 425 | PATH = "$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 426 | DIAGS_PROFILE = 'VOLTHA_PROFILE' |
| 427 | SSHPASS = 'karaf' |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 428 | } |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 429 | |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 430 | stages { |
| 431 | stage('Download Code') { |
| 432 | steps { |
| 433 | getVolthaCode([ |
| 434 | branch: "${branch}", |
| 435 | gerritProject: "${gerritProject}", |
| 436 | gerritRefspec: "${gerritRefspec}", |
| 437 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 438 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 439 | ]) |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | stage('Build patch v1.1') |
| 444 | { |
| 445 | // build the patch only if gerritProject is specified |
| 446 | when |
| 447 | { |
| 448 | expression |
| 449 | { |
| 450 | return !gerritProject.isEmpty() |
| 451 | } |
| 452 | } |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 453 | |
| 454 | steps |
| 455 | { |
| 456 | // NOTE that the correct patch has already been checked out |
| 457 | // during the getVolthaCode step |
| 458 | buildVolthaComponent("${gerritProject}") |
| 459 | } |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 460 | } |
| 461 | |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 462 | // ----------------------------------------------------------------------- |
| 463 | // ----------------------------------------------------------------------- |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 464 | stage('Install Kail') |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 465 | { |
Joey Armstrong | 2b2010d | 2023-08-02 21:47:20 -0400 | [diff] [blame] | 466 | steps |
| 467 | { |
| 468 | script |
| 469 | { |
| 470 | String cmd = [ |
| 471 | 'make', |
Joey Armstrong | 9f184d3 | 2023-08-03 11:34:48 -0400 | [diff] [blame] | 472 | '--no-print-directory', |
Joey Armstrong | 2b2010d | 2023-08-02 21:47:20 -0400 | [diff] [blame] | 473 | '-C', "$WORKSPACE/voltha-system-tests", |
| 474 | "KAIL_PATH=\"$WORKSPACE/bin\"", |
| 475 | 'kail', |
| 476 | ].join(' ') |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 477 | |
Joey Armstrong | 2b2010d | 2023-08-02 21:47:20 -0400 | [diff] [blame] | 478 | println(" ** Running: ${cmd}:\n") |
| 479 | sh("${cmd}") |
| 480 | } // script |
| 481 | } // steps |
| 482 | } // stage |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 483 | |
| 484 | // ----------------------------------------------------------------------- |
| 485 | // ----------------------------------------------------------------------- |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 486 | stage('Install Kind') |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 487 | { |
Joey Armstrong | 2b2010d | 2023-08-02 21:47:20 -0400 | [diff] [blame] | 488 | steps |
| 489 | { |
| 490 | script |
| 491 | { |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 492 | |
Joey Armstrong | 2b2010d | 2023-08-02 21:47:20 -0400 | [diff] [blame] | 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 | "KIND_PATH=\"$WORKSPACE/bin\"", |
| 498 | 'install-command-kind', |
| 499 | ].join(' ') |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 500 | |
Joey Armstrong | 2b2010d | 2023-08-02 21:47:20 -0400 | [diff] [blame] | 501 | println(" ** Running: ${cmd}:\n") |
| 502 | sh("${cmd}") |
| 503 | } // script |
| 504 | } // steps |
| 505 | } // stage |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 506 | |
| 507 | // ----------------------------------------------------------------------- |
| 508 | // ----------------------------------------------------------------------- |
| 509 | stage('Create K8s Cluster') |
| 510 | { |
| 511 | steps |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 512 | { |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 513 | script |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 514 | { |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 515 | def clusterExists = sh( |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 516 | returnStdout: true, |
| 517 | script: """kind get clusters | grep "${clusterName}" | wc -l""" |
| 518 | ) |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 519 | |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 520 | if (clusterExists.trim() == '0') |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 521 | { |
| 522 | createKubernetesCluster([nodes: 3, name: clusterName]) |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 523 | } |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 524 | } // script |
| 525 | } // steps |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 526 | } // stage('Create K8s Cluster') |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 527 | |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 528 | // ----------------------------------------------------------------------- |
| 529 | // ----------------------------------------------------------------------- |
| 530 | stage('Replace voltctl') |
| 531 | { |
| 532 | // if the project is voltctl, override the downloaded one with the built one |
| 533 | when { |
| 534 | expression { return gerritProject == 'voltctl' } |
| 535 | } |
| 536 | |
| 537 | // Hmmmm(?) where did the voltctl download happen ? |
| 538 | // Likely Makefile but would be helpful to document here. |
| 539 | steps |
| 540 | { |
| 541 | println("${iam} Running: installVoltctl($branch)") |
| 542 | installVoltctl("$branch") |
| 543 | } // steps |
| 544 | } // stage |
| 545 | |
| 546 | // ----------------------------------------------------------------------- |
| 547 | // ----------------------------------------------------------------------- |
| 548 | stage('Load image in kind nodes') |
| 549 | { |
| 550 | when { |
| 551 | expression { return !gerritProject.isEmpty() } |
| 552 | } |
| 553 | steps { |
| 554 | loadToKind() |
| 555 | } // steps |
| 556 | } // stage |
| 557 | |
| 558 | // ----------------------------------------------------------------------- |
| 559 | // ----------------------------------------------------------------------- |
| 560 | stage('Parse and execute tests') |
| 561 | { |
| 562 | steps { |
| 563 | script { |
| 564 | // Announce ourselves for log usability |
| 565 | String iam = getIam('execute_test') |
| 566 | println("${iam}: ENTER") |
| 567 | |
| 568 | def tests = readYaml text: testTargets |
| 569 | |
| 570 | println("** $iam: Testing index: tests-to-run") |
| 571 | tests.eachWithIndex { test, idx -> |
| 572 | String target = test['target'] |
| 573 | println("** $idx: $target") |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 574 | } |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 575 | println("** NOTE: For odd failures compare tests-to-run with teste output") |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 576 | |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 577 | tests.eachWithIndex { test, idx -> |
| 578 | println "** readYaml test suite[$idx]) test=[${test}]" |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 579 | |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 580 | String target = test['target'] |
| 581 | String workflow = test['workflow'] |
| 582 | String flags = test['flags'] |
| 583 | Boolean teardown = test['teardown'].toBoolean() |
| 584 | Boolean logging = test['logging'].toBoolean() |
| 585 | String testLogging = (logging) ? 'True' : 'False' |
Joey Armstrong | 0e0a42b | 2023-08-02 21:04:21 -0400 | [diff] [blame] | 586 | |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 587 | println([ |
| 588 | "Executing test ${target}", |
| 589 | "on workflow ${workflow}", |
| 590 | "with logging ${testLogging}", |
| 591 | "and extra flags ${flags}", |
| 592 | ].join(' ') |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 593 | |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 594 | try { |
| 595 | println "Executing test ${target}: ENTER" |
| 596 | execute_test(target, workflow, testLogging, teardown, flags) |
| 597 | } |
| 598 | catch (Exception err) { |
| 599 | println("** ${iam}: EXCEPTION ${err}") |
| 600 | } |
| 601 | finally { |
| 602 | println "Executing test ${target}: LEAVE" |
| 603 | } |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 604 | |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 605 | } // for |
Joey Armstrong | 642540a | 2023-08-10 10:26:36 -0400 | [diff] [blame] | 606 | |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 607 | // Premature exit if this message is not logged |
| 608 | println("${iam}: LEAVE (testing ran to completion)") |
Joey Armstrong | 54dec09 | 2023-08-03 18:21:38 -0400 | [diff] [blame] | 609 | } // script |
| 610 | } // steps |
Joey Armstrong | 008cfaf | 2023-08-18 14:49:06 -0400 | [diff] [blame] | 611 | } // stage |
Joey Armstrong | 7bcb578 | 2023-06-07 12:25:57 -0400 | [diff] [blame] | 612 | } // stages |
| 613 | |
| 614 | post |
| 615 | { |
| 616 | aborted { collectArtifacts('aborted') } |
| 617 | failure { collectArtifacts('failed') } |
| 618 | always { collectArtifacts('always') } |
| 619 | } |
| 620 | } // pipeline |
| 621 | |
| 622 | // EOF |