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 | 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) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 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") |
| 103 | |
| 104 | # ********************************************************************************************************************************************************************************************** |
| 105 | #Add Flows |
| 106 | #Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test |
| 107 | #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 |
| 108 | |
| 109 | def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update |
| 110 | main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update") |
| 111 | import time |
| 112 | main.case("Taking care of these flows!") |
| 113 | main.step("Cleaning out any leftover flows...") |
| 114 | main.ONOS1.delete_flow("all") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 115 | strtTime = time.time() |
| 116 | main.ONOS1.add_flow(main.params['FLOWDEF']) |
| 117 | main.case("Checking flows") |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 118 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 119 | count = 1 |
| 120 | i = 6 |
| 121 | while i < 16 : |
| 122 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 123 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 124 | if ping == main.FALSE and count < 9: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 125 | count = count + 1 |
| 126 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 127 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 128 | time.sleep(2) |
| 129 | elif ping == main.FALSE and count ==9: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 130 | main.log.error("Ping test failed") |
| 131 | i = 17 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 132 | result = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 133 | elif ping == main.TRUE: |
| 134 | i = i + 1 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 135 | result = main.TRUE |
| 136 | endTime = time.time() |
| 137 | if result == main.TRUE: |
| 138 | main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 139 | else: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 140 | main.log.report("\tFlows failed check") |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 141 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 142 | 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] | 143 | main.step("Verifying the result") |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 144 | 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] | 145 | |
| 146 | #********************************************************************************************************************************************************************************************** |
| 147 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 148 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 149 | #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. |
| 150 | #If the ping test fails 6 times, then the test case will return false |
| 151 | |
| 152 | def CASE4(self,main) : |
| 153 | main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 154 | import time |
| 155 | for i in range(25): |
| 156 | if i < 15: |
| 157 | j=i+1 |
| 158 | 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 |
| 159 | else: |
| 160 | j=i+16 |
| 161 | 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] | 162 | |
| 163 | strtTime = time.time() |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 164 | 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] | 165 | for i in range(2): |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 166 | if result == main.FALSE: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 167 | time.sleep(5) |
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']) |
| 169 | else: |
| 170 | break |
| 171 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 172 | count = 1 |
| 173 | i = 6 |
| 174 | while i < 16 : |
| 175 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 176 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 177 | if ping == main.FALSE and count < 6: |
| 178 | count = count + 1 |
| 179 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 180 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 181 | time.sleep(2) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 182 | elif ping == main.FALSE and count ==6: |
| 183 | main.log.error("Ping test failed") |
| 184 | i = 17 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 185 | result = main.FALSE |
| 186 | elif ping == main.TRUE: |
| 187 | i = i + 1 |
| 188 | result = main.TRUE |
| 189 | endTime = time.time() |
| 190 | if result == main.TRUE: |
| 191 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 192 | else: |
| 193 | main.log.report("\tPING TEST FAIL") |
| 194 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 195 | |
| 196 | # ********************************************************************************************************************************************************************************************** |
| 197 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 198 | |
| 199 | def CASE5(self,main) : |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 200 | 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] | 201 | import time |
| 202 | for i in range(25): |
| 203 | if i < 15: |
| 204 | j=i+1 |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 205 | 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] | 206 | else: |
| 207 | j=i+16 |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 208 | 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] | 209 | |
| 210 | strtTime = time.time() |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 211 | 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] | 212 | for i in range(2): |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 213 | if result == main.FALSE: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 214 | time.sleep(5) |
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']) |
| 216 | else: |
| 217 | break |
| 218 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 219 | count = 1 |
| 220 | i = 6 |
| 221 | while i < 16 : |
| 222 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 223 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 224 | if ping == main.FALSE and count < 6: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 225 | count = count + 1 |
| 226 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 227 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 228 | time.sleep(2) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 229 | elif ping == main.FALSE and count ==6: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 230 | main.log.error("Ping test failed") |
| 231 | i = 17 |
| 232 | result = main.FALSE |
| 233 | elif ping == main.TRUE: |
| 234 | i = i + 1 |
| 235 | result = main.TRUE |
| 236 | endTime = time.time() |
| 237 | if result == main.TRUE: |
| 238 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 239 | else: |
| 240 | main.log.report("\tPING TEST FAILED") |
| 241 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 242 | |
| 243 | # ********************************************************************************************************************************************************************************************** |
| 244 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 245 | |
| 246 | def CASE6(self,main) : |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 247 | 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] | 248 | import time |
| 249 | main.case("Bringing Link down... ") |
| 250 | 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] | 251 | 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] | 252 | |
| 253 | strtTime = time.time() |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 254 | 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] | 255 | for i in range(2): |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 256 | if result == main.FALSE: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 257 | time.sleep(5) |
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)) |
| 259 | else: |
| 260 | break |
| 261 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 262 | count = 1 |
| 263 | i = 6 |
| 264 | while i < 16 : |
| 265 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 266 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 267 | if ping == main.FALSE and count < 10: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 268 | count = count + 1 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 269 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 270 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 271 | time.sleep(2) |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 272 | elif ping == main.FALSE and count == 10: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 273 | main.log.error("Ping test failed") |
| 274 | i = 17 |
| 275 | result = main.FALSE |
| 276 | elif ping == main.TRUE: |
| 277 | i = i + 1 |
| 278 | result = main.TRUE |
| 279 | endTime = time.time() |
| 280 | if result == main.TRUE: |
| 281 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 282 | else: |
| 283 | main.log.report("\tPING TEST FAILED") |
| 284 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 285 | |
| 286 | # ********************************************************************************************************************************************************************************************** |
| 287 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 288 | |
| 289 | def CASE7(self,main) : |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 290 | 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] | 291 | import time |
| 292 | main.case("Bringing Link up... ") |
| 293 | 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] | 294 | 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] | 295 | |
| 296 | strtTime = time.time() |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 297 | 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] | 298 | for i in range(2): |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 299 | if result == main.FALSE: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 300 | time.sleep(5) |
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']) |
| 302 | else: |
| 303 | break |
| 304 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 305 | strtTime = time.time() |
| 306 | count = 1 |
| 307 | i = 6 |
| 308 | while i < 16 : |
| 309 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 310 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 311 | if ping == main.FALSE and count < 10: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 312 | count = count + 1 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 313 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 314 | i = 6 |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 315 | time.sleep(2) |
admin | e0ae820 | 2013-08-28 11:51:43 -0700 | [diff] [blame] | 316 | elif ping == main.FALSE and count ==10: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 317 | main.log.error("Ping test failed") |
| 318 | i = 17 |
| 319 | result = main.FALSE |
| 320 | elif ping == main.TRUE: |
| 321 | i = i + 1 |
| 322 | result = main.TRUE |
| 323 | endTime = time.time() |
| 324 | if result == main.TRUE: |
| 325 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 326 | else: |
| 327 | main.log.report("\tPING TESTS FAILED") |
| 328 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 329 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 330 | |
| 331 | # ****************************************************************************************************************************************************************** |
| 332 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 333 | |
| 334 | def CASE21(self,main) : |
| 335 | import json |
| 336 | from drivers.common.api.onosrestapidriver import * |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 337 | 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] | 338 | main.log.report("Check initially hostMAC/IP exist on the mininet...") |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 339 | host = main.params['YANK']['hostname'] |
| 340 | mac = main.params['YANK']['hostmac'] |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 341 | hostip = main.params['YANK']['hostip'] |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 342 | RestIP1 = main.params['RESTCALL']['restIP1'] |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 343 | RestPort = main.params['RESTCALL']['restPort'] |
| 344 | url = main.params['RESTCALL']['restURL'] |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 345 | |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 346 | t_topowait = 0 |
| 347 | t_restwait = 10 |
| 348 | main.log.report( "Wait time from topo change to ping set to " + str(t_topowait)) |
| 349 | main.log.report( "Wait time from ping to rest call set to " + str(t_restwait)) |
| 350 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
| 351 | time.sleep(t_topowait) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 352 | 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" ) |
| 353 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 354 | time.sleep(t_restwait) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 355 | restcall = OnosRestApiDriver() |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 356 | Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip) |
| 357 | 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] | 358 | if Reststatus == 1: |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 359 | 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] | 360 | result1 = main.TRUE |
| 361 | elif Reststatus > 1: |
| 362 | 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^] | 363 | main.log.report("switches are: " + "; ".join(Switch)) |
| 364 | main.log.report("Ports are: " + "; ".join(Port)) |
| 365 | main.log.report("MACs are: " + "; ".join(MAC)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 366 | result1 = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 367 | else: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 368 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED") |
| 369 | result1 = main.FALSE |
| 370 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 371 | |
| 372 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 373 | |
| 374 | main.log.report("Yank out s1-eth1") |
| 375 | main.case("Yankout s6-eth1 (link to h1) from s1") |
| 376 | 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^] | 377 | time.sleep(t_topowait) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 378 | 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] | 379 | |
| 380 | 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] | 381 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 382 | time.sleep(t_restwait) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 383 | restcall = OnosRestApiDriver() |
| 384 | Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip) |
| 385 | |
| 386 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 387 | if Reststatus == 1: |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 388 | 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] | 389 | result2 = main.FALSE |
| 390 | elif Reststatus > 1: |
| 391 | 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^] | 392 | main.log.report("switches are: " + "; ".join(Switch)) |
| 393 | main.log.report("Ports are: " + "; ".join(Port)) |
| 394 | main.log.report("MACs are: " + "; ".join(MAC)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 395 | result2 = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 396 | else: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 397 | 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.") |
| 398 | result2 = main.TRUE |
| 399 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 400 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 401 | main.log.report("Plug s1-eth1 into s6") |
| 402 | main.case("Plug s1-eth1 to s6") |
| 403 | 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^] | 404 | time.sleep(t_topowait) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 405 | 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] | 406 | 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" ) |
| 407 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 408 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 409 | time.sleep(t_restwait) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 410 | restcall = OnosRestApiDriver() |
| 411 | Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip) |
| 412 | |
| 413 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 414 | if Reststatus == 1: |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 415 | 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] | 416 | result3 = main.TRUE |
| 417 | elif Reststatus > 1: |
| 418 | 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^] | 419 | main.log.report("switches are: " + "; ".join(Switch)) |
| 420 | main.log.report("Ports are: " + "; ".join(Port)) |
| 421 | main.log.report("MACs are: " + "; ".join(MAC)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 422 | result3 = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 423 | else: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 424 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 425 | result3 = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 426 | |
| 427 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 428 | main.log.report("Move s1-eth1 back on to s1") |
| 429 | main.case("Move s1-eth1 back to s1") |
| 430 | 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^] | 431 | time.sleep(t_topowait) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 432 | retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 433 | 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] | 434 | 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" ) |
| 435 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 436 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 437 | time.sleep(t_restwait) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 438 | restcall = OnosRestApiDriver() |
| 439 | Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip) |
| 440 | |
| 441 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 442 | if Reststatus == 1: |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 443 | 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] | 444 | result4 = main.TRUE |
| 445 | elif Reststatus > 1: |
| 446 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED") |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 447 | main.log.report("switches are: " + "; ".join(Switch)) |
| 448 | main.log.report("Ports are: " + "; ".join(Port)) |
| 449 | main.log.report("MACs are: " + "; ".join(MAC)) |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 450 | result4 = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 451 | else: |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 452 | main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 453 | result4 = main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 454 | |
admin | 6845330 | 2013-12-16 15:40:04 -0800 | [diff] [blame] | 455 | result = result1 and result2 and result3 and result4 |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 456 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 457 | |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame^] | 458 | # Run a pure ping test. |
| 459 | |
| 460 | def CASE31(self, main): |
| 461 | main.log.report("Performing Ping Test") |
| 462 | count = 1 |
| 463 | i = 6 |
| 464 | while i < 16 : |
| 465 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 466 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 467 | if ping == main.FALSE and count < 6: |
| 468 | count = count + 1 |
| 469 | i = 6 |
| 470 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 471 | time.sleep(2) |
| 472 | elif ping == main.FALSE and count ==6: |
| 473 | main.log.error("Ping test failed") |
| 474 | i = 17 |
| 475 | result = main.FALSE |
| 476 | elif ping == main.TRUE: |
| 477 | i = i + 1 |
| 478 | result = main.TRUE |
| 479 | endTime = time.time() |
| 480 | if result == main.TRUE: |
| 481 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 482 | else: |
| 483 | main.log.report("\tPING TEST FAIL") |
| 484 | 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] | 485 | |