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