blob: ef3b47a4c86ba77300c83f05e1b9d90b701079d9 [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001
2class OnosSanity4nodes :
3
4 def __init__(self) :
5 self.default = ''
6
7#**********************************************************************************************************************************************************************************************
8#Test startup
9#Tests the startup of Zookeeper1, Cassandra1, and ONOS1 to be certain that all started up successfully
10 def CASE1(self,main) : #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version
11 import time
12 main.log.report("Pulling latest code from github to all nodes")
13 main.ONOS1.git_pull()
14 main.ONOS2.git_pull()
15 main.ONOS3.git_pull()
16 main.ONOS4.git_pull()
17 main.ONOS1.drop_keyspace()
18 main.ONOS1.start()
19 time.sleep(10)
20 main.ONOS2.start()
21 main.ONOS3.start()
22 main.ONOS4.start()
23 main.ONOS1.start_rest()
24 main.ONOS1.get_version()
25 main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections")
26 main.case("Checking if the startup was clean...")
27 main.step("Testing startup Zookeeper")
28 data = main.Zookeeper1.isup()
29 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
30 main.step("Testing startup Cassandra")
31 data = main.Cassandra1.isup()
32 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
33 main.step("Testing startup ONOS")
34 data = main.ONOS1.isup()
35 if data == main.FALSE:
36 main.log.report("Something is funny... restarting ONOS")
37 main.ONOS1.stop()
38 time.sleep(3)
39 main.ONOS1.start()
40 time.sleep(5)
41 data = main.ONOS1.isup()
42 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
43
44#**********************************************************************************************************************************************************************************************
45#Assign Controllers
46#This test first checks the ip of a mininet host, to be certain that the mininet exists(Host is defined in Params as <CASE1><destination>).
47#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
48#NOTE: The reason why all four controllers are assigned although one was already assigned as the master is due to the 'ovs-vsctl set-controller' command erases all present controllers if
49# the controllers already assigned to the switch are not specified.
50
51 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
52 import time
53 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
54 main.case("Checking if one MN host exists")
55 main.step("Host IP Checking using checkIP")
56 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
57 main.step("Verifying the result")
58 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
59 main.step("assigning ONOS controllers to switches")
60 for i in range(25):
61 if i < 3:
62 j=i+1
63 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
64 time.sleep(1)
65 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
66 time.sleep(1)
67 elif i >= 3 and i < 5:
68 j=i+1
69 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
70 time.sleep(1)
71 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
72 time.sleep(1)
73 elif i >= 5 and i < 15:
74 j=i+1
75 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
76 time.sleep(1)
77 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
78 time.sleep(1)
79 else:
80 j=i+16
81 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
82 time.sleep(1)
83 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
84 time.sleep(1)
85 main.Mininet1.get_sw_controller("s1")
86
87# **********************************************************************************************************************************************************************************************
88#Add Flows
89#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
90#NOTE: THE FLOWDEF FILE MUST BE PRESENT ON TESTON VM!!! TestON will copy the file from its home machine into /tmp/flowtmp on the machine the ONOS instance is present on
91
92 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
93 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
94 import time
95 main.case("Taking care of these flows!")
96 main.step("Cleaning out any leftover flows...")
97 main.ONOS1.delete_flow("all")
98 time.sleep(5)
99 strtTime = time.time()
100 main.ONOS1.add_flow(main.params['FLOWDEF'])
101 main.case("Checking flows")
102 tmp = main.FALSE
103 count = 1
104 main.log.info("Wait for flows to settle, then check")
105 while tmp == main.FALSE:
106 main.step("Waiting")
107 time.sleep(10)
108 main.step("Checking")
109 tmp = main.ONOS1.check_flow()
110 if tmp == main.FALSE and count < 6:
111 count = count + 1
112 main.log.report("Flow failed, waiting 10 seconds then making attempt number "+str(count))
113 elif tmp == main.FALSE and count == 6:
114 result = main.FALSE
115 break
116 else:
117 result = main.TRUE
118 break
119 endTime = time.time()
120 if result == main.TRUE:
121 main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
122 else:
123 main.log.report("\tFlows failed check")
124 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
125
126#**********************************************************************************************************************************************************************************************
127#This test case removes Controllers 2,3, and 4 then performs a ping test.
128#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
129#The ping test performs single pings on hosts from opposite sides of the topology. If one ping fails, the test waits 10 seconds before trying again.
130#If the ping test fails 6 times, then the test case will return false
131
132 def CASE4(self,main) :
133 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 3 attempts")
134 import time
135 for i in range(25):
136 if i < 15:
137 j=i+1
138 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) #Assigning a single controller removes all other controllers
139 time.sleep(1)
140 else:
141 j=i+16
142 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
143 time.sleep(1)
144 strtTime = time.time()
145 count = 1
146 i = 6
147 while i < 16 :
148 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
149 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
150 if ping == main.FALSE and count < 3:
151 count = count + 1
152 i = 6
153 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
154 time.sleep(10)
155 elif ping == main.FALSE and count ==3:
156 main.log.error("Ping test failed")
157 i = 17
158 result = main.FALSE
159 elif ping == main.TRUE:
160 i = i + 1
161 result = main.TRUE
162 endTime = time.time()
163 if result == main.TRUE:
164 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
165 else:
166 main.log.report("\tPING TEST FAIL")
167 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
168
169# **********************************************************************************************************************************************************************************************
170#This test case restores the controllers removed by Case 4 then performs a ping test.
171
172 def CASE5(self,main) :
173 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 3 attempts")
174 import time
175 for i in range(25):
176 if i < 15:
177 j=i+1
178 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
179 time.sleep(1)
180 else:
181 j=i+16
182 main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
183 time.sleep(1)
184 strtTime = time.time()
185 count = 1
186 i = 6
187 while i < 16 :
188 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
189 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
190 if ping == main.FALSE and count < 3:
191 count = count + 1
192 i = 6
193 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
194 time.sleep(10)
195 elif ping == main.FALSE and count ==3:
196 main.log.error("Ping test failed")
197 i = 17
198 result = main.FALSE
199 elif ping == main.TRUE:
200 i = i + 1
201 result = main.TRUE
202 endTime = time.time()
203 if result == main.TRUE:
204 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
205 else:
206 main.log.report("\tPING TEST FAILED")
207 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
208
209# **********************************************************************************************************************************************************************************************
210#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
211
212 def CASE6(self,main) :
213 main.log.report("Bring Link between s1 and s2 down, wait 20 seconds, then ping until all hosts are reachable or fail after 3 attempts")
214 import time
215 main.case("Bringing Link down... ")
216 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
217 time.sleep(20)
218 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
219 strtTime = time.time()
220 count = 1
221 i = 6
222 while i < 16 :
223 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
224 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
225 if ping == main.FALSE and count < 3:
226 count = count + 1
227 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
228 i = 6
229 time.sleep(10)
230 elif ping == main.FALSE and count ==3:
231 main.log.error("Ping test failed")
232 i = 17
233 result = main.FALSE
234 elif ping == main.TRUE:
235 i = i + 1
236 result = main.TRUE
237 endTime = time.time()
238 if result == main.TRUE:
239 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
240 else:
241 main.log.report("\tPING TEST FAILED")
242 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
243
244# **********************************************************************************************************************************************************************************************
245#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
246
247 def CASE7(self,main) :
248 main.log.report("Bring Link between s1 and s2 up, wait 20 seconds, then ping until all hosts are reachable or fail after 3 attempts")
249 import time
250 main.case("Bringing Link up... ")
251 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
252 time.sleep(20)
253 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
254 strtTime = time.time()
255 count = 1
256 i = 6
257 while i < 16 :
258 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
259 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
260 if ping == main.FALSE and count < 3:
261 count = count + 1
262 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
263 i = 6
264 time.sleep(10)
265 elif ping == main.FALSE and count ==3:
266 main.log.error("Ping test failed")
267 i = 17
268 result = main.FALSE
269 elif ping == main.TRUE:
270 i = i + 1
271 result = main.TRUE
272 endTime = time.time()
273 if result == main.TRUE:
274 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
275 else:
276 main.log.report("\tPING TESTS FAILED")
277 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
278