blob: 19baa14171b26ee9bf72ee908e89e1140169c52b [file] [log] [blame]
Kailash6f5acb62019-08-28 14:38:45 -07001// Copyright 2017-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
15node ("${TestNodeName}") {
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070016 def withKind = false
17 if (params.withKind != null){
18 withKind = params.withKind
19 }
Kailash6f5acb62019-08-28 14:38:45 -070020 timeout (100) {
21 try {
22 stage ("Parse deployment configuration file") {
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070023 sh returnStdout: true, script: "rm -rf ${configBaseDir} voltha-system-tests kind-voltha"
Suchitra Vemurie514b8c2019-09-23 19:37:18 -070024 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070025 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/voltha-system-tests"
Suchitra Vemuria9562212020-04-10 19:32:03 -070026 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/kind-voltha"
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070027 if ( params.workFlow == "DT" ) {
28 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
29 }
30 else
31 {
32 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
33 }
Kailash6f5acb62019-08-28 14:38:45 -070034 }
35 stage('Clean up') {
Suchitra Vemuri76261d02020-05-08 16:33:32 -070036 timeout(15) {
Kailash6f5acb62019-08-28 14:38:45 -070037 sh returnStdout: true, script: """
38 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070039 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
40 do
41 echo "Purging chart: \${hchart}"
42 helm delete --purge "\${hchart}"
43 done
Kailash6f5acb62019-08-28 14:38:45 -070044 """
45 timeout(5) {
46 waitUntil {
47 helm_deleted = sh returnStdout: true, script: """
48 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
49 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
50 """
51 return helm_deleted.toInteger() == 0
52 }
53 }
54 timeout(5) {
55 waitUntil {
56 kubectl_deleted = sh returnStdout: true, script: """
57 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
58 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
59 """
60 return kubectl_deleted.toInteger() == 0
61 }
62 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070063 timeout(1) {
Hung-Wei Chiu2fa15622020-04-07 16:40:35 -070064 sh returnStdout: false, script: """
65 #Remove all while true; do kubectl port-forward ...done; rules
66 for port_fwd_id in `ps -ax | grep "port-forward" | grep -E "onos|voltha" | grep "while true"| awk '{print \$1}'`;
67 do
68 cat /proc/\$port_fwd_id/cmdline
69 kill -9 \$port_fwd_id
70 done
71
72 #Remove all kubectl port-forward rules
73 for port_fwd_id in `ps -ax | grep "port-forward" | grep -E "onos|voltha" | awk '{print \$1}'`;
74 do
75 cat /proc/\$port_fwd_id/cmdline
76 kill -9 \$port_fwd_id
77 done
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070078 """
79 }
Kailash6f5acb62019-08-28 14:38:45 -070080 }
81 }
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080082 stage('Install Voltha') {
Suchitra Vemuri76261d02020-05-08 16:33:32 -070083 timeout(20) {
Kailash6f5acb62019-08-28 14:38:45 -070084 sh returnStdout: true, script: """
85 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
86 cd kind-voltha/
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070087 if [ "${branch}" != "master" ]; then
88 cd $WORKSPACE/kind-voltha
89 source releases/${branch}
Suchitra Vemurib9483862019-11-05 21:37:29 -080090 else
Andy Bavier7cee6f42019-11-05 16:49:47 -070091 export EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml'
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080092 fi
Andy Bavier7cee6f42019-11-05 16:49:47 -070093
94 # VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
hwchiu0a39d512020-04-04 05:00:29 +000095 # JENKINS_NODE_COOKIE=dontKillMe ask Jenkins doesn't kill the proces after this job. we want the `while true; do kubectl port-forward` keep alive
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070096 if [[ "${workFlow}" == "DT" ]]; then
Suchitra Vemuri3f7fb402020-05-06 17:02:39 -070097 JENKINS_NODE_COOKIE=dontKillMe NUM_OF_OPENONU=${NumOfOpenOnu} NUM_OF_ONOS=${NumOfOnos} NUM_OF_ATOMIX=${NumOfAtomix} ONOS_SSH_PORT=30115 ONOS_API_PORT=30120 VOLTHA_LOG_LEVEL=DEBUG WITH_SIM_ADAPTERS=n WITH_TP=yes DEPLOY_K8S=no INSTALL_KUBECTL=no INSTALL_HELM=no WITH_EAPOL=no WITH_DHCP=no WITH_IGMP=no WITH_RADIUS=no FANCY=0 ./voltha up
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070098 else
Suchitra Vemuri3f7fb402020-05-06 17:02:39 -070099 JENKINS_NODE_COOKIE=dontKillMe NUM_OF_OPENONU=${NumOfOpenOnu} NUM_OF_ONOS=${NumOfOnos} NUM_OF_ATOMIX=${NumOfAtomix} ONOS_SSH_PORT=30115 ONOS_API_PORT=30120 VOLTHA_LOG_LEVEL=DEBUG WITH_SIM_ADAPTERS=n WITH_RADIUS=y WITH_TP=yes DEPLOY_K8S=no INSTALL_KUBECTL=no INSTALL_HELM=no FANCY=0 ./voltha up
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700100 fi
Andy Bavier7cee6f42019-11-05 16:49:47 -0700101
Matteo Scandolo727c7972020-04-13 13:09:25 -0700102 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.image}{'\\n'}" | sort | uniq
103 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800104 kubectl get nodes -o wide
105 kubectl get pods -n voltha -o wide
Kailash6f5acb62019-08-28 14:38:45 -0700106 """
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800107 }
Kailash6f5acb62019-08-28 14:38:45 -0700108 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700109 if ( withKind && deployment_config.fabric_switches.size() > 0 ) {
110 stage('OpenFlow port forward for aggregation switch') {
111 timeout(1) {
112 sh returnStdout: true, script: """
113 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
114 #This uses the default route out, porperly configured is the management
115 mgmt_address=`ip route get 1 | awk '{print \$NF;exit}'`
Andrea Campanellac5f7db72020-05-08 10:58:11 +0200116 JENKINS_NODE_COOKIE=dontkill kubectl port-forward -n default service/onos-onos-classic-hs --address=\$mgmt_address 6653:6653 >> /dev/null 2>&1 &
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700117 """
118 }
119 }
120 }
121 if ( params.configurePod && params.profile != "Default" ) {
Suchitra Vemuri72680092019-10-03 12:39:20 -0700122 stage('Push Tech-Profile') {
Andrea Campanellabea02762020-04-23 10:59:08 +0200123 for(int i=0; i < deployment_config.olts.size(); i++) {
124 def tech_prof_directory = "XGS-PON"
125 if (deployment_config.olts[i].oltDebVersion.contains("asgvolt64")){
126 tech_prof_directory = "GPON"
127 }
128 timeout(1) {
129 out_push_tp = sh returnStatus: true, script: """
130 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
131 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
132 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json
133 put_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64')
134 """
135 return out_push_tp == 0
136 }
137 timeout(1) {
138 out_get_tp = sh returnStatus: true, script: """
Andrea Campanella85b0a8d2020-05-14 12:56:47 +0200139 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanellabea02762020-04-23 10:59:08 +0200140 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
141 get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64')
142 """
143 return out_get_tp == 0
144 }
Suchitra Vemuri72680092019-10-03 12:39:20 -0700145 }
hwchiuc77c7d22019-10-18 13:58:35 -0700146 }
147 }
148 stage('Push Sadis-config') {
149 timeout(1) {
150 sadis_out = sh returnStatus: true, script: """
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700151 if [[ "${workFlow}" == "DT" ]]; then
152 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis-DT.json
153 else
Suchitra Vemuri72680092019-10-03 12:39:20 -0700154 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis.json
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700155 fi
156 """
157 return sadis_out == 0
You Wangb9526e62019-10-07 15:25:48 -0700158 }
hwchiuc77c7d22019-10-18 13:58:35 -0700159 }
Kailash6f5acb62019-08-28 14:38:45 -0700160 if ( params.reinstallOlt ) {
161 stage('Reinstall OLT software') {
162 for(int i=0; i < deployment_config.olts.size(); i++) {
163 sh returnStdout: true, script: """
Suchitra Vemuri66174b02020-05-14 16:44:28 -0700164 if [ "${branch}" != "master" ]; then
165 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${deployment_config.olts[i].oltDebVersion23}"
166 else
167 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${deployment_config.olts[i].oltDebVersion}"
168 fi
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700169 sleep 10
Kailash6f5acb62019-08-28 14:38:45 -0700170 """
171 timeout(5) {
172 waitUntil {
173 olt_sw_present = sh returnStdout: true, script: """
Suchitra Vemuri66174b02020-05-14 16:44:28 -0700174 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16-2.4"* ]] || [[ "${deployment_config.olts[i].oltDebVersion23}" == *"asfvolt16-2.4"* ]]; then
Andrea Campanellace9e9902020-04-07 18:29:42 +0200175 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asfvolt16 | wc -l'
176 else
177 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asgvolt64 | wc -l'
178 fi
Suchitra Vemuri66174b02020-05-14 16:44:28 -0700179 if (${deployment_config.olts[i].fortygig}); then
180 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16-2.4"* ]] || [[ "${deployment_config.olts[i].oltDebVersion23}" == *"asfvolt16-2.4"* ]]; then
181 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'echo "port ce128 sp=40000 if=XLAUI" >> /broadcom/qax.soc'
182 else
183 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'echo "port ce128 sp=40000" >> /broadcom/qax.soc'
184 fi
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700185 fi
Kailash6f5acb62019-08-28 14:38:45 -0700186 """
Andrea Campanellace9e9902020-04-07 18:29:42 +0200187 return olt_sw_present.toInteger() > 0
Kailash6f5acb62019-08-28 14:38:45 -0700188 }
189 }
Kailash6f5acb62019-08-28 14:38:45 -0700190 }
191 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700192 stage('Restart OLT processes') {
Kailash6f5acb62019-08-28 14:38:45 -0700193 for(int i=0; i < deployment_config.olts.size(); i++) {
194 timeout(5) {
195 sh returnStdout: true, script: """
196 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700197 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'reboot' || true
198 sleep 120
Kailash6f5acb62019-08-28 14:38:45 -0700199 """
200 }
201 timeout(15) {
202 waitUntil {
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700203 devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
204 return devprocess.toInteger() > 0
205 }
206 }
207 timeout(15) {
208 waitUntil {
209 openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'ps -ef | grep openolt | wc -l'"
210 return openoltprocess.toInteger() > 0
Kailash6f5acb62019-08-28 14:38:45 -0700211 }
212 }
213 }
214 }
215 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700216 if ( deployment_config.fabric_switches.size() > 0 ) {
You Wang25e58612019-10-01 16:30:28 -0700217 stage('Switch Configurations in ONOS') {
218 timeout(1) {
219 netcfg_out = sh returnStatus: true, script: """
220 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json
221 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700222
You Wang25e58612019-10-01 16:30:28 -0700223 """
224 return netcfg_out == 0
225 }
226 timeout(1) {
227 waitUntil {
228 sr_active_out = sh returnStatus: true, script: """
You Wangeb76aeb2019-12-09 22:08:23 -0800229 ssh-keygen -R [${deployment_config.nodes[0].ip}]:30115
Suchitra Vemuric3257262019-12-05 19:06:42 -0800230 ssh-keyscan -p 30115 -H ${deployment_config.nodes[0].ip} >> ~/.ssh/known_hosts
231 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.dhcpl2relay"
232 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.aaa"
233 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.olt"
You Wang25e58612019-10-01 16:30:28 -0700234 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700235 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.onosproject.net.flow.impl.FlowRuleManager purgeOnDisconnection false"
Andrea Campanella086bcbb2020-04-01 09:56:23 +0200236 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.onosproject.net.meter.impl.MeterManager purgeOnDisconnection false"
You Wang25e58612019-10-01 16:30:28 -0700237 """
238 return sr_active_out == 0
239 }
240 }
Andrea Campanellabea02762020-04-23 10:59:08 +0200241 timeout(5) {
You Wang25e58612019-10-01 16:30:28 -0700242 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
Andrea Campanellabea02762020-04-23 10:59:08 +0200243 def aggPort = -1
244 for(int j=0; j < deployment_config.olts.size(); j++) {
245 if(deployment_config.olts[j].serial == deployment_config.hosts.src[j].olt){
246 aggPort = deployment_config.olts[j].aggPort
247 }
248 }
249 if(aggPort == -1){
250 throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
251 }
You Wang25e58612019-10-01 16:30:28 -0700252 xconnect_out = sh returnStatus: true, script: """
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800253 version=\$(sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "summary" | grep version)
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700254 sleep 10
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800255 if [[ \$version == *"version=2.2"* ]]; then
Andrea Campanellabea02762020-04-23 10:59:08 +0200256 curl -X POST --user karaf:karaf --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"deviceId": "${deployment_config.fabric_switches[0].device_id}", "vlanId": "${deployment_config.hosts.src[i].s_tag}", "endpoints": [${deployment_config.fabric_switches[0].bngPort},${aggPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800257 else
Andrea Campanellabea02762020-04-23 10:59:08 +0200258 curl -X POST --user karaf:karaf --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"deviceId": "${deployment_config.fabric_switches[0].device_id}", "vlanId": "${deployment_config.hosts.src[i].s_tag}", "ports": [${deployment_config.fabric_switches[0].bngPort},${aggPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800259 fi
You Wang25e58612019-10-01 16:30:28 -0700260 """
261 }
262 }
Kailash6f5acb62019-08-28 14:38:45 -0700263 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700264 }
Kailash6f5acb62019-08-28 14:38:45 -0700265 currentBuild.result = 'SUCCESS'
266 } catch (err) {
267 currentBuild.result = 'FAILURE'
268 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
269 throw err
270 }
271 echo "RESULT: ${currentBuild.result}"
272 }
273}