blob: da3481aa27270a58bc337b342c2021c6a04e9428 [file] [log] [blame]
Matteo Scandolofbcbdb82020-05-06 15:41:32 -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
Matteo Scandolo39c531a2021-01-22 16:05:32 -080015// deploy VOLTHA and performs a scale test
Matteo Scandolofbcbdb82020-05-06 15:41:32 -070016
Matteo Scandolobaf74892021-04-02 11:03:51 -070017library identifier: 'cord-jenkins-libraries@master',
18 retriever: modernSCM([
19 $class: 'GitSCMSource',
20 remote: 'https://gerrit.opencord.org/ci-management.git'
21])
22
Matteo Scandolo0e8c23a2021-03-26 11:21:54 -070023// this function generates the correct parameters for ofAgent
Andrea Campanella06ca3622021-05-26 12:14:44 +020024// to connect to multiple ONOS instances
Matteo Scandolo0e8c23a2021-03-26 11:21:54 -070025def ofAgentConnections(numOfOnos, releaseName, namespace) {
26 def params = " "
27 numOfOnos.times {
28 params += "--set voltha.services.controller[${it}].address=${releaseName}-onos-classic-${it}.${releaseName}-onos-classic-hs.${namespace}.svc:6653 "
29 }
30 return params
31}
32
Matteo Scandolofbcbdb82020-05-06 15:41:32 -070033pipeline {
34
35 /* no label, executor is determined by JJB */
36 agent {
37 label "${params.buildNode}"
38 }
39 options {
Andrea Campanellac68b8d72020-09-24 11:25:47 +020040 timeout(time: 60, unit: 'MINUTES')
Matteo Scandolofbcbdb82020-05-06 15:41:32 -070041 }
42 environment {
Matteo Scandoloc3dea532020-06-04 10:46:49 -070043 JENKINS_NODE_COOKIE="dontKillMe" // do not kill processes after the build is done
Matteo Scandolofbcbdb82020-05-06 15:41:32 -070044 KUBECONFIG="$HOME/.kube/config"
45 VOLTCONFIG="$HOME/.volt/config"
Matteo Scandolob70b3e02020-05-07 11:50:26 -070046 SSHPASS="karaf"
Matteo Scandolofbcbdb82020-05-06 15:41:32 -070047 VOLTHA_LOG_LEVEL="${logLevel}"
48 NUM_OF_BBSIM="${olts}"
Matteo Scandolo0430f672020-05-07 11:50:26 -070049 NUM_OF_OPENONU="${openonuAdapterReplicas}"
50 NUM_OF_ONOS="${onosReplicas}"
51 NUM_OF_ATOMIX="${atomixReplicas}"
Matteo Scandolod3247ae2021-04-07 12:55:55 -070052 EXTRA_HELM_FLAGS=" "
Matteo Scandolof54c9b32020-08-27 07:58:27 -070053 LOG_FOLDER="$WORKSPACE/logs"
Matteo Scandolo5f72f522020-11-02 17:59:44 -080054 GERRIT_PROJECT="${GERRIT_PROJECT}"
Matteo Scandolofbcbdb82020-05-06 15:41:32 -070055 }
56
57 stages {
58 stage ('Cleanup') {
Matteo Scandolofbcbdb82020-05-06 15:41:32 -070059 steps {
Matteo Scandolo7b53b0b2021-10-11 14:43:05 -070060 script {
61 try {
Matteo Scandoloce8fd782021-10-12 07:32:06 -070062 timeout(time: 5, unit: 'MINUTES') {
Matteo Scandolo7b53b0b2021-10-11 14:43:05 -070063 sh returnStdout: false, script: '''
64 cd $WORKSPACE
65 rm -rf $WORKSPACE/*
66 '''
67 // removing the voltha-infra chart first
68 // if we don't ONOS might get stuck because of all the events when BBSim goes down
69 sh returnStdout: false, script: '''
70 set +x
71 helm del voltha-infra || true
72 echo -ne "\nWaiting for ONOS to be removed..."
73 onos=$(kubectl get pod -n default -l app=onos-classic --no-headers | wc -l)
74 while [[ $onos != 0 ]]; do
75 onos=$(kubectl get pod -n default -l app=onos-classic --no-headers | wc -l)
76 sleep 5
77 echo -ne "."
78 done
79 '''
80 }
81 } catch(org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
82 // if we have a timeout in the Cleanup fase most likely ONOS got stuck somewhere, thuse force remove the pods
83 sh '''
84 kubectl get pods | grep Terminating | awk '{print $1}' | xargs kubectl delete pod --force --grace-period=0
85 '''
Matteo Scandolobaf74892021-04-02 11:03:51 -070086 }
Matteo Scandolo7b53b0b2021-10-11 14:43:05 -070087 timeout(time: 10, unit: 'MINUTES') {
88 script {
89 helmTeardown(["default"])
90 }
91 sh returnStdout: false, script: '''
92 helm repo add onf https://charts.opencord.org
93 helm repo update
Matteo Scandolod2e2a0d2020-06-10 18:02:03 -070094
Matteo Scandolo7b53b0b2021-10-11 14:43:05 -070095 # remove all persistent volume claims
96 kubectl delete pvc --all-namespaces --all
Matteo Scandolo81448cc2021-06-11 10:34:12 +020097 PVCS=\$(kubectl get pvc --all-namespaces --no-headers | wc -l)
Matteo Scandolo7b53b0b2021-10-11 14:43:05 -070098 while [[ \$PVCS != 0 ]]; do
99 sleep 5
100 PVCS=\$(kubectl get pvc --all-namespaces --no-headers | wc -l)
101 done
Matteo Scandoloa1b5d792021-06-01 12:19:31 -0700102
Matteo Scandolo7b53b0b2021-10-11 14:43:05 -0700103 # remove orphaned port-forward from different namespaces
104 ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true
105 '''
106 }
Matteo Scandolo3f2e4152020-09-22 15:55:27 -0700107 }
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700108 }
109 }
Matteo Scandolo49bc0472021-04-20 09:37:55 -0700110 stage('Download Code') {
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700111 steps {
Matteo Scandolo49bc0472021-04-20 09:37:55 -0700112 getVolthaCode([
113 branch: "${release}",
114 volthaSystemTestsChange: "${volthaSystemTestsChange}",
115 volthaHelmChartsChange: "${volthaHelmChartsChange}",
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700116 ])
Matteo Scandolo11311742021-01-25 13:56:22 -0800117 }
118 }
Matteo Scandolo9cdacc52020-10-21 14:54:06 -0700119 stage('Build patch') {
120 when {
121 expression {
Matteo Scandolo65f80bf2020-11-03 10:57:03 -0800122 return params.GERRIT_PROJECT
Matteo Scandolo9cdacc52020-10-21 14:54:06 -0700123 }
124 }
125 steps {
126 sh """
Matteo Scandolo5f72f522020-11-02 17:59:44 -0800127 git clone https://\$GERRIT_HOST/\$GERRIT_PROJECT
128 cd \$GERRIT_PROJECT
129 git fetch https://\$GERRIT_HOST/\$GERRIT_PROJECT \$GERRIT_REFSPEC && git checkout FETCH_HEAD
Matteo Scandolo9cdacc52020-10-21 14:54:06 -0700130
131 DOCKER_REGISTRY=${dockerRegistry}/ DOCKER_REPOSITORY=voltha/ DOCKER_TAG=voltha-scale make docker-build
132 DOCKER_REGISTRY=${dockerRegistry}/ DOCKER_REPOSITORY=voltha/ DOCKER_TAG=voltha-scale make docker-push
133 """
134 }
135 }
Matteo Scandolo0430f672020-05-07 11:50:26 -0700136 stage('Deploy common infrastructure') {
Matteo Scandolo0430f672020-05-07 11:50:26 -0700137 steps {
138 sh '''
Matteo Scandolo0430f672020-05-07 11:50:26 -0700139 if [ ${withMonitoring} = true ] ; then
Matteo Scandolo39c531a2021-01-22 16:05:32 -0800140 helm install nem-monitoring onf/nem-monitoring \
Matteo Scandolo8f185c32020-07-16 16:30:04 -0700141 -f $HOME/voltha-scale/grafana.yaml \
Matteo Scandolob70b3e02020-05-07 11:50:26 -0700142 --set prometheus.alertmanager.enabled=false,prometheus.pushgateway.enabled=false \
143 --set kpi_exporter.enabled=false,dashboards.xos=false,dashboards.onos=false,dashboards.aaa=false,dashboards.voltha=false
Matteo Scandolo0430f672020-05-07 11:50:26 -0700144 fi
Matteo Scandolo0430f672020-05-07 11:50:26 -0700145 '''
146 }
147 }
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700148 stage('Deploy Voltha') {
149 steps {
Matteo Scandolob2de2032021-02-26 10:04:02 -0800150 timeout(time: 10, unit: 'MINUTES') {
151 script {
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -0700152 startComponentsLogs([
Matteo Scandolo67842812021-07-13 16:52:13 -0700153 appsToLog: [
154 'app.kubernetes.io/name=etcd',
155 'app.kubernetes.io/name=kafka',
156 'app=onos-classic',
157 'app=adapter-open-onu',
158 'app=adapter-open-olt',
159 'app=rw-core',
160 'app=ofagent',
161 'app=bbsim',
162 'app=radius',
163 'app=bbsim-sadis-server',
164 'app=onos-config-loader',
165 ]
166 ])
Andrea Campanella238bd362021-04-07 12:30:15 +0200167 def returned_flags = sh (returnStdout: true, script: """
Matteo Scandolod43064b2020-07-13 17:18:45 -0700168
Matteo Scandolob2de2032021-02-26 10:04:02 -0800169 export EXTRA_HELM_FLAGS+=' '
Matteo Scandoloc9dd44f2020-06-18 15:06:04 -0700170
Matteo Scandolob2de2032021-02-26 10:04:02 -0800171 # BBSim custom image handling
172 if [ '${bbsimImg.trim()}' != '' ] && [ '\$GERRIT_PROJECT' != 'bbsim' ]; then
173 IFS=: read -r bbsimRepo bbsimTag <<< '${bbsimImg.trim()}'
174 EXTRA_HELM_FLAGS+="--set images.bbsim.repository=\$bbsimRepo,images.bbsim.tag=\$bbsimTag "
175 fi
Matteo Scandolo7e8a6962020-08-04 12:19:59 -0700176
Matteo Scandolob2de2032021-02-26 10:04:02 -0800177 # VOLTHA custom image handling
178 if [ '${rwCoreImg.trim()}' != '' ] && [ '\$GERRIT_PROJECT' != 'voltha-go' ]; then
179 IFS=: read -r rwCoreRepo rwCoreTag <<< '${rwCoreImg.trim()}'
180 EXTRA_HELM_FLAGS+="--set voltha.images.rw_core.repository=\$rwCoreRepo,voltha.images.rw_core.tag=\$rwCoreTag "
181 fi
Matteo Scandolo39c531a2021-01-22 16:05:32 -0800182
Matteo Scandolob2de2032021-02-26 10:04:02 -0800183 # ofAgent custom image handling
184 if [ '${ofAgentImg.trim()}' != '' ] && [ '\$GERRIT_PROJECT' != 'of-agent' ]; then
185 IFS=: read -r ofAgentRepo ofAgentTag <<< '${ofAgentImg.trim()}'
186 EXTRA_HELM_FLAGS+="--set voltha.images.ofagent.repository=\$ofAgentRepo,voltha.images.ofagent.tag=\$ofAgentTag "
187 fi
Matteo Scandolo7e8a6962020-08-04 12:19:59 -0700188
Matteo Scandolob2de2032021-02-26 10:04:02 -0800189 # OpenOLT custom image handling
190 if [ '${openoltAdapterImg.trim()}' != '' ] && [ '\$GERRIT_PROJECT' != 'voltha-openolt-adapter' ]; then
191 IFS=: read -r openoltAdapterRepo openoltAdapterTag <<< '${openoltAdapterImg.trim()}'
192 EXTRA_HELM_FLAGS+="--set voltha-adapter-openolt.images.adapter_open_olt.repository=\$openoltAdapterRepo,voltha-adapter-openolt.images.adapter_open_olt.tag=\$openoltAdapterTag "
193 fi
Matteo Scandolo7e8a6962020-08-04 12:19:59 -0700194
Matteo Scandolob2de2032021-02-26 10:04:02 -0800195 # OpenONU custom image handling
196 if [ '${openonuAdapterImg.trim()}' != '' ] && [ '\$GERRIT_PROJECT' != 'voltha-openonu-adapter' ]; then
197 IFS=: read -r openonuAdapterRepo openonuAdapterTag <<< '${openonuAdapterImg.trim()}'
198 EXTRA_HELM_FLAGS+="--set voltha-adapter-openonu.images.adapter_open_onu.repository=\$openonuAdapterRepo,voltha-adapter-openonu.images.adapter_open_onu.tag=\$openonuAdapterTag "
199 fi
Matteo Scandolo7e8a6962020-08-04 12:19:59 -0700200
Matteo Scandolob2de2032021-02-26 10:04:02 -0800201 # OpenONU GO custom image handling
202 if [ '${openonuAdapterGoImg.trim()}' != '' ] && [ '\$GERRIT_PROJECT' != 'voltha-openonu-adapter-go' ]; then
203 IFS=: read -r openonuAdapterGoRepo openonuAdapterGoTag <<< '${openonuAdapterGoImg.trim()}'
204 EXTRA_HELM_FLAGS+="--set voltha-adapter-openonu.images.adapter_open_onu_go.repository=\$openonuAdapterGoRepo,voltha-adapter-openonu.images.adapter_open_onu_go.tag=\$openonuAdapterGoTag "
205 fi
Andrea Campanella28763082020-11-18 10:55:31 +0100206
Matteo Scandolob2de2032021-02-26 10:04:02 -0800207 # ONOS custom image handling
208 if [ '${onosImg.trim()}' != '' ] && [ '\$GERRIT_PROJECT' != 'voltha-onos' ]; then
209 IFS=: read -r onosRepo onosTag <<< '${onosImg.trim()}'
Andrea Campanella4fca92c2021-03-08 13:08:28 +0100210 EXTRA_HELM_FLAGS+="--set onos-classic.image.repository=\$onosRepo,onos-classic.image.tag=\$onosTag "
Matteo Scandolob2de2032021-02-26 10:04:02 -0800211 fi
Matteo Scandolo7e8a6962020-08-04 12:19:59 -0700212
Matteo Scandolob2de2032021-02-26 10:04:02 -0800213 # set BBSim parameters
214 EXTRA_HELM_FLAGS+='--set enablePerf=true,pon=${pons},onu=${onus} '
Matteo Scandolo1c5ffab2020-07-17 08:53:01 -0700215
Matteo Scandolob2de2032021-02-26 10:04:02 -0800216 # disable the securityContext, this is a development cluster
217 EXTRA_HELM_FLAGS+='--set securityContext.enabled=false '
Matteo Scandolo1c5ffab2020-07-17 08:53:01 -0700218
Matteo Scandolob2de2032021-02-26 10:04:02 -0800219 # No persistent-volume-claims in Atomix
220 EXTRA_HELM_FLAGS+="--set onos-classic.atomix.persistence.enabled=false "
Matteo Scandolod2e2a0d2020-06-10 18:02:03 -0700221
Matteo Scandolob2de2032021-02-26 10:04:02 -0800222 # Use custom built images
Matteo Scandolo9cdacc52020-10-21 14:54:06 -0700223
Matteo Scandolob2de2032021-02-26 10:04:02 -0800224 if [ '\$GERRIT_PROJECT' == 'voltha-go' ]; then
225 EXTRA_HELM_FLAGS+="--set voltha.images.rw_core.repository=${dockerRegistry}/voltha/voltha-rw-core,voltha.images.rw_core.tag=voltha-scale "
226 fi
Matteo Scandolo9cdacc52020-10-21 14:54:06 -0700227
Matteo Scandolob2de2032021-02-26 10:04:02 -0800228 if [ '\$GERRIT_PROJECT' == 'voltha-openolt-adapter' ]; then
229 EXTRA_HELM_FLAGS+="--set voltha-openolt-adapter.images.adapter_open_olt.repository=${dockerRegistry}/voltha/voltha-openolt-adapter,voltha-openolt-adapter.images.adapter_open_olt.tag=voltha-scale "
230 fi
Matteo Scandolo9cdacc52020-10-21 14:54:06 -0700231
Matteo Scandolob2de2032021-02-26 10:04:02 -0800232 if [ '\$GERRIT_PROJECT' == 'voltha-openonu-adapter' ]; then
233 EXTRA_HELM_FLAGS+="--set voltha-openonu-adapter.images.adapter_open_onu.repository=${dockerRegistry}/voltha/voltha-openonu-adapter,voltha-openonu-adapter.images.adapter_open_onu.tag=voltha-scale "
234 fi
Matteo Scandolo9cdacc52020-10-21 14:54:06 -0700235
Matteo Scandolob2de2032021-02-26 10:04:02 -0800236 if [ '\$GERRIT_PROJECT' == 'voltha-openonu-adapter-go' ]; then
237 EXTRA_HELM_FLAGS+="--set voltha-openonu-adapter-go.images.adapter_open_onu_go.repository=${dockerRegistry}/voltha/voltha-openonu-adapter-go,voltha-openonu-adapter-go.images.adapter_open_onu_go.tag=voltha-scale "
238 fi
Andrea Campanellaed026982020-11-20 10:06:42 +0100239
Matteo Scandolob2de2032021-02-26 10:04:02 -0800240 if [ '\$GERRIT_PROJECT' == 'ofagent-go' ]; then
241 EXTRA_HELM_FLAGS+="--set voltha.images.ofagent.repository=${dockerRegistry}/voltha/voltha-ofagent-go,ofagent-go.images.ofagent.tag=voltha-scale "
242 fi
Matteo Scandolo9cdacc52020-10-21 14:54:06 -0700243
Matteo Scandolob2de2032021-02-26 10:04:02 -0800244 if [ '\$GERRIT_PROJECT' == 'voltha-onos' ]; then
Andrea Campanella4fca92c2021-03-08 13:08:28 +0100245 EXTRA_HELM_FLAGS+="--set onos-classic.image.repository=${dockerRegistry}/voltha/voltha-onos,onos-classic.image.tag=voltha-scale "
Matteo Scandolob2de2032021-02-26 10:04:02 -0800246 fi
Matteo Scandolo9cdacc52020-10-21 14:54:06 -0700247
Matteo Scandolob2de2032021-02-26 10:04:02 -0800248 if [ '\$GERRIT_PROJECT' == 'bbsim' ]; then
249 EXTRA_HELM_FLAGS+="--set images.bbsim.repository=${dockerRegistry}/voltha/bbsim,images.bbsim.tag=voltha-scale "
250 fi
Andrea Campanella238bd362021-04-07 12:30:15 +0200251 echo \$EXTRA_HELM_FLAGS
252
253 """).trim()
254
Matteo Scandolod3247ae2021-04-07 12:55:55 -0700255 def extraHelmFlags = returned_flags
Andrea Campanella15f22942021-04-08 17:24:21 +0200256 // The added space before params.extraHelmFlags is required due to the .trim() above
Matteo Scandoloed1afdd2021-04-02 16:25:45 -0700257 def infraHelmFlags =
Matteo Scandolo529e8822021-07-21 10:20:18 -0700258 "--set global.log_level=${logLevel} " +
259 "--set radius.enabled=${withEapol} " +
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700260 "--set onos-classic.onosSshPort=30115 " +
261 "--set onos-classic.onosApiPort=30120 " +
Andrea Campanella15f22942021-04-08 17:24:21 +0200262 extraHelmFlags + " " + params.extraHelmFlags
Matteo Scandolobaf74892021-04-02 11:03:51 -0700263
Andrea Campanella238bd362021-04-07 12:30:15 +0200264 println "Passing the following parameters to the VOLTHA infra deploy: ${infraHelmFlags}."
265
Matteo Scandolo49bc0472021-04-20 09:37:55 -0700266 def localCharts = false
267 if (volthaHelmChartsChange != "") {
268 localCharts = true
269 }
270
Matteo Scandolobaf74892021-04-02 11:03:51 -0700271 volthaInfraDeploy([
272 workflow: workflow,
273 infraNamespace: "default",
274 extraHelmFlags: infraHelmFlags,
Matteo Scandolo49bc0472021-04-20 09:37:55 -0700275 localCharts: localCharts,
Matteo Scandolobaf74892021-04-02 11:03:51 -0700276 onosReplica: onosReplicas,
277 atomixReplica: atomixReplicas,
Matteo Scandolo756f3ec2021-05-28 12:43:40 -0700278 kafkaReplica: kafkaReplicas,
279 etcdReplica: etcdReplicas,
Matteo Scandolobaf74892021-04-02 11:03:51 -0700280 ])
281
Matteo Scandolo756f3ec2021-05-28 12:43:40 -0700282 stackHelmFlags = " --set onu=${onus},pon=${pons} --set global.log_level=${logLevel.toLowerCase()} "
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700283 stackHelmFlags += " --set voltha.ingress.enabled=true --set voltha.ingress.enableVirtualHosts=true --set voltha.fullHostnameOverride=voltha.scale1.dev "
Andrea Campanellad51833b2021-04-09 15:42:59 +0200284 stackHelmFlags += extraHelmFlags + " " + params.extraHelmFlags
Matteo Scandolobaf74892021-04-02 11:03:51 -0700285
286 volthaStackDeploy([
287 bbsimReplica: olts.toInteger(),
288 infraNamespace: "default",
289 volthaNamespace: "default",
290 stackName: "voltha1", // TODO support custom charts
291 workflow: workflow,
292 extraHelmFlags: stackHelmFlags,
Matteo Scandolo687fd622021-06-11 18:16:42 +0200293 localCharts: localCharts,
Matteo Scandolo529e8822021-07-21 10:20:18 -0700294 onosReplica: onosReplicas,
Matteo Scandolobaf74892021-04-02 11:03:51 -0700295 ])
Matteo Scandolodbda3272021-03-04 14:50:07 -0800296 sh """
297 set +x
Matteo Scandolob2de2032021-02-26 10:04:02 -0800298
Andrea Campanella4fca92c2021-03-08 13:08:28 +0100299 echo -ne "\nWaiting for VOLTHA and ONOS to start..."
Matteo Scandolo39c531a2021-01-22 16:05:32 -0800300 voltha=\$(kubectl get pods --all-namespaces -l app.kubernetes.io/part-of=voltha --no-headers | grep "0/" | wc -l)
Andrea Campanella4fca92c2021-03-08 13:08:28 +0100301 onos=\$(kubectl get pods --all-namespaces -l app=onos-classic --no-headers | grep "0/" | wc -l)
Andrea Campanellaae871e42021-03-08 18:52:25 +0100302 while [[ \$voltha != 0 || \$onos != 0 ]]; do
Matteo Scandolob2de2032021-02-26 10:04:02 -0800303 sleep 5
304 echo -ne "."
305 voltha=\$(kubectl get pods --all-namespaces -l app.kubernetes.io/part-of=voltha --no-headers | grep "0/" | wc -l)
Andrea Campanella4fca92c2021-03-08 13:08:28 +0100306 onos=\$(kubectl get pods --all-namespaces -l app=onos-classic --no-headers | grep "0/" | wc -l)
Matteo Scandolob2de2032021-02-26 10:04:02 -0800307 done
Andrea Campanellaae871e42021-03-08 18:52:25 +0100308 echo -ne "\nVOLTHA and ONOS pods ready\n"
309 kubectl get pods --all-namespaces -l app.kubernetes.io/part-of=voltha --no-headers | grep "0/" | wc -l
310 kubectl get pods --all-namespaces -l app=onos-classic --no-headers | grep "0/" | wc -l
Matteo Scandolob2de2032021-02-26 10:04:02 -0800311 """
Matteo Scandolodbda3272021-03-04 14:50:07 -0800312 start_port_forward(olts)
Matteo Scandolob2de2032021-02-26 10:04:02 -0800313 }
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700314 }
315 }
316 }
Matteo Scandolo0430f672020-05-07 11:50:26 -0700317 stage('Configuration') {
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700318 steps {
Matteo Scandolo37cba472020-10-26 14:15:34 -0700319 script {
Matteo Scandolo04638352021-11-12 09:38:48 -0800320 setOnosLogLevels([
321 onosNamespace: "default",
322 apps: [
323 'org.opencord.dhcpl2relay',
324 'org.opencord.olt',
325 'org.opencord.aaa',
326 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
327 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
328 ],
329 logLevel: logLevel
330 ])
Andrea Campanellaf2460e8fb2021-03-15 22:03:09 +0100331 def tech_prof_directory = "XGS-PON"
Matteo Scandolo37cba472020-10-26 14:15:34 -0700332 sh returnStdout: false, script: """
Matteo Scandolo0430f672020-05-07 11:50:26 -0700333 #Setting link discovery
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700334 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.onosproject.provider.lldp.impl.LldpLinkProvider enabled ${withLLDP}
Matteo Scandolo0430f672020-05-07 11:50:26 -0700335
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700336 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.onosproject.net.flow.impl.FlowRuleManager allowExtraneousRules true
337 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.onosproject.net.flow.impl.FlowRuleManager importExtraneousRules true
Matteo Scandolo2264d9c2020-10-16 14:25:32 -0700338
Matteo Scandolo9cdacc52020-10-21 14:54:06 -0700339
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700340 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager accumulatorMaxBatchMillis 900
Andrea Campanelladeec1582020-10-28 09:37:58 +0100341
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700342 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager accumulatorMaxIdleMillis 500
Andrea Campanelladeec1582020-10-28 09:37:58 +0100343
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700344 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.opencord.olt.impl.Olt provisionDelay 1000
Matteo Scandoloea061332021-03-25 16:26:22 -0700345
Matteo Scandoloe07dcff2021-09-29 15:40:47 -0700346 # BBSim logs at debug level don't slow down the system much and are very helpful while troubleshooting
347 kubectl exec \$(kubectl get pods | grep -E "bbsim[0-9]" | awk 'NR==1{print \$1}') -- bbsimctl log debug false
Matteo Scandolo0430f672020-05-07 11:50:26 -0700348
Andrea Campanella15f22942021-04-08 17:24:21 +0200349 # Set Flows/Ports/Meters/Groups poll frequency
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700350 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.onosproject.provider.of.flow.impl.OpenFlowRuleProvider flowPollFrequency ${onosStatInterval}
351 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.onosproject.provider.of.device.impl.OpenFlowDeviceProvider portStatsPollFrequency ${onosStatInterval}
352 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.onosproject.provider.of.group.impl.OpenFlowGroupProvider groupPollInterval ${onosGroupInterval}
Andrea Campanella55f0f0e2021-04-15 18:50:54 +0200353 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.onosproject.net.flowobjective.impl.FlowObjectiveManager numThreads ${flowObjWorkerThreads}
Andrea Campanella9c93ded2021-04-29 18:59:53 +0200354 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg set org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager objectiveTimeoutMs 300000
Matteo Scandolo3136cca2020-05-15 14:14:27 -0700355
Matteo Scandolo0430f672020-05-07 11:50:26 -0700356 if [ ${withFlows} = false ]; then
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700357 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 app deactivate org.opencord.olt
Matteo Scandolo0430f672020-05-07 11:50:26 -0700358 fi
359
Andrea Campanellaf2460e8fb2021-03-15 22:03:09 +0100360 if [ '${workflow}' = 'tt' ]; then
Matteo Scandolo756f3ec2021-05-28 12:43:40 -0700361 etcd_container=\$(kubectl get pods --all-namespaces | grep etcd-0 | awk 'NR==1{print \$2}')
Andrea Campanellaf2460e8fb2021-03-15 22:03:09 +0100362 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
363 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/hsia.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64')
364 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
365 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/voip.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/65')
Girish Gowdra5d6c1272021-05-25 23:36:27 -0700366 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast.json
Andrea Campanellaf2460e8fb2021-03-15 22:03:09 +0100367 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/66')
368 fi
369
Matteo Scandoloc9dd44f2020-06-18 15:06:04 -0700370 if [ ${withPcap} = true ] ; then
Matteo Scandolo34d6a7a2020-10-20 09:29:58 -0700371 # Start the tcp-dump in ofagent
Matteo Scandolo37cba472020-10-26 14:15:34 -0700372 export OF_AGENT=\$(kubectl get pods -l app=ofagent -o name)
373 kubectl exec \$OF_AGENT -- apk update
374 kubectl exec \$OF_AGENT -- apk add tcpdump
375 kubectl exec \$OF_AGENT -- mv /usr/sbin/tcpdump /usr/bin/tcpdump
376 _TAG=ofagent-tcpdump kubectl exec \$OF_AGENT -- tcpdump -nei eth0 -w out.pcap&
Matteo Scandolo77fa78d2020-09-16 16:53:50 -0700377
Matteo Scandolo34d6a7a2020-10-20 09:29:58 -0700378 # Start the tcp-dump in radius
Matteo Scandolo37cba472020-10-26 14:15:34 -0700379 export RADIUS=\$(kubectl get pods -l app=radius -o name)
380 kubectl exec \$RADIUS -- apt-get update
381 kubectl exec \$RADIUS -- apt-get install -y tcpdump
382 _TAG=radius-tcpdump kubectl exec \$RADIUS -- tcpdump -w out.pcap&
Matteo Scandolo34d6a7a2020-10-20 09:29:58 -0700383
384 # Start the tcp-dump in ONOS
Matteo Scandolo37cba472020-10-26 14:15:34 -0700385 for i in \$(seq 0 \$ONOSES); do
386 INSTANCE="onos-onos-classic-\$i"
387 kubectl exec \$INSTANCE -- apt-get update
388 kubectl exec \$INSTANCE -- apt-get install -y tcpdump
389 kubectl exec \$INSTANCE -- mv /usr/sbin/tcpdump /usr/bin/tcpdump
390 _TAG=\$INSTANCE kubectl exec \$INSTANCE -- /usr/bin/tcpdump -nei eth0 port 1812 -w out.pcap&
Matteo Scandolo34d6a7a2020-10-20 09:29:58 -0700391 done
Matteo Scandoloc9dd44f2020-06-18 15:06:04 -0700392 fi
Matteo Scandolo37cba472020-10-26 14:15:34 -0700393 """
394 }
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700395 }
396 }
Matteo Scandolofcb75632021-04-06 16:25:19 -0700397 stage('Load MIB Template') {
398 when {
399 expression {
400 return params.withMibTemplate
401 }
402 }
403 steps {
404 sh """
405 # load MIB template
406 wget https://raw.githubusercontent.com/opencord/voltha-openonu-adapter-go/master/templates/BBSM-12345123451234512345-00000000000001-v1.json
Girish Gowdra9d12da72021-05-28 15:18:20 -0700407 cat BBSM-12345123451234512345-00000000000001-v1.json | kubectl exec -it \$(kubectl get pods |grep etcd-0 | awk 'NR==1{print \$1}') -- etcdctl put service/voltha/omci_mibs/go_templates/BBSM/12345123451234512345/00000000000001
Matteo Scandolofcb75632021-04-06 16:25:19 -0700408 """
409 }
410 }
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700411 stage('Run Test') {
412 steps {
Matteo Scandoloa731f8f2020-05-11 10:27:26 -0700413 sh '''
414 mkdir -p $WORKSPACE/RobotLogs
415 cd $WORKSPACE/voltha-system-tests
416 make vst_venv
417 '''
418 sh '''
419 if [ ${withProfiling} = true ] ; then
Matteo Scandolof54c9b32020-08-27 07:58:27 -0700420 mkdir -p $LOG_FOLDER/pprof
Matteo Scandoloa731f8f2020-05-11 10:27:26 -0700421 echo $PATH
422 #Creating Python script for ONU Detection
423 cat << EOF > $WORKSPACE/pprof.sh
Matteo Scandolo3ddd3fb2020-05-12 14:31:14 -0700424timestamp() {
425 date +"%T"
426}
427
Matteo Scandoloa731f8f2020-05-11 10:27:26 -0700428i=0
429while [[ true ]]; do
430 ((i++))
Matteo Scandolo3ddd3fb2020-05-12 14:31:14 -0700431 ts=$(timestamp)
Matteo Scandolof54c9b32020-08-27 07:58:27 -0700432 go tool pprof -png http://127.0.0.1:6060/debug/pprof/heap > $LOG_FOLDER/pprof/rw-core-heap-\\$i-\\$ts.png
433 go tool pprof -png http://127.0.0.1:6060/debug/pprof/goroutine > $LOG_FOLDER/pprof/rw-core-goroutine-\\$i-\\$ts.png
434 curl -o $LOG_FOLDER/pprof/rw-core-profile-\\$i-\\$ts.pprof http://127.0.0.1:6060/debug/pprof/profile?seconds=10
435 go tool pprof -png $LOG_FOLDER/pprof/rw-core-profile-\\$i-\\$ts.pprof > $LOG_FOLDER/pprof/rw-core-profile-\\$i-\\$ts.png
Matteo Scandoloa731f8f2020-05-11 10:27:26 -0700436
Matteo Scandolof54c9b32020-08-27 07:58:27 -0700437 go tool pprof -png http://127.0.0.1:6061/debug/pprof/heap > $LOG_FOLDER/pprof/openolt-heap-\\$i-\\$ts.png
438 go tool pprof -png http://127.0.0.1:6061/debug/pprof/goroutine > $LOG_FOLDER/pprof/openolt-goroutine-\\$i-\\$ts.png
439 curl -o $LOG_FOLDER/pprof/openolt-profile-\\$i-\\$ts.pprof http://127.0.0.1:6061/debug/pprof/profile?seconds=10
440 go tool pprof -png $LOG_FOLDER/pprof/openolt-profile-\\$i-\\$ts.pprof > $LOG_FOLDER/pprof/openolt-profile-\\$i-\\$ts.png
Matteo Scandoloa731f8f2020-05-11 10:27:26 -0700441
Matteo Scandolof54c9b32020-08-27 07:58:27 -0700442 go tool pprof -png http://127.0.0.1:6062/debug/pprof/heap > $LOG_FOLDER/pprof/ofagent-heap-\\$i-\\$ts.png
443 go tool pprof -png http://127.0.0.1:6062/debug/pprof/goroutine > $LOG_FOLDER/pprof/ofagent-goroutine-\\$i-\\$ts.png
444 curl -o $LOG_FOLDER/pprof/ofagent-profile-\\$i-\\$ts.pprof http://127.0.0.1:6062/debug/pprof/profile?seconds=10
445 go tool pprof -png $LOG_FOLDER/pprof/ofagent-profile-\\$i-\\$ts.pprof > $LOG_FOLDER/pprof/ofagent-profile-\\$i-\\$ts.png
Matteo Scandolo731d12c2020-05-13 14:33:26 -0700446
Matteo Scandoloa731f8f2020-05-11 10:27:26 -0700447 sleep 10
448done
449EOF
450
451 _TAG="pprof"
452 _TAG=$_TAG bash $WORKSPACE/pprof.sh &
453 fi
454 '''
Matteo Scandolob7d60ba2020-11-06 09:46:11 -0800455 timeout(time: 15, unit: 'MINUTES') {
Matteo Scandolo9b0728b2020-05-11 08:25:57 -0700456 sh '''
Matteo Scandolofebf6512021-03-02 11:37:37 -0800457 ROBOT_PARAMS="--exitonfailure \
458 -v olt:${olts} \
Matteo Scandolo9b0728b2020-05-11 08:25:57 -0700459 -v pon:${pons} \
460 -v onu:${onus} \
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700461 -v ONOS_SSH_PORT:30115 \
462 -v ONOS_REST_PORT:30120 \
Matteo Scandolo9b0728b2020-05-11 08:25:57 -0700463 -v workflow:${workflow} \
464 -v withEapol:${withEapol} \
465 -v withDhcp:${withDhcp} \
466 -v withIgmp:${withIgmp} \
467 --noncritical non-critical \
Matteo Scandolo5f712192021-11-18 14:24:41 -0800468 -e igmp -e teardown "
Matteo Scandolo0430f672020-05-07 11:50:26 -0700469
Matteo Scandolo9b0728b2020-05-11 08:25:57 -0700470 if [ ${withEapol} = false ] ; then
471 ROBOT_PARAMS+="-e authentication "
472 fi
Matteo Scandolo0430f672020-05-07 11:50:26 -0700473
Matteo Scandolo9b0728b2020-05-11 08:25:57 -0700474 if [ ${withDhcp} = false ] ; then
475 ROBOT_PARAMS+="-e dhcp "
476 fi
Matteo Scandolo0430f672020-05-07 11:50:26 -0700477
Matteo Scandolo9b0728b2020-05-11 08:25:57 -0700478 if [ ${provisionSubscribers} = false ] ; then
Matteo Scandolocd59fd02020-05-12 15:00:35 -0700479 # if we're not considering subscribers then we don't care about authentication and dhcp
Matteo Scandolo111c8932020-05-12 18:28:05 -0700480 ROBOT_PARAMS+="-e authentication -e provision -e flow-after -e dhcp "
Matteo Scandolo9b0728b2020-05-11 08:25:57 -0700481 fi
Matteo Scandolo0430f672020-05-07 11:50:26 -0700482
Matteo Scandolo9b0728b2020-05-11 08:25:57 -0700483 if [ ${withFlows} = false ] ; then
484 ROBOT_PARAMS+="-i setup -i activation "
485 fi
Matteo Scandolo0430f672020-05-07 11:50:26 -0700486
Matteo Scandoloa731f8f2020-05-11 10:27:26 -0700487 cd $WORKSPACE/voltha-system-tests
Matteo Scandolo9b0728b2020-05-11 08:25:57 -0700488 source ./vst_venv/bin/activate
489 robot -d $WORKSPACE/RobotLogs \
490 $ROBOT_PARAMS tests/scale/Voltha_Scale_Tests.robot
Matteo Scandolo490ec282021-12-15 15:20:08 -0800491
492 python tests/scale/collect-result.py -r $WORKSPACE/RobotLogs/output.xml -p $WORKSPACE/plots > $WORKSPACE/execution-time.txt || true
493 cat $WORKSPACE/execution-time.txt
Matteo Scandolo9b0728b2020-05-11 08:25:57 -0700494 '''
495 }
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700496 }
497 }
Hardik Windlassc716a882021-02-03 15:21:07 +0000498 stage('Run Igmp Tests') {
499 environment {
500 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/IgmpTests"
501 }
502 when {
503 expression {
504 return params.withIgmp
505 }
506 }
Matteo Scandolo91d34e92021-07-13 17:39:46 -0700507 options {
508 timeout(time: 11, unit: 'MINUTES')
509 }
Hardik Windlassc716a882021-02-03 15:21:07 +0000510 steps {
Andrea Campanella6fe1b032021-04-01 17:47:15 +0200511 sh returnStdout: false, script: """
Andrea Campanella08561cf2021-04-30 16:02:57 +0200512 # sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 log:set DEBUG org.onosproject.store.group.impl
Andrea Campanella6fe1b032021-04-01 17:47:15 +0200513 """
Hardik Windlassc716a882021-02-03 15:21:07 +0000514 sh '''
515 set +e
Andrea Campanella7ba63af2021-03-09 10:48:07 +0100516 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlassc716a882021-02-03 15:21:07 +0000517 cd $WORKSPACE/voltha-system-tests
518 make vst_venv
519 '''
Matteo Scandolo91d34e92021-07-13 17:39:46 -0700520 script {
521 Exception caughtException = null
522
Matteo Scandoloe07dcff2021-09-29 15:40:47 -0700523 catchError(buildResult: 'SUCCESS', stageResult: 'ABORTED') {
Matteo Scandolo91d34e92021-07-13 17:39:46 -0700524 try {
525 sh '''
526 ROBOT_PARAMS="--exitonfailure \
527 -v olt:${olts} \
528 -v pon:${pons} \
529 -v onu:${onus} \
530 -v workflow:${workflow} \
531 -v withEapol:${withEapol} \
532 -v withDhcp:${withDhcp} \
533 -v withIgmp:${withIgmp} \
534 -v ONOS_SSH_PORT:30115 \
535 -v ONOS_REST_PORT:30120 \
536 --noncritical non-critical \
537 -i igmp \
538 -e setup -e activation -e flow-before \
539 -e authentication -e provision -e flow-after \
540 -e dhcp -e teardown "
541 cd $WORKSPACE/voltha-system-tests
542 source ./vst_venv/bin/activate
543 robot -d $ROBOT_LOGS_DIR \
544 $ROBOT_PARAMS tests/scale/Voltha_Scale_Tests.robot
545 '''
546 } catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
547 // if the error is a timeout don't mark the build as failed
Matteo Scandoloe07dcff2021-09-29 15:40:47 -0700548 println "IGMP test timed out"
Matteo Scandolo91d34e92021-07-13 17:39:46 -0700549 } catch (Throwable e) {
550 caughtException = e
551 }
552 }
553
554 if (caughtException) {
555 error caughtException.message
556 }
Hardik Windlassc716a882021-02-03 15:21:07 +0000557 }
558 }
559 }
Matteo Scandolo5f712192021-11-18 14:24:41 -0800560 stage("Device removal") {
561 options {
562 timeout(time: 5, unit: 'MINUTES')
563 }
564 steps {
565 sh '''
566 set +e
567 mkdir -p $ROBOT_LOGS_DIR
568 cd $WORKSPACE/voltha-system-tests
569 make vst_venv
570 '''
571 script {
572 Exception caughtException = null
573
574 catchError(buildResult: 'SUCCESS', stageResult: 'ABORTED') {
575 try {
576 sh '''
577 ROBOT_PARAMS="--exitonfailure \
578 -v olt:${olts} \
579 -v pon:${pons} \
580 -v onu:${onus} \
581 -v ONOS_SSH_PORT:30115 \
582 -v ONOS_REST_PORT:30120 \
583 -v workflow:${workflow} \
584 -v withEapol:${withEapol} \
585 -v withDhcp:${withDhcp} \
586 -v withIgmp:${withIgmp} \
587 --noncritical non-critical \
588 -i teardown"
589
590 cd $WORKSPACE/voltha-system-tests
591 source ./vst_venv/bin/activate
592 robot -d $WORKSPACE/RobotLogs \
593 $ROBOT_PARAMS tests/scale/Voltha_Scale_Tests.robot
594 '''
595 } catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
596 // if the error is a timeout don't mark the build as failed
597 println "Cleanup test timed out"
598 } catch (Throwable e) {
599 caughtException = e
600 }
601 }
602 }
603 }
604 }
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700605 }
606 post {
607 always {
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -0700608 stopComponentsLogs()
Matteo Scandolo157f66c2020-05-12 09:26:19 -0700609 // collect result, done in the "post" step so it's executed even in the
610 // event of a timeout in the tests
611 sh '''
Matteo Scandoloc9dd44f2020-06-18 15:06:04 -0700612 if [ ${withPcap} = true ] ; then
613 # stop ofAgent tcpdump
614 P_ID="\$(ps e -ww -A | grep "_TAG=ofagent-tcpdump" | grep -v grep | awk '{print \$1}')"
615 if [ -n "\$P_ID" ]; then
616 kill -9 \$P_ID
617 fi
618
Matteo Scandolo34d6a7a2020-10-20 09:29:58 -0700619 # stop radius tcpdump
620 P_ID="\$(ps e -ww -A | grep "_TAG=radius-tcpdump" | grep -v grep | awk '{print \$1}')"
621 if [ -n "\$P_ID" ]; then
622 kill -9 \$P_ID
623 fi
624
625 # stop onos tcpdump
626 LIMIT=$(($NUM_OF_ONOS - 1))
627 for i in $(seq 0 $LIMIT); do
628 INSTANCE="onos-onos-classic-$i"
629 P_ID="\$(ps e -ww -A | grep "_TAG=$INSTANCE" | grep -v grep | awk '{print \$1}')"
630 if [ -n "\$P_ID" ]; then
631 kill -9 \$P_ID
632 fi
633 done
634
Matteo Scandoloc9dd44f2020-06-18 15:06:04 -0700635 # copy the file
Matteo Scandoloa7600f12020-09-21 16:09:27 -0700636 export OF_AGENT=$(kubectl get pods -l app=ofagent | awk 'NR==2{print $1}') || true
637 kubectl cp $OF_AGENT:out.pcap $LOG_FOLDER/ofagent.pcap || true
Matteo Scandolo77fa78d2020-09-16 16:53:50 -0700638
Andrea Campanella190854a2020-10-20 14:30:42 +0200639 export RADIUS=$(kubectl get pods -l app=radius | awk 'NR==2{print $1}') || true
640 kubectl cp $RADIUS:out.pcap $LOG_FOLDER/radius.pcap || true
Matteo Scandolo34d6a7a2020-10-20 09:29:58 -0700641
642 LIMIT=$(($NUM_OF_ONOS - 1))
643 for i in $(seq 0 $LIMIT); do
644 INSTANCE="onos-onos-classic-$i"
645 kubectl cp $INSTANCE:out.pcap $LOG_FOLDER/$INSTANCE.pcap || true
646 done
Matteo Scandoloc9dd44f2020-06-18 15:06:04 -0700647 fi
Matteo Scandolo157f66c2020-05-12 09:26:19 -0700648 '''
Matteo Scandoloa731f8f2020-05-11 10:27:26 -0700649 sh '''
650 if [ ${withProfiling} = true ] ; then
651 _TAG="pprof"
652 P_IDS="$(ps e -ww -A | grep "_TAG=$_TAG" | grep -v grep | awk '{print $1}')"
653 if [ -n "$P_IDS" ]; then
654 echo $P_IDS
655 for P_ID in $P_IDS; do
656 kill -9 $P_ID
657 done
658 fi
659 fi
660 '''
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700661 plot([
662 csvFileName: 'scale-test.csv',
663 csvSeries: [
Matteo Scandolo272aed42020-05-08 15:05:57 -0700664 [file: 'plots/plot-voltha-onus.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
665 [file: 'plots/plot-onos-ports.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
666 [file: 'plots/plot-voltha-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
Matteo Scandolo64966762020-05-13 11:51:38 -0700667 [file: 'plots/plot-voltha-openolt-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
Matteo Scandolo272aed42020-05-08 15:05:57 -0700668 [file: 'plots/plot-onos-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
669 [file: 'plots/plot-onos-auth.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
670 [file: 'plots/plot-voltha-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
Matteo Scandolo64966762020-05-13 11:51:38 -0700671 [file: 'plots/plot-voltha-openolt-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
Matteo Scandolo272aed42020-05-08 15:05:57 -0700672 [file: 'plots/plot-onos-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
673 [file: 'plots/plot-onos-dhcp.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700674 ],
675 group: 'Voltha-Scale-Numbers', numBuilds: '20', style: 'line', title: "Scale Test (OLTs: ${olts}, PONs: ${pons}, ONUs: ${onus})", yaxis: 'Time (s)', useDescr: true
676 ])
Matteo Scandolo8efe7df2021-11-18 10:39:17 -0800677 script {
678 try {
679 step([$class: 'RobotPublisher',
680 disableArchiveOutput: false,
681 logFileName: '**/log*.html',
682 otherFiles: '',
683 outputFileName: '**/output*.xml',
684 outputPath: 'RobotLogs',
685 passThreshold: 100,
686 reportFileName: '**/report*.html',
687 onlyCritical: true,
688 unstableThreshold: 0]);
689 } catch (Exception e) {
690 println "Cannot archive Robot Logs: ${e.toString()}"
691 }
692 }
693
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700694 getPodsInfo("$LOG_FOLDER")
Matteo Scandolo502644b2020-05-18 08:56:18 -0700695 // get all the logs from kubernetes PODs
Matteo Scandoloede5abd2020-05-22 10:57:10 -0700696 sh returnStdout: false, script: '''
Matteo Scandolo32da27d2020-05-29 10:38:31 -0700697 # copy the ONOS logs directly from the container to avoid the color codes
Matteo Scandolodbda3272021-03-04 14:50:07 -0800698 printf '%s\n' $(kubectl get pods -l app=onos-classic -o=jsonpath="{.items[*]['metadata.name']}") | xargs --no-run-if-empty -I# bash -c "kubectl cp #:${karafHome}/data/log/karaf.log $LOG_FOLDER/#.log" || true
Matteo Scandoloa2f07fc2020-10-08 18:30:54 -0700699
Matteo Scandolo064efbc2021-03-29 17:24:34 -0700700 # get ONOS cfg from the 3 nodes
Andrea Campanella188e50d2022-01-14 11:30:05 +0100701 # kubectl exec -t voltha-infra-onos-classic-0 -- sh /root/onos/${karafHome}/bin/client cfg get > ~/voltha-infra-onos-classic-0-cfg.txt || true
702 # kubectl exec -t voltha-infra-onos-classic-1 -- sh /root/onos/${karafHome}/bin/client cfg get > ~/voltha-infra-onos-classic-1-cfg.txt || true
703 # kubectl exec -t voltha-infra-onos-classic-2 -- sh /root/onos/${karafHome}/bin/client cfg get > ~/voltha-infra-onos-classic-2-cfg.txt || true
Matteo Scandolo064efbc2021-03-29 17:24:34 -0700704
Andrea Campanella188e50d2022-01-14 11:30:05 +0100705 # kubectl exec -t voltha-infra-onos-classic-0 -- sh /root/onos/${karafHome}/bin/client obj-next-ids > ~/voltha-infra-onos-classic-0-next-objs.txt || true
706 # kubectl exec -t voltha-infra-onos-classic-1 -- sh /root/onos/${karafHome}/bin/client obj-next-ids > ~/voltha-infra-onos-classic-1-next-objs.txt || true
707 # kubectl exec -t voltha-infra-onos-classic-2 -- sh /root/onos/${karafHome}/bin/client obj-next-ids > ~/voltha-infra-onos-classic-2-next-objs.txt || true
Matteo Scandolo064efbc2021-03-29 17:24:34 -0700708
Matteo Scandoloa2f07fc2020-10-08 18:30:54 -0700709 # get radius logs out of the container
Matteo Scandolob2de2032021-02-26 10:04:02 -0800710 kubectl cp $(kubectl get pods -l app=radius --no-headers | awk '{print $1}'):/var/log/freeradius/radius.log $LOG_FOLDER/radius.log || true
Matteo Scandolob70b3e02020-05-07 11:50:26 -0700711 '''
Matteo Scandolo27553c02020-07-16 17:21:57 -0700712 // dump all the BBSim(s) ONU information
Matteo Scandolob70b3e02020-05-07 11:50:26 -0700713 sh '''
714 BBSIM_IDS=$(kubectl get pods | grep bbsim | grep -v server | awk '{print $1}')
715 IDS=($BBSIM_IDS)
716
717 for bbsim in "${IDS[@]}"
718 do
Matteo Scandolo900e5112020-09-08 10:16:31 -0700719 kubectl exec -t $bbsim -- bbsimctl onu list > $LOG_FOLDER/$bbsim-device-list.txt || true
Matteo Scandoloe07dcff2021-09-29 15:40:47 -0700720 kubectl exec -t $bbsim -- bbsimctl uni list > $LOG_FOLDER/$bbsim-uni-list.txt || true
Matteo Scandolo900e5112020-09-08 10:16:31 -0700721 kubectl exec -t $bbsim -- bbsimctl service list > $LOG_FOLDER/$bbsim-service-list.txt || true
Matteo Scandolo6b66b582021-03-10 14:33:47 -0800722 kubectl exec -t $bbsim -- bbsimctl olt resources GEM_PORT > $LOG_FOLDER/$bbsim-flows-gem-ports.txt || true
723 kubectl exec -t $bbsim -- bbsimctl olt resources ALLOC_ID > $LOG_FOLDER/$bbsim-flows-alloc-ids.txt || true
724 kubectl exec -t $bbsim -- bbsimctl olt pons > $LOG_FOLDER/$bbsim-pon-resources.txt || true
Matteo Scandolob70b3e02020-05-07 11:50:26 -0700725 done
726 '''
Matteo Scandolodbda3272021-03-04 14:50:07 -0800727 script {
728 // first make sure the port-forward is still running,
Matteo Scandolo67842812021-07-13 16:52:13 -0700729 // sometimes Jenkins kills it regardless of the JENKINS_NODE_COOKIE=dontKillMe
Matteo Scandolodbda3272021-03-04 14:50:07 -0800730 def running = sh (
731 script: 'ps aux | grep port-forw | grep -E "onos|voltha" | grep -v grep | wc -l',
732 returnStdout: true
733 ).trim()
734 // if any of the voltha-api, onos-rest, onos-ssh port-forwards are not there
735 // kill all and restart
736 if (running != "3") {
737 start_port_forward(olts)
738 }
739 }
Matteo Scandolo32da27d2020-05-29 10:38:31 -0700740 // get ONOS debug infos
Matteo Scandolob70b3e02020-05-07 11:50:26 -0700741 sh '''
Matteo Scandolobbd8f902020-09-24 08:40:58 -0700742
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700743 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 apps -a -s > $LOG_FOLDER/onos-apps.txt
744 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 nodes > $LOG_FOLDER/onos-nodes.txt
745 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 masters > $LOG_FOLDER/onos-masters.txt
746 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 roles > $LOG_FOLDER/onos-roles.txt
747 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 cfg get > $LOG_FOLDER/onos-cfg.txt
748 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 netcfg > $LOG_FOLDER/onos-netcfg.txt
Matteo Scandolodbda3272021-03-04 14:50:07 -0800749
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700750 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 ports > $LOG_FOLDER/onos-ports-list.txt
751 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 hosts > $LOG_FOLDER/onos-hosts-list.txt
Matteo Scandolo32da27d2020-05-29 10:38:31 -0700752
753 if [ ${withFlows} = true ] ; then
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700754 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 volt-olts > $LOG_FOLDER/onos-olt-list.txt
755 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 flows -s > $LOG_FOLDER/onos-flows-list.txt
756 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 meters > $LOG_FOLDER/onos-meters-list.txt
Matteo Scandolo38c6adf2022-01-20 16:47:17 -0800757 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 volt-port-status > $LOG_FOLDER/onos-volt-port-status.txt
Matteo Scandolo32da27d2020-05-29 10:38:31 -0700758 fi
759
Matteo Scandolo0bf7e9e2020-05-29 18:17:50 -0700760 if [ ${provisionSubscribers} = true ]; then
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700761 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 volt-programmed-subscribers > $LOG_FOLDER/onos-programmed-subscribers.txt
762 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 volt-programmed-meters > $LOG_FOLDER/onos-programmed-meters.txt
763 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 volt-bpmeter-mappings > $LOG_FOLDER/onos-bpmeter-mappings.txt
764 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 volt-failed-subscribers > $LOG_FOLDER/onos-failed-subscribers.txt
Matteo Scandolo32da27d2020-05-29 10:38:31 -0700765 fi
766
Matteo Scandolo172c9ca2020-06-10 12:23:48 -0700767 if [ ${withEapol} = true ] ; then
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700768 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 aaa-users > $LOG_FOLDER/onos-aaa-users.txt
769 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 aaa-statistics > $LOG_FOLDER/onos-aaa-statistics.txt
Matteo Scandolo32da27d2020-05-29 10:38:31 -0700770 fi
771
Matteo Scandolo172c9ca2020-06-10 12:23:48 -0700772 if [ ${withDhcp} = true ] ; then
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700773 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 dhcpl2relay-allocations > $LOG_FOLDER/onos-dhcp-allocations.txt
Matteo Scandolofebf6512021-03-02 11:37:37 -0800774 fi
775
776 if [ ${withIgmp} = true ] ; then
Matteo Scandolofa49b8d2021-04-09 12:05:34 -0700777 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 mcast-host-routes > $LOG_FOLDER/onos-mcast-host-routes.txt
778 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 mcast-host-show > $LOG_FOLDER/onos-mcast-host-show.txt
779 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@127.0.0.1 groups > $LOG_FOLDER/onos-groups.txt
Matteo Scandolo32da27d2020-05-29 10:38:31 -0700780 fi
Matteo Scandolob70b3e02020-05-07 11:50:26 -0700781 '''
Shrey Baidcf652c82020-05-21 13:35:04 +0530782 // collect etcd metrics
783 sh '''
Matteo Scandolo77fa78d2020-09-16 16:53:50 -0700784 mkdir -p $WORKSPACE/etcd-metrics
Matteo Scandolo9214ebd2020-07-30 17:57:10 -0700785 curl -s -X GET -G http://10.90.0.101:31301/api/v1/query --data-urlencode 'query=etcd_debugging_mvcc_keys_total' | jq '.data' > $WORKSPACE/etcd-metrics/etcd-key-count.json || true
786 curl -s -X GET -G http://10.90.0.101:31301/api/v1/query --data-urlencode 'query=grpc_server_handled_total{grpc_service="etcdserverpb.KV"}' | jq '.data' > $WORKSPACE/etcd-metrics/etcd-rpc-count.json || true
787 curl -s -X GET -G http://10.90.0.101:31301/api/v1/query --data-urlencode 'query=etcd_debugging_mvcc_db_total_size_in_bytes' | jq '.data' > $WORKSPACE/etcd-metrics/etcd-db-size.json || true
788 curl -s -X GET -G http://10.90.0.101:31301/api/v1/query --data-urlencode 'query=etcd_disk_backend_commit_duration_seconds_sum' | jq '.data' > $WORKSPACE/etcd-metrics/etcd-backend-write-time.json || true
Andrea Campanella31fd31f2020-11-20 19:02:58 +0100789 curl -s -X GET -G http://10.90.0.101:31301/api/v1/query --data-urlencode 'query=etcd_disk_backend_commit_duration_seconds_sum' | jq '.data' > $WORKSPACE/etcd-metrics/etcd-backend-write-time-sum.json || true
790 curl -s -X GET -G http://10.90.0.101:31301/api/v1/query --data-urlencode 'query=etcd_disk_backend_commit_duration_seconds_bucket' | jq '.data' > $WORKSPACE/etcd-metrics/etcd-backend-write-time-bucket.json || true
791 curl -s -X GET -G http://10.90.0.101:31301/api/v1/query --data-urlencode 'query=etcd_disk_wal_fsync_duration_seconds_bucket' | jq '.data' > $WORKSPACE/etcd-metrics/etcd-wal-fsync-time-bucket.json || true
Andrea Campanella23a1c322020-11-25 17:11:55 +0100792 curl -s -X GET -G http://10.90.0.101:31301/api/v1/query --data-urlencode 'query=etcd_network_peer_round_trip_time_seconds_bucket' | jq '.data' > $WORKSPACE/etcd-metrics/etcd-network-peer-round-trip-time-seconds.json || true
Girish Gowdra483c9672021-05-29 16:08:26 -0700793 etcd_namespace=\$(kubectl get pods --all-namespaces | grep etcd-0 | awk 'NR==1{print \$1}')
794 etcd_container=\$(kubectl get pods --all-namespaces | grep etcd-0 | awk 'NR==1{print \$2}')
795 kubectl exec -it -n \$etcd_namespace \$etcd_container -- etcdctl defrag --cluster || true
796 kubectl exec -it -n \$etcd_namespace \$etcd_container -- etcdctl endpoint status -w table > $WORKSPACE/etcd-metrics/etcd-status-table.txt || true
Andrea Campanella23a1c322020-11-25 17:11:55 +0100797
Shrey Baidcf652c82020-05-21 13:35:04 +0530798 '''
Matteo Scandolo32da27d2020-05-29 10:38:31 -0700799 // get VOLTHA debug infos
Matteo Scandolo502644b2020-05-18 08:56:18 -0700800 script {
801 try {
802 sh '''
Matteo Scandolof54c9b32020-08-27 07:58:27 -0700803 voltctl -m 8MB device list -o json > $LOG_FOLDER/device-list.json || true
804 python -m json.tool $LOG_FOLDER/device-list.json > $LOG_FOLDER/voltha-devices-list.json || true
805 rm $LOG_FOLDER/device-list.json || true
806 voltctl -m 8MB device list > $LOG_FOLDER/voltha-devices-list.txt || true
Matteo Scandolo32da27d2020-05-29 10:38:31 -0700807
Matteo Scandolobe823242020-11-20 13:48:13 -0800808 printf '%s\n' $(voltctl -m 8MB device list | grep olt | awk '{print $1}') | xargs --no-run-if-empty -I# bash -c "voltctl -m 8MB device flows # > $LOG_FOLDER/voltha-device-flows-#.txt" || true
809 printf '%s\n' $(voltctl -m 8MB device list | grep olt | awk '{print $1}') | xargs --no-run-if-empty -I# bash -c "voltctl -m 8MB device port list --format 'table{{.PortNo}}\t{{.Label}}\t{{.Type}}\t{{.AdminState}}\t{{.OperStatus}}' # > $LOG_FOLDER/voltha-device-ports-#.txt" || true
Matteo Scandolo32da27d2020-05-29 10:38:31 -0700810
Matteo Scandolobe823242020-11-20 13:48:13 -0800811 printf '%s\n' $(voltctl -m 8MB logicaldevice list -q) | xargs --no-run-if-empty -I# bash -c "voltctl -m 8MB logicaldevice flows # > $LOG_FOLDER/voltha-logicaldevice-flows-#.txt" || true
812 printf '%s\n' $(voltctl -m 8MB logicaldevice list -q) | xargs --no-run-if-empty -I# bash -c "voltctl -m 8MB logicaldevice port list # > $LOG_FOLDER/voltha-logicaldevice-ports-#.txt" || true
Matteo Scandolo502644b2020-05-18 08:56:18 -0700813 '''
814 } catch(e) {
815 sh '''
816 echo "Can't get device list from voltclt"
817 '''
818 }
819 }
Matteo Scandolo27553c02020-07-16 17:21:57 -0700820 // get cpu usage by container
821 sh '''
Matteo Scandolo7d6695c2020-08-25 13:13:16 -0700822 if [ ${withMonitoring} = true ] ; then
823 cd $WORKSPACE/voltha-system-tests
Matteo Scandolo9e8ba502021-11-17 13:56:56 -0800824 make vst_venv
Andrea Campanellac9ecaba2021-06-01 14:11:09 +0200825 source ./vst_venv/bin/activate || true
Matteo Scandolo7d6695c2020-08-25 13:13:16 -0700826 sleep 60 # we have to wait for prometheus to collect all the information
Hardik Windlass5cfb29a2021-08-10 09:39:29 +0000827 python scripts/sizing.py -o $WORKSPACE/plots || true
Matteo Scandolo7d6695c2020-08-25 13:13:16 -0700828 fi
Matteo Scandolo27553c02020-07-16 17:21:57 -0700829 '''
Matteo Scandolo7cf2fc22021-03-01 18:33:42 -0800830 archiveArtifacts artifacts: 'execution-time.txt,logs/*,logs/pprof/*,RobotLogs/**/*,plots/*,etcd-metrics/*'
Matteo Scandolofbcbdb82020-05-06 15:41:32 -0700831 }
832 }
833}
Matteo Scandolodbda3272021-03-04 14:50:07 -0800834
835def start_port_forward(olts) {
836 sh """
Matteo Scandolodbda3272021-03-04 14:50:07 -0800837 bbsimRestPortFwd=50071
838 for i in {0..${olts.toInteger() - 1}}; do
839 daemonize -E JENKINS_NODE_COOKIE="dontKillMe" /usr/local/bin/kubectl port-forward --address 0.0.0.0 -n default svc/bbsim\${i} \${bbsimRestPortFwd}:50071
840 ((bbsimRestPortFwd++))
841 done
842 """
843}