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