blob: 3b5397be5716ea2e00a6f417443b8addd6a38619 [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()
admin7c10f642014-03-13 16:22:36 -070017 main.Cassandra1.stop()
18 main.Cassandra2.stop()
19 main.Cassandra3.stop()
20 main.Cassandra4.stop()
admine0ae8202013-08-28 11:51:43 -070021 main.Cassandra1.start()
22 main.Cassandra2.start()
23 main.Cassandra3.start()
24 main.Cassandra4.start()
25 time.sleep(20)
adminbae64d82013-08-01 10:50:15 -070026 main.ONOS1.drop_keyspace()
27 main.ONOS1.start()
28 time.sleep(10)
29 main.ONOS2.start()
30 main.ONOS3.start()
31 main.ONOS4.start()
32 main.ONOS1.start_rest()
admin530b4c92013-08-14 16:54:35 -070033 time.sleep(5)
admin68453302013-12-16 15:40:04 -080034 test= main.ONOS1.rest_status()
35 if test == main.FALSE:
36 main.ONOS1.start_rest()
adminbae64d82013-08-01 10:50:15 -070037 main.ONOS1.get_version()
38 main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections")
39 main.case("Checking if the startup was clean...")
40 main.step("Testing startup Zookeeper")
41 data = main.Zookeeper1.isup()
42 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
43 main.step("Testing startup Cassandra")
admin530b4c92013-08-14 16:54:35 -070044 data = main.Cassandra1.isup()
45 if data == main.FALSE:
46 main.Cassandra1.stop()
47 main.Cassandra2.stop()
48 main.Cassandra3.stop()
49 main.Cassandra4.stop()
50
51 time.sleep(5)
52
53 main.Cassandra1.start()
54 main.Cassandra2.start()
55 main.Cassandra3.start()
56 main.Cassandra4.start()
adminbae64d82013-08-01 10:50:15 -070057 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
58 main.step("Testing startup ONOS")
59 data = main.ONOS1.isup()
60 if data == main.FALSE:
61 main.log.report("Something is funny... restarting ONOS")
62 main.ONOS1.stop()
63 time.sleep(3)
64 main.ONOS1.start()
65 time.sleep(5)
66 data = main.ONOS1.isup()
67 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
68
69#**********************************************************************************************************************************************************************************************
70#Assign Controllers
71#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>).
72#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
73#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
74# the controllers already assigned to the switch are not specified.
75
76 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
77 import time
78 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
79 main.case("Checking if one MN host exists")
80 main.step("Host IP Checking using checkIP")
81 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
82 main.step("Verifying the result")
83 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
84 main.step("assigning ONOS controllers to switches")
85 for i in range(25):
86 if i < 3:
87 j=i+1
admin530b4c92013-08-14 16:54:35 -070088 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
adminbae64d82013-08-01 10:50:15 -070089 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070090 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 -070091 elif i >= 3 and i < 5:
92 j=i+1
admin530b4c92013-08-14 16:54:35 -070093 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
adminbae64d82013-08-01 10:50:15 -070094 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070095 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 -070096 elif i >= 5 and i < 15:
97 j=i+1
admin530b4c92013-08-14 16:54:35 -070098 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
adminbae64d82013-08-01 10:50:15 -070099 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -0700100 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 -0700101 else:
102 j=i+16
admin530b4c92013-08-14 16:54:35 -0700103 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
adminbae64d82013-08-01 10:50:15 -0700104 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -0700105 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 -0700106 main.Mininet1.get_sw_controller("s1")
107
108# **********************************************************************************************************************************************************************************************
109#Add Flows
110#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
111#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
112
113 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
114 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
115 import time
116 main.case("Taking care of these flows!")
117 main.step("Cleaning out any leftover flows...")
118 main.ONOS1.delete_flow("all")
adminbae64d82013-08-01 10:50:15 -0700119 strtTime = time.time()
120 main.ONOS1.add_flow(main.params['FLOWDEF'])
121 main.case("Checking flows")
admin530b4c92013-08-14 16:54:35 -0700122
adminbae64d82013-08-01 10:50:15 -0700123 count = 1
124 i = 6
125 while i < 16 :
126 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
127 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800128 if ping == main.FALSE and count < 9:
adminbae64d82013-08-01 10:50:15 -0700129 count = count + 1
130 i = 6
admin68453302013-12-16 15:40:04 -0800131 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
132 time.sleep(2)
133 elif ping == main.FALSE and count ==9:
adminbae64d82013-08-01 10:50:15 -0700134 main.log.error("Ping test failed")
135 i = 17
admin68453302013-12-16 15:40:04 -0800136 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700137 elif ping == main.TRUE:
138 i = i + 1
admin68453302013-12-16 15:40:04 -0800139 result = main.TRUE
140 endTime = time.time()
141 if result == main.TRUE:
142 main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
admin530b4c92013-08-14 16:54:35 -0700143 else:
admin68453302013-12-16 15:40:04 -0800144 main.log.report("\tFlows failed check")
admin530b4c92013-08-14 16:54:35 -0700145
admin68453302013-12-16 15:40:04 -0800146 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin530b4c92013-08-14 16:54:35 -0700147 main.step("Verifying the result")
admin68453302013-12-16 15:40:04 -0800148 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
admin530b4c92013-08-14 16:54:35 -0700149
150#**********************************************************************************************************************************************************************************************
151#This test case removes Controllers 2,3, and 4 then performs a ping test.
152#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
153#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.
154#If the ping test fails 6 times, then the test case will return false
155
156 def CASE4(self,main) :
157 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
158 import time
159 for i in range(25):
160 if i < 15:
161 j=i+1
162 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
163 else:
164 j=i+16
165 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
admine0ae8202013-08-28 11:51:43 -0700166
167 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700168 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800169 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700170 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800171 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700172 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
173 else:
174 break
175
admin530b4c92013-08-14 16:54:35 -0700176 count = 1
177 i = 6
178 while i < 16 :
179 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
180 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
181 if ping == main.FALSE and count < 6:
182 count = count + 1
183 i = 6
admin68453302013-12-16 15:40:04 -0800184 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
185 time.sleep(2)
admin530b4c92013-08-14 16:54:35 -0700186 elif ping == main.FALSE and count ==6:
187 main.log.error("Ping test failed")
188 i = 17
adminbae64d82013-08-01 10:50:15 -0700189 result = main.FALSE
190 elif ping == main.TRUE:
191 i = i + 1
192 result = main.TRUE
193 endTime = time.time()
194 if result == main.TRUE:
195 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
196 else:
197 main.log.report("\tPING TEST FAIL")
198 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
199
200# **********************************************************************************************************************************************************************************************
201#This test case restores the controllers removed by Case 4 then performs a ping test.
202
203 def CASE5(self,main) :
admin530b4c92013-08-14 16:54:35 -0700204 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 -0700205 import time
206 for i in range(25):
207 if i < 15:
208 j=i+1
admin530b4c92013-08-14 16:54:35 -0700209 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 -0700210 else:
211 j=i+16
admin530b4c92013-08-14 16:54:35 -0700212 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 -0700213
214 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700215 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800216 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700217 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800218 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700219 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
220 else:
221 break
222
adminbae64d82013-08-01 10:50:15 -0700223 count = 1
224 i = 6
225 while i < 16 :
226 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
227 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin530b4c92013-08-14 16:54:35 -0700228 if ping == main.FALSE and count < 6:
adminbae64d82013-08-01 10:50:15 -0700229 count = count + 1
230 i = 6
admin68453302013-12-16 15:40:04 -0800231 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
232 time.sleep(2)
admin530b4c92013-08-14 16:54:35 -0700233 elif ping == main.FALSE and count ==6:
adminbae64d82013-08-01 10:50:15 -0700234 main.log.error("Ping test failed")
235 i = 17
236 result = main.FALSE
237 elif ping == main.TRUE:
238 i = i + 1
239 result = main.TRUE
240 endTime = time.time()
241 if result == main.TRUE:
242 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
243 else:
244 main.log.report("\tPING TEST FAILED")
245 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
246
247# **********************************************************************************************************************************************************************************************
248#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
249
250 def CASE6(self,main) :
admine0ae8202013-08-28 11:51:43 -0700251 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 -0700252 import time
253 main.case("Bringing Link down... ")
254 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
adminbae64d82013-08-01 10:50:15 -0700255 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
admine0ae8202013-08-28 11:51:43 -0700256
257 strtTime = time.time()
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))
admin68453302013-12-16 15:40:04 -0800259 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700260 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800261 time.sleep(5)
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))
263 else:
264 break
265
adminbae64d82013-08-01 10:50:15 -0700266 count = 1
267 i = 6
268 while i < 16 :
269 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
270 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700271 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700272 count = count + 1
admin68453302013-12-16 15:40:04 -0800273 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
adminbae64d82013-08-01 10:50:15 -0700274 i = 6
admin68453302013-12-16 15:40:04 -0800275 time.sleep(2)
admine0ae8202013-08-28 11:51:43 -0700276 elif ping == main.FALSE and count == 10:
adminbae64d82013-08-01 10:50:15 -0700277 main.log.error("Ping test failed")
278 i = 17
279 result = main.FALSE
280 elif ping == main.TRUE:
281 i = i + 1
282 result = main.TRUE
283 endTime = time.time()
284 if result == main.TRUE:
285 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
286 else:
287 main.log.report("\tPING TEST FAILED")
288 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
289
290# **********************************************************************************************************************************************************************************************
291#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
292
293 def CASE7(self,main) :
admine0ae8202013-08-28 11:51:43 -0700294 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 -0700295 import time
296 main.case("Bringing Link up... ")
297 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
adminbae64d82013-08-01 10:50:15 -0700298 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
admine0ae8202013-08-28 11:51:43 -0700299
300 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700301 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800302 for i in range(2):
admin530b4c92013-08-14 16:54:35 -0700303 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800304 time.sleep(5)
admin530b4c92013-08-14 16:54:35 -0700305 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
306 else:
307 break
308
adminbae64d82013-08-01 10:50:15 -0700309 strtTime = time.time()
310 count = 1
311 i = 6
312 while i < 16 :
313 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
314 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700315 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700316 count = count + 1
admin68453302013-12-16 15:40:04 -0800317 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
adminbae64d82013-08-01 10:50:15 -0700318 i = 6
admin68453302013-12-16 15:40:04 -0800319 time.sleep(2)
admine0ae8202013-08-28 11:51:43 -0700320 elif ping == main.FALSE and count ==10:
adminbae64d82013-08-01 10:50:15 -0700321 main.log.error("Ping test failed")
322 i = 17
323 result = main.FALSE
324 elif ping == main.TRUE:
325 i = i + 1
326 result = main.TRUE
327 endTime = time.time()
328 if result == main.TRUE:
329 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
330 else:
331 main.log.report("\tPING TESTS FAILED")
332 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
333
admin530b4c92013-08-14 16:54:35 -0700334
335# ******************************************************************************************************************************************************************
336# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
337
338 def CASE21(self,main) :
339 import json
340 from drivers.common.api.onosrestapidriver import *
adminbeea0032014-01-23 14:54:13 -0800341 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 -0800342 main.log.report("Check initially hostMAC/IP exist on the mininet...")
admin530b4c92013-08-14 16:54:35 -0700343 host = main.params['YANK']['hostname']
344 mac = main.params['YANK']['hostmac']
admin68453302013-12-16 15:40:04 -0800345 hostip = main.params['YANK']['hostip']
admin530b4c92013-08-14 16:54:35 -0700346 RestIP1 = main.params['RESTCALL']['restIP1']
admin530b4c92013-08-14 16:54:35 -0700347 RestPort = main.params['RESTCALL']['restPort']
348 url = main.params['RESTCALL']['restURL']
admin68453302013-12-16 15:40:04 -0800349
adminbeea0032014-01-23 14:54:13 -0800350 t_topowait = 0
351 t_restwait = 10
352 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
353 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
354 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
355 time.sleep(t_topowait)
admin530b4c92013-08-14 16:54:35 -0700356 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" )
357 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800358 time.sleep(t_restwait)
admin530b4c92013-08-14 16:54:35 -0700359 restcall = OnosRestApiDriver()
admin68453302013-12-16 15:40:04 -0800360 Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
361 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
admin530b4c92013-08-14 16:54:35 -0700362 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800363 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 -0800364 result1 = main.TRUE
365 elif Reststatus > 1:
366 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800367 main.log.report("switches are: " + "; ".join(Switch))
368 main.log.report("Ports are: " + "; ".join(Port))
369 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800370 result1 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700371 else:
admin68453302013-12-16 15:40:04 -0800372 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
373 result1 = main.FALSE
374
admin530b4c92013-08-14 16:54:35 -0700375
376 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
377
378 main.log.report("Yank out s1-eth1")
379 main.case("Yankout s6-eth1 (link to h1) from s1")
380 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
adminbeea0032014-01-23 14:54:13 -0800381 time.sleep(t_topowait)
admin530b4c92013-08-14 16:54:35 -0700382 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
admin68453302013-12-16 15:40:04 -0800383
384 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 -0700385 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800386 time.sleep(t_restwait)
admin68453302013-12-16 15:40:04 -0800387 restcall = OnosRestApiDriver()
388 Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
389
390 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
391 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800392 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 -0800393 result2 = main.FALSE
394 elif Reststatus > 1:
395 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800396 main.log.report("switches are: " + "; ".join(Switch))
397 main.log.report("Ports are: " + "; ".join(Port))
398 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800399 result2 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700400 else:
admin68453302013-12-16 15:40:04 -0800401 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.")
402 result2 = main.TRUE
403
admin530b4c92013-08-14 16:54:35 -0700404 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
405 main.log.report("Plug s1-eth1 into s6")
406 main.case("Plug s1-eth1 to s6")
407 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
adminbeea0032014-01-23 14:54:13 -0800408 time.sleep(t_topowait)
admin530b4c92013-08-14 16:54:35 -0700409 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
admin68453302013-12-16 15:40:04 -0800410 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" )
411
admin530b4c92013-08-14 16:54:35 -0700412 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
adminbeea0032014-01-23 14:54:13 -0800413 time.sleep(t_restwait)
admin68453302013-12-16 15:40:04 -0800414 restcall = OnosRestApiDriver()
415 Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
416
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")
433 main.case("Move s1-eth1 back to s1")
434 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)
admin530b4c92013-08-14 16:54:35 -0700436 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
437 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)
admin68453302013-12-16 15:40:04 -0800442 restcall = OnosRestApiDriver()
443 Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
444
445 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
446 if Reststatus == 1:
adminbeea0032014-01-23 14:54:13 -0800447 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 -0800448 result4 = main.TRUE
449 elif Reststatus > 1:
admin7c10f642014-03-13 16:22:36 -0700450 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
adminbeea0032014-01-23 14:54:13 -0800451 main.log.report("switches are: " + "; ".join(Switch))
452 main.log.report("Ports are: " + "; ".join(Port))
453 main.log.report("MACs are: " + "; ".join(MAC))
admin68453302013-12-16 15:40:04 -0800454 result4 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700455 else:
admin68453302013-12-16 15:40:04 -0800456 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
457 result4 = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700458
admin68453302013-12-16 15:40:04 -0800459 result = result1 and result2 and result3 and result4
admin530b4c92013-08-14 16:54:35 -0700460 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
461
adminbeea0032014-01-23 14:54:13 -0800462# Run a pure ping test.
463
464 def CASE31(self, main):
465 main.log.report("Performing Ping Test")
466 count = 1
467 i = 6
468 while i < 16 :
469 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
admin7c10f642014-03-13 16:22:36 -0700470 strtTime = time.time()
adminbeea0032014-01-23 14:54:13 -0800471 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
472 if ping == main.FALSE and count < 6:
473 count = count + 1
474 i = 6
475 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
476 time.sleep(2)
477 elif ping == main.FALSE and count ==6:
478 main.log.error("Ping test failed")
479 i = 17
480 result = main.FALSE
481 elif ping == main.TRUE:
482 i = i + 1
483 result = main.TRUE
484 endTime = time.time()
485 if result == main.TRUE:
486 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
487 else:
488 main.log.report("\tPING TEST FAIL")
489 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 -0700490