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