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 b7e3694..844a127 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -110,6 +110,7 @@
main.log.info(self.name+": Checking reachabilty to the hosts using pingall")
try:
response = self.execute(cmd="pingall",prompt="mininet>",timeout=120)
+ print "response: " + str(response)
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
main.log.error(self.name + ": " + self.handle.before)
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index e89a4fa..05597f5 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -235,10 +235,10 @@
elif i==2:
main.log.info(self.name + ": Git Pull - pulling repository now")
self.handle.expect("ONOS\$", 120)
- return 0
+ return main.TRUE
elif i==3:
main.log.info(self.name + ": Git Pull - Already up to date")
- return 1
+ return main.TRUE
elif i==4:
main.log.info(self.name + ": Git Pull - Aborting... Are there conflicting git files?")
return main.ERROR
@@ -831,7 +831,8 @@
def isup(self, node = ""):
'''
- Run's onos-wait-for-start which only returns once ONOS is at run level 100(ready for use)
+ Run's onos-wait-for-start which only returns once ONOS is at run
+ level 100(ready for use)
Returns: main.TRUE if ONOS is running and main.FALSE on timeout
'''
@@ -862,3 +863,113 @@
main.exit()
+ def get_topology(self, ip):
+ '''
+ parses the onos:topology output
+ Returns: a topology dict populated by the key values found in
+ the cli command.
+ '''
+
+ try:
+ #call the cli to get the topology summary
+ cmdstr = "onos:topology"
+ cli_result = self.onos_cli(ip, cmdstr)
+
+
+ #Parse the output
+ topology = {}
+ #for line in cli_result.split("\n"):
+ for line in cli_result.splitlines():
+ if not line.startswith("time="):
+ continue
+ #else
+ print line
+ for var in line.split(","):
+ print "'"+var+"'"
+ print "'"+var.strip()+"'"
+ key, value = var.strip().split("=")
+ topology[key] = value
+ print topology
+ devices = topology.get('devices', False)
+ print devices
+ links = topology.get('links', False)
+ print links
+ clusters = topology.get('clusters', False)
+ print clusters
+ paths = topology.get('paths', False)
+ print paths
+
+ return topology
+ 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 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/tests/ONOSNextTest/ONOSNextTest.py b/TestON/tests/ONOSNextTest/ONOSNextTest.py
index fcdc28e..baa2c2f 100755
--- a/TestON/tests/ONOSNextTest/ONOSNextTest.py
+++ b/TestON/tests/ONOSNextTest/ONOSNextTest.py
@@ -30,18 +30,6 @@
main.case("Setting up test environment")
- main.step("Git checkout and pull master")
- #main.ONOSbench.git_checkout("master")
- #git_pull_result = main.ONOSbench.git_pull()
-
-
- main.step("Using mvn clean & install")
- #clean_install_result = main.ONOSbench.clean_install()
- clean_install_result = main.TRUE
-
- main.step("Creating ONOS package")
- package_result = main.ONOSbench.onos_package()
-
main.step("Creating cell file")
#params: (bench ip, cell name, mininet ip, *onos ips)
cell_file_result = main.ONOSbench.create_cell_file(
@@ -52,6 +40,18 @@
cell_result = main.ONOSbench.set_cell(cell_name)
verify_result = main.ONOSbench.verify_cell()
+ main.step("Git checkout and pull master")
+ main.ONOSbench.git_checkout("master")
+ git_pull_result = main.ONOSbench.git_pull()
+
+
+ main.step("Using mvn clean & install")
+ clean_install_result = main.ONOSbench.clean_install()
+ #clean_install_result = main.TRUE
+
+ main.step("Creating ONOS package")
+ package_result = main.ONOSbench.onos_package()
+
main.step("Installing ONOS package")
onos_install_result = main.ONOSbench.onos_install()
onos1_isup = main.ONOSbench.isup()
@@ -107,22 +107,31 @@
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.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")
+ main.case("Pingall Test(No intents are added)")
main.step("Assigning switches to controllers")
- for i in range(1,29):
+ for i in range(1,5): #1 to (num of switches +1)
main.Mininet1.assign_sw_controller(sw=str(i),
ip1=ONOS1_ip, port1=ONOS1_port)
switch_mastership = main.TRUE
- for i in range (1,29):
+ 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):