admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 1 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 2 | class JamesTest : |
| 3 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 4 | |
| 5 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 6 | def __init__(self) : |
| 7 | self.default = '' |
| 8 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 9 | # def print_hello_world(self,main): |
| 10 | # print("hello world") |
| 11 | #***************************************************************************************************************************************************************************************** |
| 12 | #Test startup |
| 13 | #Tests the startup of Zookeeper1, RamCloud1, and ONOS1 to be certain that all started up successfully |
| 14 | def CASE1(self,main) : #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version |
| 15 | main.case("Initial setup") |
| 16 | main.step("Stop ONOS") |
| 17 | import time |
| 18 | main.ONOS1.stop_all() |
| 19 | main.ONOS2.stop_all() |
| 20 | main.ONOS3.stop_all() |
| 21 | # main.print_hello_world() |
| 22 | main.ONOS4.stop_all() |
| 23 | main.ONOS2.stop_rest() |
| 24 | main.ONOS1.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 25 | main.ONOS2.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 26 | main.ONOS3.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 27 | main.ONOS4.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 28 | main.step("Start tcpdump on mn") |
| 29 | # main.Mininet2.start_tcpdump(main.params['tcpdump']['filename'], intf = main.params['tcpdump']['intf'], port = main.params['tcpdump']['port']) |
| 30 | main.step("Start ONOS") |
| 31 | main.Zookeeper1.start() |
| 32 | main.Zookeeper2.start() |
| 33 | main.Zookeeper3.start() |
| 34 | main.Zookeeper4.start() |
| 35 | time.sleep(1) |
| 36 | main.RamCloud1.del_db() |
| 37 | main.RamCloud2.del_db() |
| 38 | main.RamCloud3.del_db() |
| 39 | main.RamCloud4.del_db() |
| 40 | main.log.report("Pulling latest code from github to all nodes") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 41 | for i in range(2): |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 42 | uptodate = main.ONOS1.git_pull() |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 43 | main.ONOS2.git_pull() |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 44 | main.ONOS3.git_pull() |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 45 | main.ONOS4.git_pull() |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 46 | ver1 = main.ONOS1.get_version() |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 47 | ver2 = main.ONOS4.get_version() |
| 48 | if ver1==ver2: |
| 49 | break |
| 50 | elif i==1: |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 51 | main.ONOS2.git_pull("ONOS1 master") |
| 52 | main.ONOS3.git_pull("ONOS1 master") |
| 53 | main.ONOS4.git_pull("ONOS1 master") |
| 54 | if uptodate==0: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 55 | # if 1: |
| 56 | main.ONOS1.git_compile() |
| 57 | main.ONOS2.git_compile() |
| 58 | main.ONOS3.git_compile() |
| 59 | main.ONOS4.git_compile() |
| 60 | main.ONOS1.print_version() |
| 61 | main.ONOS1.start_all() |
| 62 | main.ONOS2.start_all() |
| 63 | main.ONOS3.start_all() |
| 64 | main.ONOS4.start_all() |
| 65 | main.ONOS2.start_rest() |
| 66 | test= main.ONOS2.rest_status() |
| 67 | if test == main.FALSE: |
| 68 | main.ONOS1.start_rest() |
| 69 | main.ONOS1.get_version() |
| 70 | main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections") |
| 71 | main.step("Testing startup Zookeeper") |
| 72 | data = main.Zookeeper1.isup() |
| 73 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...") |
| 74 | main.step("Testing startup RamCloud") |
| 75 | data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv() |
| 76 | if data == main.FALSE: |
| 77 | main.RamCloud1.stop_coor() |
| 78 | main.RamCloud1.stop_serv() |
| 79 | main.RamCloud2.stop_serv() |
| 80 | main.RamCloud3.stop_serv() |
| 81 | main.RamCloud4.stop_serv() |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 82 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 83 | time.sleep(5) |
| 84 | main.RamCloud1.start_coor() |
| 85 | main.RamCloud1.start_serv() |
| 86 | main.RamCloud2.start_serv() |
| 87 | main.RamCloud3.start_serv() |
| 88 | main.RamCloud4.start_serv() |
| 89 | time.sleep(5) |
| 90 | data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv() |
| 91 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 92 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 93 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...") |
| 94 | main.step("Testing startup ONOS") |
| 95 | data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup() |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 96 | for i in range(3): |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 97 | if data == main.FALSE: |
| 98 | #main.log.report("Something is funny... restarting ONOS") |
| 99 | #main.ONOS1.stop() |
| 100 | time.sleep(3) |
| 101 | #main.ONOS1.start() |
| 102 | #time.sleep(5) |
| 103 | data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup() |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 104 | else: |
| 105 | break |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 106 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...") |
| 107 | time.sleep(20) |
| 108 | |
| 109 | #********************************************************************************************************************************************************************************************** |
| 110 | #Assign Controllers |
| 111 | #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>). |
| 112 | #Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers. |
| 113 | #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 |
| 114 | # the controllers already assigned to the switch are not specified. |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 115 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 116 | def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 117 | import time |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 118 | main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4") |
| 119 | main.case("Checking if one MN host exists") |
| 120 | main.step("Host IP Checking using checkIP") |
| 121 | result = main.Mininet1.checkIP(main.params['CASE1']['destination']) |
| 122 | main.step("Verifying the result") |
| 123 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured") |
| 124 | main.step("assigning ONOS controllers to switches") |
| 125 | for i in range(25): |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 126 | if i < 3: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 127 | j=i+1 |
| 128 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 129 | time.sleep(1) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 130 | 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']) |
| 131 | elif i >= 3 and i < 5: |
| 132 | j=i+1 |
| 133 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 134 | time.sleep(1) |
admin | 8a30f34 | 2014-06-24 15:54:26 -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']) |
| 136 | elif i >= 5 and i < 15: |
| 137 | j=i+1 |
| 138 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 139 | time.sleep(1) |
admin | 8a30f34 | 2014-06-24 15:54:26 -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 | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 141 | else: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 142 | j=i+16 |
| 143 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 144 | time.sleep(2) |
admin | 8a30f34 | 2014-06-24 15:54:26 -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']) |
| 146 | main.Mininet1.get_sw_controller("s1") |
| 147 | time.sleep(10) |
| 148 | |
| 149 | # ********************************************************************************************************************************************************************************************** |
| 150 | #Add Flows |
| 151 | #Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test |
| 152 | #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 |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 153 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 154 | def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update |
| 155 | main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 156 | import time |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 157 | main.case("Taking care of these flows!") |
| 158 | main.step("Cleaning out any leftover flows...") |
| 159 | #main.ONOS1.delete_flow("all") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 160 | strtTime = time.time() |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 161 | main.ONOS1.rm_intents() |
| 162 | print("world") |
| 163 | main.ONOS1.add_intents() |
| 164 | time.sleep(2) |
| 165 | main.ONOS1.add_intents() |
| 166 | print("hello") |
| 167 | # main.ONOS1.add_flow(main.params['FLOWDEF']['testONip'],main.params['FLOWDEF']['user'],main.params['FLOWDEF']['password'],main.params['FLOWDEF']['flowDef']) |
| 168 | main.case("Checking flows") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 169 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 170 | count = 1 |
| 171 | i = 6 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 172 | while i < 16 : |
| 173 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 174 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 175 | if ping == main.FALSE and count < 9: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 176 | count = count + 1 |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 177 | i = 6 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 178 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 179 | time.sleep(2) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 180 | elif ping == main.FALSE and count ==9: |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 181 | main.log.error("Ping test failed") |
| 182 | i = 17 |
| 183 | result = main.FALSE |
| 184 | elif ping == main.TRUE: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 185 | i = i + 1 |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 186 | result = main.TRUE |
| 187 | endTime = time.time() |
| 188 | if result == main.TRUE: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 189 | main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 190 | else: |
| 191 | main.log.report("\tFlows failed check") |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 192 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 193 | result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 194 | main.step("Verifying the result") |
| 195 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL") |
| 196 | |
| 197 | #********************************************************************************************************************************************************************************************** |
| 198 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 199 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 200 | #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. |
| 201 | #If the ping test fails 6 times, then the test case will return false |
| 202 | def CASE41(self,main) : |
| 203 | main.log.report("Testing Removal") |
| 204 | time.sleep(10) |
| 205 | main.ONOS2.stop() |
| 206 | time.sleep(10) |
| 207 | main.ONOS3.stop() |
| 208 | time.sleep(10) |
| 209 | main.ONOS4.stop() |
| 210 | time.sleep(15) |
| 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(20) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 248 | |
| 249 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 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 |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 269 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 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 < 3: |
| 303 | j=i+1 |
| 304 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 305 | time.sleep(1) |
| 306 | 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']) |
| 307 | elif i >= 3 and i < 5: |
| 308 | j=i+1 |
| 309 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 310 | time.sleep(1) |
| 311 | 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']) |
| 312 | elif i >= 5 and i < 15: |
| 313 | j=i+1 |
| 314 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 315 | time.sleep(1) |
| 316 | 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']) |
| 317 | else: |
| 318 | j=i+16 |
| 319 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 320 | 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']) |
| 321 | time.sleep(1) |
| 322 | strtTime = time.time() |
| 323 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 324 | for i in range(10): |
| 325 | if result == main.FALSE: |
| 326 | time.sleep(5) |
| 327 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 328 | else: |
| 329 | break |
| 330 | |
| 331 | count = 1 |
| 332 | i = 6 |
| 333 | while i < 16 : |
| 334 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 335 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 336 | if ping == main.FALSE and count < 6: |
| 337 | count = count + 1 |
| 338 | i = 6 |
| 339 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 340 | time.sleep(2) |
| 341 | elif ping == main.FALSE and count ==6: |
| 342 | main.log.error("Ping test failed") |
| 343 | i = 17 |
| 344 | result = main.FALSE |
| 345 | elif ping == main.TRUE: |
| 346 | i = i + 1 |
| 347 | result = main.TRUE |
| 348 | endTime = time.time() |
| 349 | if result == main.TRUE: |
| 350 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 351 | else: |
| 352 | main.log.report("\tPING TEST FAILED") |
| 353 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 354 | |
| 355 | # ********************************************************************************************************************************************************************************************** |
| 356 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 357 | |
| 358 | def CASE6(self,main) : |
| 359 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
| 360 | import time |
| 361 | main.case("Bringing Link down... ") |
| 362 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 363 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 364 | time.sleep(10) |
| 365 | strtTime = time.time() |
| 366 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 367 | for i in range(10): |
| 368 | if result == main.FALSE: |
| 369 | time.sleep(5) |
| 370 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 371 | else: |
| 372 | break |
| 373 | |
| 374 | count = 1 |
| 375 | i = 6 |
| 376 | while i < 16 : |
| 377 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 378 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 379 | if ping == main.FALSE and count < 10: |
| 380 | count = count + 1 |
| 381 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 382 | i = 6 |
| 383 | time.sleep(2) |
| 384 | elif ping == main.FALSE and count == 10: |
| 385 | main.log.error("Ping test failed") |
| 386 | i = 17 |
| 387 | result = main.FALSE |
| 388 | elif ping == main.TRUE: |
| 389 | i = i + 1 |
| 390 | result = main.TRUE |
| 391 | endTime = time.time() |
| 392 | if result == main.TRUE: |
| 393 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 394 | else: |
| 395 | main.log.report("\tPING TEST FAILED") |
| 396 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 397 | |
| 398 | # ********************************************************************************************************************************************************************************************** |
| 399 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 400 | |
| 401 | def CASE7(self,main) : |
| 402 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 403 | import time |
| 404 | main.case("Bringing Link up... ") |
| 405 | result = main.Mininet1.link(END1='s1',END2='s3',OPTION="down") |
| 406 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 407 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
| 408 | time.sleep(10) |
| 409 | strtTime = time.time() |
| 410 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 411 | for i in range(10): |
| 412 | if result == main.FALSE: |
| 413 | time.sleep(15) |
| 414 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 415 | else: |
| 416 | break |
| 417 | |
| 418 | strtTime = time.time() |
| 419 | count = 1 |
| 420 | i = 6 |
| 421 | while i < 16 : |
| 422 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 423 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 424 | if ping == main.FALSE and count < 10: |
| 425 | count = count + 1 |
| 426 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 427 | i = 6 |
| 428 | time.sleep(2) |
| 429 | elif ping == main.FALSE and count ==10: |
| 430 | main.log.error("Ping test failed") |
| 431 | i = 17 |
| 432 | result = main.FALSE |
| 433 | elif ping == main.TRUE: |
| 434 | i = i + 1 |
| 435 | result = main.TRUE |
| 436 | endTime = time.time() |
| 437 | if result == main.TRUE: |
| 438 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 439 | else: |
| 440 | main.log.report("\tPING TESTS FAILED") |
| 441 | data = main.Mininet1.link(END1='s1',END2='s3',OPTION="up") |
| 442 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 443 | |
| 444 | |
| 445 | # ****************************************************************************************************************************************************************** |
| 446 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 447 | |
| 448 | def CASE21(self,main) : |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 449 | import json |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 450 | 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.") |
| 451 | main.log.report("Check initially hostMAC/IP exist on the mininet...") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 452 | host = main.params['YANK']['hostname'] |
| 453 | mac = main.params['YANK']['hostmac'] |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 454 | RestIP1 = main.params['RESTCALL']['restIP1'] |
| 455 | RestPort = main.params['RESTCALL']['restPort'] |
| 456 | url = main.params['RESTCALL']['restURL'] |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 457 | |
| 458 | t_topowait = 5 |
| 459 | t_restwait = 5 |
| 460 | main.log.report( "Wait time from topo change to ping set to " + str(t_topowait)) |
| 461 | main.log.report( "Wait time from ping to rest call set to " + str(t_restwait)) |
| 462 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
| 463 | time.sleep(t_topowait) |
| 464 | 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 | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 465 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 466 | time.sleep(t_restwait) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 467 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
| 468 | main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus)) |
| 469 | if Reststatus == 1: |
| 470 | main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0])) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 471 | result1 = main.TRUE |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 472 | elif Reststatus > 1: |
| 473 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 474 | main.log.report("switches are: " + "; ".join(Switch)) |
| 475 | main.log.report("Ports are: " + "; ".join(Port)) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 476 | result1 = main.FALSE |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 477 | elif Reststatus == 0 and Switch == []: |
| 478 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED") |
| 479 | result1 = main.FALSE |
| 480 | else:# check if rest server is working |
| 481 | main.log.error("Issue with find host") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 482 | result1 = main.FALSE |
| 483 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 484 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 485 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 486 | |
| 487 | main.log.report("Yank out s1-eth1") |
| 488 | main.case("Yankout s6-eth1 (link to h1) from s1") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 489 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 490 | time.sleep(t_topowait) |
| 491 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 492 | |
| 493 | 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 | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 494 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 495 | time.sleep(t_restwait) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 496 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
| 497 | |
| 498 | main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus)) |
| 499 | if Reststatus == 1: |
| 500 | main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port)) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 501 | result2 = main.FALSE |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 502 | elif Reststatus > 1: |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 503 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 504 | main.log.report("switches are: " + "; ".join(Switch)) |
| 505 | main.log.report("Ports are: " + "; ".join(Port)) |
| 506 | main.log.report("MACs are: " + "; ".join(MAC)) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 507 | result2 = main.FALSE |
| 508 | elif Reststatus == 0 and Switch == []: |
| 509 | 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.") |
| 510 | result2 = main.TRUE |
| 511 | else:# check if rest server is working |
| 512 | main.log.error("Issue with find host") |
| 513 | result2 = main.FALSE |
| 514 | |
| 515 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 516 | main.log.report("Plug s1-eth1 into s6") |
| 517 | main.case("Plug s1-eth1 to s6") |
| 518 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 519 | time.sleep(t_topowait) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 520 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...") |
| 521 | 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" ) |
| 522 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 523 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 524 | time.sleep(t_restwait) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 525 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
| 526 | |
| 527 | main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus)) |
| 528 | if Reststatus == 1: |
| 529 | main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0])) |
| 530 | result3 = main.TRUE |
| 531 | elif Reststatus > 1: |
| 532 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 533 | main.log.report("switches are: " + "; ".join(Switch)) |
| 534 | main.log.report("Ports are: " + "; ".join(Port)) |
| 535 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 536 | result3 = main.FALSE |
| 537 | elif Reststatus == 0 and Switch == []: |
| 538 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 539 | result3 = main.FALSE |
| 540 | else:# check if rest server is working |
| 541 | main.log.error("Issue with find host") |
| 542 | result3 = main.FALSE |
| 543 | |
| 544 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 545 | main.log.report("Move s1-eth1 back on to s1") |
| 546 | main.case("Move s1-eth1 back to s1") |
| 547 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 548 | time.sleep(t_topowait) |
| 549 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 550 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...") |
| 551 | 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" ) |
| 552 | |
| 553 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 554 | time.sleep(t_restwait) |
| 555 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 556 | |
| 557 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 558 | if Reststatus == 1: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 559 | main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0])) |
| 560 | result4 = main.TRUE |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 561 | elif Reststatus > 1: |
| 562 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED") |
| 563 | main.log.report("switches are: " + "; ".join(Switch)) |
| 564 | main.log.report("Ports are: " + "; ".join(Port)) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 565 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 566 | result4 = main.FALSE |
| 567 | elif Reststatus == 0 and Switch == []: |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 568 | main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 569 | result4 = main.FALSE |
| 570 | else:# check if rest server is working |
| 571 | main.log.error("Issue with find host") |
| 572 | result4 = main.FALSE |
| 573 | time.sleep(20) |
| 574 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac) |
| 575 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 576 | if Reststatus ==1: |
| 577 | main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout") |
| 578 | elif Reststatus>1: |
| 579 | main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)") |
| 580 | elif Reststatus==0: |
| 581 | main.log.report("\t PASSED - Device cleared after timeout") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 582 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 583 | result = result1 and result2 and result3 and result4 |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 584 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 585 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 586 | # Run a pure ping test. |
| 587 | |
| 588 | def CASE31(self, main): |
| 589 | main.log.report("Performing Ping Test") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 590 | count = 1 |
| 591 | i = 6 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 592 | while i < 16 : |
| 593 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 594 | strtTime = time.time() |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 595 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 596 | if ping == main.FALSE and count < 6: |
| 597 | count = count + 1 |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 598 | i = 6 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 599 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 600 | time.sleep(2) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 601 | elif ping == main.FALSE and count ==6: |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 602 | main.log.error("Ping test failed") |
| 603 | i = 17 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 604 | result = main.FALSE |
| 605 | elif ping == main.TRUE: |
| 606 | i = i + 1 |
| 607 | result = main.TRUE |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 608 | endTime = time.time() |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 609 | if result == main.TRUE: |
| 610 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 611 | else: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 612 | main.log.report("\tPING TEST FAIL") |
| 613 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 614 | |
| 615 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame^] | 616 | def CASE66(self, main): |
| 617 | main.log.report("Checking ONOS logs for exceptions") |
| 618 | count = 0 |
| 619 | check1 = main.ONOS1.check_exceptions() |
| 620 | main.log.report("Exceptions in ONOS1 logs: \n" + check1) |
| 621 | check2 = main.ONOS2.check_exceptions() |
| 622 | main.log.report("Exceptions in ONOS2 logs: \n" + check2) |
| 623 | check3 = main.ONOS3.check_exceptions() |
| 624 | main.log.report("Exceptions in ONOS3 logs: \n" + check3) |
| 625 | check4 = main.ONOS4.check_exceptions() |
| 626 | main.log.report("Exceptions in ONOS4 logs: \n" + check4) |
| 627 | result = main.TRUE |
| 628 | if (check1 or check2 or check3 or check4): |
| 629 | result = main.FALSE |
| 630 | count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines()) |
| 631 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No Exceptions found in the logs",onfail=str(count) + " Exceptions were found in the logs") |
| 632 | main.Mininet2.stop_tcpdump() |
| 633 | |
| 634 | |
| 635 | def CASE8(self,main) : |
| 636 | main.log.report("Testing Removal of Zookeeper") |
| 637 | main.Zookeeper2.stop() |
| 638 | main.Zookeeper3.stop() |
| 639 | main.Zookeeper4.stop() |
| 640 | strtTime = time.time() |
| 641 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 642 | for i in range(10): |
| 643 | if result == main.FALSE: |
| 644 | time.sleep(5) |
| 645 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 646 | else: |
| 647 | break |
| 648 | |
| 649 | count = 1 |
| 650 | i = 6 |
| 651 | while i < 16 : |
| 652 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 653 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 654 | if ping == main.FALSE and count < 6: |
| 655 | count = count + 1 |
| 656 | i = 6 |
| 657 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 658 | time.sleep(2) |
| 659 | elif ping == main.FALSE and count ==6: |
| 660 | main.log.error("Ping test failed") |
| 661 | i = 17 |
| 662 | result = main.FALSE |
| 663 | elif ping == main.TRUE: |
| 664 | i = i + 1 |
| 665 | result = main.TRUE |
| 666 | endTime = time.time() |
| 667 | if result == main.TRUE: |
| 668 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 669 | else: |
| 670 | main.log.report("\tPING TEST FAIL") |
| 671 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 672 | time.sleep(10) |
| 673 | main.Zookeeper2.start() |
| 674 | main.Zookeeper3.start() |
| 675 | main.Zookeeper4.start() |
| 676 | time.sleep(10) |
| 677 | |
| 678 | |
| 679 | def CASE67(self, main) : |
| 680 | main.case("Flapping link s1-s2") |
| 681 | main.log.report("Toggling of link s1-s2 multiple times") |
| 682 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 683 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 684 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 685 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 686 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 687 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 688 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 689 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 690 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 691 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 692 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 693 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 694 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 695 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 696 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 697 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 698 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 699 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 700 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 701 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 702 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 703 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 704 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 705 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 706 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 707 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 708 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 709 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 710 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 711 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 712 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 713 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 714 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 715 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 716 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 717 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 718 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 719 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 720 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 721 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 722 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 723 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 724 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 725 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 726 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 727 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 728 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 729 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 730 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 731 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 732 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 733 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 734 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 735 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 736 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 737 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 738 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 739 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 740 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 741 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 742 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 743 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 744 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 745 | |
| 746 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 747 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 748 | for i in range(10): |
| 749 | if result == main.FALSE: |
| 750 | time.sleep(15) |
| 751 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 752 | else: |
| 753 | break |
| 754 | |
| 755 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 756 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links']))) |
| 757 | for i in range(10): |
| 758 | if result == main.FALSE: |
| 759 | time.sleep(15) |
| 760 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links']))) |
| 761 | else: |
| 762 | break |
| 763 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 764 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 765 | for i in range(10): |
| 766 | if result == main.FALSE: |
| 767 | time.sleep(15) |
| 768 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 769 | else: |
| 770 | break |
| 771 | |
| 772 | |
| 773 | |
| 774 | def CASE101(self,main) : |
| 775 | import time |
| 776 | import json |
| 777 | import re |
| 778 | main.case("Testing the Intent Framework of ONOS") |
| 779 | |
| 780 | #***************************************************************************************** |
| 781 | #***************************************************************************************** |
| 782 | # The first part of CASE 101 will be assigning the master controllers to the switches |
| 783 | # and to check that each one is assigned correctly. |
| 784 | #***************************************************************************************** |
| 785 | #***************************************************************************************** |
| 786 | main.step("Assigning Master Controllers to the Switches and check") |
| 787 | for i in range(25): |
| 788 | if i<3: |
| 789 | j=i+1 |
| 790 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 791 | elif i>=3 and i<5: |
| 792 | j=i+1 |
| 793 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port1']) |
| 794 | elif i>=5 and i<15: |
| 795 | j=j+1 |
| 796 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port1']) |
| 797 | else: |
| 798 | j=i+16 |
| 799 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port1']) |
| 800 | result = main.TRUE |
| 801 | for i in range(25): |
| 802 | if i<3: |
| 803 | j=i+1 |
| 804 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 805 | print("Response is " + str(response)) |
| 806 | if re.search("tcp:"+main.params['CTRL']['ip1'],response) : |
| 807 | result = result and main.TRUE |
| 808 | else: |
| 809 | result = main.FALSE |
| 810 | elif i>=3 and i<5: |
| 811 | j=i+1 |
| 812 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 813 | if re.search("tcp:"+main.params['CTRL']['ip2'],response) : |
| 814 | result = result and main.TRUE |
| 815 | else: |
| 816 | result = main.FALSE |
| 817 | elif i>=5 and i<15: |
| 818 | j=j+1 |
| 819 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 820 | if re.search("tcp:"+main.params['CTRL']['ip3'],response) : |
| 821 | result = result and main.TRUE |
| 822 | else: |
| 823 | result = main.FALSE |
| 824 | else: |
| 825 | j=i+16 |
| 826 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 827 | if re.search("tcp:"+main.params['CTRL']['ip4'],response) : |
| 828 | result = result and main.TRUE |
| 829 | else: |
| 830 | result = main.FALSE |
| 831 | print(result) |
| 832 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Master Controllers assigned Properly",onfail="FAILED TO ASSIGN MASTER CONTROLLERS!") |
| 833 | |
| 834 | #***************************************************************************************** |
| 835 | #***************************************************************************************** |
| 836 | # Assign all controllers to the switches as backups. Run a get-controller on each |
| 837 | # switch to ensure that all controllers have been assigned properly to its switches |
| 838 | #***************************************************************************************** |
| 839 | #***************************************************************************************** |
| 840 | main.step("Assigning all Controllers as Backups to Switches and Check") |
| 841 | for i in range(25): |
| 842 | if i<15: |
| 843 | j=i+1 |
| 844 | 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']) |
| 845 | else: |
| 846 | j=i+16 |
| 847 | 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']) |
| 848 | result = main.TRUE |
| 849 | time.sleep(5) |
| 850 | for i in range(25): |
| 851 | if i<15: |
| 852 | j=i+1 |
| 853 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 854 | if re.search("tcp:"+main.params['CTRL']['ip1'],response) and re.search("tcp:"+main.params['CTRL']['ip2'],response) and re.search("tcp:"+main.params['CTRL']['ip3'],response) and re.search("tcp:"+main.params['CTRL']['ip4'],response): |
| 855 | result = result and main.TRUE |
| 856 | else: |
| 857 | result = main.FALSE |
| 858 | else: |
| 859 | j=i+16 |
| 860 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 861 | if re.search("tcp:"+main.params['CTRL']['ip1'],response) and re.search("tcp:"+main.params['CTRL']['ip2'],response) and re.search("tcp:"+main.params['CTRL']['ip3'],response) and re.search("tcp:"+main.params['CTRL']['ip4'],response): |
| 862 | result = result and main.TRUE |
| 863 | else: |
| 864 | result = main.FALSE |
| 865 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Controllers assigned properly to all switches",onfail="FAILED TO ASSIGN CONTROLLERS PROPERLY!") |
| 866 | |
| 867 | |
| 868 | |
| 869 | #***************************************************************************************** |
| 870 | #***************************************************************************************** |
| 871 | # Installation of Intents. This part will run run a forloop and add an intent from |
| 872 | # h6 to h31, h7 to h32, etc and the other way as well, h31 to h6, h32 to h7, etc. |
| 873 | # then Check by dumping the flows on SW2 and check for flows going bidirectionally. |
| 874 | #***************************************************************************************** |
| 875 | #***************************************************************************************** |
| 876 | main.step("Install intents and Check for Installation of Flows") |
| 877 | intentIP = main.params['INTENTREST']['intentIP'] |
| 878 | intentPort=main.params['INTENTREST']['intentPort'] |
| 879 | intentURL=main.params['INTENTREST']['intentURL'] |
| 880 | count = 1 |
| 881 | for i in range(6,16): |
| 882 | time.sleep(1) |
| 883 | srcMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 884 | dstMac = '00:00:00:00:00:'+str(hex(i+10)[2:]) |
| 885 | #srcDPID=str(i) |
| 886 | #dstDPID=str(i+10) |
| 887 | srcDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2) |
| 888 | dstDPID= '00:00:00:00:00:00:20:' +str(i+25) |
| 889 | main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID,src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
| 890 | count +=1 |
| 891 | dstMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 892 | srcMac = '00:00:00:00:00:'+str(hex(i+10)[2:]) |
| 893 | #srcDPID=str(i) |
| 894 | #dstDPID=str(i+10) |
| 895 | dstDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2) |
| 896 | srcDPID= '00:00:00:00:00:00:20:' +str(i+25) |
| 897 | main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID,src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
| 898 | count+=1 |
| 899 | result = main.TRUE |
| 900 | response = main.Mininet1.check_flows(sw="s1") |
| 901 | print(response) |
| 902 | for i in range(6,16): |
| 903 | if re.search("dl_src=00:00:00:00:00:"+''.join('%02x'%i),response) and re.search("dl_src=00:00:00:00:00:"+''.join('%02x'%(i+10)),response) and re.search("dl_dst=00:00:00:00:00:"+''.join('%02x'%i),response) and re.search("dl_dst=00:00:00:00:00:"+''.join('%02x'%(i+10)),response): |
| 904 | result = result and main.TRUE |
| 905 | else: |
| 906 | result = main.FALSE |
| 907 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flows added Properly",onfail="Flows were not added properly") |
| 908 | |
| 909 | #***************************************************************************************** |
| 910 | #***************************************************************************************** |
| 911 | # This step will run a ping test from h6 to h31, h7 to h32, etc as an End to End test |
| 912 | # All of these pings should run through. |
| 913 | #***************************************************************************************** |
| 914 | #***************************************************************************************** |
| 915 | main.step("Ping Test as End to End Test that the Intents were Correctly Installed") |
| 916 | main.log.report("Performing Ping Test") |
| 917 | count = 1 |
| 918 | i = 6 |
| 919 | while i < 16 : |
| 920 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 921 | strtTime = time.time() |
| 922 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 923 | if ping == main.FALSE and count < 6: |
| 924 | count = count + 1 |
| 925 | i = 6 |
| 926 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 927 | time.sleep(2) |
| 928 | elif ping == main.FALSE and count ==6: |
| 929 | main.log.error("Ping test failed") |
| 930 | i = 17 |
| 931 | result = main.FALSE |
| 932 | elif ping == main.TRUE: |
| 933 | i = i + 1 |
| 934 | result = main.TRUE |
| 935 | endTime = time.time() |
| 936 | if result == main.TRUE: |
| 937 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 938 | else: |
| 939 | main.log.report("\tPING TEST FAIL") |
| 940 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 941 | |
| 942 | #***************************************************************************************** |
| 943 | #***************************************************************************************** |
| 944 | # Removing a single intent. Then check to ensure that intent was found by calling |
| 945 | # show_intent. Then check that flows are removed by pinging. |
| 946 | #***************************************************************************************** |
| 947 | #***************************************************************************************** |
| 948 | main.step("Delete a single intent and ensure that flows are deleted") |
| 949 | main.ONOS1.del_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL,intent_id="intent_id=10") |
| 950 | time.sleep(2) |
| 951 | response = main.ONOS1.show_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL,intent_id=10) |
| 952 | if re.search("INTENT_NOT_FOUND",response): |
| 953 | main.log.report("Intent Removed Properly!") |
| 954 | else: |
| 955 | main.log.report("ERROR REMOVING INTENT") |
| 956 | main.log.report("Performing Ping Test") |
| 957 | count = 1 |
| 958 | for count in range(4): |
| 959 | ping = main.Mininet1.pingHost(src="h10",target="h35") |
| 960 | if ping==main.FALSE and count == 3: |
| 961 | main.log.info("Ping failed as expected. Intent Deleted") |
| 962 | result = main.TRUE |
| 963 | elif ping == main.TRUE: |
| 964 | main.log.error("Intent was not deleted correctly") |
| 965 | result = main.FALSE |
| 966 | else: |
| 967 | main.log.info("So far so good, attempting "+str(4-count) + " more times") |
| 968 | if result == main.TRUE: |
| 969 | main.log.report("\tIntent Deleted!") |
| 970 | else: |
| 971 | main.log.report("\tINTENT FAILED TO BE DELETED") |
| 972 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Intent Deleted Properly - Step Passed",onfail="INTENT NOT DELETED - STEP FAILED") |
| 973 | main.ONOS1.del_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
| 974 | |
| 975 | |
| 976 | #***************************************************************************************** |
| 977 | #***************************************************************************************** |
| 978 | # Install a bad intent. Then, ensure that we are able to get rid of it |
| 979 | # Installing an intent as ID=200, from a random dpid/mac to random dpid/mac. Then, |
| 980 | # check to make sure the intent is there, then delete it and ensure that it is gone |
| 981 | #***************************************************************************************** |
| 982 | #***************************************************************************************** |
| 983 | |
| 984 | |
| 985 | main.step("Installing incorrect intent and checking for deletion") |
| 986 | main.ONOS1.add_intent(intent_id=str(200),src_dpid="00:00:00:00:00:00:45:67",dst_dpid="00:00:00:00:00:32:21:10",src_mac="00:00:00:01:11:11",dst_mac="00:12:12:12:12:12",intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
| 987 | |
| 988 | |
| 989 | |
| 990 | |
| 991 | |
| 992 | def CASE10(self, main) : |
| 993 | import time |
| 994 | time.sleep(600) |