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 | |
Matteo Scandolo | a156b57 | 2021-02-04 11:52:18 -0800 | [diff] [blame] | 18 | library identifier: 'cord-jenkins-libraries@master', |
| 19 | retriever: modernSCM([ |
| 20 | $class: 'GitSCMSource', |
| 21 | remote: 'https://gerrit.opencord.org/ci-management.git' |
| 22 | ]) |
| 23 | |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 24 | def clusterName = "kind-ci" |
| 25 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 26 | def execute_test(testTarget, workflow, testLogging, teardown, testSpecificHelmFlags = "") |
| 27 | { |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 28 | def infraNamespace = "default" |
| 29 | def volthaNamespace = "voltha" |
| 30 | def logsDir = "$WORKSPACE/${testTarget}" |
Joey Armstrong | 293e16b | 2022-11-26 20:16:33 -0500 | [diff] [blame] | 31 | |
| 32 | stage('IAM') |
| 33 | { |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 34 | script |
| 35 | { |
| 36 | String iam = [ |
| 37 | 'ci-management', |
| 38 | 'jjb', |
| 39 | 'pipeline', |
| 40 | 'voltha', |
| 41 | 'master', |
| 42 | 'bbsim-tests.groovy' |
| 43 | ].join('/') |
Joey Armstrong | 293e16b | 2022-11-26 20:16:33 -0500 | [diff] [blame] | 44 | println("** ${iam}: ENTER") |
| 45 | |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 46 | String cmd = "which pkill" |
| 47 | def stream = sh( |
| 48 | returnStatus:false, |
| 49 | returnStdout: true, |
| 50 | script: cmd) |
| 51 | println(" ** ${cmd}:\n${stream}") |
| 52 | |
Joey Armstrong | 293e16b | 2022-11-26 20:16:33 -0500 | [diff] [blame] | 53 | println("** ${iam}: LEAVE") |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 54 | } |
Joey Armstrong | 293e16b | 2022-11-26 20:16:33 -0500 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | stage('Cleanup') { |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 58 | if (teardown) { |
| 59 | timeout(15) { |
| 60 | script { |
| 61 | helmTeardown(["default", infraNamespace, volthaNamespace]) |
| 62 | } |
| 63 | timeout(1) { |
| 64 | sh returnStdout: false, script: ''' |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 65 | # remove orphaned port-forward from different namespaces |
| 66 | ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true |
| 67 | ''' |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | } |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 71 | } |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 72 | |
| 73 | stage ('Initialize') |
| 74 | { |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 75 | // VOL-4926 - Is voltha-system-tests available ? |
| 76 | String cmd = [ |
| 77 | 'make', |
| 78 | '-C', "$WORKSPACE/voltha-system-tests", |
| 79 | "KAIL_PATH=\"$WORKSPACE/bin\"", |
| 80 | 'kail', |
| 81 | ].join(' ') |
| 82 | println(" ** Running: ${cmd}:\n") |
Joey Armstrong | beef4cd | 2023-01-18 09:59:58 -0500 | [diff] [blame] | 83 | sh("${cmd}") |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | stage('Deploy common infrastructure') { |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 87 | sh ''' |
Hardik Windlass | e166049 | 2022-03-14 15:12:46 +0000 | [diff] [blame] | 88 | helm repo add onf https://charts.opencord.org |
| 89 | helm repo update |
| 90 | if [ ${withMonitoring} = true ] ; then |
| 91 | helm install nem-monitoring onf/nem-monitoring \ |
| 92 | --set prometheus.alertmanager.enabled=false,prometheus.pushgateway.enabled=false \ |
| 93 | --set kpi_exporter.enabled=false,dashboards.xos=false,dashboards.onos=false,dashboards.aaa=false,dashboards.voltha=false |
| 94 | fi |
| 95 | ''' |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | stage('Deploy Voltha') { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 99 | if (teardown) { |
Matteo Scandolo | ea6348e | 2021-06-10 18:44:58 +0200 | [diff] [blame] | 100 | timeout(10) { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 101 | script { |
| 102 | |
| 103 | sh """ |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 104 | mkdir -p ${logsDir} |
| 105 | _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] | 106 | """ |
| 107 | |
| 108 | // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts |
| 109 | def localCharts = false |
Matteo Scandolo | ea6348e | 2021-06-10 18:44:58 +0200 | [diff] [blame] | 110 | if (volthaHelmChartsChange != "" || gerritProject == "voltha-helm-charts") { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 111 | localCharts = true |
| 112 | } |
| 113 | |
| 114 | // NOTE temporary workaround expose ONOS node ports |
Andrea Campanella | 9e41a60 | 2021-09-14 14:45:11 +0200 | [diff] [blame] | 115 | def localHelmFlags = extraHelmFlags.trim() + " --set global.log_level=${logLevel.toUpperCase()} " + |
Matteo Scandolo | 9114c89 | 2021-05-20 11:41:55 -0700 | [diff] [blame] | 116 | " --set onos-classic.onosSshPort=30115 " + |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 117 | " --set onos-classic.onosApiPort=30120 " + |
| 118 | " --set onos-classic.onosOfPort=31653 " + |
| 119 | " --set onos-classic.individualOpenFlowNodePorts=true " + testSpecificHelmFlags |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 120 | |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 121 | if (gerritProject != "") { |
| 122 | localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}") |
| 123 | } |
| 124 | |
| 125 | volthaDeploy([ |
| 126 | infraNamespace: infraNamespace, |
| 127 | volthaNamespace: volthaNamespace, |
| 128 | workflow: workflow.toLowerCase(), |
Hardik Windlass | 2b16434 | 2022-02-28 03:50:48 +0000 | [diff] [blame] | 129 | withMacLearning: enableMacLearning.toBoolean(), |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 130 | extraHelmFlags: localHelmFlags, |
| 131 | localCharts: localCharts, |
| 132 | bbsimReplica: olts.toInteger(), |
| 133 | dockerRegistry: registry, |
| 134 | ]) |
Matteo Scandolo | d17de3a | 2021-04-09 15:47:52 -0700 | [diff] [blame] | 135 | } |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 136 | |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 137 | // stop logging |
Matteo Scandolo | d17de3a | 2021-04-09 15:47:52 -0700 | [diff] [blame] | 138 | sh """ |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 139 | P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')" |
| 140 | if [ -n "\$P_IDS" ]; then |
| 141 | echo \$P_IDS |
| 142 | for P_ID in \$P_IDS; do |
| 143 | kill -9 \$P_ID |
| 144 | done |
| 145 | fi |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 146 | cd ${logsDir} |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 147 | gzip -k onos-voltha-startup-combined.log |
| 148 | rm onos-voltha-startup-combined.log |
Matteo Scandolo | d17de3a | 2021-04-09 15:47:52 -0700 | [diff] [blame] | 149 | """ |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 150 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 151 | |
| 152 | sh """ |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 153 | 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"& |
| 154 | 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"& |
| 155 | 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"& |
| 156 | bbsimDmiPortFwd=50075 |
| 157 | for i in {0..${olts.toInteger() - 1}}; do |
| 158 | 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"& |
| 159 | ((bbsimDmiPortFwd++)) |
| 160 | done |
Hardik Windlass | 3bb089a | 2022-03-22 17:56:03 +0000 | [diff] [blame] | 161 | if [ ${withMonitoring} = true ] ; then |
| 162 | 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"& |
| 163 | fi |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 164 | ps aux | grep port-forward |
| 165 | """ |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 166 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 167 | // setting ONOS log level |
| 168 | script |
| 169 | { |
| 170 | setOnosLogLevels([ |
| 171 | onosNamespace: infraNamespace, |
| 172 | apps: [ |
| 173 | 'org.opencord.dhcpl2relay', |
| 174 | 'org.opencord.olt', |
| 175 | 'org.opencord.aaa', |
| 176 | 'org.opencord.maclearner', |
| 177 | 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager', |
| 178 | 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager' |
| 179 | ], |
| 180 | logLevel: logLevel |
| 181 | ]) |
| 182 | } // script |
| 183 | } // if (teardown) |
| 184 | } // stage('Deploy Voltha') |
| 185 | |
| 186 | stage('Run test ' + testTarget + ' on ' + workflow + ' workFlow') |
| 187 | { |
| 188 | sh """ |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 189 | if [ ${withMonitoring} = true ] ; then |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 190 | mkdir -p "$WORKSPACE/voltha-pods-mem-consumption-${workflow}" |
| 191 | cd "$WORKSPACE/voltha-system-tests" |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 192 | make vst_venv |
| 193 | source ./vst_venv/bin/activate || true |
| 194 | # Collect initial memory consumption |
| 195 | python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace} || true |
| 196 | fi |
Hardik Windlass | e166049 | 2022-03-14 15:12:46 +0000 | [diff] [blame] | 197 | """ |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 198 | |
| 199 | sh """ |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 200 | mkdir -p ${logsDir} |
Hardik Windlass | d62442d | 2021-11-30 10:51:20 +0000 | [diff] [blame] | 201 | export ROBOT_MISC_ARGS="-d ${logsDir} ${params.extraRobotArgs} " |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 202 | 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] | 203 | export KVSTOREPREFIX=voltha/voltha_voltha |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 204 | |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 205 | make -C "$WORKSPACE/voltha-system-tests" ${testTarget} || true |
Hardik Windlass | 7294730 | 2021-06-14 10:36:57 +0000 | [diff] [blame] | 206 | """ |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 207 | |
| 208 | getPodsInfo("${logsDir}") |
| 209 | |
| 210 | sh """ |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 211 | set +e |
| 212 | # collect logs collected in the Robot Framework StartLogging keyword |
| 213 | cd ${logsDir} |
| 214 | gzip *-combined.log || true |
| 215 | rm *-combined.log || true |
| 216 | """ |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 217 | |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 218 | sh """ |
| 219 | if [ ${withMonitoring} = true ] ; then |
Joey Armstrong | 8c6f648 | 2023-01-12 12:31:44 -0500 | [diff] [blame] | 220 | cd "$WORKSPACE/voltha-system-tests" |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 221 | source ./vst_venv/bin/activate || true |
| 222 | # Collect memory consumption of voltha pods once all the tests are complete |
| 223 | python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace} || true |
| 224 | fi |
| 225 | """ |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 226 | } // stage |
| 227 | } // execute_test() |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 228 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 229 | // ----------------------------------------------------------------------- |
| 230 | // ----------------------------------------------------------------------- |
| 231 | def collectArtifacts(exitStatus) |
| 232 | { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 233 | getPodsInfo("$WORKSPACE/${exitStatus}") |
| 234 | sh """ |
| 235 | kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log || true |
| 236 | """ |
Hardik Windlass | 8cd517c | 2022-03-22 04:01:40 +0000 | [diff] [blame] | 237 | 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] | 238 | sh ''' |
| 239 | sync |
| 240 | pkill kail || true |
| 241 | which voltctl |
| 242 | md5sum $(which voltctl) |
| 243 | ''' |
| 244 | step([$class: 'RobotPublisher', |
| 245 | disableArchiveOutput: false, |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 246 | logFileName: "**/*/log*.html", |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 247 | otherFiles: '', |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 248 | outputFileName: "**/*/output*.xml", |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 249 | outputPath: '.', |
| 250 | passThreshold: 100, |
Matteo Scandolo | 9c230bb | 2021-10-22 12:48:39 -0700 | [diff] [blame] | 251 | reportFileName: "**/*/report*.html", |
Andrea Campanella | abc0977 | 2021-06-16 12:08:57 +0200 | [diff] [blame] | 252 | unstableThreshold: 0, |
| 253 | onlyCritical: true]); |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 254 | } |
| 255 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 256 | pipeline { |
| 257 | |
| 258 | /* no label, executor is determined by JJB */ |
| 259 | agent { |
| 260 | label "${params.buildNode}" |
| 261 | } |
| 262 | options { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 263 | timeout(time: "${timeout}", unit: 'MINUTES') |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 264 | } |
| 265 | environment { |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 266 | KUBECONFIG="$HOME/.kube/kind-${clusterName}" |
| 267 | VOLTCONFIG="$HOME/.volt/config" |
| 268 | 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] | 269 | DIAGS_PROFILE="VOLTHA_PROFILE" |
Matteo Scandolo | 35ac782 | 2021-10-28 18:08:54 -0700 | [diff] [blame] | 270 | SSHPASS="karaf" |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 271 | } |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 272 | stages { |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 273 | stage('Download Code') { |
| 274 | steps { |
| 275 | getVolthaCode([ |
| 276 | branch: "${branch}", |
| 277 | gerritProject: "${gerritProject}", |
| 278 | gerritRefspec: "${gerritRefspec}", |
| 279 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 280 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 281 | ]) |
| 282 | } |
| 283 | } |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 284 | |
| 285 | stage('Build patch v1.1') |
| 286 | { |
| 287 | // build the patch only if gerritProject is specified |
| 288 | when |
| 289 | { |
| 290 | expression |
| 291 | { |
| 292 | return !gerritProject.isEmpty() |
| 293 | } |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 294 | } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 295 | steps { |
| 296 | // NOTE that the correct patch has already been checked out |
| 297 | // during the getVolthaCode step |
| 298 | buildVolthaComponent("${gerritProject}") |
| 299 | } |
| 300 | } |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 301 | |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 302 | stage('Create K8s Cluster') |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 303 | { |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 304 | steps |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 305 | { |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 306 | script |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 307 | { |
Joey Armstrong | 6df6500 | 2023-04-14 12:24:13 -0400 | [diff] [blame] | 308 | /* |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 309 | println(' ** Calling installKind.groovy: ENTER') |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 310 | // chicken-n-egg problem, kind command needed |
| 311 | // to determine if kubernetes cluster is active |
Joey Armstrong | 41feb7c | 2023-04-14 11:28:04 -0400 | [diff] [blame] | 312 | installKind() { debug:true } |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 313 | println(' ** Calling installKind.groovy: LEAVE') |
Joey Armstrong | 6df6500 | 2023-04-14 12:24:13 -0400 | [diff] [blame] | 314 | */ |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 315 | |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 316 | def clusterExists = sh( |
| 317 | returnStdout: true, |
| 318 | script: """kind get clusters | grep ${clusterName} | wc -l""") |
| 319 | |
| 320 | if (clusterExists.trim() == "0") |
| 321 | { |
| 322 | createKubernetesCluster([nodes: 3, name: clusterName]) |
| 323 | } |
| 324 | } // script |
| 325 | } // steps |
| 326 | } // stage('Create K8s Cluster') |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 327 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 328 | stage('Replace voltctl') |
| 329 | { |
| 330 | // if the project is voltctl override the downloaded one with the built one |
| 331 | when { |
| 332 | expression { |
| 333 | return gerritProject == "voltctl" |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | steps |
| 338 | { |
| 339 | sh """ |
Joey Armstrong | 93c8273 | 2023-02-07 03:01:25 -0500 | [diff] [blame] | 340 | # [TODO] - why is this platform specific (?) |
| 341 | # [TODO] - revisit, command alteration has masked an error (see: voltha-2.11). |
| 342 | # find will fail when no filsystem matches are found. |
| 343 | # mv(ls) succeded simply by accident/invoked at a different time. |
Hardik Windlass | c6ba23e | 2021-06-08 08:19:52 +0000 | [diff] [blame] | 344 | mv `ls $WORKSPACE/voltctl/release/voltctl-*-linux-amd*` $WORKSPACE/bin/voltctl |
| 345 | chmod +x $WORKSPACE/bin/voltctl |
| 346 | """ |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 347 | } // steps |
| 348 | } // stage |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 349 | |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 350 | stage('Load image in kind nodes') |
| 351 | { |
| 352 | when { |
| 353 | expression { |
| 354 | return !gerritProject.isEmpty() |
| 355 | } |
Hardik Windlass | ec9341b | 2021-06-07 11:58:29 +0000 | [diff] [blame] | 356 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 357 | steps { |
| 358 | loadToKind() |
| 359 | } |
Matteo Scandolo | 29597f0 | 2021-02-12 10:53:57 -0800 | [diff] [blame] | 360 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 361 | |
| 362 | stage('Parse and execute tests') |
| 363 | { |
| 364 | steps { |
| 365 | script { |
| 366 | def tests = readYaml text: testTargets |
| 367 | |
| 368 | for(int i = 0;i<tests.size();i++) { |
| 369 | def test = tests[i] |
| 370 | def target = test["target"] |
| 371 | def workflow = test["workflow"] |
| 372 | def flags = test["flags"] |
| 373 | def teardown = test["teardown"].toBoolean() |
| 374 | def logging = test["logging"].toBoolean() |
| 375 | def testLogging = 'False' |
| 376 | if (logging) { |
| 377 | testLogging = 'True' |
| 378 | } |
| 379 | println "Executing test ${target} on workflow ${workflow} with logging ${testLogging} and extra flags ${flags}" |
| 380 | execute_test(target, workflow, testLogging, teardown, flags) |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | } // stage |
| 385 | } // stages |
Joey Armstrong | 84adc54 | 2023-04-11 14:47:34 -0400 | [diff] [blame] | 386 | |
| 387 | post |
| 388 | { |
| 389 | aborted { collectArtifacts('aborted') } |
| 390 | failure { collectArtifacts('failed') } |
Joey Armstrong | bf49292 | 2023-04-13 17:05:09 -0400 | [diff] [blame] | 391 | always { collectArtifacts('always') } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 392 | } |
Joey Armstrong | 2d5a7c1 | 2023-04-13 09:37:42 -0400 | [diff] [blame] | 393 | } // pipeline |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 394 | |
| 395 | // EOF |