blob: 21eb2d849b03c22c63aad1d7d82084dc626a7dcb [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") {
19 sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir}"
20 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools"
21 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
22 sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git"
23 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
24 }
25 stage('Clean up') {
26 timeout(10) {
27 sh returnStdout: true, script: """
28 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
29 cd kind-voltha/
30 DEPLOY_K8S=no ./voltha down
31 """
32 timeout(5) {
33 waitUntil {
34 helm_deleted = sh returnStdout: true, script: """
35 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
36 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
37 """
38 return helm_deleted.toInteger() == 0
39 }
40 }
41 timeout(5) {
42 waitUntil {
43 kubectl_deleted = sh returnStdout: true, script: """
44 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
45 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
46 """
47 return kubectl_deleted.toInteger() == 0
48 }
49 }
50 }
51 }
52 stage('Install Voltha') {
53 timeout(10) {
54 sh returnStdout: true, script: """
55 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
56 cd kind-voltha/
57 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
58 """
59 }
60 }
61
62 if ( params.reinstallOlt ) {
63 stage('Reinstall OLT software') {
64 for(int i=0; i < deployment_config.olts.size(); i++) {
65 sh returnStdout: true, script: """
66 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'
67 """
68 timeout(5) {
69 waitUntil {
70 olt_sw_present = 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 --list | grep asfvolt16 | wc -l'
72 """
73 return olt_sw_present.toInteger() == 0
74 }
75 }
76 sh returnStdout: true, script: """
77 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
78 """
79 timeout(5) {
80 waitUntil {
81 olt_sw_present = 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 --list | grep asfvolt16 | wc -l'
83 """
84 return olt_sw_present.toInteger() == 1
85 }
86 }
87 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
88 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
89 sh returnStdout: true, script: """
90 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'
91 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
92 """
93 }
94 }
95 }
96 stage('Restart OLT processes') {
97 for(int i=0; i < deployment_config.olts.size(); i++) {
98 timeout(5) {
99 sh returnStdout: true, script: """
100 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
101 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
102 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
103 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'
104 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
105 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
106 sleep 5
107 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
108 """
109 }
110 timeout(15) {
111 waitUntil {
112 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'"
113 return onu_discovered.toInteger() > 0
114 }
115 }
116 }
117 }
118 }
119 if ( params.configurePod ) {
120 stage('Configure ONOS Netcfg') {
121 timeout(1) {
122 waitUntil {
123 sh returnStdout: true, script: """
124 curl -w '\n%{http_code}' --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @voltha-system-tests/tests/data/${configFileName}-onos-netcfg.json
125 """
126 }
127 }
128 }
129 stage('Push Tech-Profile') {
130 timeout(1) {
131 waitUntil {
132 sh returnStdout: true, script: """
133 kubectl exec -it $(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk ‘NR==1{print $1}‘) -n voltha /bin/sh
134 cat voltha-system-tests/tests/data/${configFileName}-${techProfile}.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/xgspon/64
135 """
136 }
137 }
138 }
139 }
140 currentBuild.result = 'SUCCESS'
141 } catch (err) {
142 currentBuild.result = 'FAILURE'
143 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
144 throw err
145 }
146 echo "RESULT: ${currentBuild.result}"
147 }
148}
149