blob: 0a757a6234a92a946d5dc9ee5bfc6025c3e01818 [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001
2class OnosSanity4nodes :
3
4 def __init__(self) :
5 self.default = ''
6
adminbeea0032014-01-23 14:54:13 -08007#*****************************************************************************************************************************************************************************************
adminbae64d82013-08-01 10:50:15 -07008#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
Jon Hallf89c8552014-04-02 13:14:06 -070012 main.Zookeeper1.start()
13 main.Zookeeper2.start()
14 main.Zookeeper3.start()
15 main.Zookeeper4.start()
adminbae64d82013-08-01 10:50:15 -070016 main.log.report("Pulling latest code from github to all nodes")
17 main.ONOS1.git_pull()
18 main.ONOS2.git_pull()
19 main.ONOS3.git_pull()
20 main.ONOS4.git_pull()
admin7c10f642014-03-13 16:22:36 -070021 main.Cassandra1.stop()
22 main.Cassandra2.stop()
23 main.Cassandra3.stop()
24 main.Cassandra4.stop()
admine0ae8202013-08-28 11:51:43 -070025 main.Cassandra1.start()
26 main.Cassandra2.start()
27 main.Cassandra3.start()
28 main.Cassandra4.start()
29 time.sleep(20)
adminbae64d82013-08-01 10:50:15 -070030 main.ONOS1.drop_keyspace()
31 main.ONOS1.start()
32 time.sleep(10)
33 main.ONOS2.start()
34 main.ONOS3.start()
35 main.ONOS4.start()
36 main.ONOS1.start_rest()
admin530b4c92013-08-14 16:54:35 -070037 time.sleep(5)
admin68453302013-12-16 15:40:04 -080038 test= main.ONOS1.rest_status()
39 if test == main.FALSE:
40 main.ONOS1.start_rest()
adminbae64d82013-08-01 10:50:15 -070041 main.ONOS1.get_version()
42 main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections")
43 main.case("Checking if the startup was clean...")
44 main.step("Testing startup Zookeeper")
45 data = main.Zookeeper1.isup()
46 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
47 main.step("Testing startup Cassandra")
admin530b4c92013-08-14 16:54:35 -070048 data = main.Cassandra1.isup()
49 if data == main.FALSE:
50 main.Cassandra1.stop()
51 main.Cassandra2.stop()
52 main.Cassandra3.stop()
53 main.Cassandra4.stop()
54
55 time.sleep(5)
56
57 main.Cassandra1.start()
58 main.Cassandra2.start()
59 main.Cassandra3.start()
60 main.Cassandra4.start()
adminbae64d82013-08-01 10:50:15 -070061 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
62 main.step("Testing startup ONOS")
63 data = main.ONOS1.isup()
64 if data == main.FALSE:
65 main.log.report("Something is funny... restarting ONOS")
66 main.ONOS1.stop()
67 time.sleep(3)
68 main.ONOS1.start()
69 time.sleep(5)
70 data = main.ONOS1.isup()
71 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
72
73#**********************************************************************************************************************************************************************************************
74#Assign Controllers
75#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>).
76#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
77#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
78# the controllers already assigned to the switch are not specified.
79
80 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
81 import time
82 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
83 main.case("Checking if one MN host exists")
84 main.step("Host IP Checking using checkIP")
85 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
86 main.step("Verifying the result")
87 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
88 main.step("assigning ONOS controllers to switches")
89 for i in range(25):
90 if i < 3:
91 j=i+1
admin530b4c92013-08-14 16:54:35 -070092 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
adminbae64d82013-08-01 10:50:15 -070093 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -070094 main.Mininet1.assign_sw_controller(sw=str(j),count=4,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'])
adminbae64d82013-08-01 10:50:15 -070095 elif i >= 3 and i < 5:
96 j=i+1
admin530b4c92013-08-14 16:54:35 -070097 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
adminbae64d82013-08-01 10:50:15 -070098 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -070099 main.Mininet1.assign_sw_controller(sw=str(j),count=4,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'])
adminbae64d82013-08-01 10:50:15 -0700100 elif i >= 5 and i < 15:
101 j=i+1
admin530b4c92013-08-14 16:54:35 -0700102 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
adminbae64d82013-08-01 10:50:15 -0700103 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -0700104 main.Mininet1.assign_sw_controller(sw=str(j),count=4,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'])
adminbae64d82013-08-01 10:50:15 -0700105 else:
106 j=i+16
admin530b4c92013-08-14 16:54:35 -0700107 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
adminbae64d82013-08-01 10:50:15 -0700108 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -0700109 main.Mininet1.assign_sw_controller(sw=str(j),count=4,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'])
adminbae64d82013-08-01 10:50:15 -0700110 main.Mininet1.get_sw_controller("s1")
111
112# **********************************************************************************************************************************************************************************************
113#Add Flows
114#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
115#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
116
117 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
118 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
119 import time
120 main.case("Taking care of these flows!")
121 main.step("Cleaning out any leftover flows...")
122 main.ONOS1.delete_flow("all")
adminbae64d82013-08-01 10:50:15 -0700123 strtTime = time.time()
124 main.ONOS1.add_flow(main.params['FLOWDEF'])
125 main.case("Checking flows")
admin530b4c92013-08-14 16:54:35 -0700126
adminbae64d82013-08-01 10:50:15 -0700127 count = 1
128 i = 6
129 while i < 16 :
130 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
131 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800132 if ping == main.FALSE and count < 9:
adminbae64d82013-08-01 10:50:15 -0700133 count = count + 1
134 i = 6
admin68453302013-12-16 15:40:04 -0800135 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
136 time.sleep(2)
137 elif ping == main.FALSE and count ==9:
adminbae64d82013-08-01 10:50:15 -0700138 main.log.error("Ping test failed")
139 i = 17
admin68453302013-12-16 15:40:04 -0800140 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700141 elif ping == main.TRUE:
142 i = i + 1
admin68453302013-12-16 15:40:04 -0800143 result = main.TRUE
144 endTime = time.time()
145 if result == main.TRUE:
146 main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
admin530b4c92013-08-14 16:54:35 -0700147 else:
admin68453302013-12-16 15:40:04 -0800148 main.log.report("\tFlows failed check")
admin530b4c92013-08-14 16:54:35 -0700149
admin68453302013-12-16 15:40:04 -0800150 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin530b4c92013-08-14 16:54:35 -0700151 main.step("Verifying the result")
admin68453302013-12-16 15:40:04 -0800152 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
admin530b4c92013-08-14 16:54:35 -0700153
154#**********************************************************************************************************************************************************************************************
155#This test case removes Controllers 2,3, and 4 then performs a ping test.
156#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
157#The ping test performs single pings on hosts from opposite sides of the topology. If one ping fails, the test waits 5 seconds before trying again.
158#If the ping test fails 6 times, then the test case will return false
159
160 def CASE4(self,main) :
161 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
162 import time
163 for i in range(25):
164 if i < 15:
165 j=i+1
166 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) #Assigning a single controller removes all other controllers
167 else:
168 j=i+16
169 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
admine0ae8202013-08-28 11:51:43 -0700170
171 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700172 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800173 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700174 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800175 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700176 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
177 else:
178 break
179
admin530b4c92013-08-14 16:54:35 -0700180 count = 1
181 i = 6
182 while i < 16 :
183 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
184 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
185 if ping == main.FALSE and count < 6:
186 count = count + 1
187 i = 6
admin68453302013-12-16 15:40:04 -0800188 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
189 time.sleep(2)
admin530b4c92013-08-14 16:54:35 -0700190 elif ping == main.FALSE and count ==6:
191 main.log.error("Ping test failed")
192 i = 17
adminbae64d82013-08-01 10:50:15 -0700193 result = main.FALSE
194 elif ping == main.TRUE:
195 i = i + 1
196 result = main.TRUE
197 endTime = time.time()
198 if result == main.TRUE:
199 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
200 else:
201 main.log.report("\tPING TEST FAIL")
202 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
203
204# **********************************************************************************************************************************************************************************************
205#This test case restores the controllers removed by Case 4 then performs a ping test.
206
207 def CASE5(self,main) :
admin530b4c92013-08-14 16:54:35 -0700208 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
adminbae64d82013-08-01 10:50:15 -0700209 import time
210 for i in range(25):
211 if i < 15:
212 j=i+1
Jon Hallf89c8552014-04-02 13:14:06 -0700213 main.Mininet1.assign_sw_controller(sw=str(j),count=4,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'])
adminbae64d82013-08-01 10:50:15 -0700214 else:
215 j=i+16
Jon Hallf89c8552014-04-02 13:14:06 -0700216 main.Mininet1.assign_sw_controller(sw=str(j),count=4,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'])
admine0ae8202013-08-28 11:51:43 -0700217
218 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700219 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800220 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700221 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800222 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700223 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
224 else:
225 break
226
adminbae64d82013-08-01 10:50:15 -0700227 count = 1
228 i = 6
229 while i < 16 :
230 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
231 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin530b4c92013-08-14 16:54:35 -0700232 if ping == main.FALSE and count < 6:
adminbae64d82013-08-01 10:50:15 -0700233 count = count + 1
234 i = 6
admin68453302013-12-16 15:40:04 -0800235 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
236 time.sleep(2)
admin530b4c92013-08-14 16:54:35 -0700237 elif ping == main.FALSE and count ==6:
adminbae64d82013-08-01 10:50:15 -0700238 main.log.error("Ping test failed")
239 i = 17
240 result = main.FALSE
241 elif ping == main.TRUE:
242 i = i + 1
243 result = main.TRUE
244 endTime = time.time()
245 if result == main.TRUE:
246 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
247 else:
248 main.log.report("\tPING TEST FAILED")
249 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
250
251# **********************************************************************************************************************************************************************************************
252#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
253
254 def CASE6(self,main) :
admine0ae8202013-08-28 11:51:43 -0700255 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
adminbae64d82013-08-01 10:50:15 -0700256 import time
257 main.case("Bringing Link down... ")
258 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
adminbae64d82013-08-01 10:50:15 -0700259 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
admine0ae8202013-08-28 11:51:43 -0700260
261 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700262 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
admin68453302013-12-16 15:40:04 -0800263 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700264 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800265 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700266 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
267 else:
268 break
269
adminbae64d82013-08-01 10:50:15 -0700270 count = 1
271 i = 6
272 while i < 16 :
273 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
274 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700275 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700276 count = count + 1
admin68453302013-12-16 15:40:04 -0800277 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
adminbae64d82013-08-01 10:50:15 -0700278 i = 6
admin68453302013-12-16 15:40:04 -0800279 time.sleep(2)
admine0ae8202013-08-28 11:51:43 -0700280 elif ping == main.FALSE and count == 10:
adminbae64d82013-08-01 10:50:15 -0700281 main.log.error("Ping test failed")
282 i = 17
283 result = main.FALSE
284 elif ping == main.TRUE:
285 i = i + 1
286 result = main.TRUE
287 endTime = time.time()
288 if result == main.TRUE:
289 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
290 else:
291 main.log.report("\tPING TEST FAILED")
292 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
293
294# **********************************************************************************************************************************************************************************************
295#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
296
297 def CASE7(self,main) :
admine0ae8202013-08-28 11:51:43 -0700298 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
adminbae64d82013-08-01 10:50:15 -0700299 import time
300 main.case("Bringing Link up... ")
301 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
adminbae64d82013-08-01 10:50:15 -0700302 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
admine0ae8202013-08-28 11:51:43 -0700303
304 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700305 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800306 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700307 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800308 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700309 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
310 else:
311 break
312
adminbae64d82013-08-01 10:50:15 -0700313 strtTime = time.time()
314 count = 1
315 i = 6
316 while i < 16 :
317 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
318 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700319 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700320 count = count + 1
admin68453302013-12-16 15:40:04 -0800321 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
adminbae64d82013-08-01 10:50:15 -0700322 i = 6
admin68453302013-12-16 15:40:04 -0800323 time.sleep(2)
admine0ae8202013-08-28 11:51:43 -0700324 elif ping == main.FALSE and count ==10:
adminbae64d82013-08-01 10:50:15 -0700325 main.log.error("Ping test failed")
326 i = 17
327 result = main.FALSE
328 elif ping == main.TRUE:
329 i = i + 1
330 result = main.TRUE
331 endTime = time.time()
332 if result == main.TRUE:
333 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
334 else:
335 main.log.report("\tPING TESTS FAILED")
336 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
337
admin530b4c92013-08-14 16:54:35 -0700338
339# ******************************************************************************************************************************************************************
340# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
341
342 def CASE21(self,main) :
343 import json
adminbeea0032014-01-23 14:54:13 -0800344 main.log.report("Test device discovery function, by attach, detach, move host h1 from s1->s6->s1. Per mininet naming, switch port the host attaches will remain as 's1-eth1' throughout the test.")
admin68453302013-12-16 15:40:04 -0800345 main.log.report("Check initially hostMAC/IP exist on the mininet...")
admin530b4c92013-08-14 16:54:35 -0700346 host = main.params['YANK']['hostname']
347 mac = main.params['YANK']['hostmac']
admin68453302013-12-16 15:40:04 -0800348 hostip = main.params['YANK']['hostip']
admin530b4c92013-08-14 16:54:35 -0700349 RestIP1 = main.params['RESTCALL']['restIP1']
admin530b4c92013-08-14 16:54:35 -0700350 RestPort = main.params['RESTCALL']['restPort']
351 url = main.params['RESTCALL']['restURL']
admin68453302013-12-16 15:40:04 -0800352
adminbeea0032014-01-23 14:54:13 -0800353 t_topowait = 0
354 t_restwait = 10
355 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
356 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
357 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
358 time.sleep(t_topowait)
admin530b4c92013-08-14 16:54:35 -0700359 main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
360 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800361 time.sleep(t_restwait)
Jon Hallf89c8552014-04-02 13:14:06 -0700362 Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin68453302013-12-16 15:40:04 -0800363 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
admin530b4c92013-08-14 16:54:35 -0700364 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800365 main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
admin68453302013-12-16 15:40:04 -0800366 result1 = main.TRUE
367 elif Reststatus > 1:
368 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800369 main.log.report("switches are: " + "; ".join(Switch))
370 main.log.report("Ports are: " + "; ".join(Port))
371 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800372 result1 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700373 else:
admin68453302013-12-16 15:40:04 -0800374 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
375 result1 = main.FALSE
376
admin530b4c92013-08-14 16:54:35 -0700377
378 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
379
380 main.log.report("Yank out s1-eth1")
Jon Hallf89c8552014-04-02 13:14:06 -0700381 main.step("Yankout s6-eth1 (link to h1) from s1")
admin530b4c92013-08-14 16:54:35 -0700382 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
adminbeea0032014-01-23 14:54:13 -0800383 time.sleep(t_topowait)
admin530b4c92013-08-14 16:54:35 -0700384 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
admin68453302013-12-16 15:40:04 -0800385
386 main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
admin530b4c92013-08-14 16:54:35 -0700387 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800388 time.sleep(t_restwait)
Jon Hallf89c8552014-04-02 13:14:06 -0700389 Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin68453302013-12-16 15:40:04 -0800390
391 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
392 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800393 main.log.report("\tFAILED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
admin68453302013-12-16 15:40:04 -0800394 result2 = main.FALSE
395 elif Reststatus > 1:
396 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800397 main.log.report("switches are: " + "; ".join(Switch))
398 main.log.report("Ports are: " + "; ".join(Port))
399 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800400 result2 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700401 else:
admin68453302013-12-16 15:40:04 -0800402 main.log.report("\t PASSED - Host " + host + " with MAC:" + str(mac) + " does not exist. PASSED - host is not supposed to be attached to the switch.")
403 result2 = main.TRUE
404
admin530b4c92013-08-14 16:54:35 -0700405 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
406 main.log.report("Plug s1-eth1 into s6")
Jon Hallf89c8552014-04-02 13:14:06 -0700407 main.step("Plug s1-eth1 to s6")
admin530b4c92013-08-14 16:54:35 -0700408 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
adminbeea0032014-01-23 14:54:13 -0800409 time.sleep(t_topowait)
admin530b4c92013-08-14 16:54:35 -0700410 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
admin68453302013-12-16 15:40:04 -0800411 main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
412
admin530b4c92013-08-14 16:54:35 -0700413 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800414 time.sleep(t_restwait)
Jon Hallf89c8552014-04-02 13:14:06 -0700415 Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin68453302013-12-16 15:40:04 -0800416
417 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
418 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800419 main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
admin68453302013-12-16 15:40:04 -0800420 result3 = main.TRUE
421 elif Reststatus > 1:
422 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800423 main.log.report("switches are: " + "; ".join(Switch))
424 main.log.report("Ports are: " + "; ".join(Port))
425 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800426 result3 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700427 else:
admin68453302013-12-16 15:40:04 -0800428 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
429 result3 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700430
431 ###### Step to put interface "s1-eth1" back to s1"#####
432 main.log.report("Move s1-eth1 back on to s1")
Jon Hallf89c8552014-04-02 13:14:06 -0700433 main.step("Move s1-eth1 back to s1")
admin530b4c92013-08-14 16:54:35 -0700434 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
adminbeea0032014-01-23 14:54:13 -0800435 time.sleep(t_topowait)
Jon Hallf89c8552014-04-02 13:14:06 -0700436 result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
admin530b4c92013-08-14 16:54:35 -0700437 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
admin68453302013-12-16 15:40:04 -0800438 main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
439
admin530b4c92013-08-14 16:54:35 -0700440 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800441 time.sleep(t_restwait)
Jon Hallf89c8552014-04-02 13:14:06 -0700442 Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin68453302013-12-16 15:40:04 -0800443
444 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
445 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800446 main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
admin68453302013-12-16 15:40:04 -0800447 result4 = main.TRUE
448 elif Reststatus > 1:
admin7c10f642014-03-13 16:22:36 -0700449 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800450 main.log.report("switches are: " + "; ".join(Switch))
451 main.log.report("Ports are: " + "; ".join(Port))
452 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800453 result4 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700454 else:
admin68453302013-12-16 15:40:04 -0800455 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
456 result4 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700457
admin68453302013-12-16 15:40:04 -0800458 result = result1 and result2 and result3 and result4
admin530b4c92013-08-14 16:54:35 -0700459 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
460
adminbeea0032014-01-23 14:54:13 -0800461# Run a pure ping test.
462
463 def CASE31(self, main):
464 main.log.report("Performing Ping Test")
465 count = 1
466 i = 6
467 while i < 16 :
468 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
admin7c10f642014-03-13 16:22:36 -0700469 strtTime = time.time()
adminbeea0032014-01-23 14:54:13 -0800470 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
471 if ping == main.FALSE and count < 6:
472 count = count + 1
473 i = 6
474 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
475 time.sleep(2)
476 elif ping == main.FALSE and count ==6:
477 main.log.error("Ping test failed")
478 i = 17
479 result = main.FALSE
480 elif ping == main.TRUE:
481 i = i + 1
482 result = main.TRUE
483 endTime = time.time()
484 if result == main.TRUE:
485 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
486 else:
487 main.log.report("\tPING TEST FAIL")
488 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
admin530b4c92013-08-14 16:54:35 -0700489