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