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}") { |
| 16 | timeout (100) { |
| 17 | try { |
| 18 | stage ("Parse deployment configuration file") { |
| 19 | sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir} voltha-system-tests kind-voltha" |
| 20 | 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" |
| 23 | sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git" |
| 24 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 25 | } |
| 26 | stage('Clean up') { |
| 27 | timeout(10) { |
| 28 | sh returnStdout: true, script: """ |
| 29 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 30 | for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet'); |
| 31 | do |
| 32 | echo "Purging chart: \${hchart}" |
| 33 | helm delete --purge "\${hchart}" |
| 34 | done |
| 35 | """ |
| 36 | timeout(5) { |
| 37 | waitUntil { |
| 38 | helm_deleted = sh returnStdout: true, script: """ |
| 39 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 40 | helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l |
| 41 | """ |
| 42 | return helm_deleted.toInteger() == 0 |
| 43 | } |
| 44 | } |
| 45 | timeout(5) { |
| 46 | waitUntil { |
| 47 | kubectl_deleted = sh returnStdout: true, script: """ |
| 48 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 49 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
| 50 | """ |
| 51 | return kubectl_deleted.toInteger() == 0 |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | } |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 56 | stage('Install Voltha') { |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 57 | timeout(10) { |
| 58 | sh returnStdout: true, script: """ |
| 59 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 60 | cd kind-voltha/ |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 61 | if ( ${released} ); then |
| 62 | export EXTRA_HELM_FLAGS="--set defaults.image_tag=null,images.onos.tag=2.2.0" |
| 63 | else |
| 64 | export EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml' |
| 65 | fi |
| 66 | |
| 67 | # VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests |
| 68 | 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 |
| 69 | |
| 70 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c |
| 71 | kubectl get nodes -o wide |
| 72 | kubectl get pods -n voltha -o wide |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 73 | """ |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 74 | } |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 75 | } |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 76 | if ( params.configurePod && params.profile != "Default") { |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 77 | stage('Push Tech-Profile') { |
| 78 | timeout(1) { |
| 79 | out_push_tp = sh returnStatus: true, script: """ |
| 80 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 81 | 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] | 82 | kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json |
| 83 | 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] | 84 | """ |
| 85 | return out_push_tp == 0 |
| 86 | } |
| 87 | timeout(1) { |
| 88 | out_get_tp = sh returnStatus: true, script: """ |
| 89 | 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] | 90 | 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] | 91 | """ |
| 92 | return out_get_tp == 0 |
| 93 | } |
| 94 | } |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 95 | } |
| 96 | stage('Push Sadis-config') { |
| 97 | timeout(1) { |
| 98 | sadis_out = sh returnStatus: true, script: """ |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 99 | 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 |
| 100 | """ |
| 101 | return sadis_out == 0 |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 102 | } |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 103 | } |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 104 | if ( params.reinstallOlt ) { |
| 105 | stage('Reinstall OLT software') { |
| 106 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 107 | sh returnStdout: true, script: """ |
| 108 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}" |
| 109 | sleep 10 |
| 110 | """ |
| 111 | timeout(5) { |
| 112 | waitUntil { |
| 113 | olt_sw_present = sh returnStdout: true, script: """ |
| 114 | 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' |
| 115 | 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' |
| 116 | """ |
| 117 | return olt_sw_present.toInteger() == 1 |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | stage('Restart OLT processes') { |
| 123 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 124 | timeout(5) { |
| 125 | sh returnStdout: true, script: """ |
| 126 | ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts |
| 127 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'reboot' || true |
| 128 | sleep 120 |
| 129 | """ |
| 130 | } |
| 131 | timeout(15) { |
| 132 | waitUntil { |
| 133 | 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'" |
| 134 | return devprocess.toInteger() > 0 |
| 135 | } |
| 136 | } |
| 137 | timeout(15) { |
| 138 | waitUntil { |
| 139 | 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'" |
| 140 | return openoltprocess.toInteger() > 0 |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | } |
Suchitra Vemuri | 4ac4463 | 2019-11-12 13:41:08 -0800 | [diff] [blame] | 146 | |
Suchitra Vemuri | a8e7bb2 | 2019-10-22 15:50:05 -0700 | [diff] [blame] | 147 | if ( deployment_config.fabric_switches.size() > 0 ) { |
| 148 | stage('Switch Configurations in ONOS') { |
| 149 | timeout(1) { |
| 150 | netcfg_out = sh returnStatus: true, script: """ |
| 151 | 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 |
| 152 | curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active |
| 153 | """ |
| 154 | return netcfg_out == 0 |
| 155 | } |
| 156 | timeout(1) { |
| 157 | waitUntil { |
| 158 | sr_active_out = sh returnStatus: true, script: """ |
You Wang | eb76aeb | 2019-12-09 22:08:23 -0800 | [diff] [blame^] | 159 | ssh-keygen -R [${deployment_config.nodes[0].ip}]:30115 |
Suchitra Vemuri | 6db64b2 | 2019-12-09 13:00:54 -0800 | [diff] [blame] | 160 | ssh-keyscan -p 30115 -H ${deployment_config.nodes[0].ip} >> ~/.ssh/known_hosts |
| 161 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.dhcpl2relay" |
| 162 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.aaa" |
| 163 | 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] | 164 | curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE |
| 165 | """ |
| 166 | return sr_active_out == 0 |
| 167 | } |
| 168 | } |
| 169 | timeout(1) { |
| 170 | // FIXME support multiple OLTs |
| 171 | for(int i=0; i < deployment_config.hosts.src.size(); i++) { |
| 172 | xconnect_out = sh returnStatus: true, script: """ |
| 173 | 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' |
| 174 | """ |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | } |
| 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 | } |