admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 1 | |
| 2 | class 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 |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 12 | main.Zookeeper1.start() |
| 13 | main.Zookeeper2.start() |
| 14 | main.Zookeeper3.start() |
| 15 | main.Zookeeper4.start() |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 16 | main.log.report("Pulling latest code from github to all nodes") |
| 17 | main.ONOS1.git_pull() |
| 18 | main.ONOS2.git_pull() |
| 19 | main.ONOS3.git_pull() |
| 20 | main.ONOS4.git_pull() |
| 21 | main.Cassandra1.start() |
| 22 | main.Cassandra2.start() |
| 23 | main.Cassandra3.start() |
| 24 | main.Cassandra4.start() |
| 25 | time.sleep(20) |
| 26 | 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() |
| 33 | time.sleep(5) |
| 34 | test= main.ONOS1.rest_status() |
| 35 | if test == main.FALSE: |
| 36 | main.ONOS1.start_rest() |
| 37 | 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") |
| 44 | 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() |
| 57 | 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 |
| 88 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 89 | time.sleep(1) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 90 | main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4']) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 91 | elif i >= 3 and i < 5: |
| 92 | j=i+1 |
| 93 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 94 | time.sleep(1) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 95 | main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4']) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 96 | elif i >= 5 and i < 15: |
| 97 | j=i+1 |
| 98 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 99 | time.sleep(1) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 100 | main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4']) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 101 | else: |
| 102 | j=i+16 |
| 103 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 104 | time.sleep(1) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 105 | main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4']) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 106 | 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") |
| 119 | time.sleep(5) |
| 120 | strtTime = time.time() |
| 121 | main.ONOS1.add_flow(main.params['FLOWDEF']) |
| 122 | main.case("Checking flows") |
| 123 | tmp = main.FALSE |
| 124 | count = 1 |
| 125 | main.log.info("Wait for flows to be pushed to the switches, then check") |
| 126 | while tmp == main.FALSE: |
| 127 | main.step("Waiting") |
| 128 | time.sleep(10) |
| 129 | main.step("Checking") |
| 130 | tmp = main.ONOS1.check_flow() |
| 131 | if tmp == main.FALSE and count < 6: |
| 132 | count = count + 1 |
| 133 | main.log.report("Flow failed, waiting 10 seconds then making attempt number "+str(count)) |
| 134 | elif tmp == main.FALSE and count == 6: |
| 135 | result1 = main.FALSE |
| 136 | break |
| 137 | else: |
| 138 | result1 = main.TRUE |
| 139 | break |
| 140 | endTime = time.time() |
| 141 | if result1 == main.TRUE: |
| 142 | main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
| 143 | else: |
| 144 | main.log.report("\tFlows failed check") |
| 145 | |
| 146 | strtTime = time.time() |
| 147 | count = 1 |
| 148 | i = 6 |
| 149 | while i < 16 : |
| 150 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 151 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 152 | if ping == main.FALSE and count < 3: |
| 153 | count = count + 1 |
| 154 | i = 6 |
| 155 | main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds") |
| 156 | time.sleep(10) |
| 157 | elif ping == main.FALSE and count ==3: |
| 158 | main.log.error("Ping test failed") |
| 159 | i = 17 |
| 160 | result2 = main.FALSE |
| 161 | elif ping == main.TRUE: |
| 162 | i = i + 1 |
| 163 | result2 = main.TRUE |
| 164 | endTime = time.time() |
| 165 | if result2 == main.TRUE: |
| 166 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 167 | else: |
| 168 | main.log.report("\tPING TEST FAIL") |
| 169 | |
| 170 | result3 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 171 | main.step("Verifying the result") |
| 172 | utilities.assert_equals(expect=main.TRUE,actual=result1 and result2 and result3,onpass="Flow check PASS",onfail="Flow check FAIL") |
| 173 | |
| 174 | #********************************************************************************************************************************************************************************************** |
| 175 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 176 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 177 | #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. |
| 178 | #If the ping test fails 6 times, then the test case will return false |
| 179 | |
| 180 | def CASE4(self,main) : |
| 181 | main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 182 | import time |
| 183 | for i in range(25): |
| 184 | if i < 15: |
| 185 | j=i+1 |
| 186 | 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 |
| 187 | else: |
| 188 | j=i+16 |
| 189 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 190 | |
| 191 | strtTime = time.time() |
| 192 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 193 | for i in range(2): |
| 194 | if result == main.FALSE: |
| 195 | time.sleep(5) |
| 196 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 197 | else: |
| 198 | break |
| 199 | |
| 200 | count = 1 |
| 201 | i = 6 |
| 202 | while i < 16 : |
| 203 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 204 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 205 | if ping == main.FALSE and count < 6: |
| 206 | count = count + 1 |
| 207 | i = 6 |
| 208 | main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds") |
| 209 | time.sleep(5) |
| 210 | elif ping == main.FALSE and count ==6: |
| 211 | main.log.error("Ping test failed") |
| 212 | i = 17 |
| 213 | result = main.FALSE |
| 214 | elif ping == main.TRUE: |
| 215 | i = i + 1 |
| 216 | result = main.TRUE |
| 217 | endTime = time.time() |
| 218 | if result == main.TRUE: |
| 219 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 220 | else: |
| 221 | main.log.report("\tPING TEST FAIL") |
| 222 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 223 | |
| 224 | # ********************************************************************************************************************************************************************************************** |
| 225 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 226 | |
| 227 | def CASE5(self,main) : |
| 228 | main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 229 | import time |
| 230 | for i in range(25): |
| 231 | if i < 15: |
| 232 | j=i+1 |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 233 | main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4']) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 234 | else: |
| 235 | j=i+16 |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 236 | main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4']) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 237 | |
| 238 | strtTime = time.time() |
| 239 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 240 | for i in range(2): |
| 241 | if result == main.FALSE: |
| 242 | time.sleep(5) |
| 243 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 244 | else: |
| 245 | break |
| 246 | |
| 247 | count = 1 |
| 248 | i = 6 |
| 249 | while i < 16 : |
| 250 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 251 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 252 | if ping == main.FALSE and count < 6: |
| 253 | count = count + 1 |
| 254 | i = 6 |
| 255 | main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds") |
| 256 | time.sleep(5) |
| 257 | elif ping == main.FALSE and count ==6: |
| 258 | main.log.error("Ping test failed") |
| 259 | i = 17 |
| 260 | result = main.FALSE |
| 261 | elif ping == main.TRUE: |
| 262 | i = i + 1 |
| 263 | result = main.TRUE |
| 264 | endTime = time.time() |
| 265 | if result == main.TRUE: |
| 266 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 267 | else: |
| 268 | main.log.report("\tPING TEST FAILED") |
| 269 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 270 | |
| 271 | # ********************************************************************************************************************************************************************************************** |
| 272 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 273 | |
| 274 | def CASE6(self,main) : |
| 275 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
| 276 | import time |
| 277 | main.case("Bringing Link down... ") |
| 278 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 279 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 280 | |
| 281 | strtTime = time.time() |
| 282 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 283 | for i in range(2): |
| 284 | if result == main.FALSE: |
| 285 | time.sleep(5) |
| 286 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 287 | else: |
| 288 | break |
| 289 | |
| 290 | count = 1 |
| 291 | i = 6 |
| 292 | while i < 16 : |
| 293 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 294 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 295 | if ping == main.FALSE and count < 10: |
| 296 | count = count + 1 |
| 297 | main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds") |
| 298 | i = 6 |
| 299 | time.sleep(5) |
| 300 | elif ping == main.FALSE and count == 10: |
| 301 | main.log.error("Ping test failed") |
| 302 | i = 17 |
| 303 | result = main.FALSE |
| 304 | elif ping == main.TRUE: |
| 305 | i = i + 1 |
| 306 | result = main.TRUE |
| 307 | endTime = time.time() |
| 308 | if result == main.TRUE: |
| 309 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 310 | else: |
| 311 | main.log.report("\tPING TEST FAILED") |
| 312 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 313 | |
| 314 | # ********************************************************************************************************************************************************************************************** |
| 315 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 316 | |
| 317 | def CASE7(self,main) : |
| 318 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 319 | import time |
| 320 | main.case("Bringing Link up... ") |
| 321 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 322 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
| 323 | |
| 324 | strtTime = time.time() |
| 325 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 326 | for i in range(2): |
| 327 | if result == main.FALSE: |
| 328 | time.sleep(5) |
| 329 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 330 | else: |
| 331 | break |
| 332 | |
| 333 | strtTime = time.time() |
| 334 | count = 1 |
| 335 | i = 6 |
| 336 | while i < 16 : |
| 337 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 338 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 339 | if ping == main.FALSE and count < 10: |
| 340 | count = count + 1 |
| 341 | main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds") |
| 342 | i = 6 |
| 343 | time.sleep(5) |
| 344 | elif ping == main.FALSE and count ==10: |
| 345 | main.log.error("Ping test failed") |
| 346 | i = 17 |
| 347 | result = main.FALSE |
| 348 | elif ping == main.TRUE: |
| 349 | i = i + 1 |
| 350 | result = main.TRUE |
| 351 | endTime = time.time() |
| 352 | if result == main.TRUE: |
| 353 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 354 | else: |
| 355 | main.log.report("\tPING TESTS FAILED") |
| 356 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 357 | |
| 358 | |
| 359 | # ****************************************************************************************************************************************************************** |
| 360 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 361 | |
| 362 | def CASE21(self,main) : |
| 363 | import json |
| 364 | from drivers.common.api.onosrestapidriver import * |
| 365 | main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.") |
| 366 | main.log.report("Check initially hostMAC exist on the mininet...") |
| 367 | host = main.params['YANK']['hostname'] |
| 368 | mac = main.params['YANK']['hostmac'] |
| 369 | RestIP1 = main.params['RESTCALL']['restIP1'] |
| 370 | RestIP2 = main.params['RESTCALL']['restIP2'] |
| 371 | RestPort = main.params['RESTCALL']['restPort'] |
| 372 | url = main.params['RESTCALL']['restURL'] |
| 373 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
| 374 | |
| 375 | 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" ) |
| 376 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 377 | restcall = OnosRestApiDriver() |
| 378 | Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac) |
| 379 | try: |
| 380 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
| 381 | host_ip = Hoststatus[0]['ipv4'][0] |
| 382 | except: |
| 383 | Reststatus = 0 |
| 384 | if Reststatus == 1 and host_ip == '10.0.0.1': |
| 385 | main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW) |
| 386 | result = main.TRUE |
| 387 | else: |
| 388 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 389 | result = main.FALSE |
| 390 | |
| 391 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 392 | |
| 393 | main.log.report("Yank out s1-eth1") |
| 394 | main.case("Yankout s6-eth1 (link to h1) from s1") |
| 395 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 396 | time.sleep(3) |
| 397 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
| 398 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 399 | Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac) |
| 400 | try: |
| 401 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
| 402 | except IndexError: |
| 403 | Reststatus = 0 |
| 404 | if Reststatus == 0: |
| 405 | main.log.report("Attempt to yank out s1-eth1 from s1 sucessfully") |
| 406 | result = main.TRUE |
| 407 | else: |
| 408 | main.log.report("Attempt to yank out s1-eht1 from s1 failed.") |
| 409 | result = main.FALSE |
| 410 | |
| 411 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 412 | main.log.report("Plug s1-eth1 into s6") |
| 413 | main.case("Plug s1-eth1 to s6") |
| 414 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
| 415 | time.sleep(3) |
| 416 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...") |
| 417 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 418 | Reststatus, Hoststatus = restcall.find_host(RestIP2,RestPort,url,mac) |
| 419 | try: |
| 420 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
| 421 | host_ip = Hoststatus[0]['ipv4'][0] |
| 422 | except: |
| 423 | Reststatus = 0 |
| 424 | if Reststatus == 0: |
| 425 | main.log.report("Attempt to plug s1-eth1 to s6 FAILED") |
| 426 | result = main.FALSE |
| 427 | elif attachedSW == "00:00:00:00:00:00:00:06"and host_ip == '10.0.0.1': |
| 428 | main.log.report("Attempt to plug s1-eht1 to s6 succeded.") |
| 429 | result = main.TRUE |
| 430 | else: |
| 431 | main.log.report( "FAILED to attach s1-eth1 to s6 correctly!") |
| 432 | result = main.FALSE |
| 433 | |
| 434 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 435 | main.log.report("Move s1-eth1 back on to s1") |
| 436 | main.case("Move s1-eth1 back to s1") |
| 437 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 438 | time.sleep(3) |
| 439 | retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 440 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...") |
| 441 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 442 | Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac) |
| 443 | try: |
| 444 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
| 445 | host_ip = Hoststatus[0]['ipv4'][0] |
| 446 | except: |
| 447 | Reststatus = 0 |
| 448 | if Reststatus == 0: |
| 449 | main.log.report("Attempt to plug s1-eth1 back to s1 FAILED") |
| 450 | result = main.FALSE |
| 451 | elif attachedSW == "00:00:00:00:00:00:00:01" and host_ip == '10.0.0.1': |
| 452 | main.log.report("Attempt to plug s1-eht1 back to s1 succeded.") |
| 453 | result = main.TRUE |
| 454 | else: |
| 455 | main.log.report( "FAIL to attach s1-eth1 to s1 correctly!") |
| 456 | result = main.FALSE |
| 457 | |
| 458 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 459 | |
| 460 | |