admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 1 | |
| 2 | class OnosSanity4ARP : |
| 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) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 34 | test= main.ONOS1.rest_status() |
| 35 | if test == main.FALSE: |
| 36 | main.ONOS1.start_rest() |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 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") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 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 |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 116 | main.case("Taking care of these flows!") |
| 117 | main.step("Cleaning out any leftover flows...") |
| 118 | main.ONOS1.delete_flow("all") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 119 | strtTime = time.time() |
| 120 | main.ONOS1.add_flow(main.params['FLOWDEF']) |
| 121 | main.case("Checking flows") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 122 | |
| 123 | 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)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 128 | if ping == main.FALSE and count < 9: |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 129 | count = count + 1 |
| 130 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 131 | 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: |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 134 | main.log.error("Ping test failed") |
| 135 | i = 17 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 136 | result = main.FALSE |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 137 | elif ping == main.TRUE: |
| 138 | i = i + 1 |
| 139 | result2 = main.TRUE |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 140 | endTime = time.time() |
| 141 | if result == main.TRUE: |
| 142 | main.log.report("\tTime to complete add flows: "+str(round(endTime-strtTime,2))+" seconds") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 143 | else: |
| 144 | main.log.report("\tPING TEST FAIL") |
| 145 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 146 | result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 147 | main.step("Verifying the result") |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 148 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 149 | |
| 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']) |
| 166 | |
| 167 | strtTime = time.time() |
| 168 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 169 | for i in range(2): |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 170 | if result == main.FALSE: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 171 | time.sleep(5) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 172 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 173 | else: |
| 174 | break |
| 175 | |
| 176 | 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 |
| 184 | main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds") |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 185 | time.sleep(2) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 186 | elif ping == main.FALSE and count ==6: |
| 187 | main.log.error("Ping test failed") |
| 188 | i = 17 |
| 189 | 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) : |
| 204 | main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 205 | import time |
| 206 | for i in range(25): |
| 207 | if i < 15: |
| 208 | j=i+1 |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 209 | 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] | 210 | else: |
| 211 | j=i+16 |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 212 | 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] | 213 | |
| 214 | strtTime = time.time() |
| 215 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 216 | for i in range(2): |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 217 | if result == main.FALSE: |
| 218 | time.sleep(3) |
| 219 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 220 | else: |
| 221 | break |
| 222 | |
| 223 | 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)) |
| 228 | if ping == main.FALSE and count < 6: |
| 229 | count = count + 1 |
| 230 | i = 6 |
| 231 | main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds") |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 232 | time.sleep(2) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 233 | elif ping == main.FALSE and count ==6: |
| 234 | 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) : |
| 251 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
| 252 | 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") |
| 255 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 256 | |
| 257 | strtTime = time.time() |
| 258 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 259 | for i in range(2): |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 260 | if result == main.FALSE: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 261 | time.sleep(5) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 262 | 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 | |
| 266 | 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)) |
| 271 | if ping == main.FALSE and count < 10: |
| 272 | count = count + 1 |
| 273 | main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds") |
| 274 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 275 | time.sleep(2) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 276 | elif ping == main.FALSE and count == 10: |
| 277 | 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) : |
| 294 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 295 | 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") |
| 298 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
| 299 | |
| 300 | strtTime = time.time() |
| 301 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 302 | for i in range(2): |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 303 | if result == main.FALSE: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 304 | time.sleep(5) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 305 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 306 | else: |
| 307 | break |
| 308 | |
| 309 | 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)) |
| 315 | if ping == main.FALSE and count < 10: |
| 316 | count = count + 1 |
| 317 | main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds") |
| 318 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 319 | time.sleep(2) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 320 | elif ping == main.FALSE and count ==10: |
| 321 | 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 | |
| 334 | |
| 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 |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 340 | main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.") |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 341 | main.log.report("Check initially hostMAC/IP exist on the mininet...") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 342 | host = main.params['YANK']['hostname'] |
| 343 | mac = main.params['YANK']['hostmac'] |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 344 | hostip = main.params['YANK']['hostip'] |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 345 | RestIP1 = main.params['RESTCALL']['restIP1'] |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 346 | RestPort = main.params['RESTCALL']['restPort'] |
| 347 | url = main.params['RESTCALL']['restURL'] |
| 348 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 349 | |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 350 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
Jon Hall | f38785a | 2014-04-08 16:28:22 -0700 | [diff] [blame] | 351 | Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 352 | try: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 353 | attachedSW = RestSwitch[0]['dpid'] |
| 354 | host_ip = RestSwitch[0]['devices'][0]['ipv4addresses'] |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 355 | except: |
| 356 | Reststatus = 0 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 357 | if Reststatus == 1 and host_ip == '10.0.0.1': |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 358 | main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 359 | result = main.TRUE |
| 360 | elif Reststatus > 1: |
| 361 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " has " + Reststatus + " duplicated IP addresses. FAILED") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 362 | else: |
| 363 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 364 | result = main.FALSE |
| 365 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 366 | 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" ) |
| 367 | |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 368 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 369 | |
| 370 | main.log.report("Yank out s1-eth1") |
| 371 | main.case("Yankout s6-eth1 (link to h1) from s1") |
| 372 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 373 | time.sleep(3) |
| 374 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 375 | |
| 376 | 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" ) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 377 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
Jon Hall | f38785a | 2014-04-08 16:28:22 -0700 | [diff] [blame] | 378 | Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 379 | try: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 380 | attachedSW = RestSwitch[0]['dpid'] |
| 381 | host_ip = RestSwitch[0]['devices'][0]['ipv4addresses'] |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 382 | except: |
| 383 | Reststatus = 0 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 384 | if Reststatus == 1 and host_ip == '10.0.0.1': |
| 385 | main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 386 | result = main.TRUE |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 387 | elif Reststatus > 1: |
| 388 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " has " + Reststatus + " duplicated IP addresses. FAILED") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 389 | else: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 390 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 391 | result = main.FALSE |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 392 | |
| 393 | |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 394 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 395 | main.log.report("Plug s1-eth1 into s6") |
| 396 | main.case("Plug s1-eth1 to s6") |
| 397 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
| 398 | time.sleep(3) |
| 399 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...") |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 400 | 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" ) |
| 401 | |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 402 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
Jon Hall | f38785a | 2014-04-08 16:28:22 -0700 | [diff] [blame] | 403 | Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 404 | try: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 405 | attachedSW = RestSwitch[0]['dpid'] |
| 406 | host_ip = RestSwitch[0]['devices'][0]['ipv4addresses'] |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 407 | except: |
| 408 | Reststatus = 0 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 409 | if Reststatus == 1 and host_ip == '10.0.0.1': |
| 410 | main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW) |
| 411 | result = main.TRUE |
| 412 | elif Reststatus > 1: |
| 413 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " has " + Reststatus + " duplicated IP addresses. FAILED") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 414 | else: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 415 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 416 | result = main.FALSE |
| 417 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 418 | |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 419 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 420 | main.log.report("Move s1-eth1 back on to s1") |
| 421 | main.case("Move s1-eth1 back to s1") |
| 422 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 423 | time.sleep(3) |
| 424 | retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 425 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...") |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 426 | 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" ) |
| 427 | |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 428 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
Jon Hall | f38785a | 2014-04-08 16:28:22 -0700 | [diff] [blame] | 429 | Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 430 | try: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 431 | attachedSW = RestSwitch[0]['dpid'] |
| 432 | host_ip = RestSwitch[0]['devices'][0]['ipv4addresses'] |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 433 | except: |
| 434 | Reststatus = 0 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 435 | if Reststatus == 1 and host_ip == '10.0.0.1': |
| 436 | main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW) |
| 437 | result = main.TRUE |
| 438 | elif Reststatus > 1: |
| 439 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " has " + Reststatus + " duplicated IP addresses. FAILED") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 440 | else: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 441 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 442 | result = main.FALSE |
| 443 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 444 | |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 445 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 446 | |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 447 | |