blob: 3215d61143b1a20cdd99a5df07d8ec0e8576da59 [file] [log] [blame]
You Wang4eefdc82017-11-17 13:58:55 -08001// 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
15pod_config = null
16deployment_config = null
17
Kailash Khalasia0d49002018-04-18 15:00:47 -070018
19node ("${devNodeName}") {
20
21 stage ("Parse deployment configuration file") {
You Wang4eefdc82017-11-17 13:58:55 -080022 sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}'
23 sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}'
24 deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}"
25 pod_config = readYaml file: "${configRepoBaseDir}${deployment_config.pod_config.file_name}"
26 }
You Wang4eefdc82017-11-17 13:58:55 -080027
You Wang4eefdc82017-11-17 13:58:55 -080028 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 Khalasi68f9f632018-04-11 08:09:19 -070038 export SERVER_IP=localhost
39 export SERVER_PORT=9101
40 export XOS_USER=xosadmin@opencord.org
Kailash Khalasia0d49002018-04-18 15:00:47 -070041 export XOS_PASSWD=\\\$(cat /opt/credentials/xosadmin@opencord.org)
You Wang4eefdc82017-11-17 13:58:55 -080042 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 Khalasi3d1c4d72018-01-30 12:10:28 -080046 rm -r TestDoc/ || true
47 mkdir TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -080048 pybot -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T verifyCollectDiag.robot
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080049 python -m robot.testdoc verifyCollectDiag.robot TestDoc/verifyCollectDiag.html
You Wang4eefdc82017-11-17 13:58:55 -080050 """)
51 } catch(error) { currentBuild.result = 'FAILURE' }
52 }
53 }
54 stage('XOS API Tests') {
55 timeout(10) {
56 try {
57 runHeadNodeCmd("""
Kailash Khalasi68f9f632018-04-11 08:09:19 -070058 export SERVER_IP=localhost
59 export SERVER_PORT=9101
60 export XOS_USER=xosadmin@opencord.org
Kailash Khalasia0d49002018-04-18 15:00:47 -070061 export XOS_PASSWD=\\\$(cat /opt/credentials/xosadmin@opencord.org)
You Wang4eefdc82017-11-17 13:58:55 -080062 """)
63 } catch(error) { currentBuild.result = 'FAILURE' }
64 }
65 }
66 stage('Publish') {
67 try {
68 sh """
69 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
Kailash Khalasi9b311092018-02-08 11:26:37 -080070 mkdir RobotLogs/TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -080071 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/Log/* ./RobotLogs || true
72 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/Log/* ./RobotLogs || true
73 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/Log/* ./RobotLogs || true
Kailash Khalasi9b311092018-02-08 11:26:37 -080074 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/TestDoc/* ./RobotLogs/TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -080075 """
76 step([$class: 'RobotPublisher',
77 disableArchiveOutput: false,
78 logFileName: 'RobotLogs/log*.html',
Kailash Khalasi9b311092018-02-08 11:26:37 -080079 otherFiles: 'RobotLogs/TestDoc/*.html',
You Wang4eefdc82017-11-17 13:58:55 -080080 outputFileName: 'RobotLogs/output*.xml',
81 outputPath: '.',
82 passThreshold: 100,
83 reportFileName: 'RobotLogs/report*.html',
84 unstableThreshold: 0])
85 } catch(error) {}
86 }
87 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
88}
89
90/**
91 * Runs a command on the head node.
92 *
93 * @param command the command to run
94 * @param sshArgs arguments for the ssh command
95 * @return the output of the command
96 */
97def runHeadNodeCmd(command, sshArgs="") {
98 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}\"")
99}