blob: 10cdc58ad8f1f6a84c4e0041161fae9720faeefa [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001
2class OnosSanity4nodes :
3
4 def __init__(self) :
5 self.default = ''
6
7#**********************************************************************************************************************************************************************************************
8#Test startup
9#Tests the startup of Zookeeper1, Cassandra1, and ONOS1 to be certain that all started up successfully
10 def CASE1(self,main) : #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version
11 import time
12 main.log.report("Pulling latest code from github to all nodes")
13 main.ONOS1.git_pull()
14 main.ONOS2.git_pull()
15 main.ONOS3.git_pull()
16 main.ONOS4.git_pull()
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)
30 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")
admincd0944e2013-09-30 12:07:19 -0700103
104 for i in range(9):
105 if result == main.FALSE:
106 time.sleep(3)
107 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
108 else:
109 break
adminbae64d82013-08-01 10:50:15 -0700110
111# **********************************************************************************************************************************************************************************************
112#Add Flows
113#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
114#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
115
116 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
117 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
118 import time
admincd0944e2013-09-30 12:07:19 -0700119
120 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
121 for i in range(9):
122 if result == main.FALSE:
123 time.sleep(3)
124 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
125 else:
126 break
127
adminbae64d82013-08-01 10:50:15 -0700128 main.case("Taking care of these flows!")
129 main.step("Cleaning out any leftover flows...")
130 main.ONOS1.delete_flow("all")
131 time.sleep(5)
132 strtTime = time.time()
133 main.ONOS1.add_flow(main.params['FLOWDEF'])
134 main.case("Checking flows")
135 tmp = main.FALSE
136 count = 1
admine0ae8202013-08-28 11:51:43 -0700137 main.log.info("Wait for flows to be pushed to the switches, then check")
adminbae64d82013-08-01 10:50:15 -0700138 while tmp == main.FALSE:
139 main.step("Waiting")
admincd0944e2013-09-30 12:07:19 -0700140 time.sleep(5)
adminbae64d82013-08-01 10:50:15 -0700141 main.step("Checking")
142 tmp = main.ONOS1.check_flow()
143 if tmp == main.FALSE and count < 6:
144 count = count + 1
145 main.log.report("Flow failed, waiting 10 seconds then making attempt number "+str(count))
146 elif tmp == main.FALSE and count == 6:
admin530b4c92013-08-14 16:54:35 -0700147 result1 = main.FALSE
adminbae64d82013-08-01 10:50:15 -0700148 break
149 else:
admin530b4c92013-08-14 16:54:35 -0700150 result1 = main.TRUE
adminbae64d82013-08-01 10:50:15 -0700151 break
152 endTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700153 if result1 == main.TRUE:
adminbae64d82013-08-01 10:50:15 -0700154 main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
155 else:
156 main.log.report("\tFlows failed check")
admin530b4c92013-08-14 16:54:35 -0700157
adminbae64d82013-08-01 10:50:15 -0700158 count = 1
159 i = 6
160 while i < 16 :
161 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
162 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
163 if ping == main.FALSE and count < 3:
164 count = count + 1
165 i = 6
166 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
167 time.sleep(10)
168 elif ping == main.FALSE and count ==3:
169 main.log.error("Ping test failed")
170 i = 17
admin530b4c92013-08-14 16:54:35 -0700171 result2 = main.FALSE
172 elif ping == main.TRUE:
173 i = i + 1
174 result2 = main.TRUE
admin530b4c92013-08-14 16:54:35 -0700175 if result2 == main.TRUE:
admincd0944e2013-09-30 12:07:19 -0700176 main.log.info("Flows successfully added")
admin530b4c92013-08-14 16:54:35 -0700177 else:
178 main.log.report("\tPING TEST FAIL")
179
admin530b4c92013-08-14 16:54:35 -0700180 main.step("Verifying the result")
admincd0944e2013-09-30 12:07:19 -0700181 utilities.assert_equals(expect=main.TRUE,actual=result1 and result2,onpass="Flow check PASS",onfail="Flow check FAIL")
admin530b4c92013-08-14 16:54:35 -0700182
183#**********************************************************************************************************************************************************************************************
184#This test case removes Controllers 2,3, and 4 then performs a ping test.
185#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
186#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.
187#If the ping test fails 6 times, then the test case will return false
188
189 def CASE4(self,main) :
190 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
191 import time
192 for i in range(25):
193 if i < 15:
194 j=i+1
195 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
196 else:
197 j=i+16
198 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
admine0ae8202013-08-28 11:51:43 -0700199
200 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700201 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admincd0944e2013-09-30 12:07:19 -0700202 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700203 if result == main.FALSE:
admincd0944e2013-09-30 12:07:19 -0700204 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700205 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
206 else:
207 break
208
admin530b4c92013-08-14 16:54:35 -0700209 count = 1
210 i = 6
211 while i < 16 :
212 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
213 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
214 if ping == main.FALSE and count < 6:
215 count = count + 1
216 i = 6
217 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
218 time.sleep(5)
219 elif ping == main.FALSE and count ==6:
220 main.log.error("Ping test failed")
221 i = 17
adminbae64d82013-08-01 10:50:15 -0700222 result = main.FALSE
223 elif ping == main.TRUE:
224 i = i + 1
225 result = main.TRUE
226 endTime = time.time()
227 if result == main.TRUE:
228 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
229 else:
230 main.log.report("\tPING TEST FAIL")
231 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
232
233# **********************************************************************************************************************************************************************************************
234#This test case restores the controllers removed by Case 4 then performs a ping test.
235
236 def CASE5(self,main) :
admin530b4c92013-08-14 16:54:35 -0700237 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 -0700238 import time
239 for i in range(25):
240 if i < 15:
241 j=i+1
admin530b4c92013-08-14 16:54:35 -0700242 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 -0700243 else:
244 j=i+16
admin530b4c92013-08-14 16:54:35 -0700245 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 -0700246
247 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700248 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admincd0944e2013-09-30 12:07:19 -0700249 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700250 if result == main.FALSE:
admincd0944e2013-09-30 12:07:19 -0700251 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700252 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
253 else:
254 break
255
adminbae64d82013-08-01 10:50:15 -0700256 count = 1
257 i = 6
258 while i < 16 :
259 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
260 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin530b4c92013-08-14 16:54:35 -0700261 if ping == main.FALSE and count < 6:
adminbae64d82013-08-01 10:50:15 -0700262 count = count + 1
263 i = 6
admin530b4c92013-08-14 16:54:35 -0700264 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
265 time.sleep(5)
266 elif ping == main.FALSE and count ==6:
adminbae64d82013-08-01 10:50:15 -0700267 main.log.error("Ping test failed")
268 i = 17
269 result = main.FALSE
270 elif ping == main.TRUE:
271 i = i + 1
272 result = main.TRUE
273 endTime = time.time()
274 if result == main.TRUE:
275 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
276 else:
277 main.log.report("\tPING TEST FAILED")
278 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
279
280# **********************************************************************************************************************************************************************************************
281#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
282
283 def CASE6(self,main) :
admine0ae8202013-08-28 11:51:43 -0700284 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 -0700285 import time
286 main.case("Bringing Link down... ")
287 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
adminbae64d82013-08-01 10:50:15 -0700288 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
admine0ae8202013-08-28 11:51:43 -0700289
290 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700291 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
admincd0944e2013-09-30 12:07:19 -0700292 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700293 if result == main.FALSE:
admincd0944e2013-09-30 12:07:19 -0700294 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700295 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
296 else:
297 break
298
adminbae64d82013-08-01 10:50:15 -0700299 count = 1
300 i = 6
301 while i < 16 :
302 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
303 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700304 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700305 count = count + 1
admin530b4c92013-08-14 16:54:35 -0700306 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
adminbae64d82013-08-01 10:50:15 -0700307 i = 6
admin530b4c92013-08-14 16:54:35 -0700308 time.sleep(5)
admine0ae8202013-08-28 11:51:43 -0700309 elif ping == main.FALSE and count == 10:
adminbae64d82013-08-01 10:50:15 -0700310 main.log.error("Ping test failed")
311 i = 17
312 result = main.FALSE
313 elif ping == main.TRUE:
314 i = i + 1
315 result = main.TRUE
316 endTime = time.time()
317 if result == main.TRUE:
318 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
319 else:
320 main.log.report("\tPING TEST FAILED")
321 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
322
323# **********************************************************************************************************************************************************************************************
324#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
325
326 def CASE7(self,main) :
admine0ae8202013-08-28 11:51:43 -0700327 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 -0700328 import time
329 main.case("Bringing Link up... ")
330 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
adminbae64d82013-08-01 10:50:15 -0700331 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
admine0ae8202013-08-28 11:51:43 -0700332
333 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700334 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admincd0944e2013-09-30 12:07:19 -0700335 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700336 if result == main.FALSE:
admincd0944e2013-09-30 12:07:19 -0700337 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700338 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
339 else:
340 break
341
adminbae64d82013-08-01 10:50:15 -0700342 strtTime = time.time()
343 count = 1
344 i = 6
345 while i < 16 :
346 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
347 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700348 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700349 count = count + 1
admin530b4c92013-08-14 16:54:35 -0700350 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
adminbae64d82013-08-01 10:50:15 -0700351 i = 6
admin530b4c92013-08-14 16:54:35 -0700352 time.sleep(5)
admine0ae8202013-08-28 11:51:43 -0700353 elif ping == main.FALSE and count ==10:
adminbae64d82013-08-01 10:50:15 -0700354 main.log.error("Ping test failed")
355 i = 17
356 result = main.FALSE
357 elif ping == main.TRUE:
358 i = i + 1
359 result = main.TRUE
360 endTime = time.time()
361 if result == main.TRUE:
362 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
363 else:
364 main.log.report("\tPING TESTS FAILED")
365 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
366
admin530b4c92013-08-14 16:54:35 -0700367
368# ******************************************************************************************************************************************************************
369# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
370
371 def CASE21(self,main) :
372 import json
373 from drivers.common.api.onosrestapidriver import *
374 main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.")
375 main.log.report("Check initially hostMAC exist on the mininet...")
376 host = main.params['YANK']['hostname']
377 mac = main.params['YANK']['hostmac']
378 RestIP1 = main.params['RESTCALL']['restIP1']
379 RestIP2 = main.params['RESTCALL']['restIP2']
380 RestPort = main.params['RESTCALL']['restPort']
381 url = main.params['RESTCALL']['restURL']
382 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
383
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" )
385 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
386 restcall = OnosRestApiDriver()
387 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
388 try:
389 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admincd0944e2013-09-30 12:07:19 -0700390 ip_found = Hoststatus[0]['ipv4'][0]
391 except:
admin530b4c92013-08-14 16:54:35 -0700392 Reststatus = 0
admincd0944e2013-09-30 12:07:19 -0700393
admin530b4c92013-08-14 16:54:35 -0700394 if Reststatus == 1:
395 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
admincd0944e2013-09-30 12:07:19 -0700396 if ip_found != None:
397 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
398 result = main.TRUE
399 else:
400 main.log.report("\t Found host attached to switch, but no IP address discovered.")
401 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700402 else:
403 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
404 result = main.FALSE
405
406 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
407
408 main.log.report("Yank out s1-eth1")
409 main.case("Yankout s6-eth1 (link to h1) from s1")
410 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
411 time.sleep(3)
412 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
413 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
414 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
415 try:
416 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admincd0944e2013-09-30 12:07:19 -0700417 except:
admin530b4c92013-08-14 16:54:35 -0700418 Reststatus = 0
419 if Reststatus == 0:
420 main.log.report("Attempt to yank out s1-eth1 from s1 sucessfully")
421 result = main.TRUE
422 else:
423 main.log.report("Attempt to yank out s1-eht1 from s1 failed.")
424 result = main.FALSE
425
426 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
427 main.log.report("Plug s1-eth1 into s6")
428 main.case("Plug s1-eth1 to s6")
429 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
430 time.sleep(3)
431 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
432 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
433 Reststatus, Hoststatus = restcall.find_host(RestIP2,RestPort,url,mac)
434 try:
435 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admincd0944e2013-09-30 12:07:19 -0700436 ip_found = Hoststatus[0]['ipv4'][0]
437 except:
admin530b4c92013-08-14 16:54:35 -0700438 Reststatus = 0
439 if Reststatus == 0:
440 main.log.report("Attempt to plug s1-eth1 to s6 FAILED")
441 result = main.FALSE
442 elif attachedSW == "00:00:00:00:00:00:00:06":
443 main.log.report("Attempt to plug s1-eht1 to s6 succeded.")
admincd0944e2013-09-30 12:07:19 -0700444 if ip_found != None:
445 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
446 result = main.TRUE
447 else:
448 main.log.report("\t Found host attached to switch, but no IP address discovered.")
449 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700450 else:
451 main.log.report( "FAILED to attach s1-eth1 to s6 correctly!")
452 result = main.FALSE
453
454 ###### Step to put interface "s1-eth1" back to s1"#####
455 main.log.report("Move s1-eth1 back on to s1")
456 main.case("Move s1-eth1 back to s1")
457 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
458 time.sleep(3)
459 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
460 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
461 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
462 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
463 try:
464 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admincd0944e2013-09-30 12:07:19 -0700465 ip_found = Hoststatus[0]['ipv4'][0]
466 except:
admin530b4c92013-08-14 16:54:35 -0700467 Reststatus = 0
468 if Reststatus == 0:
469 main.log.report("Attempt to plug s1-eth1 back to s1 FAILED")
470 result = main.FALSE
471 elif attachedSW == "00:00:00:00:00:00:00:01":
472 main.log.report("Attempt to plug s1-eht1 back to s1 succeded.")
admincd0944e2013-09-30 12:07:19 -0700473 if ip_found != None:
474 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
475 result = main.TRUE
476 else:
477 main.log.report("\t Found host attached to switch, but no IP address discovered.")
478 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700479 else:
480 main.log.report( "FAIL to attach s1-eth1 to s1 correctly!")
481 result = main.FALSE
482
483 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
484
485
admincd0944e2013-09-30 12:07:19 -0700486
487