SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1 | |
| 2 | class RCOnosCHO4nodes : |
| 3 | |
| 4 | def __init__(self) : |
| 5 | self.default = '' |
| 6 | |
| 7 | #********************************************************************************************************************************************************************************************** |
| 8 | #Test startup |
| 9 | #Tests the startup of Zookeeper1, RamCloud1, 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 | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 12 | main.ONOS1.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 13 | main.ONOS2.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 14 | main.ONOS3.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
| 15 | main.ONOS4.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties") |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 16 | |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 17 | main.ONOS1.stop_all() |
| 18 | main.ONOS2.stop_all() |
| 19 | main.ONOS3.stop_all() |
| 20 | main.ONOS4.stop_all() |
SeanCorcoran | f4ee258 | 2014-04-16 17:12:30 -0700 | [diff] [blame] | 21 | main.Zookeeper1.start() |
SeanCorcoran | f4ee258 | 2014-04-16 17:12:30 -0700 | [diff] [blame] | 22 | main.Zookeeper2.start() |
| 23 | main.Zookeeper3.start() |
| 24 | main.Zookeeper4.start() |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 25 | main.RamCloud1.stop_coor() |
| 26 | main.RamCloud1.stop_serv() |
| 27 | main.RamCloud2.stop_serv() |
| 28 | main.RamCloud3.stop_serv() |
| 29 | main.RamCloud4.stop_serv() |
| 30 | time.sleep(10) |
| 31 | main.RamCloud1.del_db() |
| 32 | main.RamCloud2.del_db() |
| 33 | main.RamCloud3.del_db() |
| 34 | main.RamCloud4.del_db() |
| 35 | time.sleep(10) |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame] | 36 | main.log.report("Pulling latest code from github to all nodes") |
| 37 | for i in range(2): |
| 38 | uptodate = main.ONOS1.git_pull() |
| 39 | main.ONOS2.git_pull() |
| 40 | main.ONOS3.git_pull() |
| 41 | main.ONOS4.git_pull() |
| 42 | ver1 = main.ONOS1.get_version() |
| 43 | ver2 = main.ONOS4.get_version() |
| 44 | if ver1==ver2: |
| 45 | break |
| 46 | elif i==1: |
| 47 | main.ONOS2.git_pull("ONOS1 master") |
| 48 | main.ONOS3.git_pull("ONOS1 master") |
| 49 | main.ONOS4.git_pull("ONOS1 master") |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 50 | #if uptodate==0 |
| 51 | if 1: |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame] | 52 | main.ONOS1.git_compile() |
| 53 | main.ONOS2.git_compile() |
| 54 | main.ONOS3.git_compile() |
| 55 | main.ONOS4.git_compile() |
| 56 | main.ONOS1.print_version() |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 57 | # main.RamCloud1.git_pull() |
| 58 | # main.RamCloud2.git_pull() |
| 59 | # main.RamCloud3.git_pull() |
| 60 | # main.RamCloud4.git_pull() |
| 61 | # main.ONOS1.get_version() |
| 62 | # main.ONOS2.get_version() |
| 63 | # main.ONOS3.get_version() |
| 64 | # main.ONOS4.get_version() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 65 | main.RamCloud1.start_coor() |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 66 | time.sleep(1) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 67 | main.RamCloud1.start_serv() |
| 68 | main.RamCloud2.start_serv() |
| 69 | main.RamCloud3.start_serv() |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 70 | main.RamCloud4.start_serv() |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 71 | main.ONOS1.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ") |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 72 | time.sleep(5) |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 73 | main.ONOS2.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ") |
| 74 | main.ONOS3.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ") |
| 75 | main.ONOS4.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ") |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 76 | main.ONOS1.start_rest() |
| 77 | time.sleep(10) |
| 78 | test= main.ONOS1.rest_status() |
| 79 | if test == main.FALSE: |
| 80 | main.ONOS1.start_rest() |
| 81 | main.ONOS1.get_version() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 82 | main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections") |
| 83 | main.case("Checking if the startup was clean...") |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 84 | main.step("Testing startup Zookeeper") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 85 | data = main.Zookeeper1.isup() |
| 86 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...") |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 87 | main.step("Testing startup RamCloud") |
| 88 | data = main.RamCloud1.status_serv() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 89 | if data == main.FALSE: |
| 90 | main.RamCloud1.stop_coor() |
| 91 | main.RamCloud1.stop_serv() |
| 92 | main.RamCloud2.stop_serv() |
| 93 | main.RamCloud3.stop_serv() |
| 94 | main.RamCloud4.stop_serv() |
| 95 | |
| 96 | time.sleep(5) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 97 | main.RamCloud1.start_coor() |
| 98 | main.RamCloud1.start_serv() |
| 99 | main.RamCloud2.start_serv() |
| 100 | main.RamCloud3.start_serv() |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 101 | main.RamCloud4.start_serv() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 102 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...") |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 103 | main.step("Testing startup ONOS") |
| 104 | data = main.ONOS1.isup() |
| 105 | for i in range(3): |
| 106 | if data == main.FALSE: |
| 107 | #main.log.report("Something is funny... restarting ONOS") |
| 108 | #main.ONOS1.stop() |
| 109 | time.sleep(3) |
| 110 | #main.ONOS1.start() |
| 111 | #time.sleep(5) |
| 112 | data = main.ONOS1.isup() |
| 113 | else: |
| 114 | break |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 115 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 116 | time.sleep(10) |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 117 | |
| 118 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 119 | #********************************************************************************************************************************************************************************************** |
| 120 | #Assign Controllers |
| 121 | #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>). |
| 122 | #Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers. |
| 123 | #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 |
| 124 | # the controllers already assigned to the switch are not specified. |
| 125 | |
| 126 | def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches |
| 127 | import time |
| 128 | main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4") |
| 129 | main.case("Checking if one MN host exists") |
| 130 | main.step("Host IP Checking using checkIP") |
| 131 | result = main.Mininet1.checkIP(main.params['CASE1']['destination']) |
| 132 | main.step("Verifying the result") |
| 133 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured") |
| 134 | main.step("assigning ONOS controllers to switches") |
| 135 | for i in range(25): |
| 136 | if i < 3: |
| 137 | j=i+1 |
| 138 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 139 | time.sleep(1) |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame] | 140 | 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']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 141 | elif i >= 3 and i < 5: |
| 142 | j=i+1 |
| 143 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 144 | time.sleep(1) |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame] | 145 | 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']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 146 | elif i >= 5 and i < 15: |
| 147 | j=i+1 |
| 148 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 149 | time.sleep(1) |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame] | 150 | 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']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 151 | else: |
| 152 | j=i+16 |
| 153 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 154 | time.sleep(1) |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame] | 155 | 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']) |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 156 | result = main.Mininet1.get_sw_controller("s1") |
| 157 | if result: |
| 158 | result = main.TRUE |
| 159 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="S1 assigned to controller",onfail="S1 not assigned to controller") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 160 | |
| 161 | for i in range(9): |
| 162 | if result == main.FALSE: |
| 163 | time.sleep(3) |
| 164 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 165 | else: |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 166 | main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 167 | main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 168 | main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 169 | break |
| 170 | |
| 171 | # ********************************************************************************************************************************************************************************************** |
| 172 | #Add Flows |
| 173 | #Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test |
| 174 | #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 |
| 175 | |
| 176 | def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 177 | main.log.report("Delete any flows from previous tests, then add flows using intents and wait for switch flow tables to update") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 178 | import time |
| 179 | |
| 180 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 181 | for counter in range(9): |
| 182 | if result == main.FALSE: |
| 183 | time.sleep(3) |
| 184 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 185 | else: |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 186 | main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 187 | main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 188 | main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 189 | break |
| 190 | |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 191 | ####New Topo Check |
| 192 | ctrls = [] |
| 193 | count = 1 |
| 194 | while True: |
| 195 | temp = () |
| 196 | if ('ip' + str(count)) in main.params['CTRL']: |
| 197 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 198 | temp = temp + ("ONOS"+str(count),) |
| 199 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 200 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 201 | ctrls.append(temp) |
| 202 | count = count + 1 |
| 203 | else: |
| 204 | break |
| 205 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 206 | global MNTopo |
| 207 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 208 | |
| 209 | |
| 210 | topo_result = main.TRUE |
| 211 | for n in range(1,5): |
| 212 | temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest'])) |
| 213 | topo_result = topo_result and temp_result |
| 214 | print "Topoology check results: " + str(topo_result) |
| 215 | ###End New Topo Check |
| 216 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL") |
| 217 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 218 | main.case("Taking care of these flows!") |
| 219 | main.step("Cleaning out any leftover flows...") |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 220 | intentIP = main.params['CTRL']['ip1'] |
| 221 | intentPort=main.params['INTENTS']['intentPort'] |
| 222 | intentURL=main.params['INTENTS']['intentURL'] |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame] | 223 | #main.ONOS1.delete_flow("all") |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 224 | main.ONOS1.del_intent(intentIP=intentIP) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 225 | time.sleep(5) |
| 226 | strtTime = time.time() |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 227 | main.step("Adding Intents") |
| 228 | count=1 |
| 229 | for i in range(6,16): |
| 230 | srcMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 231 | dstMac = '00:00:00:00:00:'+str(hex(i+10)[2:]) |
| 232 | srcDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2) |
| 233 | dstDPID= '00:00:00:00:00:00:20:' +str(i+25) |
| 234 | main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID, |
| 235 | src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort, |
| 236 | intentURL=intentURL) |
| 237 | count=count +1 |
| 238 | dstDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2) |
| 239 | srcDPID= '00:00:00:00:00:00:20:' +str(i+25) |
| 240 | dstMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 241 | srcMac = '00:00:00:00:00:'+str(hex(i+10)[2:]) |
| 242 | main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID, |
| 243 | src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort, |
| 244 | intentURL=intentURL) |
| 245 | count=count +1 |
| 246 | main.step("Checking flows with pings") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 247 | |
| 248 | pingAttempts = main.params['pingAttempts'] |
| 249 | pingSleep = main.params['pingSleep'] |
| 250 | |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 251 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 252 | count = 1 |
| 253 | i = 6 |
| 254 | while i < 16 : |
| 255 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 256 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 257 | if ping == main.FALSE and count < int(pingAttempts): |
| 258 | count = count + 1 |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 259 | # i = 6 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 260 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
| 261 | time.sleep(int(pingSleep)) |
| 262 | elif ping == main.FALSE and count == int(pingAttempts): |
| 263 | main.log.error("Ping test failed") |
| 264 | i = 17 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 265 | result2 = main.FALSE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 266 | elif ping == main.TRUE: |
| 267 | i = i + 1 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 268 | result2 = main.TRUE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 269 | endTime = time.time() |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 270 | result = result and result2 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 271 | if result == main.TRUE: |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 272 | main.log.report("\n\t\t\t\tTime from pushing intents to successful ping test: "+str(round(endTime-strtTime,2))+" seconds") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 273 | else: |
| 274 | main.log.report("\tFlows failed check") |
| 275 | |
| 276 | main.step("Verifying the result") |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 277 | utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 278 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 279 | |
| 280 | #********************************************************************************************************************************************************************************************** |
| 281 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 282 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 283 | #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. |
| 284 | #If the ping test fails 6 times, then the test case will return false |
| 285 | |
| 286 | def CASE4(self,main) : |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 287 | main.log.report("Assign all switches to just one ONOS instance then ping until all hosts are reachable or fail after 6 attempts") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 288 | import time |
| 289 | import random |
| 290 | |
| 291 | random.seed(None) |
| 292 | |
| 293 | num = random.randint(1,4) |
| 294 | if num == 1: |
| 295 | ip = main.params['CTRL']['ip1'] |
| 296 | port = main.params['CTRL']['port1'] |
| 297 | elif num == 2: |
| 298 | ip = main.params['CTRL']['ip2'] |
| 299 | port = main.params['CTRL']['port2'] |
| 300 | elif num == 3: |
| 301 | ip = main.params['CTRL']['ip3'] |
| 302 | port = main.params['CTRL']['port3'] |
| 303 | else: |
| 304 | ip = main.params['CTRL']['ip4'] |
| 305 | port = main.params['CTRL']['port4'] |
| 306 | |
| 307 | main.log.report("ONOS"+str(num)+" will be the sole controller") |
| 308 | for i in range(25): |
| 309 | if i < 15: |
| 310 | j=i+1 |
| 311 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) #Assigning a single controller removes all other controllers |
| 312 | else: |
| 313 | j=i+16 |
| 314 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) |
| 315 | |
| 316 | strtTime = time.time() |
| 317 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 318 | for counter in range(9): |
| 319 | if result == main.FALSE: |
| 320 | time.sleep(3) |
| 321 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 322 | else: |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 323 | main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 324 | main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 325 | main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 326 | break |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 327 | ####New Topo Check |
| 328 | ctrls = [] |
| 329 | count = 1 |
| 330 | while True: |
| 331 | temp = () |
| 332 | if ('ip' + str(count)) in main.params['CTRL']: |
| 333 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 334 | temp = temp + ("ONOS"+str(count),) |
| 335 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 336 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 337 | ctrls.append(temp) |
| 338 | count = count + 1 |
| 339 | else: |
| 340 | break |
| 341 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 342 | global MNTopo |
| 343 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 344 | |
| 345 | |
| 346 | topo_result = main.TRUE |
| 347 | for n in range(1,5): |
| 348 | temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest'])) |
| 349 | topo_result = topo_result and temp_result |
| 350 | print "Topoology check results: " + str(topo_result) |
| 351 | ###End New Topo Check |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 352 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 353 | |
| 354 | pingAttempts = main.params['pingAttempts'] |
| 355 | pingSleep = main.params['pingSleep'] |
| 356 | |
| 357 | count = 1 |
| 358 | i = 6 |
| 359 | while i < 16 : |
| 360 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 361 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 362 | if ping == main.FALSE and count < int(pingAttempts): |
| 363 | count = count + 1 |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 364 | # i = 6 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 365 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
| 366 | time.sleep(int(pingSleep)) |
| 367 | elif ping == main.FALSE and count == int(pingAttempts): |
| 368 | main.log.error("Ping test failed") |
| 369 | i = 17 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 370 | result2 = main.FALSE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 371 | elif ping == main.TRUE: |
| 372 | i = i + 1 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 373 | result2 = main.TRUE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 374 | endTime = time.time() |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 375 | result = result and result2 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 376 | if result == main.TRUE: |
| 377 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 378 | else: |
| 379 | main.log.report("\tPING TEST FAIL") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 380 | main.ONOS1.show_intent(main.params['RestIP']) |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 381 | utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 382 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 383 | |
| 384 | # ********************************************************************************************************************************************************************************************** |
| 385 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 386 | |
| 387 | def CASE5(self,main) : |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 388 | main.log.report("Restore switch assignments to all 4 ONOS instances then ping until all hosts are reachable or fail after 6 attempts") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 389 | import time |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 390 | |
| 391 | #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute |
| 392 | time.sleep(10) |
| 393 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 394 | for i in range(25): |
| 395 | if i < 15: |
| 396 | j=i+1 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 397 | 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']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 398 | else: |
| 399 | j=i+16 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 400 | 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']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 401 | |
| 402 | strtTime = time.time() |
| 403 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 404 | for counter in range(9): |
| 405 | if result == main.FALSE: |
| 406 | time.sleep(3) |
| 407 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 408 | else: |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 409 | main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 410 | main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 411 | main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 412 | break |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 413 | ####New Topo Check |
| 414 | ctrls = [] |
| 415 | count = 1 |
| 416 | while True: |
| 417 | temp = () |
| 418 | if ('ip' + str(count)) in main.params['CTRL']: |
| 419 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 420 | temp = temp + ("ONOS"+str(count),) |
| 421 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 422 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 423 | ctrls.append(temp) |
| 424 | count = count + 1 |
| 425 | else: |
| 426 | break |
| 427 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 428 | global MNTopo |
| 429 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 430 | |
| 431 | |
| 432 | topo_result = main.TRUE |
| 433 | for n in range(1,5): |
| 434 | temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest'])) |
| 435 | topo_result = topo_result and temp_result |
| 436 | print "Topoology check results: " + str(topo_result) |
| 437 | ###End New Topo Check |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 438 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 439 | |
| 440 | pingAttempts = main.params['pingAttempts'] |
| 441 | pingSleep = main.params['pingSleep'] |
| 442 | |
| 443 | count = 1 |
| 444 | i = 6 |
| 445 | while i < 16 : |
| 446 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 447 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 448 | if ping == main.FALSE and count < int(pingAttempts): |
| 449 | count = count + 1 |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 450 | # i = 6 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 451 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
| 452 | time.sleep(int(pingSleep)) |
| 453 | elif ping == main.FALSE and count == int(pingAttempts): |
| 454 | main.log.error("Ping test failed") |
| 455 | i = 17 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 456 | result2 = main.FALSE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 457 | elif ping == main.TRUE: |
| 458 | i = i + 1 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 459 | result2 = main.TRUE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 460 | endTime = time.time() |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 461 | result = result and result2 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 462 | if result == main.TRUE: |
| 463 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 464 | else: |
| 465 | main.log.report("\tPING TEST FAILED") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 466 | main.ONOS1.show_intent(main.params['RestIP']) |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 467 | utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 468 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 469 | |
| 470 | # ********************************************************************************************************************************************************************************************** |
| 471 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 472 | |
| 473 | def CASE6(self,main) : |
| 474 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
| 475 | import time |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 476 | |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 477 | #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute |
| 478 | time.sleep(10) |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 479 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 480 | main.case("Bringing Link down... ") |
| 481 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 482 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 483 | |
| 484 | strtTime = time.time() |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 485 | result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 486 | for counter in range(9): |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 487 | if result1 == main.FALSE: |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 488 | time.sleep(3) |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 489 | result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 490 | else: |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 491 | main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 492 | main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 493 | main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 494 | break |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 495 | ####New Topo Check |
| 496 | ctrls = [] |
| 497 | count = 1 |
| 498 | while True: |
| 499 | temp = () |
| 500 | if ('ip' + str(count)) in main.params['CTRL']: |
| 501 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 502 | temp = temp + ("ONOS"+str(count),) |
| 503 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 504 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 505 | ctrls.append(temp) |
| 506 | count = count + 1 |
| 507 | else: |
| 508 | break |
| 509 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 510 | global MNTopo |
| 511 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 512 | |
| 513 | |
| 514 | topo_result = main.TRUE |
| 515 | for n in range(1,5): |
| 516 | temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest'])) |
| 517 | topo_result = topo_result and temp_result |
| 518 | print "Topoology check results: " + str(topo_result) |
| 519 | ###End New Topo Check |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 520 | utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 521 | |
| 522 | pingAttempts = main.params['pingAttempts'] |
| 523 | pingSleep = main.params['pingSleep'] |
| 524 | |
| 525 | count = 1 |
| 526 | i = 6 |
| 527 | while i < 16 : |
| 528 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 529 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 530 | if ping == main.FALSE and count < int(pingAttempts): |
| 531 | count = count + 1 |
| 532 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame] | 533 | #i = 6 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 534 | time.sleep(int(pingSleep)) |
| 535 | elif ping == main.FALSE and count == int(pingAttempts): |
| 536 | main.log.error("Ping test failed") |
| 537 | i = 17 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 538 | result2 = main.FALSE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 539 | elif ping == main.TRUE: |
| 540 | i = i + 1 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 541 | result2 = main.TRUE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 542 | endTime = time.time() |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 543 | result = result and result2 and result1 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 544 | if result == main.TRUE: |
| 545 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 546 | else: |
| 547 | main.log.report("\tPING TEST FAILED") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 548 | main.ONOS1.show_intent(main.params['RestIP']) |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 549 | utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 550 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 551 | |
| 552 | # ********************************************************************************************************************************************************************************************** |
| 553 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 554 | |
| 555 | def CASE7(self,main) : |
| 556 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 557 | import time |
| 558 | main.case("Bringing Link up... ") |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 559 | |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 560 | #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute |
| 561 | time.sleep(10) |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 562 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 563 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 564 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
| 565 | |
| 566 | strtTime = time.time() |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 567 | result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 568 | for counter in range(9): |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 569 | if result1 == main.FALSE: |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 570 | time.sleep(3) |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 571 | result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 572 | else: |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 573 | main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 574 | main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 575 | main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 576 | break |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 577 | ####New Topo Check |
| 578 | ctrls = [] |
| 579 | count = 1 |
| 580 | while True: |
| 581 | temp = () |
| 582 | if ('ip' + str(count)) in main.params['CTRL']: |
| 583 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 584 | temp = temp + ("ONOS"+str(count),) |
| 585 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 586 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 587 | ctrls.append(temp) |
| 588 | count = count + 1 |
| 589 | else: |
| 590 | break |
| 591 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 592 | global MNTopo |
| 593 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 594 | |
| 595 | |
| 596 | topo_result = main.TRUE |
| 597 | for n in range(1,5): |
| 598 | temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest'])) |
| 599 | topo_result = topo_result and temp_result |
| 600 | print "Topoology check results: " + str(topo_result) |
| 601 | ###End New Topo Check |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 602 | utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 603 | |
| 604 | pingAttempts = main.params['pingAttempts'] |
| 605 | pingSleep = main.params['pingSleep'] |
| 606 | |
| 607 | strtTime = time.time() |
| 608 | count = 1 |
| 609 | i = 6 |
| 610 | while i < 16 : |
| 611 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 612 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 613 | if ping == main.FALSE and count < int(pingAttempts): |
| 614 | count = count + 1 |
| 615 | main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds") |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 616 | #i = 6 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 617 | time.sleep(int(pingSleep)) |
| 618 | elif ping == main.FALSE and count == int(pingAttempts): |
| 619 | main.log.error("Ping test failed") |
| 620 | i = 17 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 621 | result2 = main.FALSE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 622 | elif ping == main.TRUE: |
| 623 | i = i + 1 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 624 | result2 = main.TRUE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 625 | endTime = time.time() |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 626 | result = result and result2 and result1 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 627 | if result == main.TRUE: |
| 628 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 629 | else: |
| 630 | main.log.report("\tPING TESTS FAILED") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 631 | main.ONOS1.show_intent(main.params['RestIP']) |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 632 | |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 633 | print main.ONOS1.check_exceptions() |
| 634 | print main.ONOS2.check_exceptions() |
| 635 | print main.ONOS3.check_exceptions() |
| 636 | print main.ONOS4.check_exceptions() |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 637 | |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 638 | utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 639 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed") |
| 640 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 641 | |
Jon Hall | f794798 | 2014-05-22 10:44:45 -0700 | [diff] [blame] | 642 | # ********************************************************************************************************************************************************************************************** |
| 643 | # Runs reactive ping test |
| 644 | def CASE8(self,main) : |
| 645 | main.log.report("Reactive flow ping test:ping until the routes are active or fail after 10 attempts") |
| 646 | import time |
| 647 | |
| 648 | strtTime = time.time() |
| 649 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 650 | for counter in range(9): |
| 651 | if result == main.FALSE: |
| 652 | time.sleep(3) |
| 653 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 654 | else: |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 655 | main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 656 | main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 657 | main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
Jon Hall | f794798 | 2014-05-22 10:44:45 -0700 | [diff] [blame] | 658 | break |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 659 | ####New Topo Check |
| 660 | ctrls = [] |
| 661 | count = 1 |
| 662 | while True: |
| 663 | temp = () |
| 664 | if ('ip' + str(count)) in main.params['CTRL']: |
| 665 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 666 | temp = temp + ("ONOS"+str(count),) |
| 667 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 668 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 669 | ctrls.append(temp) |
| 670 | count = count + 1 |
| 671 | else: |
| 672 | break |
| 673 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 674 | global MNTopo |
| 675 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 676 | |
| 677 | |
| 678 | topo_result = main.TRUE |
| 679 | for n in range(1,5): |
| 680 | temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest'])) |
| 681 | topo_result = topo_result and temp_result |
| 682 | print "Topoology check results: " + str(topo_result) |
| 683 | ###End New Topo Check |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 684 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL") |
Jon Hall | f794798 | 2014-05-22 10:44:45 -0700 | [diff] [blame] | 685 | |
| 686 | pingAttempts = main.params['pingAttempts'] |
| 687 | pingSleep = main.params['pingSleep'] |
| 688 | |
| 689 | strtTime = time.time() |
| 690 | count = 1 |
| 691 | i = 6 |
| 692 | while i < 16 : |
| 693 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) ) |
| 694 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i)) |
| 695 | if ping == main.FALSE and count < int(pingAttempts): |
| 696 | count = count + 1 |
| 697 | main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds") |
| 698 | #i = 6 |
| 699 | time.sleep(int(pingSleep)) |
| 700 | elif ping == main.FALSE and count == int(pingAttempts): |
| 701 | main.log.error("Ping test failed") |
| 702 | i = 17 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 703 | result2 = main.FALSE |
Jon Hall | f794798 | 2014-05-22 10:44:45 -0700 | [diff] [blame] | 704 | elif ping == main.TRUE: |
| 705 | i = i + 1 |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 706 | result2 = main.TRUE |
Jon Hall | f794798 | 2014-05-22 10:44:45 -0700 | [diff] [blame] | 707 | endTime = time.time() |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 708 | result = result and result2 |
Jon Hall | f794798 | 2014-05-22 10:44:45 -0700 | [diff] [blame] | 709 | if result == main.TRUE: |
| 710 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 711 | else: |
| 712 | main.log.report("\tPING TESTS FAILED") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 713 | main.ONOS1.show_intent(main.params['RestIP']) |
Jon Hall | f794798 | 2014-05-22 10:44:45 -0700 | [diff] [blame] | 714 | |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 715 | print main.ONOS1.check_exceptions() |
| 716 | print main.ONOS2.check_exceptions() |
| 717 | print main.ONOS3.check_exceptions() |
| 718 | print main.ONOS4.check_exceptions() |
| 719 | |
| 720 | utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 721 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed") |
| 722 | # ********************************************************************************************************************************************************************************************** |
| 723 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 724 | # This is the same as case 6, but specifically for the reactive tests |
| 725 | |
| 726 | def CASE61(self,main) : |
| 727 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
| 728 | import time |
| 729 | |
| 730 | #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute |
| 731 | time.sleep(10) |
| 732 | |
| 733 | main.case("Bringing Link down... ") |
| 734 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 735 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 736 | |
| 737 | strtTime = time.time() |
| 738 | result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 739 | for counter in range(9): |
| 740 | if result1 == main.FALSE: |
| 741 | time.sleep(3) |
| 742 | result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 743 | else: |
| 744 | main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 745 | main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 746 | main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 747 | break |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 748 | ####New Topo Check |
| 749 | ctrls = [] |
| 750 | count = 1 |
| 751 | while True: |
| 752 | temp = () |
| 753 | if ('ip' + str(count)) in main.params['CTRL']: |
| 754 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 755 | temp = temp + ("ONOS"+str(count),) |
| 756 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 757 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 758 | ctrls.append(temp) |
| 759 | count = count + 1 |
| 760 | else: |
| 761 | break |
| 762 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 763 | global MNTopo |
| 764 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 765 | |
| 766 | |
| 767 | topo_result = main.TRUE |
| 768 | for n in range(1,5): |
| 769 | temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest'])) |
| 770 | topo_result = topo_result and temp_result |
| 771 | print "Topoology check results: " + str(topo_result) |
| 772 | ###End New Topo Check |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 773 | utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL") |
| 774 | |
| 775 | pingAttempts = main.params['pingAttempts'] |
| 776 | pingSleep = main.params['pingSleep'] |
| 777 | |
| 778 | count = 1 |
| 779 | i = 6 |
| 780 | while i < 16 : |
| 781 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) ) |
| 782 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i)) |
| 783 | if ping == main.FALSE and count < int(pingAttempts): |
| 784 | count = count + 1 |
| 785 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
| 786 | #i = 6 |
| 787 | time.sleep(int(pingSleep)) |
| 788 | elif ping == main.FALSE and count == int(pingAttempts): |
| 789 | main.log.error("Ping test failed") |
| 790 | i = 17 |
| 791 | result2 = main.FALSE |
| 792 | elif ping == main.TRUE: |
| 793 | i = i + 1 |
| 794 | result2 = main.TRUE |
| 795 | endTime = time.time() |
| 796 | result = result and result2 and result1 |
| 797 | if result == main.TRUE: |
| 798 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 799 | else: |
| 800 | main.log.report("\tPING TEST FAILED") |
| 801 | main.ONOS1.show_intent(main.params['RestIP']) |
| 802 | utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 803 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed") |
| 804 | |
| 805 | |
| 806 | # ********************************************************************************************************************************************************************************************** |
| 807 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 808 | # Specifically for the Reactive tests |
| 809 | |
| 810 | def CASE71(self,main) : |
| 811 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 812 | import time |
| 813 | main.case("Bringing Link up... ") |
| 814 | |
| 815 | #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute |
| 816 | time.sleep(10) |
| 817 | |
| 818 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 819 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
| 820 | |
| 821 | strtTime = time.time() |
| 822 | result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 823 | for counter in range(9): |
| 824 | if result1 == main.FALSE: |
| 825 | time.sleep(3) |
| 826 | result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 827 | else: |
| 828 | main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 829 | main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 830 | main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 831 | break |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 832 | ####New Topo Check |
| 833 | ctrls = [] |
| 834 | count = 1 |
| 835 | while True: |
| 836 | temp = () |
| 837 | if ('ip' + str(count)) in main.params['CTRL']: |
| 838 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 839 | temp = temp + ("ONOS"+str(count),) |
| 840 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 841 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 842 | ctrls.append(temp) |
| 843 | count = count + 1 |
| 844 | else: |
| 845 | break |
| 846 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 847 | global MNTopo |
| 848 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 849 | |
| 850 | |
| 851 | topo_result = main.TRUE |
| 852 | for n in range(1,5): |
| 853 | temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest'])) |
| 854 | topo_result = topo_result and temp_result |
| 855 | print "Topoology check results: " + str(topo_result) |
| 856 | ###End New Topo Check |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 857 | utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL") |
| 858 | |
| 859 | pingAttempts = main.params['pingAttempts'] |
| 860 | pingSleep = main.params['pingSleep'] |
| 861 | |
| 862 | strtTime = time.time() |
| 863 | count = 1 |
| 864 | i = 6 |
| 865 | while i < 16 : |
| 866 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) ) |
| 867 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i)) |
| 868 | if ping == main.FALSE and count < int(pingAttempts): |
| 869 | count = count + 1 |
| 870 | main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds") |
| 871 | #i = 6 |
| 872 | time.sleep(int(pingSleep)) |
| 873 | elif ping == main.FALSE and count == int(pingAttempts): |
| 874 | main.log.error("Ping test failed") |
| 875 | i = 17 |
| 876 | result2 = main.FALSE |
| 877 | elif ping == main.TRUE: |
| 878 | i = i + 1 |
| 879 | result2 = main.TRUE |
| 880 | endTime = time.time() |
| 881 | result = result and result2 and result1 |
| 882 | if result == main.TRUE: |
| 883 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 884 | else: |
| 885 | main.log.report("\tPING TESTS FAILED") |
| 886 | main.ONOS1.show_intent(main.params['RestIP']) |
| 887 | |
| 888 | print main.ONOS1.check_exceptions() |
| 889 | print main.ONOS2.check_exceptions() |
| 890 | print main.ONOS3.check_exceptions() |
| 891 | print main.ONOS4.check_exceptions() |
Jon Hall | f794798 | 2014-05-22 10:44:45 -0700 | [diff] [blame] | 892 | |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 893 | utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 894 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed") |
Jon Hall | f794798 | 2014-05-22 10:44:45 -0700 | [diff] [blame] | 895 | |
| 896 | |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 897 | |
| 898 | |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 899 | # ****************************************************************************************************************************************************************** |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 900 | # Check for ONOS Components health |
Jon Hall | 670808c | 2014-06-23 16:07:22 -0700 | [diff] [blame] | 901 | |
| 902 | def CASE9(self,main) : |
| 903 | main.case("Checking component status") |
| 904 | result = main.TRUE |
| 905 | |
| 906 | main.step("Checking Zookeeper status") |
| 907 | result1 = main.Zookeeper1.status() |
| 908 | if not result1: |
| 909 | main.log.report("Zookeeper1 encountered a tragic death!") |
| 910 | result2 = main.Zookeeper2.status() |
| 911 | if not result2: |
| 912 | main.log.report("Zookeeper2 encountered a tragic death!") |
| 913 | result3 = main.Zookeeper3.status() |
| 914 | if not result3: |
| 915 | main.log.report("Zookeeper3 encountered a tragic death!") |
| 916 | result4 = main.Zookeeper4.status() |
| 917 | if not result4: |
| 918 | main.log.report("Zookeeper4 encountered a tragic death!") |
| 919 | result = result and result1 and result2 and result3 and result4 |
| 920 | |
| 921 | main.step("Checking RamCloud status") |
| 922 | result5 = main.RamCloud1.status_coor() |
| 923 | if not result5: |
| 924 | main.log.report("RamCloud Coordinator1 encountered a tragic death!") |
| 925 | result6 = main.RamCloud1.status_serv() |
| 926 | if not result6: |
| 927 | main.log.report("RamCloud Server1 encountered a tragic death!") |
| 928 | result7 = main.RamCloud2.status_serv() |
| 929 | if not result7: |
| 930 | main.log.report("RamCloud Server2 encountered a tragic death!") |
| 931 | result8 = main.RamCloud3.status_serv() |
| 932 | if not result8: |
| 933 | main.log.report("RamCloud Server3 encountered a tragic death!") |
| 934 | result9 = main.RamCloud4.status_serv() |
| 935 | if not result9: |
| 936 | main.log.report("RamCloud Server4 encountered a tragic death!") |
| 937 | result = result and result5 and result6 and result7 and result8 and result9 |
| 938 | |
| 939 | |
| 940 | main.step("Checking ONOS status") |
| 941 | result10 = main.ONOS1.status() |
| 942 | if not result10: |
| 943 | main.log.report("ONOS1 core encountered a tragic death!") |
| 944 | result11 = main.ONOS2.status() |
| 945 | if not result11: |
| 946 | main.log.report("ONOS2 core encountered a tragic death!") |
| 947 | result12 = main.ONOS3.status() |
| 948 | if not result12: |
| 949 | main.log.report("ONOS3 core encountered a tragic death!") |
| 950 | result13 = main.ONOS4.status() |
| 951 | if not result13: |
| 952 | main.log.report("ONOS4 core encountered a tragic death!") |
| 953 | result = result and result10 and result11 and result12 and result13 |
| 954 | |
| 955 | |
| 956 | |
| 957 | rest_result = main.ONOS1.rest_status() |
| 958 | if not rest_result: |
| 959 | main.log.report("Simple Rest GUI server is not running on ONOS1") |
| 960 | |
| 961 | |
| 962 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="All Components are running",onfail="One or more components failed") |
Jon Hall | f794798 | 2014-05-22 10:44:45 -0700 | [diff] [blame] | 963 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 964 | # ****************************************************************************************************************************************************************** |
| 965 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 966 | |
| 967 | def CASE21(self,main) : |
| 968 | import json |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 969 | main.log.report("Test device discovery function, by attach, detach, and move host h1 from s1->s6->s1. Per mininet naming, the name of the switch port the host attaches to will remain as 's1-eth1' throughout the test.") |
| 970 | main.log.report("Check initially hostMAC/IP exist on the mininet...") |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 971 | host = main.params['YANK']['hostname'] |
| 972 | mac = main.params['YANK']['hostmac'] |
| 973 | RestIP1 = main.params['RESTCALL']['restIP1'] |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 974 | RestPort = main.params['RESTCALL']['restPort'] |
| 975 | url = main.params['RESTCALL']['restURL'] |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 976 | |
| 977 | t_topowait = 5 |
Jon Hall | 81d3daa | 2014-09-03 14:15:10 -0700 | [diff] [blame] | 978 | t_restwait = 5 |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 979 | main.log.report( "Wait time from topo change to ping set to " + str(t_topowait)) |
| 980 | main.log.report( "Wait time from ping to rest call set to " + str(t_restwait)) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 981 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 982 | time.sleep(t_topowait) |
| 983 | 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" ) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 984 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 985 | time.sleep(t_restwait) |
| 986 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
| 987 | main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus)) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 988 | if Reststatus == 1: |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 989 | main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0])) |
| 990 | result1 = main.TRUE |
| 991 | elif Reststatus > 1: |
| 992 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED") |
| 993 | main.log.report("switches are: " + "; ".join(Switch)) |
| 994 | main.log.report("Ports are: " + "; ".join(Port)) |
| 995 | result1 = main.FALSE |
| 996 | elif Reststatus == 0 and Switch == []: |
| 997 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED") |
| 998 | result1 = main.FALSE |
| 999 | else:# check if rest server is working |
| 1000 | main.log.error("Issue with find host") |
| 1001 | result1 = main.FALSE |
| 1002 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1003 | |
| 1004 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 1005 | |
| 1006 | main.log.report("Yank out s1-eth1") |
| 1007 | main.case("Yankout s6-eth1 (link to h1) from s1") |
| 1008 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1009 | time.sleep(t_topowait) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1010 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1011 | |
| 1012 | 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" ) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1013 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1014 | time.sleep(t_restwait) |
| 1015 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
| 1016 | |
| 1017 | main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus)) |
| 1018 | if Reststatus == 1: |
| 1019 | main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port)) |
| 1020 | result2 = main.FALSE |
| 1021 | elif Reststatus > 1: |
| 1022 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 1023 | main.log.report("switches are: " + "; ".join(Switch)) |
| 1024 | main.log.report("Ports are: " + "; ".join(Port)) |
| 1025 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 1026 | result2 = main.FALSE |
| 1027 | elif Reststatus == 0 and Switch == []: |
| 1028 | 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.") |
| 1029 | result2 = main.TRUE |
| 1030 | else:# check if rest server is working |
| 1031 | main.log.error("Issue with find host") |
| 1032 | result2 = main.FALSE |
| 1033 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1034 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 1035 | main.log.report("Plug s1-eth1 into s6") |
| 1036 | main.case("Plug s1-eth1 to s6") |
| 1037 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1038 | time.sleep(t_topowait) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1039 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1040 | 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" ) |
| 1041 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1042 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1043 | time.sleep(t_restwait) |
| 1044 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
| 1045 | |
| 1046 | main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus)) |
| 1047 | if Reststatus == 1: |
| 1048 | main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0])) |
| 1049 | result3 = main.TRUE |
| 1050 | elif Reststatus > 1: |
| 1051 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 1052 | main.log.report("switches are: " + "; ".join(Switch)) |
| 1053 | main.log.report("Ports are: " + "; ".join(Port)) |
| 1054 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 1055 | result3 = main.FALSE |
| 1056 | elif Reststatus == 0 and Switch == []: |
| 1057 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 1058 | result3 = main.FALSE |
| 1059 | else:# check if rest server is working |
| 1060 | main.log.error("Issue with find host") |
| 1061 | result3 = main.FALSE |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1062 | |
| 1063 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 1064 | main.log.report("Move s1-eth1 back on to s1") |
| 1065 | main.case("Move s1-eth1 back to s1") |
| 1066 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1067 | time.sleep(t_topowait) |
| 1068 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1069 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1070 | 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" ) |
| 1071 | |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1072 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1073 | time.sleep(t_restwait) |
| 1074 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1075 | |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1076 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 1077 | if Reststatus == 1: |
| 1078 | main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0])) |
| 1079 | result4 = main.TRUE |
| 1080 | elif Reststatus > 1: |
| 1081 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED") |
| 1082 | main.log.report("switches are: " + "; ".join(Switch)) |
| 1083 | main.log.report("Ports are: " + "; ".join(Port)) |
| 1084 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 1085 | result4 = main.FALSE |
| 1086 | elif Reststatus == 0 and Switch == []: |
| 1087 | main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 1088 | result4 = main.FALSE |
| 1089 | else:# check if rest server is working |
| 1090 | main.log.error("Issue with find host") |
| 1091 | result4 = main.FALSE |
| 1092 | time.sleep(20) |
| 1093 | Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac) |
| 1094 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 1095 | if Reststatus ==1: |
| 1096 | main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout") |
| 1097 | elif Reststatus>1: |
| 1098 | main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)") |
| 1099 | elif Reststatus==0: |
| 1100 | main.log.report("\t PASSED - Device cleared after timeout") |
| 1101 | |
| 1102 | result = result1 and result2 and result3 and result4 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1103 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 1104 | |