blob: f844a7b0ab42cc4299f24a48e2aadb31c580ece0 [file] [log] [blame]
Matteo Scandoloc88d3132020-08-27 15:24:34 -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
15pipeline {
16
17 agent {
18 label "${params.buildNode}"
19 }
20 options {
Matteo Scandolo5fec8022020-08-27 17:29:35 -070021 timeout(time: 120, unit: 'MINUTES')
Matteo Scandoloc88d3132020-08-27 15:24:34 -070022 }
23 environment {
Matteo Scandolo52749cb2020-08-27 16:33:13 -070024 JENKINS_NODE_COOKIE="dontKillMe" // do not kill processes after the build is done
25 KUBECONFIG="$HOME/.kube/config"
26 VOLTCONFIG="$HOME/.volt/config"
27 SCHEDULE_ON_CONTROL_NODES="yes"
Matteo Scandolo5fec8022020-08-27 17:29:35 -070028 FANCY=0
29 NAME="minimal"
Matteo Scandoloc88d3132020-08-27 15:24:34 -070030
Matteo Scandolo52749cb2020-08-27 16:33:13 -070031 WITH_SIM_ADAPTERS="no"
Matteo Scandolo5fec8022020-08-27 17:29:35 -070032 WITH_RADIUS="no"
Matteo Scandolo52749cb2020-08-27 16:33:13 -070033 WITH_BBSIM="yes"
34 LEGACY_BBSIM_INDEX="no"
35 DEPLOY_K8S="no"
36 CONFIG_SADIS="external"
Matteo Scandolo5fec8022020-08-27 17:29:35 -070037 VOLTHA_LOG_LEVEL="WARN"
38
39 // install everything in the default namespace
40 VOLTHA_NS="default"
41 ADAPTER_NS="default"
42 INFRA_NS="default"
43 BBSIM_NS="default"
44
45 // workflow
46 WITH_EAPOL="no"
47 WITH_DHCP="no"
48 WITH_IGMP="no"
49
50 // infrastructure size
Matteo Scandoloe5d41f62020-11-04 15:43:50 -080051 NUM_OF_OPENONU="${openonuAdapterReplicas}"
Matteo Scandolof6e86582020-11-03 17:53:01 -080052 NUM_OF_ONOS="${onosReplicas}"
53 NUM_OF_ATOMIX="${atomixReplicas}"
54 NUM_OF_KAFKA="${kafkaReplicas}"
55 NUM_OF_ETCD="${etcdReplicas}"
Matteo Scandoloc88d3132020-08-27 15:24:34 -070056 }
57
58 stages {
Matteo Scandoloffc7f842020-11-04 13:43:21 -080059 stage ('Parse parameters') {
60 steps {
61 script {
62 format = "format is 'olt-pon-onu' separated bya comma, eg: '1-16-16, 1-16-32, 2-16-32'"
63 source = params.topologies
64
65 if (source == null || source == "") {
66 throw new Exception("You need to specify some deployment topologies, " + format)
67 }
68
69 topologies = []
70
71 for(topo in source.split(",")) {
72 t = topo.split("-")
73 topologies.add(['olt': t[0].trim(), 'pon': t[1].trim(), 'onu': t[2].trim()])
74 }
75
76 if (topologies.size() == 0) {
77 throw new Exception("Not enough topologies defined, " + format)
78 }
79 println "Deploying topologies:"
80 println topologies
81 }
82 }
83 }
Matteo Scandoloc88d3132020-08-27 15:24:34 -070084 stage ('Cleanup') {
85 steps {
Matteo Scandolo5fec8022020-08-27 17:29:35 -070086 timeout(time: 10, unit: 'MINUTES') {
Matteo Scandoloc88d3132020-08-27 15:24:34 -070087 sh returnStdout: false, script: """
88 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com
89 helm repo add stable https://kubernetes-charts.storage.googleapis.com
90 helm repo add onf https://charts.opencord.org
91 helm repo add cord https://charts.opencord.org
92 helm repo add onos https://charts.onosproject.org
93 helm repo add atomix https://charts.atomix.io
94 helm repo add bbsim-sadis https://ciena.github.io/bbsim-sadis-server/charts
95 helm repo update
96
Matteo Scandoloc88d3132020-08-27 15:24:34 -070097 for hchart in \$(helm list -q | grep -E -v 'docker-registry|kafkacat');
98 do
99 echo "Purging chart: \${hchart}"
100 helm delete "\${hchart}"
101 done
102 bash /home/cord/voltha-scale/wait_for_pods.sh
103
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700104 cd $WORKSPACE
105 rm -rf $WORKSPACE/*
106 """
107 }
108 }
109 }
110 stage('Clone kind-voltha') {
111 steps {
112 checkout([
113 $class: 'GitSCM',
114 userRemoteConfigs: [[ url: "https://gerrit.opencord.org/kind-voltha", ]],
115 branches: [[ name: "master", ]],
116 extensions: [
117 [$class: 'WipeWorkspace'],
118 [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
119 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
120 ],
121 ])
122 script {
123 sh(script:"""
124 if [ '${kindVolthaChange}' != '' ] ; then
125 cd $WORKSPACE/kind-voltha;
126 git fetch https://gerrit.opencord.org/kind-voltha ${volthaSystemTestsChange} && git checkout FETCH_HEAD
127 fi
128 """)
129 }
130 }
131 }
132 stage('Clone voltha-system-tests') {
133 steps {
134 checkout([
135 $class: 'GitSCM',
136 userRemoteConfigs: [[ url: "https://gerrit.opencord.org/voltha-system-tests", ]],
137 branches: [[ name: "${release}", ]],
138 extensions: [
139 [$class: 'WipeWorkspace'],
140 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
141 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
142 ],
143 ])
144 script {
145 sh(script:"""
146 if [ '${volthaSystemTestsChange}' != '' ] ; then
147 cd $WORKSPACE/voltha-system-tests;
148 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
149 fi
150 """)
151 }
152 }
153 }
154 stage('Deploy and test') {
Matteo Scandolo52749cb2020-08-27 16:33:13 -0700155 steps {
156 repeat_deploy_and_test(topologies)
157 }
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700158 }
Matteo Scandoloe5d41f62020-11-04 15:43:50 -0800159 stage('Aggregate stats') {
160 steps {
161 sh returnStdout: false, script: """
162 export IN_FOLDER=$WORKSPACE/stats/
163 export OUT_FOLDER=$WORKSPACE/plots/
164 mkdir -p \$OUT_FOLDER
165 cd $WORKSPACE/voltha-system-tests
166 make vst_venv
167 source ./vst_venv/bin/activate
168
169 sleep 60 # we have to wait for prometheus to collect all the information
170
Matteo Scandolob7d60ba2020-11-06 09:46:11 -0800171 python tests/scale/stats-aggregation.py -s \$IN_FOLDER -o \$OUT_FOLDER
Matteo Scandoloe5d41f62020-11-04 15:43:50 -0800172 """
173 }
174 }
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700175 }
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700176 post {
177 always {
Matteo Scandolob7d60ba2020-11-06 09:46:11 -0800178 archiveArtifacts artifacts: '*-install-minimal.log,*-minimal-env.sh,RobotLogs/**/*,stats/**/*,logs/**/*'
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700179 }
180 }
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700181}
182
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700183def repeat_deploy_and_test(list) {
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700184 for (int i = 0; i < list.size(); i++) {
Matteo Scandolof6e86582020-11-03 17:53:01 -0800185 stage('Cleanup') {
186 sh returnStdout: false, script: """
187 for hchart in \$(helm list -q | grep -E -v 'bbsim-sadis-server|onos|radius');
188 do
189 echo "Purging chart: \${hchart}"
190 helm delete "\${hchart}"
191 done
192 bash /home/cord/voltha-scale/wait_for_pods.sh
193 """
194 }
195 stage('Deploy monitoring infrastructure') {
196 sh returnStdout: false, script: '''
197 helm install nem-monitoring cord/nem-monitoring \
198 -f $HOME/voltha-scale/grafana.yaml \
199 --set prometheus.alertmanager.enabled=false,prometheus.pushgateway.enabled=false \
200 --set kpi_exporter.enabled=false,dashboards.xos=false,dashboards.onos=false,dashboards.aaa=false,dashboards.voltha=false
201
202 # TODO download this file from https://github.com/opencord/helm-charts/blob/master/scripts/wait_for_pods.sh
203 bash /home/cord/voltha-scale/wait_for_pods.sh
204 '''
205 }
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700206 stage('Deploy topology: ' + list[i]['olt'] + "-" + list[i]['pon'] + "-" + list[i]['onu']) {
207 timeout(time: 10, unit: 'MINUTES') {
208 script {
209 now = new Date();
210 currentRunStart = now.getTime() / 1000;
211 println("Start: " + currentRunStart)
212 }
213 sh returnStdout: false, script: """
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700214 cd $WORKSPACE/kind-voltha/
215
216 if [ '${release.trim()}' != 'master' ]; then
217 source $WORKSPACE/kind-voltha/releases/${release}
218 fi
219
220 # if it's newer than voltha-2.4 set the correct BBSIM_CFG
221 if [ '${release.trim()}' != 'voltha-2.4' ]; then
222 export BBSIM_CFG="$WORKSPACE/kind-voltha/configs/bbsim-sadis-dt.yaml"
223 fi
224
225 export NUM_OF_BBSIM=${list[i]['olt']}
226 export EXTRA_HELM_FLAGS+="--set enablePerf=true,pon=${list[i]['pon']},onu=${list[i]['onu']} "
Matteo Scandolof6e86582020-11-03 17:53:01 -0800227 export EXTRA_HELM_FLAGS+="--set prometheus.kafka.enabled=true,prometheus.operator.enabled=true,prometheus.jmx.enabled=true,prometheus.operator.serviceMonitor.namespace=default"
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700228 ./voltha up
229
230 cp minimal-env.sh ../${list[i]['olt']}-${list[i]['pon']}-${list[i]['onu']}-minimal-env.sh
231 cp install-minimal.log ../${list[i]['olt']}-${list[i]['pon']}-${list[i]['onu']}-install-minimal.log
232 """
Matteo Scandolob7d60ba2020-11-06 09:46:11 -0800233 sleep(120) // TODO can we improve and check once the bbsim-sadis-server is actually done loading subscribers??
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700234 }
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700235 }
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700236 stage('Test topology: ' + list[i]['olt'] + "-" + list[i]['pon'] + "-" + list[i]['onu']) {
Matteo Scandolob7d60ba2020-11-06 09:46:11 -0800237 timeout(time: 15, unit: 'MINUTES') {
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700238 sh returnStdout: false, script: """
239 mkdir -p $WORKSPACE/RobotLogs/${list[i]['olt']}-${list[i]['pon']}-${list[i]['onu']}
240 cd $WORKSPACE/voltha-system-tests
241 make vst_venv
242
243 export ROBOT_PARAMS=" \
244 -v olt:${list[i]['olt']} \
245 -v pon:${list[i]['pon']} \
246 -v onu:${list[i]['onu']} \
247 -v workflow:dt \
248 -v withEapol:false \
249 -v withDhcp:false \
250 -v withIgmp:false \
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700251 -e authentication \
252 -e dhcp"
253
254 cd $WORKSPACE/voltha-system-tests
255 source ./vst_venv/bin/activate
256 robot -d $WORKSPACE/RobotLogs/${list[i]['olt']}-${list[i]['pon']}-${list[i]['onu']} \
257 \$ROBOT_PARAMS tests/scale/Voltha_Scale_Tests.robot
258 """
259 }
260 }
261 stage('Collect metrics: ' + list[i]['olt'] + "-" + list[i]['pon'] + "-" + list[i]['onu']) {
262 script {
263 now = new Date();
264 currentRunEnd = now.getTime() / 1000;
265 println("End: " + currentRunEnd)
266 delta = currentRunEnd - currentRunStart
267 println("Delta: " + delta)
268 minutesDelta = Math.ceil(delta / 60).toInteger()
269 println("Delta in minutes: " + minutesDelta)
270 }
271 sh returnStdout: false, script: """
272 export LOG_FOLDER=$WORKSPACE/stats/${list[i]['olt']}-${list[i]['pon']}-${list[i]['onu']}
273 mkdir -p \$LOG_FOLDER
274 cd $WORKSPACE/voltha-system-tests
275 make vst_venv
276 source ./vst_venv/bin/activate
277
Matteo Scandolof6e86582020-11-03 17:53:01 -0800278 sleep 60 # we have to wait for prometheus to collect all the information
279
Matteo Scandolob7d60ba2020-11-06 09:46:11 -0800280 python tests/scale/sizing.py -o \$LOG_FOLDER -s ${minutesDelta}
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700281 """
282 }
283 }
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700284}