| // Copyright 2017-present Open Networking Foundation |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| pod_config = null |
| deployment_config = null |
| |
| |
| node ("${devNodeName}") { |
| |
| stage ("Parse deployment configuration file") { |
| sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}' |
| sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}' |
| deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}" |
| pod_config = readYaml file: "${configRepoBaseDir}${deployment_config.pod_config.file_name}" |
| } |
| |
| stage('Prerequisites') { |
| runHeadNodeCmd(""" |
| cd /opt/cord/test/cord-tester/src/test/setup |
| sudo ./prerequisites.sh --cord |
| """) |
| } |
| stage('Verify Collect Diag') { |
| timeout(10) { |
| try { |
| runHeadNodeCmd(""" |
| export SERVER_IP=localhost |
| export SERVER_PORT=9101 |
| export XOS_USER=xosadmin@opencord.org |
| export XOS_PASSWD=\\\$(cat /opt/credentials/xosadmin@opencord.org) |
| rm -rf ~/diag-* |
| cd /opt/cord/build; make collect-diag |
| cd /opt/cord/test/cord-tester/src/test/diag/ |
| rm -r Log/ || true |
| rm -r TestDoc/ || true |
| mkdir TestDoc || true |
| pybot -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T verifyCollectDiag.robot |
| python -m robot.testdoc verifyCollectDiag.robot TestDoc/verifyCollectDiag.html |
| """) |
| } catch(error) { currentBuild.result = 'FAILURE' } |
| } |
| } |
| stage('XOS API Tests') { |
| timeout(10) { |
| try { |
| runHeadNodeCmd(""" |
| export SERVER_IP=localhost |
| export SERVER_PORT=9101 |
| export XOS_USER=xosadmin@opencord.org |
| export XOS_PASSWD=\\\$(cat /opt/credentials/xosadmin@opencord.org) |
| """) |
| } catch(error) { currentBuild.result = 'FAILURE' } |
| } |
| } |
| stage('Publish') { |
| try { |
| sh """ |
| if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| mkdir RobotLogs/TestDoc || true |
| scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/Log/* ./RobotLogs || true |
| scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/Log/* ./RobotLogs || true |
| scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/Log/* ./RobotLogs || true |
| scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/TestDoc/* ./RobotLogs/TestDoc || true |
| """ |
| step([$class: 'RobotPublisher', |
| disableArchiveOutput: false, |
| logFileName: 'RobotLogs/log*.html', |
| otherFiles: 'RobotLogs/TestDoc/*.html', |
| outputFileName: 'RobotLogs/output*.xml', |
| outputPath: '.', |
| passThreshold: 100, |
| reportFileName: 'RobotLogs/report*.html', |
| unstableThreshold: 0]) |
| } catch(error) {} |
| } |
| step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| } |
| |
| /** |
| * Runs a command on the head node. |
| * |
| * @param command the command to run |
| * @param sshArgs arguments for the ssh command |
| * @return the output of the command |
| */ |
| def runHeadNodeCmd(command, sshArgs="") { |
| 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}\"") |
| } |