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