blob: abb366390e954182959e70a3fafcf700a0d86e39 [file] [log] [blame]
You Wangb918adb2017-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 Khalasi149b9e12018-05-01 09:13:01 -070018node ("${devNodeName}") {
You Wangb918adb2017-11-17 13:58:55 -080019 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 }
You Wangb918adb2017-11-17 13:58:55 -080025 stage('Prerequisites') {
26 runHeadNodeCmd("""
27 cd /opt/cord/test/cord-tester/src/test/setup
28 sudo ./prerequisites.sh --cord
29 """)
30 }
31 stage('Verify Collect Diag') {
32 timeout(10) {
33 try {
34 runHeadNodeCmd("""
35 rm -rf ~/diag-*
36 cd /opt/cord/build; make collect-diag
37 cd /opt/cord/test/cord-tester/src/test/diag/
38 rm -r Log/ || true
39 pybot -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T verifyCollectDiag.robot
40 """)
41 } catch(error) { currentBuild.result = 'FAILURE' }
42 }
43 }
44 stage('XOS API Tests') {
45 timeout(10) {
46 try {
47 runHeadNodeCmd("""
48 cd /opt/cord/test/cord-tester/src/test/cord-api/Properties/
49 sed -i s/^SERVER_IP\\ =\\ .*/SERVER_IP\\ =\\ \\'localhost\\'/ RestApiProperties.py
50 sed -i s/^SERVER_PORT\\ =\\ .*/SERVER_PORT\\ =\\ \\'9101\\'/ RestApiProperties.py
51 sed -i s/^PASSWD\\ =\\ .*/PASSWD\\ =\\ \\'\\\$(cat /opt/credentials/xosadmin@opencord.org)\\'/ RestApiProperties.py
52 """)
53 } catch(error) { currentBuild.result = 'FAILURE' }
54 }
55 }
56 stage('Publish') {
57 try {
58 sh """
59 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
60 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/Log/* ./RobotLogs || true
61 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/Log/* ./RobotLogs || true
62 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/Log/* ./RobotLogs || true
63 """
64 step([$class: 'RobotPublisher',
65 disableArchiveOutput: false,
66 logFileName: 'RobotLogs/log*.html',
67 otherFiles: '',
68 outputFileName: 'RobotLogs/output*.xml',
69 outputPath: '.',
70 passThreshold: 100,
71 reportFileName: 'RobotLogs/report*.html',
72 unstableThreshold: 0])
73 } catch(error) {}
74 }
75 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
76}
77
78/**
79 * Runs a command on the head node.
80 *
81 * @param command the command to run
82 * @param sshArgs arguments for the ssh command
83 * @return the output of the command
84 */
85def runHeadNodeCmd(command, sshArgs="") {
86 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}\"")
87}