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