Joey Armstrong | beef4cd | 2023-01-18 09:59:58 -0500 | [diff] [blame] | 1 | // Copyright 2019-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Matteo Scandolo | 633a2eb | 2022-03-28 08:26:17 -0700 | [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 | |
| 15 | // deploy VOLTHA and performs a scale test with the LWC controller |
| 16 | |
| 17 | library identifier: 'cord-jenkins-libraries@master', |
| 18 | retriever: modernSCM([ |
| 19 | $class: 'GitSCMSource', |
| 20 | remote: 'https://gerrit.opencord.org/ci-management.git' |
| 21 | ]) |
| 22 | |
Joey Armstrong | 6540541 | 2022-11-22 10:43:06 -0500 | [diff] [blame] | 23 | // [TODO] fix path, achilles heel for testing. |
Matteo Scandolo | e133ae5 | 2022-03-28 15:41:13 -0700 | [diff] [blame] | 24 | def lwc_helm_chart_path="/home/jenkins/Radisys_LWC_helm_charts" |
| 25 | def value_file="/home/jenkins/lwc-values.yaml" |
Matteo Scandolo | e133ae5 | 2022-03-28 15:41:13 -0700 | [diff] [blame] | 26 | def workflow="dt" |
| 27 | |
Matteo Scandolo | 633a2eb | 2022-03-28 08:26:17 -0700 | [diff] [blame] | 28 | pipeline { |
| 29 | |
| 30 | /* no label, executor is determined by JJB */ |
| 31 | agent { |
| 32 | label "${params.buildNode}" |
| 33 | } |
| 34 | options { |
| 35 | timeout(time: 60, unit: 'MINUTES') |
| 36 | } |
| 37 | environment { |
| 38 | JENKINS_NODE_COOKIE="dontKillMe" // do not kill processes after the build is done |
| 39 | KUBECONFIG="$HOME/.kube/config" |
| 40 | VOLTCONFIG="$HOME/.volt/config" |
| 41 | SSHPASS="karaf" |
| 42 | VOLTHA_LOG_LEVEL="${logLevel}" |
| 43 | NUM_OF_BBSIM="${olts}" |
| 44 | NUM_OF_OPENONU="${openonuAdapterReplicas}" |
| 45 | NUM_OF_ONOS="${onosReplicas}" |
| 46 | NUM_OF_ATOMIX="${atomixReplicas}" |
| 47 | EXTRA_HELM_FLAGS=" " |
| 48 | LOG_FOLDER="$WORKSPACE/logs" |
| 49 | GERRIT_PROJECT="${GERRIT_PROJECT}" |
| 50 | PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" |
| 51 | } |
| 52 | |
| 53 | stages { |
| 54 | stage ('Cleanup') { |
| 55 | steps { |
| 56 | script { |
| 57 | try { |
| 58 | timeout(time: 5, unit: 'MINUTES') { |
| 59 | sh returnStdout: false, script: ''' |
| 60 | cd $WORKSPACE |
| 61 | rm -rf $WORKSPACE/* |
| 62 | ''' |
| 63 | // removing the voltha-infra chart first |
| 64 | // if we don't ONOS might get stuck because of all the events when BBSim goes down |
| 65 | sh returnStdout: false, script: ''' |
| 66 | set +x |
Matteo Scandolo | e133ae5 | 2022-03-28 15:41:13 -0700 | [diff] [blame] | 67 | helm del -n infra voltha-infra || true |
Matteo Scandolo | 633a2eb | 2022-03-28 08:26:17 -0700 | [diff] [blame] | 68 | helm del voltha-infra || true |
| 69 | echo -ne "\nWaiting for ONOS to be removed..." |
| 70 | onos=$(kubectl get pod -n default -l app=onos-classic --no-headers | wc -l) |
| 71 | while [[ $onos != 0 ]]; do |
| 72 | onos=$(kubectl get pod -n default -l app=onos-classic --no-headers | wc -l) |
| 73 | sleep 5 |
| 74 | echo -ne "." |
| 75 | done |
| 76 | ''' |
| 77 | } |
| 78 | } catch(org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) { |
| 79 | // if we have a timeout in the Cleanup fase most likely ONOS got stuck somewhere, thuse force remove the pods |
| 80 | sh ''' |
| 81 | kubectl get pods | grep Terminating | awk '{print $1}' | xargs kubectl delete pod --force --grace-period=0 |
| 82 | ''' |
| 83 | } |
| 84 | timeout(time: 10, unit: 'MINUTES') { |
| 85 | script { |
| 86 | helmTeardown(["default", "voltha1", "voltha-infra"]) |
| 87 | } |
| 88 | sh returnStdout: false, script: ''' |
| 89 | helm repo add onf https://charts.opencord.org |
| 90 | helm repo update |
| 91 | |
| 92 | # remove all persistent volume claims |
| 93 | kubectl delete pvc --all-namespaces --all |
| 94 | PVCS=\$(kubectl get pvc --all-namespaces --no-headers | wc -l) |
| 95 | while [[ \$PVCS != 0 ]]; do |
| 96 | sleep 5 |
| 97 | PVCS=\$(kubectl get pvc --all-namespaces --no-headers | wc -l) |
| 98 | done |
| 99 | |
| 100 | # remove orphaned port-forward from different namespaces |
| 101 | ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true |
| 102 | ''' |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | } |
Matteo Scandolo | e133ae5 | 2022-03-28 15:41:13 -0700 | [diff] [blame] | 107 | stage('Download Code') { |
| 108 | steps { |
| 109 | getVolthaCode([ |
| 110 | branch: "${release}", |
| 111 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 112 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 113 | ]) |
| 114 | } |
| 115 | } |
Matteo Scandolo | 633a2eb | 2022-03-28 08:26:17 -0700 | [diff] [blame] | 116 | stage('Deploy Voltha') { |
| 117 | steps { |
Matteo Scandolo | e133ae5 | 2022-03-28 15:41:13 -0700 | [diff] [blame] | 118 | timeout(time: 5, unit: 'MINUTES') { |
Matteo Scandolo | 633a2eb | 2022-03-28 08:26:17 -0700 | [diff] [blame] | 119 | installVoltctl("${release}") |
| 120 | script { |
| 121 | startComponentsLogs([ |
| 122 | appsToLog: [ |
| 123 | 'app.kubernetes.io/name=etcd', |
| 124 | 'app.kubernetes.io/name=kafka', |
| 125 | 'app=lwc', |
| 126 | 'app=adapter-open-onu', |
| 127 | 'app=adapter-open-olt', |
| 128 | 'app=rw-core', |
| 129 | 'app=bbsim', |
| 130 | ] |
| 131 | ]) |
| 132 | } |
| 133 | } |
Matteo Scandolo | e133ae5 | 2022-03-28 15:41:13 -0700 | [diff] [blame] | 134 | timeout(time: 10, unit: 'MINUTES') { |
| 135 | sh """ |
| 136 | cd /home/jenkins/Radisys_LWC_helm_charts |
| 137 | |
| 138 | helm dep update ${lwc_helm_chart_path}/voltha-infra |
| 139 | helm upgrade --install --create-namespace -n infra voltha-infra ${lwc_helm_chart_path}/voltha-infra -f examples/${workflow}-values.yaml \ |
| 140 | -f ${value_file} --wait |
| 141 | |
| 142 | # helm dep update ${lwc_helm_chart_path}/voltha-stack |
| 143 | helm upgrade --install --create-namespace -n voltha1 voltha1 onf/voltha-stack \ |
| 144 | --set voltha.ingress.enabled=true --set voltha.ingress.enableVirtualHosts=true --set voltha.fullHostnameOverride=voltha.scale1.dev \ |
| 145 | -f ${value_file} --wait |
| 146 | |
Matteo Scandolo | ea09af8 | 2022-05-10 07:48:45 -0700 | [diff] [blame] | 147 | helm upgrade --install -n voltha1 bbsim0 onf/bbsim --set olt_id=10 -f examples/${workflow}-values.yaml --set pon=${pons},onu=${onus} --version 4.6.0 --set oltRebootDelay=5 --wait |
Matteo Scandolo | e133ae5 | 2022-03-28 15:41:13 -0700 | [diff] [blame] | 148 | """ |
| 149 | } |
Matteo Scandolo | 633a2eb | 2022-03-28 08:26:17 -0700 | [diff] [blame] | 150 | } |
| 151 | } |
Matteo Scandolo | e133ae5 | 2022-03-28 15:41:13 -0700 | [diff] [blame] | 152 | stage('Load MIB Template') { |
| 153 | when { |
| 154 | expression { |
| 155 | return params.withMibTemplate |
| 156 | } |
| 157 | } |
| 158 | steps { |
| 159 | sh """ |
| 160 | # load MIB template |
| 161 | wget ${mibTemplateUrl} -O mibTemplate.json |
| 162 | cat mibTemplate.json | kubectl exec -it -n infra \$(kubectl get pods -n infra |grep etcd-0 | awk 'NR==1{print \$1}') -- etcdctl put service/voltha/omci_mibs/go_templates/BBSM/12345123451234512345/BBSM_IMG_00001 |
| 163 | """ |
| 164 | } |
| 165 | } |
| 166 | stage('Run Test') { |
| 167 | steps { |
| 168 | sh """ |
| 169 | mkdir -p $WORKSPACE/RobotLogs |
| 170 | cd $WORKSPACE/voltha-system-tests |
| 171 | make vst_venv |
| 172 | |
| 173 | daemonize -E JENKINS_NODE_COOKIE="dontKillMe" /usr/local/bin/kubectl port-forward -n infra svc/lwc 8182:8181 --address 0.0.0.0 |
| 174 | |
| 175 | source ./vst_venv/bin/activate |
| 176 | robot -d $WORKSPACE/RobotLogs \ |
| 177 | --exitonfailure \ |
Matteo Scandolo | ea09af8 | 2022-05-10 07:48:45 -0700 | [diff] [blame] | 178 | -v pon:${pons} -v onu:${onus} \ |
Matteo Scandolo | e133ae5 | 2022-03-28 15:41:13 -0700 | [diff] [blame] | 179 | tests/scale/Voltha_Scale_Tests_lwc.robot |
| 180 | |
| 181 | python tests/scale/collect-result.py -r $WORKSPACE/RobotLogs/output.xml -p $WORKSPACE/plots > $WORKSPACE/execution-time.txt || true |
| 182 | cat $WORKSPACE/execution-time.txt |
| 183 | """ |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | post { |
| 188 | always { |
| 189 | stopComponentsLogs() |
| 190 | script { |
| 191 | try { |
| 192 | step([$class: 'RobotPublisher', |
| 193 | disableArchiveOutput: false, |
| 194 | logFileName: '**/log*.html', |
| 195 | otherFiles: '', |
| 196 | outputFileName: '**/output*.xml', |
| 197 | outputPath: 'RobotLogs', |
| 198 | passThreshold: 100, |
| 199 | reportFileName: '**/report*.html', |
| 200 | onlyCritical: true, |
| 201 | unstableThreshold: 0]); |
| 202 | } catch (Exception e) { |
| 203 | println "Cannot archive Robot Logs: ${e.toString()}" |
| 204 | } |
| 205 | } |
| 206 | plot([ |
| 207 | csvFileName: 'scale-test.csv', |
| 208 | csvSeries: [ |
| 209 | [file: 'plots/plot-lwc-olts.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''], |
| 210 | [file: 'plots/plot-voltha-onus.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''], |
| 211 | [file: 'plots/plot-lwc-ports.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''], |
| 212 | [file: 'plots/plot-voltha-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''], |
| 213 | [file: 'plots/plot-voltha-openolt-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''], |
| 214 | [file: 'plots/plot-lwc-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''], |
| 215 | [file: 'plots/plot-voltha-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''], |
| 216 | [file: 'plots/plot-voltha-openolt-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''], |
| 217 | [file: 'plots/plot-lwc-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''], |
| 218 | ], |
| 219 | group: 'Voltha-Scale-Numbers', numBuilds: '20', style: 'line', title: "Scale Test (OLTs: ${olts}, PONs: ${pons}, ONUs: ${onus}, UNIs: ${unis})", yaxis: 'Time (s)', useDescr: true |
| 220 | ]) |
| 221 | getPodsInfo("$LOG_FOLDER") |
| 222 | archiveArtifacts artifacts: 'execution-time.txt,logs/*,logs/pprof/*,RobotLogs/**/*,plots/*,etcd-metrics/*' |
| 223 | } |
Matteo Scandolo | 633a2eb | 2022-03-28 08:26:17 -0700 | [diff] [blame] | 224 | } |
| 225 | } |