blob: c98c406b942fdcb27ea7e1c655b94e30f632af5e [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 Khalasie48bad02018-05-01 09:20:51 -070018node ("${devNodeName}") {
You Wang4eefdc82017-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 Wang4eefdc82017-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 }
Kailash Khalasiecf30142018-01-24 15:16:45 -080031 stage('Bring up Cord-Test Container') {
32 runHeadNodeCmd("""
33 cd /opt/cord/test/cord-tester/src/test/setup
34 sudo ./cord-test.py setup -m manifest-onf-cord.json
35 """)
36 }
You Wang9d616dd2018-01-22 14:10:28 -080037 stage('Configure Fabric for E2E testing') {
38 //FIXME: this only works for PODs with 2 leaf switches
39 fabricIpPrefix = pod_config.fabric_ip.split(/\.\d+\.\d+\/24/)[0]
40 runHeadNodeCmd("sudo ip route add ${fabricIpPrefix}.2.0/24 via ${fabricIpPrefix}.1.254 || echo route already exists")
41 runHeadNodeCmd("sudo route add -net 10.7.1.0/24 gw 10.6.1.254 || echo route already exists")
42 runHeadNodeCmd("sudo route add -net 10.8.1.0/24 gw 10.6.1.254 || echo route already exists")
43 runHeadNodeCmd("ping -c 1 ${fabricIpPrefix}.1.254", "-qftn")
44 runOnosCliCmd("onos-fabric", "8101", "onos", "rocks", "route-add 0.0.0.0/0 ${fabricIpPrefix}.1.1")
45 // Verify ONOS has recognized the hosts
46 timeout(time: 5) {
47 waitUntil {
48 try {
49 num = runHeadNodeCmd("\"sshpass -p rocks ssh -q -oStrictHostKeyChecking=no -l onos -p 8101 onos-fabric hosts | grep id= | wc -l\"").trim()
50 return num.toInteger() == deployment_config.compute_nodes.size() + 1
51 } catch (exception) {
52 return false
53 }
54 }
55 }
56 // Generate network configuration
57 runHeadNodeCmd("""
58 cd /opt/cord_profile/
59 cp fabric-network-cfg.json fabric-network-cfg.json.\$(date +%Y%m%d-%H%M%S)
60 cord generate > fabric-network-cfg.json
61 """)
You Wange8c3b542018-02-06 15:58:04 -080062 // Install httpie on the head-node
63 runHeadNodeCmd("sudo pip install httpie")
You Wang9d616dd2018-01-22 14:10:28 -080064 // Delete old ONOS netcfg
65 runHeadNodeCmd("http -a onos:rocks DELETE http://onos-fabric:8181/onos/v1/network/configuration/")
66 // Load new configuration
67 runHeadNodeCmd("http -a onos:rocks POST http://onos-fabric:8181/onos/v1/network/configuration/ < /opt/cord_profile/fabric-network-cfg.json")
68 // Restart ONOS apps
69 runHeadNodeCmd("""
70 http -a onos:rocks DELETE http://onos-fabric:8181/onos/v1/applications/org.onosproject.segmentrouting/active; sleep 5
71 http -a onos:rocks POST http://onos-fabric:8181/onos/v1/applications/org.onosproject.segmentrouting/active; sleep 5
72 """)
73 }
You Wang4eefdc82017-11-17 13:58:55 -080074 stage('Verify Collect Diag') {
75 timeout(10) {
76 try {
77 runHeadNodeCmd("""
78 rm -rf ~/diag-*
79 cd /opt/cord/build; make collect-diag
80 cd /opt/cord/test/cord-tester/src/test/diag/
81 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080082 rm -r TestDoc/ || true
83 mkdir TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -080084 pybot -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T verifyCollectDiag.robot
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080085 python -m robot.testdoc verifyCollectDiag.robot TestDoc/verifyCollectDiag.html
You Wang4eefdc82017-11-17 13:58:55 -080086 """)
87 } catch(error) { currentBuild.result = 'FAILURE' }
88 }
89 }
90 stage('Sanity Test') {
91 timeout(10) {
92 try {
93 runHeadNodeCmd("""
94 cd /opt/cord/test/cord-tester/src/test/robot/
95 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080096 rm -r TestDoc/ || true
97 mkdir TestDoc
You Wang4eefdc82017-11-17 13:58:55 -080098 """)
99 if (deployment_config.fabric_switches != null) {
100 runHeadNodeCmd("""
101 cd /opt/cord/test/cord-tester/src/test/robot/
102 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 -0800103 python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html
You Wang4eefdc82017-11-17 13:58:55 -0800104 """)
105 }
106 else {
107 // Exclude fabric related tests
108 runHeadNodeCmd("""
109 cd /opt/cord/test/cord-tester/src/test/robot/
110 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 -0800111 python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html
You Wang4eefdc82017-11-17 13:58:55 -0800112 """)
113 }
114 } catch(error) { currentBuild.result = 'FAILURE' }
115 }
116 }
117 stage('XOS API Tests') {
118 timeout(10) {
119 try {
120 runHeadNodeCmd("""
121 cd /opt/cord/test/cord-tester/src/test/cord-api/Properties/
122 sed -i s/^SERVER_IP\\ =\\ .*/SERVER_IP\\ =\\ \\'localhost\\'/ RestApiProperties.py
123 sed -i s/^SERVER_PORT\\ =\\ .*/SERVER_PORT\\ =\\ \\'9101\\'/ RestApiProperties.py
124 sed -i s/^PASSWD\\ =\\ .*/PASSWD\\ =\\ \\'\\\$(cat /opt/credentials/xosadmin@opencord.org)\\'/ RestApiProperties.py
125 all_passed=true
126 cd /opt/cord/test/cord-tester/src/test/cord-api/
127 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800128 rm -r TestDoc/ || true
129 mkdir TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -0800130 pybot -d Log -T Tests/Ch_defaultImagesCheck.txt || all_passed=false
131 pybot -d Log -T -v PROFILE:${pod_config.cord_profile} Tests/Ch_DefaultServiceCheck.txt || all_passed=false
132 pybot -d Log -T Tests/Ch_SubscriberTest.txt || all_passed=false
133 pybot -d Log -T Tests/Ch_VoltTenant.txt || all_passed=false
134 pybot -d Log -T Tests/Ch_ServiceTest.txt || all_passed=false
135 pybot -d Log -T Tests/Ch_UsersTest.txt || all_passed=false
136 pybot -d Log -T Tests/Ch_DeploymentTest.txt || all_passed=false
137 pybot -d Log -T Tests/Ch_NodeTest.txt || all_passed=false
138 pybot -d Log -T Tests/Ch_SliceTest.txt || all_passed=false
139 pybot -d Log -T Tests/Ch_SanityInstance.txt || all_passed=false
140 pybot -d Log -T Tests/Ch_SanityFlavors.txt || all_passed=false
141 pybot -d Log -T Tests/Ch_SiteTest.txt || all_passed=false
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800142 python -m robot.testdoc Tests/Ch_*.txt TestDoc/XOSApiTests.html
You Wang4eefdc82017-11-17 13:58:55 -0800143 if [ "\\\$all_passed" = true ]; then exit 0; else exit 1; fi
144 """)
145 } catch(error) { currentBuild.result = 'FAILURE' }
146 }
147 }
Kailash Khalasi383dca82018-02-09 13:34:31 -0800148 stage('Dataplane Test') {
Kailash Khalasi7a1d1622018-02-10 12:26:39 -0800149 timeout(30) {
Kailash Khalasiecf30142018-01-24 15:16:45 -0800150 try {
151 runHeadNodeCmd("""
152 cd /opt/cord/test/cord-tester/src/test/vsg/
153 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800154 rm -r TestDoc/ || true
Kailash Khalasi383dca82018-02-09 13:34:31 -0800155 mkdir TestDoc
Kailash Khalasiecf30142018-01-24 15:16:45 -0800156 """)
Kailash Khalasi383dca82018-02-09 13:34:31 -0800157 if (deployment_config.pod_config.file_name != 'calix-pod1.yml') {
158 runHeadNodeCmd("""
159 cd /opt/cord/test/cord-tester/src/test/vsg/
160 pybot -L TRACE -v pod:${deployment_config.pod_config.file_name} -d Log -T vsg_dataplane_test.robot
161 python -m robot.testdoc vsg_dataplane_test.robot TestDoc/vsg_dataplane_test.html
162 """)
163 }
164 else {
165 runHeadNodeCmd("""
166 cd /opt/cord/test/cord-tester/src/test/vsg/
167 pybot -L TRACE -v pod:${deployment_config.pod_config.file_name} -e dataplane -d Log -T vsg_dataplane_test.robot
168 python -m robot.testdoc vsg_dataplane_test.robot TestDoc/vsg_dataplane_test.html
169 """)
170 }
Kailash Khalasiecf30142018-01-24 15:16:45 -0800171 } catch(error) { currentBuild.result = 'FAILURE' }
Kailash Khalasi383dca82018-02-09 13:34:31 -0800172 }
173 }
You Wang4eefdc82017-11-17 13:58:55 -0800174 stage('Publish') {
175 try {
176 sh """
Kailash Khalasi626e0d82018-02-08 11:26:37 -0800177 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs;
178 mkdir RobotLogs/TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -0800179 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/Log/* ./RobotLogs || true
180 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/Log/* ./RobotLogs || true
181 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 -0800182 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/vsg/Log/* ./RobotLogs || true
Kailash Khalasi626e0d82018-02-08 11:26:37 -0800183 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/TestDoc/* ./RobotLogs/TestDoc || true
184 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/TestDoc/* ./RobotLogs/TestDoc || true
185 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/TestDoc/* ./RobotLogs/TestDoc || true
186 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 -0800187 """
188 step([$class: 'RobotPublisher',
189 disableArchiveOutput: false,
190 logFileName: 'RobotLogs/log*.html',
Kailash Khalasi626e0d82018-02-08 11:26:37 -0800191 otherFiles: 'RobotLogs/TestDoc/*.html',
You Wang4eefdc82017-11-17 13:58:55 -0800192 outputFileName: 'RobotLogs/output*.xml',
193 outputPath: '.',
194 passThreshold: 100,
195 reportFileName: 'RobotLogs/report*.html',
196 unstableThreshold: 0])
197 } catch(error) {}
198 }
199 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
200}
201
202/**
203 * Runs a command on the head node.
204 *
205 * @param command the command to run
206 * @param sshArgs arguments for the ssh command
207 * @return the output of the command
208 */
209def runHeadNodeCmd(command, sshArgs="") {
210 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}\"")
211}
You Wang9d616dd2018-01-22 14:10:28 -0800212
213/**
214 * Runs an ONOS CLI command
215 *
216 * @param name the onos node name, reachable from the head node
217 * @param port the port used to login to ONOS CLI
218 * @param user the user name to login to ONOS CLI
219 * @param pass the password to login to ONOS CLI
220 * @param command the command to run in ONOS CLI
221 * @return the output of the command
222 */
223def runOnosCliCmd(name, port, user, pass, command) {
224 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}\"")
225}