admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 1 | |
| 2 | class RCOnosSanity4nodesJ : |
| 3 | |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 4 | |
| 5 | |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 6 | def __init__(self) : |
| 7 | self.default = '' |
| 8 | |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 9 | # def print_hello_world(self,main): |
| 10 | # print("hello world") |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 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 |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 15 | main.case("Initial setup") |
| 16 | main.step("Stop ONOS") |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 17 | import time |
admin | e8c47d0 | 2014-06-03 11:59:16 -0700 | [diff] [blame] | 18 | main.ONOS1.stop_all() |
| 19 | main.ONOS2.stop_all() |
| 20 | main.ONOS3.stop_all() |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 21 | # main.print_hello_world() |
admin | e8c47d0 | 2014-06-03 11:59:16 -0700 | [diff] [blame] | 22 | main.ONOS4.stop_all() |
| 23 | main.ONOS2.stop_rest() |
admin | 9fce04b | 2014-08-11 10:50:22 -0700 | [diff] [blame] | 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") |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 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") |
Jon Hall | 0955bc9 | 2014-04-16 17:00:19 -0700 | [diff] [blame] | 31 | main.Zookeeper1.start() |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 32 | main.Zookeeper2.start() |
| 33 | main.Zookeeper3.start() |
| 34 | main.Zookeeper4.start() |
admin | e8c47d0 | 2014-06-03 11:59:16 -0700 | [diff] [blame] | 35 | time.sleep(1) |
admin | 6c96b8e | 2014-05-15 11:11:58 -0700 | [diff] [blame] | 36 | main.RamCloud1.del_db() |
| 37 | main.RamCloud2.del_db() |
| 38 | main.RamCloud3.del_db() |
| 39 | main.RamCloud4.del_db() |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 40 | main.log.report("Pulling latest code from github to all nodes") |
admin | 2121179 | 2014-04-15 15:42:39 -0700 | [diff] [blame] | 41 | for i in range(2): |
| 42 | uptodate = main.ONOS1.git_pull() |
| 43 | main.ONOS2.git_pull() |
| 44 | main.ONOS3.git_pull() |
| 45 | main.ONOS4.git_pull() |
| 46 | ver1 = main.ONOS1.get_version() |
| 47 | ver2 = main.ONOS4.get_version() |
| 48 | if ver1==ver2: |
| 49 | break |
| 50 | elif i==1: |
| 51 | main.ONOS2.git_pull("ONOS1 master") |
| 52 | main.ONOS3.git_pull("ONOS1 master") |
| 53 | main.ONOS4.git_pull("ONOS1 master") |
admin | e8c47d0 | 2014-06-03 11:59:16 -0700 | [diff] [blame] | 54 | if uptodate==0: |
| 55 | # if 1: |
admin | 2121179 | 2014-04-15 15:42:39 -0700 | [diff] [blame] | 56 | main.ONOS1.git_compile() |
| 57 | main.ONOS2.git_compile() |
| 58 | main.ONOS3.git_compile() |
| 59 | main.ONOS4.git_compile() |
Jon Hall | 364f37a | 2014-04-17 10:29:35 -0700 | [diff] [blame] | 60 | main.ONOS1.print_version() |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 61 | # main.RamCloud1.git_pull() |
| 62 | # main.RamCloud2.git_pull() |
| 63 | # main.RamCloud3.git_pull() |
| 64 | # main.RamCloud4.git_pull() |
| 65 | # main.ONOS1.get_version() |
| 66 | # main.ONOS2.get_version() |
| 67 | # main.ONOS3.get_version() |
| 68 | # main.ONOS4.get_version() |
admin | e8c47d0 | 2014-06-03 11:59:16 -0700 | [diff] [blame] | 69 | main.ONOS1.start_all() |
| 70 | main.ONOS2.start_all() |
| 71 | main.ONOS3.start_all() |
| 72 | main.ONOS4.start_all() |
| 73 | main.ONOS2.start_rest() |
| 74 | test= main.ONOS2.rest_status() |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 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") |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 79 | main.step("Testing startup Zookeeper") |
| 80 | data = main.Zookeeper1.isup() |
| 81 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...") |
| 82 | main.step("Testing startup RamCloud") |
Jon Hall | 5a8aac6 | 2014-06-03 09:30:21 -0700 | [diff] [blame] | 83 | data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv() |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 84 | if data == main.FALSE: |
| 85 | main.RamCloud1.stop_coor() |
| 86 | main.RamCloud1.stop_serv() |
| 87 | main.RamCloud2.stop_serv() |
| 88 | main.RamCloud3.stop_serv() |
| 89 | main.RamCloud4.stop_serv() |
| 90 | |
| 91 | time.sleep(5) |
| 92 | main.RamCloud1.start_coor() |
| 93 | main.RamCloud1.start_serv() |
| 94 | main.RamCloud2.start_serv() |
| 95 | main.RamCloud3.start_serv() |
| 96 | main.RamCloud4.start_serv() |
Jon Hall | 5a8aac6 | 2014-06-03 09:30:21 -0700 | [diff] [blame] | 97 | time.sleep(5) |
| 98 | data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv() |
| 99 | |
| 100 | |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 101 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...") |
| 102 | main.step("Testing startup ONOS") |
Jon Hall | 5a8aac6 | 2014-06-03 09:30:21 -0700 | [diff] [blame] | 103 | data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup() |
admin | aef0055 | 2014-05-08 09:18:36 -0700 | [diff] [blame] | 104 | for i in range(3): |
| 105 | if data == main.FALSE: |
| 106 | #main.log.report("Something is funny... restarting ONOS") |
| 107 | #main.ONOS1.stop() |
| 108 | time.sleep(3) |
| 109 | #main.ONOS1.start() |
| 110 | #time.sleep(5) |
Jon Hall | 5a8aac6 | 2014-06-03 09:30:21 -0700 | [diff] [blame] | 111 | data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup() |
admin | aef0055 | 2014-05-08 09:18:36 -0700 | [diff] [blame] | 112 | else: |
| 113 | break |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 114 | 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] | 115 | time.sleep(20) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 116 | |
| 117 | #********************************************************************************************************************************************************************************************** |
| 118 | #Assign Controllers |
| 119 | #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>). |
| 120 | #Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers. |
| 121 | #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 |
| 122 | # the controllers already assigned to the switch are not specified. |
| 123 | |
| 124 | def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches |
| 125 | import time |
| 126 | main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4") |
| 127 | main.case("Checking if one MN host exists") |
| 128 | main.step("Host IP Checking using checkIP") |
| 129 | result = main.Mininet1.checkIP(main.params['CASE1']['destination']) |
| 130 | main.step("Verifying the result") |
| 131 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured") |
| 132 | main.step("assigning ONOS controllers to switches") |
| 133 | for i in range(25): |
| 134 | if i < 3: |
| 135 | j=i+1 |
| 136 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 137 | time.sleep(1) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 138 | 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] | 139 | elif i >= 3 and i < 5: |
| 140 | j=i+1 |
| 141 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 142 | time.sleep(1) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 143 | 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] | 144 | elif i >= 5 and i < 15: |
| 145 | j=i+1 |
| 146 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 147 | time.sleep(1) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 148 | 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] | 149 | else: |
| 150 | j=i+16 |
| 151 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 152 | time.sleep(2) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 153 | 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] | 154 | main.Mininet1.get_sw_controller("s1") |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 155 | time.sleep(30) |
admin | 2580a0e | 2014-07-29 11:24:34 -0700 | [diff] [blame] | 156 | |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 157 | |
| 158 | # ********************************************************************************************************************************************************************************************** |
| 159 | #Add Flows |
| 160 | #Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test |
| 161 | #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 |
| 162 | |
| 163 | def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update |
| 164 | main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update") |
| 165 | import time |
| 166 | main.case("Taking care of these flows!") |
| 167 | main.step("Cleaning out any leftover flows...") |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 168 | #main.ONOS1.delete_flow("all") |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 169 | strtTime = time.time() |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 170 | main.ONOS1.rm_intents() |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 171 | print("world") |
admin | a0c1fe3 | 2014-08-11 10:08:22 -0700 | [diff] [blame] | 172 | time.sleep(5) |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 173 | main.ONOS1.add_intents() |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 174 | print("hello") |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 175 | # 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] | 176 | main.case("Checking flows") |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 177 | |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 178 | count = 1 |
| 179 | i = 6 |
| 180 | while i < 16 : |
| 181 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 182 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 183 | if ping == main.FALSE and count < 9: |
| 184 | count = count + 1 |
| 185 | i = 6 |
| 186 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 187 | time.sleep(2) |
| 188 | elif ping == main.FALSE and count ==9: |
| 189 | main.log.error("Ping test failed") |
| 190 | i = 17 |
| 191 | result = main.FALSE |
| 192 | elif ping == main.TRUE: |
| 193 | i = i + 1 |
| 194 | result = main.TRUE |
| 195 | endTime = time.time() |
| 196 | if result == main.TRUE: |
| 197 | main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
| 198 | else: |
| 199 | main.log.report("\tFlows failed check") |
| 200 | |
| 201 | result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 202 | main.step("Verifying the result") |
| 203 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL") |
| 204 | |
| 205 | #********************************************************************************************************************************************************************************************** |
| 206 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 207 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 208 | #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. |
| 209 | #If the ping test fails 6 times, then the test case will return false |
| 210 | def CASE41(self,main) : |
| 211 | main.log.report("Testing Removal") |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 212 | time.sleep(20) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 213 | main.ONOS2.stop() |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 214 | time.sleep(30) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 215 | main.ONOS3.stop() |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 216 | time.sleep(30) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 217 | main.ONOS4.stop() |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 218 | time.sleep(45) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 219 | strtTime = time.time() |
| 220 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 221 | for i in range(10): |
| 222 | if result == main.FALSE: |
| 223 | time.sleep(5) |
| 224 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 225 | else: |
| 226 | break |
| 227 | |
| 228 | count = 1 |
| 229 | i = 6 |
| 230 | while i < 16 : |
| 231 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 232 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 233 | if ping == main.FALSE and count < 6: |
| 234 | count = count + 1 |
| 235 | i = 6 |
| 236 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 237 | time.sleep(2) |
| 238 | elif ping == main.FALSE and count ==6: |
| 239 | main.log.error("Ping test failed") |
| 240 | i = 17 |
| 241 | result = main.FALSE |
| 242 | elif ping == main.TRUE: |
| 243 | i = i + 1 |
| 244 | result = main.TRUE |
| 245 | endTime = time.time() |
| 246 | if result == main.TRUE: |
| 247 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 248 | else: |
| 249 | main.log.report("\tPING TEST FAIL") |
| 250 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 251 | time.sleep(10) |
| 252 | main.ONOS2.start() |
| 253 | main.ONOS3.start() |
| 254 | main.ONOS4.start() |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 255 | time.sleep(20) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 256 | |
| 257 | |
| 258 | def CASE4(self,main) : |
| 259 | main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 260 | import time |
| 261 | for i in range(25): |
| 262 | if i < 15: |
| 263 | j=i+1 |
| 264 | 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 |
| 265 | else: |
| 266 | j=i+16 |
| 267 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 268 | |
| 269 | strtTime = time.time() |
| 270 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 271 | for i in range(10): |
| 272 | if result == main.FALSE: |
| 273 | time.sleep(5) |
| 274 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 275 | else: |
| 276 | break |
| 277 | |
| 278 | count = 1 |
| 279 | i = 6 |
| 280 | while i < 16 : |
| 281 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 282 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 283 | if ping == main.FALSE and count < 6: |
| 284 | count = count + 1 |
| 285 | i = 6 |
| 286 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 287 | time.sleep(2) |
| 288 | elif ping == main.FALSE and count ==6: |
| 289 | main.log.error("Ping test failed") |
| 290 | i = 17 |
| 291 | result = main.FALSE |
| 292 | elif ping == main.TRUE: |
| 293 | i = i + 1 |
| 294 | result = main.TRUE |
| 295 | endTime = time.time() |
| 296 | if result == main.TRUE: |
| 297 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 298 | else: |
| 299 | main.log.report("\tPING TEST FAIL") |
| 300 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 301 | time.sleep(10) |
| 302 | |
| 303 | # ********************************************************************************************************************************************************************************************** |
| 304 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 305 | |
| 306 | def CASE5(self,main) : |
| 307 | main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 308 | import time |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 309 | for i in range(25): |
| 310 | if i < 3: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 311 | j=i+1 |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 312 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 313 | time.sleep(1) |
| 314 | 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']) |
| 315 | elif i >= 3 and i < 5: |
| 316 | j=i+1 |
| 317 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 318 | time.sleep(1) |
| 319 | 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']) |
| 320 | elif i >= 5 and i < 15: |
| 321 | j=i+1 |
| 322 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 323 | time.sleep(1) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 324 | 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] | 325 | else: |
| 326 | j=i+16 |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 327 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 328 | 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 | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 329 | time.sleep(1) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 330 | strtTime = time.time() |
| 331 | 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] | 332 | for i in range(10): |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 333 | if result == main.FALSE: |
| 334 | time.sleep(5) |
| 335 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 336 | else: |
| 337 | break |
| 338 | |
| 339 | count = 1 |
| 340 | i = 6 |
| 341 | while i < 16 : |
| 342 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 343 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 344 | if ping == main.FALSE and count < 6: |
| 345 | count = count + 1 |
| 346 | i = 6 |
| 347 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 348 | time.sleep(2) |
| 349 | elif ping == main.FALSE and count ==6: |
| 350 | main.log.error("Ping test failed") |
| 351 | i = 17 |
| 352 | result = main.FALSE |
| 353 | elif ping == main.TRUE: |
| 354 | i = i + 1 |
| 355 | result = main.TRUE |
| 356 | endTime = time.time() |
| 357 | if result == main.TRUE: |
| 358 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 359 | else: |
| 360 | main.log.report("\tPING TEST FAILED") |
| 361 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 362 | |
| 363 | # ********************************************************************************************************************************************************************************************** |
| 364 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 365 | |
| 366 | def CASE6(self,main) : |
| 367 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
| 368 | import time |
| 369 | main.case("Bringing Link down... ") |
| 370 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 371 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
admin | 2580a0e | 2014-07-29 11:24:34 -0700 | [diff] [blame] | 372 | time.sleep(30) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 373 | strtTime = time.time() |
| 374 | 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] | 375 | for i in range(10): |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 376 | if result == main.FALSE: |
| 377 | time.sleep(5) |
| 378 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 379 | else: |
| 380 | break |
| 381 | |
| 382 | count = 1 |
| 383 | i = 6 |
| 384 | while i < 16 : |
| 385 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 386 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 387 | if ping == main.FALSE and count < 10: |
| 388 | count = count + 1 |
| 389 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 390 | i = 6 |
| 391 | time.sleep(2) |
| 392 | elif ping == main.FALSE and count == 10: |
| 393 | main.log.error("Ping test failed") |
| 394 | i = 17 |
| 395 | result = main.FALSE |
| 396 | elif ping == main.TRUE: |
| 397 | i = i + 1 |
| 398 | result = main.TRUE |
| 399 | endTime = time.time() |
| 400 | if result == main.TRUE: |
| 401 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 402 | else: |
| 403 | main.log.report("\tPING TEST FAILED") |
| 404 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 405 | |
| 406 | # ********************************************************************************************************************************************************************************************** |
| 407 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 408 | |
| 409 | def CASE7(self,main) : |
| 410 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 411 | import time |
| 412 | main.case("Bringing Link up... ") |
Jon Hall | 5a8aac6 | 2014-06-03 09:30:21 -0700 | [diff] [blame] | 413 | result = main.Mininet1.link(END1='s1',END2='s3',OPTION="down") |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 414 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 415 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
admin | 2580a0e | 2014-07-29 11:24:34 -0700 | [diff] [blame] | 416 | time.sleep(30) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 417 | strtTime = time.time() |
Jon Hall | 5a8aac6 | 2014-06-03 09:30:21 -0700 | [diff] [blame] | 418 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 419 | for i in range(10): |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 420 | if result == main.FALSE: |
Jon Hall | 5a8aac6 | 2014-06-03 09:30:21 -0700 | [diff] [blame] | 421 | time.sleep(15) |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 422 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 423 | else: |
| 424 | break |
| 425 | |
| 426 | strtTime = time.time() |
| 427 | count = 1 |
| 428 | i = 6 |
| 429 | while i < 16 : |
| 430 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 431 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 432 | if ping == main.FALSE and count < 10: |
| 433 | count = count + 1 |
| 434 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 435 | i = 6 |
| 436 | time.sleep(2) |
| 437 | elif ping == main.FALSE and count ==10: |
| 438 | main.log.error("Ping test failed") |
| 439 | i = 17 |
| 440 | result = main.FALSE |
| 441 | elif ping == main.TRUE: |
| 442 | i = i + 1 |
| 443 | result = main.TRUE |
| 444 | endTime = time.time() |
| 445 | if result == main.TRUE: |
| 446 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 447 | else: |
| 448 | main.log.report("\tPING TESTS FAILED") |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 449 | data = main.Mininet1.link(END1='s1',END2='s3',OPTION="up") |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 450 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 451 | |
| 452 | |
| 453 | # ****************************************************************************************************************************************************************** |
| 454 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 455 | |
| 456 | def CASE21(self,main) : |
| 457 | import json |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 458 | 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.") |
| 459 | main.log.report("Check initially hostMAC/IP exist on the mininet...") |
| 460 | host = main.params['YANK']['hostname'] |
| 461 | mac = main.params['YANK']['hostmac'] |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 462 | RestIP1 = main.params['RESTCALL']['restIP1'] |
| 463 | RestPort = main.params['RESTCALL']['restPort'] |
| 464 | url = main.params['RESTCALL']['restURL'] |
| 465 | |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 466 | t_topowait = 5 |
| 467 | t_restwait = 5 |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 468 | main.log.report( "Wait time from topo change to ping set to " + str(t_topowait)) |
| 469 | main.log.report( "Wait time from ping to rest call set to " + str(t_restwait)) |
| 470 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
| 471 | time.sleep(t_topowait) |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 472 | 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] | 473 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 474 | time.sleep(t_restwait) |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 475 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
| 476 | main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus)) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 477 | if Reststatus == 1: |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 478 | main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0])) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 479 | result1 = main.TRUE |
| 480 | elif Reststatus > 1: |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 481 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED") |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 482 | main.log.report("switches are: " + "; ".join(Switch)) |
| 483 | main.log.report("Ports are: " + "; ".join(Port)) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 484 | result1 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 485 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 486 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED") |
| 487 | result1 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 488 | else:# check if rest server is working |
| 489 | main.log.error("Issue with find host") |
| 490 | result1 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 491 | |
| 492 | |
| 493 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 494 | |
| 495 | main.log.report("Yank out s1-eth1") |
| 496 | main.case("Yankout s6-eth1 (link to h1) from s1") |
| 497 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 498 | time.sleep(t_topowait) |
| 499 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
| 500 | |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 501 | 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] | 502 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 503 | time.sleep(t_restwait) |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 504 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 505 | |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 506 | main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus)) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 507 | if Reststatus == 1: |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 508 | main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port)) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 509 | result2 = main.FALSE |
| 510 | elif Reststatus > 1: |
| 511 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 512 | main.log.report("switches are: " + "; ".join(Switch)) |
| 513 | main.log.report("Ports are: " + "; ".join(Port)) |
| 514 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 515 | result2 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 516 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 517 | 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.") |
| 518 | result2 = main.TRUE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 519 | else:# check if rest server is working |
| 520 | main.log.error("Issue with find host") |
| 521 | result2 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 522 | |
| 523 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 524 | main.log.report("Plug s1-eth1 into s6") |
| 525 | main.case("Plug s1-eth1 to s6") |
| 526 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
| 527 | time.sleep(t_topowait) |
| 528 | 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] | 529 | 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] | 530 | |
| 531 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 532 | time.sleep(t_restwait) |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 533 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 534 | |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 535 | main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus)) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 536 | if Reststatus == 1: |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 537 | main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0])) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 538 | result3 = main.TRUE |
| 539 | elif Reststatus > 1: |
| 540 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 541 | main.log.report("switches are: " + "; ".join(Switch)) |
| 542 | main.log.report("Ports are: " + "; ".join(Port)) |
| 543 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 544 | result3 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 545 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 546 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 547 | result3 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 548 | else:# check if rest server is working |
| 549 | main.log.error("Issue with find host") |
| 550 | result3 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 551 | |
| 552 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 553 | main.log.report("Move s1-eth1 back on to s1") |
| 554 | main.case("Move s1-eth1 back to s1") |
| 555 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 556 | time.sleep(t_topowait) |
| 557 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 558 | 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] | 559 | 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] | 560 | |
| 561 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 562 | time.sleep(t_restwait) |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 563 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 564 | |
| 565 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 566 | if Reststatus == 1: |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 567 | main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0])) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 568 | result4 = main.TRUE |
| 569 | elif Reststatus > 1: |
| 570 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED") |
| 571 | main.log.report("switches are: " + "; ".join(Switch)) |
| 572 | main.log.report("Ports are: " + "; ".join(Port)) |
| 573 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 574 | result4 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 575 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 576 | main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 577 | result4 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 578 | else:# check if rest server is working |
| 579 | main.log.error("Issue with find host") |
| 580 | result4 = main.FALSE |
Jon Hall | 5a8aac6 | 2014-06-03 09:30:21 -0700 | [diff] [blame] | 581 | time.sleep(20) |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 582 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac) |
| 583 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 584 | if Reststatus ==1: |
| 585 | main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout") |
| 586 | elif Reststatus>1: |
| 587 | main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)") |
| 588 | elif Reststatus==0: |
| 589 | main.log.report("\t PASSED - Device cleared after timeout") |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 590 | |
| 591 | result = result1 and result2 and result3 and result4 |
| 592 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 593 | |
| 594 | # Run a pure ping test. |
| 595 | |
| 596 | def CASE31(self, main): |
| 597 | main.log.report("Performing Ping Test") |
| 598 | count = 1 |
| 599 | i = 6 |
| 600 | while i < 16 : |
| 601 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 602 | strtTime = time.time() |
| 603 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 604 | if ping == main.FALSE and count < 6: |
| 605 | count = count + 1 |
| 606 | i = 6 |
| 607 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 608 | time.sleep(2) |
| 609 | elif ping == main.FALSE and count ==6: |
| 610 | main.log.error("Ping test failed") |
| 611 | i = 17 |
| 612 | result = main.FALSE |
| 613 | elif ping == main.TRUE: |
| 614 | i = i + 1 |
| 615 | result = main.TRUE |
| 616 | endTime = time.time() |
| 617 | if result == main.TRUE: |
| 618 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 619 | else: |
| 620 | main.log.report("\tPING TEST FAIL") |
| 621 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 622 | |
admin | 1723f1c | 2014-05-19 16:08:39 -0700 | [diff] [blame] | 623 | |
SeanCorcoran | 29b7054 | 2014-05-14 14:53:42 -0700 | [diff] [blame] | 624 | def CASE66(self, main): |
| 625 | main.log.report("Checking ONOS logs for exceptions") |
admin | 1723f1c | 2014-05-19 16:08:39 -0700 | [diff] [blame] | 626 | count = 0 |
| 627 | check1 = main.ONOS1.check_exceptions() |
| 628 | main.log.report("Exceptions in ONOS1 logs: \n" + check1) |
| 629 | check2 = main.ONOS2.check_exceptions() |
| 630 | main.log.report("Exceptions in ONOS2 logs: \n" + check2) |
| 631 | check3 = main.ONOS3.check_exceptions() |
| 632 | main.log.report("Exceptions in ONOS3 logs: \n" + check3) |
| 633 | check4 = main.ONOS4.check_exceptions() |
| 634 | main.log.report("Exceptions in ONOS4 logs: \n" + check4) |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 635 | result = main.TRUE |
admin | 1723f1c | 2014-05-19 16:08:39 -0700 | [diff] [blame] | 636 | if (check1 or check2 or check3 or check4): |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 637 | result = main.FALSE |
admin | 1723f1c | 2014-05-19 16:08:39 -0700 | [diff] [blame] | 638 | count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines()) |
Jon Hall | 1c4d274 | 2014-05-22 10:57:05 -0700 | [diff] [blame] | 639 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No Exceptions found in the logs",onfail=str(count) + " Exceptions were found in the logs") |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 640 | main.Mininet1.stop_tcpdump() |
admin | 1723f1c | 2014-05-19 16:08:39 -0700 | [diff] [blame] | 641 | |
SeanCorcoran | 29b7054 | 2014-05-14 14:53:42 -0700 | [diff] [blame] | 642 | |
admin | f689a27 | 2014-06-17 14:08:57 -0700 | [diff] [blame] | 643 | def CASE8(self,main) : |
| 644 | main.log.report("Testing Removal of Zookeeper") |
| 645 | main.Zookeeper2.stop() |
| 646 | main.Zookeeper3.stop() |
| 647 | main.Zookeeper4.stop() |
| 648 | strtTime = time.time() |
| 649 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 650 | for i in range(10): |
| 651 | if result == main.FALSE: |
| 652 | time.sleep(5) |
| 653 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 654 | else: |
| 655 | break |
| 656 | |
| 657 | count = 1 |
| 658 | i = 6 |
| 659 | while i < 16 : |
| 660 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 661 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 662 | if ping == main.FALSE and count < 6: |
| 663 | count = count + 1 |
| 664 | i = 6 |
| 665 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 666 | time.sleep(2) |
| 667 | elif ping == main.FALSE and count ==6: |
| 668 | main.log.error("Ping test failed") |
| 669 | i = 17 |
| 670 | result = main.FALSE |
| 671 | elif ping == main.TRUE: |
| 672 | i = i + 1 |
| 673 | result = main.TRUE |
| 674 | endTime = time.time() |
| 675 | if result == main.TRUE: |
| 676 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 677 | else: |
| 678 | main.log.report("\tPING TEST FAIL") |
| 679 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 680 | time.sleep(10) |
| 681 | main.Zookeeper2.start() |
| 682 | main.Zookeeper3.start() |
| 683 | main.Zookeeper4.start() |
| 684 | time.sleep(10) |
| 685 | |
| 686 | |
| 687 | def CASE67(self, main) : |
| 688 | main.case("Flapping link s1-s2") |
| 689 | main.log.report("Toggling of link s1-s2 multiple times") |
| 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 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 746 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 747 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 748 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 749 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 750 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 751 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 752 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 753 | |
| 754 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 755 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 756 | for i in range(10): |
| 757 | if result == main.FALSE: |
| 758 | time.sleep(15) |
| 759 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 760 | else: |
| 761 | break |
| 762 | |
| 763 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 764 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links']))) |
| 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']))) |
| 769 | else: |
| 770 | break |
| 771 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 772 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 773 | for i in range(10): |
| 774 | if result == main.FALSE: |
| 775 | time.sleep(15) |
| 776 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 777 | else: |
| 778 | break |
| 779 | |
| 780 | |
| 781 | |
| 782 | def CASE101(self,main) : |
| 783 | import time |
| 784 | import json |
| 785 | import re |
| 786 | main.case("Testing the Intent Framework of ONOS") |
| 787 | |
| 788 | main.step("Assigning Master Controllers to the Switches and check") |
| 789 | for i in range(25): |
| 790 | if i<3: |
| 791 | j=i+1 |
| 792 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 793 | elif i>=3 and i<5: |
| 794 | j=i+1 |
| 795 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port1']) |
| 796 | elif i>=5 and i<15: |
| 797 | j=j+1 |
| 798 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port1']) |
| 799 | else: |
| 800 | j=i+16 |
| 801 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port1']) |
| 802 | result = main.TRUE |
| 803 | for i in range(25): |
| 804 | if i<3: |
| 805 | j=i+1 |
| 806 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 807 | print(response) |
| 808 | if re.search("tcp:"+main.params['CTRL']['ip1'],response) : |
| 809 | result = result and main.TRUE |
| 810 | else: |
| 811 | result = main.FALSE |
| 812 | elif i>=3 and i<5: |
| 813 | j=i+1 |
| 814 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 815 | if re.search("tcp:"+main.params['CTRL']['ip2'],response) : |
| 816 | result = result and main.TRUE |
| 817 | else: |
| 818 | result = main.FALSE |
| 819 | elif i>=5 and i<15: |
| 820 | j=j+1 |
| 821 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 822 | if re.search("tcp:"+main.params['CTRL']['ip3'],response) : |
| 823 | result = result and main.TRUE |
| 824 | else: |
| 825 | result = main.FALSE |
| 826 | else: |
| 827 | j=i+16 |
| 828 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 829 | if re.search("tcp:"+main.params['CTRL']['ip4'],response) : |
| 830 | result = result and main.TRUE |
| 831 | else: |
| 832 | result = main.FALSE |
| 833 | print(result) |
| 834 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Master Controllers assigned Properly",onfail="FAILED TO ASSIGN MASTER CONTROLLERS!") |
| 835 | |
| 836 | main.step("Assigning all Controllers as Backups to Switches and Check") |
| 837 | for i in range(25): |
| 838 | if i<15: |
| 839 | j=i+1 |
| 840 | 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']) |
| 841 | else: |
| 842 | j=i+16 |
| 843 | 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']) |
| 844 | result = main.TRUE |
| 845 | for i in range(25): |
| 846 | if i<15: |
| 847 | j=i+1 |
| 848 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 849 | 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): |
| 850 | result = result and main.TRUE |
| 851 | else: |
| 852 | result = main.FALSE |
| 853 | else: |
| 854 | j=i+16 |
| 855 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 856 | 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): |
| 857 | result = result and main.TRUE |
| 858 | else: |
| 859 | result = main.FALSE |
| 860 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Controllers assigned properly to all switches",onfail="FAILED TO ASSIGN CONTROLLERS PROPERLY!") |
| 861 | |
| 862 | main.step("Install intents and Check for Installation of Flows") |
| 863 | intentIP = main.params['INTENTREST']['intentIP'] |
| 864 | intentPort=main.params['INTENTREST']['intentPort'] |
| 865 | intentURL=main.params['INTENTREST']['intentURL'] |
| 866 | for i in range(6,16): |
| 867 | srcMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 868 | dstMac = '00:00:00:00:00:'+str(hex(i+25)[2:]) |
| 869 | # srcDPID=str(i) |
| 870 | # dstDPID=str(i+10) |
| 871 | srcDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2) |
| 872 | dstDPID= '00:00:00:00:00:00:20:' +str(i+25) |
| 873 | main.ONOS1.add_intent(intent_id=str(i),src_dpid=srcDPID,dst_dpid=dstDPID,src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
| 874 | result = main.TRUE |
| 875 | response = main.Mininet1.check_flows(sw="s1") |
| 876 | for i in range(6,16): |
| 877 | 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): |
| 878 | result = result and main.TRUE |
| 879 | else: |
| 880 | result = main.FALSE |
| 881 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flows added Properly",onfail="Flows were not added properly") |
| 882 | |
| 883 | |
| 884 | |
| 885 | def CASE10(self, main) : |
| 886 | import time |
| 887 | time.sleep(600) |