blob: 6cd45fd4b411fa4431af2606bd3cad0befe5401f [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
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()
admine0ae8202013-08-28 11:51:43 -070017 main.Cassandra1.start()
18 main.Cassandra2.start()
19 main.Cassandra3.start()
20 main.Cassandra4.start()
21 time.sleep(20)
adminbae64d82013-08-01 10:50:15 -070022 main.ONOS1.drop_keyspace()
23 main.ONOS1.start()
24 time.sleep(10)
25 main.ONOS2.start()
26 main.ONOS3.start()
27 main.ONOS4.start()
28 main.ONOS1.start_rest()
admin530b4c92013-08-14 16:54:35 -070029 time.sleep(5)
admin68453302013-12-16 15:40:04 -080030 test= main.ONOS1.rest_status()
31 if test == main.FALSE:
32 main.ONOS1.start_rest()
adminbae64d82013-08-01 10:50:15 -070033 main.ONOS1.get_version()
34 main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections")
35 main.case("Checking if the startup was clean...")
36 main.step("Testing startup Zookeeper")
37 data = main.Zookeeper1.isup()
38 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
39 main.step("Testing startup Cassandra")
admin530b4c92013-08-14 16:54:35 -070040 data = main.Cassandra1.isup()
41 if data == main.FALSE:
42 main.Cassandra1.stop()
43 main.Cassandra2.stop()
44 main.Cassandra3.stop()
45 main.Cassandra4.stop()
46
47 time.sleep(5)
48
49 main.Cassandra1.start()
50 main.Cassandra2.start()
51 main.Cassandra3.start()
52 main.Cassandra4.start()
adminbae64d82013-08-01 10:50:15 -070053 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
54 main.step("Testing startup ONOS")
55 data = main.ONOS1.isup()
56 if data == main.FALSE:
57 main.log.report("Something is funny... restarting ONOS")
58 main.ONOS1.stop()
59 time.sleep(3)
60 main.ONOS1.start()
61 time.sleep(5)
62 data = main.ONOS1.isup()
63 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
64
65#**********************************************************************************************************************************************************************************************
66#Assign Controllers
67#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>).
68#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
69#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
70# the controllers already assigned to the switch are not specified.
71
72 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
73 import time
74 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
75 main.case("Checking if one MN host exists")
76 main.step("Host IP Checking using checkIP")
77 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
78 main.step("Verifying the result")
79 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
80 main.step("assigning ONOS controllers to switches")
81 for i in range(25):
82 if i < 3:
83 j=i+1
admin530b4c92013-08-14 16:54:35 -070084 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
adminbae64d82013-08-01 10:50:15 -070085 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070086 main.Mininet1.assign_sw_controller(sw=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'])
adminbae64d82013-08-01 10:50:15 -070087 elif i >= 3 and i < 5:
88 j=i+1
admin530b4c92013-08-14 16:54:35 -070089 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
adminbae64d82013-08-01 10:50:15 -070090 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070091 main.Mininet1.assign_sw_controller(sw=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'])
adminbae64d82013-08-01 10:50:15 -070092 elif i >= 5 and i < 15:
93 j=i+1
admin530b4c92013-08-14 16:54:35 -070094 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
adminbae64d82013-08-01 10:50:15 -070095 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070096 main.Mininet1.assign_sw_controller(sw=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'])
adminbae64d82013-08-01 10:50:15 -070097 else:
98 j=i+16
admin530b4c92013-08-14 16:54:35 -070099 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
adminbae64d82013-08-01 10:50:15 -0700100 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -0700101 main.Mininet1.assign_sw_controller(sw=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'])
adminbae64d82013-08-01 10:50:15 -0700102 main.Mininet1.get_sw_controller("s1")
103
104# **********************************************************************************************************************************************************************************************
105#Add Flows
106#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
107#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
108
109 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
110 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
111 import time
112 main.case("Taking care of these flows!")
113 main.step("Cleaning out any leftover flows...")
114 main.ONOS1.delete_flow("all")
adminbae64d82013-08-01 10:50:15 -0700115 strtTime = time.time()
116 main.ONOS1.add_flow(main.params['FLOWDEF'])
117 main.case("Checking flows")
admin530b4c92013-08-14 16:54:35 -0700118
adminbae64d82013-08-01 10:50:15 -0700119 count = 1
120 i = 6
121 while i < 16 :
122 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
123 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800124 if ping == main.FALSE and count < 9:
adminbae64d82013-08-01 10:50:15 -0700125 count = count + 1
126 i = 6
admin68453302013-12-16 15:40:04 -0800127 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
128 time.sleep(2)
129 elif ping == main.FALSE and count ==9:
adminbae64d82013-08-01 10:50:15 -0700130 main.log.error("Ping test failed")
131 i = 17
admin68453302013-12-16 15:40:04 -0800132 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700133 elif ping == main.TRUE:
134 i = i + 1
admin68453302013-12-16 15:40:04 -0800135 result = main.TRUE
136 endTime = time.time()
137 if result == main.TRUE:
138 main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
admin530b4c92013-08-14 16:54:35 -0700139 else:
admin68453302013-12-16 15:40:04 -0800140 main.log.report("\tFlows failed check")
admin530b4c92013-08-14 16:54:35 -0700141
admin68453302013-12-16 15:40:04 -0800142 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin530b4c92013-08-14 16:54:35 -0700143 main.step("Verifying the result")
admin68453302013-12-16 15:40:04 -0800144 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
admin530b4c92013-08-14 16:54:35 -0700145
146#**********************************************************************************************************************************************************************************************
147#This test case removes Controllers 2,3, and 4 then performs a ping test.
148#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
149#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.
150#If the ping test fails 6 times, then the test case will return false
151
152 def CASE4(self,main) :
153 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
154 import time
155 for i in range(25):
156 if i < 15:
157 j=i+1
158 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
159 else:
160 j=i+16
161 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
admine0ae8202013-08-28 11:51:43 -0700162
163 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700164 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800165 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700166 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800167 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700168 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
169 else:
170 break
171
admin530b4c92013-08-14 16:54:35 -0700172 count = 1
173 i = 6
174 while i < 16 :
175 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
176 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
177 if ping == main.FALSE and count < 6:
178 count = count + 1
179 i = 6
admin68453302013-12-16 15:40:04 -0800180 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
181 time.sleep(2)
admin530b4c92013-08-14 16:54:35 -0700182 elif ping == main.FALSE and count ==6:
183 main.log.error("Ping test failed")
184 i = 17
adminbae64d82013-08-01 10:50:15 -0700185 result = main.FALSE
186 elif ping == main.TRUE:
187 i = i + 1
188 result = main.TRUE
189 endTime = time.time()
190 if result == main.TRUE:
191 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
192 else:
193 main.log.report("\tPING TEST FAIL")
194 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
195
196# **********************************************************************************************************************************************************************************************
197#This test case restores the controllers removed by Case 4 then performs a ping test.
198
199 def CASE5(self,main) :
admin530b4c92013-08-14 16:54:35 -0700200 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 -0700201 import time
202 for i in range(25):
203 if i < 15:
204 j=i+1
admin530b4c92013-08-14 16:54:35 -0700205 main.Mininet1.assign_sw_controller(sw=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'])
adminbae64d82013-08-01 10:50:15 -0700206 else:
207 j=i+16
admin530b4c92013-08-14 16:54:35 -0700208 main.Mininet1.assign_sw_controller(sw=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'])
admine0ae8202013-08-28 11:51:43 -0700209
210 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700211 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800212 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700213 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800214 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700215 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
216 else:
217 break
218
adminbae64d82013-08-01 10:50:15 -0700219 count = 1
220 i = 6
221 while i < 16 :
222 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
223 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin530b4c92013-08-14 16:54:35 -0700224 if ping == main.FALSE and count < 6:
adminbae64d82013-08-01 10:50:15 -0700225 count = count + 1
226 i = 6
admin68453302013-12-16 15:40:04 -0800227 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
228 time.sleep(2)
admin530b4c92013-08-14 16:54:35 -0700229 elif ping == main.FALSE and count ==6:
adminbae64d82013-08-01 10:50:15 -0700230 main.log.error("Ping test failed")
231 i = 17
232 result = main.FALSE
233 elif ping == main.TRUE:
234 i = i + 1
235 result = main.TRUE
236 endTime = time.time()
237 if result == main.TRUE:
238 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
239 else:
240 main.log.report("\tPING TEST FAILED")
241 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
242
243# **********************************************************************************************************************************************************************************************
244#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
245
246 def CASE6(self,main) :
admine0ae8202013-08-28 11:51:43 -0700247 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 -0700248 import time
249 main.case("Bringing Link down... ")
250 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
adminbae64d82013-08-01 10:50:15 -0700251 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
admine0ae8202013-08-28 11:51:43 -0700252
253 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700254 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 -0800255 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700256 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800257 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700258 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
259 else:
260 break
261
adminbae64d82013-08-01 10:50:15 -0700262 count = 1
263 i = 6
264 while i < 16 :
265 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
266 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700267 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700268 count = count + 1
admin68453302013-12-16 15:40:04 -0800269 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
adminbae64d82013-08-01 10:50:15 -0700270 i = 6
admin68453302013-12-16 15:40:04 -0800271 time.sleep(2)
admine0ae8202013-08-28 11:51:43 -0700272 elif ping == main.FALSE and count == 10:
adminbae64d82013-08-01 10:50:15 -0700273 main.log.error("Ping test failed")
274 i = 17
275 result = main.FALSE
276 elif ping == main.TRUE:
277 i = i + 1
278 result = main.TRUE
279 endTime = time.time()
280 if result == main.TRUE:
281 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
282 else:
283 main.log.report("\tPING TEST FAILED")
284 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
285
286# **********************************************************************************************************************************************************************************************
287#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
288
289 def CASE7(self,main) :
admine0ae8202013-08-28 11:51:43 -0700290 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 -0700291 import time
292 main.case("Bringing Link up... ")
293 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
adminbae64d82013-08-01 10:50:15 -0700294 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
admine0ae8202013-08-28 11:51:43 -0700295
296 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700297 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800298 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700299 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800300 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700301 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
302 else:
303 break
304
adminbae64d82013-08-01 10:50:15 -0700305 strtTime = time.time()
306 count = 1
307 i = 6
308 while i < 16 :
309 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
310 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700311 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700312 count = count + 1
admin68453302013-12-16 15:40:04 -0800313 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
adminbae64d82013-08-01 10:50:15 -0700314 i = 6
admin68453302013-12-16 15:40:04 -0800315 time.sleep(2)
admine0ae8202013-08-28 11:51:43 -0700316 elif ping == main.FALSE and count ==10:
adminbae64d82013-08-01 10:50:15 -0700317 main.log.error("Ping test failed")
318 i = 17
319 result = main.FALSE
320 elif ping == main.TRUE:
321 i = i + 1
322 result = main.TRUE
323 endTime = time.time()
324 if result == main.TRUE:
325 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
326 else:
327 main.log.report("\tPING TESTS FAILED")
328 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
329
admin530b4c92013-08-14 16:54:35 -0700330
331# ******************************************************************************************************************************************************************
332# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
333
334 def CASE21(self,main) :
335 import json
336 from drivers.common.api.onosrestapidriver import *
adminbeea0032014-01-23 14:54:13 -0800337 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 -0800338 main.log.report("Check initially hostMAC/IP exist on the mininet...")
admin530b4c92013-08-14 16:54:35 -0700339 host = main.params['YANK']['hostname']
340 mac = main.params['YANK']['hostmac']
admin68453302013-12-16 15:40:04 -0800341 hostip = main.params['YANK']['hostip']
admin530b4c92013-08-14 16:54:35 -0700342 RestIP1 = main.params['RESTCALL']['restIP1']
admin530b4c92013-08-14 16:54:35 -0700343 RestPort = main.params['RESTCALL']['restPort']
344 url = main.params['RESTCALL']['restURL']
admin68453302013-12-16 15:40:04 -0800345
adminbeea0032014-01-23 14:54:13 -0800346 t_topowait = 0
347 t_restwait = 10
348 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
349 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
350 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
351 time.sleep(t_topowait)
admin530b4c92013-08-14 16:54:35 -0700352 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" )
353 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800354 time.sleep(t_restwait)
admin530b4c92013-08-14 16:54:35 -0700355 restcall = OnosRestApiDriver()
admin68453302013-12-16 15:40:04 -0800356 Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
357 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
admin530b4c92013-08-14 16:54:35 -0700358 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800359 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 -0800360 result1 = main.TRUE
361 elif Reststatus > 1:
362 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800363 main.log.report("switches are: " + "; ".join(Switch))
364 main.log.report("Ports are: " + "; ".join(Port))
365 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800366 result1 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700367 else:
admin68453302013-12-16 15:40:04 -0800368 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
369 result1 = main.FALSE
370
admin530b4c92013-08-14 16:54:35 -0700371
372 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
373
374 main.log.report("Yank out s1-eth1")
375 main.case("Yankout s6-eth1 (link to h1) from s1")
376 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
adminbeea0032014-01-23 14:54:13 -0800377 time.sleep(t_topowait)
admin530b4c92013-08-14 16:54:35 -0700378 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
admin68453302013-12-16 15:40:04 -0800379
380 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 -0700381 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800382 time.sleep(t_restwait)
admin68453302013-12-16 15:40:04 -0800383 restcall = OnosRestApiDriver()
384 Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
385
386 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
387 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800388 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 -0800389 result2 = main.FALSE
390 elif Reststatus > 1:
391 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800392 main.log.report("switches are: " + "; ".join(Switch))
393 main.log.report("Ports are: " + "; ".join(Port))
394 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800395 result2 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700396 else:
admin68453302013-12-16 15:40:04 -0800397 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.")
398 result2 = main.TRUE
399
admin530b4c92013-08-14 16:54:35 -0700400 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
401 main.log.report("Plug s1-eth1 into s6")
402 main.case("Plug s1-eth1 to s6")
403 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
adminbeea0032014-01-23 14:54:13 -0800404 time.sleep(t_topowait)
admin530b4c92013-08-14 16:54:35 -0700405 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
admin68453302013-12-16 15:40:04 -0800406 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" )
407
admin530b4c92013-08-14 16:54:35 -0700408 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800409 time.sleep(t_restwait)
admin68453302013-12-16 15:40:04 -0800410 restcall = OnosRestApiDriver()
411 Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
412
413 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
414 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800415 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 -0800416 result3 = main.TRUE
417 elif Reststatus > 1:
418 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800419 main.log.report("switches are: " + "; ".join(Switch))
420 main.log.report("Ports are: " + "; ".join(Port))
421 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800422 result3 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700423 else:
admin68453302013-12-16 15:40:04 -0800424 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
425 result3 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700426
427 ###### Step to put interface "s1-eth1" back to s1"#####
428 main.log.report("Move s1-eth1 back on to s1")
429 main.case("Move s1-eth1 back to s1")
430 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
adminbeea0032014-01-23 14:54:13 -0800431 time.sleep(t_topowait)
admin530b4c92013-08-14 16:54:35 -0700432 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
433 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
admin68453302013-12-16 15:40:04 -0800434 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" )
435
admin530b4c92013-08-14 16:54:35 -0700436 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800437 time.sleep(t_restwait)
admin68453302013-12-16 15:40:04 -0800438 restcall = OnosRestApiDriver()
439 Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
440
441 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
442 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800443 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 -0800444 result4 = main.TRUE
445 elif Reststatus > 1:
446 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800447 main.log.report("switches are: " + "; ".join(Switch))
448 main.log.report("Ports are: " + "; ".join(Port))
449 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800450 result4 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700451 else:
admin68453302013-12-16 15:40:04 -0800452 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
453 result4 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700454
admin68453302013-12-16 15:40:04 -0800455 result = result1 and result2 and result3 and result4
admin530b4c92013-08-14 16:54:35 -0700456 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
457
adminbeea0032014-01-23 14:54:13 -0800458# Run a pure ping test.
459
460 def CASE31(self, main):
461 main.log.report("Performing Ping Test")
462 count = 1
463 i = 6
464 while i < 16 :
465 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
466 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
467 if ping == main.FALSE and count < 6:
468 count = count + 1
469 i = 6
470 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
471 time.sleep(2)
472 elif ping == main.FALSE and count ==6:
473 main.log.error("Ping test failed")
474 i = 17
475 result = main.FALSE
476 elif ping == main.TRUE:
477 i = i + 1
478 result = main.TRUE
479 endTime = time.time()
480 if result == main.TRUE:
481 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
482 else:
483 main.log.report("\tPING TEST FAIL")
484 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 -0700485