blob: 4a11f98e371250739dfd1e8f3f1a2c16f981f34f [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)
adminbae64d82013-08-01 10:50:15 -070030 main.ONOS1.get_version()
31 main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections")
32 main.case("Checking if the startup was clean...")
33 main.step("Testing startup Zookeeper")
34 data = main.Zookeeper1.isup()
35 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
36 main.step("Testing startup Cassandra")
admin530b4c92013-08-14 16:54:35 -070037 data = main.Cassandra1.isup()
38 if data == main.FALSE:
39 main.Cassandra1.stop()
40 main.Cassandra2.stop()
41 main.Cassandra3.stop()
42 main.Cassandra4.stop()
43
44 time.sleep(5)
45
46 main.Cassandra1.start()
47 main.Cassandra2.start()
48 main.Cassandra3.start()
49 main.Cassandra4.start()
adminbae64d82013-08-01 10:50:15 -070050 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
51 main.step("Testing startup ONOS")
52 data = main.ONOS1.isup()
53 if data == main.FALSE:
54 main.log.report("Something is funny... restarting ONOS")
55 main.ONOS1.stop()
56 time.sleep(3)
57 main.ONOS1.start()
58 time.sleep(5)
59 data = main.ONOS1.isup()
60 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
61
62#**********************************************************************************************************************************************************************************************
63#Assign Controllers
64#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>).
65#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
66#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
67# the controllers already assigned to the switch are not specified.
68
69 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
70 import time
71 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
72 main.case("Checking if one MN host exists")
73 main.step("Host IP Checking using checkIP")
74 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
75 main.step("Verifying the result")
76 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
77 main.step("assigning ONOS controllers to switches")
78 for i in range(25):
79 if i < 3:
80 j=i+1
admin530b4c92013-08-14 16:54:35 -070081 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
adminbae64d82013-08-01 10:50:15 -070082 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070083 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 -070084 elif i >= 3 and i < 5:
85 j=i+1
admin530b4c92013-08-14 16:54:35 -070086 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
adminbae64d82013-08-01 10:50:15 -070087 time.sleep(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'],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 -070089 elif i >= 5 and i < 15:
90 j=i+1
admin530b4c92013-08-14 16:54:35 -070091 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
adminbae64d82013-08-01 10:50:15 -070092 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070093 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 -070094 else:
95 j=i+16
admin530b4c92013-08-14 16:54:35 -070096 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
adminbae64d82013-08-01 10:50:15 -070097 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070098 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 -070099 main.Mininet1.get_sw_controller("s1")
admincd0944e2013-09-30 12:07:19 -0700100
101 for i in range(9):
102 if result == main.FALSE:
103 time.sleep(3)
104 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
105 else:
106 break
adminbae64d82013-08-01 10:50:15 -0700107
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
admincd0944e2013-09-30 12:07:19 -0700116
117 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
118 for i in range(9):
119 if result == main.FALSE:
120 time.sleep(3)
121 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
122 else:
123 break
124
adminbae64d82013-08-01 10:50:15 -0700125 main.case("Taking care of these flows!")
126 main.step("Cleaning out any leftover flows...")
127 main.ONOS1.delete_flow("all")
128 time.sleep(5)
129 strtTime = time.time()
130 main.ONOS1.add_flow(main.params['FLOWDEF'])
131 main.case("Checking flows")
132 tmp = main.FALSE
133 count = 1
admine0ae8202013-08-28 11:51:43 -0700134 main.log.info("Wait for flows to be pushed to the switches, then check")
adminbae64d82013-08-01 10:50:15 -0700135 while tmp == main.FALSE:
136 main.step("Waiting")
admincd0944e2013-09-30 12:07:19 -0700137 time.sleep(5)
adminbae64d82013-08-01 10:50:15 -0700138 main.step("Checking")
139 tmp = main.ONOS1.check_flow()
140 if tmp == main.FALSE and count < 6:
141 count = count + 1
142 main.log.report("Flow failed, waiting 10 seconds then making attempt number "+str(count))
143 elif tmp == main.FALSE and count == 6:
admin530b4c92013-08-14 16:54:35 -0700144 result1 = main.FALSE
adminbae64d82013-08-01 10:50:15 -0700145 break
146 else:
admin530b4c92013-08-14 16:54:35 -0700147 result1 = main.TRUE
adminbae64d82013-08-01 10:50:15 -0700148 break
149 endTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700150 if result1 == main.TRUE:
adminbae64d82013-08-01 10:50:15 -0700151 main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
152 else:
153 main.log.report("\tFlows failed check")
admin530b4c92013-08-14 16:54:35 -0700154
adminbae64d82013-08-01 10:50:15 -0700155 count = 1
156 i = 6
157 while i < 16 :
158 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
159 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
160 if ping == main.FALSE and count < 3:
161 count = count + 1
162 i = 6
163 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
164 time.sleep(10)
165 elif ping == main.FALSE and count ==3:
166 main.log.error("Ping test failed")
167 i = 17
admin530b4c92013-08-14 16:54:35 -0700168 result2 = main.FALSE
169 elif ping == main.TRUE:
170 i = i + 1
171 result2 = main.TRUE
admin530b4c92013-08-14 16:54:35 -0700172 if result2 == main.TRUE:
admincd0944e2013-09-30 12:07:19 -0700173 main.log.info("Flows successfully added")
admin530b4c92013-08-14 16:54:35 -0700174 else:
175 main.log.report("\tPING TEST FAIL")
176
admin530b4c92013-08-14 16:54:35 -0700177 main.step("Verifying the result")
admincd0944e2013-09-30 12:07:19 -0700178 utilities.assert_equals(expect=main.TRUE,actual=result1 and result2,onpass="Flow check PASS",onfail="Flow check FAIL")
admin530b4c92013-08-14 16:54:35 -0700179
180#**********************************************************************************************************************************************************************************************
181#This test case removes Controllers 2,3, and 4 then performs a ping test.
182#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
183#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.
184#If the ping test fails 6 times, then the test case will return false
185
186 def CASE4(self,main) :
187 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
188 import time
189 for i in range(25):
190 if i < 15:
191 j=i+1
192 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
193 else:
194 j=i+16
195 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
admine0ae8202013-08-28 11:51:43 -0700196
197 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700198 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admincd0944e2013-09-30 12:07:19 -0700199 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700200 if result == main.FALSE:
admincd0944e2013-09-30 12:07:19 -0700201 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700202 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
203 else:
204 break
205
admin530b4c92013-08-14 16:54:35 -0700206 count = 1
207 i = 6
208 while i < 16 :
209 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
210 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
211 if ping == main.FALSE and count < 6:
212 count = count + 1
213 i = 6
214 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
215 time.sleep(5)
216 elif ping == main.FALSE and count ==6:
217 main.log.error("Ping test failed")
218 i = 17
adminbae64d82013-08-01 10:50:15 -0700219 result = main.FALSE
220 elif ping == main.TRUE:
221 i = i + 1
222 result = main.TRUE
223 endTime = time.time()
224 if result == main.TRUE:
225 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
226 else:
227 main.log.report("\tPING TEST FAIL")
228 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
229
230# **********************************************************************************************************************************************************************************************
231#This test case restores the controllers removed by Case 4 then performs a ping test.
232
233 def CASE5(self,main) :
admin530b4c92013-08-14 16:54:35 -0700234 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 -0700235 import time
236 for i in range(25):
237 if i < 15:
238 j=i+1
admin530b4c92013-08-14 16:54:35 -0700239 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 -0700240 else:
241 j=i+16
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'])
admine0ae8202013-08-28 11:51:43 -0700243
244 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700245 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admincd0944e2013-09-30 12:07:19 -0700246 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700247 if result == main.FALSE:
admincd0944e2013-09-30 12:07:19 -0700248 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700249 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
250 else:
251 break
252
adminbae64d82013-08-01 10:50:15 -0700253 count = 1
254 i = 6
255 while i < 16 :
256 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
257 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin530b4c92013-08-14 16:54:35 -0700258 if ping == main.FALSE and count < 6:
adminbae64d82013-08-01 10:50:15 -0700259 count = count + 1
260 i = 6
admin530b4c92013-08-14 16:54:35 -0700261 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
262 time.sleep(5)
263 elif ping == main.FALSE and count ==6:
adminbae64d82013-08-01 10:50:15 -0700264 main.log.error("Ping test failed")
265 i = 17
266 result = main.FALSE
267 elif ping == main.TRUE:
268 i = i + 1
269 result = main.TRUE
270 endTime = time.time()
271 if result == main.TRUE:
272 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
273 else:
274 main.log.report("\tPING TEST FAILED")
275 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
276
277# **********************************************************************************************************************************************************************************************
278#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
279
280 def CASE6(self,main) :
admine0ae8202013-08-28 11:51:43 -0700281 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 -0700282 import time
283 main.case("Bringing Link down... ")
284 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
adminbae64d82013-08-01 10:50:15 -0700285 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
admine0ae8202013-08-28 11:51:43 -0700286
287 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700288 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 -0700289 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700290 if result == main.FALSE:
admincd0944e2013-09-30 12:07:19 -0700291 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700292 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
293 else:
294 break
295
adminbae64d82013-08-01 10:50:15 -0700296 count = 1
297 i = 6
298 while i < 16 :
299 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
300 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700301 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700302 count = count + 1
admin530b4c92013-08-14 16:54:35 -0700303 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
adminbae64d82013-08-01 10:50:15 -0700304 i = 6
admin530b4c92013-08-14 16:54:35 -0700305 time.sleep(5)
admine0ae8202013-08-28 11:51:43 -0700306 elif ping == main.FALSE and count == 10:
adminbae64d82013-08-01 10:50:15 -0700307 main.log.error("Ping test failed")
308 i = 17
309 result = main.FALSE
310 elif ping == main.TRUE:
311 i = i + 1
312 result = main.TRUE
313 endTime = time.time()
314 if result == main.TRUE:
315 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
316 else:
317 main.log.report("\tPING TEST FAILED")
318 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
319
320# **********************************************************************************************************************************************************************************************
321#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
322
323 def CASE7(self,main) :
admine0ae8202013-08-28 11:51:43 -0700324 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 -0700325 import time
326 main.case("Bringing Link up... ")
327 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
adminbae64d82013-08-01 10:50:15 -0700328 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
admine0ae8202013-08-28 11:51:43 -0700329
330 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700331 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admincd0944e2013-09-30 12:07:19 -0700332 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700333 if result == main.FALSE:
admincd0944e2013-09-30 12:07:19 -0700334 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700335 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
336 else:
337 break
338
adminbae64d82013-08-01 10:50:15 -0700339 strtTime = time.time()
340 count = 1
341 i = 6
342 while i < 16 :
343 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
344 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700345 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700346 count = count + 1
admin530b4c92013-08-14 16:54:35 -0700347 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
adminbae64d82013-08-01 10:50:15 -0700348 i = 6
admin530b4c92013-08-14 16:54:35 -0700349 time.sleep(5)
admine0ae8202013-08-28 11:51:43 -0700350 elif ping == main.FALSE and count ==10:
adminbae64d82013-08-01 10:50:15 -0700351 main.log.error("Ping test failed")
352 i = 17
353 result = main.FALSE
354 elif ping == main.TRUE:
355 i = i + 1
356 result = main.TRUE
357 endTime = time.time()
358 if result == main.TRUE:
359 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
360 else:
361 main.log.report("\tPING TESTS FAILED")
362 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
363
admin530b4c92013-08-14 16:54:35 -0700364
365# ******************************************************************************************************************************************************************
366# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
367
368 def CASE21(self,main) :
369 import json
370 from drivers.common.api.onosrestapidriver import *
371 main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.")
372 main.log.report("Check initially hostMAC exist on the mininet...")
373 host = main.params['YANK']['hostname']
374 mac = main.params['YANK']['hostmac']
375 RestIP1 = main.params['RESTCALL']['restIP1']
376 RestIP2 = main.params['RESTCALL']['restIP2']
377 RestPort = main.params['RESTCALL']['restPort']
378 url = main.params['RESTCALL']['restURL']
379 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
380
381 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" )
382 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
383 restcall = OnosRestApiDriver()
384 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
385 try:
386 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admincd0944e2013-09-30 12:07:19 -0700387 ip_found = Hoststatus[0]['ipv4'][0]
388 except:
admin530b4c92013-08-14 16:54:35 -0700389 Reststatus = 0
admincd0944e2013-09-30 12:07:19 -0700390
admin530b4c92013-08-14 16:54:35 -0700391 if Reststatus == 1:
392 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
admincd0944e2013-09-30 12:07:19 -0700393 if ip_found != None:
394 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
395 result = main.TRUE
396 else:
397 main.log.report("\t Found host attached to switch, but no IP address discovered.")
398 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700399 else:
400 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
401 result = main.FALSE
402
403 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
404
405 main.log.report("Yank out s1-eth1")
406 main.case("Yankout s6-eth1 (link to h1) from s1")
407 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
408 time.sleep(3)
409 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
410 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
411 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
412 try:
413 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admincd0944e2013-09-30 12:07:19 -0700414 except:
admin530b4c92013-08-14 16:54:35 -0700415 Reststatus = 0
416 if Reststatus == 0:
417 main.log.report("Attempt to yank out s1-eth1 from s1 sucessfully")
418 result = main.TRUE
419 else:
420 main.log.report("Attempt to yank out s1-eht1 from s1 failed.")
421 result = main.FALSE
422
423 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
424 main.log.report("Plug s1-eth1 into s6")
425 main.case("Plug s1-eth1 to s6")
426 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
427 time.sleep(3)
428 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
429 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
430 Reststatus, Hoststatus = restcall.find_host(RestIP2,RestPort,url,mac)
431 try:
432 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admincd0944e2013-09-30 12:07:19 -0700433 ip_found = Hoststatus[0]['ipv4'][0]
434 except:
admin530b4c92013-08-14 16:54:35 -0700435 Reststatus = 0
436 if Reststatus == 0:
437 main.log.report("Attempt to plug s1-eth1 to s6 FAILED")
438 result = main.FALSE
439 elif attachedSW == "00:00:00:00:00:00:00:06":
440 main.log.report("Attempt to plug s1-eht1 to s6 succeded.")
admincd0944e2013-09-30 12:07:19 -0700441 if ip_found != None:
442 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
443 result = main.TRUE
444 else:
445 main.log.report("\t Found host attached to switch, but no IP address discovered.")
446 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700447 else:
448 main.log.report( "FAILED to attach s1-eth1 to s6 correctly!")
449 result = main.FALSE
450
451 ###### Step to put interface "s1-eth1" back to s1"#####
452 main.log.report("Move s1-eth1 back on to s1")
453 main.case("Move s1-eth1 back to s1")
454 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
455 time.sleep(3)
456 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
457 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
458 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
459 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
460 try:
461 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admincd0944e2013-09-30 12:07:19 -0700462 ip_found = Hoststatus[0]['ipv4'][0]
463 except:
admin530b4c92013-08-14 16:54:35 -0700464 Reststatus = 0
465 if Reststatus == 0:
466 main.log.report("Attempt to plug s1-eth1 back to s1 FAILED")
467 result = main.FALSE
468 elif attachedSW == "00:00:00:00:00:00:00:01":
469 main.log.report("Attempt to plug s1-eht1 back to s1 succeded.")
admincd0944e2013-09-30 12:07:19 -0700470 if ip_found != None:
471 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
472 result = main.TRUE
473 else:
474 main.log.report("\t Found host attached to switch, but no IP address discovered.")
475 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700476 else:
477 main.log.report( "FAIL to attach s1-eth1 to s1 correctly!")
478 result = main.FALSE
479
480 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
481
482
admincd0944e2013-09-30 12:07:19 -0700483
484