blob: 5d5db04c03ce1aaf16f56a16cea7c4017884d62b [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}") {
16 timeout (100) {
17 try {
18 stage ("Parse deployment configuration file") {
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070019 sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir} voltha-system-tests kind-voltha"
Suchitra Vemurie514b8c2019-09-23 19:37:18 -070020 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/helm-repo-tools"
21 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
22 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/voltha-system-tests"
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070023 sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git"
Suchitra Vemuria1f7c592019-09-28 19:21:50 -070024 sh returnStdout: true, script: "cp /home/cord/onos-dhcpl2relay-withFalse.json $WORKSPACE/kind-voltha/onos-files/onos-dhcpl2relay.json"
Kailash6f5acb62019-08-28 14:38:45 -070025 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
26 }
27 stage('Clean up') {
You Wang25e58612019-10-01 16:30:28 -070028 timeout(10) {
Kailash6f5acb62019-08-28 14:38:45 -070029 sh returnStdout: true, script: """
30 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070031 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
32 do
33 echo "Purging chart: \${hchart}"
34 helm delete --purge "\${hchart}"
35 done
Kailash6f5acb62019-08-28 14:38:45 -070036 """
37 timeout(5) {
38 waitUntil {
39 helm_deleted = sh returnStdout: true, script: """
40 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
41 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
42 """
43 return helm_deleted.toInteger() == 0
44 }
45 }
46 timeout(5) {
47 waitUntil {
48 kubectl_deleted = sh returnStdout: true, script: """
49 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
50 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
51 """
52 return kubectl_deleted.toInteger() == 0
53 }
54 }
55 }
56 }
57 stage('Install Voltha') {
58 timeout(10) {
59 sh returnStdout: true, script: """
60 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
61 cd kind-voltha/
Suchitra Vemuri9c24d2b2019-09-30 10:28:25 -070062 EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml' WITH_RADIUS=y WITH_TP=yes DEPLOY_K8S=no INSTALL_KUBECTL=no INSTALL_HELM=no FANCY=0 ONOS_TAG=voltha-2.1 ./voltha up
Kailash6f5acb62019-08-28 14:38:45 -070063 """
64 }
65 }
66
67 if ( params.reinstallOlt ) {
68 stage('Reinstall OLT software') {
69 for(int i=0; i < deployment_config.olts.size(); i++) {
70 sh returnStdout: true, script: """
71 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --remove asfvolt16 && dpkg --purge asfvolt16'
72 """
73 timeout(5) {
74 waitUntil {
75 olt_sw_present = sh returnStdout: true, script: """
76 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'
77 """
78 return olt_sw_present.toInteger() == 0
79 }
80 }
81 sh returnStdout: true, script: """
82 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
83 """
84 timeout(5) {
85 waitUntil {
86 olt_sw_present = sh returnStdout: true, script: """
87 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'
88 """
89 return olt_sw_present.toInteger() == 1
90 }
91 }
92 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
93 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
94 sh returnStdout: true, script: """
95 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'
96 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
97 """
98 }
99 }
100 }
101 stage('Restart OLT processes') {
102 for(int i=0; i < deployment_config.olts.size(); i++) {
103 timeout(5) {
104 sh returnStdout: true, script: """
105 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
106 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist stop' || true
107 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
108 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/bal_core_dist.log'
109 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
110 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
111 sleep 5
112 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
113 """
114 }
115 timeout(15) {
116 waitUntil {
117 onu_discovered = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'cat /var/log/openolt.log | grep \"oper_state: up\" | wc -l'"
118 return onu_discovered.toInteger() > 0
119 }
120 }
121 }
122 }
123 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700124 if ( deployment_config.fabric_switches.size() > 0 ) {
You Wang25e58612019-10-01 16:30:28 -0700125 stage('Switch Configurations in ONOS') {
126 timeout(1) {
127 netcfg_out = sh returnStatus: true, script: """
128 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
129 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
130 """
131 return netcfg_out == 0
132 }
133 timeout(1) {
134 waitUntil {
135 sr_active_out = sh returnStatus: true, script: """
136 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
137 """
138 return sr_active_out == 0
139 }
140 }
141 timeout(1) {
142 // FIXME support multiple OLTs
143 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
144 xconnect_out = sh returnStatus: true, script: """
145 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'
146 """
147 }
148 }
Kailash6f5acb62019-08-28 14:38:45 -0700149 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700150 }
151 if ( params.configurePod ) {
You Wang5f8ab4a2019-09-13 16:27:24 -0700152 stage('Push Tech-Profile') {
Kailash6f5acb62019-08-28 14:38:45 -0700153 timeout(1) {
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700154 out_push_tp = sh returnStatus: true, script: """
You Wang5f8ab4a2019-09-13 16:27:24 -0700155 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
156 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
Suchitra Vemurif2e0a4a2019-09-26 09:30:57 -0700157 kubectl cp /home/cord/voltha-system-tests/tests/data/${configFileName}-multipleGem.json voltha/\$etcd_container:/tmp/flexpod.json
You Wang5f8ab4a2019-09-13 16:27:24 -0700158 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/xgspon/64')
You Wang5f8ab4a2019-09-13 16:27:24 -0700159 """
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700160 return out_push_tp == 0
Kailash6f5acb62019-08-28 14:38:45 -0700161 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700162 timeout(1) {
You Wang25e58612019-10-01 16:30:28 -0700163 out_get_tp = sh returnStatus: true, script: """
164 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
165 get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/xgspon/64')
166 """
167 return out_get_tp == 0
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700168 }
169 }
170 stage('Push Sadis-config') {
You Wang25e58612019-10-01 16:30:28 -0700171 timeout(1) {
172 sadis_out = sh returnStatus: true, script: """
173 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
174 """
175 return sadis_out == 0
176 }
You Wang5f8ab4a2019-09-13 16:27:24 -0700177 }
Kailash6f5acb62019-08-28 14:38:45 -0700178 }
179 currentBuild.result = 'SUCCESS'
180 } catch (err) {
181 currentBuild.result = 'FAILURE'
182 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
183 throw err
184 }
185 echo "RESULT: ${currentBuild.result}"
186 }
187}