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