admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 1 | |
| 2 | class RCOnosSanity4nodesJ : |
| 3 | |
| 4 | def __init__(self) : |
| 5 | self.default = '' |
| 6 | |
| 7 | #***************************************************************************************************************************************************************************************** |
| 8 | #Test startup |
| 9 | #Tests the startup of Zookeeper1, RamCloud1, 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 | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 12 | main.ONOS1.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 13 | main.ONOS2.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 14 | main.ONOS3.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 15 | main.ONOS4.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 16 | |
Jon Hall | 0955bc9 | 2014-04-16 17:00:19 -0700 | [diff] [blame] | 17 | main.Zookeeper1.start() |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 18 | main.Zookeeper2.start() |
| 19 | main.Zookeeper3.start() |
| 20 | main.Zookeeper4.start() |
| 21 | main.RamCloud1.stop_coor() |
| 22 | main.RamCloud1.stop_serv() |
| 23 | main.RamCloud2.stop_serv() |
| 24 | main.RamCloud3.stop_serv() |
| 25 | main.RamCloud4.stop_serv() |
admin | aef0055 | 2014-05-08 09:18:36 -0700 | [diff] [blame^] | 26 | time.sleep(10) |
| 27 | main.ONOS1.handle.sendline("~/ONOS/onos.sh rc deldb") |
| 28 | main.ONOS2.handle.sendline("~/ONOS/onos.sh rc deldb") |
| 29 | main.ONOS3.handle.sendline("~/ONOS/onos.sh rc deldb") |
| 30 | main.ONOS4.handle.sendline("~/ONOS/onos.sh rc deldb") |
| 31 | time.sleep(10) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 32 | main.log.report("Pulling latest code from github to all nodes") |
admin | 2121179 | 2014-04-15 15:42:39 -0700 | [diff] [blame] | 33 | for i in range(2): |
| 34 | uptodate = main.ONOS1.git_pull() |
| 35 | main.ONOS2.git_pull() |
| 36 | main.ONOS3.git_pull() |
| 37 | main.ONOS4.git_pull() |
| 38 | ver1 = main.ONOS1.get_version() |
| 39 | ver2 = main.ONOS4.get_version() |
| 40 | if ver1==ver2: |
| 41 | break |
| 42 | elif i==1: |
| 43 | main.ONOS2.git_pull("ONOS1 master") |
| 44 | main.ONOS3.git_pull("ONOS1 master") |
| 45 | main.ONOS4.git_pull("ONOS1 master") |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 46 | #if uptodate==0 |
| 47 | if 1: |
admin | 2121179 | 2014-04-15 15:42:39 -0700 | [diff] [blame] | 48 | main.ONOS1.git_compile() |
| 49 | main.ONOS2.git_compile() |
| 50 | main.ONOS3.git_compile() |
| 51 | main.ONOS4.git_compile() |
Jon Hall | 364f37a | 2014-04-17 10:29:35 -0700 | [diff] [blame] | 52 | main.ONOS1.print_version() |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 53 | # main.RamCloud1.git_pull() |
| 54 | # main.RamCloud2.git_pull() |
| 55 | # main.RamCloud3.git_pull() |
| 56 | # main.RamCloud4.git_pull() |
| 57 | # main.ONOS1.get_version() |
| 58 | # main.ONOS2.get_version() |
| 59 | # main.ONOS3.get_version() |
| 60 | # main.ONOS4.get_version() |
| 61 | main.RamCloud1.start_coor() |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 62 | time.sleep(1) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 63 | main.RamCloud1.start_serv() |
| 64 | main.RamCloud2.start_serv() |
| 65 | main.RamCloud3.start_serv() |
| 66 | main.RamCloud4.start_serv() |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 67 | main.ONOS1.start() |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 68 | time.sleep(5) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 69 | main.ONOS2.start() |
| 70 | main.ONOS3.start() |
| 71 | main.ONOS4.start() |
| 72 | main.ONOS1.start_rest() |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 73 | time.sleep(10) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 74 | test= main.ONOS1.rest_status() |
| 75 | if test == main.FALSE: |
| 76 | main.ONOS1.start_rest() |
| 77 | main.ONOS1.get_version() |
| 78 | main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections") |
| 79 | main.case("Checking if the startup was clean...") |
| 80 | main.step("Testing startup Zookeeper") |
| 81 | data = main.Zookeeper1.isup() |
| 82 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...") |
| 83 | main.step("Testing startup RamCloud") |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 84 | data = main.RamCloud1.status_serv() |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 85 | if data == main.FALSE: |
| 86 | main.RamCloud1.stop_coor() |
| 87 | main.RamCloud1.stop_serv() |
| 88 | main.RamCloud2.stop_serv() |
| 89 | main.RamCloud3.stop_serv() |
| 90 | main.RamCloud4.stop_serv() |
| 91 | |
| 92 | time.sleep(5) |
| 93 | main.RamCloud1.start_coor() |
| 94 | main.RamCloud1.start_serv() |
| 95 | main.RamCloud2.start_serv() |
| 96 | main.RamCloud3.start_serv() |
| 97 | main.RamCloud4.start_serv() |
| 98 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...") |
| 99 | main.step("Testing startup ONOS") |
| 100 | data = main.ONOS1.isup() |
admin | aef0055 | 2014-05-08 09:18:36 -0700 | [diff] [blame^] | 101 | for i in range(3): |
| 102 | if data == main.FALSE: |
| 103 | #main.log.report("Something is funny... restarting ONOS") |
| 104 | #main.ONOS1.stop() |
| 105 | time.sleep(3) |
| 106 | #main.ONOS1.start() |
| 107 | #time.sleep(5) |
| 108 | data = main.ONOS1.isup() |
| 109 | else: |
| 110 | break |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 111 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...") |
admin | aef0055 | 2014-05-08 09:18:36 -0700 | [diff] [blame^] | 112 | time.sleep(20) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 113 | |
| 114 | #********************************************************************************************************************************************************************************************** |
| 115 | #Assign Controllers |
| 116 | #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>). |
| 117 | #Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers. |
| 118 | #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 |
| 119 | # the controllers already assigned to the switch are not specified. |
| 120 | |
| 121 | def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches |
| 122 | import time |
| 123 | main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4") |
| 124 | main.case("Checking if one MN host exists") |
| 125 | main.step("Host IP Checking using checkIP") |
| 126 | result = main.Mininet1.checkIP(main.params['CASE1']['destination']) |
| 127 | main.step("Verifying the result") |
| 128 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured") |
| 129 | main.step("assigning ONOS controllers to switches") |
| 130 | for i in range(25): |
| 131 | if i < 3: |
| 132 | j=i+1 |
| 133 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 134 | time.sleep(1) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 135 | 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 | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 136 | elif i >= 3 and i < 5: |
| 137 | j=i+1 |
| 138 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 139 | time.sleep(1) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 140 | 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 | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 141 | elif i >= 5 and i < 15: |
| 142 | j=i+1 |
| 143 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 144 | time.sleep(1) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 145 | 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 | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 146 | else: |
| 147 | j=i+16 |
| 148 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 149 | time.sleep(1) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 150 | 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 | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 151 | main.Mininet1.get_sw_controller("s1") |
| 152 | |
| 153 | # ********************************************************************************************************************************************************************************************** |
| 154 | #Add Flows |
| 155 | #Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test |
| 156 | #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 |
| 157 | |
| 158 | def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update |
| 159 | main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update") |
| 160 | import time |
| 161 | main.case("Taking care of these flows!") |
| 162 | main.step("Cleaning out any leftover flows...") |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 163 | #main.ONOS1.delete_flow("all") |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 164 | strtTime = time.time() |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 165 | main.ONOS1.rm_flow() |
| 166 | print("world") |
| 167 | main.ONOS1.ad_flow() |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 168 | time.sleep(2) |
| 169 | main.ONOS1.ad_flow() |
| 170 | print("hello") |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 171 | # main.ONOS1.add_flow(main.params['FLOWDEF']['testONip'],main.params['FLOWDEF']['user'],main.params['FLOWDEF']['password'],main.params['FLOWDEF']['flowDef']) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 172 | main.case("Checking flows") |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 173 | |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 174 | count = 1 |
| 175 | i = 6 |
| 176 | while i < 16 : |
| 177 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 178 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 179 | if ping == main.FALSE and count < 9: |
| 180 | count = count + 1 |
| 181 | i = 6 |
| 182 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 183 | time.sleep(2) |
| 184 | elif ping == main.FALSE and count ==9: |
| 185 | main.log.error("Ping test failed") |
| 186 | i = 17 |
| 187 | result = main.FALSE |
| 188 | elif ping == main.TRUE: |
| 189 | i = i + 1 |
| 190 | result = main.TRUE |
| 191 | endTime = time.time() |
| 192 | if result == main.TRUE: |
| 193 | main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
| 194 | else: |
| 195 | main.log.report("\tFlows failed check") |
| 196 | |
| 197 | result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 198 | main.step("Verifying the result") |
| 199 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL") |
| 200 | |
| 201 | #********************************************************************************************************************************************************************************************** |
| 202 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 203 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 204 | #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. |
| 205 | #If the ping test fails 6 times, then the test case will return false |
| 206 | def CASE41(self,main) : |
| 207 | main.log.report("Testing Removal") |
| 208 | main.ONOS2.stop() |
| 209 | main.ONOS3.stop() |
| 210 | main.ONOS4.stop() |
| 211 | strtTime = time.time() |
| 212 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 213 | for i in range(10): |
| 214 | if result == main.FALSE: |
| 215 | time.sleep(5) |
| 216 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 217 | else: |
| 218 | break |
| 219 | |
| 220 | count = 1 |
| 221 | i = 6 |
| 222 | while i < 16 : |
| 223 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 224 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 225 | if ping == main.FALSE and count < 6: |
| 226 | count = count + 1 |
| 227 | i = 6 |
| 228 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 229 | time.sleep(2) |
| 230 | elif ping == main.FALSE and count ==6: |
| 231 | main.log.error("Ping test failed") |
| 232 | i = 17 |
| 233 | result = main.FALSE |
| 234 | elif ping == main.TRUE: |
| 235 | i = i + 1 |
| 236 | result = main.TRUE |
| 237 | endTime = time.time() |
| 238 | if result == main.TRUE: |
| 239 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 240 | else: |
| 241 | main.log.report("\tPING TEST FAIL") |
| 242 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 243 | time.sleep(10) |
| 244 | main.ONOS2.start() |
| 245 | main.ONOS3.start() |
| 246 | main.ONOS4.start() |
| 247 | time.sleep(10) |
| 248 | |
| 249 | |
| 250 | def CASE4(self,main) : |
| 251 | main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 252 | import time |
| 253 | for i in range(25): |
| 254 | if i < 15: |
| 255 | j=i+1 |
| 256 | 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 |
| 257 | else: |
| 258 | j=i+16 |
| 259 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 260 | |
| 261 | strtTime = time.time() |
| 262 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 263 | for i in range(10): |
| 264 | if result == main.FALSE: |
| 265 | time.sleep(5) |
| 266 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 267 | else: |
| 268 | break |
| 269 | |
| 270 | count = 1 |
| 271 | i = 6 |
| 272 | while i < 16 : |
| 273 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 274 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 275 | if ping == main.FALSE and count < 6: |
| 276 | count = count + 1 |
| 277 | i = 6 |
| 278 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 279 | time.sleep(2) |
| 280 | elif ping == main.FALSE and count ==6: |
| 281 | main.log.error("Ping test failed") |
| 282 | i = 17 |
| 283 | result = main.FALSE |
| 284 | elif ping == main.TRUE: |
| 285 | i = i + 1 |
| 286 | result = main.TRUE |
| 287 | endTime = time.time() |
| 288 | if result == main.TRUE: |
| 289 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 290 | else: |
| 291 | main.log.report("\tPING TEST FAIL") |
| 292 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 293 | time.sleep(10) |
| 294 | |
| 295 | # ********************************************************************************************************************************************************************************************** |
| 296 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 297 | |
| 298 | def CASE5(self,main) : |
| 299 | main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 300 | import time |
| 301 | for i in range(25): |
| 302 | if i < 15: |
| 303 | j=i+1 |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 304 | 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 | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 305 | else: |
| 306 | j=i+16 |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 307 | 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 | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 308 | |
| 309 | strtTime = time.time() |
| 310 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
admin | aef0055 | 2014-05-08 09:18:36 -0700 | [diff] [blame^] | 311 | for i in range(10): |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 312 | if result == main.FALSE: |
| 313 | time.sleep(5) |
| 314 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 315 | else: |
| 316 | break |
| 317 | |
| 318 | count = 1 |
| 319 | i = 6 |
| 320 | while i < 16 : |
| 321 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 322 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 323 | if ping == main.FALSE and count < 6: |
| 324 | count = count + 1 |
| 325 | i = 6 |
| 326 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 327 | time.sleep(2) |
| 328 | elif ping == main.FALSE and count ==6: |
| 329 | main.log.error("Ping test failed") |
| 330 | i = 17 |
| 331 | result = main.FALSE |
| 332 | elif ping == main.TRUE: |
| 333 | i = i + 1 |
| 334 | result = main.TRUE |
| 335 | endTime = time.time() |
| 336 | if result == main.TRUE: |
| 337 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 338 | else: |
| 339 | main.log.report("\tPING TEST FAILED") |
| 340 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 341 | |
| 342 | # ********************************************************************************************************************************************************************************************** |
| 343 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 344 | |
| 345 | def CASE6(self,main) : |
| 346 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
| 347 | import time |
| 348 | main.case("Bringing Link down... ") |
| 349 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 350 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 351 | |
| 352 | strtTime = time.time() |
| 353 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
admin | aef0055 | 2014-05-08 09:18:36 -0700 | [diff] [blame^] | 354 | for i in range(10): |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 355 | if result == main.FALSE: |
| 356 | time.sleep(5) |
| 357 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 358 | else: |
| 359 | break |
| 360 | |
| 361 | count = 1 |
| 362 | i = 6 |
| 363 | while i < 16 : |
| 364 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 365 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 366 | if ping == main.FALSE and count < 10: |
| 367 | count = count + 1 |
| 368 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 369 | i = 6 |
| 370 | time.sleep(2) |
| 371 | elif ping == main.FALSE and count == 10: |
| 372 | main.log.error("Ping test failed") |
| 373 | i = 17 |
| 374 | result = main.FALSE |
| 375 | elif ping == main.TRUE: |
| 376 | i = i + 1 |
| 377 | result = main.TRUE |
| 378 | endTime = time.time() |
| 379 | if result == main.TRUE: |
| 380 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 381 | else: |
| 382 | main.log.report("\tPING TEST FAILED") |
| 383 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 384 | |
| 385 | # ********************************************************************************************************************************************************************************************** |
| 386 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 387 | |
| 388 | def CASE7(self,main) : |
| 389 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 390 | import time |
| 391 | main.case("Bringing Link up... ") |
| 392 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 393 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 394 | time.sleep(5) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 395 | strtTime = time.time() |
| 396 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 397 | for i in range(2): |
| 398 | if result == main.FALSE: |
| 399 | time.sleep(5) |
| 400 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 401 | else: |
| 402 | break |
| 403 | |
| 404 | strtTime = time.time() |
| 405 | count = 1 |
| 406 | i = 6 |
| 407 | while i < 16 : |
| 408 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 409 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 410 | if ping == main.FALSE and count < 10: |
| 411 | count = count + 1 |
| 412 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 413 | i = 6 |
| 414 | time.sleep(2) |
| 415 | elif ping == main.FALSE and count ==10: |
| 416 | main.log.error("Ping test failed") |
| 417 | i = 17 |
| 418 | result = main.FALSE |
| 419 | elif ping == main.TRUE: |
| 420 | i = i + 1 |
| 421 | result = main.TRUE |
| 422 | endTime = time.time() |
| 423 | if result == main.TRUE: |
| 424 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 425 | else: |
| 426 | main.log.report("\tPING TESTS FAILED") |
| 427 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 428 | |
| 429 | |
| 430 | # ****************************************************************************************************************************************************************** |
| 431 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 432 | |
| 433 | def CASE21(self,main) : |
| 434 | import json |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 435 | main.log.report("Test device discovery function, by attach, detach, move host h1 from s1->s6->s1. Per mininet naming, switch port the host attaches will remain as 's1-eth1' throughout the test.") |
| 436 | main.log.report("Check initially hostMAC/IP exist on the mininet...") |
| 437 | host = main.params['YANK']['hostname'] |
| 438 | mac = main.params['YANK']['hostmac'] |
| 439 | hostip = main.params['YANK']['hostip'] |
| 440 | RestIP1 = main.params['RESTCALL']['restIP1'] |
| 441 | RestPort = main.params['RESTCALL']['restPort'] |
| 442 | url = main.params['RESTCALL']['restURL'] |
| 443 | |
| 444 | t_topowait = 0 |
| 445 | t_restwait = 10 |
| 446 | main.log.report( "Wait time from topo change to ping set to " + str(t_topowait)) |
| 447 | main.log.report( "Wait time from ping to rest call set to " + str(t_restwait)) |
| 448 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
| 449 | time.sleep(t_topowait) |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 450 | 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 | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 451 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 452 | time.sleep(t_restwait) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 453 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 454 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 455 | if Reststatus == 1: |
| 456 | main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 457 | result1 = main.TRUE |
| 458 | elif Reststatus > 1: |
| 459 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 460 | main.log.report("switches are: " + "; ".join(Switch)) |
| 461 | main.log.report("Ports are: " + "; ".join(Port)) |
| 462 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 463 | result1 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 464 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 465 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED") |
| 466 | result1 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 467 | else:# check if rest server is working |
| 468 | main.log.error("Issue with find host") |
| 469 | result1 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 470 | |
| 471 | |
| 472 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 473 | |
| 474 | main.log.report("Yank out s1-eth1") |
| 475 | main.case("Yankout s6-eth1 (link to h1) from s1") |
| 476 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 477 | time.sleep(t_topowait) |
| 478 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
| 479 | |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 480 | 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 | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 481 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 482 | time.sleep(t_restwait) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 483 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 484 | |
| 485 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 486 | if Reststatus == 1: |
| 487 | main.log.report("\tFAILED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 488 | result2 = main.FALSE |
| 489 | elif Reststatus > 1: |
| 490 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 491 | main.log.report("switches are: " + "; ".join(Switch)) |
| 492 | main.log.report("Ports are: " + "; ".join(Port)) |
| 493 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 494 | result2 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 495 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 496 | main.log.report("\t PASSED - Host " + host + " with MAC:" + str(mac) + " does not exist. PASSED - host is not supposed to be attached to the switch.") |
| 497 | result2 = main.TRUE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 498 | else:# check if rest server is working |
| 499 | main.log.error("Issue with find host") |
| 500 | result2 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 501 | |
| 502 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 503 | main.log.report("Plug s1-eth1 into s6") |
| 504 | main.case("Plug s1-eth1 to s6") |
| 505 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
| 506 | time.sleep(t_topowait) |
| 507 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...") |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 508 | 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 | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 509 | |
| 510 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 511 | time.sleep(t_restwait) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 512 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 513 | |
| 514 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 515 | if Reststatus == 1: |
| 516 | main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 517 | result3 = main.TRUE |
| 518 | elif Reststatus > 1: |
| 519 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 520 | main.log.report("switches are: " + "; ".join(Switch)) |
| 521 | main.log.report("Ports are: " + "; ".join(Port)) |
| 522 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 523 | result3 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 524 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 525 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 526 | result3 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 527 | else:# check if rest server is working |
| 528 | main.log.error("Issue with find host") |
| 529 | result3 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 530 | |
| 531 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 532 | main.log.report("Move s1-eth1 back on to s1") |
| 533 | main.case("Move s1-eth1 back to s1") |
| 534 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 535 | time.sleep(t_topowait) |
| 536 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 537 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...") |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 538 | 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 | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 539 | |
| 540 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 541 | time.sleep(t_restwait) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 542 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 543 | |
| 544 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 545 | if Reststatus == 1: |
| 546 | main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 547 | result4 = main.TRUE |
| 548 | elif Reststatus > 1: |
| 549 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED") |
| 550 | main.log.report("switches are: " + "; ".join(Switch)) |
| 551 | main.log.report("Ports are: " + "; ".join(Port)) |
| 552 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 553 | result4 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 554 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 555 | main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 556 | result4 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 557 | else:# check if rest server is working |
| 558 | main.log.error("Issue with find host") |
| 559 | result4 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 560 | |
| 561 | result = result1 and result2 and result3 and result4 |
| 562 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 563 | |
| 564 | # Run a pure ping test. |
| 565 | |
| 566 | def CASE31(self, main): |
| 567 | main.log.report("Performing Ping Test") |
| 568 | count = 1 |
| 569 | i = 6 |
| 570 | while i < 16 : |
| 571 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 572 | strtTime = time.time() |
| 573 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 574 | if ping == main.FALSE and count < 6: |
| 575 | count = count + 1 |
| 576 | i = 6 |
| 577 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 578 | time.sleep(2) |
| 579 | elif ping == main.FALSE and count ==6: |
| 580 | main.log.error("Ping test failed") |
| 581 | i = 17 |
| 582 | result = main.FALSE |
| 583 | elif ping == main.TRUE: |
| 584 | i = i + 1 |
| 585 | result = main.TRUE |
| 586 | endTime = time.time() |
| 587 | if result == main.TRUE: |
| 588 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 589 | else: |
| 590 | main.log.report("\tPING TEST FAIL") |
| 591 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 592 | |