blob: 54d390ac9735399fb933984cd80e27361490599f [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 }
Kailash Khalasiecf30142018-01-24 15:16:45 -080034 stage('Bring up Cord-Test Container') {
35 runHeadNodeCmd("""
36 cd /opt/cord/test/cord-tester/src/test/setup
37 sudo ./cord-test.py setup -m manifest-onf-cord.json
38 """)
39 }
You Wang9d616dd2018-01-22 14:10:28 -080040 stage('Configure Fabric for E2E testing') {
41 //FIXME: this only works for PODs with 2 leaf switches
42 fabricIpPrefix = pod_config.fabric_ip.split(/\.\d+\.\d+\/24/)[0]
43 runHeadNodeCmd("sudo ip route add ${fabricIpPrefix}.2.0/24 via ${fabricIpPrefix}.1.254 || echo route already exists")
44 runHeadNodeCmd("sudo route add -net 10.7.1.0/24 gw 10.6.1.254 || echo route already exists")
45 runHeadNodeCmd("sudo route add -net 10.8.1.0/24 gw 10.6.1.254 || echo route already exists")
46 runHeadNodeCmd("ping -c 1 ${fabricIpPrefix}.1.254", "-qftn")
47 runOnosCliCmd("onos-fabric", "8101", "onos", "rocks", "route-add 0.0.0.0/0 ${fabricIpPrefix}.1.1")
48 // Verify ONOS has recognized the hosts
49 timeout(time: 5) {
50 waitUntil {
51 try {
52 num = runHeadNodeCmd("\"sshpass -p rocks ssh -q -oStrictHostKeyChecking=no -l onos -p 8101 onos-fabric hosts | grep id= | wc -l\"").trim()
53 return num.toInteger() == deployment_config.compute_nodes.size() + 1
54 } catch (exception) {
55 return false
56 }
57 }
58 }
59 // Generate network configuration
60 runHeadNodeCmd("""
61 cd /opt/cord_profile/
62 cp fabric-network-cfg.json fabric-network-cfg.json.\$(date +%Y%m%d-%H%M%S)
63 cord generate > fabric-network-cfg.json
64 """)
65 // 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
You Wang4eefdc82017-11-17 13:58:55 -080085 pybot -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T verifyCollectDiag.robot
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080086 python -m robot.testdoc verifyCollectDiag.robot TestDoc/verifyCollectDiag.html
You Wang4eefdc82017-11-17 13:58:55 -080087 """)
88 } catch(error) { currentBuild.result = 'FAILURE' }
89 }
90 }
91 stage('Sanity Test') {
92 timeout(10) {
93 try {
94 runHeadNodeCmd("""
95 cd /opt/cord/test/cord-tester/src/test/robot/
96 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -080097 rm -r TestDoc/ || true
98 mkdir TestDoc
You Wang4eefdc82017-11-17 13:58:55 -080099 """)
100 if (deployment_config.fabric_switches != null) {
101 runHeadNodeCmd("""
102 cd /opt/cord/test/cord-tester/src/test/robot/
103 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 -0800104 python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html
You Wang4eefdc82017-11-17 13:58:55 -0800105 """)
106 }
107 else {
108 // Exclude fabric related tests
109 runHeadNodeCmd("""
110 cd /opt/cord/test/cord-tester/src/test/robot/
111 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 -0800112 python -m robot.testdoc SanityPhyPOD.robot TestDoc/SanityPhyPOD.html
You Wang4eefdc82017-11-17 13:58:55 -0800113 """)
114 }
115 } catch(error) { currentBuild.result = 'FAILURE' }
116 }
117 }
118 stage('XOS API Tests') {
119 timeout(10) {
120 try {
121 runHeadNodeCmd("""
122 cd /opt/cord/test/cord-tester/src/test/cord-api/Properties/
123 sed -i s/^SERVER_IP\\ =\\ .*/SERVER_IP\\ =\\ \\'localhost\\'/ RestApiProperties.py
124 sed -i s/^SERVER_PORT\\ =\\ .*/SERVER_PORT\\ =\\ \\'9101\\'/ RestApiProperties.py
125 sed -i s/^PASSWD\\ =\\ .*/PASSWD\\ =\\ \\'\\\$(cat /opt/credentials/xosadmin@opencord.org)\\'/ RestApiProperties.py
126 all_passed=true
127 cd /opt/cord/test/cord-tester/src/test/cord-api/
128 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800129 rm -r TestDoc/ || true
130 mkdir TestDoc || true
You Wang4eefdc82017-11-17 13:58:55 -0800131 pybot -d Log -T Tests/Ch_defaultImagesCheck.txt || all_passed=false
132 pybot -d Log -T -v PROFILE:${pod_config.cord_profile} Tests/Ch_DefaultServiceCheck.txt || all_passed=false
133 pybot -d Log -T Tests/Ch_SubscriberTest.txt || all_passed=false
134 pybot -d Log -T Tests/Ch_VoltTenant.txt || all_passed=false
135 pybot -d Log -T Tests/Ch_ServiceTest.txt || all_passed=false
136 pybot -d Log -T Tests/Ch_UsersTest.txt || all_passed=false
137 pybot -d Log -T Tests/Ch_DeploymentTest.txt || all_passed=false
138 pybot -d Log -T Tests/Ch_NodeTest.txt || all_passed=false
139 pybot -d Log -T Tests/Ch_SliceTest.txt || all_passed=false
140 pybot -d Log -T Tests/Ch_SanityInstance.txt || all_passed=false
141 pybot -d Log -T Tests/Ch_SanityFlavors.txt || all_passed=false
142 pybot -d Log -T Tests/Ch_SiteTest.txt || all_passed=false
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800143 python -m robot.testdoc Tests/Ch_*.txt TestDoc/XOSApiTests.html
You Wang4eefdc82017-11-17 13:58:55 -0800144 if [ "\\\$all_passed" = true ]; then exit 0; else exit 1; fi
145 """)
146 } catch(error) { currentBuild.result = 'FAILURE' }
147 }
148 }
Kailash Khalasiecf30142018-01-24 15:16:45 -0800149 stage('Dataplane Test') {
150 timeout(10) {
151 try {
152 runHeadNodeCmd("""
153 cd /opt/cord/test/cord-tester/src/test/vsg/
154 rm -r Log/ || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800155 rm -r TestDoc/ || true
156 mkdir TestDoc || true
Kailash Khalasiecf30142018-01-24 15:16:45 -0800157 ssh-agent bash
158 ssh-add
159 pybot -L TRACE -d Log -T vsg_dataplane_test.robot
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800160 python -m robot.testdoc vsg_dataplane_test.robot TestDoc/vsg_dataplane_test.html
Kailash Khalasiecf30142018-01-24 15:16:45 -0800161 """)
162 } catch(error) { currentBuild.result = 'FAILURE' }
163 }
164 }
You Wang4eefdc82017-11-17 13:58:55 -0800165 stage('Publish') {
166 try {
167 sh """
168 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
169 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/Log/* ./RobotLogs || true
170 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/Log/* ./RobotLogs || true
171 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 -0800172 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/vsg/Log/* ./RobotLogs || true
Kailash Khalasi3d1c4d72018-01-30 12:10:28 -0800173 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/TestDoc/* ./RobotLogs/TestDocs || true
174 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/TestDoc/* ./RobotLogs/TestDocs || true
175 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/TestDoc/* ./RobotLogs/TestDocs || true
176 scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/vsg/TestDoc/* ./RobotLogs/TestDocs || true
You Wang4eefdc82017-11-17 13:58:55 -0800177 """
178 step([$class: 'RobotPublisher',
179 disableArchiveOutput: false,
180 logFileName: 'RobotLogs/log*.html',
Kailash Khalasi9f4029a2018-02-01 09:29:52 -0800181 otherFiles: 'RobotLogs/TestDocs/*.html',
You Wang4eefdc82017-11-17 13:58:55 -0800182 outputFileName: 'RobotLogs/output*.xml',
183 outputPath: '.',
184 passThreshold: 100,
185 reportFileName: 'RobotLogs/report*.html',
186 unstableThreshold: 0])
187 } catch(error) {}
188 }
189 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
190}
191
192/**
193 * Runs a command on the head node.
194 *
195 * @param command the command to run
196 * @param sshArgs arguments for the ssh command
197 * @return the output of the command
198 */
199def runHeadNodeCmd(command, sshArgs="") {
200 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}\"")
201}
You Wang9d616dd2018-01-22 14:10:28 -0800202
203/**
204 * Runs an ONOS CLI command
205 *
206 * @param name the onos node name, reachable from the head node
207 * @param port the port used to login to ONOS CLI
208 * @param user the user name to login to ONOS CLI
209 * @param pass the password to login to ONOS CLI
210 * @param command the command to run in ONOS CLI
211 * @return the output of the command
212 */
213def runOnosCliCmd(name, port, user, pass, command) {
214 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}\"")
215}