blob: b776daf185522a1b7c7694d731de6b9b18207300 [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 -070018node ("${devNodeName}") {
19
20 stage ("Parse deployment configuration file") {
You Wang4eefdc82017-11-17 13:58:55 -080021 sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}'
22 sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}'
23 deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}"
24 pod_config = readYaml file: "${configRepoBaseDir}${deployment_config.pod_config.file_name}"
25 }
You Wang4eefdc82017-11-17 13:58:55 -080026 stage('Prerequisites') {
27 runHeadNodeCmd("""
28 cd /opt/cord/test/cord-tester/src/test/setup
29 sudo ./prerequisites.sh --cord
30 """)
31 }
Kailash Khalasiecf30142018-01-24 15:16:45 -080032 stage('Bring up Cord-Test Container') {
33 runHeadNodeCmd("""
34 cd /opt/cord/test/cord-tester/src/test/setup
35 sudo ./cord-test.py setup -m manifest-onf-cord.json
36 """)
37 }
You Wang9d616dd2018-01-22 14:10:28 -080038 stage('Configure Fabric for E2E testing') {
39 //FIXME: this only works for PODs with 2 leaf switches
40 fabricIpPrefix = pod_config.fabric_ip.split(/\.\d+\.\d+\/24/)[0]
41 runHeadNodeCmd("sudo ip route add ${fabricIpPrefix}.2.0/24 via ${fabricIpPrefix}.1.254 || echo route already exists")
42 runHeadNodeCmd("sudo route add -net 10.7.1.0/24 gw 10.6.1.254 || echo route already exists")
43 runHeadNodeCmd("sudo route add -net 10.8.1.0/24 gw 10.6.1.254 || echo route already exists")
44 runHeadNodeCmd("ping -c 1 ${fabricIpPrefix}.1.254", "-qftn")
45 runOnosCliCmd("onos-fabric", "8101", "onos", "rocks", "route-add 0.0.0.0/0 ${fabricIpPrefix}.1.1")
46 // Verify ONOS has recognized the hosts
47 timeout(time: 5) {
48 waitUntil {
49 try {
50 num = runHeadNodeCmd("\"sshpass -p rocks ssh -q -oStrictHostKeyChecking=no -l onos -p 8101 onos-fabric hosts | grep id= | wc -l\"").trim()
51 return num.toInteger() == deployment_config.compute_nodes.size() + 1
52 } catch (exception) {
53 return false
54 }
55 }
56 }
57 // Generate network configuration
58 runHeadNodeCmd("""
59 cd /opt/cord_profile/
60 cp fabric-network-cfg.json fabric-network-cfg.json.\$(date +%Y%m%d-%H%M%S)
61 cord generate > fabric-network-cfg.json
62 """)
You Wangc18aa9f2018-02-06 15:58:04 -080063 // Install httpie on the head-node
64 runHeadNodeCmd("sudo pip install httpie")
You Wang9d616dd2018-01-22 14:10:28 -080065 // Delete old ONOS netcfg
66 runHeadNodeCmd("http -a onos:rocks DELETE http://onos-fabric:8181/onos/v1/network/configuration/")
67 // Load new configuration
68 runHeadNodeCmd("http -a onos:rocks POST http://onos-fabric:8181/onos/v1/network/configuration/ < /opt/cord_profile/fabric-network-cfg.json")
69 // Restart ONOS apps
70 runHeadNodeCmd("""
71 http -a onos:rocks DELETE http://onos-fabric:8181/onos/v1/applications/org.onosproject.segmentrouting/active; sleep 5
72 http -a onos:rocks POST http://onos-fabric:8181/onos/v1/applications/org.onosproject.segmentrouting/active; sleep 5
73 """)
74 }
You Wang4eefdc82017-11-17 13:58:55 -080075 stage('Verify Collect Diag') {
76 timeout(10) {
77 try {
78 runHeadNodeCmd("""
79 rm -rf ~/diag-*
80 cd /opt/cord/build; make collect-diag
81 cd /opt/cord/test/cord-tester/src/test/diag/
82 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080083 rm -r TestDoc/ || true
84 mkdir TestDoc || true
Kailash Khalasi68f9f632018-04-11 08:09:19 -070085 export SERVER_IP=localhost
86 export SERVER_PORT=9101
87 export XOS_USER=xosadmin@opencord.org
Kailash Khalasia0d49002018-04-18 15:00:47 -070088 export XOS_PASSWD=\\\$(cat /opt/credentials/xosadmin@opencord.org)
You Wang4eefdc82017-11-17 13:58:55 -080089 pybot -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T verifyCollectDiag.robot
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080090 python -m robot.testdoc verifyCollectDiag.robot TestDoc/verifyCollectDiag.html
You Wang4eefdc82017-11-17 13:58:55 -080091 """)
92 } catch(error) { currentBuild.result = 'FAILURE' }
93 }
94 }
95 stage('Sanity Test') {
96 timeout(10) {
97 try {
98 runHeadNodeCmd("""
99 cd /opt/cord/test/cord-tester/src/test/robot/
100 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800101 rm -r TestDoc/ || true
102 mkdir TestDoc
You Wang4eefdc82017-11-17 13:58:55 -0800103 """)
104 if (deployment_config.fabric_switches != null) {
105 runHeadNodeCmd("""
Kailash Khalasi68f9f632018-04-11 08:09:19 -0700106 export SERVER_IP=localhost
107 export SERVER_PORT=9101
108 export XOS_USER=xosadmin@opencord.org
Kailash Khalasia0d49002018-04-18 15:00:47 -0700109 export XOS_PASSWD=\\\$(cat /opt/credentials/xosadmin@opencord.org)
You Wang4eefdc82017-11-17 13:58:55 -0800110 cd /opt/cord/test/cord-tester/src/test/robot/
111 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 -0800112 python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html
You Wang4eefdc82017-11-17 13:58:55 -0800113 """)
114 }
115 else {
116 // Exclude fabric related tests
117 runHeadNodeCmd("""
Kailash Khalasi68f9f632018-04-11 08:09:19 -0700118 export SERVER_IP=localhost
119 export SERVER_PORT=9101
120 export XOS_USER=xosadmin@opencord.org
Kailash Khalasia0d49002018-04-18 15:00:47 -0700121 export XOS_PASSWD=\\\$(cat /opt/credentials/xosadmin@opencord.org)
You Wang4eefdc82017-11-17 13:58:55 -0800122 cd /opt/cord/test/cord-tester/src/test/robot/
123 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 -0800124 python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html
You Wang4eefdc82017-11-17 13:58:55 -0800125 """)
126 }
127 } catch(error) { currentBuild.result = 'FAILURE' }
128 }
129 }
130 stage('XOS API Tests') {
131 timeout(10) {
132 try {
133 runHeadNodeCmd("""
Kailash Khalasi68f9f632018-04-11 08:09:19 -0700134 export SERVER_IP=localhost
135 export SERVER_PORT=9101
136 export XOS_USER=xosadmin@opencord.org
Kailash Khalasia0d49002018-04-18 15:00:47 -0700137 export XOS_PASSWD=\\\$(cat /opt/credentials/xosadmin@opencord.org)
You Wang4eefdc82017-11-17 13:58:55 -0800138 all_passed=true
139 cd /opt/cord/test/cord-tester/src/test/cord-api/
140 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800141 rm -r TestDoc/ || true
142 mkdir TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -0800143 pybot -d Log -T Tests/Ch_defaultImagesCheck.txt || all_passed=false
144 pybot -d Log -T -v PROFILE:${pod_config.cord_profile} Tests/Ch_DefaultServiceCheck.txt || all_passed=false
145 pybot -d Log -T Tests/Ch_SubscriberTest.txt || all_passed=false
You Wang4eefdc82017-11-17 13:58:55 -0800146 pybot -d Log -T Tests/Ch_ServiceTest.txt || all_passed=false
147 pybot -d Log -T Tests/Ch_UsersTest.txt || all_passed=false
148 pybot -d Log -T Tests/Ch_DeploymentTest.txt || all_passed=false
149 pybot -d Log -T Tests/Ch_NodeTest.txt || all_passed=false
150 pybot -d Log -T Tests/Ch_SliceTest.txt || all_passed=false
151 pybot -d Log -T Tests/Ch_SanityInstance.txt || all_passed=false
152 pybot -d Log -T Tests/Ch_SanityFlavors.txt || all_passed=false
153 pybot -d Log -T Tests/Ch_SiteTest.txt || all_passed=false
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800154 python -m robot.testdoc Tests/Ch_*.txt TestDoc/XOSApiTests.html
You Wang4eefdc82017-11-17 13:58:55 -0800155 if [ "\\\$all_passed" = true ]; then exit 0; else exit 1; fi
156 """)
157 } catch(error) { currentBuild.result = 'FAILURE' }
158 }
159 }
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -0800160 stage('Dataplane Test') {
Kailash Khalasie1688822018-02-10 12:26:39 -0800161 timeout(30) {
Kailash Khalasiecf30142018-01-24 15:16:45 -0800162 try {
163 runHeadNodeCmd("""
Kailash Khalasi68f9f632018-04-11 08:09:19 -0700164 export SERVER_IP=localhost
165 export SERVER_PORT=9101
166 export XOS_USER=xosadmin@opencord.org
167 export XOS_PASSWD=\$(cat /opt/credentials/xosadmin@opencord.org)
Kailash Khalasiecf30142018-01-24 15:16:45 -0800168 cd /opt/cord/test/cord-tester/src/test/vsg/
169 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800170 rm -r TestDoc/ || true
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -0800171 mkdir TestDoc
Kailash Khalasiecf30142018-01-24 15:16:45 -0800172 """)
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -0800173 if (deployment_config.pod_config.file_name != 'calix-pod1.yml') {
174 runHeadNodeCmd("""
Kailash Khalasi68f9f632018-04-11 08:09:19 -0700175 export SERVER_IP=localhost
176 export SERVER_PORT=9101
177 export XOS_USER=xosadmin@opencord.org
Kailash Khalasia0d49002018-04-18 15:00:47 -0700178 export XOS_PASSWD=\\\$(cat /opt/credentials/xosadmin@opencord.org)
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -0800179 cd /opt/cord/test/cord-tester/src/test/vsg/
180 pybot -L TRACE -v pod:${deployment_config.pod_config.file_name} -d Log -T vsg_dataplane_test.robot
181 python -m robot.testdoc vsg_dataplane_test.robot TestDoc/vsg_dataplane_test.html
182 """)
183 }
184 else {
185 runHeadNodeCmd("""
Kailash Khalasi68f9f632018-04-11 08:09:19 -0700186 export SERVER_IP=localhost
187 export SERVER_PORT=9101
188 export XOS_USER=xosadmin@opencord.org
Kailash Khalasia0d49002018-04-18 15:00:47 -0700189 export XOS_PASSWD=\\\$(cat /opt/credentials/xosadmin@opencord.org)
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -0800190 cd /opt/cord/test/cord-tester/src/test/vsg/
191 pybot -L TRACE -v pod:${deployment_config.pod_config.file_name} -e dataplane -d Log -T vsg_dataplane_test.robot
192 python -m robot.testdoc vsg_dataplane_test.robot TestDoc/vsg_dataplane_test.html
193 """)
194 }
Kailash Khalasiecf30142018-01-24 15:16:45 -0800195 } catch(error) { currentBuild.result = 'FAILURE' }
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -0800196 }
197 }
You Wang4eefdc82017-11-17 13:58:55 -0800198 stage('Publish') {
199 try {
200 sh """
Kailash Khalasi9b311092018-02-08 11:26:37 -0800201 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs;
202 mkdir RobotLogs/TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -0800203 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/Log/* ./RobotLogs || true
204 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/Log/* ./RobotLogs || true
205 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/Log/* ./RobotLogs || true
Kailash Khalasiecf30142018-01-24 15:16:45 -0800206 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/vsg/Log/* ./RobotLogs || true
Kailash Khalasi9b311092018-02-08 11:26:37 -0800207 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/TestDoc/* ./RobotLogs/TestDoc || true
208 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/TestDoc/* ./RobotLogs/TestDoc || true
209 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/TestDoc/* ./RobotLogs/TestDoc || true
210 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/vsg/TestDoc/* ./RobotLogs/TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -0800211 """
212 step([$class: 'RobotPublisher',
213 disableArchiveOutput: false,
214 logFileName: 'RobotLogs/log*.html',
Kailash Khalasi9b311092018-02-08 11:26:37 -0800215 otherFiles: 'RobotLogs/TestDoc/*.html',
You Wang4eefdc82017-11-17 13:58:55 -0800216 outputFileName: 'RobotLogs/output*.xml',
217 outputPath: '.',
218 passThreshold: 100,
219 reportFileName: 'RobotLogs/report*.html',
220 unstableThreshold: 0])
221 } catch(error) {}
222 }
223 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
224}
225
226/**
227 * Runs a command on the head node.
228 *
229 * @param command the command to run
230 * @param sshArgs arguments for the ssh command
231 * @return the output of the command
232 */
233def runHeadNodeCmd(command, sshArgs="") {
234 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}\"")
235}
You Wang9d616dd2018-01-22 14:10:28 -0800236
237/**
238 * Runs an ONOS CLI command
239 *
240 * @param name the onos node name, reachable from the head node
241 * @param port the port used to login to ONOS CLI
242 * @param user the user name to login to ONOS CLI
243 * @param pass the password to login to ONOS CLI
244 * @param command the command to run in ONOS CLI
245 * @return the output of the command
246 */
247def runOnosCliCmd(name, port, user, pass, command) {
248 return sh(returnStdout: true, script: "sshpass -p ${deployment_config.head.pass} ssh -oStrictHostKeyChecking=no -l ${deployment_config.head.user} ${deployment_config.head.ip} \"sshpass -p ${pass} ssh -oStrictHostKeyChecking=no -l ${user} -p ${port} ${name} ${command}\"")
249}