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