blob: b693e9a732d3f6f5d94053ffc4651874ad5e94c7 [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 Vemuri0c40ebe2020-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 Vemuri0c40ebe2020-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 Vemuri0c40ebe2020-03-27 15:09:36 -070025 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/voltha-system-tests"
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070026 sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git"
Suchitra Vemuri0c40ebe2020-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') {
You Wang25e58612019-10-01 16:30:28 -070036 timeout(10) {
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 Vemuri0c40ebe2020-03-27 15:09:36 -070063 timeout(1) {
64 sh returnStdout: true, script: """
65 port_fwd_pid=`ps -ax | grep "port-forward -n default service/onos-openflow" | grep -v "grep" | awk '{print \$1}'`
66 if [[ "" != "\$port_fwd_pid" ]]; then
67 kill -9 \$port_fwd_pid > /dev/null 2>&1
68 fi
69 """
70 }
Kailash6f5acb62019-08-28 14:38:45 -070071 }
72 }
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080073 stage('Install Voltha') {
Kailash6f5acb62019-08-28 14:38:45 -070074 timeout(10) {
75 sh returnStdout: true, script: """
76 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
77 cd kind-voltha/
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -070078 if [ "${branch}" != "master" ]; then
79 cd $WORKSPACE/kind-voltha
80 source releases/${branch}
Suchitra Vemurib9483862019-11-05 21:37:29 -080081 else
Andy Bavier7cee6f42019-11-05 16:49:47 -070082 export EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml'
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080083 fi
Andy Bavier7cee6f42019-11-05 16:49:47 -070084
85 # VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -070086 if [[ "${workFlow}" == "DT" ]]; then
87 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
88 else
89 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
90 fi
Andy Bavier7cee6f42019-11-05 16:49:47 -070091
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080092 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
93 kubectl get nodes -o wide
94 kubectl get pods -n voltha -o wide
Kailash6f5acb62019-08-28 14:38:45 -070095 """
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080096 }
Kailash6f5acb62019-08-28 14:38:45 -070097 }
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -070098 if ( withKind && deployment_config.fabric_switches.size() > 0 ) {
99 stage('OpenFlow port forward for aggregation switch') {
100 timeout(1) {
101 sh returnStdout: true, script: """
102 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
103 #This uses the default route out, porperly configured is the management
104 mgmt_address=`ip route get 1 | awk '{print \$NF;exit}'`
105 JENKINS_NODE_COOKIE=dontkill kubectl port-forward -n default service/onos-openflow --address=\$mgmt_address 6653:6653 >> /dev/null 2>&1 &
106 """
107 }
108 }
109 }
110 if ( params.configurePod && params.profile != "Default" ) {
Suchitra Vemuri72680092019-10-03 12:39:20 -0700111 stage('Push Tech-Profile') {
112 timeout(1) {
113 out_push_tp = sh returnStatus: true, script: """
114 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
115 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
hwchiuc77c7d22019-10-18 13:58:35 -0700116 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -0700117 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/XGS-PON/64')
Suchitra Vemuri72680092019-10-03 12:39:20 -0700118 """
119 return out_push_tp == 0
120 }
121 timeout(1) {
122 out_get_tp = sh returnStatus: true, script: """
123 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -0700124 get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64')
Suchitra Vemuri72680092019-10-03 12:39:20 -0700125 """
126 return out_get_tp == 0
127 }
hwchiuc77c7d22019-10-18 13:58:35 -0700128 }
129 }
130 stage('Push Sadis-config') {
131 timeout(1) {
132 sadis_out = sh returnStatus: true, script: """
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -0700133 if [[ "${workFlow}" == "DT" ]]; then
134 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
135 else
Suchitra Vemuri72680092019-10-03 12:39:20 -0700136 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 Vemuri0c40ebe2020-03-27 15:09:36 -0700137 fi
138 """
139 return sadis_out == 0
You Wangb9526e62019-10-07 15:25:48 -0700140 }
hwchiuc77c7d22019-10-18 13:58:35 -0700141 }
Kailash6f5acb62019-08-28 14:38:45 -0700142 if ( params.reinstallOlt ) {
143 stage('Reinstall OLT software') {
144 for(int i=0; i < deployment_config.olts.size(); i++) {
145 sh returnStdout: true, script: """
Kailash6f5acb62019-08-28 14:38:45 -0700146 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -0700147 sleep 10
Kailash6f5acb62019-08-28 14:38:45 -0700148 """
149 timeout(5) {
150 waitUntil {
151 olt_sw_present = sh returnStdout: true, script: """
152 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'
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -0700153 if ( ${deployment_config.olts[i].fortygig} ); then
154 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'
155 fi
Kailash6f5acb62019-08-28 14:38:45 -0700156 """
157 return olt_sw_present.toInteger() == 1
158 }
159 }
Kailash6f5acb62019-08-28 14:38:45 -0700160 }
161 }
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -0700162 stage('Restart OLT processes') {
Kailash6f5acb62019-08-28 14:38:45 -0700163 for(int i=0; i < deployment_config.olts.size(); i++) {
164 timeout(5) {
165 sh returnStdout: true, script: """
166 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -0700167 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'reboot' || true
168 sleep 120
Kailash6f5acb62019-08-28 14:38:45 -0700169 """
170 }
171 timeout(15) {
172 waitUntil {
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -0700173 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'"
174 return devprocess.toInteger() > 0
175 }
176 }
177 timeout(15) {
178 waitUntil {
179 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'"
180 return openoltprocess.toInteger() > 0
Kailash6f5acb62019-08-28 14:38:45 -0700181 }
182 }
183 }
184 }
185 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700186 if ( deployment_config.fabric_switches.size() > 0 ) {
You Wang25e58612019-10-01 16:30:28 -0700187 stage('Switch Configurations in ONOS') {
188 timeout(1) {
189 netcfg_out = sh returnStatus: true, script: """
190 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
191 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -0700192
You Wang25e58612019-10-01 16:30:28 -0700193 """
194 return netcfg_out == 0
195 }
196 timeout(1) {
197 waitUntil {
198 sr_active_out = sh returnStatus: true, script: """
You Wangeb76aeb2019-12-09 22:08:23 -0800199 ssh-keygen -R [${deployment_config.nodes[0].ip}]:30115
Suchitra Vemuric3257262019-12-05 19:06:42 -0800200 ssh-keyscan -p 30115 -H ${deployment_config.nodes[0].ip} >> ~/.ssh/known_hosts
201 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.dhcpl2relay"
202 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.aaa"
203 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 -0700204 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 Vemuri0c40ebe2020-03-27 15:09:36 -0700205 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.onosproject.net.flow.impl.FlowRuleManager purgeOnDisconnection false"
You Wang25e58612019-10-01 16:30:28 -0700206 """
207 return sr_active_out == 0
208 }
209 }
210 timeout(1) {
211 // FIXME support multiple OLTs
212 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
213 xconnect_out = sh returnStatus: true, script: """
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800214 version=\$(sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "summary" | grep version)
Suchitra Vemuri0c40ebe2020-03-27 15:09:36 -0700215 sleep 10
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800216 if [[ \$version == *"version=2.2"* ]]; then
217 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},${deployment_config.fabric_switches[0].oltPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
218 else
219 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},${deployment_config.fabric_switches[0].oltPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
220 fi
You Wang25e58612019-10-01 16:30:28 -0700221 """
222 }
223 }
Kailash6f5acb62019-08-28 14:38:45 -0700224 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700225 }
Kailash6f5acb62019-08-28 14:38:45 -0700226 currentBuild.result = 'SUCCESS'
227 } catch (err) {
228 currentBuild.result = 'FAILURE'
229 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
230 throw err
231 }
232 echo "RESULT: ${currentBuild.result}"
233 }
234}