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