blob: 8d35c2b221b9c0706697b8caebb44407ac3a138d [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
51 NUM_OF_OPENONU=1
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 }
159 }
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700160 post {
161 always {
162 archiveArtifacts artifacts: '*-install-minimal.log,*-minimal-env.sh,RobotLogs/**/*,stats/**/*'
163 }
164 }
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700165}
166
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700167def repeat_deploy_and_test(list) {
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700168 for (int i = 0; i < list.size(); i++) {
Matteo Scandolof6e86582020-11-03 17:53:01 -0800169 stage('Cleanup') {
170 sh returnStdout: false, script: """
171 for hchart in \$(helm list -q | grep -E -v 'bbsim-sadis-server|onos|radius');
172 do
173 echo "Purging chart: \${hchart}"
174 helm delete "\${hchart}"
175 done
176 bash /home/cord/voltha-scale/wait_for_pods.sh
177 """
178 }
179 stage('Deploy monitoring infrastructure') {
180 sh returnStdout: false, script: '''
181 helm install nem-monitoring cord/nem-monitoring \
182 -f $HOME/voltha-scale/grafana.yaml \
183 --set prometheus.alertmanager.enabled=false,prometheus.pushgateway.enabled=false \
184 --set kpi_exporter.enabled=false,dashboards.xos=false,dashboards.onos=false,dashboards.aaa=false,dashboards.voltha=false
185
186 # TODO download this file from https://github.com/opencord/helm-charts/blob/master/scripts/wait_for_pods.sh
187 bash /home/cord/voltha-scale/wait_for_pods.sh
188 '''
189 }
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700190 stage('Deploy topology: ' + list[i]['olt'] + "-" + list[i]['pon'] + "-" + list[i]['onu']) {
191 timeout(time: 10, unit: 'MINUTES') {
192 script {
193 now = new Date();
194 currentRunStart = now.getTime() / 1000;
195 println("Start: " + currentRunStart)
196 }
197 sh returnStdout: false, script: """
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700198 cd $WORKSPACE/kind-voltha/
199
200 if [ '${release.trim()}' != 'master' ]; then
201 source $WORKSPACE/kind-voltha/releases/${release}
202 fi
203
204 # if it's newer than voltha-2.4 set the correct BBSIM_CFG
205 if [ '${release.trim()}' != 'voltha-2.4' ]; then
206 export BBSIM_CFG="$WORKSPACE/kind-voltha/configs/bbsim-sadis-dt.yaml"
207 fi
208
209 export NUM_OF_BBSIM=${list[i]['olt']}
210 export EXTRA_HELM_FLAGS+="--set enablePerf=true,pon=${list[i]['pon']},onu=${list[i]['onu']} "
Matteo Scandolof6e86582020-11-03 17:53:01 -0800211 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 -0700212 ./voltha up
213
214 cp minimal-env.sh ../${list[i]['olt']}-${list[i]['pon']}-${list[i]['onu']}-minimal-env.sh
215 cp install-minimal.log ../${list[i]['olt']}-${list[i]['pon']}-${list[i]['onu']}-install-minimal.log
216 """
217 //sleep(120) // TODO can we improve and check once the bbsim-sadis-server is actually done loading subscribers??
218 }
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700219 }
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700220 stage('Test topology: ' + list[i]['olt'] + "-" + list[i]['pon'] + "-" + list[i]['onu']) {
221 timeout(time: 10, unit: 'MINUTES') {
222 sh returnStdout: false, script: """
223 mkdir -p $WORKSPACE/RobotLogs/${list[i]['olt']}-${list[i]['pon']}-${list[i]['onu']}
224 cd $WORKSPACE/voltha-system-tests
225 make vst_venv
226
227 export ROBOT_PARAMS=" \
228 -v olt:${list[i]['olt']} \
229 -v pon:${list[i]['pon']} \
230 -v onu:${list[i]['onu']} \
231 -v workflow:dt \
232 -v withEapol:false \
233 -v withDhcp:false \
234 -v withIgmp:false \
235 --noncritical non-critical \
236 -e teardown \
237 -e authentication \
238 -e dhcp"
239
240 cd $WORKSPACE/voltha-system-tests
241 source ./vst_venv/bin/activate
242 robot -d $WORKSPACE/RobotLogs/${list[i]['olt']}-${list[i]['pon']}-${list[i]['onu']} \
243 \$ROBOT_PARAMS tests/scale/Voltha_Scale_Tests.robot
244 """
245 }
246 }
247 stage('Collect metrics: ' + list[i]['olt'] + "-" + list[i]['pon'] + "-" + list[i]['onu']) {
248 script {
249 now = new Date();
250 currentRunEnd = now.getTime() / 1000;
251 println("End: " + currentRunEnd)
252 delta = currentRunEnd - currentRunStart
253 println("Delta: " + delta)
254 minutesDelta = Math.ceil(delta / 60).toInteger()
255 println("Delta in minutes: " + minutesDelta)
256 }
257 sh returnStdout: false, script: """
258 export LOG_FOLDER=$WORKSPACE/stats/${list[i]['olt']}-${list[i]['pon']}-${list[i]['onu']}
259 mkdir -p \$LOG_FOLDER
260 cd $WORKSPACE/voltha-system-tests
261 make vst_venv
262 source ./vst_venv/bin/activate
263
Matteo Scandolof6e86582020-11-03 17:53:01 -0800264 sleep 60 # we have to wait for prometheus to collect all the information
265
Matteo Scandolo5fec8022020-08-27 17:29:35 -0700266 python tests/scale/sizing.py -o \$LOG_FOLDER -s ${minutesDelta}|| true
267 """
268 }
269 }
Matteo Scandoloc88d3132020-08-27 15:24:34 -0700270}