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