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 | 089a078 | 2014-07-22 15:48:19 -0700 | [diff] [blame^] | 157 | from subprocess import Popen, PIPE |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 158 | main.case("Taking care of these flows!") |
| 159 | main.step("Cleaning out any leftover flows...") |
admin | 089a078 | 2014-07-22 15:48:19 -0700 | [diff] [blame^] | 160 | masterSwitches = [] |
| 161 | masterSwitches2 = [] |
| 162 | for i in range(25): |
| 163 | if i < 15: |
| 164 | j=i+1 |
| 165 | else: |
| 166 | j=i+16 |
| 167 | (stdout, stderr) = Popen(["curl",main.params['RESTCALL']['restIP1']+":"+main.params['RESTCALL']['restPort']+"/wm/onos/registry/switches/json"],stdout=PIPE).communicate() |
| 168 | switchDPID1 = main.Mininet1.getSwitchDPID(switch="s"+str(j)) |
| 169 | sDPID1 = str(switchDPID1) |
| 170 | switchDPID2 = sDPID1[:2]+":"+sDPID1[2:4]+":"+sDPID1[4:6]+":"+sDPID1[6:8]+":"+sDPID1[8:10]+":"+sDPID1[10:12]+":"+sDPID1[12:14]+":"+sDPID1[14:] |
| 171 | master=main.Zookeeper1.findMaster(switchDPID = switchDPID2, switchList=stdout) |
| 172 | masterSwitches.append("s"+str(j)+" " + master) |
| 173 | |
| 174 | for i in range(25): |
| 175 | if i < 15: |
| 176 | j=i+1 |
| 177 | else: |
| 178 | j=i+16 |
| 179 | print j |
| 180 | (stdout, stderr) = Popen(["curl",main.params['RESTCALL']['restIP1']+":"+main.params['RESTCALL']['restPort']+"/wm/onos/registry/switches/json"],stdout=PIPE).communicate() |
| 181 | switchDPID1 = main.Mininet1.getSwitchDPID(switch="s"+str(j)) |
| 182 | sDPID1 = str(switchDPID1) |
| 183 | switchDPID2 = sDPID1[:2]+":"+sDPID1[2:4]+":"+sDPID1[4:6]+":"+sDPID1[6:8]+":"+sDPID1[8:10]+":"+sDPID1[10:12]+":"+sDPID1[12:14]+":"+sDPID1[14:] |
| 184 | master=main.Zookeeper1.findMaster(switchDPID = switchDPID2, switchList=stdout) |
| 185 | masterSwitches2.append("s"+str(j)+" " + master) |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | print masterSwitches |
| 191 | print "\n\n\n" |
| 192 | print masterSwitches2 |
| 193 | print masterSwitches == masterSwitches2 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 194 | #main.ONOS1.delete_flow("all") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 195 | strtTime = time.time() |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 196 | main.ONOS1.rm_intents() |
admin | 089a078 | 2014-07-22 15:48:19 -0700 | [diff] [blame^] | 197 | (stdout,stderr) = Popen(["curl",main.params['RESTCALL']['restIP1']+":"+main.params['RESTCALL']['restPort']+"/wm/onos/intent/high"],stdout=PIPE).communicate() |
| 198 | intent1 = stdout |
| 199 | print intent1 + "\n\n\n Intent 1 \n\n\n" |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 200 | main.ONOS1.add_intents() |
| 201 | time.sleep(2) |
admin | 089a078 | 2014-07-22 15:48:19 -0700 | [diff] [blame^] | 202 | (stdout,stderr) = Popen(["curl",main.params['RESTCALL']['restIP1']+":"+main.params['RESTCALL']['restPort']+"/wm/onos/intent/high"],stdout=PIPE).communicate() |
| 203 | intent2 = stdout |
| 204 | print intent2 + "\n\n\n Intent 2 \n\n\n" |
| 205 | changesMade = main.ONOS1.comp_intents(preIntents=intent1,postIntents=intent2) |
| 206 | print changesMade |
| 207 | if not changesMade: |
| 208 | print "Intents were Constant" |
| 209 | print changesMade |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 210 | # main.ONOS1.add_flow(main.params['FLOWDEF']['testONip'],main.params['FLOWDEF']['user'],main.params['FLOWDEF']['password'],main.params['FLOWDEF']['flowDef']) |
| 211 | main.case("Checking flows") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 212 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 213 | count = 1 |
| 214 | i = 6 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 215 | while i < 16 : |
| 216 | 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] | 217 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 218 | if ping == main.FALSE and count < 9: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 219 | count = count + 1 |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 220 | i = 6 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 221 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 222 | time.sleep(2) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 223 | elif ping == main.FALSE and count ==9: |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 224 | main.log.error("Ping test failed") |
| 225 | i = 17 |
| 226 | result = main.FALSE |
| 227 | elif ping == main.TRUE: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 228 | i = i + 1 |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 229 | result = main.TRUE |
| 230 | endTime = time.time() |
| 231 | if result == main.TRUE: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 232 | main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 233 | else: |
| 234 | main.log.report("\tFlows failed check") |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 235 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 236 | 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] | 237 | main.step("Verifying the result") |
| 238 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL") |
| 239 | |
| 240 | #********************************************************************************************************************************************************************************************** |
| 241 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 242 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 243 | #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. |
| 244 | #If the ping test fails 6 times, then the test case will return false |
| 245 | def CASE41(self,main) : |
| 246 | main.log.report("Testing Removal") |
| 247 | time.sleep(10) |
| 248 | main.ONOS2.stop() |
| 249 | time.sleep(10) |
| 250 | main.ONOS3.stop() |
| 251 | time.sleep(10) |
| 252 | main.ONOS4.stop() |
| 253 | time.sleep(15) |
| 254 | strtTime = time.time() |
| 255 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 256 | for i in range(10): |
| 257 | if result == main.FALSE: |
| 258 | time.sleep(5) |
| 259 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 260 | else: |
| 261 | break |
| 262 | |
| 263 | count = 1 |
| 264 | i = 6 |
| 265 | while i < 16 : |
| 266 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 267 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 268 | if ping == main.FALSE and count < 6: |
| 269 | count = count + 1 |
| 270 | i = 6 |
| 271 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 272 | time.sleep(2) |
| 273 | elif ping == main.FALSE and count ==6: |
| 274 | main.log.error("Ping test failed") |
| 275 | i = 17 |
| 276 | result = main.FALSE |
| 277 | elif ping == main.TRUE: |
| 278 | i = i + 1 |
| 279 | result = main.TRUE |
| 280 | endTime = time.time() |
| 281 | if result == main.TRUE: |
| 282 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 283 | else: |
| 284 | main.log.report("\tPING TEST FAIL") |
| 285 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 286 | time.sleep(10) |
| 287 | main.ONOS2.start() |
| 288 | main.ONOS3.start() |
| 289 | main.ONOS4.start() |
| 290 | time.sleep(20) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 291 | |
| 292 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 293 | def CASE4(self,main) : |
| 294 | main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 295 | import time |
| 296 | for i in range(25): |
| 297 | if i < 15: |
| 298 | j=i+1 |
| 299 | 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 |
| 300 | else: |
| 301 | j=i+16 |
| 302 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 303 | |
| 304 | strtTime = time.time() |
| 305 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 306 | for i in range(10): |
| 307 | if result == main.FALSE: |
| 308 | time.sleep(5) |
| 309 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 310 | else: |
| 311 | break |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 312 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 313 | count = 1 |
| 314 | i = 6 |
| 315 | while i < 16 : |
| 316 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 317 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 318 | if ping == main.FALSE and count < 6: |
| 319 | count = count + 1 |
| 320 | i = 6 |
| 321 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 322 | time.sleep(2) |
| 323 | elif ping == main.FALSE and count ==6: |
| 324 | main.log.error("Ping test failed") |
| 325 | i = 17 |
| 326 | result = main.FALSE |
| 327 | elif ping == main.TRUE: |
| 328 | i = i + 1 |
| 329 | result = main.TRUE |
| 330 | endTime = time.time() |
| 331 | if result == main.TRUE: |
| 332 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 333 | else: |
| 334 | main.log.report("\tPING TEST FAIL") |
| 335 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 336 | time.sleep(10) |
| 337 | |
| 338 | # ********************************************************************************************************************************************************************************************** |
| 339 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 340 | |
| 341 | def CASE5(self,main) : |
| 342 | main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 343 | import time |
| 344 | for i in range(25): |
| 345 | if i < 3: |
| 346 | j=i+1 |
| 347 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 348 | time.sleep(1) |
| 349 | 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']) |
| 350 | elif i >= 3 and i < 5: |
| 351 | j=i+1 |
| 352 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 353 | time.sleep(1) |
| 354 | 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']) |
| 355 | elif i >= 5 and i < 15: |
| 356 | j=i+1 |
| 357 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 358 | time.sleep(1) |
| 359 | 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']) |
| 360 | else: |
| 361 | j=i+16 |
| 362 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 363 | 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']) |
| 364 | time.sleep(1) |
| 365 | strtTime = time.time() |
| 366 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 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'],main.params['NR_Links']) |
| 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 < 6: |
| 380 | count = count + 1 |
| 381 | i = 6 |
| 382 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 383 | time.sleep(2) |
| 384 | elif ping == main.FALSE and count ==6: |
| 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 a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 400 | |
| 401 | def CASE6(self,main) : |
| 402 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
| 403 | import time |
| 404 | main.case("Bringing Link down... ") |
| 405 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 406 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 407 | time.sleep(10) |
| 408 | strtTime = time.time() |
| 409 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 410 | for i in range(10): |
| 411 | if result == main.FALSE: |
| 412 | time.sleep(5) |
| 413 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 414 | else: |
| 415 | break |
| 416 | |
| 417 | count = 1 |
| 418 | i = 6 |
| 419 | while i < 16 : |
| 420 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 421 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 422 | if ping == main.FALSE and count < 10: |
| 423 | count = count + 1 |
| 424 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 425 | i = 6 |
| 426 | time.sleep(2) |
| 427 | elif ping == main.FALSE and count == 10: |
| 428 | main.log.error("Ping test failed") |
| 429 | i = 17 |
| 430 | result = main.FALSE |
| 431 | elif ping == main.TRUE: |
| 432 | i = i + 1 |
| 433 | result = main.TRUE |
| 434 | endTime = time.time() |
| 435 | if result == main.TRUE: |
| 436 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 437 | else: |
| 438 | main.log.report("\tPING TEST FAILED") |
| 439 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 440 | |
| 441 | # ********************************************************************************************************************************************************************************************** |
| 442 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 443 | |
| 444 | def CASE7(self,main) : |
| 445 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 446 | import time |
| 447 | main.case("Bringing Link up... ") |
| 448 | result = main.Mininet1.link(END1='s1',END2='s3',OPTION="down") |
| 449 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 450 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
| 451 | time.sleep(10) |
| 452 | strtTime = time.time() |
| 453 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 454 | for i in range(10): |
| 455 | if result == main.FALSE: |
| 456 | time.sleep(15) |
| 457 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 458 | else: |
| 459 | break |
| 460 | |
| 461 | strtTime = time.time() |
| 462 | count = 1 |
| 463 | i = 6 |
| 464 | while i < 16 : |
| 465 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 466 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 467 | if ping == main.FALSE and count < 10: |
| 468 | count = count + 1 |
| 469 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 470 | i = 6 |
| 471 | time.sleep(2) |
| 472 | elif ping == main.FALSE and count ==10: |
| 473 | main.log.error("Ping test failed") |
| 474 | i = 17 |
| 475 | result = main.FALSE |
| 476 | elif ping == main.TRUE: |
| 477 | i = i + 1 |
| 478 | result = main.TRUE |
| 479 | endTime = time.time() |
| 480 | if result == main.TRUE: |
| 481 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 482 | else: |
| 483 | main.log.report("\tPING TESTS FAILED") |
| 484 | data = main.Mininet1.link(END1='s1',END2='s3',OPTION="up") |
| 485 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 486 | |
| 487 | |
| 488 | # ****************************************************************************************************************************************************************** |
| 489 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 490 | |
| 491 | def CASE21(self,main) : |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 492 | import json |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 493 | 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.") |
| 494 | main.log.report("Check initially hostMAC/IP exist on the mininet...") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 495 | host = main.params['YANK']['hostname'] |
| 496 | mac = main.params['YANK']['hostmac'] |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 497 | RestIP1 = main.params['RESTCALL']['restIP1'] |
| 498 | RestPort = main.params['RESTCALL']['restPort'] |
| 499 | url = main.params['RESTCALL']['restURL'] |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 500 | |
| 501 | t_topowait = 5 |
| 502 | t_restwait = 5 |
| 503 | main.log.report( "Wait time from topo change to ping set to " + str(t_topowait)) |
| 504 | main.log.report( "Wait time from ping to rest call set to " + str(t_restwait)) |
| 505 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
| 506 | time.sleep(t_topowait) |
| 507 | 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] | 508 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 509 | time.sleep(t_restwait) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 510 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
| 511 | main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus)) |
| 512 | if Reststatus == 1: |
| 513 | 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] | 514 | result1 = main.TRUE |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 515 | elif Reststatus > 1: |
| 516 | 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] | 517 | main.log.report("switches are: " + "; ".join(Switch)) |
| 518 | main.log.report("Ports are: " + "; ".join(Port)) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 519 | result1 = main.FALSE |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 520 | elif Reststatus == 0 and Switch == []: |
| 521 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED") |
| 522 | result1 = main.FALSE |
| 523 | else:# check if rest server is working |
| 524 | main.log.error("Issue with find host") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 525 | result1 = main.FALSE |
| 526 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 527 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 528 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 529 | |
| 530 | main.log.report("Yank out s1-eth1") |
| 531 | main.case("Yankout s6-eth1 (link to h1) from s1") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 532 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 533 | time.sleep(t_topowait) |
| 534 | 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] | 535 | |
| 536 | 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] | 537 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 538 | time.sleep(t_restwait) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 539 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
| 540 | |
| 541 | main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus)) |
| 542 | if Reststatus == 1: |
| 543 | 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] | 544 | result2 = main.FALSE |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 545 | elif Reststatus > 1: |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 546 | 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] | 547 | main.log.report("switches are: " + "; ".join(Switch)) |
| 548 | main.log.report("Ports are: " + "; ".join(Port)) |
| 549 | main.log.report("MACs are: " + "; ".join(MAC)) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 550 | result2 = main.FALSE |
| 551 | elif Reststatus == 0 and Switch == []: |
| 552 | 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.") |
| 553 | result2 = main.TRUE |
| 554 | else:# check if rest server is working |
| 555 | main.log.error("Issue with find host") |
| 556 | result2 = main.FALSE |
| 557 | |
| 558 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 559 | main.log.report("Plug s1-eth1 into s6") |
| 560 | main.case("Plug s1-eth1 to s6") |
| 561 | 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] | 562 | time.sleep(t_topowait) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 563 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...") |
| 564 | 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" ) |
| 565 | |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 566 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 567 | time.sleep(t_restwait) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 568 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
| 569 | |
| 570 | main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus)) |
| 571 | if Reststatus == 1: |
| 572 | main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0])) |
| 573 | result3 = main.TRUE |
| 574 | elif Reststatus > 1: |
| 575 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 576 | main.log.report("switches are: " + "; ".join(Switch)) |
| 577 | main.log.report("Ports are: " + "; ".join(Port)) |
| 578 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 579 | result3 = main.FALSE |
| 580 | elif Reststatus == 0 and Switch == []: |
| 581 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 582 | result3 = main.FALSE |
| 583 | else:# check if rest server is working |
| 584 | main.log.error("Issue with find host") |
| 585 | result3 = main.FALSE |
| 586 | |
| 587 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 588 | main.log.report("Move s1-eth1 back on to s1") |
| 589 | main.case("Move s1-eth1 back to s1") |
| 590 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 591 | time.sleep(t_topowait) |
| 592 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 593 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...") |
| 594 | 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" ) |
| 595 | |
| 596 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 597 | time.sleep(t_restwait) |
| 598 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 599 | |
| 600 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 601 | if Reststatus == 1: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 602 | main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0])) |
| 603 | result4 = main.TRUE |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 604 | elif Reststatus > 1: |
| 605 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED") |
| 606 | main.log.report("switches are: " + "; ".join(Switch)) |
| 607 | main.log.report("Ports are: " + "; ".join(Port)) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 608 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 609 | result4 = main.FALSE |
| 610 | elif Reststatus == 0 and Switch == []: |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 611 | 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] | 612 | result4 = main.FALSE |
| 613 | else:# check if rest server is working |
| 614 | main.log.error("Issue with find host") |
| 615 | result4 = main.FALSE |
| 616 | time.sleep(20) |
| 617 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac) |
| 618 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 619 | if Reststatus ==1: |
| 620 | main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout") |
| 621 | elif Reststatus>1: |
| 622 | main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)") |
| 623 | elif Reststatus==0: |
| 624 | main.log.report("\t PASSED - Device cleared after timeout") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 625 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 626 | result = result1 and result2 and result3 and result4 |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 627 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 628 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 629 | # Run a pure ping test. |
| 630 | |
| 631 | def CASE31(self, main): |
| 632 | main.log.report("Performing Ping Test") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 633 | count = 1 |
| 634 | i = 6 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 635 | while i < 16 : |
| 636 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 637 | strtTime = time.time() |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 638 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 639 | if ping == main.FALSE and count < 6: |
| 640 | count = count + 1 |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 641 | i = 6 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 642 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 643 | time.sleep(2) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 644 | elif ping == main.FALSE and count ==6: |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 645 | main.log.error("Ping test failed") |
| 646 | i = 17 |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 647 | result = main.FALSE |
| 648 | elif ping == main.TRUE: |
| 649 | i = i + 1 |
| 650 | result = main.TRUE |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 651 | endTime = time.time() |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 652 | if result == main.TRUE: |
| 653 | 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] | 654 | else: |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 655 | main.log.report("\tPING TEST FAIL") |
| 656 | 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] | 657 | |
| 658 | |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 659 | def CASE66(self, main): |
| 660 | main.log.report("Checking ONOS logs for exceptions") |
| 661 | count = 0 |
| 662 | check1 = main.ONOS1.check_exceptions() |
| 663 | main.log.report("Exceptions in ONOS1 logs: \n" + check1) |
| 664 | check2 = main.ONOS2.check_exceptions() |
| 665 | main.log.report("Exceptions in ONOS2 logs: \n" + check2) |
| 666 | check3 = main.ONOS3.check_exceptions() |
| 667 | main.log.report("Exceptions in ONOS3 logs: \n" + check3) |
| 668 | check4 = main.ONOS4.check_exceptions() |
| 669 | main.log.report("Exceptions in ONOS4 logs: \n" + check4) |
| 670 | result = main.TRUE |
| 671 | if (check1 or check2 or check3 or check4): |
| 672 | result = main.FALSE |
| 673 | count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines()) |
| 674 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No Exceptions found in the logs",onfail=str(count) + " Exceptions were found in the logs") |
| 675 | main.Mininet2.stop_tcpdump() |
| 676 | |
| 677 | |
| 678 | def CASE8(self,main) : |
| 679 | main.log.report("Testing Removal of Zookeeper") |
| 680 | main.Zookeeper2.stop() |
| 681 | main.Zookeeper3.stop() |
| 682 | main.Zookeeper4.stop() |
| 683 | strtTime = time.time() |
| 684 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 685 | for i in range(10): |
| 686 | if result == main.FALSE: |
| 687 | time.sleep(5) |
| 688 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 689 | else: |
| 690 | break |
| 691 | |
| 692 | count = 1 |
| 693 | i = 6 |
| 694 | while i < 16 : |
| 695 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 696 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 697 | if ping == main.FALSE and count < 6: |
| 698 | count = count + 1 |
| 699 | i = 6 |
| 700 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 701 | time.sleep(2) |
| 702 | elif ping == main.FALSE and count ==6: |
| 703 | main.log.error("Ping test failed") |
| 704 | i = 17 |
| 705 | result = main.FALSE |
| 706 | elif ping == main.TRUE: |
| 707 | i = i + 1 |
| 708 | result = main.TRUE |
| 709 | endTime = time.time() |
| 710 | if result == main.TRUE: |
| 711 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 712 | else: |
| 713 | main.log.report("\tPING TEST FAIL") |
| 714 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 715 | time.sleep(10) |
| 716 | main.Zookeeper2.start() |
| 717 | main.Zookeeper3.start() |
| 718 | main.Zookeeper4.start() |
| 719 | time.sleep(10) |
| 720 | |
| 721 | |
| 722 | def CASE67(self, main) : |
| 723 | main.case("Flapping link s1-s2") |
| 724 | main.log.report("Toggling of link s1-s2 multiple times") |
| 725 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 726 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 727 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 728 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 729 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 730 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 731 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 732 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 733 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 734 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 735 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 736 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 737 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 738 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 739 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 740 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 741 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 742 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 743 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 744 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 745 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 746 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 747 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 748 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 749 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 750 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 751 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 752 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 753 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 754 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 755 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 756 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 757 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 758 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 759 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 760 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 761 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 762 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 763 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 764 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 765 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 766 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 767 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 768 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 769 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 770 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 771 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 772 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 773 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 774 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 775 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 776 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 777 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 778 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 779 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 780 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 781 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 782 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 783 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 784 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 785 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 786 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 787 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 788 | |
| 789 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 790 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 791 | for i in range(10): |
| 792 | if result == main.FALSE: |
| 793 | time.sleep(15) |
| 794 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 795 | else: |
| 796 | break |
| 797 | |
| 798 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 799 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links']))) |
| 800 | for i in range(10): |
| 801 | if result == main.FALSE: |
| 802 | time.sleep(15) |
| 803 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links']))) |
| 804 | else: |
| 805 | break |
| 806 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 807 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 808 | for i in range(10): |
| 809 | if result == main.FALSE: |
| 810 | time.sleep(15) |
| 811 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 812 | else: |
| 813 | break |
| 814 | |
admin | 803f05d | 2014-07-18 10:44:38 -0700 | [diff] [blame] | 815 | #***************************************************************************************** |
| 816 | #***************************************************************************************** |
| 817 | # CASE101: |
| 818 | # This case is designed to test the intents framework |
| 819 | # It will cover Installation, Deletion, Rerouting, and Calling of Intents |
| 820 | #***************************************************************************************** |
| 821 | #***************************************************************************************** |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 822 | |
| 823 | |
| 824 | def CASE101(self,main) : |
| 825 | import time |
| 826 | import json |
| 827 | import re |
| 828 | main.case("Testing the Intent Framework of ONOS") |
| 829 | |
| 830 | #***************************************************************************************** |
| 831 | #***************************************************************************************** |
| 832 | # The first part of CASE 101 will be assigning the master controllers to the switches |
| 833 | # and to check that each one is assigned correctly. |
| 834 | #***************************************************************************************** |
| 835 | #***************************************************************************************** |
| 836 | main.step("Assigning Master Controllers to the Switches and check") |
| 837 | for i in range(25): |
| 838 | if i<3: |
| 839 | j=i+1 |
| 840 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 841 | elif i>=3 and i<5: |
| 842 | j=i+1 |
| 843 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port1']) |
| 844 | elif i>=5 and i<15: |
| 845 | j=j+1 |
| 846 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port1']) |
| 847 | else: |
| 848 | j=i+16 |
| 849 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port1']) |
| 850 | result = main.TRUE |
| 851 | for i in range(25): |
| 852 | if i<3: |
| 853 | j=i+1 |
| 854 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 855 | print("Response is " + str(response)) |
| 856 | if re.search("tcp:"+main.params['CTRL']['ip1'],response) : |
| 857 | result = result and main.TRUE |
| 858 | else: |
| 859 | result = main.FALSE |
| 860 | elif i>=3 and i<5: |
| 861 | j=i+1 |
| 862 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 863 | if re.search("tcp:"+main.params['CTRL']['ip2'],response) : |
| 864 | result = result and main.TRUE |
| 865 | else: |
| 866 | result = main.FALSE |
| 867 | elif i>=5 and i<15: |
| 868 | j=j+1 |
| 869 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 870 | if re.search("tcp:"+main.params['CTRL']['ip3'],response) : |
| 871 | result = result and main.TRUE |
| 872 | else: |
| 873 | result = main.FALSE |
| 874 | else: |
| 875 | j=i+16 |
| 876 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 877 | if re.search("tcp:"+main.params['CTRL']['ip4'],response) : |
| 878 | result = result and main.TRUE |
| 879 | else: |
| 880 | result = main.FALSE |
| 881 | print(result) |
| 882 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Master Controllers assigned Properly",onfail="FAILED TO ASSIGN MASTER CONTROLLERS!") |
| 883 | |
| 884 | #***************************************************************************************** |
| 885 | #***************************************************************************************** |
| 886 | # Assign all controllers to the switches as backups. Run a get-controller on each |
| 887 | # switch to ensure that all controllers have been assigned properly to its switches |
| 888 | #***************************************************************************************** |
| 889 | #***************************************************************************************** |
| 890 | main.step("Assigning all Controllers as Backups to Switches and Check") |
| 891 | for i in range(25): |
| 892 | if i<15: |
| 893 | j=i+1 |
| 894 | 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']) |
| 895 | else: |
| 896 | j=i+16 |
| 897 | 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']) |
| 898 | result = main.TRUE |
| 899 | time.sleep(5) |
| 900 | for i in range(25): |
| 901 | if i<15: |
| 902 | j=i+1 |
| 903 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 904 | 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): |
| 905 | result = result and main.TRUE |
| 906 | else: |
| 907 | result = main.FALSE |
| 908 | else: |
| 909 | j=i+16 |
| 910 | response=main.Mininet1.get_sw_controller("s"+str(j)) |
| 911 | 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): |
| 912 | result = result and main.TRUE |
| 913 | else: |
| 914 | result = main.FALSE |
| 915 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Controllers assigned properly to all switches",onfail="FAILED TO ASSIGN CONTROLLERS PROPERLY!") |
| 916 | |
| 917 | |
| 918 | |
| 919 | #***************************************************************************************** |
| 920 | #***************************************************************************************** |
| 921 | # Installation of Intents. This part will run run a forloop and add an intent from |
| 922 | # h6 to h31, h7 to h32, etc and the other way as well, h31 to h6, h32 to h7, etc. |
| 923 | # then Check by dumping the flows on SW2 and check for flows going bidirectionally. |
| 924 | #***************************************************************************************** |
| 925 | #***************************************************************************************** |
| 926 | main.step("Install intents and Check for Installation of Flows") |
| 927 | intentIP = main.params['INTENTREST']['intentIP'] |
| 928 | intentPort=main.params['INTENTREST']['intentPort'] |
| 929 | intentURL=main.params['INTENTREST']['intentURL'] |
| 930 | count = 1 |
| 931 | for i in range(6,16): |
| 932 | time.sleep(1) |
| 933 | srcMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 934 | dstMac = '00:00:00:00:00:'+str(hex(i+10)[2:]) |
| 935 | #srcDPID=str(i) |
| 936 | #dstDPID=str(i+10) |
| 937 | srcDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2) |
| 938 | dstDPID= '00:00:00:00:00:00:20:' +str(i+25) |
| 939 | 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) |
| 940 | count +=1 |
| 941 | dstMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 942 | srcMac = '00:00:00:00:00:'+str(hex(i+10)[2:]) |
| 943 | #srcDPID=str(i) |
| 944 | #dstDPID=str(i+10) |
| 945 | dstDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2) |
| 946 | srcDPID= '00:00:00:00:00:00:20:' +str(i+25) |
| 947 | 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) |
| 948 | count+=1 |
admin | 803f05d | 2014-07-18 10:44:38 -0700 | [diff] [blame] | 949 | main.ONOS1.show_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 950 | result = main.TRUE |
| 951 | response = main.Mininet1.check_flows(sw="s1") |
| 952 | print(response) |
| 953 | for i in range(6,16): |
| 954 | 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): |
| 955 | result = result and main.TRUE |
| 956 | else: |
| 957 | result = main.FALSE |
| 958 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flows added Properly",onfail="Flows were not added properly") |
| 959 | |
| 960 | #***************************************************************************************** |
| 961 | #***************************************************************************************** |
| 962 | # This step will run a ping test from h6 to h31, h7 to h32, etc as an End to End test |
| 963 | # All of these pings should run through. |
| 964 | #***************************************************************************************** |
| 965 | #***************************************************************************************** |
| 966 | main.step("Ping Test as End to End Test that the Intents were Correctly Installed") |
| 967 | main.log.report("Performing Ping Test") |
| 968 | count = 1 |
| 969 | i = 6 |
| 970 | while i < 16 : |
| 971 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 972 | strtTime = time.time() |
| 973 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 974 | if ping == main.FALSE and count < 6: |
| 975 | count = count + 1 |
| 976 | i = 6 |
| 977 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 978 | time.sleep(2) |
| 979 | elif ping == main.FALSE and count ==6: |
| 980 | main.log.error("Ping test failed") |
| 981 | i = 17 |
| 982 | result = main.FALSE |
| 983 | elif ping == main.TRUE: |
| 984 | i = i + 1 |
| 985 | result = main.TRUE |
| 986 | endTime = time.time() |
| 987 | if result == main.TRUE: |
| 988 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 989 | else: |
| 990 | main.log.report("\tPING TEST FAIL") |
| 991 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 992 | |
| 993 | #***************************************************************************************** |
| 994 | #***************************************************************************************** |
| 995 | # Removing a single intent. Then check to ensure that intent was found by calling |
| 996 | # show_intent. Then check that flows are removed by pinging. |
| 997 | #***************************************************************************************** |
| 998 | #***************************************************************************************** |
| 999 | main.step("Delete a single intent and ensure that flows are deleted") |
| 1000 | main.ONOS1.del_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL,intent_id="intent_id=10") |
| 1001 | time.sleep(2) |
| 1002 | response = main.ONOS1.show_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL,intent_id=10) |
| 1003 | if re.search("INTENT_NOT_FOUND",response): |
| 1004 | main.log.report("Intent Removed Properly!") |
| 1005 | else: |
| 1006 | main.log.report("ERROR REMOVING INTENT") |
| 1007 | main.log.report("Performing Ping Test") |
| 1008 | count = 1 |
| 1009 | for count in range(4): |
| 1010 | ping = main.Mininet1.pingHost(src="h10",target="h35") |
| 1011 | if ping==main.FALSE and count == 3: |
| 1012 | main.log.info("Ping failed as expected. Intent Deleted") |
| 1013 | result = main.TRUE |
| 1014 | elif ping == main.TRUE: |
| 1015 | main.log.error("Intent was not deleted correctly") |
| 1016 | result = main.FALSE |
| 1017 | else: |
admin | 803f05d | 2014-07-18 10:44:38 -0700 | [diff] [blame] | 1018 | main.log.info("So far so good, attempting "+str(2-count) + " more times") |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 1019 | if result == main.TRUE: |
| 1020 | main.log.report("\tIntent Deleted!") |
| 1021 | else: |
| 1022 | main.log.report("\tINTENT FAILED TO BE DELETED") |
| 1023 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Intent Deleted Properly - Step Passed",onfail="INTENT NOT DELETED - STEP FAILED") |
admin | 089a078 | 2014-07-22 15:48:19 -0700 | [diff] [blame^] | 1024 | #main.ONOS1.del_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
| 1025 | main.ONOS1.add_intent(intent_id=str(10),src_dpid="00:00:00:00:00:00:10: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) |
| 1026 | |
| 1027 | |
| 1028 | |
| 1029 | #***************************************************************************************** |
| 1030 | #***************************************************************************************** |
| 1031 | # Delete all intents, and ensure that all flows were deleted |
| 1032 | # Will delete, then call for intents. |
| 1033 | # Lastly try a ping test to check that all flows are deleted. |
| 1034 | #***************************************************************************************** |
| 1035 | #***************************************************************************************** |
| 1036 | main.step("Deleting all flows and check that they are all gone") |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 1037 | |
| 1038 | |
| 1039 | #***************************************************************************************** |
| 1040 | #***************************************************************************************** |
| 1041 | # Install a bad intent. Then, ensure that we are able to get rid of it |
| 1042 | # Installing an intent as ID=200, from a random dpid/mac to random dpid/mac. Then, |
| 1043 | # check to make sure the intent is there, then delete it and ensure that it is gone |
| 1044 | #***************************************************************************************** |
| 1045 | #***************************************************************************************** |
| 1046 | |
| 1047 | |
| 1048 | main.step("Installing incorrect intent and checking for deletion") |
| 1049 | 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) |
admin | 803f05d | 2014-07-18 10:44:38 -0700 | [diff] [blame] | 1050 | main.ONOS1.show_intent(intent_id=str(200),intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
admin | 089a078 | 2014-07-22 15:48:19 -0700 | [diff] [blame^] | 1051 | main.ONOS1.del_intent(intent_id="intent_id=200",intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
admin | 803f05d | 2014-07-18 10:44:38 -0700 | [diff] [blame] | 1052 | time.sleep(2) |
| 1053 | response = main.ONOS1.show_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL,intent_id=200) |
| 1054 | if re.search("INTENT_NOT_FOUND",response): |
| 1055 | main.log.report("Intent Removed Properly!") |
| 1056 | else: |
| 1057 | main.log.report("ERROR REMOVING INTENT") |
admin | 8a30f34 | 2014-06-24 15:54:26 -0700 | [diff] [blame] | 1058 | |
| 1059 | |
| 1060 | |
| 1061 | def CASE10(self, main) : |
| 1062 | import time |
| 1063 | time.sleep(600) |