Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 1 | // Copyright 2021-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 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 | |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 15 | // voltha-2.x e2e tests for openonu-go |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 16 | // uses bbsim to simulate OLT/ONUs |
| 17 | |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 18 | // [TODO] Update syntax below to the latest supported |
Matteo Scandolo | a156b57 | 2021-02-04 11:52:18 -0800 | [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 | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 25 | //------------------// |
| 26 | //---] GLOBAL [---// |
| 27 | //------------------// |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 28 | def clusterName = "kind-ci" |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 29 | String branch_name = 'master' |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 30 | |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 31 | // ----------------------------------------------------------------------- |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 32 | // Intent: Due to lack of a reliable stack trace, construct a literal. |
| 33 | // Jenkins will re-write the call stack for serialization. |
| 34 | // ----------------------------------------------------------------------- |
| 35 | def getIam(String func) |
| 36 | { |
| 37 | String src = [ |
| 38 | 'ci-management', |
| 39 | 'jjb', |
| 40 | 'pipeline', |
| 41 | 'voltha', |
| 42 | branch_name, |
| 43 | 'bbsim-tests.groovy' |
| 44 | ].join('/') |
| 45 | |
| 46 | String iam = [src, func].join('::') |
| 47 | return iam |
| 48 | } |
| 49 | |
| 50 | // ----------------------------------------------------------------------- |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 51 | // Intent: Determine if working on a release branch. |
| 52 | // Note: Conditional is legacy, should also check for *-dev or *-pre |
| 53 | // ----------------------------------------------------------------------- |
| 54 | Boolean isReleaseBranch(String name) |
| 55 | { |
| 56 | // List modifiers = ['-dev', '-pre', 'voltha-x.y.z-pre'] |
| 57 | // if branch_name in modifiers |
| 58 | return(name != 'master') // OR branch_name.contains('-') |
| 59 | } |
| 60 | |
| 61 | // ----------------------------------------------------------------------- |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 62 | // Intent: Phase helper method |
| 63 | // ----------------------------------------------------------------------- |
Joey Armstrong | 46bfeea | 2023-07-31 10:39:25 -0400 | [diff] [blame] | 64 | // NOTE: installKind temporarily disabled: |
| 65 | // o error makes little sense, install.Kind.{groovy,sh} exist in vars/ |
| 66 | // o jenkins shared library -- checked out on server disk is stale |
| 67 | // 2 changesets behind current ?!?! |
| 68 | // o Disable call for now to revive the pipeline. |
| 69 | // 10:26:05 org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: |
| 70 | // 10:26:05 WorkflowScript: 73: unexpected token: installKind @ line 73, column 2. |
| 71 | // 10:26:05 installKind(name) |
| 72 | // 10:26:05 ^ |
| 73 | // ----------------------------------------------------------------------- |
Joey Armstrong | 53cebea | 2023-07-26 10:35:53 -0400 | [diff] [blame] | 74 | Boolean install_kind(String name) |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 75 | { |
| 76 | String iam = getIam('installKind') |
| 77 | Boolean ans = False |
| 78 | |
| 79 | println("** ${iam}: ENTER") |
| 80 | try |
| 81 | { |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame] | 82 | println("** ${iam} Running installKind(name): ENTER") |
| 83 | installKind(name) |
| 84 | println("** ${iam} Running installKind(name): LEAVE") |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 85 | ans = True // iff |
| 86 | } |
| 87 | catch (Exception err) |
| 88 | { |
| 89 | ans = False |
| 90 | println("** ${iam}: EXCEPTION ${err}") |
| 91 | throw err |
| 92 | } |
| 93 | finally |
| 94 | { |
| 95 | println("** ${iam}: ENTER") |
| 96 | } |
Joey Armstrong | 53cebea | 2023-07-26 10:35:53 -0400 | [diff] [blame] | 97 | |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 98 | return(ans) |
| 99 | } |
| 100 | |
| 101 | // ----------------------------------------------------------------------- |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 102 | // Intent: |
| 103 | // ----------------------------------------------------------------------- |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 104 | def execute_test(testTarget, workflow, testLogging, teardown, testSpecificHelmFlags = "") |
| 105 | { |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 106 | def infraNamespace = "default" |
| 107 | def volthaNamespace = "voltha" |
| 108 | def logsDir = "$WORKSPACE/${testTarget}" |
Joey Armstrong | 293e16b | 2022-11-26 20:16:33 -0500 | [diff] [blame] | 109 | |
| 110 | stage('IAM') |
| 111 | { |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 112 | script |
| 113 | { |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 114 | // Announce ourselves for log usability |
| 115 | String iam = getIam('execute_test') |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 116 | println("${iam}: ENTER") |
| 117 | println("${iam}: LEAVE") |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 118 | } |
Joey Armstrong | 293e16b | 2022-11-26 20:16:33 -0500 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | stage('Cleanup') { |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 122 | if (teardown) { |
| 123 | timeout(15) { |
| 124 | script { |
| 125 | helmTeardown(["default", infraNamespace, volthaNamespace]) |
| 126 | } |
| 127 | timeout(1) { |
| 128 | sh returnStdout: false, script: ''' |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 129 | # remove orphaned port-forward from different namespaces |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 130 | ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 131 | ''' |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | } |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 135 | } |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 136 | |
Joey Armstrong | 53cebea | 2023-07-26 10:35:53 -0400 | [diff] [blame] | 137 | stage ('Install Kail') |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 138 | { |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 139 | // VOL-4926 - Is voltha-system-tests available ? |
| 140 | String cmd = [ |
| 141 | 'make', |
| 142 | '-C', "$WORKSPACE/voltha-system-tests", |
| 143 | "KAIL_PATH=\"$WORKSPACE/bin\"", |
| 144 | 'kail', |
| 145 | ].join(' ') |
| 146 | println(" ** Running: ${cmd}:\n") |
Joey Armstrong | beef4cd | 2023-01-18 09:59:58 -0500 | [diff] [blame] | 147 | sh("${cmd}") |
Joey Armstrong | 53cebea | 2023-07-26 10:35:53 -0400 | [diff] [blame] | 148 | // if (! my_install_kail()) |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 149 | // throw new Exception('installKail() failed') |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 150 | } |
| 151 | |
Joey Armstrong | 53cebea | 2023-07-26 10:35:53 -0400 | [diff] [blame] | 152 | stage ('Install Kind') |
| 153 | { |
| 154 | steps |
| 155 | { |
| 156 | install_kind(branch_name) |
| 157 | } |
| 158 | } |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 159 | |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 160 | stage('Deploy common infrastructure') |
| 161 | { |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 162 | sh ''' |
Hardik Windlass | e166049 | 2022-03-14 15:12:46 +0000 | [diff] [blame] | 163 | helm repo add onf https://charts.opencord.org |
| 164 | helm repo update |
| 165 | if [ ${withMonitoring} = true ] ; then |
| 166 | helm install nem-monitoring onf/nem-monitoring \ |
| 167 | --set prometheus.alertmanager.enabled=false,prometheus.pushgateway.enabled=false \ |
| 168 | --set kpi_exporter.enabled=false,dashboards.xos=false,dashboards.onos=false,dashboards.aaa=false,dashboards.voltha=false |
| 169 | fi |
| 170 | ''' |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 171 | } |
| 172 | |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 173 | stage('Deploy Voltha') |
| 174 | { |
| 175 | if (teardown) |
| 176 | { |
| 177 | timeout(10) |
| 178 | { |
| 179 | script |
| 180 | { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 181 | sh """ |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 182 | mkdir -p ${logsDir} |
| 183 | _TAG=kail-startup kail -n ${infraNamespace} -n ${volthaNamespace} > ${logsDir}/onos-voltha-startup-combined.log & |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 184 | """ |
| 185 | |
| 186 | // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts |
| 187 | def localCharts = false |
Joey Armstrong | 53cebea | 2023-07-26 10:35:53 -0400 | [diff] [blame] | 188 | |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 189 | if (volthaHelmChartsChange != "" |
| 190 | || gerritProject == "voltha-helm-charts" |
| 191 | || isReleaseBranch(branch) // branch != 'master' |
| 192 | ) { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 193 | localCharts = true |
| 194 | } |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 195 | Boolean is_release = isReleaseBranch(branch) |
| 196 | println(" ** localCharts=${localCharts}, branch_name=${branch_name}, isReleaseBranch=${is_release}") |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 197 | |
| 198 | // NOTE temporary workaround expose ONOS node ports |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 199 | def localHelmFlags = extraHelmFlags.trim() |
| 200 | + " --set global.log_level=${logLevel.toUpperCase()} " |
| 201 | + " --set onos-classic.onosSshPort=30115 " |
| 202 | + " --set onos-classic.onosApiPort=30120 " |
| 203 | + " --set onos-classic.onosOfPort=31653 " |
| 204 | + " --set onos-classic.individualOpenFlowNodePorts=true " |
| 205 | + testSpecificHelmFlags |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 206 | |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 207 | if (gerritProject != "") { |
| 208 | localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}") |
| 209 | } |
| 210 | |
| 211 | volthaDeploy([ |
| 212 | infraNamespace: infraNamespace, |
| 213 | volthaNamespace: volthaNamespace, |
| 214 | workflow: workflow.toLowerCase(), |
Hardik Windlass | 2b16434 | 2022-02-28 03:50:48 +0000 | [diff] [blame] | 215 | withMacLearning: enableMacLearning.toBoolean(), |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 216 | extraHelmFlags: localHelmFlags, |
| 217 | localCharts: localCharts, |
| 218 | bbsimReplica: olts.toInteger(), |
| 219 | dockerRegistry: registry, |
| 220 | ]) |
Matteo Scandolo | d17de3a | 2021-04-09 15:47:52 -0700 | [diff] [blame] | 221 | } |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 222 | |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 223 | // ----------------------------------------------------------------------- |
| 224 | // Intent: Replacing P_IDS with pgrep/pkill is a step forward. |
| 225 | // Why not simply use a pid file, capture _TAG=kail-startup above |
| 226 | // Grep runs the risk of terminating stray commands (??-good <=> bad-??) |
| 227 | // ----------------------------------------------------------------------- |
| 228 | println('Try out the pgrep/pkill commands') |
| 229 | def stream = sh( |
| 230 | returnStatus:false, |
| 231 | returnStdout:true, |
| 232 | script: '''pgrep --list-full kail-startup || true''' |
| 233 | ) |
| 234 | println("** pgrep output: ${stream}") |
| 235 | |
| 236 | // ----------------------------------------------------------------------- |
| 237 | // stop logging |
| 238 | // ----------------------------------------------------------------------- |
Matteo Scandolo | d17de3a | 2021-04-09 15:47:52 -0700 | [diff] [blame] | 239 | sh """ |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 240 | P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')" |
| 241 | if [ -n "\$P_IDS" ]; then |
| 242 | echo \$P_IDS |
| 243 | for P_ID in \$P_IDS; do |
| 244 | kill -9 \$P_ID |
| 245 | done |
| 246 | fi |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 247 | cd ${logsDir} |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 248 | gzip -k onos-voltha-startup-combined.log |
| 249 | rm onos-voltha-startup-combined.log |
Matteo Scandolo | d17de3a | 2021-04-09 15:47:52 -0700 | [diff] [blame] | 250 | """ |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 251 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 252 | |
| 253 | sh """ |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 254 | 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"& |
| 255 | 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"& |
| 256 | 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"& |
| 257 | bbsimDmiPortFwd=50075 |
| 258 | for i in {0..${olts.toInteger() - 1}}; do |
| 259 | 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"& |
| 260 | ((bbsimDmiPortFwd++)) |
| 261 | done |
Hardik Windlass | 3bb089a | 2022-03-22 17:56:03 +0000 | [diff] [blame] | 262 | if [ ${withMonitoring} = true ] ; then |
| 263 | 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"& |
| 264 | fi |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 265 | ps aux | grep port-forward |
| 266 | """ |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 267 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 268 | // setting ONOS log level |
| 269 | script |
| 270 | { |
| 271 | setOnosLogLevels([ |
| 272 | onosNamespace: infraNamespace, |
| 273 | apps: [ |
| 274 | 'org.opencord.dhcpl2relay', |
| 275 | 'org.opencord.olt', |
| 276 | 'org.opencord.aaa', |
| 277 | 'org.opencord.maclearner', |
| 278 | 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager', |
| 279 | 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager' |
| 280 | ], |
| 281 | logLevel: logLevel |
| 282 | ]) |
| 283 | } // script |
| 284 | } // if (teardown) |
| 285 | } // stage('Deploy Voltha') |
| 286 | |
| 287 | stage('Run test ' + testTarget + ' on ' + workflow + ' workFlow') |
| 288 | { |
| 289 | sh """ |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 290 | if [ ${withMonitoring} = true ] ; then |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 291 | mkdir -p "$WORKSPACE/voltha-pods-mem-consumption-${workflow}" |
| 292 | cd "$WORKSPACE/voltha-system-tests" |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 293 | make venv-activate-script |
| 294 | set +u && source .venv/bin/activate && set -u |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 295 | # Collect initial memory consumption |
Joey Armstrong | 0eb8bd8 | 2023-07-10 13:26:25 -0400 | [diff] [blame] | 296 | python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace} |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 297 | fi |
Hardik Windlass | e166049 | 2022-03-14 15:12:46 +0000 | [diff] [blame] | 298 | """ |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 299 | |
| 300 | sh """ |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 301 | mkdir -p ${logsDir} |
Hardik Windlass | d62442d | 2021-11-30 10:51:20 +0000 | [diff] [blame] | 302 | export ROBOT_MISC_ARGS="-d ${logsDir} ${params.extraRobotArgs} " |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 303 | 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}" |
Hardik Windlass | 7294730 | 2021-06-14 10:36:57 +0000 | [diff] [blame] | 304 | export KVSTOREPREFIX=voltha/voltha_voltha |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 305 | |
Joey Armstrong | 0eb8bd8 | 2023-07-10 13:26:25 -0400 | [diff] [blame] | 306 | make -C "$WORKSPACE/voltha-system-tests" ${testTarget} |
Hardik Windlass | 7294730 | 2021-06-14 10:36:57 +0000 | [diff] [blame] | 307 | """ |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 308 | |
| 309 | getPodsInfo("${logsDir}") |
| 310 | |
| 311 | sh """ |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 312 | # set +e |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 313 | # collect logs collected in the Robot Framework StartLogging keyword |
| 314 | cd ${logsDir} |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 315 | gzip *-combined.log |
| 316 | rm -f *-combined.log |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 317 | """ |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 318 | |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 319 | sh """ |
| 320 | if [ ${withMonitoring} = true ] ; then |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 321 | cd "$WORKSPACE/voltha-system-tests" |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 322 | make venv-activate-script |
| 323 | set +u && source .venv/bin/activate && set -u |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 324 | # Collect memory consumption of voltha pods once all the tests are complete |
Joey Armstrong | 0eb8bd8 | 2023-07-10 13:26:25 -0400 | [diff] [blame] | 325 | python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace} |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 326 | fi |
| 327 | """ |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 328 | } // stage |
| 329 | } // execute_test() |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 330 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 331 | // ----------------------------------------------------------------------- |
| 332 | // ----------------------------------------------------------------------- |
| 333 | def collectArtifacts(exitStatus) |
| 334 | { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 335 | getPodsInfo("$WORKSPACE/${exitStatus}") |
| 336 | sh """ |
Joey Armstrong | 0eb8bd8 | 2023-07-10 13:26:25 -0400 | [diff] [blame] | 337 | kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 338 | """ |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 339 | archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html,**/voltha-pods-mem-consumption-att/*,**/voltha-pods-mem-consumption-dt/*,**/voltha-pods-mem-consumption-tt/*' |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 340 | sh ''' |
| 341 | sync |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 342 | [[ $(pgrep --count kail) -gt 0 ]] && pkill --echo kail |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 343 | which voltctl |
| 344 | md5sum $(which voltctl) |
| 345 | ''' |
| 346 | step([$class: 'RobotPublisher', |
| 347 | disableArchiveOutput: false, |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 348 | logFileName: "**/*/log*.html", |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 349 | otherFiles: '', |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 350 | outputFileName: "**/*/output*.xml", |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 351 | outputPath: '.', |
| 352 | passThreshold: 100, |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 353 | reportFileName: "**/*/report*.html", |
Andrea Campanella | abc0977 | 2021-06-16 12:08:57 +0200 | [diff] [blame] | 354 | unstableThreshold: 0, |
| 355 | onlyCritical: true]); |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 356 | } |
| 357 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 358 | pipeline { |
| 359 | |
| 360 | /* no label, executor is determined by JJB */ |
| 361 | agent { |
| 362 | label "${params.buildNode}" |
| 363 | } |
| 364 | options { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 365 | timeout(time: "${timeout}", unit: 'MINUTES') |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 366 | } |
| 367 | environment { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 368 | KUBECONFIG="$HOME/.kube/kind-${clusterName}" |
| 369 | VOLTCONFIG="$HOME/.volt/config" |
| 370 | PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 371 | DIAGS_PROFILE="VOLTHA_PROFILE" |
Matteo Scandolo | 35ac782 | 2021-10-28 18:08:54 -0700 | [diff] [blame] | 372 | SSHPASS="karaf" |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 373 | } |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 374 | stages { |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 375 | stage('Download Code') { |
| 376 | steps { |
| 377 | getVolthaCode([ |
| 378 | branch: "${branch}", |
| 379 | gerritProject: "${gerritProject}", |
| 380 | gerritRefspec: "${gerritRefspec}", |
| 381 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 382 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 383 | ]) |
| 384 | } |
| 385 | } |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 386 | |
| 387 | stage('Build patch v1.1') |
| 388 | { |
| 389 | // build the patch only if gerritProject is specified |
| 390 | when |
| 391 | { |
| 392 | expression |
| 393 | { |
| 394 | return !gerritProject.isEmpty() |
| 395 | } |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 396 | } |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 397 | |
| 398 | steps |
| 399 | { |
| 400 | // NOTE that the correct patch has already been checked out |
| 401 | // during the getVolthaCode step |
| 402 | buildVolthaComponent("${gerritProject}") |
| 403 | } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 404 | } |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 405 | |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 406 | stage('Create K8s Cluster') |
| 407 | { |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 408 | steps |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 409 | { |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 410 | script |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 411 | { |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 412 | def clusterExists = sh( |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 413 | returnStdout: true, |
Joey Armstrong | e5aae1c | 2023-07-24 14:11:20 -0400 | [diff] [blame] | 414 | script: """kind get clusters | grep "${clusterName}" | wc -l""") |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 415 | |
| 416 | if (clusterExists.trim() == "0") |
| 417 | { |
| 418 | createKubernetesCluster([nodes: 3, name: clusterName]) |
| 419 | } |
| 420 | } // script |
| 421 | } // steps |
| 422 | } // stage('Create K8s Cluster') |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 423 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 424 | stage('Replace voltctl') |
| 425 | { |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 426 | // if the project is voltctl, override the downloaded one with the built one |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 427 | when { |
| 428 | expression { |
| 429 | return gerritProject == "voltctl" |
| 430 | } |
| 431 | } |
Joey Armstrong | 53cebea | 2023-07-26 10:35:53 -0400 | [diff] [blame] | 432 | |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 433 | // Hmmmm(?) where did the voltctl download happen ? |
| 434 | // Likely Makefile but would be helpful to document here. |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 435 | steps |
Joey Armstrong | 06a6837 | 2023-07-24 16:37:16 -0400 | [diff] [blame] | 436 | { |
| 437 | println("${iam} Running: installVoltctl($branch)") |
| 438 | installVoltctl("$branch") |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 439 | } // steps |
| 440 | } // stage |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 441 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 442 | stage('Load image in kind nodes') |
| 443 | { |
| 444 | when { |
| 445 | expression { |
| 446 | return !gerritProject.isEmpty() |
| 447 | } |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 448 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 449 | steps { |
| 450 | loadToKind() |
| 451 | } |
Matteo Scandolo | 29597f0 | 2021-02-12 10:53:57 -0800 | [diff] [blame] | 452 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 453 | |
| 454 | stage('Parse and execute tests') |
| 455 | { |
| 456 | steps { |
| 457 | script { |
| 458 | def tests = readYaml text: testTargets |
| 459 | |
| 460 | for(int i = 0;i<tests.size();i++) { |
| 461 | def test = tests[i] |
| 462 | def target = test["target"] |
| 463 | def workflow = test["workflow"] |
| 464 | def flags = test["flags"] |
| 465 | def teardown = test["teardown"].toBoolean() |
| 466 | def logging = test["logging"].toBoolean() |
| 467 | def testLogging = 'False' |
| 468 | if (logging) { |
| 469 | testLogging = 'True' |
| 470 | } |
| 471 | println "Executing test ${target} on workflow ${workflow} with logging ${testLogging} and extra flags ${flags}" |
| 472 | execute_test(target, workflow, testLogging, teardown, flags) |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | } // stage |
| 477 | } // stages |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 478 | |
| 479 | post |
| 480 | { |
| 481 | aborted { collectArtifacts('aborted') } |
| 482 | failure { collectArtifacts('failed') } |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 483 | always { collectArtifacts('always') } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 484 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 485 | } // pipeline |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 486 | |
| 487 | // EOF |