blob: 75b48e24435cfb01b06c54c43cd16824f50a9c43 [file] [log] [blame]
Matteo Scandolo633a2eb2022-03-28 08:26:17 -07001// Copyright 2019-present Open Networking Foundation
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
Matteo Scandoloe133ae52022-03-28 15:41:13 -070023def lwc_helm_chart_path="/home/jenkins/Radisys_LWC_helm_charts"
24def value_file="/home/jenkins/lwc-values.yaml"
Matteo Scandoloe133ae52022-03-28 15:41:13 -070025def workflow="dt"
26
Matteo Scandolo633a2eb2022-03-28 08:26:17 -070027pipeline {
28
29 /* no label, executor is determined by JJB */
30 agent {
31 label "${params.buildNode}"
32 }
33 options {
34 timeout(time: 60, unit: 'MINUTES')
35 }
36 environment {
37 JENKINS_NODE_COOKIE="dontKillMe" // do not kill processes after the build is done
38 KUBECONFIG="$HOME/.kube/config"
39 VOLTCONFIG="$HOME/.volt/config"
40 SSHPASS="karaf"
41 VOLTHA_LOG_LEVEL="${logLevel}"
42 NUM_OF_BBSIM="${olts}"
43 NUM_OF_OPENONU="${openonuAdapterReplicas}"
44 NUM_OF_ONOS="${onosReplicas}"
45 NUM_OF_ATOMIX="${atomixReplicas}"
46 EXTRA_HELM_FLAGS=" "
47 LOG_FOLDER="$WORKSPACE/logs"
48 GERRIT_PROJECT="${GERRIT_PROJECT}"
49 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
50 }
51
52 stages {
53 stage ('Cleanup') {
54 steps {
55 script {
56 try {
57 timeout(time: 5, unit: 'MINUTES') {
58 sh returnStdout: false, script: '''
59 cd $WORKSPACE
60 rm -rf $WORKSPACE/*
61 '''
62 // removing the voltha-infra chart first
63 // if we don't ONOS might get stuck because of all the events when BBSim goes down
64 sh returnStdout: false, script: '''
65 set +x
Matteo Scandoloe133ae52022-03-28 15:41:13 -070066 helm del -n infra voltha-infra || true
Matteo Scandolo633a2eb2022-03-28 08:26:17 -070067 helm del voltha-infra || true
68 echo -ne "\nWaiting for ONOS to be removed..."
69 onos=$(kubectl get pod -n default -l app=onos-classic --no-headers | wc -l)
70 while [[ $onos != 0 ]]; do
71 onos=$(kubectl get pod -n default -l app=onos-classic --no-headers | wc -l)
72 sleep 5
73 echo -ne "."
74 done
75 '''
76 }
77 } catch(org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
78 // if we have a timeout in the Cleanup fase most likely ONOS got stuck somewhere, thuse force remove the pods
79 sh '''
80 kubectl get pods | grep Terminating | awk '{print $1}' | xargs kubectl delete pod --force --grace-period=0
81 '''
82 }
83 timeout(time: 10, unit: 'MINUTES') {
84 script {
85 helmTeardown(["default", "voltha1", "voltha-infra"])
86 }
87 sh returnStdout: false, script: '''
88 helm repo add onf https://charts.opencord.org
89 helm repo update
90
91 # remove all persistent volume claims
92 kubectl delete pvc --all-namespaces --all
93 PVCS=\$(kubectl get pvc --all-namespaces --no-headers | wc -l)
94 while [[ \$PVCS != 0 ]]; do
95 sleep 5
96 PVCS=\$(kubectl get pvc --all-namespaces --no-headers | wc -l)
97 done
98
99 # remove orphaned port-forward from different namespaces
100 ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true
101 '''
102 }
103 }
104 }
105 }
Matteo Scandoloe133ae52022-03-28 15:41:13 -0700106 stage('Download Code') {
107 steps {
108 getVolthaCode([
109 branch: "${release}",
110 volthaSystemTestsChange: "${volthaSystemTestsChange}",
111 volthaHelmChartsChange: "${volthaHelmChartsChange}",
112 ])
113 }
114 }
Matteo Scandolo633a2eb2022-03-28 08:26:17 -0700115 stage('Deploy Voltha') {
116 steps {
Matteo Scandoloe133ae52022-03-28 15:41:13 -0700117 timeout(time: 5, unit: 'MINUTES') {
Matteo Scandolo633a2eb2022-03-28 08:26:17 -0700118 installVoltctl("${release}")
119 script {
120 startComponentsLogs([
121 appsToLog: [
122 'app.kubernetes.io/name=etcd',
123 'app.kubernetes.io/name=kafka',
124 'app=lwc',
125 'app=adapter-open-onu',
126 'app=adapter-open-olt',
127 'app=rw-core',
128 'app=bbsim',
129 ]
130 ])
131 }
132 }
Matteo Scandoloe133ae52022-03-28 15:41:13 -0700133 timeout(time: 10, unit: 'MINUTES') {
134 sh """
135 cd /home/jenkins/Radisys_LWC_helm_charts
136
137 helm dep update ${lwc_helm_chart_path}/voltha-infra
138 helm upgrade --install --create-namespace -n infra voltha-infra ${lwc_helm_chart_path}/voltha-infra -f examples/${workflow}-values.yaml \
139 -f ${value_file} --wait
140
141 # helm dep update ${lwc_helm_chart_path}/voltha-stack
142 helm upgrade --install --create-namespace -n voltha1 voltha1 onf/voltha-stack \
143 --set voltha.ingress.enabled=true --set voltha.ingress.enableVirtualHosts=true --set voltha.fullHostnameOverride=voltha.scale1.dev \
144 -f ${value_file} --wait
145
Matteo Scandoloea09af82022-05-10 07:48:45 -0700146 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 Scandoloe133ae52022-03-28 15:41:13 -0700147 """
148 }
Matteo Scandolo633a2eb2022-03-28 08:26:17 -0700149 }
150 }
Matteo Scandoloe133ae52022-03-28 15:41:13 -0700151 stage('Load MIB Template') {
152 when {
153 expression {
154 return params.withMibTemplate
155 }
156 }
157 steps {
158 sh """
159 # load MIB template
160 wget ${mibTemplateUrl} -O mibTemplate.json
161 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
162 """
163 }
164 }
165 stage('Run Test') {
166 steps {
167 sh """
168 mkdir -p $WORKSPACE/RobotLogs
169 cd $WORKSPACE/voltha-system-tests
170 make vst_venv
171
172 daemonize -E JENKINS_NODE_COOKIE="dontKillMe" /usr/local/bin/kubectl port-forward -n infra svc/lwc 8182:8181 --address 0.0.0.0
Matteo Scandolo175c2092022-05-09 15:51:12 -0700173 daemonize -E JENKINS_NODE_COOKIE="dontKillMe" /usr/local/bin/kubectl port-forward -n voltha1 svc/voltha1-voltha-api 55555 --address 0.0.0.0
Matteo Scandoloe133ae52022-03-28 15:41:13 -0700174
175 source ./vst_venv/bin/activate
176 robot -d $WORKSPACE/RobotLogs \
177 --exitonfailure \
Matteo Scandoloea09af82022-05-10 07:48:45 -0700178 -v pon:${pons} -v onu:${onus} \
Matteo Scandoloe133ae52022-03-28 15:41:13 -0700179 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 Scandolo633a2eb2022-03-28 08:26:17 -0700224 }
225}