Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -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 | |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 15 | node ("${TestNodeName}") { |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 16 | timeout (100) { |
| 17 | try { |
| 18 | stage ("Parse deployment configuration file") { |
| 19 | sh returnStdout: true, script: "rm -rf ${configBaseDir}" |
| 20 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
| 21 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yml" |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 22 | } |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 23 | stage('Clean up') { |
| 24 | timeout(10) { |
| 25 | sh returnStdout: true, script: """ |
| 26 | rm -rf helm-charts cord-tester |
| 27 | git clone -b ${branch} ${cordRepoUrl}/helm-charts |
| 28 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Luca Prete | 5a97015 | 2018-08-29 15:20:47 -0700 | [diff] [blame] | 29 | for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet'); |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 30 | do |
| 31 | echo "Purging chart: \${hchart}" |
| 32 | helm delete --purge "\${hchart}" |
| 33 | done |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 34 | """ |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 35 | timeout(5) { |
| 36 | waitUntil { |
| 37 | helm_deleted = sh returnStdout: true, script: """ |
| 38 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
Luca Prete | b496667 | 2018-08-29 16:49:48 -0700 | [diff] [blame] | 39 | helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 40 | """ |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 41 | return helm_deleted.toInteger() == 0 |
| 42 | } |
| 43 | } |
| 44 | timeout(5) { |
| 45 | waitUntil { |
| 46 | kubectl_deleted = sh returnStdout: true, script: """ |
| 47 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
Luca Prete | b496667 | 2018-08-29 16:49:48 -0700 | [diff] [blame] | 48 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 49 | """ |
| 50 | return kubectl_deleted.toInteger() == 0 |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 55 | dir ("helm-charts") { |
Luca Prete | 08be18b | 2018-08-29 14:10:06 -0700 | [diff] [blame] | 56 | stage('Install Voltha Kafka') { |
| 57 | timeout(10) { |
| 58 | sh returnStdout: true, script: """ |
| 59 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 60 | helm install --name voltha-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.replicaCount=1 --set zookeeper.persistence.enabled=false incubator/kafka |
| 61 | """ |
| 62 | } |
| 63 | timeout(10) { |
| 64 | waitUntil { |
| 65 | kafka_instances_running = sh returnStdout: true, script: """ |
| 66 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 67 | kubectl get pods | grep voltha-kafka | grep -i running | grep 1/1 | wc -l |
| 68 | """ |
| 69 | return kafka_instances_running.toInteger() == 2 |
| 70 | } |
| 71 | } |
| 72 | } |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 73 | stage('Install voltha') { |
| 74 | timeout(10) { |
| 75 | sh returnStdout: true, script: """ |
| 76 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 77 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 78 | helm dep build voltha |
| 79 | helm install -n voltha -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set etcd-operator.customResources.createEtcdClusterCRD=false voltha |
Matteo Scandolo | a6e1f9d | 2018-08-29 17:23:19 -0700 | [diff] [blame^] | 80 | helm upgrade -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 81 | """ |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 82 | } |
| 83 | timeout(10) { |
| 84 | waitUntil { |
| 85 | voltha_completed = sh returnStdout: true, script: """ |
| 86 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 87 | kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l |
| 88 | """ |
| 89 | return voltha_completed.toInteger() == 8 |
| 90 | } |
| 91 | } |
| 92 | } |
Luca Prete | 5a97015 | 2018-08-29 15:20:47 -0700 | [diff] [blame] | 93 | stage('Install ONOS') { |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 94 | timeout(10) { |
| 95 | sh returnStdout: true, script: """ |
| 96 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Luca Prete | 5a97015 | 2018-08-29 15:20:47 -0700 | [diff] [blame] | 97 | helm install -n onos -f configs/onos.yaml -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml onos |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 98 | """ |
| 99 | } |
| 100 | timeout(10) { |
| 101 | waitUntil { |
Luca Prete | 5a97015 | 2018-08-29 15:20:47 -0700 | [diff] [blame] | 102 | onos_completed = sh returnStdout: true, script: """ |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 103 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
Luca Prete | 5a97015 | 2018-08-29 15:20:47 -0700 | [diff] [blame] | 104 | kubectl get pods | grep -i onos | grep -i running | grep 1/1 | wc -l |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 105 | """ |
Luca Prete | 5a97015 | 2018-08-29 15:20:47 -0700 | [diff] [blame] | 106 | return onos_completed.toInteger() == 1 |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 107 | } |
| 108 | } |
| 109 | } |
| 110 | stage('Install xos-core') { |
| 111 | timeout(10) { |
| 112 | sh returnStdout: true, script: """ |
| 113 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 114 | helm dep update xos-core |
| 115 | helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core xos-core |
| 116 | """ |
| 117 | } |
| 118 | timeout(10) { |
| 119 | waitUntil { |
| 120 | xos_core_completed = sh returnStdout: true, script: """ |
| 121 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 122 | kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l |
| 123 | """ |
| 124 | return xos_core_completed.toInteger() == 7 |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | stage('Install rcord-lite') { |
| 129 | timeout(10) { |
| 130 | sh returnStdout: true, script: """ |
| 131 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 132 | helm dep update xos-profiles/rcord-lite |
| 133 | helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n rcord-lite xos-profiles/rcord-lite |
| 134 | """ |
| 135 | } |
| 136 | timeout(10) { |
| 137 | waitUntil { |
| 138 | rcord_tosca_completed = sh returnStdout: true, script: """ |
| 139 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 140 | kubectl get pods | grep -i tosca-loader | grep -i completed | wc -l |
| 141 | """ |
| 142 | return rcord_tosca_completed.toInteger() == 1 |
| 143 | } |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 144 | } |
| 145 | } |
| 146 | } |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 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 --remove asfvolt16 && dpkg --purge asfvolt16' |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 151 | """ |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 152 | timeout(5) { |
| 153 | waitUntil { |
| 154 | olt_sw_present = sh returnStdout: true, script: """ |
| 155 | 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' |
| 156 | """ |
| 157 | return olt_sw_present.toInteger() == 0 |
| 158 | } |
| 159 | } |
| 160 | sh returnStdout: true, script: """ |
| 161 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}" |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 162 | """ |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 163 | timeout(5) { |
| 164 | waitUntil { |
| 165 | olt_sw_present = sh returnStdout: true, script: """ |
| 166 | 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' |
| 167 | """ |
| 168 | return olt_sw_present.toInteger() == 1 |
| 169 | } |
| 170 | } |
| 171 | // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded |
| 172 | if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') { |
| 173 | sh returnStdout: true, script: """ |
| 174 | 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' |
| 175 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh' |
| 176 | """ |
| 177 | } |
| 178 | } |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 179 | } |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 180 | stage('Restart OLT processes') { |
| 181 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 182 | timeout(5) { |
| 183 | sh returnStdout: true, script: """ |
| 184 | ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts |
| 185 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'pkill bal_core_dist' || true |
| 186 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'pkill openolt' || true |
| 187 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /broadcom/bal.log' |
| 188 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /broadcom/openolt.log' |
| 189 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'cd /broadcom; ./bal_core_dist -C :55001 < /dev/tty1 > ./bal.log 2>&1 &' |
| 190 | sleep 5 |
| 191 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'cd /broadcom; ./openolt -C 127.0.0.1:55001 < /dev/tty1 > ./openolt.log 2>&1 &' |
| 192 | """ |
| 193 | } |
| 194 | timeout(15) { |
| 195 | waitUntil { |
| 196 | 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 /broadcom/openolt.log | grep \"oper_state:up\" | wc -l'" |
| 197 | return onu_discovered.toInteger() > 0 |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | stage('Download cord-tester repo') { |
| 203 | timeout(2) { |
| 204 | sh returnStdout: true, script: """ |
| 205 | git clone -b ${branch} ${cordRepoUrl}/cord-tester |
| 206 | """ |
| 207 | } |
| 208 | } |
| 209 | stage('Validate installed PODs') { |
| 210 | timeout(10) { |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 211 | sh """ |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 212 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 213 | cd $WORKSPACE/cord-tester/src/test/robot/ |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 214 | rm -rf Log/ || true |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 215 | pybot -d Log -T SanityK8POD.robot || true |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 216 | """ |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 217 | } |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 218 | } |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 219 | stage('Configurations and Tests') { |
| 220 | timeout(10) { |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 221 | sh """ |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 222 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 223 | cd $WORKSPACE/cord-tester/src/test/cord-api/Properties/ |
| 224 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'${deployment_config.nodes[0].ip}\'/\" RestApiProperties.py |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 225 | sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'30006\'/\" RestApiProperties.py |
| 226 | sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py |
| 227 | sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 228 | cd $WORKSPACE/cord-tester/src/test/cord-api/Tests/ |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 229 | rm -rf Log/ || true |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 230 | pybot -d Log -T FabricConfig.txt || true |
| 231 | pybot -d Log -T RealOLT_Test.txt || true |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 232 | sleep 120 |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 233 | pybot -d Log -T Subscriber_TopDown.txt || true |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 234 | """ |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 235 | } |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 236 | } |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 237 | stage('Subscriber Validation and Ping Tests') { |
| 238 | timeout(30) { |
| 239 | sh """ |
| 240 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 241 | cd $WORKSPACE/cord-tester/src/test/cord-api/Tests/ |
Kailash Khalasi | 01e433e | 2018-08-29 14:48:08 -0700 | [diff] [blame] | 242 | pybot -d Log -T -v src_ip:${deployment_config.srcHost.ip} -v src_user:${deployment_config.srcHost.user} -v src_pass:${deployment_config.srcHost.pass} -v dst_user:${deployment_config.dstHost.user} -v dst_pass:${deployment_config.dstHost.pass} -v dst_ip:${deployment_config.dstHost.ip} -v dst_host_ip:${deployment_config.dstHost.hostIp} -v src_gateway:${deployment_config.srcHost.gateway} -v dst_gateway:${deployment_config.dstHost.gateway} -v init_state:disabled -v INITIAL_STATUS:FAIL -v ENABLE_STATUS:PASS -e zerotouch Subscriber_StatusChecks.txt || true |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 243 | """ |
| 244 | } |
| 245 | } |
| 246 | stage('Publish test results') { |
| 247 | sh returnStdout: true, script: """ |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 248 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs; |
| 249 | mkdir RobotLogs/TestDoc || true |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 250 | cp -r $WORKSPACE/cord-tester/src/test/robot/Log/* $WORKSPACE/RobotLogs || true |
| 251 | cp -r $WORKSPACE/cord-tester/src/test/cord-api/Tests/Log/* $WORKSPACE/RobotLogs || true |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 252 | """ |
| 253 | step([$class: 'RobotPublisher', |
| 254 | disableArchiveOutput: false, |
| 255 | logFileName: 'RobotLogs/log*.html', |
| 256 | otherFiles: '', |
| 257 | outputFileName: 'RobotLogs/output*.xml', |
| 258 | outputPath: '.', |
| 259 | passThreshold: 100, |
| 260 | reportFileName: 'RobotLogs/report*.html', |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 261 | unstableThreshold: 0 |
| 262 | ]) |
| 263 | } |
| 264 | currentBuild.result = 'SUCCESS' |
| 265 | } catch (err) { |
| 266 | currentBuild.result = 'FAILURE' |
| 267 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 268 | } |
You Wang | d6c5e8c | 2018-08-29 12:49:51 -0700 | [diff] [blame] | 269 | echo "RESULT: ${currentBuild.result}" |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 270 | } |
| 271 | } |