Merge branch 'master' of https://github.com/OPENNETWORKINGLAB/ONLabTest
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index e8f6caa..f049074 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -189,7 +189,6 @@
'''
Verifies the host's ip configured or not.
'''
- self.handle.sendline("")
if self.handle :
try:
response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10)
@@ -319,6 +318,23 @@
else:
main.log.error("Connection failed to the host")
+ def getDPID(self, switch):
+ if self.handle:
+ self.handle.sendline("")
+ self.expect("mininet>")
+ cmd = "py %s.dpid" %switch
+ try:
+ response = self.execute(cmd=cmd,prompt="mininet>",timeout=10)
+ self.handle.expect("mininet>")
+ response = self.handle.before
+ return response
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ main.cleanup()
+ main.exit()
+
+
def getInterfaces(self, node):
'''
return information dict about interfaces connected to the node
@@ -531,7 +547,6 @@
def get_sw_controller(self,sw):
command = "sh ovs-vsctl get-controller "+str(sw)
try:
- self.handle.expect("mininet")
response = self.execute(cmd=command,prompt="mininet>",timeout=10)
print(response)
if response:
@@ -733,7 +748,147 @@
main.cleanup()
main.exit()
+ def compare_topo(self, onos_list, onos_json):
+ '''
+ compares mn topology with ONOS topology
+ onos_list is a list of ONOS controllers, each element of the list should be (handle, name, ip, port)
+ onos_json is the output of the onos get_json function calling the /wm/onos/topology REST API
+ Returns: True if MN and ONOS topology match and False if the differ.
+ Differences between ONOS and MN topology will be printed to the log.
+ Dependency: Requires STS to be installed on the TestON machine. STS can be pulled
+ from https://github.com/ucb-sts/sts.git . Currently the required functions from STS are located in the
+ topology_refactoring2 branch, but may be merged into the master branch soon. You may need to install some
+ python modules such as networkx to use the STS functions.
+
+ '''
+ from sts.topology.teston_topology import TestONTopology # assumes that sts already in you PYTHONPATH
+ #import sts.entities.base as base
+ import json
+ topo = TestONTopology(self, onos_list)
+
+ link_results = main.TRUE
+ switch_results = main.TRUE
+ port_results = main.TRUE
+
+ ########Switches#######
+ output = {"switches":[]}
+ for switch in topo.graph.switches: #iterate through the MN topology and pull out switches and and port info
+ ports = []
+ for port in switch.ports.values():
+ ports.append({'of_port': port.port_no, 'mac': port.hw_addr.replace('\'',''), 'name': port.name})
+ output['switches'].append({"name": switch.name, "dpid": switch.dpid, "ports": ports })
+ #print output
+
+ #print json.dumps(output, sort_keys=True,indent=4,separators=(',', ': '))
+
+
+ # created sorted list of dpid's in MN and ONOS for comparison
+ mnDPIDs=[]
+ for switch in output['switches']:
+ mnDPIDs.append(switch['dpid'])
+ mnDPIDs.sort()
+ #print mnDPIDs
+ if onos_json == "":#if rest call fails
+ main.log.error(self.name + ".compare_topo(): Empty JSON object given from ONOS rest call")
+ return main.FALSE
+ onos=onos_json
+ onosDPIDs=[]
+ for switch in onos['switches']:
+ onosDPIDs.append(switch['dpid'].replace(":",''))
+ onosDPIDs.sort()
+ #print onosDPIDs
+
+ if mnDPIDs!=onosDPIDs:
+ switch_results = main.FALSE
+ main.log.report( "Switches in MN but not in ONOS:")
+ main.log.report( str([switch for switch in mnDPIDs if switch not in onosDPIDs]))
+ main.log.report( "Switches in ONOS but not in MN:")
+ main.log.report( str([switch for switch in onosDPIDs if switch not in mnDPIDs]))
+ else:#list of dpid's match in onos and mn
+ switch_results = main.TRUE
+
+ ################ports#############
+ for switch in output['switches']:
+ mn_ports = []
+ onos_ports = []
+ for port in switch['ports']:
+ mn_ports.append(port['of_port'])
+ for onos_switch in onos['switches']:
+ if onos_switch['dpid'].replace(':','') == switch['dpid']:
+ for port in onos_switch['ports']:
+ onos_ports.append(port['portNumber'])
+ mn_ports.sort()
+ onos_ports.sort()
+ if mn_ports == onos_ports:
+ pass #don't set results to true here as this is just one of many checks and it might override a failure
+ else: #the ports of this switch don't match
+ port_results = main.FALSE
+ main.log.report("ports in MN switch %s(%s) but not in ONOS:" % (switch['name'],switch['dpid']))
+ main.log.report( str([port for port in mn_ports if port not in onos_ports]))
+ main.log.report("ports in ONOS switch %s(%s) but not in MN:" % (switch['name'],switch['dpid']))
+ main.log.report( str([port for port in onos_ports if port not in mn_ports]))
+
+
+ #######Links########
+ # iterate through MN links and check if and ONOS link exists in both directions
+ for link in topo.patch_panel.network_links:
+ #print "Link: %s" % link
+ #TODO: Find a more efficient search method
+ node1 = None
+ port1 = None
+ node2 = None
+ port2 = None
+ first_dir = main.FALSE
+ second_dir = main.FALSE
+ for switch in output['switches']:
+ if switch['name'] == link.node1.name:
+ node1 = switch['dpid']
+ for port in switch['ports']:
+ if str(port['name']) == str(link.port1):
+ port1 = port['of_port']
+ if node1 is not None and node2 is not None:
+ break
+ if switch['name'] == link.node2.name:
+ node2 = switch['dpid']
+ for port in switch['ports']:
+ if str(port['name']) == str(link.port2):
+ port2 = port['of_port']
+ if node1 is not None and node2 is not None:
+ break
+ # check onos link from node1 to node2
+ for onos_link in onos['links']:
+ if onos_link['src']['dpid'].replace(":",'') == node1 and onos_link['dst']['dpid'].replace(":",'') == node2:
+ if onos_link['src']['portNumber'] == port1 and onos_link['dst']['portNumber'] == port2:
+ first_dir = main.TRUE
+ else:
+ main.log.report('the port numbers do not match for ' +str(link) + ' between ONOS and MN')
+ #print node1, ' to ', node2
+ elif onos_link['src']['dpid'].replace(":",'') == node2 and onos_link['dst']['dpid'].replace(":",'') == node1:
+ if onos_link['src']['portNumber'] == port2 and onos_link['dst']['portNumber'] == port1:
+ second_dir = main.TRUE
+ else:
+ main.log.report('the port numbers do not match for ' +str(link) + ' between ONOS and MN')
+ #print node2, ' to ', node1
+ else:#this is not the link you're looking for
+ pass
+ if not first_dir:
+ main.log.report('ONOS has issues with the link from '+str(link.node1.name) +"(dpid: "+ str(node1)+"):"+str(link.port1)+"(portNumber: "+str(port1)+")"+ ' to ' + str(link.node2.name) +"(dpid: "+ str(node2)+"):"+str(link.port2)+"(portNumber: "+str(port2)+")")
+ if not second_dir:
+ main.log.report('ONOS has issues with the link from '+str(link.node2.name) +"(dpid: "+ str(node2)+"):"+str(link.port2)+"(portNumber: "+str(port2)+")"+ ' to ' + str(link.node1.name) +"(dpid: "+ str(node1)+"):"+str(link.port1)+"(portNumber: "+str(port1)+")")
+ link_results = link_results and first_dir and second_dir
+
+
+ results = switch_results and port_results and link_results
+ '''
+ if not results: #To print out both topologies
+ main.log.error("Topology comparison failed, printing json objects, MN then ONOS")
+ main.log.error(str(json.dumps(output, sort_keys=True,indent=4,separators=(',', ': '))))
+ main.log.error('MN Links:')
+ for link in topo.patch_panel.network_links: main.log.error(str("\tLink: %s" % link))
+ main.log.error(str(json.dumps(onos, sort_keys=True,indent=4,separators=(',', ': '))))
+ '''
+ return results
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index f528fe7..7aaec91 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -74,15 +74,18 @@
#*********************************************************************************************
#*********************************************************************************************
- def checkForLoss(self, fileName):
+ def checkForLoss(self, pingList):
import os
- if os.stat(fileName)[6]==0:
- return main.TRUE
- pingFile= open(fileName,'r')
- pingList = pingFile.read()
-
- if re.search("0% packet loss",pingList):
+ self.handle.sendline("")
+ self.handle.expect("\$")
+ self.handle.sendline("cat " + pingList)
+ self.handle.expect(pingList)
+ self.handle.expect("\$")
+ outputs = self.handle.before + self.handle.after
+ if re.search(" 0% packet loss",outputs):
return main.FALSE
+ elif re.search("found multiple mininet",outputs):
+ return main.ERROR
return main.TRUE
@@ -123,7 +126,7 @@
Then copies all the ping files to the TestStation.
'''
import time
- command = "sudo pkill ping"
+ command = "sudo kill -SIGINT `pgrep ping`"
main.log.info( command )
self.execute(cmd=command,prompt="(.*)",timeout=10)
main.log.info( "Removing old ping data" )
@@ -133,6 +136,14 @@
main.log.info( "Transferring ping files to TestStation" )
command = "scp /tmp/ping.* admin@10.128.7.7:/tmp/"
self.execute(cmd=command,prompt="100%",timeout=20)
+ print("finished kill")
+ return main.TRUE
+
+ def pingLongKill(self):
+ import time
+ command = "sudo kill -SIGING `pgrep ping`"
+ main.log.info(command)
+ self.execute(cmd=command,prompt="(.*)",timeout=10)
return main.TRUE
def pingHost(self,**pingParams):
diff --git a/TestON/drivers/common/cli/zookeeperclidriver.py b/TestON/drivers/common/cli/zookeeperclidriver.py
index 79f06ee..2a7c218 100644
--- a/TestON/drivers/common/cli/zookeeperclidriver.py
+++ b/TestON/drivers/common/cli/zookeeperclidriver.py
@@ -151,7 +151,7 @@
k4 = k3[1].split()
k5 = k4[1].split('"')
return k5[1]
- return "NO SWITCH FOUND"
+ return "NO CONTROLLERS FOUND"
def isup(self):
'''
diff --git a/TestON/tests/HATest1/HATest1.params b/TestON/tests/HATest1/HATest1.params
index dfda24b..7ccd409 100644
--- a/TestON/tests/HATest1/HATest1.params
+++ b/TestON/tests/HATest1/HATest1.params
@@ -1,15 +1,50 @@
<PARAMS>
- <testcases>2,3</testcases>
+ <testcases>2,3,4,5,6</testcases>
<CTRL>
<ip1>10.128.9.1</ip1>
- <ip2>10.128.9.2</ip2>
- <ip3>10.128.9.3</ip3>
- <ip4>10.128.9.4</ip4>
- <ip5>10.128.9.5</ip5>
<port1>6633</port1>
+ <restPort1>8080</restPort1>
+ <ip2>10.128.9.2</ip2>
+ <port2>6633</port2>
+ <restPort2>8080</restPort2>
+ <ip3>10.128.9.3</ip3>
+ <port3>6633</port3>
+ <restPort3>8080</restPort3>
+ <ip4>10.128.9.4</ip4>
+ <port4>6633</port4>
+ <restPort4>8080</restPort4>
+ <ip5>10.128.9.5</ip5>
+ <port5>6633</port5>
+ <restPort5>8080</restPort5>
+ <switchURL>/wm/onos/registry/switches/json</switchURL>
+ <intentHighURL>/wm/onos/intent/high</intentHighURL>
+ <intentLowURL>/wm/onos/intent/log</intentLowURL>
</CTRL>
+ <TopoRest>/wm/onos/topology</TopoRest>
<INTENTS>
<intentPort>8080</intentPort>
<intentURL>wm/onos/intent</intentURL>
</INTENTS>
+ <PING>
+ <source1>h8</source1>
+ <source2>h9</source2>
+ <source3>h10</source3>
+ <source4>h11</source4>
+ <source5>h12</source5>
+ <source6>h13</source6>
+ <source7>h14</source7>
+ <source8>h15</source8>
+ <source9>h16</source9>
+ <source10>h17</source10>
+ <target1>10.0.0.18</target1>
+ <target2>10.0.0.19</target2>
+ <target3>10.0.0.20</target3>
+ <target4>10.0.0.21</target4>
+ <target5>10.0.0.22</target5>
+ <target6>10.0.0.23</target6>
+ <target7>10.0.0.24</target7>
+ <target8>10.0.0.25</target8>
+ <target9>10.0.0.26</target9>
+ <target10>10.0.0.27</target10>
+ </PING>
</PARAMS>
diff --git a/TestON/tests/HATest1/HATest1.py b/TestON/tests/HATest1/HATest1.py
index 61b7c29..91d5b96 100644
--- a/TestON/tests/HATest1/HATest1.py
+++ b/TestON/tests/HATest1/HATest1.py
@@ -1,7 +1,11 @@
class HATest1:
-
+ global topology
+ global masterSwitchList
+ global highIntentList
+ global lowIntentList
+ global flowTable
def __init__(self) :
self.default = ''
@@ -69,13 +73,13 @@
if i ==1:
main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
elif i>=2 and i<5:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port1'])
+ main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
elif i>=5 and i<8:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port1'])
+ main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
elif i>=8 and i<18:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port1'])
+ main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
elif i>=18 and i<28:
- main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip5'],port1=main.params['CTRL']['port1'])
+ main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip5'],port1=main.params['CTRL']['port5'])
else:
main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
@@ -124,7 +128,6 @@
else:
result = main.FALSE
utilities.assert_equals(expect = main.TRUE,actual=result,onpass="MasterControllers assigned correctly")
- time.sleep(30)
def CASE3(self,main) :
import time
@@ -148,7 +151,6 @@
srcMac = '00:00:00:00:00:'+str(hex(i+10)[2:])
main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID,src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,intentURL=intentURL)
count+=1
- time.sleep(400)
count = 1
i = 8
result = main.TRUE
@@ -179,8 +181,113 @@
def CASE4(self,main) :
+ import time
+ from subprocess import Popen, PIPE
main.case("Setting up and Gathering data for current state")
+ main.step("Get the current In-Memory Topology on each ONOS Instance")
+ ctrls = []
+ count = 1
+ while True:
+ temp = ()
+ if ('ip'+str(count)) in main.params['CTRL']:
+ temp = temp+(getattr(main,('ONOS'+str(count))),)
+ temp = temp + ("ONOS"+str(count),)
+ temp = temp + (main.params['CTRL']['ip'+str(count)],)
+ temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+ ctrls.append(temp)
+ count+=1
+ else:
+ break
+ topo_result = main.TRUE
+ for n in range(1,count):
+ temp_result = main.Mininet1.compare_topo(ctrls,main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
+
+ main.step("Get the Mastership of each switch")
+ (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['apiPort']+main.params['CTRL']['switchURL']],stdout=PIPE).communicate()
+ global masterSwitchList1
+ masterSwitchList1 = stdout
+
+ main.step("Get the High Level Intents")
+ (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['apiPort']+main.params['CTRL']['intentHighURL']],stdout=PIPE).communicate()
+ global highIntentList1
+ highIntentList1 = stdout
+ main.step("Get the Low level Intents")
+ (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['apiPort']+main.params['CTRL']['intentLowURL']],stdout=PIPE).communicate()
+ global lowIntentList1
+ lowIntentList1= stdout
+
+ main.step("Get the OF Table entries")
+
+ main.step("Start continuous pings")
+ main.Mininet2.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'],pingTime=500)
+
+
+ def CASE5(self,main) :
+ main.case("MAIN COMPONENT FAILURE AND SCENARIO SPECIFIC TESTS")
+
+
+ def CASE6(self,main) :
+ import os
+ main.case("Running ONOS Constant State Tests")
+ main.step("Get the current In-Memory Topology on each ONOS Instance and Compare it to the Topology before component failure")
+
+ main.step("Get the Mastership of each switch and compare to the Mastership before component failure")
+ (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['apiPort']+main.params['CTRL']['switchURL']],stdout=PIPE).communicate()
+ result = main.TRUE
+ for i in range(1,28):
+ if main.ZK1.findMaster(switchDPID="s"+str(i),switchList=masterSwitchList1)==main.ZK1.findMaster(switchDPID="s"+str(i),switchList=stdout):
+ result = result and main.TRUE
+ else:
+ result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Mastership of Switches was not changed",onfail="MASTERSHIP OF SWITCHES HAS CHANGED!!!")
+
+ main.step("Get the High Level Intents and compare to before component failure")
+ (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['apiPort']+main.params['CTRL']['intentHighURL']],stdout=PIPE).communicate()
+ changesInIntents=main.ONOS1.comp_intents(preIntents=highIntentList1,postIntents=stdout)
+ if not changesInIntents:
+ result = main.TRUE
+ else:
+ main.log.info("THERE WERE CHANGES TO THE HIGH LEVEL INTENTS! CHANGES WERE: "+str(changesInIntents))
+ result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No changes to High level Intents",onfail="CHANGES WERE MADE TO HIGH LEVEL INTENTS")
+
+ main.step("Get the Low level Intents and compare to before component failure")
+ (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['apiPort']+main.params['CTRL']['intentLowURL']],stdout=PIPE).communicate()
+ changesInIntents=main.ONOS1.comp_low(preIntents=lowIntentList1,postIntents=stdout)
+ if not changesInIntents:
+ result = main.TRUE
+ else:
+ main.log.info("THERE WERE CHANGES TO THE LOW LEVEL INTENTS! CHANGES WERE: "+str(changesInIntents))
+ result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No changes to Low level Intents",onfail="CHANGES WERE MADE TO LOW LEVEL INTENTS")
+
+
+ main.step("Get the OF Table entries and compare to before component failure")
+
+ main.step("Check the continuous pings to ensure that no packets were dropped during component failure")
+ main.Mininet2.pingKill()
+ result = main.FALSE
+ for i in range(8,18):
+ result = result or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
+ if result==main.TRUE:
+ main.log.info("LOSS IN THE PINGS!")
+ elif result == main.ERROR:
+ main.log.info("There are multiple mininet process running!!")
+ else:
+ main.log.info("No Loss in the pings!")
+ utilities.assert_equals(expect=main.FALSE,actual=result,onpass="No Loss of connectivity!",onfail="LOSS OF CONNECTIVITY")
+
+
diff --git a/TestON/tests/RCOnosPerf4nodes/RCOnosPerf4nodes.py b/TestON/tests/RCOnosPerf4nodes/RCOnosPerf4nodes.py
index 38a754e..32a6601 100644
--- a/TestON/tests/RCOnosPerf4nodes/RCOnosPerf4nodes.py
+++ b/TestON/tests/RCOnosPerf4nodes/RCOnosPerf4nodes.py
@@ -27,7 +27,7 @@
main.RamCloud3.del_db()
main.RamCloud4.del_db()
main.step("Start tcpdump on mn")
- main.Mininet1.start_tcpdump(main.params['tcpdump']['filename'], intf = main.params['tcpdump']['intf'], port = main.params['tcpdump']['port'])
+ main.Mininet2.start_tcpdump(main.params['tcpdump']['filename'], intf = main.params['tcpdump']['intf'], port = main.params['tcpdump']['port'])
# main.step("Start tcpdump on mn")
# main.Mininet1.start_tcpdump(main.params['tcpdump']['filename'], intf = main.params['tcpdump']['intf'], port = main.params['tcpdump']['port'])
main.step("Starting ONOS")
@@ -266,16 +266,16 @@
import time
import os
main.case("Starting long ping... ")
- main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
- main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'])
- main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'])
- main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'])
- main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'])
- main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'])
- main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'])
- main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'])
- main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'])
- main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'])
+ main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'], pingTime = 100)
main.step("Check that the pings are going")
result = main.Mininet4.pingstatus(src=main.params['PING']['source1'])
result = result & main.Mininet4.pingstatus(src=main.params['PING']['source2'])
@@ -339,16 +339,16 @@
import os
time.sleep(20)
main.case("Starting long ping... ")
- main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
- main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'])
- main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'])
- main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'])
- main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'])
- main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'])
- main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'])
- main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'])
- main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'])
- main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'])
+ main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'], pingTime = 100)
main.step("Check that the pings are going")
result = main.Mininet4.pingstatus(src=main.params['PING']['source1'])
result = result & main.Mininet4.pingstatus(src=main.params['PING']['source2'])
@@ -396,16 +396,16 @@
time.sleep(20)
main.case("Starting long ping... ")
- main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
- main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'])
- main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'])
- main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'])
- main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'])
- main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'])
- main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'])
- main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'])
- main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'])
- main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'])
+ main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'], pingTime = 100)
+ main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'], pingTime = 100)
main.step("Check that the pings are going")
result = main.Mininet4.pingstatus(src=main.params['PING']['source1'])
result = result & main.Mininet4.pingstatus(src=main.params['PING']['source2'])
@@ -471,6 +471,6 @@
result = main.FALSE
count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines())
utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No Exceptions found in the logs",onfail=str(count) + " Exceptions were found in the logs")
- main.Mininet1.stop_tcpdump()
+ main.Mininet2.stop_tcpdump()
diff --git a/TestON/tests/RCOnosPerf4nodes/RCOnosPerf4nodes.topo b/TestON/tests/RCOnosPerf4nodes/RCOnosPerf4nodes.topo
index b49d5dc..6402f13 100644
--- a/TestON/tests/RCOnosPerf4nodes/RCOnosPerf4nodes.topo
+++ b/TestON/tests/RCOnosPerf4nodes/RCOnosPerf4nodes.topo
@@ -110,13 +110,20 @@
<controller> remote </controller>
</COMPONENTS>
</Mininet1>
+ <Mininet2>
+ <host>10.128.4.159</host>
+ <user>admin</user>
+ <password></password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>14</connect_order>
+ </Mininet2>
<Mininet4>
<host>10.128.4.159</host>
<user>admin</user>
<password></password>
<type>RemoteMininetDriver</type>
- <connect_order>14</connect_order>
+ <connect_order>15</connect_order>
</Mininet4>
</COMPONENT>
</TOPOLOGY>
diff --git a/TestON/tests/RCOnosSanity4nodesJ/RCOnosSanity4nodesJ.py b/TestON/tests/RCOnosSanity4nodesJ/RCOnosSanity4nodesJ.py
index f8cfca1..d177f8b 100644
--- a/TestON/tests/RCOnosSanity4nodesJ/RCOnosSanity4nodesJ.py
+++ b/TestON/tests/RCOnosSanity4nodesJ/RCOnosSanity4nodesJ.py
@@ -153,6 +153,8 @@
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'])
main.Mininet1.get_sw_controller("s1")
time.sleep(30)
+
+ main.Zookeeper1.findMaster(switchDPID="00:00:00:00:00:00:10:00")
# **********************************************************************************************************************************************************************************************
#Add Flows
@@ -369,7 +371,7 @@
main.case("Bringing Link down... ")
result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
- time.sleep(10)
+ time.sleep(30)
strtTime = time.time()
result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
for i in range(10):
@@ -413,7 +415,7 @@
result = main.Mininet1.link(END1='s1',END2='s3',OPTION="down")
result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
- time.sleep(10)
+ time.sleep(30)
strtTime = time.time()
result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
for i in range(10):
diff --git a/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.params b/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.params
index 6de3811..250da70 100644
--- a/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.params
+++ b/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.params
@@ -1,5 +1,5 @@
<PARAMS>
- <testcases>1,2,21,31,6,7,4,5,6,7,41,5,6,7,4,6,7,5,41,6,7,66</testcases>
+ <testcases>1,2,21,31,6,7,4,6,7,5,6,7,41,6,7,5,6,7,6,7,66</testcases>
<tcpdump>
<intf>eth0</intf>
<port>port 6633</port>
diff --git a/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.py b/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.py
index be801e6..bebdf4b 100644
--- a/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.py
+++ b/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.py
@@ -20,7 +20,7 @@
main.ONOS3.stop_all()
main.ONOS4.stop_all()
main.step("Start tcpdump on mn")
- main.Mininet1.start_tcpdump(main.params['tcpdump']['filename'], intf = main.params['tcpdump']['intf'], port = main.params['tcpdump']['port'])
+ main.Mininet2.start_tcpdump(main.params['tcpdump']['filename'], intf = main.params['tcpdump']['intf'], port = main.params['tcpdump']['port'])
# main.step("Start tcpdump on mn")
# main.Mininet1.start_tcpdump(main.params['tcpdump']['filename'], intf = main.params['tcpdump']['intf'], port = main.params['tcpdump']['port'])
main.step("start ONOS")
@@ -616,6 +616,6 @@
result = main.FALSE
count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines())
utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No Exceptions found in the logs",onfail=str(count) + " Exceptions were found in the logs")
- main.Mininet1.stop_tcpdump()
+ main.Mininet2.stop_tcpdump()
diff --git a/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.topo b/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.topo
index c5c5dee..988e8af 100644
--- a/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.topo
+++ b/TestON/tests/RRCOnosSanity4nodesJ/RRCOnosSanity4nodesJ.topo
@@ -134,6 +134,13 @@
<controller> remote </controller>
</COMPONENTS>
</Mininet1>
+ <Mininet2>
+ <host>10.128.4.159</host>
+ <user>admin</user>
+ <password></password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>14</connect_order>
+ </Mininet2>
</COMPONENT>
</TOPOLOGY>
diff --git a/TestON/tests/TopoONOS2/TopoONOS2.back b/TestON/tests/TopoONOS2/TopoONOS2.back
new file mode 100644
index 0000000..97698e1
--- /dev/null
+++ b/TestON/tests/TopoONOS2/TopoONOS2.back
@@ -0,0 +1,971 @@
+
+class TopoONOS2 :
+
+ def __init__(self) :
+ self.default = ''
+
+#**********************************************************************************************************************************************************************************************
+#Test startup
+#Tests the startup of Zookeeper1, RamCloud1, and ONOS1 to be certain that all started up successfully
+ def CASE1(self,main) : #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version
+ import time
+ main.ONOS1.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
+ main.ONOS2.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
+ main.ONOS3.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
+ main.ONOS4.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
+
+ main.ONOS1.stop_all()
+ main.ONOS2.stop_all()
+ main.ONOS3.stop_all()
+ main.ONOS4.stop_all()
+ main.Zookeeper1.start()
+ main.Zookeeper2.start()
+ main.Zookeeper3.start()
+ main.Zookeeper4.start()
+ main.RamCloud1.stop_coor()
+ main.RamCloud1.stop_serv()
+ main.RamCloud2.stop_serv()
+ main.RamCloud3.stop_serv()
+ main.RamCloud4.stop_serv()
+ time.sleep(10)
+ main.RamCloud1.del_db()
+ main.RamCloud2.del_db()
+ main.RamCloud3.del_db()
+ main.RamCloud4.del_db()
+ time.sleep(10)
+ main.log.report("Pulling latest code from github to all nodes")
+ for i in range(2):
+ uptodate = main.ONOS1.git_pull()
+ main.ONOS2.git_pull()
+ main.ONOS3.git_pull()
+ main.ONOS4.git_pull()
+ ver1 = main.ONOS1.get_version()
+ ver2 = main.ONOS4.get_version()
+ if ver1==ver2:
+ break
+ elif i==1:
+ main.ONOS2.git_pull("ONOS1 master")
+ main.ONOS3.git_pull("ONOS1 master")
+ main.ONOS4.git_pull("ONOS1 master")
+ if uptodate==0:
+ main.ONOS1.git_compile()
+ main.ONOS2.git_compile()
+ main.ONOS3.git_compile()
+ main.ONOS4.git_compile()
+ main.ONOS1.print_version()
+ # main.RamCloud1.git_pull()
+ # main.RamCloud2.git_pull()
+ # main.RamCloud3.git_pull()
+ # main.RamCloud4.git_pull()
+ # main.ONOS1.get_version()
+ # main.ONOS2.get_version()
+ # main.ONOS3.get_version()
+ # main.ONOS4.get_version()
+ main.RamCloud1.start_coor()
+ time.sleep(1)
+ main.RamCloud1.start_serv()
+ main.RamCloud2.start_serv()
+ main.RamCloud3.start_serv()
+ main.RamCloud4.start_serv()
+ main.ONOS1.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
+ time.sleep(5)
+ main.ONOS2.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
+ main.ONOS3.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
+ main.ONOS4.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
+ main.ONOS1.start_rest()
+ time.sleep(10)
+ test= main.ONOS1.rest_status()
+ if test == main.FALSE:
+ main.ONOS1.start_rest()
+ main.ONOS1.get_version()
+ main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
+ main.case("Checking if the startup was clean...")
+ main.step("Testing startup Zookeeper")
+ data = main.Zookeeper1.isup()
+ utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
+ main.step("Testing startup RamCloud")
+ data = main.RamCloud1.status_serv()
+ if data == main.FALSE:
+ main.RamCloud1.stop_coor()
+ main.RamCloud1.stop_serv()
+ main.RamCloud2.stop_serv()
+ main.RamCloud3.stop_serv()
+ main.RamCloud4.stop_serv()
+
+ time.sleep(5)
+ main.RamCloud1.start_coor()
+ main.RamCloud1.start_serv()
+ main.RamCloud2.start_serv()
+ main.RamCloud3.start_serv()
+ main.RamCloud4.start_serv()
+ utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
+ main.step("Testing startup ONOS")
+ data = main.ONOS1.isup()
+ for i in range(3):
+ if data == main.FALSE:
+ #main.log.report("Something is funny... restarting ONOS")
+ #main.ONOS1.stop()
+ time.sleep(3)
+ #main.ONOS1.start()
+ #time.sleep(5)
+ data = main.ONOS1.isup()
+ else:
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
+ time.sleep(10)
+
+
+#**********************************************************************************************************************************************************************************************
+#Assign Controllers
+#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>).
+#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
+#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
+# the controllers already assigned to the switch are not specified.
+
+ def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
+ import time
+ main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
+ main.case("Checking if one MN host exists")
+ main.step("Host IP Checking using checkIP")
+ result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
+ main.step("Verifying the result")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
+ main.step("assigning ONOS controllers to switches")
+ for i in range(25):
+ if i < 3:
+ j=i+1
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+ time.sleep(1)
+ 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'])
+ elif i >= 3 and i < 5:
+ j=i+1
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
+ time.sleep(1)
+ 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'])
+ elif i >= 5 and i < 15:
+ j=i+1
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
+ time.sleep(1)
+ 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'])
+ else:
+ j=i+16
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
+ time.sleep(1)
+ 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'])
+ result = main.Mininet1.get_sw_controller("s1")
+ if result:
+ result = main.TRUE
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="S1 assigned to controller",onfail="S1 not assigned to controller")
+
+ for i in range(9):
+ if result == main.FALSE:
+ time.sleep(3)
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+
+# **********************************************************************************************************************************************************************************************
+#Add Flows
+#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
+#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
+
+ def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
+ main.log.report("Delete any flows from previous tests, then add flows using intents and wait for switch flow tables to update")
+ import time
+
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result == main.FALSE:
+ time.sleep(3)
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ main.case("Taking care of these flows!")
+ main.step("Cleaning out any leftover flows...")
+ #main.ONOS1.delete_flow("all")
+ main.ONOS1.rm_intents()
+ time.sleep(5)
+ main.ONOS1.purge_intents()
+ strtTime = time.time()
+ main.ONOS1.add_intents()
+ main.case("Checking flows with pings")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ # i = 6
+ main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2
+ if result == main.TRUE:
+ main.log.report("\n\t\t\t\tTime from pushing intents to successful ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tFlows failed check")
+
+ main.step("Verifying the result")
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+#**********************************************************************************************************************************************************************************************
+#This test case removes Controllers 2,3, and 4 then performs a ping test.
+#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
+#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.
+#If the ping test fails 6 times, then the test case will return false
+
+ def CASE4(self,main) :
+ main.log.report("Assign all switches to just one ONOS instance then ping until all hosts are reachable or fail after 6 attempts")
+ import time
+ import random
+
+ random.seed(None)
+
+ num = random.randint(1,4)
+ if num == 1:
+ ip = main.params['CTRL']['ip1']
+ port = main.params['CTRL']['port1']
+ elif num == 2:
+ ip = main.params['CTRL']['ip2']
+ port = main.params['CTRL']['port2']
+ elif num == 3:
+ ip = main.params['CTRL']['ip3']
+ port = main.params['CTRL']['port3']
+ else:
+ ip = main.params['CTRL']['ip4']
+ port = main.params['CTRL']['port4']
+
+ main.log.report("ONOS"+str(num)+" will be the sole controller")
+ for i in range(25):
+ if i < 15:
+ j=i+1
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) #Assigning a single controller removes all other controllers
+ else:
+ j=i+16
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port)
+
+ strtTime = time.time()
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result == main.FALSE:
+ time.sleep(3)
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ # i = 6
+ main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TEST FAIL")
+ main.ONOS1.show_intent(main.params['RestIP'])
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+# **********************************************************************************************************************************************************************************************
+#This test case restores the controllers removed by Case 4 then performs a ping test.
+
+ def CASE5(self,main) :
+ main.log.report("Restore switch assignments to all 4 ONOS instances then ping until all hosts are reachable or fail after 6 attempts")
+ import time
+
+ #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
+ time.sleep(10)
+
+ for i in range(25):
+ if i < 15:
+ j=i+1
+ 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'])
+ else:
+ j=i+16
+ 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'])
+
+ strtTime = time.time()
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result == main.FALSE:
+ time.sleep(3)
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ # i = 6
+ main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TEST FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+# **********************************************************************************************************************************************************************************************
+#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
+
+ def CASE6(self,main) :
+ main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
+ import time
+
+ #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
+ time.sleep(10)
+
+ main.case("Bringing Link down... ")
+ result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
+
+ strtTime = time.time()
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ for counter in range(9):
+ if result1 == main.FALSE:
+ time.sleep(3)
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
+ #i = 6
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2 and result1
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TEST FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+# **********************************************************************************************************************************************************************************************
+#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
+
+ def CASE7(self,main) :
+ main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
+ import time
+ main.case("Bringing Link up... ")
+
+ #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
+ time.sleep(10)
+
+ result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
+
+ strtTime = time.time()
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result1 == main.FALSE:
+ time.sleep(3)
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ strtTime = time.time()
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
+ #i = 6
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2 and result1
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TESTS FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+
+ print main.ONOS1.check_exceptions()
+ print main.ONOS2.check_exceptions()
+ print main.ONOS3.check_exceptions()
+ print main.ONOS4.check_exceptions()
+
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+
+# **********************************************************************************************************************************************************************************************
+# Runs reactive ping test
+ def CASE8(self,main) :
+ main.log.report("Reactive flow ping test:ping until the routes are active or fail after 10 attempts")
+ import time
+
+ strtTime = time.time()
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result == main.FALSE:
+ time.sleep(3)
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ strtTime = time.time()
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
+ #i = 6
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TESTS FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+
+ print main.ONOS1.check_exceptions()
+ print main.ONOS2.check_exceptions()
+ print main.ONOS3.check_exceptions()
+ print main.ONOS4.check_exceptions()
+
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+# **********************************************************************************************************************************************************************************************
+#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
+# This is the same as case 6, but specifically for the reactive tests
+
+ def CASE61(self,main) :
+ main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
+ import time
+
+ #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
+ time.sleep(10)
+
+ main.case("Bringing Link down... ")
+ result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
+
+ strtTime = time.time()
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ for counter in range(9):
+ if result1 == main.FALSE:
+ time.sleep(3)
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
+ #i = 6
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2 and result1
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TEST FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+
+# **********************************************************************************************************************************************************************************************
+#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
+# Specifically for the Reactive tests
+
+ def CASE71(self,main) :
+ main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
+ import time
+ main.case("Bringing Link up... ")
+
+ #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
+ time.sleep(10)
+
+ result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
+
+ strtTime = time.time()
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result1 == main.FALSE:
+ time.sleep(3)
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ strtTime = time.time()
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
+ #i = 6
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2 and result1
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TESTS FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+
+ print main.ONOS1.check_exceptions()
+ print main.ONOS2.check_exceptions()
+ print main.ONOS3.check_exceptions()
+ print main.ONOS4.check_exceptions()
+
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+
+
+
+# ******************************************************************************************************************************************************************
+# Check for ONOS Components health
+
+ def CASE9(self,main) :
+ main.case("Checking component status")
+ result = main.TRUE
+
+ main.step("Checking Zookeeper status")
+ result1 = main.Zookeeper1.status()
+ if not result1:
+ main.log.report("Zookeeper1 encountered a tragic death!")
+ result2 = main.Zookeeper2.status()
+ if not result2:
+ main.log.report("Zookeeper2 encountered a tragic death!")
+ result3 = main.Zookeeper3.status()
+ if not result3:
+ main.log.report("Zookeeper3 encountered a tragic death!")
+ result4 = main.Zookeeper4.status()
+ if not result4:
+ main.log.report("Zookeeper4 encountered a tragic death!")
+ result = result and result1 and result2 and result3 and result4
+
+ main.step("Checking RamCloud status")
+ result5 = main.RamCloud1.status_coor()
+ if not result5:
+ main.log.report("RamCloud Coordinator1 encountered a tragic death!")
+ result6 = main.RamCloud1.status_serv()
+ if not result6:
+ main.log.report("RamCloud Server1 encountered a tragic death!")
+ result7 = main.RamCloud2.status_serv()
+ if not result7:
+ main.log.report("RamCloud Server2 encountered a tragic death!")
+ result8 = main.RamCloud3.status_serv()
+ if not result8:
+ main.log.report("RamCloud Server3 encountered a tragic death!")
+ result9 = main.RamCloud4.status_serv()
+ if not result9:
+ main.log.report("RamCloud Server4 encountered a tragic death!")
+ result = result and result5 and result6 and result7 and result8 and result9
+
+
+ main.step("Checking ONOS status")
+ result10 = main.ONOS1.status()
+ if not result10:
+ main.log.report("ONOS1 core encountered a tragic death!")
+ result11 = main.ONOS2.status()
+ if not result11:
+ main.log.report("ONOS2 core encountered a tragic death!")
+ result12 = main.ONOS3.status()
+ if not result12:
+ main.log.report("ONOS3 core encountered a tragic death!")
+ result13 = main.ONOS4.status()
+ if not result13:
+ main.log.report("ONOS4 core encountered a tragic death!")
+ result = result and result10 and result11 and result12 and result13
+
+
+
+ rest_result = main.ONOS1.rest_status()
+ if not rest_result:
+ main.log.report("Simple Rest GUI server is not running on ONOS1")
+
+
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="All Components are running",onfail="One or more components failed")
+
+# ******************************************************************************************************************************************************************
+# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
+
+ def CASE21(self,main) :
+ import json
+ 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.")
+ main.log.report("Check initially hostMAC/IP exist on the mininet...")
+ host = main.params['YANK']['hostname']
+ mac = main.params['YANK']['hostmac']
+ RestIP1 = main.params['RESTCALL']['restIP1']
+ RestPort = main.params['RESTCALL']['restPort']
+ url = main.params['RESTCALL']['restURL']
+
+ t_topowait = 5
+ t_restwait = 0
+ main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
+ main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
+ #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
+ time.sleep(t_topowait)
+ 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" )
+ ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
+ time.sleep(t_restwait)
+ Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
+ main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus))
+ if Reststatus == 1:
+ main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0]))
+ result1 = main.TRUE
+ elif Reststatus > 1:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED")
+ main.log.report("switches are: " + "; ".join(Switch))
+ main.log.report("Ports are: " + "; ".join(Port))
+ result1 = main.FALSE
+ elif Reststatus == 0 and Switch == []:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
+ result1 = main.FALSE
+ else:# check if rest server is working
+ main.log.error("Issue with find host")
+ result1 = main.FALSE
+
+
+ ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
+
+ main.log.report("Yank out s1-eth1")
+ main.case("Yankout s6-eth1 (link to h1) from s1")
+ result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
+ time.sleep(t_topowait)
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
+
+ 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" )
+ ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
+ time.sleep(t_restwait)
+ Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
+
+ main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus))
+ if Reststatus == 1:
+ main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port))
+ result2 = main.FALSE
+ elif Reststatus > 1:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+ main.log.report("switches are: " + "; ".join(Switch))
+ main.log.report("Ports are: " + "; ".join(Port))
+ main.log.report("MACs are: " + "; ".join(MAC))
+ result2 = main.FALSE
+ elif Reststatus == 0 and Switch == []:
+ 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.")
+ result2 = main.TRUE
+ else:# check if rest server is working
+ main.log.error("Issue with find host")
+ result2 = main.FALSE
+
+ ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
+ main.log.report("Plug s1-eth1 into s6")
+ main.case("Plug s1-eth1 to s6")
+ result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
+ time.sleep(t_topowait)
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
+ 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" )
+
+ ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
+ time.sleep(t_restwait)
+ Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
+
+ main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus))
+ if Reststatus == 1:
+ main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
+ result3 = main.TRUE
+ elif Reststatus > 1:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+ main.log.report("switches are: " + "; ".join(Switch))
+ main.log.report("Ports are: " + "; ".join(Port))
+ main.log.report("MACs are: " + "; ".join(MAC))
+ result3 = main.FALSE
+ elif Reststatus == 0 and Switch == []:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
+ result3 = main.FALSE
+ else:# check if rest server is working
+ main.log.error("Issue with find host")
+ result3 = main.FALSE
+
+ ###### Step to put interface "s1-eth1" back to s1"#####
+ main.log.report("Move s1-eth1 back on to s1")
+ main.case("Move s1-eth1 back to s1")
+ result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
+ time.sleep(t_topowait)
+ result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
+ 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" )
+
+ ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
+ time.sleep(t_restwait)
+ Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
+
+ main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+ if Reststatus == 1:
+ main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
+ result4 = main.TRUE
+ elif Reststatus > 1:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
+ main.log.report("switches are: " + "; ".join(Switch))
+ main.log.report("Ports are: " + "; ".join(Port))
+ main.log.report("MACs are: " + "; ".join(MAC))
+ result4 = main.FALSE
+ elif Reststatus == 0 and Switch == []:
+ main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
+ result4 = main.FALSE
+ else:# check if rest server is working
+ main.log.error("Issue with find host")
+ result4 = main.FALSE
+ time.sleep(20)
+ Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac)
+ main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+ if Reststatus ==1:
+ main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout")
+ elif Reststatus>1:
+ main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)")
+ elif Reststatus==0:
+ main.log.report("\t PASSED - Device cleared after timeout")
+
+ result = result1 and result2 and result3 and result4
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
+
+
+ def CASE100(self,main):
+
+ from sts.topology.teston_topology import TestONTopology # assumes that sts already in you PYTHONPATH
+
+ topo = TestONTopology(main.Mininet1, onos_controllers=
+ [(main.ONOS1, 'ONOS1', main.params['CTRL']['ip1'], main.params['CTRL']['port1']),
+ (main.ONOS2, 'ONOS2', main.params['CTRL']['ip2'], main.params['CTRL']['port2']),
+ (main.ONOS3, 'ONOS3', main.params['CTRL']['ip3'], main.params['CTRL']['port3']),
+ (main.ONOS4, 'ONOS4', main.params['CTRL']['ip4'], main.params['CTRL']['port4'])])
+
+
+
+ #for switch in topo.graph.switches: print "Switch name: %s, dpid: %s, ports: %s" % (switch.name, switch.dpid, [p.hw_addr for p in switch.ports.values()])
+ print()
+ print()
+ print()
+ import json
+ '''
+ output = '{"Switches":['
+ for switch in topo.graph.switches:
+ ports = '%s' % [p.hw_addr for p in switch.ports.values()]
+ ports = ports.replace('\'','"')
+ output += '{"name": "%s", "dpid": "%s", "ports": %s},' % (switch.name, switch.dpid, ports)
+ output = output[:-1]
+ output += ']}'
+ '''
+ output = {"Switches":[]}
+ for switch in topo.graph.switches:
+ print [p.hw_addr for p in switch.ports.values()]
+ ports = '%s' % [p.hw_addr for p in switch.ports.values()]
+ ports = ports.replace('\'','')
+ output['Switches'].append({"name": switch.name, "dpid": switch.dpid, "ports": ports})
+ print output
+ #mn_json = json.loads(output)
+ print json.dumps(output, sort_keys=True,indent=4,separators=(',', ': '))
+ print type(output)
+ print output.items()
+ mnDPIDs=[]
+ for switch in output['Switches']:
+ mnDPIDs.append(switch['dpid'])
+ mnDPIDs.append('mn1')
+ mnDPIDs.sort()
+ print mnDPIDs
+ print
+ print "Dumping ONOS view of Switches"
+ onos=main.ONOS1.get_json("10.128.11.1:8080/wm/onos/topology/switches")
+ onosDPIDs=[]
+ for switch in onos:
+ print switch
+ onosDPIDs.append(switch['dpid'].replace(":",''))
+ onosDPIDs.append(00121)
+ onosDPIDs.sort()
+ print onosDPIDs
+ if mnDPIDs!=onosDPIDs:
+ print "Switches in MN but not in ONOS:"
+ print [switch for switch in mnDPIDs if switch not in onosDPIDs]
+ print "Switches in ONOS but not in MN:"
+ print [switch for switch in onosDPIDs if switch not in mnDPIDs]
+ print()
+ print()
+ print()
+ '''
+ for host in topo.graph.hosts: print "Host: %s, interfaces: %s" % (host.name, [iface.hw_addr for iface in host.interfaces])
+ print()
+ print()
+ print()
+ for link in topo.graph.links: print "Link: %s" % link
+ print()
+ print()
+ print()
+ # To print just internal network links (connecting switches to each other)
+ print "Just printing network links"
+ for link in topo.patch_panel.network_links: print "Link: %s" % link
+ '''
+ '''
+ # Bring links up and down
+ for link in topo.patch_panel.network_links:
+ topo.patch_panel.sever_network_link(link)
+ for link in topo.patch_panel.access_links:
+ topo.patch_panel.sever_access_link(link)
+ for link in topo.patch_panel.network_links:
+ topo.patch_panel.repair_network_link(link)
+ for link in topo.patch_panel.access_links:
+ topo.patch_panel.repair_access_link(link)
+ '''
+
+
+ time.sleep(40)
+
diff --git a/TestON/tests/TopoONOS2/TopoONOS2.params b/TestON/tests/TopoONOS2/TopoONOS2.params
new file mode 100644
index 0000000..ce2b4fb
--- /dev/null
+++ b/TestON/tests/TopoONOS2/TopoONOS2.params
@@ -0,0 +1,55 @@
+<PARAMS>
+ <testcases>2,100 </testcases>
+ <pingSleep>1</pingSleep>
+ <pingAttempts>60</pingAttempts>
+ <CASE1>
+ <destination>h6</destination>
+ </CASE1>
+ <PING>
+ <source1>h6</source1>
+ <target1>h31</target1>
+ <source2>h8</source2>
+ <target2>h33</target2>
+ </PING>
+ <LINK>
+ <begin>s1</begin>
+ <end>s2</end>
+ </LINK>
+ <CTRL>
+ <ip1>10.128.11.1</ip1>
+ <port1>6633</port1>
+ <restPort1>8080</restPort1>
+ <ip2>10.128.11.2</ip2>
+ <port2>6633</port2>
+ <restPort2>8080</restPort2>
+ <ip3>10.128.11.3</ip3>
+ <port3>6633</port3>
+ <restPort3>8080</restPort3>
+ <ip4>10.128.11.4</ip4>
+ <port4>6633</port4>
+ <restPort4>8080</restPort4>
+ </CTRL>
+ <TopoRest>/wm/onos/topology</TopoRest>
+ <RestIP> 10.128.11.1 </RestIP>
+ <NR_Switches>25</NR_Switches>
+ <NR_Links>50</NR_Links>
+ <YANK>
+ <hostname>h1</hostname>
+ <hostip>10.0.0.1</hostip>
+ <hostmac>00:00:00:00:00:01</hostmac>
+ <sw1>s1</sw1>
+ <sw6>s6</sw6>
+ <intf>s1-eth1</intf>
+ </YANK>
+ <PLUG>
+ <intf>s1-eth1</intf>
+ <sw6>s6</sw6>
+ <sw1>s1</sw1>
+ </PLUG>
+ <RESTCALL>
+ <restIP1>10.128.11.1</restIP1>
+ <restIP2>10.128.11.2</restIP2>
+ <restPort>8080</restPort>
+ <restURL>/wm/onos/topology/hosts</restURL>
+ </RESTCALL>
+</PARAMS>
diff --git a/TestON/tests/TopoONOS2/TopoONOS2.py b/TestON/tests/TopoONOS2/TopoONOS2.py
new file mode 100644
index 0000000..032e2b0
--- /dev/null
+++ b/TestON/tests/TopoONOS2/TopoONOS2.py
@@ -0,0 +1,914 @@
+
+class TopoONOS2 :
+
+ def __init__(self) :
+ self.default = ''
+
+#**********************************************************************************************************************************************************************************************
+#Test startup
+#Tests the startup of Zookeeper1, RamCloud1, and ONOS1 to be certain that all started up successfully
+ def CASE1(self,main) : #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version
+ import time
+ main.ONOS1.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
+ main.ONOS2.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
+ main.ONOS3.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
+ main.ONOS4.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
+
+ main.ONOS1.stop_all()
+ main.ONOS2.stop_all()
+ main.ONOS3.stop_all()
+ main.ONOS4.stop_all()
+ main.Zookeeper1.start()
+ main.Zookeeper2.start()
+ main.Zookeeper3.start()
+ main.Zookeeper4.start()
+ main.RamCloud1.stop_coor()
+ main.RamCloud1.stop_serv()
+ main.RamCloud2.stop_serv()
+ main.RamCloud3.stop_serv()
+ main.RamCloud4.stop_serv()
+ time.sleep(10)
+ main.RamCloud1.del_db()
+ main.RamCloud2.del_db()
+ main.RamCloud3.del_db()
+ main.RamCloud4.del_db()
+ time.sleep(10)
+ main.log.report("Pulling latest code from github to all nodes")
+ for i in range(2):
+ uptodate = main.ONOS1.git_pull()
+ main.ONOS2.git_pull()
+ main.ONOS3.git_pull()
+ main.ONOS4.git_pull()
+ ver1 = main.ONOS1.get_version()
+ ver2 = main.ONOS4.get_version()
+ if ver1==ver2:
+ break
+ elif i==1:
+ main.ONOS2.git_pull("ONOS1 master")
+ main.ONOS3.git_pull("ONOS1 master")
+ main.ONOS4.git_pull("ONOS1 master")
+ if uptodate==0:
+ main.ONOS1.git_compile()
+ main.ONOS2.git_compile()
+ main.ONOS3.git_compile()
+ main.ONOS4.git_compile()
+ main.ONOS1.print_version()
+ # main.RamCloud1.git_pull()
+ # main.RamCloud2.git_pull()
+ # main.RamCloud3.git_pull()
+ # main.RamCloud4.git_pull()
+ # main.ONOS1.get_version()
+ # main.ONOS2.get_version()
+ # main.ONOS3.get_version()
+ # main.ONOS4.get_version()
+ main.RamCloud1.start_coor()
+ time.sleep(1)
+ main.RamCloud1.start_serv()
+ main.RamCloud2.start_serv()
+ main.RamCloud3.start_serv()
+ main.RamCloud4.start_serv()
+ main.ONOS1.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
+ time.sleep(5)
+ main.ONOS2.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
+ main.ONOS3.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
+ main.ONOS4.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
+ main.ONOS1.start_rest()
+ time.sleep(10)
+ test= main.ONOS1.rest_status()
+ if test == main.FALSE:
+ main.ONOS1.start_rest()
+ main.ONOS1.get_version()
+ main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
+ main.case("Checking if the startup was clean...")
+ main.step("Testing startup Zookeeper")
+ data = main.Zookeeper1.isup()
+ utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
+ main.step("Testing startup RamCloud")
+ data = main.RamCloud1.status_serv()
+ if data == main.FALSE:
+ main.RamCloud1.stop_coor()
+ main.RamCloud1.stop_serv()
+ main.RamCloud2.stop_serv()
+ main.RamCloud3.stop_serv()
+ main.RamCloud4.stop_serv()
+
+ time.sleep(5)
+ main.RamCloud1.start_coor()
+ main.RamCloud1.start_serv()
+ main.RamCloud2.start_serv()
+ main.RamCloud3.start_serv()
+ main.RamCloud4.start_serv()
+ utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
+ main.step("Testing startup ONOS")
+ data = main.ONOS1.isup()
+ for i in range(3):
+ if data == main.FALSE:
+ #main.log.report("Something is funny... restarting ONOS")
+ #main.ONOS1.stop()
+ time.sleep(3)
+ #main.ONOS1.start()
+ #time.sleep(5)
+ data = main.ONOS1.isup()
+ else:
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
+ time.sleep(10)
+
+
+#**********************************************************************************************************************************************************************************************
+#Assign Controllers
+#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>).
+#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
+#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
+# the controllers already assigned to the switch are not specified.
+
+ def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
+ import time
+ main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
+ main.case("Checking if one MN host exists")
+ main.step("Host IP Checking using checkIP")
+ result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
+ main.step("Verifying the result")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
+ main.step("assigning ONOS controllers to switches")
+ for i in range(25):
+ if i < 3:
+ j=i+1
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+ time.sleep(1)
+ 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'])
+ elif i >= 3 and i < 5:
+ j=i+1
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
+ time.sleep(1)
+ 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'])
+ elif i >= 5 and i < 15:
+ j=i+1
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
+ time.sleep(1)
+ 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'])
+ else:
+ j=i+16
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
+ time.sleep(1)
+ 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'])
+ result = main.Mininet1.get_sw_controller("s1")
+ if result:
+ result = main.TRUE
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="S1 assigned to controller",onfail="S1 not assigned to controller")
+
+ for i in range(9):
+ if result == main.FALSE:
+ time.sleep(3)
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+
+# **********************************************************************************************************************************************************************************************
+#Add Flows
+#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
+#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
+
+ def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
+ main.log.report("Delete any flows from previous tests, then add flows using intents and wait for switch flow tables to update")
+ import time
+
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result == main.FALSE:
+ time.sleep(3)
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ main.case("Taking care of these flows!")
+ main.step("Cleaning out any leftover flows...")
+ #main.ONOS1.delete_flow("all")
+ main.ONOS1.rm_intents()
+ time.sleep(5)
+ main.ONOS1.purge_intents()
+ strtTime = time.time()
+ main.ONOS1.add_intents()
+ main.case("Checking flows with pings")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ # i = 6
+ main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2
+ if result == main.TRUE:
+ main.log.report("\n\t\t\t\tTime from pushing intents to successful ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tFlows failed check")
+
+ main.step("Verifying the result")
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+#**********************************************************************************************************************************************************************************************
+#This test case removes Controllers 2,3, and 4 then performs a ping test.
+#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
+#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.
+#If the ping test fails 6 times, then the test case will return false
+
+ def CASE4(self,main) :
+ main.log.report("Assign all switches to just one ONOS instance then ping until all hosts are reachable or fail after 6 attempts")
+ import time
+ import random
+
+ random.seed(None)
+
+ num = random.randint(1,4)
+ if num == 1:
+ ip = main.params['CTRL']['ip1']
+ port = main.params['CTRL']['port1']
+ elif num == 2:
+ ip = main.params['CTRL']['ip2']
+ port = main.params['CTRL']['port2']
+ elif num == 3:
+ ip = main.params['CTRL']['ip3']
+ port = main.params['CTRL']['port3']
+ else:
+ ip = main.params['CTRL']['ip4']
+ port = main.params['CTRL']['port4']
+
+ main.log.report("ONOS"+str(num)+" will be the sole controller")
+ for i in range(25):
+ if i < 15:
+ j=i+1
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) #Assigning a single controller removes all other controllers
+ else:
+ j=i+16
+ main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port)
+
+ strtTime = time.time()
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result == main.FALSE:
+ time.sleep(3)
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ # i = 6
+ main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TEST FAIL")
+ main.ONOS1.show_intent(main.params['RestIP'])
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+# **********************************************************************************************************************************************************************************************
+#This test case restores the controllers removed by Case 4 then performs a ping test.
+
+ def CASE5(self,main) :
+ main.log.report("Restore switch assignments to all 4 ONOS instances then ping until all hosts are reachable or fail after 6 attempts")
+ import time
+
+ #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
+ time.sleep(10)
+
+ for i in range(25):
+ if i < 15:
+ j=i+1
+ 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'])
+ else:
+ j=i+16
+ 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'])
+
+ strtTime = time.time()
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result == main.FALSE:
+ time.sleep(3)
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ # i = 6
+ main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TEST FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+# **********************************************************************************************************************************************************************************************
+#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
+
+ def CASE6(self,main) :
+ main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
+ import time
+
+ #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
+ time.sleep(10)
+
+ main.case("Bringing Link down... ")
+ result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
+
+ strtTime = time.time()
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ for counter in range(9):
+ if result1 == main.FALSE:
+ time.sleep(3)
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
+ #i = 6
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2 and result1
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TEST FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+# **********************************************************************************************************************************************************************************************
+#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
+
+ def CASE7(self,main) :
+ main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
+ import time
+ main.case("Bringing Link up... ")
+
+ #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
+ time.sleep(10)
+
+ result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
+
+ strtTime = time.time()
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result1 == main.FALSE:
+ time.sleep(3)
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ strtTime = time.time()
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
+ #i = 6
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2 and result1
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TESTS FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+
+ print main.ONOS1.check_exceptions()
+ print main.ONOS2.check_exceptions()
+ print main.ONOS3.check_exceptions()
+ print main.ONOS4.check_exceptions()
+
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+
+# **********************************************************************************************************************************************************************************************
+# Runs reactive ping test
+ def CASE8(self,main) :
+ main.log.report("Reactive flow ping test:ping until the routes are active or fail after 10 attempts")
+ import time
+
+ strtTime = time.time()
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result == main.FALSE:
+ time.sleep(3)
+ result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ strtTime = time.time()
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
+ #i = 6
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TESTS FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+
+ print main.ONOS1.check_exceptions()
+ print main.ONOS2.check_exceptions()
+ print main.ONOS3.check_exceptions()
+ print main.ONOS4.check_exceptions()
+
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+# **********************************************************************************************************************************************************************************************
+#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
+# This is the same as case 6, but specifically for the reactive tests
+
+ def CASE61(self,main) :
+ main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
+ import time
+
+ #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
+ time.sleep(10)
+
+ main.case("Bringing Link down... ")
+ result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
+
+ strtTime = time.time()
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ for counter in range(9):
+ if result1 == main.FALSE:
+ time.sleep(3)
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
+ #i = 6
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2 and result1
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TEST FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+
+# **********************************************************************************************************************************************************************************************
+#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
+# Specifically for the Reactive tests
+
+ def CASE71(self,main) :
+ main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
+ import time
+ main.case("Bringing Link up... ")
+
+ #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
+ time.sleep(10)
+
+ result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
+
+ strtTime = time.time()
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ for counter in range(9):
+ if result1 == main.FALSE:
+ time.sleep(3)
+ result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ else:
+ main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+ break
+ utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
+
+ pingAttempts = main.params['pingAttempts']
+ pingSleep = main.params['pingSleep']
+
+ strtTime = time.time()
+ count = 1
+ i = 6
+ while i < 16 :
+ main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) )
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i))
+ if ping == main.FALSE and count < int(pingAttempts):
+ count = count + 1
+ main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
+ #i = 6
+ time.sleep(int(pingSleep))
+ elif ping == main.FALSE and count == int(pingAttempts):
+ main.log.error("Ping test failed")
+ i = 17
+ result2 = main.FALSE
+ elif ping == main.TRUE:
+ i = i + 1
+ result2 = main.TRUE
+ endTime = time.time()
+ result = result and result2 and result1
+ if result == main.TRUE:
+ main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+ else:
+ main.log.report("\tPING TESTS FAILED")
+ main.ONOS1.show_intent(main.params['RestIP'])
+
+ print main.ONOS1.check_exceptions()
+ print main.ONOS2.check_exceptions()
+ print main.ONOS3.check_exceptions()
+ print main.ONOS4.check_exceptions()
+
+ utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
+
+
+
+
+# ******************************************************************************************************************************************************************
+# Check for ONOS Components health
+
+ def CASE9(self,main) :
+ main.case("Checking component status")
+ result = main.TRUE
+
+ main.step("Checking Zookeeper status")
+ result1 = main.Zookeeper1.status()
+ if not result1:
+ main.log.report("Zookeeper1 encountered a tragic death!")
+ result2 = main.Zookeeper2.status()
+ if not result2:
+ main.log.report("Zookeeper2 encountered a tragic death!")
+ result3 = main.Zookeeper3.status()
+ if not result3:
+ main.log.report("Zookeeper3 encountered a tragic death!")
+ result4 = main.Zookeeper4.status()
+ if not result4:
+ main.log.report("Zookeeper4 encountered a tragic death!")
+ result = result and result1 and result2 and result3 and result4
+
+ main.step("Checking RamCloud status")
+ result5 = main.RamCloud1.status_coor()
+ if not result5:
+ main.log.report("RamCloud Coordinator1 encountered a tragic death!")
+ result6 = main.RamCloud1.status_serv()
+ if not result6:
+ main.log.report("RamCloud Server1 encountered a tragic death!")
+ result7 = main.RamCloud2.status_serv()
+ if not result7:
+ main.log.report("RamCloud Server2 encountered a tragic death!")
+ result8 = main.RamCloud3.status_serv()
+ if not result8:
+ main.log.report("RamCloud Server3 encountered a tragic death!")
+ result9 = main.RamCloud4.status_serv()
+ if not result9:
+ main.log.report("RamCloud Server4 encountered a tragic death!")
+ result = result and result5 and result6 and result7 and result8 and result9
+
+
+ main.step("Checking ONOS status")
+ result10 = main.ONOS1.status()
+ if not result10:
+ main.log.report("ONOS1 core encountered a tragic death!")
+ result11 = main.ONOS2.status()
+ if not result11:
+ main.log.report("ONOS2 core encountered a tragic death!")
+ result12 = main.ONOS3.status()
+ if not result12:
+ main.log.report("ONOS3 core encountered a tragic death!")
+ result13 = main.ONOS4.status()
+ if not result13:
+ main.log.report("ONOS4 core encountered a tragic death!")
+ result = result and result10 and result11 and result12 and result13
+
+
+
+ rest_result = main.ONOS1.rest_status()
+ if not rest_result:
+ main.log.report("Simple Rest GUI server is not running on ONOS1")
+
+
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="All Components are running",onfail="One or more components failed")
+
+# ******************************************************************************************************************************************************************
+# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
+
+ def CASE21(self,main) :
+ import json
+ 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.")
+ main.log.report("Check initially hostMAC/IP exist on the mininet...")
+ host = main.params['YANK']['hostname']
+ mac = main.params['YANK']['hostmac']
+ RestIP1 = main.params['RESTCALL']['restIP1']
+ RestPort = main.params['RESTCALL']['restPort']
+ url = main.params['RESTCALL']['restURL']
+
+ t_topowait = 5
+ t_restwait = 0
+ main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
+ main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
+ #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
+ time.sleep(t_topowait)
+ 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" )
+ ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
+ time.sleep(t_restwait)
+ Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
+ main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus))
+ if Reststatus == 1:
+ main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0]))
+ result1 = main.TRUE
+ elif Reststatus > 1:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED")
+ main.log.report("switches are: " + "; ".join(Switch))
+ main.log.report("Ports are: " + "; ".join(Port))
+ result1 = main.FALSE
+ elif Reststatus == 0 and Switch == []:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
+ result1 = main.FALSE
+ else:# check if rest server is working
+ main.log.error("Issue with find host")
+ result1 = main.FALSE
+
+
+ ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
+
+ main.log.report("Yank out s1-eth1")
+ main.case("Yankout s6-eth1 (link to h1) from s1")
+ result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
+ time.sleep(t_topowait)
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
+
+ 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" )
+ ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
+ time.sleep(t_restwait)
+ Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
+
+ main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus))
+ if Reststatus == 1:
+ main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port))
+ result2 = main.FALSE
+ elif Reststatus > 1:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+ main.log.report("switches are: " + "; ".join(Switch))
+ main.log.report("Ports are: " + "; ".join(Port))
+ main.log.report("MACs are: " + "; ".join(MAC))
+ result2 = main.FALSE
+ elif Reststatus == 0 and Switch == []:
+ 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.")
+ result2 = main.TRUE
+ else:# check if rest server is working
+ main.log.error("Issue with find host")
+ result2 = main.FALSE
+
+ ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
+ main.log.report("Plug s1-eth1 into s6")
+ main.case("Plug s1-eth1 to s6")
+ result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
+ time.sleep(t_topowait)
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
+ 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" )
+
+ ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
+ time.sleep(t_restwait)
+ Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
+
+ main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus))
+ if Reststatus == 1:
+ main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
+ result3 = main.TRUE
+ elif Reststatus > 1:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+ main.log.report("switches are: " + "; ".join(Switch))
+ main.log.report("Ports are: " + "; ".join(Port))
+ main.log.report("MACs are: " + "; ".join(MAC))
+ result3 = main.FALSE
+ elif Reststatus == 0 and Switch == []:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
+ result3 = main.FALSE
+ else:# check if rest server is working
+ main.log.error("Issue with find host")
+ result3 = main.FALSE
+
+ ###### Step to put interface "s1-eth1" back to s1"#####
+ main.log.report("Move s1-eth1 back on to s1")
+ main.case("Move s1-eth1 back to s1")
+ result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
+ time.sleep(t_topowait)
+ result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
+ 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" )
+
+ ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
+ time.sleep(t_restwait)
+ Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
+
+ main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+ if Reststatus == 1:
+ main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
+ result4 = main.TRUE
+ elif Reststatus > 1:
+ main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
+ main.log.report("switches are: " + "; ".join(Switch))
+ main.log.report("Ports are: " + "; ".join(Port))
+ main.log.report("MACs are: " + "; ".join(MAC))
+ result4 = main.FALSE
+ elif Reststatus == 0 and Switch == []:
+ main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
+ result4 = main.FALSE
+ else:# check if rest server is working
+ main.log.error("Issue with find host")
+ result4 = main.FALSE
+ time.sleep(20)
+ Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac)
+ main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+ if Reststatus ==1:
+ main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout")
+ elif Reststatus>1:
+ main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)")
+ elif Reststatus==0:
+ main.log.report("\t PASSED - Device cleared after timeout")
+
+ result = result1 and result2 and result3 and result4
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
+
+
+ def CASE100(self,main):
+
+ time.sleep(40)
+ ctrls = []
+ count = 1
+ while True:
+ temp = ()
+ if ('ip' + str(count)) in main.params['CTRL']:
+ temp = temp + (getattr(main,('ONOS' + str(count))),)
+ temp = temp + ("ONOS"+str(count),)
+ temp = temp + (main.params['CTRL']['ip'+str(count)],)
+ temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+ ctrls.append(temp)
+ count = count + 1
+ else:
+ break
+
+
+ topo_result = main.TRUE
+ for n in range(1,5):
+ temp_result = main.Mininet1.compare_topo(ctrls, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
+ '''
+ temp_result = main.Mininet1.compare_topo(
+ [(main.ONOS1, 'ONOS1', main.params['CTRL']['ip1'], main.params['CTRL']['port1']),
+ (main.ONOS2, 'ONOS2', main.params['CTRL']['ip2'], main.params['CTRL']['port2']),
+ (main.ONOS3, 'ONOS3', main.params['CTRL']['ip3'], main.params['CTRL']['port3']),
+ (main.ONOS4, 'ONOS4', main.params['CTRL']['ip4'], main.params['CTRL']['port4'])],
+ main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
+ '''
+ topo_result = topo_result and temp_result
+ print "Topoology check results: " + str(topo_result)
+
diff --git a/TestON/tests/TopoONOS2/TopoONOS2.topo b/TestON/tests/TopoONOS2/TopoONOS2.topo
new file mode 100644
index 0000000..c3f1b4b
--- /dev/null
+++ b/TestON/tests/TopoONOS2/TopoONOS2.topo
@@ -0,0 +1,139 @@
+<TOPOLOGY>
+
+ <COMPONENT>
+ <Zookeeper1>
+ <host>10.128.11.1</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>ZookeeperCliDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </Zookeeper1>
+
+ <Zookeeper2>
+ <host>10.128.11.2</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>ZookeeperCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </Zookeeper2>
+
+ <Zookeeper3>
+ <host>10.128.11.3</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>ZookeeperCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </Zookeeper3>
+
+ <Zookeeper4>
+ <host>10.128.11.4</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>ZookeeperCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </Zookeeper4>
+
+ <RamCloud1>
+ <host>10.128.11.1</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RamCloudCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </RamCloud1>
+
+ <RamCloud2>
+ <host>10.128.11.2</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RamCloudCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </RamCloud2>
+
+ <RamCloud3>
+ <host>10.128.11.3</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RamCloudCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </RamCloud3>
+
+ <RamCloud4>
+ <host>10.128.11.4</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RamCloudCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </RamCloud4>
+
+ <ONOS1>
+ <host>10.128.11.1</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.11.2</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.11.3</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.128.11.4</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOS4>
+
+ <Mininet1>
+ <host>10.128.11.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS>
+ # Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-onos4node.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/TopoONOS2/__init__.py b/TestON/tests/TopoONOS2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/TopoONOS2/__init__.py