blob: b2737d12f013796cab7a09034a48050d89388078 [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
18node ('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
27node ("${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("""
38 rm -rf ~/diag-*
39 cd /opt/cord/build; make collect-diag
40 cd /opt/cord/test/cord-tester/src/test/diag/
41 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080042 rm -r TestDoc/ || true
43 mkdir TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -080044 pybot -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T verifyCollectDiag.robot
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080045 python -m robot.testdoc verifyCollectDiag.robot TestDoc/verifyCollectDiag.html
You Wang4eefdc82017-11-17 13:58:55 -080046 """)
47 } catch(error) { currentBuild.result = 'FAILURE' }
48 }
49 }
50 stage('Sanity Test') {
51 timeout(10) {
52 try {
53 runHeadNodeCmd("""
54 cd /opt/cord/test/cord-tester/src/test/robot/
55 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080056 rm -r TestDoc/ || true
57 mkdir TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -080058 """)
59 if (deployment_config.fabric_switches != null) {
60 runHeadNodeCmd("""
61 cd /opt/cord/test/cord-tester/src/test/robot/
62 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 Khalasi3d1c4d72018-01-30 12:10:28 -080063 python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html
You Wang4eefdc82017-11-17 13:58:55 -080064 """)
65 }
66 else {
67 // Exclude fabric related tests
68 runHeadNodeCmd("""
69 cd /opt/cord/test/cord-tester/src/test/robot/
70 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 Khalasi3d1c4d72018-01-30 12:10:28 -080071 python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html
You Wang4eefdc82017-11-17 13:58:55 -080072 """)
73 }
74 } catch(error) { currentBuild.result = 'FAILURE' }
75 }
76 }
77 stage('XOS API Tests') {
78 timeout(10) {
79 try {
80 runHeadNodeCmd("""
81 cd /opt/cord/test/cord-tester/src/test/cord-api/Properties/
82 sed -i s/^SERVER_IP\\ =\\ .*/SERVER_IP\\ =\\ \\'localhost\\'/ RestApiProperties.py
83 sed -i s/^SERVER_PORT\\ =\\ .*/SERVER_PORT\\ =\\ \\'9101\\'/ RestApiProperties.py
84 sed -i s/^PASSWD\\ =\\ .*/PASSWD\\ =\\ \\'\\\$(cat /opt/credentials/xosadmin@opencord.org)\\'/ RestApiProperties.py
85 """)
86 } catch(error) { currentBuild.result = 'FAILURE' }
87 }
88 }
89 stage('Publish') {
90 try {
91 sh """
92 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
93 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/Log/* ./RobotLogs || true
94 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/Log/* ./RobotLogs || true
95 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/Log/* ./RobotLogs || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080096 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/TestDoc/* ./RobotLogs/TestDocs || true
97 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/TestDoc/* ./RobotLogs/TestDocs || true
98
You Wang4eefdc82017-11-17 13:58:55 -080099 """
100 step([$class: 'RobotPublisher',
101 disableArchiveOutput: false,
102 logFileName: 'RobotLogs/log*.html',
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800103 otherFiles: 'RobotLogs/TestDocs/*.html',
You Wang4eefdc82017-11-17 13:58:55 -0800104 outputFileName: 'RobotLogs/output*.xml',
105 outputPath: '.',
106 passThreshold: 100,
107 reportFileName: 'RobotLogs/report*.html',
108 unstableThreshold: 0])
109 } catch(error) {}
110 }
111 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
112}
113
114/**
115 * Runs a command on the head node.
116 *
117 * @param command the command to run
118 * @param sshArgs arguments for the ssh command
119 * @return the output of the command
120 */
121def runHeadNodeCmd(command, sshArgs="") {
122 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}\"")
123}