Merge branch 'ONOS-Next' of https://github.com/OPENNETWORKINGLAB/ONLabTest into ONOS-Next
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index ccf3baf..419ee06 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -808,6 +808,7 @@
'''
import json
+ #main.log.debug("Switches_json string: ", switches_json)
output = {"switches":[]}
for switch in topo.graph.switches: #iterate through the MN topology and pull out switches and and port info
#print vars(switch)
@@ -818,7 +819,10 @@
output['switches'].append({"name": switch.name, "dpid": str(switch.dpid).zfill(16), "ports": ports })
#print output
+ #print "mn"
#print json.dumps(output, sort_keys=True,indent=4,separators=(',', ': '))
+ #print "onos"
+ #print json.dumps(switches_json, sort_keys=True,indent=4,separators=(',', ': '))
# created sorted list of dpid's in MN and ONOS for comparison
@@ -828,7 +832,7 @@
mnDPIDs.sort()
#print mnDPIDs
if switches_json == "":#if rest call fails
- main.log.error(self.name + ".compare_topo(): Empty JSON object given from ONOS")
+ main.log.error(self.name + ".compare_switches(): Empty JSON object given from ONOS")
return main.FALSE
onos=switches_json
onosDPIDs=[]
@@ -1019,184 +1023,6 @@
return link_results
-
-
- def compare_topo(self, topo, 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.
-
- To install sts:
- $ git clone git://github.com/ucb-sts/sts.git
- $ cd sts
- $ git clone -b debugger git://github.com/ucb-sts/pox.git
- $ sudo apt-get install python-dev
- $ ./tools/install_hassel_python.sh
- $ sudo pip install networkx
-
- Include sts in your PYTHONPATH. it should looks comething like:
- PYTHONPATH=/home/admin/TestON:/home/admin/sts
-
- '''
- import sys
- sys.path.append("~/sts")
- #NOTE: Create this once per Test and pass the TestONTopology object around. It takes too long to create this object.
- # This will make it easier to use the sts methods for severing links and solve that issue
- import json
-
- 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():
- #print port.hw_addr.toStr(separator = '')
- ports.append({'of_port': port.port_no, 'mac': str(port.hw_addr).replace('\'',''), 'name': port.name})
- output['switches'].append({"name": switch.name, "dpid": str(switch.dpid).zfill(16), "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()
- #print "mn_ports[] = ", mn_ports
- #print "onos_ports90 = ", onos_ports
-
- #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
-
- #For OF1.3, the OFP_local port number is 0xfffffffe or 4294967294 instead of 0xfffe or 65534 in OF1.0, ONOS topology
- #sees the correct port number, however MN topology as read from line 151 of https://github.com/ucb-sts/sts/blob/
- #topology_refactoring2/sts/entities/teston_entities.py is 0xfffe which doesn't work correctly with OF1.3 switches.
- #So a short term fix is to ignore the case when mn_port == 65534 and onos_port ==4294967294.
- for mn_port,onos_port in zip(mn_ports,onos_ports):
- if mn_port == onos_port or (mn_port == 65534 and onos_port ==4294967294):
- continue
- else:
- port_results = main.FALSE
- break
- '''
- 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]))
- '''
- if 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
- # NOTE: Will currently only show mn links as down if they are cut through STS.
- # We can either do everything through STS or wait for up_network_links
- # and down_network_links to be fully implemented.
- 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
-
def get_hosts(self):
'''
Returns a list of all hosts
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 46bcaa1..eeb379f 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -209,6 +209,8 @@
handle += self.handle.after
main.log.info("Command sent.")
+ ansi_escape = re.compile(r'\x1b[^m]*m')
+ handle = ansi_escape.sub('', handle)
return handle
except pexpect.EOF:
@@ -689,8 +691,95 @@
main.cleanup()
main.exit()
- #TODO:
- #def hosts(self):
+ def hosts(self, json_format=True, grep_str=""):
+ '''
+ Lists all discovered hosts
+ Optional argument:
+ * grep_str - pass in a string to grep
+ '''
+ try:
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+
+ if json_format:
+ if not grep_str:
+ self.handle.sendline("hosts -j")
+ self.handle.expect("hosts -j")
+ self.handle.expect("onos>")
+ else:
+ self.handle.sendline("hosts -j | grep '"+
+ str(grep_str)+"'")
+ self.handle.expect("hosts -j | grep '"+str(grep_str)+"'")
+ self.handle.expect("onos>")
+ handle = self.handle.before
+ '''
+ handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
+ To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
+ In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
+ So we take off that escape sequence using
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ '''
+ #print "repr(handle) =", repr(handle)
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ #print "repr(handle1) = ", repr(handle1)
+ return handle1
+ else:
+ if not grep_str:
+ self.handle.sendline("hosts")
+ self.handle.expect("onos>")
+ else:
+ self.handle.sendline("hosts | grep '"+
+ str(grep_str)+"'")
+ self.handle.expect("onos>")
+ handle = self.handle.before
+ print "handle =",handle
+ return handle
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ main.cleanup()
+ main.exit()
+ except:
+ main.log.info(self.name+" ::::::")
+ main.log.error( traceback.print_exc())
+ main.log.info(self.name+" ::::::")
+ main.cleanup()
+ main.exit()
+
+ def get_host(self, mac):
+ '''
+ Return the first host from the hosts api whose 'id' contains 'mac'
+ Note: mac must be a colon seperated mac address, but could be a partial mac address
+ Return None if there is no match
+ '''
+ import json
+ try:
+ if mac == None:
+ return None
+ else:
+ mac = mac
+ raw_hosts = self.hosts()
+ hosts_json = json.loads(raw_hosts)
+ #search json for the host with mac then return the device
+ for host in hosts_json:
+ print "%s in %s?" % (mac, host['id'])
+ if mac in host['id']:
+ return host
+ return None
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ main.cleanup()
+ main.exit()
+ except:
+ main.log.info(self.name+" ::::::")
+ main.log.error( traceback.print_exc())
+ main.log.info(self.name+" ::::::")
+ main.cleanup()
+ main.exit()
+
def get_hosts_id(self, host_list):
'''
@@ -850,18 +939,24 @@
cmd += " "+str(ingress_device) + "/" + str(port_ingress) + " " +\
str(egress_device) + "/" + str(port_egress)
- self.handle.sendline("")
- self.handle.expect("onos>")
+ print "cmd = ", cmd
+ #self.handle.sendline("")
+ #self.handle.expect("onos>")
self.handle.sendline(cmd)
i = self.handle.expect([
"Error",
"onos>"])
- self.handle.sendline("")
+ self.handle.sendline("intents")
self.handle.expect("onos>")
+ Intenthandle = self.handle.before
+ #print "Intenthandle = ", Intenthandle
- handle = self.handle.before
+ #self.handle.sendline("flows")
+ #self.handle.expect("onos>")
+ #Flowhandle = self.handle.before
+ #print "Flowhandle = ", Flowhandle
if i == 0:
main.log.error("Error in adding point-to-point intent")
@@ -926,7 +1021,6 @@
self.handle.sendline("intents -j")
self.handle.expect("intents -j")
self.handle.expect("onos>")
-
handle = self.handle.before
else:
@@ -935,10 +1029,6 @@
self.handle.sendline("intents")
self.handle.expect("onos>")
-
- self.handle.sendline("")
- self.handle.expect("onos>")
-
handle = self.handle.before
return handle
@@ -955,6 +1045,43 @@
main.cleanup()
main.exit()
+ def flows(self, json_format = False):
+ '''
+ Optional:
+ * json_format: enable output formatting in json
+ Description:
+ Obtain flows currently installed
+ '''
+ try:
+ if json_format:
+ self.handle.sendline("flows -j")
+ self.handle.expect("flows -j")
+ self.handle.expect("onos>")
+ handle = self.handle.before
+
+ else:
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+ self.handle.sendline("flows")
+ self.handle.expect("onos>")
+ handle = self.handle.before
+
+ return handle
+
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ main.cleanup()
+ main.exit()
+ except:
+ main.log.info(self.name+" ::::::")
+ main.log.error( traceback.print_exc())
+ main.log.info(self.name+" ::::::")
+ main.cleanup()
+ main.exit()
+
+
+
def topology_events_metrics(self, json_format=True):
'''
Description:Returns topology metrics
@@ -1160,4 +1287,65 @@
main.cleanup()
main.exit()
+ def check_status(self, ip, numoswitch, numolink, log_level="info"):
+ '''
+ Checks the number of swithes & links that ONOS sees against the
+ supplied values. By default this will report to main.log, but the
+ log level can be specifid.
+
+ Params: ip = ip used for the onos cli
+ numoswitch = expected number of switches
+ numlink = expected number of links
+ log_level = level to log to. Currently accepts 'info', 'warn' and 'report'
+
+
+ log_level can
+
+ Returns: main.TRUE if the number of switchs and links are correct,
+ main.FALSE if the numer of switches and links is incorrect,
+ and main.ERROR otherwise
+ '''
+
+ try:
+ topology = self.get_topology(ip)
+ if topology == {}:
+ return main.ERROR
+ output = ""
+ #Is the number of switches is what we expected
+ devices = topology.get('devices',False)
+ links = topology.get('links',False)
+ if devices == False or links == False:
+ return main.ERROR
+ switch_check = ( int(devices) == int(numoswitch) )
+ #Is the number of links is what we expected
+ link_check = ( int(links) == int(numolink) )
+ if (switch_check and link_check):
+ #We expected the correct numbers
+ output = output + "The number of links and switches match "\
+ + "what was expected"
+ result = main.TRUE
+ else:
+ output = output + \
+ "The number of links and switches does not match what was expected"
+ result = main.FALSE
+ output = output + "\n ONOS sees %i devices (%i expected) and %i links (%i expected)"\
+ % ( int(devices), int(numoswitch), int(links), int(numolink) )
+ if log_level == "report":
+ main.log.report(output)
+ elif log_level == "warn":
+ main.log.warn(output)
+ else:
+ main.log.info(output)
+ return result
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ main.cleanup()
+ main.exit()
+ except:
+ main.log.info(self.name+" ::::::")
+ main.log.error( traceback.print_exc())
+ main.log.info(self.name+" ::::::")
+ main.cleanup()
+ main.exit()
#***********************************
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 5d56863..a31e946 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -366,10 +366,14 @@
self.handle.sendline("export TERM=xterm-256color")
self.handle.expect("xterm-256color")
self.handle.expect("\$")
- self.handle.sendline("cd " + self.home + "; git log -1 --pretty=fuller --decorate=short | grep -A 5 \"commit\" --color=never; cd \.\.")
- self.handle.expect("cd ..")
+ self.handle.sendline("\n")
+ self.handle.expect("\$")
+ self.handle.sendline("cd " + self.home + "; git log -1 --pretty=fuller --decorate=short | grep -A 6 \"commit\" --color=never")
+ self.handle.expect("--color=never")
self.handle.expect("\$")
response=(self.name +": \n"+ str(self.handle.before + self.handle.after))
+ self.handle.sendline("cd " + self.home)
+ self.handle.expect("\$")
lines=response.splitlines()
for line in lines:
print line
@@ -580,19 +584,22 @@
self.handle.sendline("onos -w " + ONOS_ip + " " + cmdstr)
self.handle.expect("\$")
- handle_before = str(self.handle.before)
+ handle_before = self.handle.before
+ print "handle_before = ", self.handle.before
handle_after = str(self.handle.after)
- self.handle.sendline("")
- self.handle.expect("\$")
- handle_more = str(self.handle.before)
+ #self.handle.sendline("")
+ #self.handle.expect("\$")
+ #handle_more = str(self.handle.before)
main.log.info("Command sent successfully")
#Obtain return handle that consists of result from
#the onos command. The string may need to be
#configured further.
- return_string = handle_before + handle_after + handle_more
+ #return_string = handle_before + handle_after
+ return_string = handle_before
+ print "return_string = ", return_string
return return_string
except pexpect.EOF:
@@ -630,10 +637,10 @@
main.log.warn("Network is unreachable")
return main.FALSE
elif i == 1:
- main.log.info("ONOS was installed on the VM and started")
+ main.log.info("ONOS was installed on " + node + " and started")
return main.TRUE
elif i == 2:
- main.log.info("Installation of ONOS on the VM timed out")
+ main.log.info("Installation of ONOS on " + node + " timed out")
return main.FALSE
except pexpect.EOF:
@@ -870,7 +877,7 @@
main.exit()
- def get_topology(self, ip):
+ def get_topology(self,topology_output):
'''
parses the onos:topology output
Returns: a topology dict populated by the key values found in
@@ -879,32 +886,32 @@
try:
#call the cli to get the topology summary
- cmdstr = "onos:topology"
- cli_result = self.onos_cli(ip, cmdstr)
-
+ #cmdstr = "onos:topology"
+ #cli_result = self.onos_cli(ip, cmdstr)
+ #print "cli_result = ", cli_result
#Parse the output
topology = {}
#for line in cli_result.split("\n"):
- for line in cli_result.splitlines():
+ for line in topology_output.splitlines():
if not line.startswith("time="):
continue
#else
print line
for var in line.split(","):
- print "'"+var+"'"
- print "'"+var.strip()+"'"
+ #print "'"+var+"'"
+ #print "'"+var.strip()+"'"
key, value = var.strip().split("=")
topology[key] = value
- print topology
+ print "topology = ", topology
devices = topology.get('devices', False)
- print devices
+ print "devices = ", devices
links = topology.get('links', False)
- print links
+ print "links = ", links
clusters = topology.get('clusters', False)
- print clusters
+ print "clusters = ", clusters
paths = topology.get('paths', False)
- print paths
+ print "paths = ", paths
return topology
except pexpect.EOF:
@@ -918,8 +925,10 @@
main.log.info(self.name+" ::::::")
main.cleanup()
main.exit()
+
+
- def check_status(self, ip, numoswitch, numolink, log_level="info"):
+ def check_status(self, topology_result, numoswitch, numolink, log_level="info"):
'''
Checks the number of swithes & links that ONOS sees against the
supplied values. By default this will report to main.log, but the
@@ -939,7 +948,7 @@
'''
try:
- topology = self.get_topology(ip)
+ topology = self.get_topology(topology_result)
if topology == {}:
return main.ERROR
output = ""
@@ -981,6 +990,7 @@
main.cleanup()
main.exit()
+
def tshark_grep(self, grep, directory, interface='eth0'):
'''
Required:
diff --git a/TestON/tests/FuncNext/FuncNext.params b/TestON/tests/FuncNext/FuncNext.params
new file mode 100755
index 0000000..34d8a56
--- /dev/null
+++ b/TestON/tests/FuncNext/FuncNext.params
@@ -0,0 +1,43 @@
+<PARAMS>
+
+ <testcases>1,4,5,7,3</testcases>
+
+ #Environment variables
+ <ENV>
+ <cellName>driver_test</cellName>
+ </ENV>
+
+ <CTRL>
+ <ip1>10.128.60.11</ip1>
+ <port1>6633</port1>
+ </CTRL>
+
+ <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>
+
+ <timers>
+ <LinkDiscovery>5</LinkDiscovery>
+ <SwitchDiscovery>31</SwitchDiscovery>
+ </timers>
+
+</PARAMS>
diff --git a/TestON/tests/FuncNext/FuncNext.py b/TestON/tests/FuncNext/FuncNext.py
new file mode 100755
index 0000000..36e0376
--- /dev/null
+++ b/TestON/tests/FuncNext/FuncNext.py
@@ -0,0 +1,606 @@
+
+#Testing the basic functionality of ONOS Next
+#For sanity and driver functionality excercises only.
+
+import time
+import sys
+import os
+import re
+import time
+import json
+
+time.sleep(1)
+class FuncNext:
+ def __init__(self):
+ self.default = ''
+
+ def CASE1(self, main):
+ '''
+ Startup sequence:
+ git pull
+ mvn clean install
+ onos-package
+ cell <name>
+ onos-verify-cell
+ onos-install -f
+ onos-wait-for-start
+ '''
+
+ cell_name = main.params['ENV']['cellName']
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_port = main.params['CTRL']['port1']
+
+ main.case("Setting up test environment")
+
+ main.step("Git checkout and pull master and get version")
+ main.ONOSbench.git_checkout("master")
+ git_pull_result = main.ONOSbench.git_pull()
+ print "git_pull_result = ", git_pull_result
+ version_result = main.ONOSbench.get_version()
+
+ main.step("Using mvn clean & install")
+ #clean_install_result = main.ONOSbench.clean_install()
+ #clean_install_result = main.TRUE
+
+ main.step("Applying cell variable to environment")
+ cell_result1 = main.ONOSbench.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+ cell_result2 = main.ONOS2.set_cell(cell_name)
+ #verify_result = main.ONOS2.verify_cell()
+ main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+
+ cell_result = cell_result1 and cell_result2
+
+ main.step("Creating ONOS package")
+ package_result = main.ONOSbench.onos_package()
+
+ #main.step("Creating a cell")
+ #cell_create_result = main.ONOSbench.create_cell_file(**************)
+
+ main.step("Installing ONOS package")
+ onos_install_result = main.ONOSbench.onos_install()
+ onos1_isup = main.ONOSbench.isup()
+
+ main.step("Starting ONOS service")
+ start_result = main.ONOSbench.onos_start(ONOS1_ip)
+
+ case1_result = (package_result and\
+ cell_result and verify_result and onos_install_result and\
+ onos1_isup and start_result )
+ utilities.assert_equals(expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful")
+
+ def CASE11(self, main):
+ '''
+ Cleanup sequence:
+ onos-service <node_ip> stop
+ onos-uninstall
+
+ TODO: Define rest of cleanup
+
+ '''
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+
+ main.case("Cleaning up test environment")
+
+ main.step("Testing ONOS kill function")
+ kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
+
+ main.step("Stopping ONOS service")
+ stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
+
+ main.step("Uninstalling ONOS service")
+ uninstall_result = main.ONOSbench.onos_uninstall()
+
+ def CASE3(self, main):
+ '''
+ Test 'onos' command and its functionality in driver
+ '''
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+
+ main.case("Testing 'onos' command")
+
+ main.step("Sending command 'onos -w <onos-ip> system:name'")
+ cmdstr1 = "system:name"
+ cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
+ main.log.info("onos command returned: "+cmd_result1)
+
+ main.step("Sending command 'onos -w <onos-ip> onos:topology'")
+ cmdstr2 = "onos:topology"
+ cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
+ main.log.info("onos command returned: "+cmd_result2)
+
+
+
+ def CASE4(self, main):
+ import re
+ import time
+ main.case("Pingall Test")
+ main.step("Assigning switches to controllers")
+ for i in range(1,29):
+ if i ==1:
+ main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+ elif i>=2 and i<5:
+ main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+ elif i>=5 and i<8:
+ main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+ elif i>=8 and i<18:
+ main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+ elif i>=18 and i<28:
+ main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+ else:
+ main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+ Switch_Mastership = main.TRUE
+ for i in range (1,29):
+ if i==1:
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ print("Response is " + str(response))
+ if re.search("tcp:"+ONOS1_ip,response):
+ Switch_Mastership = Switch_Mastership and main.TRUE
+ else:
+ Switch_Mastership = main.FALSE
+ elif i>=2 and i<5:
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ print("Response is " + str(response))
+ if re.search("tcp:"+ONOS1_ip,response):
+ Switch_Mastership = Switch_Mastership and main.TRUE
+ else:
+ Switch_Mastership = main.FALSE
+ elif i>=5 and i<8:
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ print("Response is " + str(response))
+ if re.search("tcp:"+ONOS1_ip,response):
+ Switch_Mastership = Switch_Mastership and main.TRUE
+ else:
+ Switch_Mastership = main.FALSE
+ elif i>=8 and i<18:
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ print("Response is " + str(response))
+ if re.search("tcp:"+ONOS1_ip,response):
+ Switch_Mastership = Switch_Mastership and main.TRUE
+ else:
+ Switch_Mastership = main.FALSE
+ elif i>=18 and i<28:
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ print("Response is " + str(response))
+ if re.search("tcp:"+ONOS1_ip,response):
+ Switch_Mastership = Switch_Mastership and main.TRUE
+ else:
+ Switch_Mastership = main.FALSE
+ else:
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ print("Response is" + str(response))
+ if re.search("tcp:" +ONOS1_ip,response):
+ Switch_Mastership = Switch_Mastership and main.TRUE
+ else:
+ Switch_Mastership = main.FALSE
+
+ if Switch_Mastership == main.TRUE:
+ main.log.report("MasterControllers assigned correctly")
+ utilities.assert_equals(expect = main.TRUE,actual=Switch_Mastership,
+ onpass="MasterControllers assigned correctly")
+ '''
+ for i in range (1,29):
+ main.Mininet1.assign_sw_controller(sw=str(i),count=5,
+ ip1=ONOS1_ip,port1=ONOS1_port,
+ ip2=ONOS2_ip,port2=ONOS2_port,
+ ip3=ONOS3_ip,port3=ONOS3_port,
+ ip4=ONOS4_ip,port4=ONOS4_port,
+ ip5=ONOS5_ip,port5=ONOS5_port)
+ '''
+ #REACTIVE FWD test
+
+ main.step("Get list of hosts from Mininet")
+ host_list = main.Mininet1.get_hosts()
+ main.log.info(host_list)
+
+ main.step("Get host list in ONOS format")
+ host_onos_list = main.ONOS2.get_hosts_id(host_list)
+ main.log.info(host_onos_list)
+ #time.sleep(5)
+
+ #We must use ping from hosts we want to add intents from
+ #to make the hosts talk
+ #main.Mininet2.handle.sendline("\r")
+ #main.Mininet2.handle.sendline("h4 ping 10.1.1.1 -c 1 -W 1")
+ #time.sleep(3)
+ #main.Mininet2.handle.sendline("h5 ping 10.1.1.1 -c 1 -W 1")
+ #time.sleep(5)
+
+ main.step("Pingall")
+ ping_result = main.FALSE
+ while ping_result == main.FALSE:
+ time1 = time.time()
+ ping_result = main.Mininet1.pingall()
+ time2 = time.time()
+ print "Time for pingall: %2f seconds" % (time2 - time1)
+
+ #Start onos cli again because u might have dropped out of onos prompt to the shell prompt
+ #if there was no activity
+ main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+
+ main.step("Get hosts")
+ main.ONOS2.handle.sendline("hosts")
+ main.ONOS2.handle.expect("onos>")
+ hosts = main.ONOS2.handle.before
+ main.log.info(hosts)
+
+ main.step("Get all devices id")
+ devices_id_list = main.ONOS2.get_all_devices_id()
+ main.log.info(devices_id_list)
+
+ #ONOS displays the hosts in hex format unlike mininet which does in decimal format
+ #So take care while adding intents
+
+ main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
+ hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
+ hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
+ hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
+ hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
+ hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
+ hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
+ hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
+ hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
+ hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
+ hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
+
+
+
+ print "_____________________________________________________________________________________"
+
+ main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008", 1, "of:0000000000006018", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018", 1, "of:0000000000003008", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009", 1, "of:0000000000006019", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019", 1, "of:0000000000003009", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010", 1, "of:0000000000006020", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020", 1, "of:0000000000003010", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011", 1, "of:0000000000006021", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021", 1, "of:0000000000003011", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012", 1, "of:0000000000006022", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022", 1, "of:0000000000003012", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013", 1, "of:0000000000006023", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023", 1, "of:0000000000003013", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014", 1, "of:0000000000006024", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024", 1, "of:0000000000003014", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015", 1, "of:0000000000006025", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025", 1, "of:0000000000003015", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016", 1, "of:0000000000006026", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026", 1, "of:0000000000003016", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017", 1, "of:0000000000006027", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027", 1, "of:0000000000003017", 1)
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS2.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ print("_______________________________________________________________________________________")
+
+ #Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
+ main.log.info("onos-app-fwd uninstalled")
+
+ #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+ #So sleep for 15s
+ time.sleep(15)
+
+ flowHandle = main.ONOS2.flows()
+ print "flowHandle = ", flowHandle
+
+ count = 1
+ i = 8
+ Ping_Result = main.TRUE
+ #while i<10:
+ while i <18 :
+ main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+ if ping == main.FALSE and count <5:
+ count+=1
+ i = 8
+ Ping_Result = main.FALSE
+ main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
+ time.sleep(2)
+ elif ping==main.FALSE:
+ main.log.report("All ping attempts have failed")
+ i=19
+ Ping_Result = main.FALSE
+ elif ping==main.TRUE:
+ main.log.info("Ping test passed!")
+ i+=1
+ Ping_Result = main.TRUE
+ else:
+ main.log.info("Unknown error")
+ Ping_Result = main.ERROR
+ if Ping_Result==main.FALSE:
+ main.log.report("Intents have not ben installed correctly. Cleaning up")
+ #main.cleanup()
+ #main.exit()
+ if Ping_Result==main.TRUE:
+ main.log.report("Intents have been installed correctly")
+
+ case4_result = Switch_Mastership and Ping_Result
+ utilities.assert_equals(expect=main.TRUE, actual=case4_result,
+ onpass="Pingall Test successful",
+ onfail="Pingall Test NOT successful")
+
+ def CASE5(self,main) :
+ import json
+ from subprocess import Popen, PIPE
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+ #main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ deviceResult = main.ONOS2.devices()
+ linksResult = main.ONOS2.links()
+ portsResult = main.ONOS2.ports()
+ print "**************"
+ 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)
+
+ main.step("Create TestONTopology object")
+ global ctrls
+ 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
+ global MNTopo
+ Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+ MNTopo = Topo
+
+ Topology_Check = main.TRUE
+ main.step("Compare ONOS Topology to MN Topology")
+ devices_json = main.ONOS2.devices()
+ links_json = main.ONOS2.links()
+ ports_json = main.ONOS2.ports()
+ print "devices_json= ", devices_json
+
+ result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
+ print "***********************"
+ result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
+ print "***********************"
+ result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
+
+ result = result1 and result2 and result3
+ print "***********************"
+ if result == main.TRUE:
+ main.log.report("ONOS"+ " Topology matches MN Topology")
+ utilities.assert_equals(expect=main.TRUE,actual=result,
+ onpass="ONOS" + " Topology matches MN Topology",
+ onfail="ONOS" + " Topology does not match MN Topology")
+ Topology_Check = Topology_Check and result
+ utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
+ onpass="Topology checks passed", onfail="Topology checks failed")
+
+
+ def CASE7 (self,main):
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+
+ link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+ main.log.report("Killing a link to ensure that link discovery is consistent")
+ main.case("Killing a link to Ensure that Link Discovery is Working Properly")
+ 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)
+
+
+ main.step("Determine the current number of switches and links")
+ topology_output = main.ONOS2.topology()
+ topology_result = main.ONOS1.get_topology(topology_output)
+ activeSwitches = topology_result['devices']
+ links = topology_result['links']
+ print "activeSwitches = ", type(activeSwitches)
+ print "links = ", type(links)
+ main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
+
+ main.step("Kill Link between s3 and s28")
+ main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
+ time.sleep(link_sleep)
+ topology_output = main.ONOS2.topology()
+ Link_Down = main.ONOS1.check_status(topology_output,activeSwitches,str(int(links)-2))
+ if Link_Down == main.TRUE:
+ main.log.report("Link Down discovered properly")
+ utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
+
+ main.step("Bring link between s3 and s28 back up")
+ Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
+ time.sleep(link_sleep)
+ topology_output = main.ONOS2.topology()
+ Link_Up = main.ONOS1.check_status(topology_output,activeSwitches,str(links))
+ if Link_Up == main.TRUE:
+ main.log.report("Link up discovered properly")
+ utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
+
+
+
+
+ main.step("Compare ONOS Topology to MN Topology")
+ Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+ MNTopo = Topo
+ Topology_Check = main.TRUE
+ devices_json = main.ONOS2.devices()
+ links_json = main.ONOS2.links()
+ ports_json = main.ONOS2.ports()
+ print "devices_json= ", devices_json
+
+ result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
+ print "***********************"
+ result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
+ print "***********************"
+ result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
+
+ result = result1 and result2 and result3
+ print "***********************"
+ if result == main.TRUE:
+ main.log.report("ONOS"+ " Topology matches MN Topology")
+ utilities.assert_equals(expect=main.TRUE,actual=result,
+ onpass="ONOS" + " Topology matches MN Topology",
+ onfail="ONOS" + " Topology does not match MN Topology")
+ Topology_Check = Topology_Check and result
+ utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
+ onpass="Topology checks passed", onfail="Topology checks failed")
+
+ result = Link_Down and Link_Up and Topology_Check
+ utilities.assert_equals(expect=main.TRUE,actual=result,
+ onpass="Link failure is discovered correctly",
+ onfail="Link Discovery failed")
+
+
+
diff --git a/TestON/tests/FuncNext/FuncNext.topo b/TestON/tests/FuncNext/FuncNext.topo
new file mode 100755
index 0000000..444c605
--- /dev/null
+++ b/TestON/tests/FuncNext/FuncNext.topo
@@ -0,0 +1,61 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.60.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1>
+ <host>10.128.60.10</host>
+ <user>sdn</user>
+ <password>sdn</password>
+ <type>OnosDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.60.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <Mininet1>
+ <host>10.128.9.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> --switch ovs,protocols=OpenFlow10 </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.128.9.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> --switch ovs,protocols=OpenFlow10 </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet2>
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/FuncNext/__init__.py b/TestON/tests/FuncNext/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FuncNext/__init__.py
diff --git a/TestON/tests/JonTest/JonTest.params b/TestON/tests/JonTest/JonTest.params
new file mode 100755
index 0000000..f0b64a5
--- /dev/null
+++ b/TestON/tests/JonTest/JonTest.params
@@ -0,0 +1,18 @@
+<PARAMS>
+
+ <testcases>1,4,3,7</testcases>
+
+ <Git>True</Git>
+ #Environment variables
+ <ENV>
+ <cellName>multi</cellName>
+ </ENV>
+
+ <CTRL>
+ <ip1>10.128.30.11</ip1>
+ <port1>6633</port1>
+ <ip2>10.128.30.12</ip2>
+ <port2>6633</port2>
+ </CTRL>
+
+</PARAMS>
diff --git a/TestON/tests/JonTest/JonTest.py b/TestON/tests/JonTest/JonTest.py
new file mode 100755
index 0000000..5ed17db
--- /dev/null
+++ b/TestON/tests/JonTest/JonTest.py
@@ -0,0 +1,376 @@
+
+#Testing the basic functionality of ONOS Next
+#For sanity and driver functionality excercises only.
+
+import time
+import sys
+import os
+import re
+
+class JonTest:
+ def __init__(self):
+ self.default = ''
+
+ def CASE1(self, main):
+ '''
+ Startup sequence:
+ git pull
+ mvn clean install
+ onos-package
+ cell <name>
+ onos-verify-cell
+ onos-install -f
+ onos-wait-for-start
+ '''
+ import time
+
+ PULL_CODE = False
+ if main.params['Git'] == 'True':
+ PULL_CODE = True
+ cell_name = main.params['ENV']['cellName']
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_port = main.params['CTRL']['port1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS2_port = main.params['CTRL']['port2']
+
+ main.case("Setting up test environment")
+
+ main.step("Applying cell variable to environment")
+ cell_result = main.ONOSbench.set_cell(cell_name)
+ #cell_result = main.ONOSbench.set_cell("temp_cell_2")
+ verify_result = main.ONOSbench.verify_cell()
+
+ if PULL_CODE:
+ main.step("Git checkout and pull master")
+ #main.log.report("Skipping git pull")
+ main.ONOSbench.git_checkout("master")
+ git_pull_result = main.ONOSbench.git_pull()
+ main.log.report(main.ONOSbench.get_version())
+
+ main.step("Using mvn clean & install")
+ clean_install_result = main.FALSE
+ if git_pull_result:
+ clean_install_result = main.ONOSbench.clean_install()
+ else:
+ main.log.report("git pull failed so skipping mvn clean install")
+
+ main.step("Creating ONOS package")
+ package_result = main.ONOSbench.onos_package()
+
+ main.step("Installing ONOS package")
+ onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
+ onos2_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS2_ip)
+ onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+ onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+
+ main.step("Starting ONOS service")
+ start_result = main.TRUE
+ #start_result = main.ONOSbench.onos_start(ONOS1_ip)
+
+ case1_result = (clean_install_result and package_result and\
+ cell_result and verify_result and onos1_install_result and\
+ onos2_install_result and onos1_isup and onos2_isup )
+ utilities.assert_equals(expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful")
+
+
+ def CASE11(self, main):
+ '''
+ Cleanup sequence:
+ onos-service <node_ip> stop
+ onos-uninstall
+
+ TODO: Define rest of cleanup
+
+ '''
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+
+ main.case("Cleaning up test environment")
+
+ main.step("Testing ONOS kill function")
+ kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
+
+ main.step("Stopping ONOS service")
+ stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
+
+ main.step("Uninstalling ONOS service")
+ uninstall_result = main.ONOSbench.onos_uninstall()
+
+ def CASE3(self, main):
+ '''
+ Test 'onos' command and its functionality in driver
+ '''
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+
+ main.case("Testing 'onos' command")
+
+ main.step("Sending command 'onos -w <onos-ip> system:name'")
+ cmdstr1 = "system:name"
+ cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
+ main.log.info("onos command returned: "+cmd_result1)
+
+ main.step("Sending command 'onos -w <onos-ip> onos:topology'")
+ cmdstr2 = "onos:topology"
+ cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
+ main.log.info("onos command returned: "+cmd_result2)
+
+ main.step("Testing check_status")
+ check_status_results = main.FALSE
+ check_status_results = main.ONOSbench.check_status(ONOS1_ip, 4, 6)
+ main.log.info("Results of check_status " + str(check_status_results))
+
+ main.step("Sending command 'onos -w <onos-ip> bundle:list'")
+ cmdstr3 = "bundle:list"
+ cmd_result3 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr3)
+ main.log.info("onos command returned: "+cmd_result3)
+ case3_result = (cmd_result1 and cmd_result2 and\
+ check_status_results and cmd_result3 )
+ utilities.assert_equals(expect=main.TRUE, actual=case3_result,
+ onpass="Test case 3 successful",
+ onfail="Test case 3 NOT successful")
+
+ def CASE4(self, main):
+ import re
+ import time
+ main.case("Pingall Test(No intents are added)")
+ main.step("Assigning switches to controllers")
+ for i in range(1,5): #1 to (num of switches +1)
+ main.Mininet1.assign_sw_controller(sw=str(i),count=2,
+ ip1=ONOS1_ip, port1=ONOS1_port,
+ ip2=ONOS2_ip, port2=ONOS2_port)
+
+ switch_mastership = main.TRUE
+ for i in range (1,5):
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ print("Response is " + str(response))
+ if re.search("tcp:"+ONOS1_ip,response):
+ switch_mastership = switch_mastership and main.TRUE
+ else:
+ switch_mastership = main.FALSE
+
+
+ #REACTIVE FWD test
+ main.step("Pingall")
+ ping_result = main.FALSE
+ time1 = time.time()
+ ping_result = main.Mininet1.pingall()
+ time2 = time.time()
+ print "Time for pingall: %2f seconds" % (time2 - time1)
+
+ case4_result = switch_mastership and ping_result
+ utilities.assert_equals(expect=main.TRUE, actual=case4_result,
+ onpass="Pingall Test successful",
+ onfail="Pingall Test NOT successful")
+
+ def CASE5(self, main):
+ '''
+ Test the ONOS-cli functionality
+
+ Below are demonstrations of what the
+ ONOS cli driver functions can be used for.
+ '''
+ import time
+ import json
+
+ cell_name = main.params['ENV']['cellName']
+ ONOS1_ip = main.params['CTRL']['ip1']
+
+ main.case("Testing the ONOS-cli")
+
+ main.step("Set cell for ONOS-cli environment")
+ main.ONOScli.set_cell(cell_name)
+
+ main.step("Start ONOS-cli")
+ main.ONOScli.start_onos_cli(ONOS1_ip)
+
+ main.step("issue command: onos:topology")
+ topology_obj = main.ONOScli.topology()
+
+ main.step("issue various feature:install <str> commands")
+ #main.ONOScli.feature_install("onos-app-fwd")
+ #main.ONOScli.feature_install("onos-rest")
+
+ main.step("Add a bad node")
+ node_result = main.ONOScli.add_node("111", "10.128.20.")
+ if node_result == main.TRUE:
+ main.log.info("Node successfully added")
+
+ main.step("Add a correct node")
+ node_result = main.ONOScli.add_node("111", "10.128.20.12")
+
+ main.step("Assign switches and list devices")
+ for i in range(1,8):
+ main.Mininet1.handle.sendline("sh ovs-vsctl set-controller s"+str(i)+
+ " tcp:10.128.20.11")
+ main.Mininet1.handle.expect("mininet>")
+ #Need to sleep to allow switch add processing
+ time.sleep(5)
+ list_result = main.ONOScli.devices()
+ main.log.info(list_result)
+
+ main.step("Get all devices id")
+ devices_id_list = main.ONOScli.get_all_devices_id()
+ main.log.info(devices_id_list)
+
+ main.step("Get path and cost between device 1 and 7")
+ (path, cost) = main.ONOScli.paths(devices_id_list[0], devices_id_list[6])
+ main.log.info("Path: "+str(path))
+ main.log.info("Cost: "+str(cost))
+
+ main.step("Get nodes currently visible")
+ nodes_str = main.ONOScli.nodes()
+ main.log.info(nodes_str)
+
+ main.step("Get all nodes id's")
+ node_id_list = main.ONOScli.get_all_nodes_id()
+ main.log.info(node_id_list)
+
+ main.step("Set device "+str(devices_id_list[0])+" to role: standby")
+ device_role_result = main.ONOScli.device_role(
+ devices_id_list[0], node_id_list[0], "standby")
+ if device_role_result == main.TRUE:
+ main.log.report("Device role successfully set")
+
+ main.step("Revert device role to master")
+ device_role = main.ONOScli.device_role(
+ devices_id_list[0], node_id_list[0], "master")
+
+ main.step("Check devices / role again")
+ dev_result = main.ONOScli.devices()
+ main.log.info(dev_result)
+
+ #Sample steps to push intents ***********
+ # * Obtain host id in ONOS format
+ # * Push intents
+ main.step("Get list of hosts from Mininet")
+ host_list = main.Mininet2.get_hosts()
+ main.log.info(host_list)
+
+ main.step("Get host list in ONOS format")
+ host_onos_list = main.ONOScli.get_hosts_id(host_list)
+ main.log.info(host_onos_list)
+
+ main.step("Ensure that reactive forwarding is installed")
+ feature_result = main.ONOScli.feature_install("onos-app-fwd")
+
+ time.sleep(5)
+
+ main.Mininet2.handle.sendline("\r")
+ main.Mininet2.handle.sendline("h4 ping h5 -c 1")
+
+ time.sleep(5)
+
+ main.step("Get hosts")
+ main.ONOScli.handle.sendline("hosts")
+ main.ONOScli.handle.expect("onos>")
+ hosts = main.ONOScli.handle.before
+ main.log.info(hosts)
+
+ main.step("Install host-to-host-intents between h4 and h5")
+ intent_install = main.ONOScli.add_host_intent(
+ host_onos_list[3], host_onos_list[4])
+ main.log.info(intent_install)
+
+ main.step("Uninstall reactive forwarding to test host-to-host intent")
+ main.ONOScli.feature_uninstall("onos-app-fwd")
+
+ main.step("Get intents installed on ONOS")
+ get_intent_result = main.ONOScli.intents()
+ main.log.info(get_intent_result)
+ #****************************************
+
+
+ def CASE7(self, main):
+ '''
+ Test compare topo functions
+ '''
+ import sys
+ sys.path.append("/home/admin/sts") # Trying to remove some dependancies, #FIXME add this path to params
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+ import json
+
+ main.step("Create TestONTopology object")
+ 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
+ MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+
+ main.ONOScli1.start_onos_cli(ONOS1_ip)
+ main.ONOScli2.start_onos_cli(ONOS2_ip)
+
+ main.step("Collecting topology information from ONOS")
+ devices1 = main.ONOScli1.devices()
+ devices2 = main.ONOScli2.devices()
+ switch1 = main.ONOScli1.get_device("0000000000000001")
+ hosts1 = main.ONOScli1.hosts()
+ hosts2 = main.ONOScli2.hosts()
+ host1 = main.ONOScli1.get_host("00:00:00:00:00:01")
+ print json.dumps(json.loads(hosts1), sort_keys=True,indent=4,separators=(',', ': '))
+ print json.dumps(json.loads(hosts2), sort_keys=True,indent=4,separators=(',', ': '))
+ print json.dumps(host1, sort_keys=True,indent=4,separators=(',', ': '))
+ ports1 = main.ONOScli1.ports()
+ ports2 = main.ONOScli2.ports()
+ links1 = main.ONOScli1.links()
+ links2 = main.ONOScli2.links()
+
+
+ main.step("Comparing ONOS topology to MN")
+ #results = main.Mininet1.compare_topo(MNTopo, json.loads(devices))
+ switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
+ utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
+ onpass="ONOS1 Switches view is correct",
+ onfail="ONOS1 Switches view is incorrect")
+
+ switches_results2 = main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
+ utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
+ onpass="ONOS2 Switches view is correct",
+ onfail="ONOS2 Switches view is incorrect")
+
+
+ ports_results1 = main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
+ utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
+ onpass="ONOS1 Ports view is correct",
+ onfail="ONOS1 Ports view is incorrect")
+
+ ports_results2 = main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
+ utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
+ onpass="ONOS2 Ports view is correct",
+ onfail="ONOS2 Ports view is incorrect")
+
+ links_results1 = main.Mininet1.compare_links(MNTopo, json.loads(links1))
+ utilities.assert_equals(expect=main.TRUE, actual=links_results1,
+ onpass="ONOS1 Links view is correct",
+ onfail="ONOS1 Links view is incorrect")
+
+ links_results2 = main.Mininet1.compare_links(MNTopo, json.loads(links2))
+ utilities.assert_equals(expect=main.TRUE, actual=links_results2,
+ onpass="ONOS2 Links view is correct",
+ onfail="ONOS2 Links view is incorrect")
+
+ topo_result = switches_results1 and switches_results2 \
+ and ports_results1 and ports_results2\
+ and links_results1 and links_results2
+ utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful")
+
+######
+#jhall@onlab.us
+#andrew@onlab.us
+######
diff --git a/TestON/tests/JonTest/JonTest.topo b/TestON/tests/JonTest/JonTest.topo
new file mode 100755
index 0000000..bf8cb18
--- /dev/null
+++ b/TestON/tests/JonTest/JonTest.topo
@@ -0,0 +1,65 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli2>
+
+ <ONOS1>
+ <host>10.128.30.11</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.30.12</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <Mininet1>
+ <host>10.128.11.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --topo tree,2,3</arg1>
+ <arg2> </arg2>
+ <arg3> </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/JonTest/__init__.py b/TestON/tests/JonTest/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/JonTest/__init__.py