blob: d0c5d51dbae4d8127a09d40d544c2dcbfdd2977e [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') {
Matteo Scandolo1294aeb2019-09-24 16:20:32 -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/
62 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 ONOS_TAG=voltha-2.1 ./voltha up
63 """
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 ) {
Suchitra Vemuri44a9b672019-09-25 23:13:00 -0700125 stage('Switch Configurations in ONOS') {
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700126 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
Kailash6f5acb62019-08-28 14:38:45 -0700132 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700133 timeout(1) {
134 // FIXME iterate over the hosts section to create multiple xconnect if needed
135 // FIXME read the device id from deployment_config.fabric_switches
136 xconnect_out = sh returnStatus: true, script: """
137 curl -X POST --user karaf:karaf --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"deviceId": "of:0000000000000001", "vlanId": "111", "ports": [3,10]}' 'http://10.192.20.45:30120/onos/segmentrouting/xconnect'
138 """
139 return xconnect_out == 0
140 }
141 }
142 }
143 if ( params.configurePod ) {
You Wang5f8ab4a2019-09-13 16:27:24 -0700144 stage('Push Tech-Profile') {
Kailash6f5acb62019-08-28 14:38:45 -0700145 timeout(1) {
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700146 out_push_tp = sh returnStatus: true, script: """
You Wang5f8ab4a2019-09-13 16:27:24 -0700147 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
148 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
Suchitra Vemurif2e0a4a2019-09-26 09:30:57 -0700149 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 -0700150 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 -0700151 """
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700152 return out_push_tp == 0
Kailash6f5acb62019-08-28 14:38:45 -0700153 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700154 timeout(1) {
155 out_get_tp = sh returnStatus: true, script: """
156 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
157 get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/xgspon/64')
158 """
159 return out_get_tp == 0
160 }
161 }
162 stage('Push Sadis-config') {
163 timeout(1) {
164 sadis_out = sh returnStatus: true, script: """
165 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
166 """
167 return sadis_out == 0
168 }
You Wang5f8ab4a2019-09-13 16:27:24 -0700169 }
Kailash6f5acb62019-08-28 14:38:45 -0700170 }
171 currentBuild.result = 'SUCCESS'
172 } catch (err) {
173 currentBuild.result = 'FAILURE'
174 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
175 throw err
176 }
177 echo "RESULT: ${currentBuild.result}"
178 }
179}