Merge branch 'ONOS-Next' of https://github.com/OPENNETWORKINGLAB/ONLabTest into ONOS-Next
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 1002698..2404a0d 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -448,9 +448,9 @@
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
+ So we take off that escape sequence using
ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
- handle1 = ansi_escape.sub('', handle)
+ handle1 = ansi_escape.sub('', handle)
'''
#print "repr(handle) =", repr(handle)
ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
@@ -466,7 +466,7 @@
str(grep_str)+"'")
self.handle.expect("onos>")
handle = self.handle.before
- print "handle =",handle
+ #print "handle =",handle
return handle
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
@@ -527,7 +527,7 @@
self.handle.sendline("")
self.handle.expect("onos>")
handle = self.handle.before
- print "handle =",handle
+ #print "handle =",handle
return handle
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
@@ -590,7 +590,7 @@
self.handle.sendline("")
self.handle.expect("onos>")
handle = self.handle.before
- print "handle =",handle
+ #print "handle =",handle
return handle
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
@@ -605,39 +605,91 @@
main.exit()
- def device_role(self, device_id, node_id, role):
+ def roles(self, json_format=True, grep_str=""):
'''
- Set device role for specified device and node with role
- Required:
- * device_id : may be obtained by function get_all_devices_id
- * node_id : may be obtained by function get_all_nodes_id
- * role: specify one of the following roles:
- - master
- - standby
- - none
+ Lists all devices and the controllers with roles assigned to them
+ Optional argument:
+ * grep_str - pass in a string to grep
'''
try:
self.handle.sendline("")
self.handle.expect("onos>")
-
- self.handle.sendline("device-role "+
- str(device_id) + " " +
- str(node_id) + " " +
- str(role))
- i = self.handle.expect([
- "Error",
- "onos>"])
- self.handle.sendline("")
- self.handle.expect("onos>")
-
- handle = self.handle.before
+ if json_format:
+ if not grep_str:
+ self.handle.sendline("roles -j")
+ self.handle.expect("roles -j")
+ self.handle.expect("onos>")
+ else:
+ self.handle.sendline("roles -j | grep '"+
+ str(grep_str)+"'")
+ self.handle.expect("roles -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 the following commads:
+ 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
- if i == 0:
- main.log.error("device-role command returned error")
- return handle
else:
- return main.TRUE
+ if not grep_str:
+ self.handle.sendline("roles")
+ self.handle.expect("onos>")
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+ else:
+ self.handle.sendline("roles | grep '"+
+ str(grep_str)+"'")
+ self.handle.expect("onos>")
+ self.handle.sendline("")
+ 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_role(self, device_id):
+ '''
+ Given the a string containing the json representation of the "roles" cli command and a
+ partial or whole device id, returns a json object containing the
+ roles output for the first device whose id contains "device_id"
+
+ Returns:
+ Dict of the role assignments for the given device or
+ None if not match
+ '''
+ try:
+ import json
+ if device_id == None:
+ return None
+ else:
+ raw_roles = self.roles()
+ roles_json = json.loads(raw_roles)
+ #search json for the device with id then return the device
+ for device in roles_json:
+ #print device
+ if str(device_id) in device['id']:
+ return device
+ return None
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
@@ -734,7 +786,7 @@
str(grep_str)+"'")
self.handle.expect("onos>")
handle = self.handle.before
- print "handle =",handle
+ #print "handle =",handle
return handle
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
@@ -764,7 +816,7 @@
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'])
+ #print "%s in %s?" % (mac, host['id'])
if mac in host['id']:
return host
return None
@@ -937,7 +989,7 @@
cmd += " "+str(ingress_device) + "/" + str(port_ingress) + " " +\
str(egress_device) + "/" + str(port_egress)
- print "cmd = ", cmd
+ #print "cmd = ", cmd
#self.handle.sendline("")
#self.handle.expect("onos>")
@@ -1354,21 +1406,32 @@
onos_node is the ip of one of the onos nodes in the cluster
role must be either master, standby, or none
- Returns main.TRUE or main.FALSE based argument varification.
- When device-role supports errors this should be extended to
+ Returns main.TRUE or main.FALSE based argument varification.
+ When device-role supports errors this should be extended to
support that output
'''
- #TODO: handle error messages from device-role
try:
- print "beginning device_role... \n\tdevice_id:" + device_id
- print "\tonos_node: " + onos_node
- print "\trole: "+ role
+ #print "beginning device_role... \n\tdevice_id:" + device_id
+ #print "\tonos_node: " + onos_node
+ #print "\trole: "+ role
if role.lower() == "master" or \
role.lower() == "standby" or \
role.lower() == "none":
self.handle.sendline("")
self.handle.expect("onos>")
- self.handle.sendline("device-role " + device_id + " " + onos_node + " " + role)
+ self.handle.sendline("device-role " +
+ str(device_id) + " " +
+ str(onos_node) + " " +
+ str(role))
+ i= self.handle.expect(["Error","onos>"])
+ if i == 0:
+ output = str(self.handle.before)
+ self.handle.expect("onos>")
+ output = output + str(self.handle.before)
+ main.log.error(self.name + ": " +
+ output + '\033[0m')#end color output to escape any colours from the cli
+ return main.ERROR
+ self.handle.sendline("")
self.handle.expect("onos>")
return main.TRUE
else:
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 43c1c30..4bf6978 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -1025,6 +1025,44 @@
self.handle.sendline("")
main.log.info("Tshark stopped")
+ def ptpd(self, args):
+ '''
+ Initiate ptp with user-specified args.
+ Required:
+ * args: specify string of args after command
+ 'sudo ptpd'
+ '''
+ try:
+ self.handle.sendline("sudo ptpd "+str(args))
+ i = self.handle.expect([
+ "Multiple",
+ "Error",
+ "\$"])
+ self.handle.expect("\$")
+ if i == 0:
+ handle = self.handle.before
+ main.log.info("ptpd returned an error: "+
+ str(handle))
+ return handle
+ elif i == 1:
+ handle = self.handle.before
+ main.log.error("ptpd returned an error: "+
+ str(handle))
+ return handle
+ else:
+ return main.TRUE
+
+ 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/tests/JonTest/JonTest.params b/TestON/tests/JonTest/JonTest.params
index f0b64a5..4bb85e6 100755
--- a/TestON/tests/JonTest/JonTest.params
+++ b/TestON/tests/JonTest/JonTest.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>1,4,3,7</testcases>
+ <testcases>1,4,3,7,8,9,7,8</testcases>
<Git>True</Git>
#Environment variables
diff --git a/TestON/tests/JonTest/JonTest.py b/TestON/tests/JonTest/JonTest.py
index 5ed17db..8e53fd2 100755
--- a/TestON/tests/JonTest/JonTest.py
+++ b/TestON/tests/JonTest/JonTest.py
@@ -49,10 +49,10 @@
main.step("Using mvn clean & install")
clean_install_result = main.FALSE
- if git_pull_result:
+ if git_pull_result == main.TRUE:
clean_install_result = main.ONOSbench.clean_install()
else:
- main.log.report("git pull failed so skipping mvn clean install")
+ main.log.report("did not pull new code so skipping mvn clean install")
main.step("Creating ONOS package")
package_result = main.ONOSbench.onos_package()
@@ -67,6 +67,9 @@
start_result = main.TRUE
#start_result = main.ONOSbench.onos_start(ONOS1_ip)
+ main.ONOScli1.start_onos_cli(ONOS1_ip)
+ main.ONOScli2.start_onos_cli(ONOS2_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 )
@@ -119,7 +122,8 @@
main.step("Testing check_status")
check_status_results = main.FALSE
- check_status_results = main.ONOSbench.check_status(ONOS1_ip, 4, 6)
+ topology_result = main.ONOScli1.topology()
+ check_status_results = main.ONOSbench.check_status(topology_result, 4, 6)
main.log.info("Results of check_status " + str(check_status_results))
main.step("Sending command 'onos -w <onos-ip> bundle:list'")
@@ -311,8 +315,6 @@
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()
@@ -321,9 +323,9 @@
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=(',', ': '))
+ #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()
@@ -370,6 +372,59 @@
onpass="Topology Check Test successful",
onfail="Topology Check Test NOT successful")
+ def CASE8(self, main):
+ '''
+ try doing some role assignments
+ '''
+ import time
+ print main.ONOScli1.devices()
+ print main.ONOScli1.device_role("of:0000000000000001", " ", "none")
+ time.sleep(1)
+ roles = main.ONOScli1.roles()
+ roles2 = main.ONOScli2.roles()
+ print roles
+ print roles2
+ print main.ONOScli1.get_role("00001")
+
+ print main.ONOScli1.devices()
+ print main.ONOScli1.device_role("of:0000000000000001", "10.128.30.11", "master")
+ time.sleep(1)
+ roles = main.ONOScli1.roles()
+ roles2 = main.ONOScli2.roles()
+ print roles
+ print roles2
+ print main.ONOScli1.get_role("00001")
+
+ print main.ONOScli1.devices()
+ print main.ONOScli1.device_role("of:0000000000000001", "10.128.30.11", "standby")
+ time.sleep(1)
+ roles = main.ONOScli1.roles()
+ roles2 = main.ONOScli2.roles()
+ print roles
+ print roles2
+ print main.ONOScli1.get_role("00001")
+
+ print main.ONOScli1.devices()
+ print main.ONOScli1.device_role("of:0000000000000001", "10.128.30.11", "MASTER")
+ time.sleep(1)
+ roles = main.ONOScli1.roles()
+ roles2 = main.ONOScli2.roles()
+ print roles
+ print roles2
+ print main.ONOScli1.get_role("00001")
+ print main.ONOScli1.devices()
+
+ def CASE9(self, main):
+ '''
+ Bring Links down
+ '''
+ main.Mininet1.link(END1="s1", END2="s2", OPTION="down")
+ main.Mininet1.link(END1="s1", END2="s3", OPTION="down")
+ main.Mininet1.link(END1="s1", END2="s4", OPTION="down")
+
+
+
+
######
#jhall@onlab.us
#andrew@onlab.us
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.py b/TestON/tests/TopoPerfNext/TopoPerfNext.py
index e3940f8..5b80b50 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.py
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.py
@@ -832,6 +832,77 @@
# link down discovery. Take timestamp and
# gather list for num_iter
+ def CASE5(self, main):
+ '''
+ 100 Switch discovery latency
+
+ Important:
+ If a simple topology was used in previous cases,
+ you will need to change the topology file in the
+ params for this case to proceed
+ '''
+ import time
+ import subprocess
+ import os
+ import requests
+ import json
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ MN1_ip = main.params['MN']['ip1']
+ ONOS_user = main.params['CTRL']['user']
+
+ default_sw_port = main.params['CTRL']['port1']
+
+ #Number of iterations of case
+ num_iter = main.params['TEST']['numIter']
+
+ #Timestamp 'keys' for json metrics output.
+ #These are subject to change, hence moved into params
+ deviceTimestamp = main.params['JSON']['deviceTimestamp']
+
+ main.case("100 Switch discovery latency")
+ main.step("Assigning all switches to ONOS1")
+ #Assumes that topology consists of 100 switches
+ for i in range(1, 101):
+ main.Mininet1.assign_sw_controller(
+ sw=str(i),
+ ip1=ONOS1_ip,
+ port1=default_sw_port)
+ #Ensure that nodes are configured with ptpd
+ #ONOS1 ptpd is master without NTP
+ ONOS1_ptpd = main.ONOS1.ptpd("-W")
+ ONOS2_ptpd = main.ONOS2.ptpd("-g")
+ ONOS3_ptpd = main.ONOS3.ptpd("-g")
+ os.system("sudo ptpd -g")
+
+ if ONOS1_ptpd == main.TRUE and\
+ ONOS2_ptpd == main.TRUE and\
+ ONOS3_ptpd == main.TRUE:
+ main.log.info("ptpd started on all ONOS instances")
+ else:
+ main.log.info("Check ptpd configuration to ensure"+\
+ " All nodes' system times are in sync")
+
+ for i in range(0, int(num_iter)):
-
-
+ main.step("Set iptables rule to block incoming sw connections")
+ #Set iptables rule to block incoming switch connections
+ main.ONOS1.handle.sendline(
+ "sudo iptables -A INPUT -p tcp -s "+MN_ip+
+ " --dport "+default_sw_port+" -j DROP")
+ main.ONOS1.handle.expect("\$")
+ #Give time to allow rule to take effect
+ time.sleep(10)
+
+ #TODO: Implement iptables to block all switch communication
+ # sudo iptables -A INPUT -p packet_type -s ip_to_block
+ # --dport port_to_block -j rule<DROP>
+ #TODO: Remove all iptables rule quickly (flush)
+ # Before removal, obtain TestON timestamp at which
+ # removal took place (ensuring nodes are configured via ptp)
+ # sudo iptables -F
+
+
+
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.topo b/TestON/tests/TopoPerfNext/TopoPerfNext.topo
index 37ca2f9..5010fcc 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.topo
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.topo
@@ -46,6 +46,24 @@
<COMPONENTS> </COMPONENTS>
</ONOS1>
+ <ONOS2>
+ <host>10.128.174.2</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.174.3</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
<Mininet1>
<host>10.128.10.90</host>
<user>admin</user>
@@ -53,7 +71,7 @@
<type>MininetCliDriver</type>
<connect_order>4</connect_order>
<COMPONENTS>
- <arg1> --custom topo-perf-2sw.py </arg1>
+ <arg1> --custom topo-100sw.py </arg1>
<arg2> --arp --mac --topo mytopo</arg2>
<arg3> </arg3>
<controller> remote </controller>