blob: afa034f6ff0abc2e9557af623813410118d9e262 [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') {
96 steps {
97 timeout(20) {
98 installVoltctl("${branch}")
99 script {
100 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
101 def localCharts = false
102 if (volthaHelmChartsChange != "") {
103 localCharts = true
104 }
105
106 // should the config file be suffixed with the workflow? see "deployment_config"
107 def localHelmFlags = "-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml --set global.log_level=${logLevel} "
108
109 if (workFlow.toLowerCase() == "dt") {
110 localHelmFlags += " --set radius.enabled=false "
111 }
112 if (workFlow.toLowerCase() == "tt") {
113 localHelmFlags += " --set radius.enabled=false --set global.incremental_evto_update=true "
114 if (enableMultiUni.toBoolean()) {
115 localHelmFlags += " --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=${uniPortMask} "
116 }
117 }
118
119 // NOTE temporary workaround expose ONOS node ports (pod-config needs to be updated to contain these values)
120 // and to connect the ofagent to all instances of ONOS
121 localHelmFlags = localHelmFlags + " --set onos-classic.onosSshPort=30115 " +
122 "--set onos-classic.onosApiPort=30120 " +
123 "--set onos-classic.onosOfPort=31653 " +
124 "--set onos-classic.individualOpenFlowNodePorts=true " +
125 "--set voltha.onos_classic.replicas=${params.NumOfOnos}"
126
127 if (bbsimReplicas.toInteger() != 0) {
128 localHelmFlags = localHelmFlags + " --set onu=${onuNumber},pon=${ponNumber} "
129 }
130
131 // adding user specified helm flags at the end so they'll have priority over everything else
132 localHelmFlags = localHelmFlags + " ${extraHelmFlags}"
133
134 def numberOfAdaptersToWait = 2
135
136 if(openoltAdapterChart != "onf/voltha-adapter-openolt") {
137 localHelmFlags = localHelmFlags + " --set voltha-adapter-openolt.enabled=false"
138 // We skip waiting for adapters in the volthaDeploy step because it's already waiting for
139 // both of them after the deployment of the custom olt adapter. See line 156.
140 numberOfAdaptersToWait = 0
141 }
142
143 volthaDeploy([
144 workflow: workFlow.toLowerCase(),
145 extraHelmFlags: localHelmFlags,
146 localCharts: localCharts,
147 kubeconfig: "$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf",
148 onosReplica: params.NumOfOnos,
149 atomixReplica: params.NumOfAtomix,
150 kafkaReplica: params.NumOfKafka,
151 etcdReplica: params.NumOfEtcd,
152 bbsimReplica: bbsimReplicas.toInteger(),
153 adaptersToWait: numberOfAdaptersToWait,
Hardik Windlass230fca62022-05-04 08:50:35 +0530154 withVolthaInfra: installVolthaInfra.toBoolean(),
155 withVolthaStack: installVolthaStack.toBoolean(),
Hardik Windlass36d5bdb2022-02-09 10:13:13 +0000156 ])
157
Hardik Windlass230fca62022-05-04 08:50:35 +0530158 if(installVolthaStack.toBoolean()) {
159 if(openoltAdapterChart != "onf/voltha-adapter-openolt"){
160 extraHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel}"
161 deploy_custom_chart(volthaNamespace, oltAdapterReleaseName, openoltAdapterChart, extraHelmFlags)
162 waitForAdapters([
163 adaptersToWait: 2
164 ])
165 }
Hardik Windlass36d5bdb2022-02-09 10:13:13 +0000166 }
167 }
168 sh """
169 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"&
170 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"&
171 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"&
172 ps aux | grep port-forward
173 """
174 getPodsInfo("$WORKSPACE")
175 }
176 }
177 }
178 stage('Deploy Device Manager Interface Chart') {
179 steps {
180 script {
181 deploy_custom_chart('default', 'olt-device-manager', dmiChart, extraHelmFlags)
182 }
183 println "Wait for olt-device-manager to start"
184 sh """
185 set +x
186 devmgr=\$(kubectl get pods -l app.kubernetes.io/name=${params.OltDevMgr} --no-headers | grep "0/" | wc -l)
187 while [[ \$devmgr != 0 ]]; do
188 sleep 5
189 devmgr=\$(kubectl get pods -l app.kubernetes.io/name=${params.OltDevMgr} --no-headers | grep "0/" | wc -l)
190 done
191 """
192 sh """
Hardik Windlassace19e52022-02-10 09:36:21 +0000193 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 +0000194 ps aux | grep port-forward
195 """
196 }
197 }
198 stage('Start logging') {
199 steps {
Hardik Windlass8a24b8f2022-02-10 14:06:36 +0000200 // check if kail is installed and if not installs it
201 sh """
202 if ! command -v kail &> /dev/null
203 then
204 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
205 fi
206 """
Hardik Windlass36d5bdb2022-02-09 10:13:13 +0000207 sh returnStdout: false, script: '''
208 # start logging with kail
209 cd $WORKSPACE
210 mkdir -p $LOG_FOLDER
211 list=($APPS_TO_LOG)
212 for app in "${list[@]}"
213 do
214 echo "Starting logs for: ${app}"
215 _TAG=kail-$app kail -l app.kubernetes.io/name=$app --since 1h > $LOG_FOLDER/$app.log&
216 done
217 '''
218 }
219 }
220 stage('Reinstall OLT software') {
221 steps {
222 script {
223 if ( params.reinstallOlt ) {
224 for(int i=0; i < deployment_config.olts.size(); i++) {
225 sh returnStdout: true, script: """
226 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
227 if [ "${params.inBandManagement}" == "true" ]; then
228 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'
229 fi
230 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}"
231 sleep 10
232 """
233 timeout(5) {
234 waitUntil {
235 olt_sw_present = sh returnStdout: true, script: """
236 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]]; then
237 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'
238 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"asgvolt64"* ]]; then
239 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'
240 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600x-w"* ]]; then
241 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'
242 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600g-w"* ]]; then
243 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'
244 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-3200g-w"* ]]; then
245 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'
246 else
247 echo Unknown Debian package for openolt
248 fi
249 if (${deployment_config.olts[i].fortygig}); then
250 if [[ "${params.inBandManagement}" == "true" ]]; then
251 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
252 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/'
253 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/'
254 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'
255 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/'
256 fi
257 fi
258 """
259 return olt_sw_present.toInteger() > 0
260 }
261 }
262 }
263 }
264 }
265 }
266 }
267 stage('Restart OLT processes') {
268 steps {
269 script {
270 if ( params.restartOlt ) {
271 //rebooting OLTs
272 for(int i=0; i < deployment_config.olts.size(); i++) {
273 timeout(15) {
274 sh returnStdout: true, script: """
275 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
276 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
277 """
278 }
279 }
280 sh returnStdout: true, script: """
281 sleep ${params.waitTimerForOltUp}
282 """
283 //Checking dev_management_deamon and openoltprocesses
284 for(int i=0; i < deployment_config.olts.size(); i++) {
285 if ( params.oltAdapterReleaseName != "open-olt" ) {
286 timeout(15) {
287 waitUntil {
288 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'"
289 return devprocess.toInteger() > 0
290 }
291 }
292 timeout(15) {
293 waitUntil {
294 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'"
295 return openoltprocess.toInteger() > 0
296 }
297 }
298 }
299 }
300 }
301 }
302 }
303 }
304 stage('Run Device Management Interface Tests') {
305 environment {
306 ROBOT_FILE="dmi-hw-management.robot"
307 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs"
308 ROBOT_CONFIG_FILE="$WORKSPACE/voltha-system-tests/tests/data/dmi-components-adtran.yaml"
309 }
310 steps {
311 sh """
312 mkdir -p $ROBOT_LOGS_DIR
313 export ROBOT_MISC_ARGS="--removekeywords wuks -e notreadyDMI -i functionalDMI -d $ROBOT_LOGS_DIR"
314 make -C $WORKSPACE/voltha-system-tests voltha-dmi-test || true
315 """
316 }
317 }
318 }
319
320 post {
321 always {
Hardik Windlassace19e52022-02-10 09:36:21 +0000322 getPodsInfo("$WORKSPACE")
Hardik Windlass36d5bdb2022-02-09 10:13:13 +0000323 sh '''
324 # stop the kail processes
325 list=($APPS_TO_LOG)
326 for app in "${list[@]}"
327 do
328 echo "Stopping logs for: ${app}"
329 _TAG="kail-$app"
330 P_IDS="$(ps e -ww -A | grep "_TAG=$_TAG" | grep -v grep | awk '{print $1}')"
331 if [ -n "$P_IDS" ]; then
332 echo $P_IDS
333 for P_ID in $P_IDS; do
334 kill -9 $P_ID
335 done
336 fi
337 done
338 '''
339 step([$class: 'RobotPublisher',
340 disableArchiveOutput: false,
341 logFileName: 'RobotLogs/log*.html',
342 otherFiles: '',
343 outputFileName: 'RobotLogs/output*.xml',
344 outputPath: '.',
345 passThreshold: 100,
346 reportFileName: 'RobotLogs/report*.html',
347 unstableThreshold: 0,
348 onlyCritical: true]);
349 archiveArtifacts artifacts: '**/*.txt,**/*.gz,*.gz,**/*.log'
350 }
351 }
352}