blob: 137907498a35d7fc395b0b07cc8964ce79b8e752 [file] [log] [blame]
// 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 ('master') {
stage ("Parse 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}"
}
}
node ("${deployment_config.dev_node.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('Sanity Test') {
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)
cd /opt/cord/test/cord-tester/src/test/robot/
rm -r Log/ || true
rm -r TestDoc/ || true
mkdir TestDoc || true
""")
if (deployment_config.fabric_switches != null) {
runHeadNodeCmd("""
export SERVER_IP=localhost
export SERVER_PORT=9101
export XOS_USER=xosadmin@opencord.org
export XOS_PASSWD=\$(cat /opt/credentials/xosadmin@opencord.org)
cd /opt/cord/test/cord-tester/src/test/robot/
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
python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html
""")
}
else {
// Exclude fabric related tests
runHeadNodeCmd("""
export SERVER_IP=localhost
export SERVER_PORT=9101
export XOS_USER=xosadmin@opencord.org
export XOS_PASSWD=\$(cat /opt/credentials/xosadmin@opencord.org)
cd /opt/cord/test/cord-tester/src/test/robot/
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
python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.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/robot/TestDoc/* ./RobotLogs/TestDoc || 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}\"")
}