blob: 0aaae42cdba7c9446dc44f6161a5a337b7ebc368 [file] [log] [blame]
You Wang6cd3e1c2017-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 Khalasi3a4bd782018-05-01 09:16:55 -070018node ("${devNodeName}") {
You Wang6cd3e1c2017-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 Wang6cd3e1c2017-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('Sanity Test') {
45 timeout(10) {
46 try {
47 runHeadNodeCmd("""
48 cd /opt/cord/test/cord-tester/src/test/robot/
49 rm -r Log/ || true
50 """)
51 if (deployment_config.fabric_switches != null) {
52 runHeadNodeCmd("""
53 cd /opt/cord/test/cord-tester/src/test/robot/
54 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
55 """)
56 }
57 else {
58 // Exclude fabric related tests
59 runHeadNodeCmd("""
60 cd /opt/cord/test/cord-tester/src/test/robot/
61 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
62 """)
63 }
64 } catch(error) { currentBuild.result = 'FAILURE' }
65 }
66 }
67 stage('XOS API Tests') {
68 timeout(10) {
69 try {
70 runHeadNodeCmd("""
71 cd /opt/cord/test/cord-tester/src/test/cord-api/Properties/
72 sed -i s/^SERVER_IP\\ =\\ .*/SERVER_IP\\ =\\ \\'localhost\\'/ RestApiProperties.py
73 sed -i s/^SERVER_PORT\\ =\\ .*/SERVER_PORT\\ =\\ \\'9101\\'/ RestApiProperties.py
74 sed -i s/^PASSWD\\ =\\ .*/PASSWD\\ =\\ \\'\\\$(cat /opt/credentials/xosadmin@opencord.org)\\'/ RestApiProperties.py
75 all_passed=true
76 cd /opt/cord/test/cord-tester/src/test/cord-api/
77 rm -r Log/ || true
78 pybot -d Log -T Tests/Ch_defaultImagesCheck.txt || all_passed=false
79 pybot -d Log -T -v PROFILE:${pod_config.cord_profile} Tests/Ch_DefaultServiceCheck.txt || all_passed=false
80 pybot -d Log -T Tests/Ch_SubscriberTest.txt || all_passed=false
81 pybot -d Log -T Tests/Ch_VoltTenant.txt || all_passed=false
82 pybot -d Log -T Tests/Ch_ServiceTest.txt || all_passed=false
83 pybot -d Log -T Tests/Ch_UsersTest.txt || all_passed=false
84 pybot -d Log -T Tests/Ch_DeploymentTest.txt || all_passed=false
85 pybot -d Log -T Tests/Ch_NodeTest.txt || all_passed=false
86 pybot -d Log -T Tests/Ch_SliceTest.txt || all_passed=false
87 pybot -d Log -T Tests/Ch_SanityInstance.txt || all_passed=false
88 pybot -d Log -T Tests/Ch_SanityFlavors.txt || all_passed=false
89 pybot -d Log -T Tests/Ch_SiteTest.txt || all_passed=false
90 if [ "\\\$all_passed" = true ]; then exit 0; else exit 1; fi
91 """)
92 } catch(error) { currentBuild.result = 'FAILURE' }
93 }
94 }
95 stage('Publish') {
96 try {
97 sh """
98 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
99 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/Log/* ./RobotLogs || true
100 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/Log/* ./RobotLogs || true
101 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/Log/* ./RobotLogs || true
102 """
103 step([$class: 'RobotPublisher',
104 disableArchiveOutput: false,
105 logFileName: 'RobotLogs/log*.html',
106 otherFiles: '',
107 outputFileName: 'RobotLogs/output*.xml',
108 outputPath: '.',
109 passThreshold: 100,
110 reportFileName: 'RobotLogs/report*.html',
111 unstableThreshold: 0])
112 } catch(error) {}
113 }
114 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
115}
116
117/**
118 * Runs a command on the head node.
119 *
120 * @param command the command to run
121 * @param sshArgs arguments for the ssh command
122 * @return the output of the command
123 */
124def runHeadNodeCmd(command, sshArgs="") {
125 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}\"")
126}