blob: 84308ac3f338a037609ae151ec778fa9c6224be9 [file] [log] [blame]
Joey Armstrong980e37f2023-02-28 18:57:41 -05001// Copyright 2019-2023 Open Networking Foundation (ONF) and the ONF Contributors
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
17library identifier: 'cord-jenkins-libraries@master',
18 retriever: modernSCM([
19 $class: 'GitSCMSource',
20 remote: 'https://gerrit.opencord.org/ci-management.git'
21])
22
23// [TODO] fix path, achilles heel for testing.
24def lwc_helm_chart_path="/home/jenkins/Radisys_LWC_helm_charts"
25def value_file="/home/jenkins/lwc-values.yaml"
26def workflow="dt"
27
28pipeline {
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
67 helm del -n infra voltha-infra || true
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 }
107 stage('Download Code') {
108 steps {
109 getVolthaCode([
110 branch: "${release}",
111 volthaSystemTestsChange: "${volthaSystemTestsChange}",
112 volthaHelmChartsChange: "${volthaHelmChartsChange}",
113 ])
114 }
115 }
116 stage('Deploy Voltha') {
117 steps {
118 timeout(time: 5, unit: 'MINUTES') {
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 }
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
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
148 """
149 }
150 }
151 }
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 daemonize -E JENKINS_NODE_COOKIE="dontKillMe" /usr/local/bin/kubectl port-forward -n voltha1 svc/voltha1-voltha-api 55555 --address 0.0.0.0
175
176 source ./vst_venv/bin/activate
177 robot -d $WORKSPACE/RobotLogs \
178 --exitonfailure \
179 -v pon:${pons} -v onu:${onus} \
180 tests/scale/Voltha_Scale_Tests_lwc.robot
181
182 python tests/scale/collect-result.py -r $WORKSPACE/RobotLogs/output.xml -p $WORKSPACE/plots > $WORKSPACE/execution-time.txt || true
183 cat $WORKSPACE/execution-time.txt
184 """
185 }
186 }
187 }
188 post {
189 always {
190 stopComponentsLogs()
191 script {
192 try {
193 step([$class: 'RobotPublisher',
194 disableArchiveOutput: false,
195 logFileName: '**/log*.html',
196 otherFiles: '',
197 outputFileName: '**/output*.xml',
198 outputPath: 'RobotLogs',
199 passThreshold: 100,
200 reportFileName: '**/report*.html',
201 onlyCritical: true,
202 unstableThreshold: 0]);
203 } catch (Exception e) {
204 println "Cannot archive Robot Logs: ${e.toString()}"
205 }
206 }
207 plot([
208 csvFileName: 'scale-test.csv',
209 csvSeries: [
210 [file: 'plots/plot-lwc-olts.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
211 [file: 'plots/plot-voltha-onus.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
212 [file: 'plots/plot-lwc-ports.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
213 [file: 'plots/plot-voltha-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
214 [file: 'plots/plot-voltha-openolt-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
215 [file: 'plots/plot-lwc-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
216 [file: 'plots/plot-voltha-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
217 [file: 'plots/plot-voltha-openolt-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
218 [file: 'plots/plot-lwc-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
219 ],
220 group: 'Voltha-Scale-Numbers', numBuilds: '20', style: 'line', title: "Scale Test (OLTs: ${olts}, PONs: ${pons}, ONUs: ${onus}, UNIs: ${unis})", yaxis: 'Time (s)', useDescr: true
221 ])
222 getPodsInfo("$LOG_FOLDER")
223 archiveArtifacts artifacts: 'execution-time.txt,logs/*,logs/pprof/*,RobotLogs/**/*,plots/*,etcd-metrics/*'
224 }
225 }
226}