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