Updated drivers and tests from HA. Changed include:
- onos-check-logs function
- remove some print statements
- create a csv file for jenkin's plugin
- Add timestamp to long pings
- Remove cookies from flow table comparison
- when printing flow tables, check that a correct protocol format is
given
- add cli commands for leadership election sample app
- add command to check that all devices have a masster assigned
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 17c25a0..bf3a2c6 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -1207,7 +1207,7 @@
break
mn_ports.sort(key=float)
onos_ports.sort(key=float)
- #print "\nPorts for Switch %s:" % (switch['name'])
+ #print "\nPorts for Switch %s:" % (mn_switch['name'])
#print "\tmn_ports[] = ", mn_ports
#print "\tonos_ports[] = ", onos_ports
mn_ports_log = mn_ports
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index 1795a16..ae0f599 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -114,7 +114,7 @@
args = utilities.parse_args(["SRC","TARGET","PINGTIME"],**pingParams)
precmd = "sudo rm /tmp/ping." + args["SRC"]
self.execute(cmd=precmd,prompt="(.*)",timeout=10)
- command = "sudo mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -i .2 -w " + str(args['PINGTIME']) + " > /tmp/ping." + args["SRC"] + " &"
+ command = "sudo mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -i .2 -w " + str(args['PINGTIME']) + " -D > /tmp/ping." + args["SRC"] + " &"
main.log.info( command )
self.execute(cmd=command,prompt="(.*)",timeout=10)
self.handle.sendline("")
@@ -372,57 +372,40 @@
def get_flowTable(self, protoVersion, sw):
#TODO document usage
- #FIXME: clean up print statements and such
+ #TODO add option to look at cookies. ignoreing them for now
self.handle.sendline("cd")
self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
- #TODO: Write seperate versions of the function for this, possibly a string that tells it which switch is in use?
- #For 1.0 version of OVS
- #command = "sudo ovs-ofctl dump-flows " + sw + " | awk '{OFS=\",\" ; print $1 $6 $7 }' |sort -n -k1"
- #for 1.3 version of OVS
- #command = "sudo ovs-ofctl dump-flows " + sw + " | awk '{OFS=\",\" ; print $1 $3 $7 $8}' |sort -n -k1"
+ #print "get_flowTable(" + str(protoVersion) +" " + str(sw) +")"
#NOTE: Use format to force consistent flow table output across versions
if protoVersion==1.0:
- command = "sudo ovs-ofctl dump-flows " + sw + " -F OpenFlow10-table_id | awk '{OFS=\",\" ; print $1 $3 $6 $7 $8}' |sort -n -k1"
+ command = "sudo ovs-ofctl dump-flows " + sw + " -F OpenFlow10-table_id | awk '{OFS=\",\" ; print $1 $3 $6 $7 $8}' | cut -d ',' -f 2- | sort -n -k1 -r"
self.handle.sendline(command)
- self.handle.expect(["sort -n -k1",pexpect.EOF,pexpect.TIMEOUT])
+ self.handle.expect(["k1 -r",pexpect.EOF,pexpect.TIMEOUT])
self.handle.expect(["OFPST_FLOW",pexpect.EOF,pexpect.TIMEOUT])
response = self.handle.before
#print "response=", response
return response
elif protoVersion==1.3:
- command = "sudo ovs-ofctl dump-flows " + sw + " -O OpenFlow13 | awk '{OFS=\",\" ; print $1 $3 $6 $7}' |sort -n -k1"
+ command = "sudo ovs-ofctl dump-flows " + sw + " -O OpenFlow13 | awk '{OFS=\",\" ; print $1 $3 $6 $7}' | cut -d ',' -f 2- | sort -n -k1 -r"
self.handle.sendline(command)
- #print "ovs-vsctl Command sent status."
- #self.handle.expect(["sort -n -k1",pexpect.EOF,pexpect.TIMEOUT])
- #print "sort return status: "
- #print self.handle.expect(["sort -n -k1",pexpect.EOF,pexpect.TIMEOUT])
- #print self.handle.before
+ self.handle.expect(["k1 -r",pexpect.EOF,pexpect.TIMEOUT])
self.handle.expect(["OFPST_FLOW",pexpect.EOF,pexpect.TIMEOUT])
- #print "OFPST_FLOW expected status: "
- #print self.handle.expect(["OFPST_FLOW",pexpect.EOF,pexpect.TIMEOUT])
- #print self.handle.before
response = self.handle.before
#print "response=", response
- return response
-
+ return response
+ else:
+ main.log.error("Unknown protoVersion in get_flowTable(). given: ("+str(type(protoVersion))+") '"+str(protoVersion)+"'")
+
def flow_comp(self,flow1,flow2):
- #print "Inside flow compare function"
- #print "Flow1 Table:"
- #for flow in flow1:
- #print flow1
- #print "Flow2 Table"
- #for flow in flow2:
- #print flow2
-
if flow1==flow2:
return main.TRUE
else:
main.log.info("Flow tables do not match, printing tables:")
- #main.log.info("Flow Table 1:")
- #main.log.info(flow1)
- #main.log.info("Flow Table 2:")
- #main.log.info(flow2)
+ main.log.info("Flow Table 1:")
+ main.log.info(flow1)
+ main.log.info("Flow Table 2:")
+ main.log.info(flow2)
return main.FALSE
def setIpTablesOUTPUT(self, dst_ip, dst_port, action='add', packet_type='tcp',rule='DROP'):
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index a6cf341..358945f 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -693,7 +693,38 @@
main.log.info(self.name+" ::::::")
main.cleanup()
main.exit()
-
+
+ def roles_not_null(self):
+ '''
+ Iterates through each device and checks if there is a master assigned
+ Returns: main.TRUE if each device has a master
+ main.FALSE any device has no master
+ '''
+ try:
+ import json
+ 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 device['master'] == "none":
+ main.log.warn("Device has no master: " + str(device) )
+ return main.FALSE
+ 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()
+
+
def paths(self, src_id, dst_id):
'''
Returns string of paths, and the cost.
@@ -1713,7 +1744,7 @@
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.
+ Returns main.TRUE or main.FALSE based on argument verification.
When device-role supports errors this should be extended to
support that output
'''
@@ -1805,5 +1836,115 @@
main.cleanup()
main.exit()
+ def election_test_leader(self):
+ '''
+ * CLI command to get the current leader for the Election test application.
+ #NOTE: Requires installation of the onos-app-election feature
+ Returns: Node IP of the leader if one exists
+ None if none exists
+ Main.FALSE on error
+ '''
+ try:
+ self.handle.sendline("election-test-leader")
+ self.handle.expect("election-test-leader")
+ self.handle.expect("onos>")
+ response = self.handle.before
+ #Leader
+ node_search = re.search("The\scurrent\sleader\sfor\sthe\sElection\sapp\sis\s(?P<node>.+)\.", response)
+ if node_search:
+ node = node_search.group('node')
+ main.log.info("Election-test-leader found " + node + " as the leader")
+ return node
+ #no leader
+ null_search = re.search("There\sis\scurrently\sno\sleader\selected\sfor\sthe\sElection\sapp", response)
+ if null_search:
+ main.log.info("Election-test-leader found no leader")
+ return None
+ #error
+ main.log.error("Error in election_test_leader: unexpected response")
+ main.log.error( repr(response) )
+ return main.FALSE
+
+ 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 election_test_run(self):
+ '''
+ * CLI command to run for leadership of the Election test application.
+ #NOTE: Requires installation of the onos-app-election feature
+ Returns: Main.TRUE on success
+ Main.FALSE on error
+ '''
+ try:
+ self.handle.sendline("election-test-run")
+ self.handle.expect("election-test-run")
+ self.handle.expect("onos>")
+ response = self.handle.before
+ #success
+ search = re.search("Entering\sleadership\selections\sfor\sthe\sElection\sapp.", response)
+ if search:
+ main.log.info("Entering leadership elections for the Election app.")
+ return main.TRUE
+ #error
+ main.log.error("Error in election_test_run: unexpected response")
+ main.log.error( repr(response) )
+ return main.FALSE
+
+ 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 election_test_withdraw(self):
+ '''
+ * CLI command to withdraw the local node from leadership election for
+ * the Election test application.
+ #NOTE: Requires installation of the onos-app-election feature
+ Returns: Main.TRUE on success
+ Main.FALSE on error
+ '''
+ try:
+ self.handle.sendline("election-test-withdraw")
+ self.handle.expect("election-test-withdraw")
+ self.handle.expect("onos>")
+ response = self.handle.before
+ #success
+ search = re.search("Withdrawing\sfrom\sleadership\selections\sfor\sthe\sElection\sapp.", response)
+ if search:
+ main.log.info("Withdrawing from leadership elections for the Election app.")
+ return main.TRUE
+ #error
+ main.log.error("Error in election_test_withdraw: unexpected response")
+ main.log.error( repr(response) )
+ return main.FALSE
+
+
+ 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 418554d..678bae4 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -1072,21 +1072,21 @@
if not line.startswith("time="):
continue
#else
- print line
+ #print line
for var in line.split(","):
#print "'"+var+"'"
#print "'"+var.strip()+"'"
key, value = var.strip().split("=")
topology[key] = value
- print "topology = ", topology
+ #print "topology = ", topology
devices = topology.get('devices', False)
- print "devices = ", devices
+ #print "devices = ", devices
links = topology.get('links', False)
- print "links = ", links
- clusters = topology.get('clusters', False)
- print "clusters = ", clusters
+ #print "links = ", links
+ SCCs = topology.get('SCC(s)', False)
+ #print "SCCs = ", SCCs
paths = topology.get('paths', False)
- print "paths = ", paths
+ #print "paths = ", paths
return topology
except pexpect.EOF:
@@ -1339,3 +1339,26 @@
main.log.error( traceback.print_exc())
main.log.info(self.name+" ::::::")
+ def check_logs(self, onos_ip):
+ '''
+ runs onos-check-logs on the given onos node
+ returns the response
+ '''
+ try:
+ cmd = "onos-check-logs " + str(onos_ip)
+ self.handle.sendline(cmd)
+ self.handle.expect(cmd)
+ self.handle.expect("\$")
+ response = self.handle.before
+ return response
+ except pexpect.EOF:
+ main.log.error("Lost ssh connection")
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ except:
+ main.log.error("Some error in check_logs:")
+ main.log.info(self.name+" ::::::")
+ main.log.error( traceback.print_exc())
+ main.log.info(self.name+" ::::::")
+
+