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