You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [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 | pod_config = null |
| 16 | deployment_config = null |
| 17 | |
Kailash Khalasi | e48bad0 | 2018-05-01 09:20:51 -0700 | [diff] [blame] | 18 | node ("${devNodeName}") { |
You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [diff] [blame] | 19 | stage ("Parse configuration file") { |
| 20 | sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}' |
| 21 | sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}' |
| 22 | deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}" |
| 23 | pod_config = readYaml file: "${configRepoBaseDir}${deployment_config.pod_config.file_name}" |
| 24 | } |
You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [diff] [blame] | 25 | stage('Prerequisites') { |
| 26 | runHeadNodeCmd(""" |
| 27 | cd /opt/cord/test/cord-tester/src/test/setup |
| 28 | sudo ./prerequisites.sh --cord |
| 29 | """) |
| 30 | } |
| 31 | stage('Verify Collect Diag') { |
| 32 | timeout(10) { |
| 33 | try { |
| 34 | runHeadNodeCmd(""" |
| 35 | rm -rf ~/diag-* |
| 36 | cd /opt/cord/build; make collect-diag |
| 37 | cd /opt/cord/test/cord-tester/src/test/diag/ |
| 38 | rm -r Log/ || true |
Kailash Khalasi | 3d1c4d7 | 2018-01-30 12:10:28 -0800 | [diff] [blame] | 39 | rm -r TestDoc/ || true |
| 40 | mkdir TestDoc || true |
You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [diff] [blame] | 41 | pybot -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T verifyCollectDiag.robot |
Kailash Khalasi | 3d1c4d7 | 2018-01-30 12:10:28 -0800 | [diff] [blame] | 42 | python -m robot.testdoc verifyCollectDiag.robot TestDoc/verifyCollectDiag.html |
You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [diff] [blame] | 43 | """) |
| 44 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 45 | } |
| 46 | } |
| 47 | stage('Sanity Test') { |
| 48 | timeout(10) { |
| 49 | try { |
| 50 | runHeadNodeCmd(""" |
| 51 | cd /opt/cord/test/cord-tester/src/test/robot/ |
| 52 | rm -r Log/ || true |
Kailash Khalasi | 3d1c4d7 | 2018-01-30 12:10:28 -0800 | [diff] [blame] | 53 | rm -r TestDoc/ || true |
| 54 | mkdir TestDoc || true |
You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [diff] [blame] | 55 | """) |
| 56 | if (deployment_config.fabric_switches != null) { |
| 57 | runHeadNodeCmd(""" |
| 58 | cd /opt/cord/test/cord-tester/src/test/robot/ |
| 59 | pybot --exclude notready -v FABRIC:on -v PUBLIC_IFACE:${pod_config.external_iface} -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T SanityPhyPOD.robot |
Kailash Khalasi | 3d1c4d7 | 2018-01-30 12:10:28 -0800 | [diff] [blame] | 60 | python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html |
You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [diff] [blame] | 61 | """) |
| 62 | } |
| 63 | else { |
| 64 | // Exclude fabric related tests |
| 65 | runHeadNodeCmd(""" |
| 66 | cd /opt/cord/test/cord-tester/src/test/robot/ |
| 67 | pybot --exclude notready --exclude fabric -v FABRIC:off -v PUBLIC_IFACE:${pod_config.external_iface} -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T SanityPhyPOD.robot |
Kailash Khalasi | 3d1c4d7 | 2018-01-30 12:10:28 -0800 | [diff] [blame] | 68 | python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html |
You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [diff] [blame] | 69 | """) |
| 70 | } |
| 71 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 72 | } |
| 73 | } |
| 74 | stage('XOS API Tests') { |
| 75 | timeout(10) { |
| 76 | try { |
| 77 | runHeadNodeCmd(""" |
| 78 | cd /opt/cord/test/cord-tester/src/test/cord-api/Properties/ |
| 79 | sed -i s/^SERVER_IP\\ =\\ .*/SERVER_IP\\ =\\ \\'localhost\\'/ RestApiProperties.py |
| 80 | sed -i s/^SERVER_PORT\\ =\\ .*/SERVER_PORT\\ =\\ \\'9101\\'/ RestApiProperties.py |
| 81 | sed -i s/^PASSWD\\ =\\ .*/PASSWD\\ =\\ \\'\\\$(cat /opt/credentials/xosadmin@opencord.org)\\'/ RestApiProperties.py |
| 82 | """) |
| 83 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 84 | } |
| 85 | } |
| 86 | stage('Publish') { |
| 87 | try { |
| 88 | sh """ |
| 89 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
Kailash Khalasi | 626e0d8 | 2018-02-08 11:26:37 -0800 | [diff] [blame] | 90 | mkdir RobotLogs/TestDoc || true |
You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [diff] [blame] | 91 | scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/Log/* ./RobotLogs || true |
| 92 | scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/Log/* ./RobotLogs || true |
| 93 | scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/Log/* ./RobotLogs || true |
Kailash Khalasi | 626e0d8 | 2018-02-08 11:26:37 -0800 | [diff] [blame] | 94 | scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/TestDoc/* ./RobotLogs/TestDoc || true |
| 95 | scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/TestDoc/* ./RobotLogs/TestDoc || true |
Kailash Khalasi | 3d1c4d7 | 2018-01-30 12:10:28 -0800 | [diff] [blame] | 96 | |
You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [diff] [blame] | 97 | """ |
| 98 | step([$class: 'RobotPublisher', |
| 99 | disableArchiveOutput: false, |
| 100 | logFileName: 'RobotLogs/log*.html', |
Kailash Khalasi | 626e0d8 | 2018-02-08 11:26:37 -0800 | [diff] [blame] | 101 | otherFiles: 'RobotLogs/TestDoc/*.html', |
You Wang | 4eefdc8 | 2017-11-17 13:58:55 -0800 | [diff] [blame] | 102 | outputFileName: 'RobotLogs/output*.xml', |
| 103 | outputPath: '.', |
| 104 | passThreshold: 100, |
| 105 | reportFileName: 'RobotLogs/report*.html', |
| 106 | unstableThreshold: 0]) |
| 107 | } catch(error) {} |
| 108 | } |
| 109 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Runs a command on the head node. |
| 114 | * |
| 115 | * @param command the command to run |
| 116 | * @param sshArgs arguments for the ssh command |
| 117 | * @return the output of the command |
| 118 | */ |
| 119 | def runHeadNodeCmd(command, sshArgs="") { |
| 120 | return sh(returnStdout: true, script: "sshpass -p ${deployment_config.head.pass} ssh ${sshArgs} -oStrictHostKeyChecking=no -l ${deployment_config.head.user} ${deployment_config.head.ip} \"${command}\"") |
| 121 | } |