Kailash Khalasi | 164dc14 | 2018-09-14 11:49:08 -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 ${configBaseDir}" |
| 20 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
You Wang | 59ded6c | 2018-10-05 17:43:44 -0700 | [diff] [blame] | 21 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
Kailash Khalasi | 164dc14 | 2018-09-14 11:49:08 -0700 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | stage('Download cord-tester repo') { |
| 25 | timeout(2) { |
| 26 | sh returnStdout: true, script: """ |
| 27 | git clone -b ${branch} ${cordRepoUrl}/cord-tester |
| 28 | """ |
| 29 | } |
| 30 | } |
| 31 | stage('Configurations and Tests') { |
| 32 | timeout(10) { |
| 33 | sh """ |
| 34 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 35 | cd $WORKSPACE/cord-tester/src/test/cord-api/Properties/ |
| 36 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'${deployment_config.nodes[0].ip}\'/\" RestApiProperties.py |
| 37 | sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'30006\'/\" RestApiProperties.py |
| 38 | sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py |
| 39 | sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
| 40 | cd $WORKSPACE/cord-tester/src/test/cord-api/Tests/ |
| 41 | rm -rf Log/ || true |
| 42 | """ |
| 43 | } |
| 44 | } |
| 45 | stage('Subscriber Validation and Ping Tests') { |
| 46 | timeout(30) { |
| 47 | sh """ |
| 48 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 49 | cd $WORKSPACE/cord-tester/src/test/cord-api/Tests/ |
You Wang | 0a38207 | 2018-09-28 13:29:26 -0700 | [diff] [blame] | 50 | pybot -d Log -T -l log-Subscriber_StatusChecks -v src_ip:${deployment_config.hosts.src.ip} -v src_user:${deployment_config.hosts.src.user} -v src_pass:${deployment_config.hosts.src.pass} -v dst_user:${deployment_config.hosts.dst.user} -v dst_pass:${deployment_config.hosts.dst.pass} -v dst_ip:${deployment_config.hosts.dst.ip} -v src_host_ip:${deployment_config.hosts.src.dp_iface_ip} -v dst_host_ip:${deployment_config.hosts.dst.dp_iface_ip} -v src_gateway:${deployment_config.hosts.src.dp_iface_gateway} -v dst_gateway:${deployment_config.hosts.dst.dp_iface_gateway} -v init_state:awaiting-auth -v INITIAL_STATUS:FAIL -v ENABLE_STATUS:FAIL -v MACIP_STATUS:PASS Subscriber_StatusChecks.txt || true |
Kailash Khalasi | 164dc14 | 2018-09-14 11:49:08 -0700 | [diff] [blame] | 51 | """ |
| 52 | } |
| 53 | } |
Kailash Khalasi | c233b22 | 2018-10-12 12:26:26 -0700 | [diff] [blame^] | 54 | stage ('Display Kafka Events') { |
| 55 | timeout(5) { |
| 56 | sh """ |
| 57 | CORD_KAFKA_IP=\$(kubectl exec cord-kafka-0 -- ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 192) |
| 58 | kafkacat -e -C -b \$CORD_KAFKA_IP -t onu.events -f 'Topic %t [%p] at offset %o: key %k: %s\n >0' |
| 59 | kafkacat -e -C -b \$CORD_KAFKA_IP -t authentication.events -f 'Topic %t [%p] at offset %o: key %k: %s\n >0' |
| 60 | kafkacat -e -C -b \$CORD_KAFKA_IP -t dhcp.events -f 'Topic %t [%p] at offset %o: key %k: %s\n >0' |
| 61 | """ |
| 62 | } |
| 63 | } |
Kailash Khalasi | 164dc14 | 2018-09-14 11:49:08 -0700 | [diff] [blame] | 64 | stage('Publish test results') { |
| 65 | sh returnStdout: true, script: """ |
| 66 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs; |
| 67 | mkdir RobotLogs/TestDoc || true |
| 68 | cp -r $WORKSPACE/cord-tester/src/test/robot/Log/* $WORKSPACE/RobotLogs || true |
| 69 | cp -r $WORKSPACE/cord-tester/src/test/cord-api/Tests/Log/* $WORKSPACE/RobotLogs || true |
Kailash Khalasi | c233b22 | 2018-10-12 12:26:26 -0700 | [diff] [blame^] | 70 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 71 | do |
| 72 | kubectl logs \$pod > $WORKSPACE/\$pod.log; |
| 73 | done |
| 74 | for pod in \$(kubectl get pods -n voltha --no-headers | awk '{print \$1}'); |
| 75 | do |
| 76 | kubectl logs \$pod > $WORKSPACE/\$pod.log; |
| 77 | done |
| 78 | cp -r $WORKSPACE/cord-tester/src/test/cord-api/Tests/Log/* $WORKSPACE/RobotLogs || true |
| 79 | sudo chown cord:cord $WORKSPACE/*log |
Kailash Khalasi | 164dc14 | 2018-09-14 11:49:08 -0700 | [diff] [blame] | 80 | """ |
Kailash Khalasi | c233b22 | 2018-10-12 12:26:26 -0700 | [diff] [blame^] | 81 | archiveArtifacts artifacts: '*log' |
Kailash Khalasi | 164dc14 | 2018-09-14 11:49:08 -0700 | [diff] [blame] | 82 | step([$class: 'RobotPublisher', |
| 83 | disableArchiveOutput: false, |
| 84 | logFileName: 'RobotLogs/log*.html', |
| 85 | otherFiles: '', |
| 86 | outputFileName: 'RobotLogs/output*.xml', |
| 87 | outputPath: '.', |
| 88 | passThreshold: 100, |
| 89 | reportFileName: 'RobotLogs/report*.html', |
| 90 | unstableThreshold: 0 |
| 91 | ]) |
| 92 | } |
| 93 | currentBuild.result = 'SUCCESS' |
| 94 | } catch (err) { |
| 95 | currentBuild.result = 'FAILURE' |
| 96 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 97 | } |
| 98 | echo "RESULT: ${currentBuild.result}" |
| 99 | } |
| 100 | } |