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