admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1 | |
| 2 | class OnosCHO4nodes : |
| 3 | |
| 4 | def __init__(self) : |
| 5 | self.default = '' |
| 6 | |
| 7 | #********************************************************************************************************************************************************************************************** |
| 8 | #Test startup |
| 9 | #Tests the startup of Zookeeper1, Cassandra1, and ONOS1 to be certain that all started up successfully |
| 10 | def CASE1(self,main) : #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 11 | import time |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 12 | main.ONOS1.stop() |
| 13 | main.ONOS2.stop() |
| 14 | main.ONOS3.stop() |
| 15 | main.ONOS4.stop() |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 16 | main.ONOS1.git_pull() |
| 17 | main.ONOS2.git_pull() |
| 18 | main.ONOS3.git_pull() |
| 19 | main.ONOS4.git_pull() |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 20 | main.Cassandra1.start() |
| 21 | main.Cassandra2.start() |
| 22 | main.Cassandra3.start() |
| 23 | main.Cassandra4.start() |
| 24 | time.sleep(20) |
| 25 | main.ONOS1.drop_keyspace() |
| 26 | main.ONOS1.start() |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 27 | time.sleep(30) |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 28 | main.ONOS2.start() |
| 29 | main.ONOS3.start() |
| 30 | main.ONOS4.start() |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 31 | time.sleep(20) |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 32 | main.ONOS1.get_version() |
| 33 | main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections") |
| 34 | main.case("Checking if the startup was clean...") |
| 35 | main.step("Testing startup Zookeeper") |
| 36 | data = main.Zookeeper1.isup() |
| 37 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...") |
| 38 | main.step("Testing startup Cassandra") |
| 39 | data = main.Cassandra1.isup() |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 40 | if data == main.FALSE: |
| 41 | main.Cassandra1.stop() |
| 42 | main.Cassandra2.stop() |
| 43 | main.Cassandra3.stop() |
| 44 | main.Cassandra4.stop() |
| 45 | |
| 46 | time.sleep(5) |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 47 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 48 | main.Cassandra1.start() |
| 49 | main.Cassandra2.start() |
| 50 | main.Cassandra3.start() |
| 51 | main.Cassandra4.start() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 52 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...") |
| 53 | main.step("Testing startup ONOS") |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 54 | data = main.ONOS1.isup() |
| 55 | data = data and main.ONOS2.isup() |
| 56 | data = data and main.ONOS3.isup() |
| 57 | data = data and main.ONOS4.isup() |
| 58 | if data == main.FALSE: |
| 59 | main.log.report("Something is funny... restarting ONOS") |
| 60 | main.ONOS1.stop() |
| 61 | main.ONOS2.stop() |
| 62 | main.ONOS3.stop() |
| 63 | main.ONOS4.stop() |
| 64 | time.sleep(5) |
| 65 | main.ONOS1.start() |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 66 | time.sleep(30) |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 67 | main.ONOS2.start() |
| 68 | main.ONOS3.start() |
| 69 | main.ONOS4.start() |
| 70 | data = main.ONOS1.isup() |
| 71 | #main.ONOS1.tcpdump() |
| 72 | #main.ONOS2.tcpdump() |
| 73 | #main.ONOS3.tcpdump() |
| 74 | #main.ONOS4.tcpdump() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 75 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...") |
| 76 | |
| 77 | #********************************************************************************************************************************************************************************************** |
| 78 | #Assign Controllers |
| 79 | #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>). |
| 80 | #Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers. |
| 81 | #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 |
| 82 | # the controllers already assigned to the switch are not specified. |
| 83 | |
| 84 | def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches |
| 85 | import time |
| 86 | main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4") |
| 87 | main.case("Checking if one MN host exists") |
| 88 | main.step("Host IP Checking using checkIP") |
| 89 | result = main.Mininet1.checkIP(main.params['CASE1']['destination']) |
| 90 | main.step("Verifying the result") |
| 91 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured") |
| 92 | main.step("assigning ONOS controllers to switches") |
| 93 | for i in range(25): |
| 94 | if i < 3: |
| 95 | j=i+1 |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 96 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 97 | time.sleep(1) |
| 98 | main.Mininet1.assign_sw_controller(sw=str(j),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 | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 99 | elif i >= 3 and i < 5: |
| 100 | j=i+1 |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 101 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 102 | time.sleep(1) |
| 103 | main.Mininet1.assign_sw_controller(sw=str(j),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 | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 104 | elif i >= 5 and i < 15: |
| 105 | j=i+1 |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 106 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 107 | time.sleep(1) |
| 108 | main.Mininet1.assign_sw_controller(sw=str(j),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 | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 109 | else: |
| 110 | j=i+16 |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 111 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 112 | time.sleep(1) |
| 113 | main.Mininet1.assign_sw_controller(sw=str(j),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 | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 114 | main.Mininet1.get_sw_controller("s1") |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 115 | |
| 116 | for i in range(9): |
| 117 | if result == main.FALSE: |
| 118 | time.sleep(3) |
| 119 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 120 | else: |
| 121 | break |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 122 | |
| 123 | # ********************************************************************************************************************************************************************************************** |
| 124 | #Add Flows |
| 125 | #Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test |
| 126 | #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 |
| 127 | |
| 128 | def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update |
| 129 | main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update") |
| 130 | import time |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 131 | |
| 132 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 133 | for counter in range(9): |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 134 | if result == main.FALSE: |
| 135 | time.sleep(3) |
| 136 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 137 | else: |
| 138 | break |
| 139 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 140 | main.case("Taking care of these flows!") |
| 141 | main.step("Cleaning out any leftover flows...") |
| 142 | main.ONOS1.delete_flow("all") |
| 143 | time.sleep(5) |
| 144 | strtTime = time.time() |
| 145 | main.ONOS1.add_flow(main.params['FLOWDEF']) |
| 146 | main.case("Checking flows") |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 147 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 148 | pingAttempts = main.params['pingAttempts'] |
| 149 | pingSleep = main.params['pingSleep'] |
| 150 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 151 | count = 1 |
| 152 | i = 6 |
| 153 | while i < 16 : |
| 154 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 155 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 156 | if ping == main.FALSE and count < int(pingAttempts): |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 157 | count = count + 1 |
| 158 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 159 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
| 160 | time.sleep(int(pingSleep)) |
| 161 | elif ping == main.FALSE and count == int(pingAttempts): |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 162 | main.log.error("Ping test failed") |
| 163 | i = 17 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 164 | result = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 165 | elif ping == main.TRUE: |
| 166 | i = i + 1 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 167 | result = main.TRUE |
| 168 | endTime = time.time() |
| 169 | if result == main.TRUE: |
| 170 | main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 171 | else: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 172 | main.log.report("\tFlows failed check") |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 173 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 174 | main.step("Verifying the result") |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 175 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 176 | |
| 177 | #********************************************************************************************************************************************************************************************** |
| 178 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 179 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 180 | #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. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 181 | #If the ping test fails 6 times, then the test case will return false |
| 182 | |
| 183 | def CASE4(self,main) : |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 184 | main.log.report("Remove all but one ONOS then ping until all hosts are reachable or fail after 6 attempts") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 185 | import time |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 186 | import random |
| 187 | |
| 188 | random.seed(None) |
| 189 | |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 190 | num = random.randint(1,4) |
| 191 | if num == 1: |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 192 | ip = main.params['CTRL']['ip1'] |
| 193 | port = main.params['CTRL']['port1'] |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 194 | elif num == 2: |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 195 | ip = main.params['CTRL']['ip2'] |
| 196 | port = main.params['CTRL']['port2'] |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 197 | elif num == 3: |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 198 | ip = main.params['CTRL']['ip3'] |
| 199 | port = main.params['CTRL']['port3'] |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 200 | else: |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 201 | ip = main.params['CTRL']['ip4'] |
| 202 | port = main.params['CTRL']['port4'] |
| 203 | |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 204 | main.log.report("ONOS"+str(num)+" will be the sole controller") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 205 | for i in range(25): |
| 206 | if i < 15: |
| 207 | j=i+1 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 208 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) #Assigning a single controller removes all other controllers |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 209 | else: |
| 210 | j=i+16 |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 211 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 212 | |
| 213 | strtTime = time.time() |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 214 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 215 | for counter in range(9): |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 216 | if result == main.FALSE: |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 217 | time.sleep(3) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 218 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 219 | else: |
| 220 | break |
| 221 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 222 | pingAttempts = main.params['pingAttempts'] |
| 223 | pingSleep = main.params['pingSleep'] |
| 224 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 225 | count = 1 |
| 226 | i = 6 |
| 227 | while i < 16 : |
| 228 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 229 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 230 | if ping == main.FALSE and count < int(pingAttempts): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 231 | count = count + 1 |
| 232 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 233 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
| 234 | time.sleep(int(pingSleep)) |
| 235 | elif ping == main.FALSE and count == int(pingAttempts): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 236 | main.log.error("Ping test failed") |
| 237 | i = 17 |
| 238 | result = main.FALSE |
| 239 | elif ping == main.TRUE: |
| 240 | i = i + 1 |
| 241 | result = main.TRUE |
| 242 | endTime = time.time() |
| 243 | if result == main.TRUE: |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 244 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 245 | else: |
| 246 | main.log.report("\tPING TEST FAIL") |
| 247 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 248 | |
| 249 | # ********************************************************************************************************************************************************************************************** |
| 250 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 251 | |
| 252 | def CASE5(self,main) : |
| 253 | main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 254 | import time |
| 255 | for i in range(25): |
| 256 | if i < 15: |
| 257 | j=i+1 |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 258 | main.Mininet1.assign_sw_controller(sw=str(j),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 | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 259 | else: |
| 260 | j=i+16 |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 261 | main.Mininet1.assign_sw_controller(sw=str(j),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 | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 262 | |
| 263 | strtTime = time.time() |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 264 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 265 | for counter in range(9): |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 266 | if result == main.FALSE: |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 267 | time.sleep(3) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 268 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 269 | else: |
| 270 | break |
| 271 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 272 | pingAttempts = main.params['pingAttempts'] |
| 273 | pingSleep = main.params['pingSleep'] |
| 274 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 275 | count = 1 |
| 276 | i = 6 |
| 277 | while i < 16 : |
| 278 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 279 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 280 | if ping == main.FALSE and count < int(pingAttempts): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 281 | count = count + 1 |
| 282 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 283 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
| 284 | time.sleep(int(pingSleep)) |
| 285 | elif ping == main.FALSE and count == int(pingAttempts): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 286 | main.log.error("Ping test failed") |
| 287 | i = 17 |
| 288 | result = main.FALSE |
| 289 | elif ping == main.TRUE: |
| 290 | i = i + 1 |
| 291 | result = main.TRUE |
| 292 | endTime = time.time() |
| 293 | if result == main.TRUE: |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 294 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 295 | else: |
| 296 | main.log.report("\tPING TEST FAILED") |
| 297 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 298 | |
| 299 | # ********************************************************************************************************************************************************************************************** |
| 300 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 301 | |
| 302 | def CASE6(self,main) : |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 303 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 304 | import time |
| 305 | main.case("Bringing Link down... ") |
| 306 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 307 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 308 | |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 309 | strtTime = time.time() |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 310 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 311 | for counter in range(9): |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 312 | if result == main.FALSE: |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 313 | time.sleep(3) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 314 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 315 | else: |
| 316 | break |
| 317 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 318 | pingAttempts = main.params['pingAttempts'] |
| 319 | pingSleep = main.params['pingSleep'] |
| 320 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 321 | count = 1 |
| 322 | i = 6 |
| 323 | while i < 16 : |
| 324 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 325 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 326 | if ping == main.FALSE and count < int(pingAttempts): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 327 | count = count + 1 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 328 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 329 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 330 | time.sleep(int(pingSleep)) |
| 331 | elif ping == main.FALSE and count == int(pingAttempts): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 332 | main.log.error("Ping test failed") |
| 333 | i = 17 |
| 334 | result = main.FALSE |
| 335 | elif ping == main.TRUE: |
| 336 | i = i + 1 |
| 337 | result = main.TRUE |
| 338 | endTime = time.time() |
| 339 | if result == main.TRUE: |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 340 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 341 | else: |
| 342 | main.log.report("\tPING TEST FAILED") |
| 343 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 344 | |
| 345 | # ********************************************************************************************************************************************************************************************** |
| 346 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 347 | |
| 348 | def CASE7(self,main) : |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 349 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 350 | import time |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 351 | main.case("Bringing Link up... ") |
| 352 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 353 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 354 | |
| 355 | strtTime = time.time() |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 356 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 357 | for counter in range(9): |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 358 | if result == main.FALSE: |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 359 | time.sleep(3) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 360 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 361 | else: |
| 362 | break |
| 363 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 364 | pingAttempts = main.params['pingAttempts'] |
| 365 | pingSleep = main.params['pingSleep'] |
| 366 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 367 | strtTime = time.time() |
| 368 | count = 1 |
| 369 | i = 6 |
| 370 | while i < 16 : |
| 371 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 372 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 373 | if ping == main.FALSE and count < int(pingAttempts): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 374 | count = count + 1 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 375 | main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 376 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame^] | 377 | time.sleep(int(pingSleep)) |
| 378 | elif ping == main.FALSE and count == int(pingAttempts): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 379 | main.log.error("Ping test failed") |
| 380 | i = 17 |
| 381 | result = main.FALSE |
| 382 | elif ping == main.TRUE: |
| 383 | i = i + 1 |
| 384 | result = main.TRUE |
| 385 | endTime = time.time() |
| 386 | if result == main.TRUE: |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 387 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 388 | else: |
| 389 | main.log.report("\tPING TESTS FAILED") |
| 390 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 391 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 392 | |
| 393 | # ****************************************************************************************************************************************************************** |
| 394 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 395 | |
| 396 | def CASE21(self,main) : |
| 397 | import json |
| 398 | from drivers.common.api.onosrestapidriver import * |
| 399 | main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.") |
| 400 | main.log.report("Check initially hostMAC exist on the mininet...") |
| 401 | host = main.params['YANK']['hostname'] |
| 402 | mac = main.params['YANK']['hostmac'] |
| 403 | RestIP1 = main.params['RESTCALL']['restIP1'] |
| 404 | RestIP2 = main.params['RESTCALL']['restIP2'] |
| 405 | RestPort = main.params['RESTCALL']['restPort'] |
| 406 | url = main.params['RESTCALL']['restURL'] |
| 407 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
| 408 | |
| 409 | 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" ) |
| 410 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 411 | restcall = OnosRestApiDriver() |
| 412 | Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac) |
| 413 | try: |
| 414 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 415 | ip_found = Hoststatus[0]['ipv4'][0] |
| 416 | except: |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 417 | Reststatus = 0 |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 418 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 419 | if Reststatus == 1: |
| 420 | main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW) |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 421 | if ip_found != None: |
| 422 | main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).") |
| 423 | result = main.TRUE |
| 424 | else: |
| 425 | main.log.report("\t Found host attached to switch, but no IP address discovered.") |
| 426 | result = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 427 | else: |
| 428 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 429 | result = main.FALSE |
| 430 | |
| 431 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 432 | |
| 433 | main.log.report("Yank out s1-eth1") |
| 434 | main.case("Yankout s6-eth1 (link to h1) from s1") |
| 435 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 436 | time.sleep(3) |
| 437 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
| 438 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 439 | Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac) |
| 440 | try: |
| 441 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 442 | except: |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 443 | Reststatus = 0 |
| 444 | if Reststatus == 0: |
| 445 | main.log.report("Attempt to yank out s1-eth1 from s1 sucessfully") |
| 446 | result = main.TRUE |
| 447 | else: |
| 448 | main.log.report("Attempt to yank out s1-eht1 from s1 failed.") |
| 449 | result = main.FALSE |
| 450 | |
| 451 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 452 | main.log.report("Plug s1-eth1 into s6") |
| 453 | main.case("Plug s1-eth1 to s6") |
| 454 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
| 455 | time.sleep(3) |
| 456 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...") |
| 457 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 458 | Reststatus, Hoststatus = restcall.find_host(RestIP2,RestPort,url,mac) |
| 459 | try: |
| 460 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 461 | ip_found = Hoststatus[0]['ipv4'][0] |
| 462 | except: |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 463 | Reststatus = 0 |
| 464 | if Reststatus == 0: |
| 465 | main.log.report("Attempt to plug s1-eth1 to s6 FAILED") |
| 466 | result = main.FALSE |
| 467 | elif attachedSW == "00:00:00:00:00:00:00:06": |
| 468 | main.log.report("Attempt to plug s1-eht1 to s6 succeded.") |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 469 | if ip_found != None: |
| 470 | main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).") |
| 471 | result = main.TRUE |
| 472 | else: |
| 473 | main.log.report("\t Found host attached to switch, but no IP address discovered.") |
| 474 | result = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 475 | else: |
| 476 | main.log.report( "FAILED to attach s1-eth1 to s6 correctly!") |
| 477 | result = main.FALSE |
| 478 | |
| 479 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 480 | main.log.report("Move s1-eth1 back on to s1") |
| 481 | main.case("Move s1-eth1 back to s1") |
| 482 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 483 | time.sleep(3) |
| 484 | retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 485 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...") |
| 486 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 487 | Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac) |
| 488 | try: |
| 489 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 490 | ip_found = Hoststatus[0]['ipv4'][0] |
| 491 | except: |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 492 | Reststatus = 0 |
| 493 | if Reststatus == 0: |
| 494 | main.log.report("Attempt to plug s1-eth1 back to s1 FAILED") |
| 495 | result = main.FALSE |
| 496 | elif attachedSW == "00:00:00:00:00:00:00:01": |
| 497 | main.log.report("Attempt to plug s1-eht1 back to s1 succeded.") |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 498 | if ip_found != None: |
| 499 | main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).") |
| 500 | result = main.TRUE |
| 501 | else: |
| 502 | main.log.report("\t Found host attached to switch, but no IP address discovered.") |
| 503 | result = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 504 | else: |
| 505 | main.log.report( "FAIL to attach s1-eth1 to s1 correctly!") |
| 506 | result = main.FALSE |
| 507 | |
| 508 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 509 | |
| 510 | |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 511 | |
| 512 | |