blob: aa74c4d4da2f06e461871a2d592a326e4537ef04 [file] [log] [blame]
Hardik Windlass36d5bdb2022-02-09 10:13:13 +00001// Copyright 2022-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// used to deploy VOLTHA and configure ONOS physical PODs
16
17// NOTE we are importing the library even if it's global so that it's
18// easier to change the keywords during a replay
19library identifier: 'cord-jenkins-libraries@master',
20 retriever: modernSCM([
21 $class: 'GitSCMSource',
22 remote: 'https://gerrit.opencord.org/ci-management.git'
23])
24
25def infraNamespace = "infra"
26def volthaNamespace = "voltha"
27
28def deploy_custom_chart(namespace, name, chart, extraHelmFlags) {
29 sh """
30 helm install --create-namespace --set defaults.image_pullPolicy=Always --namespace ${namespace} ${extraHelmFlags} ${name} ${chart}
31 """
32}
33
34pipeline {
35
36 /* no label, executor is determined by JJB */
37 agent {
38 label "${params.buildNode}"
39 }
40 options {
41 timeout(time: 45, unit: 'MINUTES')
42 }
43 environment {
44 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
45 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
46 VOLTCONFIG="$HOME/.volt/config-minimal"
47 LOG_FOLDER="$WORKSPACE/dmi/"
48 APPS_TO_LOG="${OltDevMgr}"
49 }
50
51 stages{
52 stage('Download Code') {
53 steps {
54 getVolthaCode([
55 branch: "${branch}",
56 volthaSystemTestsChange: "${volthaSystemTestsChange}",
57 volthaHelmChartsChange: "${volthaHelmChartsChange}",
58 ])
59 }
60 }
61 stage ("Parse deployment configuration file") {
62 steps {
63 sh returnStdout: true, script: "rm -rf ${configBaseDir}"
64 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
65 script {
66 if ( params.workFlow == "DT" ) {
67 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
68 }
69 else if ( params.workFlow == "TT" )
70 {
71 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
72 }
73 else
74 {
75 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
76 }
77 }
78 }
79 }
80 stage('Clean up') {
81 steps {
82 timeout(15) {
83 script {
84 helmTeardown(["default", infraNamespace, volthaNamespace])
85 }
86 timeout(1) {
87 sh returnStdout: false, script: '''
88 # remove orphaned port-forward from different namespaces
89 ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true
90 '''
91 }
92 }
93 }
94 }
95 stage('Install Voltha') {
Hardik Windlassace19e52022-02-10 09:36:21 +000096 when {
97 expression {
98 return installVoltha.toBoolean()
99 }
100 }
Hardik Windlass36d5bdb2022-02-09 10:13:13 +0000101 steps {
102 timeout(20) {
103 installVoltctl("${branch}")
104 script {
105 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
106 def localCharts = false
107 if (volthaHelmChartsChange != "") {
108 localCharts = true
109 }
110
111 // should the config file be suffixed with the workflow? see "deployment_config"
112 def localHelmFlags = "-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml --set global.log_level=${logLevel} "
113
114 if (workFlow.toLowerCase() == "dt") {
115 localHelmFlags += " --set radius.enabled=false "
116 }
117 if (workFlow.toLowerCase() == "tt") {
118 localHelmFlags += " --set radius.enabled=false --set global.incremental_evto_update=true "
119 if (enableMultiUni.toBoolean()) {
120 localHelmFlags += " --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=${uniPortMask} "
121 }
122 }
123
124 // NOTE temporary workaround expose ONOS node ports (pod-config needs to be updated to contain these values)
125 // and to connect the ofagent to all instances of ONOS
126 localHelmFlags = localHelmFlags + " --set onos-classic.onosSshPort=30115 " +
127 "--set onos-classic.onosApiPort=30120 " +
128 "--set onos-classic.onosOfPort=31653 " +
129 "--set onos-classic.individualOpenFlowNodePorts=true " +
130 "--set voltha.onos_classic.replicas=${params.NumOfOnos}"
131
132 if (bbsimReplicas.toInteger() != 0) {
133 localHelmFlags = localHelmFlags + " --set onu=${onuNumber},pon=${ponNumber} "
134 }
135
136 // adding user specified helm flags at the end so they'll have priority over everything else
137 localHelmFlags = localHelmFlags + " ${extraHelmFlags}"
138
139 def numberOfAdaptersToWait = 2
140
141 if(openoltAdapterChart != "onf/voltha-adapter-openolt") {
142 localHelmFlags = localHelmFlags + " --set voltha-adapter-openolt.enabled=false"
143 // We skip waiting for adapters in the volthaDeploy step because it's already waiting for
144 // both of them after the deployment of the custom olt adapter. See line 156.
145 numberOfAdaptersToWait = 0
146 }
147
148 volthaDeploy([
149 workflow: workFlow.toLowerCase(),
150 extraHelmFlags: localHelmFlags,
151 localCharts: localCharts,
152 kubeconfig: "$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf",
153 onosReplica: params.NumOfOnos,
154 atomixReplica: params.NumOfAtomix,
155 kafkaReplica: params.NumOfKafka,
156 etcdReplica: params.NumOfEtcd,
157 bbsimReplica: bbsimReplicas.toInteger(),
158 adaptersToWait: numberOfAdaptersToWait,
159 ])
160
161 if(openoltAdapterChart != "onf/voltha-adapter-openolt"){
162 extraHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel}"
163 deploy_custom_chart(volthaNamespace, oltAdapterReleaseName, openoltAdapterChart, extraHelmFlags)
164 waitForAdapters([
165 adaptersToWait: 2
166 ])
167 }
168 }
169 sh """
170 JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-api" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/voltha-voltha-api 55555:55555; done"&
171 JENKINS_NODE_COOKIE="dontKillMe" _TAG="etcd" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-etcd ${params.VolthaEtcdPort}:2379; done"&
172 JENKINS_NODE_COOKIE="dontKillMe" _TAG="kafka" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-kafka 9092:9092; done"&
173 ps aux | grep port-forward
174 """
175 getPodsInfo("$WORKSPACE")
176 }
177 }
178 }
179 stage('Deploy Device Manager Interface Chart') {
180 steps {
181 script {
182 deploy_custom_chart('default', 'olt-device-manager', dmiChart, extraHelmFlags)
183 }
184 println "Wait for olt-device-manager to start"
185 sh """
186 set +x
187 devmgr=\$(kubectl get pods -l app.kubernetes.io/name=${params.OltDevMgr} --no-headers | grep "0/" | wc -l)
188 while [[ \$devmgr != 0 ]]; do
189 sleep 5
190 devmgr=\$(kubectl get pods -l app.kubernetes.io/name=${params.OltDevMgr} --no-headers | grep "0/" | wc -l)
191 done
192 """
193 sh """
Hardik Windlassace19e52022-02-10 09:36:21 +0000194 JENKINS_NODE_COOKIE="dontKillMe" _TAG="${params.OltDevMgr}" bash -c "while true; do kubectl port-forward --address 0.0.0.0 svc/${params.OltDevMgr} 50051; done"&
Hardik Windlass36d5bdb2022-02-09 10:13:13 +0000195 ps aux | grep port-forward
196 """
197 }
198 }
199 stage('Start logging') {
200 steps {
201 sh returnStdout: false, script: '''
202 # start logging with kail
203 cd $WORKSPACE
204 mkdir -p $LOG_FOLDER
205 list=($APPS_TO_LOG)
206 for app in "${list[@]}"
207 do
208 echo "Starting logs for: ${app}"
209 _TAG=kail-$app kail -l app.kubernetes.io/name=$app --since 1h > $LOG_FOLDER/$app.log&
210 done
211 '''
212 }
213 }
214 stage('Reinstall OLT software') {
215 steps {
216 script {
217 if ( params.reinstallOlt ) {
218 for(int i=0; i < deployment_config.olts.size(); i++) {
219 sh returnStdout: true, script: """
220 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
221 if [ "${params.inBandManagement}" == "true" ]; then
222 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'kill -9 `pgrep -f "[b]ash /opt/openolt/openolt_dev_mgmt_daemon_process_watchdog"` || true'
223 fi
224 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} "dpkg --install ${deployment_config.olts[i].oltDebVersion}"
225 sleep 10
226 """
227 timeout(5) {
228 waitUntil {
229 olt_sw_present = sh returnStdout: true, script: """
230 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]]; then
231 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep asfvolt16 | wc -l'
232 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"asgvolt64"* ]]; then
233 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep asgvolt64 | wc -l'
234 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600x-w"* ]]; then
235 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep rlt-1600x-w | wc -l'
236 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600g-w"* ]]; then
237 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep rlt-1600g-w | wc -l'
238 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-3200g-w"* ]]; then
239 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep rlt-3200g-w | wc -l'
240 else
241 echo Unknown Debian package for openolt
242 fi
243 if (${deployment_config.olts[i].fortygig}); then
244 if [[ "${params.inBandManagement}" == "true" ]]; then
245 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
246 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/'
247 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'cp /root/watchdog-script/* /opt/openolt/'
248 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'cp /root/bal_cli_appl/example_user_appl /broadcom'
249 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'cp in-band-startup-script/* /etc/init.d/'
250 fi
251 fi
252 """
253 return olt_sw_present.toInteger() > 0
254 }
255 }
256 }
257 }
258 }
259 }
260 }
261 stage('Restart OLT processes') {
262 steps {
263 script {
264 if ( params.restartOlt ) {
265 //rebooting OLTs
266 for(int i=0; i < deployment_config.olts.size(); i++) {
267 timeout(15) {
268 sh returnStdout: true, script: """
269 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
270 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; rm -f /var/log/openolt_process_watchdog.log; reboot > /dev/null &' || true
271 """
272 }
273 }
274 sh returnStdout: true, script: """
275 sleep ${params.waitTimerForOltUp}
276 """
277 //Checking dev_management_deamon and openoltprocesses
278 for(int i=0; i < deployment_config.olts.size(); i++) {
279 if ( params.oltAdapterReleaseName != "open-olt" ) {
280 timeout(15) {
281 waitUntil {
282 devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
283 return devprocess.toInteger() > 0
284 }
285 }
286 timeout(15) {
287 waitUntil {
288 openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep openolt | wc -l'"
289 return openoltprocess.toInteger() > 0
290 }
291 }
292 }
293 }
294 }
295 }
296 }
297 }
298 stage('Run Device Management Interface Tests') {
299 environment {
300 ROBOT_FILE="dmi-hw-management.robot"
301 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs"
302 ROBOT_CONFIG_FILE="$WORKSPACE/voltha-system-tests/tests/data/dmi-components-adtran.yaml"
303 }
304 steps {
305 sh """
306 mkdir -p $ROBOT_LOGS_DIR
307 export ROBOT_MISC_ARGS="--removekeywords wuks -e notreadyDMI -i functionalDMI -d $ROBOT_LOGS_DIR"
308 make -C $WORKSPACE/voltha-system-tests voltha-dmi-test || true
309 """
310 }
311 }
312 }
313
314 post {
315 always {
Hardik Windlassace19e52022-02-10 09:36:21 +0000316 getPodsInfo("$WORKSPACE")
Hardik Windlass36d5bdb2022-02-09 10:13:13 +0000317 sh '''
318 # stop the kail processes
319 list=($APPS_TO_LOG)
320 for app in "${list[@]}"
321 do
322 echo "Stopping logs for: ${app}"
323 _TAG="kail-$app"
324 P_IDS="$(ps e -ww -A | grep "_TAG=$_TAG" | grep -v grep | awk '{print $1}')"
325 if [ -n "$P_IDS" ]; then
326 echo $P_IDS
327 for P_ID in $P_IDS; do
328 kill -9 $P_ID
329 done
330 fi
331 done
332 '''
333 step([$class: 'RobotPublisher',
334 disableArchiveOutput: false,
335 logFileName: 'RobotLogs/log*.html',
336 otherFiles: '',
337 outputFileName: 'RobotLogs/output*.xml',
338 outputPath: '.',
339 passThreshold: 100,
340 reportFileName: 'RobotLogs/report*.html',
341 unstableThreshold: 0,
342 onlyCritical: true]);
343 archiveArtifacts artifacts: '**/*.txt,**/*.gz,*.gz,**/*.log'
344 }
345 }
346}