Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | node ("${TestNodeName}") { |
Andrea Campanella | 80dcae0 | 2020-01-28 11:23:26 +0100 | [diff] [blame] | 16 | def withKind = false |
| 17 | if (params.withKind != null){ |
| 18 | withKind = params.withKind |
| 19 | } |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 20 | timeout (100) { |
| 21 | try { |
| 22 | stage ("Parse deployment configuration file") { |
| 23 | sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir} voltha-system-tests kind-voltha" |
| 24 | sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/helm-repo-tools" |
| 25 | sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}" |
| 26 | sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/voltha-system-tests" |
| 27 | sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git" |
| 28 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 29 | } |
| 30 | stage('Clean up') { |
| 31 | timeout(10) { |
| 32 | sh returnStdout: true, script: """ |
| 33 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 34 | for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet'); |
| 35 | do |
| 36 | echo "Purging chart: \${hchart}" |
| 37 | helm delete --purge "\${hchart}" |
| 38 | done |
| 39 | """ |
| 40 | timeout(5) { |
| 41 | waitUntil { |
| 42 | helm_deleted = sh returnStdout: true, script: """ |
| 43 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 44 | helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l |
| 45 | """ |
| 46 | return helm_deleted.toInteger() == 0 |
| 47 | } |
| 48 | } |
| 49 | timeout(5) { |
| 50 | waitUntil { |
| 51 | kubectl_deleted = sh returnStdout: true, script: """ |
| 52 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 53 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
| 54 | """ |
| 55 | return kubectl_deleted.toInteger() == 0 |
| 56 | } |
| 57 | } |
Andrea Campanella | 80dcae0 | 2020-01-28 11:23:26 +0100 | [diff] [blame] | 58 | timeout(1) { |
| 59 | sh returnStdout: true, script: """ |
| 60 | port_fwd_pid=`ps -ax | grep "port-forward -n default service/onos-openflow" | grep -v "grep" | awk '{print \$1}'` |
| 61 | if [[ "" != "\$port_fwd_pid" ]]; then |
| 62 | kill -9 \$port_fwd_pid > /dev/null 2>&1 |
| 63 | fi |
| 64 | """ |
| 65 | } |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 66 | } |
| 67 | } |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 68 | stage('Install Voltha') { |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 69 | timeout(10) { |
| 70 | sh returnStdout: true, script: """ |
| 71 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 72 | cd kind-voltha/ |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 73 | if ( ${released} ); then |
| 74 | export EXTRA_HELM_FLAGS="--set defaults.image_tag=null,images.onos.tag=2.2.0" |
| 75 | else |
| 76 | export EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml' |
| 77 | fi |
| 78 | |
| 79 | # VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests |
| 80 | 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 |
| 81 | |
| 82 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c |
| 83 | kubectl get nodes -o wide |
| 84 | kubectl get pods -n voltha -o wide |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 85 | """ |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 86 | } |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 87 | } |
Andrea Campanella | 80dcae0 | 2020-01-28 11:23:26 +0100 | [diff] [blame] | 88 | if ( withKind && deployment_config.fabric_switches.size() > 0 ) { |
| 89 | stage('OpenFlow port forward for aggregation switch') { |
| 90 | timeout(1) { |
| 91 | sh returnStdout: true, script: """ |
| 92 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 93 | #This uses the default route out, porperly configured is the management |
| 94 | mgmt_address=`ip route get 1 | awk '{print \$NF;exit}'` |
Andrea Campanella | 12d1ff0 | 2020-02-03 16:52:30 +0100 | [diff] [blame] | 95 | bash -c "while true; do kubectl port-forward -n default service/onos-openflow --address=\$mgmt_address 6653:6653; done" >> /dev/null 2>&1 & |
Andrea Campanella | 80dcae0 | 2020-01-28 11:23:26 +0100 | [diff] [blame] | 96 | """ |
| 97 | } |
| 98 | } |
| 99 | } |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 100 | if ( params.configurePod && params.profile != "Default") { |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 101 | stage('Push Tech-Profile') { |
| 102 | timeout(1) { |
| 103 | out_push_tp = sh returnStatus: true, script: """ |
| 104 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 105 | etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}') |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 106 | kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json |
| 107 | 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 Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 108 | """ |
| 109 | return out_push_tp == 0 |
| 110 | } |
| 111 | timeout(1) { |
| 112 | out_get_tp = sh returnStatus: true, script: """ |
| 113 | etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}') |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 114 | 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 Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 115 | """ |
| 116 | return out_get_tp == 0 |
| 117 | } |
| 118 | } |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 119 | } |
| 120 | stage('Push Sadis-config') { |
| 121 | timeout(1) { |
| 122 | sadis_out = sh returnStatus: true, script: """ |
Suchitra Vemuri | ce73b7a | 2020-02-11 22:01:00 -0800 | [diff] [blame] | 123 | if [[ "${onosVersion}" == "1.13.10" || "${onosVersion}" == "2.2" ]]; then |
Suchitra Vemuri | c735bab | 2020-02-05 14:55:00 -0800 | [diff] [blame] | 124 | 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}-${onosVersion}-sadis.json |
| 125 | else |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 126 | 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 Vemuri | c735bab | 2020-02-05 14:55:00 -0800 | [diff] [blame] | 127 | fi |
| 128 | |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 129 | """ |
| 130 | return sadis_out == 0 |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 131 | } |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 132 | } |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 133 | if ( params.reinstallOlt ) { |
| 134 | stage('Reinstall OLT software') { |
| 135 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 136 | sh returnStdout: true, script: """ |
| 137 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}" |
| 138 | sleep 10 |
| 139 | """ |
| 140 | timeout(5) { |
| 141 | waitUntil { |
| 142 | olt_sw_present = sh returnStdout: true, script: """ |
| 143 | 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 Vemuri | f574b94 | 2020-01-27 16:39:58 -0800 | [diff] [blame] | 144 | if ( ${deployment_config.olts[i].fortygig} ); then |
| 145 | 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' |
| 146 | fi |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 147 | """ |
| 148 | return olt_sw_present.toInteger() == 1 |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | stage('Restart OLT processes') { |
| 154 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 155 | timeout(5) { |
| 156 | sh returnStdout: true, script: """ |
| 157 | ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts |
| 158 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'reboot' || true |
| 159 | sleep 120 |
| 160 | """ |
| 161 | } |
| 162 | timeout(15) { |
| 163 | waitUntil { |
| 164 | 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'" |
| 165 | return devprocess.toInteger() > 0 |
| 166 | } |
| 167 | } |
| 168 | timeout(15) { |
| 169 | waitUntil { |
| 170 | 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'" |
| 171 | return openoltprocess.toInteger() > 0 |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | } |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 177 | if ( deployment_config.fabric_switches.size() > 0 ) { |
| 178 | stage('Switch Configurations in ONOS') { |
| 179 | timeout(1) { |
| 180 | netcfg_out = sh returnStatus: true, script: """ |
| 181 | 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 |
| 182 | curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active |
Suchitra Vemuri | c735bab | 2020-02-05 14:55:00 -0800 | [diff] [blame] | 183 | |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 184 | """ |
| 185 | return netcfg_out == 0 |
| 186 | } |
| 187 | timeout(1) { |
| 188 | waitUntil { |
| 189 | sr_active_out = sh returnStatus: true, script: """ |
You Wang | eb76aeb | 2019-12-09 22:08:23 -0800 | [diff] [blame] | 190 | ssh-keygen -R [${deployment_config.nodes[0].ip}]:30115 |
Suchitra Vemuri | 6db64b2 | 2019-12-09 13:00:54 -0800 | [diff] [blame] | 191 | ssh-keyscan -p 30115 -H ${deployment_config.nodes[0].ip} >> ~/.ssh/known_hosts |
| 192 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.dhcpl2relay" |
| 193 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.aaa" |
| 194 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.olt" |
Suchitra Vemuri | ce73b7a | 2020-02-11 22:01:00 -0800 | [diff] [blame] | 195 | if [[ "${onosVersion}" == "1.13.10" || "${onosVersion}" == "2.2" ]]; then |
Suchitra Vemuri | c69817d | 2020-02-05 20:47:12 -0800 | [diff] [blame] | 196 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.opencord.olt.impl.OltFlowService enableDhcpOnProvisioning true" |
| 197 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.opencord.olt.impl.OltFlowService enableDhcpV4 true" |
| 198 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.opencord.olt.impl.OltFlowService enableEapol true" |
| 199 | fi |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 200 | curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE |
| 201 | """ |
| 202 | return sr_active_out == 0 |
| 203 | } |
| 204 | } |
| 205 | timeout(1) { |
| 206 | // FIXME support multiple OLTs |
| 207 | for(int i=0; i < deployment_config.hosts.src.size(); i++) { |
| 208 | xconnect_out = sh returnStatus: true, script: """ |
Suchitra Vemuri | c4d9293 | 2020-01-16 21:50:30 -0800 | [diff] [blame] | 209 | version=\$(sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "summary" | grep version) |
| 210 | if [[ \$version == *"version=2.2"* ]]; then |
| 211 | 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' |
| 212 | else |
| 213 | 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' |
| 214 | fi |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 215 | """ |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | currentBuild.result = 'SUCCESS' |
| 221 | } catch (err) { |
| 222 | currentBuild.result = 'FAILURE' |
| 223 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 224 | throw err |
| 225 | } |
| 226 | echo "RESULT: ${currentBuild.result}" |
| 227 | } |
| 228 | } |