Merge pull request #120 from pingping-lin/master
update sdn-ip test from onos1.0 to onos1.1
diff --git a/TestON/bin/cli.py b/TestON/bin/cli.py
index 47b027e..ed1c796 100755
--- a/TestON/bin/cli.py
+++ b/TestON/bin/cli.py
@@ -48,11 +48,12 @@
dump = pprint.PrettyPrinter(indent=4)
__builtin__.testthread = False
introduction = "TestON is the testing framework \nDeveloped by Paxterra Solutions (www.paxterrasolutions.com)"
+__builtin__.COLORS = False
path = re.sub("teston$", "", os.getcwd())
sys.path.append(path+"/Core")
sys.path.append("../")
-from core.teston import *
+from core.teston import *
class CLI( threading.Thread,Cmd,object ):
"command-line interface to execute the test."
@@ -61,7 +62,7 @@
def __init__( self, teston, stdin=sys.stdin ):
self.teston = teston
-
+
self._mainevent = threading.Event()
threading.Thread.__init__(self)
self.main_stop = False
@@ -592,6 +593,8 @@
if __name__ == '__main__':
if len(sys.argv) > 1:
+ __builtin__.COLORS = True
CLI("test").onecmd(' '.join(sys.argv[1:]))
else:
+ __builtin__.COLORS = False
CLI("test").cmdloop()
diff --git a/TestON/core/Thread.py b/TestON/core/Thread.py
new file mode 100644
index 0000000..fcc06b5
--- /dev/null
+++ b/TestON/core/Thread.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+import threading
+
+
+class Thread( threading.Thread ):
+ def __init__( self, target=None, threadID=None, name="", args=(),
+ kwargs={} ):
+ super( Thread, self ).__init__()
+ self.threadID = threadID
+ self.name = name
+ self.target = target
+ self.args = args
+ self.kwargs = kwargs
+ self.result = None
+
+ def run( self ):
+ try:
+ if self.target is not None:
+ self.result = self.target( *self.args, **self.kwargs )
+ except Exception as e:
+ print "ThreadID:" + str( self.threadID ) + ", Name:" +\
+ self.name + "- something went wrong with " +\
+ str( self.target.im_class ) + "." +\
+ str( self.target.im_func ) + " method: "
+ print e
diff --git a/TestON/core/iniparser.py b/TestON/core/iniparser.py
index b952f2d..c350a20 100644
--- a/TestON/core/iniparser.py
+++ b/TestON/core/iniparser.py
@@ -48,7 +48,7 @@
try :
parsedInfo = ConfigObj(self.fileName)
return parsedInfo
- except :
+ except Exception:
print "There is no such file to parse "+fileName
else:
return 0
diff --git a/TestON/core/jsonparser.py b/TestON/core/jsonparser.py
index 8726e87..fea797a 100644
--- a/TestON/core/jsonparser.py
+++ b/TestON/core/jsonparser.py
@@ -21,7 +21,6 @@
'''
-import re
import json
class JsonParser:
'''
@@ -37,7 +36,7 @@
response_dict = {}
try :
response_dict = json.loads(json_response)
- except :
+ except Exception:
main.log.error("Json Parser is unable to parse the string")
return response_dict
@@ -50,7 +49,7 @@
json_response = {}
try :
json_response = json.dumps(response_dict)
- except :
+ except Exception:
main.log.error("Json Parser is unable to parse the string")
return json_response
'''
diff --git a/TestON/core/logger.py b/TestON/core/logger.py
index 80fe0de..e77d440 100644
--- a/TestON/core/logger.py
+++ b/TestON/core/logger.py
@@ -1,7 +1,7 @@
#/usr/bin/env python
'''
Created on 07-Jan-2013
-
+
@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
TestON is free software: you can redistribute it and/or modify
@@ -15,7 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
'''
@@ -27,7 +27,7 @@
class Logger:
'''
Add continuous logs and reports of the test.
-
+
@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
'''
def _printHeader(self,main) :
@@ -39,7 +39,7 @@
logmsg = logmsg + "\n\tReport Log File : " + main.ReportFileName + ""
for component in main.componentDictionary.keys():
logmsg = logmsg + "\n\t"+component+" Session Log : " + main.logdir+"/"+component+".session" + ""
-
+
logmsg = logmsg + "\n\tTest Script :" + path + "Tests/" + main.TEST + ".py"+ ""
logmsg = logmsg + "\n\tTest Params : " + path + "Tests/" + main.TEST + ".params" + ""
logmsg = logmsg + "\n\tTopology : " + path + "Tests/" +main.TEST + ".topo" + ""
@@ -49,11 +49,10 @@
values = re.sub("{", "\n\t", values)
values = re.sub("}", "\n\t", values)
logmsg = logmsg + values
-
logmsg = logmsg + "\n\n"+" " * 31+"+---------------+\n" +"-" * 29+" { Components Used } " +"-" * 29+"\n"+" " * 31+"+---------------+\n"
component_list = []
component_list.append(None)
-
+
# Listing the components in the order of test_target component should be first.
if type(main.componentDictionary) == dict:
for key in main.componentDictionary.keys():
@@ -61,64 +60,74 @@
component_list[0] = key+"-Test Target"
else :
component_list.append(key)
-
+
for index in range(len(component_list)) :
if index==0:
if component_list[index]:
logmsg+="\t"+component_list[index]+"\n"
elif index > 0 :
logmsg+="\t"+str(component_list[index])+"\n"
-
-
-
+
logmsg = logmsg + "\n\n"+" " * 30+"+--------+\n" +"-" * 28+" { Topology } "+"-" * 28 +"\n" +" " * 30+"+--------+\n"
values = "\n\t" + str(main.topology['COMPONENT'])
values = re.sub(",", "\n\t", values)
values = re.sub("{", "\n\t", values)
values = re.sub("}", "\n\t", values)
logmsg = logmsg + values
-
logmsg = logmsg + "\n"+"-" * 60+"\n"
-
+
# enter into log file all headers
logfile = open(main.LogFileName,"w+")
logfile.write (logmsg)
print logmsg
main.logHeader = logmsg
-
logfile.close()
-
+
#enter into report file all headers
main.reportFile = open(main.ReportFileName,"w+")
main.reportFile.write(logmsg)
main.reportFile.close()
-
+
+ #Sumamry file header
+ currentTime = str( main.STARTTIME.strftime("%d %b %Y %H:%M:%S") )
+ main.summaryFile = open( main.SummaryFileName, "w+" )
+ main.summaryFile.write( main.TEST + " at " + currentTime + "\n" )
+ main.summaryFile.close()
+
+ #wiki file header
+ currentTime = str( main.STARTTIME.strftime("%d %b %Y %H:%M:%S") )
+ main.wikiFile = open( main.WikiFileName, "w+" )
+ main.wikiFile.write( main.TEST + " at " + currentTime + "<p></p>\n" )
+ main.wikiFile.close()
+
def initlog(self,main):
'''
Initialise all the log handles.
'''
main._getTest()
- main.STARTTIME = datetime.datetime.now()
+ main.STARTTIME = datetime.datetime.now()
currentTime = re.sub("-|\s|:|\.", "_", str(main.STARTTIME.strftime("%d %b %Y %H:%M:%S")))
if main.logdir:
main.logdir = main.logdir+ "/"+main.TEST + "_" + currentTime
else:
main.logdir = main.logs_path + main.TEST + "_" + currentTime
-
+
os.mkdir(main.logdir)
-
+
main.LogFileName = main.logdir + "/" + main.TEST + "_" +str(currentTime) + ".log"
main.ReportFileName = main.logdir + "/" + main.TEST + "_" + str(currentTime) + ".rpt"
+ main.WikiFileName = main.logdir + "/" + main.TEST + "Wiki.txt"
+ main.SummaryFileName = main.logdir + "/" + main.TEST + "Summary.txt"
main.JenkinsCSV = main.logdir + "/" + main.TEST + ".csv"
-
+
#### Add log-level - Report
logging.addLevelName(9, "REPORT")
logging.addLevelName(7, "EXACT")
- logging.addLevelName(10, "CASE")
- logging.addLevelName(11, "STEP")
+ logging.addLevelName(11, "CASE")
+ logging.addLevelName(12, "STEP")
main.log = logging.getLogger(main.TEST)
- def report (msg):
+ def report(msg):
'''
Will append the report message to the logs.
'''
@@ -130,11 +139,32 @@
main.reportFile = open(main.ReportFileName,"a+")
main.reportFile.write(newmsg)
main.reportFile.close()
-
-
- main.log.report = report
-
- def exact (exmsg):
+
+ main.log.report = report
+
+ def summary( msg ):
+ '''
+ Will append the message to the txt file for the summary.
+ '''
+ main.log._log(6,msg,"OpenFlowAutoMattion","OFAutoMation")
+ main.summaryFile = open(main.SummaryFileName,"a+")
+ main.summaryFile.write(msg+"\n")
+ main.summaryFile.close()
+
+ main.log.summary = summary
+
+ def wiki( msg ):
+ '''
+ Will append the message to the txt file for the wiki.
+ '''
+ main.log._log(6,msg,"OpenFlowAutoMattion","OFAutoMation")
+ main.wikiFile = open(main.WikiFileName,"a+")
+ main.wikiFile.write(msg+"\n")
+ main.wikiFile.close()
+
+ main.log.wiki = wiki
+
+ def exact(exmsg):
'''
Will append the raw formatted message to the logs
'''
@@ -146,10 +176,9 @@
logfile.write("\n"+ str(exmsg) +"\n")
logfile.close()
print exmsg
-
- main.log.exact = exact
-
-
+
+ main.log.exact = exact
+
def case(msg):
'''
Format of the case type log defined here.
@@ -161,10 +190,10 @@
logfile.write("\n"+ str(newmsg) +"\n")
logfile.close()
print newmsg
-
+
main.log.case = case
-
- def step (msg):
+
+ def step(msg):
'''
Format of the step type log defined here.
'''
@@ -175,28 +204,57 @@
logfile.write("\n"+ str(newmsg) +"\n")
logfile.close()
print newmsg
-
- main.log.step = step
-
+
+ main.log.step = step
+
main.LogFileHandler = logging.FileHandler(main.LogFileName)
self._printHeader(main)
### initializing logging module and settig log level
main.log.setLevel(logging.INFO)
+ main.log.setLevel(logging.DEBUG) # Temporary
main.LogFileHandler.setLevel(logging.INFO)
-
+
# create console handler with a higher log level
main.ConsoleHandler = logging.StreamHandler()
main.ConsoleHandler.setLevel(logging.INFO)
+ main.ConsoleHandler.setLevel(logging.DEBUG) #Temporary
# create formatter and add it to the handlers
- formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+ #formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+ class MyFormatter( logging.Formatter ):
+ colors = { 'cyan': '\033[96m', 'purple': '\033[95m',
+ 'blue': '\033[94m', 'green': '\033[92m',
+ 'yellow': '\033[93m', 'red': '\033[91m',
+ 'end': '\033[0m' }
+
+ FORMATS = {'DEFAULT': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'}
+ if COLORS: # NOTE:colors will only be loaded if command is run from one line
+ # IE: './cli.py run testname'
+ # This is to prevent issues with Jenkins parsing
+ # TODO: Make colors configurable
+ levels = { logging.ERROR : colors['red'] +
+ FORMATS['DEFAULT'] +
+ colors['end'],
+ logging.WARN : colors['yellow'] +
+ FORMATS['DEFAULT'] +
+ colors['end'],
+ logging.DEBUG : colors['purple'] +
+ FORMATS['DEFAULT'] +
+ colors['end'] }
+ FORMATS.update( levels )
+
+ def format( self, record ):
+ self._fmt = self.FORMATS.get( record.levelno,
+ self.FORMATS[ 'DEFAULT' ] )
+ return logging.Formatter.format( self, record )
+ formatter = MyFormatter()
main.ConsoleHandler.setFormatter(formatter)
main.LogFileHandler.setFormatter(formatter)
# add the handlers to logger
main.log.addHandler(main.ConsoleHandler)
main.log.addHandler(main.LogFileHandler)
-
+
def testSummary(self,main):
'''
testSummary will take care about the Summary of test.
@@ -208,12 +266,10 @@
main.TOTAL_TC_SUCCESS = 0
else:
main.TOTAL_TC_SUCCESS = str((main.TOTAL_TC_PASS*100)/main.TOTAL_TC_RUN)
-
if (main.TOTAL_TC_RUN == 0) :
main.TOTAL_TC_EXECPERCENT = 0
else :
main.TOTAL_TC_EXECPERCENT = str((main.TOTAL_TC_RUN*100)/main.TOTAL_TC_PLANNED)
-
testResult = "\n\n"+"*" * 37+"\n" + "\tTest Execution Summary\n" + "\n"+"*" * 37+" \n"
testResult = testResult + "\n Test Start : " + str(main.STARTTIME.strftime("%d %b %Y %H:%M:%S"))
testResult = testResult + "\n Test End : " + str(main.ENDTIME.strftime("%d %b %Y %H:%M:%S"))
@@ -225,7 +281,7 @@
testResult = testResult + "\n Total No Result : " + str(main.TOTAL_TC_NORESULT)
testResult = testResult + "\n Success Percentage : " + str(main.TOTAL_TC_SUCCESS) + "%"
testResult = testResult + "\n Execution Result : " + str(main.TOTAL_TC_EXECPERCENT) + "%"
-
+
#main.log.report(testResult)
main.testResult = testResult
main.log.exact(testResult)
@@ -237,24 +293,32 @@
logfile.write(",".join( [str(int(main.TOTAL_TC_FAIL)), str(int(main.TOTAL_TC_PASS)), str(int(main.TOTAL_TC_PLANNED))] ))
logfile.close()
-
-
-
def updateCaseResults(self,main):
'''
Update the case result based on the steps execution and asserting each step in the test-case
'''
case = str(main.CurrentTestCaseNumber)
-
- if main.testCaseResult[case] == 2:
+ currentResult = main.testCaseResult.get(case, 2)
+
+ if currentResult == 2:
main.TOTAL_TC_RUN = main.TOTAL_TC_RUN + 1
main.TOTAL_TC_NORESULT = main.TOTAL_TC_NORESULT + 1
main.log.exact("\n "+"*" * 29+"\n" + "\n Result: No Assertion Called \n"+"*" * 29+"\n")
- elif main.testCaseResult[case] == 1:
+ line = "Case "+case+": "+main.CurrentTestCase+" - No Result"
+ elif currentResult == 1:
main.TOTAL_TC_RUN = main.TOTAL_TC_RUN + 1
main.TOTAL_TC_PASS = main.TOTAL_TC_PASS + 1
main.log.exact("\n"+"*" * 29+"\n Result: Pass \n"+"*" * 29+"\n")
- elif main.testCaseResult[case] == 0:
+ line = "Case "+case+": "+main.CurrentTestCase+" - PASS"
+ elif currentResult == 0:
main.TOTAL_TC_RUN = main.TOTAL_TC_RUN + 1
main.TOTAL_TC_FAIL = main.TOTAL_TC_FAIL + 1
main.log.exact("\n"+"*" * 29+"\n Result: Failed \n"+"*" * 29+"\n")
+ line = "Case "+case+": "+main.CurrentTestCase+" - FAIL"
+ else:
+ main.log.error( " Unknown result of case " + case +
+ ". Result was: " + currentResult )
+ line = "Case "+case+": "+main.CurrentTestCase+" - ERROR"
+ main.log.wiki( "<h3>" + line + "</h3>" )
+ main.log.summary( line )
+
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 8934e50..a15bb8c 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
'''
Created on 22-Oct-2012
-
+
@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
@@ -16,7 +16,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
@@ -31,6 +31,7 @@
import __builtin__
import new
import xmldict
+import importlib
module = new.module("test")
import openspeak
global path, drivers_path, core_path, tests_path,logs_path
@@ -46,52 +47,50 @@
sys.path.append(tests_path)
from core.utilities import Utilities
+from core.Thread import Thread
-import logging
-import datetime
-from optparse import OptionParser
class TestON:
'''
-
- TestON will initiate the specified test.
- The main tasks are :
- * Initiate the required Component handles for the test.
+ TestON will initiate the specified test.
+ The main tasks are :
+ * Initiate the required Component handles for the test.
* Create Log file Handles.
-
'''
def __init__(self,options):
'''
Initialise the component handles specified in the topology file of the specified test.
-
'''
# Initialization of the variables.
__builtin__.main = self
-
__builtin__.path = path
__builtin__.utilities = Utilities()
self.TRUE = 1
self.FALSE = 0
self.ERROR = -1
+ self.NORESULT = 2
self.FAIL = False
self.PASS = True
- self.CASERESULT = self.TRUE
+ self.CASERESULT = self.ERROR
+ self.STEPRESULT = self.NORESULT
+ self.stepResults = []
self.init_result = self.TRUE
self.testResult = "Summary"
- self.stepName =""
- self.EXPERIMENTAL_MODE = False
+ self.stepName = ""
+ self.stepCache = ""
+ self.EXPERIMENTAL_MODE = False
self.test_target = None
self.lastcommand = None
- self.testDir = tests_path
- self.configFile = config_path + "teston.cfg"
+ self.testDir = tests_path
+ self.configFile = config_path + "teston.cfg"
self.parsingClass = "xmlparser"
self.parserPath = core_path + "/xmlparser"
self.loggerPath = core_path + "/logger"
self.loggerClass = "Logger"
self.logs_path = logs_path
self.driver = ''
-
-
+ self.Thread = Thread
+
self.configparser()
verifyOptions(options)
load_logger()
@@ -100,18 +99,18 @@
self.driversList=[]
if type(self.componentDictionary) == str :
self.componentDictionary = dict(self.componentDictionary)
-
+
for component in self.componentDictionary :
self.driversList.append(self.componentDictionary[component]['type'])
-
+
self.driversList = list(set(self.driversList)) # Removing duplicates.
# Checking the test_target option set for the component or not
if type(self.componentDictionary) == dict:
for component in self.componentDictionary.keys():
if 'test_target' in self.componentDictionary[component].keys():
self.test_target = component
-
- # Checking for the openspeak file and test script
+
+ # Checking for the openspeak file and test script
self.logger.initlog(self)
# Creating Drivers Handles
@@ -128,7 +127,6 @@
#Ordering components based on the connect order.
ordered_component_list =sorted(components_connect_order, key=lambda key: components_connect_order[key])
print ordered_component_list
-
for component in ordered_component_list:
self.componentInit(component)
@@ -142,28 +140,28 @@
try :
self.configDict = xmldict.xml_to_dict(xml)
return self.configDict
- except :
+ except Exception:
print "There is no such file to parse " + self.configFile
-
+
def componentInit(self,component):
'''
This method will initialize specified component
'''
global driver_options
self.log.info("Creating component Handle: "+component)
- driver_options = {}
+ driver_options = {}
if 'COMPONENTS' in self.componentDictionary[component].keys():
driver_options =dict(self.componentDictionary[component]['COMPONENTS'])
driver_options['name']=component
driverName = self.componentDictionary[component]['type']
driver_options ['type'] = driverName
-
+
classPath = self.getDriverPath(driverName.lower())
- driverModule = __import__(classPath, globals(), locals(), [driverName.lower()], -1)
+ driverModule = importlib.import_module(classPath)
driverClass = getattr(driverModule, driverName)
driverObject = driverClass()
-
+
connect_result = driverObject.connect(user_name = self.componentDictionary[component]['user'] if ('user' in self.componentDictionary[component].keys()) else getpass.getuser(),
ip_address= self.componentDictionary[component]['host'] if ('host' in self.componentDictionary[component].keys()) else 'localhost',
pwd = self.componentDictionary[component]['password'] if ('password' in self.componentDictionary[component].keys()) else 'changeme',
@@ -171,46 +169,49 @@
options = driver_options)
if not connect_result:
self.log.error("Exiting form the test execution because the connecting to the "+component+" component failed.")
- self.exit()
-
+ self.exit()
+
vars(self)[component] = driverObject
-
+
def run(self):
'''
- The Execution of the test script's cases listed in the Test params file will be done here.
- And Update each test case result.
- This method will return TRUE if it executed all the test cases successfully,
+ The Execution of the test script's cases listed in the Test params file will be done here.
+ And Update each test case result.
+ This method will return TRUE if it executed all the test cases successfully,
else will retun FALSE
'''
-
self.testCaseResult = {}
self.TOTAL_TC = 0
self.TOTAL_TC_RUN = 0
- self.TOTAL_TC_PLANNED = 0
+ self.TOTAL_TC_PLANNED = 0
self.TOTAL_TC_NORESULT = 0
self.TOTAL_TC_FAIL = 0
self.TOTAL_TC_PASS = 0
self.TEST_ITERATION = 0
self.stepCount = 0
- self.CASERESULT = self.TRUE
-
- import testparser
+ self.CASERESULT = self.NORESULT
+
+ import testparser
testFile = self.tests_path + "/"+self.TEST + "/"+self.TEST + ".py"
test = testparser.TestParser(testFile)
self.testscript = test.testscript
self.code = test.getStepCode()
- repeat= int(self.params['repeat']) if ('repeat' in self.params) else 1
- main.TOTAL_TC_PLANNED = len(self.testcases_list)*repeat
-
+ repeat= int(self.params['repeat']) if ('repeat' in self.params) else 1
+ self.TOTAL_TC_PLANNED = len(self.testcases_list)*repeat
+
result = self.TRUE
- while(repeat):
+ while(repeat):
for self.CurrentTestCaseNumber in self.testcases_list:
- result = self.runCase(self.CurrentTestCaseNumber)
- repeat-=1
+ result = self.runCase(self.CurrentTestCaseNumber)
+ repeat-=1
return result
-
+
def runCase(self,testCaseNumber):
self.CurrentTestCaseNumber = testCaseNumber
+ self.CurrentTestCase = ""
+ self.stepResults = []
+ self.stepName = ""
+ self.caseExplaination = ""
result = self.TRUE
self.stepCount = 0
self.EXPERIMENTAL_MODE = self.FALSE
@@ -219,34 +220,89 @@
stopped = False
try :
self.stepList = self.code[self.testCaseNumber].keys()
- except KeyError,e:
- main.log.error("There is no Test-Case "+ self.testCaseNumber)
- return main.FALSE
-
+ except KeyError:
+ self.log.error("There is no Test-Case "+ self.testCaseNumber)
+ return self.FALSE
+
self.stepCount = 0
while self.stepCount < len(self.code[self.testCaseNumber].keys()):
result = self.runStep(self.stepList,self.code,self.testCaseNumber)
- if result == main.FALSE:
+ if result == self.FALSE:
break
- elif result == main.TRUE :
+ elif result == self.TRUE:
continue
-
if not stopped :
+ if all( self.TRUE == i for i in self.stepResults ):
+ # ALL PASSED
+ self.CASERESULT = self.TRUE
+ elif self.FALSE in self.stepResults:
+ # AT LEAST ONE FAILED
+ self.CASERESULT = self.FALSE
+ elif self.TRUE in self.stepResults:
+ # AT LEAST ONE PASSED
+ self.CASERESULT = self.TRUE
+ else:
+ self.CASERESULT = self.NORESULT
self.testCaseResult[str(self.CurrentTestCaseNumber)] = self.CASERESULT
self.logger.updateCaseResults(self)
+ self.log.wiki( "<p>" + self.caseExplaination + "</p>" )
+ self.log.summary( self.caseExplaination )
+ self.log.wiki( "<ul>" )
+ for line in self.stepCache.splitlines():
+ if re.search( " - PASS$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"tick\" /></li>\n" )
+ elif re.search( " - FAIL$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"cross\" /></li>\n" )
+ elif re.search( " - No Result$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"warning\" /></li>\n" )
+ self.log.wiki( "</ul>" )
+ self.log.summary( self.stepCache )
+ self.stepCache = ""
return result
-
+
def runStep(self,stepList,code,testCaseNumber):
if not cli.pause:
try :
step = stepList[self.stepCount]
+ self.STEPRESULT = self.NORESULT
exec code[testCaseNumber][step] in module.__dict__
self.stepCount = self.stepCount + 1
+ if step > 0:
+ self.stepCache += "\t"+str(testCaseNumber)+"."+str(step)+" "+self.stepName+" - "
+ if self.STEPRESULT == self.TRUE:
+ self.stepCache += "PASS\n"
+ #self.stepCache += "PASS <ac:emoticon ac:name=\"tick\" /></li>\n"
+ elif self.STEPRESULT == self.FALSE:
+ self.stepCache += "FAIL\n"
+ #self.stepCache += "FAIL <ac:emoticon ac:name=\"cross\" /></li>\n"
+ else:
+ self.stepCache += "No Result\n"
+ #self.stepCache += "No Result <ac:emoticon ac:name=\"warning\" /></li>\n"
+ self.stepResults.append(self.STEPRESULT)
except TypeError,e:
+ print "\nException in the following section of code: " +\
+ str(testCaseNumber) + "." + str(step) + ": " +\
+ self.stepName
+ #print code[testCaseNumber][step]
self.stepCount = self.stepCount + 1
- self.log.error(e)
+ self.log.exception(e)
+ self.logger.updateCaseResults(self)
+ #WIKI results
+ self.log.wiki( "<ul>" )
+ for line in self.stepCache.splitlines():
+ if re.search( " - PASS$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"tick\" /></li>\n" )
+ elif re.search( " - FAIL$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"cross\" /></li>\n" )
+ elif re.search( " - No Result$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"warning\" /></li>\n" )
+ self.log.wiki( "</ul>" )
+ #summary results
+ self.log.summary( self.stepCache )
+ self.stepCache = ""
+ self.cleanup()
+ self.exit()
return main.TRUE
-
if cli.stop:
cli.stop = False
stopped = True
@@ -255,21 +311,21 @@
self.logger.updateCaseResults(self)
result = self.cleanup()
return main.FALSE
-
+
def addCaseHeader(self):
caseHeader = "\n"+"*" * 30+"\n Result summary for Testcase"+str(self.CurrentTestCaseNumber)+"\n"+"*" * 30+"\n"
- self.log.exact(caseHeader)
- caseHeader = "\n"+"*" * 40 +"\nStart of Test Case"+str(self.CurrentTestCaseNumber)+" : "
+ self.log.exact(caseHeader)
+ caseHeader = "\n"+"*" * 40 +"\nStart of Test Case"+str(self.CurrentTestCaseNumber)+" : "
for driver in self.componentDictionary.keys():
vars(self)[driver+'log'].info(caseHeader)
-
+
def addCaseFooter(self):
if self.stepCount-1 > 0 :
previousStep = " "+str(self.CurrentTestCaseNumber)+"."+str(self.stepCount-1)+": "+ str(self.stepName) + ""
stepHeader = "\n"+"*" * 40+"\nEnd of Step "+previousStep+"\n"+"*" * 40+"\n"
-
+
caseFooter = "\n"+"*" * 40+"\nEnd of Test case "+str(self.CurrentTestCaseNumber)+"\n"+"*" * 40+"\n"
-
+
for driver in self.driversList:
vars(self)[driver].write(stepHeader+"\n"+caseFooter)
@@ -282,39 +338,38 @@
'''
result = self.TRUE
self.logger.testSummary(self)
-
+
#self.reportFile.close()
-
#utilities.send_mail()
- try :
- for component in self.componentDictionary.keys():
- tempObject = vars(self)[component]
- print "Disconnecting "+str(tempObject)
-
+ for component in self.componentDictionary.keys():
+ try :
+ tempObject = vars(self)[component]
+ print "Disconnecting from " + str(tempObject.name) + ": " + \
+ str(tempObject)
tempObject.disconnect()
- #tempObject.execute(cmd="exit",prompt="(.*)",timeout=120)
+ #tempObject.execute(cmd="exit",prompt="(.*)",timeout=120)
- except(Exception):
- #print " There is an error with closing hanldes"
- result = self.FALSE
+ except (Exception):
+ self.log.exception( "Exception while disconnecting from " +
+ str( component ) )
+ result = self.FALSE
# Closing all the driver's session files
for driver in self.componentDictionary.keys():
vars(self)[driver].close_log_handles()
-
+
return result
-
+
def pause(self):
'''
This function will pause the test's execution, and will continue after user provide 'resume' command.
'''
__builtin__.testthread.pause()
-
+
def onfail(self,*components):
'''
- When test step failed, calling all the components onfail.
+ When test step failed, calling all the components onfail.
'''
-
if not components:
try :
for component in self.componentDictionary.keys():
@@ -323,7 +378,6 @@
except(Exception),e:
print str(e)
result = self.FALSE
-
else:
try :
for component in components:
@@ -332,8 +386,7 @@
except(Exception),e:
print str(e)
result = self.FALSE
-
-
+
def getDriverPath(self,driverName):
'''
Based on the component 'type' specified in the params , this method will find the absolute path ,
@@ -343,23 +396,22 @@
cmd = "find "+drivers_path+" -name "+driverName+".py"
result = commands.getoutput(cmd)
-
+
result_array = str(result).split('\n')
result_count = 0
-
+
for drivers_list in result_array:
result_count = result_count+1
if result_count > 1 :
print "found "+driverName+" "+ str(result_count) + " times"+str(result_array)
self.exit()
-
+
result = re.sub("(.*)drivers","",result)
result = re.sub("\.py","",result)
result = re.sub("\.pyc","",result)
result = re.sub("\/",".",result)
result = "drivers"+result
return result
-
def step(self,stepDesc):
'''
@@ -374,34 +426,34 @@
stepName = " INIT : Initializing the test case :"+self.CurrentTestCase
except AttributeError:
stepName = " INIT : Initializing the test case :"+str(self.CurrentTestCaseNumber)
-
+
self.log.step(stepName)
stepHeader = ""
if self.stepCount > 1 :
stepHeader = "\n"+"-"*45+"\nEnd of Step "+previousStep+"\n"+"-"*45+"\n"
-
- stepHeader += "\n"+"-"*45+"\nStart of Step"+stepName+"\n"+"-"*45+"\n"
+
+ stepHeader += "\n"+"-"*45+"\nStart of Step"+stepName+"\n"+"-"*45+"\n"
for driver in self.componentDictionary.keys():
vars(self)[driver+'log'].info(stepHeader)
-
+
def case(self,testCaseName):
'''
Test's each test-case information will append to the logs.
'''
- self.CurrentTestCase = testCaseName
+ self.CurrentTestCase = testCaseName
testCaseName = " " + str(testCaseName) + ""
self.log.case(testCaseName)
- caseHeader = testCaseName+"\n"+"*" * 40+"\n"
+ caseHeader = testCaseName+"\n"+"*" * 40+"\n"
for driver in self.componentDictionary.keys():
vars(self)[driver+'log'].info(caseHeader)
-
+
def testDesc(self,description):
'''
Test description will append to the logs.
'''
description = "Test Description : " + str (description) + ""
self.log.info(description)
-
+
def _getTest(self):
'''
This method will parse the test script to find required test information.
@@ -417,65 +469,57 @@
if lineMatch:
counter = counter + 1
self.TC_PLANNED = len(self.testcases_list)
-
-
+
def response_parser(self,response, return_format):
''' It will load the default response parser '''
response_dict = {}
response_dict = self.response_to_dict(response, return_format)
- return_format_string = self.dict_to_return_format(response,return_format,response_dict)
+ return_format_string = self.dict_to_return_format(response,return_format,response_dict)
return return_format_string
-
+
def response_to_dict(self,response,return_format):
-
response_dict = {}
json_match = re.search('^\s*{', response)
xml_match = re.search('^\s*\<', response)
ini_match = re.search('^\s*\[', response)
if json_match :
- main.log.info(" Response is in 'JSON' format and Converting to '"+return_format+"' format")
- # Formatting the json string
-
+ self.log.info(" Response is in 'JSON' format and Converting to '"+return_format+"' format")
+ # Formatting the json string
response = re.sub(r"{\s*'?(\w)", r'{"\1', response)
response = re.sub(r",\s*'?(\w)", r',"\1', response)
response = re.sub(r"(\w)'?\s*:", r'\1":', response)
response = re.sub(r":\s*'(\w)'\s*([,}])", r':"\1"\2', response)
-
try :
import json
response_dict = json.loads(response)
- except Exception , e :
- print e
- main.log.error("Json Parser is unable to parse the string")
+ except Exception, e:
+ self.log.exception( e )
+ self.log.error("Json Parser is unable to parse the string")
return response_dict
-
elif ini_match :
- main.log.info(" Response is in 'INI' format and Converting to '"+return_format+"' format")
+ self.log.info(" Response is in 'INI' format and Converting to '"+return_format+"' format")
from configobj import ConfigObj
response_file = open("respnse_file.temp",'w')
response_file.write(response)
- response_file.close()
+ response_file.close()
response_dict = ConfigObj("respnse_file.temp")
return response_dict
-
elif xml_match :
- main.log.info(" Response is in 'XML' format and Converting to '"+return_format+"' format")
+ self.log.info(" Response is in 'XML' format and Converting to '"+return_format+"' format")
try :
- from core import dicttoobject
response_dict = xmldict.xml_to_dict("<response> "+str(response)+" </response>")
except Exception, e:
- main.log.error(e)
+ self.log.exception( e )
return response_dict
-
+
def dict_to_return_format(self,response,return_format,response_dict):
-
if return_format =='table' :
''' Will return in table format'''
to_do = "Call the table output formatter"
global response_table
response_table = '\n'
response_table = response_table +'\t'.join(response_dict)+"\n"
-
+
def get_table(value_to_convert):
''' This will parse the dictionary recusrsively and print as table format'''
table_data = ""
@@ -485,17 +529,13 @@
table_data = table_data + get_table(temp_val)
else :
table_data = table_data + str(value_to_convert) +"\t"
- return table_data
-
+ return table_data
+
for value in response_dict.values() :
response_table = response_table + get_table(value)
-
-
-
- #response_table = response_table + '\t'.join(response_dict.values())
-
+ # response_table = response_table + '\t'.join(response_dict.values())
return response_table
-
+
elif return_format =='config':
''' Will return in config format'''
to_do = 'Call dict to config coverter'
@@ -507,25 +547,22 @@
response_config = re.sub("}", "\n", response_config)
response_config = re.sub(":", " =", response_config)
return "[response]\n\t "+response_config
-
elif return_format == 'xml':
''' Will return in xml format'''
- from core import dicttoobject
response_xml = xmldict.dict_to_xml(response_dict)
response_xml = re.sub(">\s*<", ">\n<", response_xml)
return "\n"+response_xml
-
elif return_format == 'json':
''' Will return in json format'''
to_do = 'Call dict to xml coverter'
import json
response_json = json.dumps(response_dict)
return response_json
-
+
def get_random(self):
self.random_order = self.random_order + 1
return self.random_order
-
+
def exit(self):
__builtin__.testthread = None
sys.exit()
@@ -537,7 +574,7 @@
import pprint
pp = pprint.PrettyPrinter(indent=4)
- #pp.pprint(options)
+ # pp.pprint(options)
verifyTest(options)
verifyExample(options)
verifyTestScript(options)
@@ -564,16 +601,16 @@
main.testDir = path+'/examples/'
main.tests_path = path+"/examples/"
main.classPath = "examples."+main.TEST+"."+main.TEST
-
+
def verifyLogdir(options):
- #Verifying Log directory option
+ # Verifying Log directory option
if options.logdir:
main.logdir = options.logdir
else :
- main.logdir = main.FALSE
-
+ main.logdir = main.FALSE
+
def verifyMail(options):
- # Checking the mailing list
+ # Checking the mailing list
if options.mail:
main.mail = options.mail
elif main.params.has_key('mail'):
@@ -582,10 +619,10 @@
main.mail = 'paxweb@paxterrasolutions.com'
def verifyTestCases(options):
- #Getting Test cases list
+ # Getting Test cases list
if options.testcases:
- testcases_list = options.testcases
- #sys.exit()
+ testcases_list = options.testcases
+ # sys.exit()
testcases_list = re.sub("(\[|\])", "", options.testcases)
main.testcases_list = eval(testcases_list+",")
else :
@@ -593,27 +630,27 @@
temp = eval(main.params['testcases']+",")
list1=[]
if type(temp[0])==list:
- for test in temp:
- for testcase in test:
- if type(testcase)==int:
- testcase=[testcase]
- list1.extend(testcase)
- else :
- temp=list(temp)
- for testcase in temp:
- if type(testcase)==int:
- testcase=[testcase]
- list1.extend(testcase)
- main.testcases_list=list1
+ for test in temp:
+ for testcase in test:
+ if type(testcase)==int:
+ testcase=[testcase]
+ list1.extend(testcase)
+ else :
+ temp=list(temp)
+ for testcase in temp:
+ if type(testcase)==int:
+ testcase=[testcase]
+ list1.extend(testcase)
+ main.testcases_list=list1
else :
print "testcases not specifed in params, please provide in params file or 'testcases' commandline argument"
- sys.exit()
-
+ sys.exit()
+
def verifyTestScript(options):
'''
Verifyies test script.
'''
- main.openspeak = openspeak.OpenSpeak()
+ main.openspeak = openspeak.OpenSpeak()
openspeakfile = main.testDir+"/" + main.TEST + "/" + main.TEST + ".ospk"
testfile = main.testDir+"/" + main.TEST + "/" + main.TEST + ".py"
if os.path.exists(openspeakfile) :
@@ -624,32 +661,30 @@
print "\nThere is no :\""+main.TEST+"\" test, Please Provide OpenSpeak Script/ test script"
__builtin__.testthread = None
main.exit()
-
try :
testModule = __import__(main.classPath, globals(), locals(), [main.TEST], -1)
except(ImportError):
print "There was an import error, it might mean that there is no test like "+main.TEST
- main.exit()
+ main.exit()
testClass = getattr(testModule, main.TEST)
main.testObject = testClass()
load_parser()
- main.params = main.parser.parseParams(main.classPath)
- main.topology = main.parser.parseTopology(main.classPath)
-
+ main.params = main.parser.parseParams(main.classPath)
+ main.topology = main.parser.parseTopology(main.classPath)
+
def verifyParams():
try :
main.params = main.params['PARAMS']
except(KeyError):
print "Error with the params file: Either the file not specified or the format is not correct"
- main.exit()
-
+ main.exit()
try :
main.topology = main.topology['TOPOLOGY']
except(KeyError):
print "Error with the Topology file: Either the file not specified or the format is not correct"
main.exit()
-
+
def load_parser() :
'''
It facilitates the loading customised parser for topology and params file.
@@ -671,19 +706,17 @@
main.parser = parsingClass()
#hashobj = main.parser.parseParams(main.classPath)
if hasattr(main.parser,"parseParams") and hasattr(main.parser,"parseTopology") and hasattr(main.parser,"parse") :
-
pass
else:
main.exit()
-
except ImportError:
print sys.exc_info()[1]
main.exit()
else :
print "No Such File Exists !!"+ confighash['config']['parser']['file'] +"using default parser"
- load_defaultParser()
- elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :
- load_defaultParser()
+ load_defaultParser()
+ elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :
+ load_defaultParser()
else:
load_defaultParser()
@@ -694,7 +727,7 @@
moduleList = main.parserPath.split("/")
newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
try :
- parsingClass = main.parsingClass
+ parsingClass = main.parsingClass
parsingModule = __import__(newModule, globals(), locals(), [parsingClass], -1)
parsingClass = getattr(parsingModule, parsingClass)
main.parser = parsingClass()
@@ -706,7 +739,6 @@
except ImportError:
print sys.exc_info()[1]
-
def load_logger() :
'''
It facilitates the loading customised parser for topology and params file.
@@ -733,8 +765,8 @@
else :
print "No Such File Exists !!"+confighash['config']['logger']['file']+ "Using default logger"
load_defaultlogger()
- elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :
- load_defaultlogger()
+ elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :
+ load_defaultlogger()
else:
load_defaultlogger()
@@ -745,23 +777,7 @@
moduleList = main.loggerPath.split("/")
newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
try :
- loggerClass = main.loggerClass
- loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1)
- loggerClass = getattr(loggerModule, loggerClass)
- main.logger = loggerClass()
-
- except ImportError:
- print sys.exc_info()[1]
- main.exit()
-
-def load_defaultlogger():
- '''
- It will load the default parser which is xml parser to parse the params and topology file.
- '''
- moduleList = main.loggerPath.split("/")
- newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
- try :
- loggerClass = main.loggerClass
+ loggerClass = main.loggerClass
loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1)
loggerClass = getattr(loggerModule, loggerClass)
main.logger = loggerClass()
@@ -770,8 +786,21 @@
print sys.exc_info()[1]
main.exit()
+def load_defaultlogger():
+ '''
+ It will load the default parser which is xml parser to parse the params and topology file.
+ '''
+ moduleList = main.loggerPath.split("/")
+ newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
+ try :
+ loggerClass = main.loggerClass
+ loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1)
+ loggerClass = getattr(loggerModule, loggerClass)
+ main.logger = loggerClass()
-
+ except ImportError:
+ print sys.exc_info()[1]
+ main.exit()
def _echo(self):
print "THIS IS ECHO"
diff --git a/TestON/core/testparser.py b/TestON/core/testparser.py
index 37f50f0..24b1ca2 100644
--- a/TestON/core/testparser.py
+++ b/TestON/core/testparser.py
@@ -16,7 +16,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
'''
@@ -26,21 +26,21 @@
def __init__(self,testFile):
try :
testFileHandler = open(testFile, 'r')
- except IOError:
+ except IOError:
print "No such file "+testFile
sys.exit(0)
-
+
testFileList = testFileHandler.readlines()
- self.testscript = testFileList
+ self.testscript = testFileList
self.caseCode = {}
self.caseBlock = ''
self.statementsList = []
- index = 0
+ index = 0
self.statementsList = []
#initialSpaces = len(line) -len(line.lstrip())
while index < len(testFileList):
testFileList[index] = re.sub("^\s{8}|^\s{4}", "", testFileList[index])
- # Skip multiline comments
+ # Skip multiline comments
if re.match('^(\'\'\')|^(\"\"\")',testFileList[index],0) :
index = index + 1
try :
@@ -48,16 +48,15 @@
index = index + 1
except IndexError,e:
print ''
-
- # skip empty lines and single line comments
+ # skip empty lines and single line comments
elif not re.match('#|^\s*$',testFileList[index],0):
self.statementsList.append(testFileList[index])
index = index + 1
-
+
def case_code(self):
- index = 0
- statementsList = self.statementsList
+ index = 0
+ statementsList = self.statementsList
while index < len(statementsList):
#print statementsList[index]
m= re.match('def\s+CASE(\d+)',statementsList[index],0)
@@ -76,18 +75,16 @@
except IndexError,e:
#print 'IndexError'
print ''
-
self.caseCode [str(m.group(1))] = self.caseBlock
#print "Case CODE "+self.caseCode [str(m.group(1))]
index = index + 1
-
- return self.caseCode
-
+ return self.caseCode
+
def step_code(self,caseStatements):
index = 0
- step = 0
- stepCode = {}
- step_flag = False
+ step = 0
+ stepCode = {}
+ step_flag = False
while index < len(caseStatements):
m= re.match('main\.step',caseStatements[index],0)
stepBlock = ''
@@ -99,13 +96,13 @@
while i < index :
block += caseStatements[i]
i = i + 1
- stepCode[step] = block
+ stepCode[step] = block
step = step + 1
- stepBlock= stepBlock + caseStatements[index]
+ stepBlock = stepBlock + caseStatements[index]
index = index + 1
try :
while not re.match('main\.step',caseStatements[index],0) :
- stepBlock= stepBlock + caseStatements[index]
+ stepBlock = stepBlock + caseStatements[index]
if index < len(caseStatements)-1:
index = index + 1
else :
@@ -121,11 +118,10 @@
if not step_flag :
stepCode[step] = "".join(caseStatements)
return stepCode
-
+
def getStepCode(self):
case_step_code = {}
case_block = self.case_code()
-
for case in case_block :
case_step_code[case] = {}
step_block = self.step_code(case_block[case])
diff --git a/TestON/core/utilities.py b/TestON/core/utilities.py
index b6bed3e..dda43bf 100644
--- a/TestON/core/utilities.py
+++ b/TestON/core/utilities.py
@@ -29,11 +29,9 @@
'''
import re
from configobj import ConfigObj
-import pydoc
from core import ast as ast
import smtplib
-import mimetypes
import email
import os
import email.mime.application
@@ -70,28 +68,22 @@
operators = matchVar.group(2)
elif matchVar.group(1) == "_" and matchVar.group(2):
operators = matchVar.group(2)
-
except AttributeError:
if matchVar==None and nameVar:
operators ='equals'
-
- result = self._assert(NOT=notVar,operator=operators,**kwargs)
+ result = self._assert(NOT=notVar,operator=operators,**kwargs)
if result == main.TRUE:
main.log.info("Assertion Passed")
- main.CASERESULT = main.TRUE
+ main.STEPRESULT = main.TRUE
elif result == main.FALSE:
main.log.warn("Assertion Failed")
- main.CASERESULT = main.FALSE
-
- else :
+ main.STEPRESULT = main.FALSE
+ else:
main.log.error("There is an Error in Assertion")
- main.CASERESULT = main.ERROR
-
+ main.STEPRESULT = main.ERROR
return result
-
return assertHandling
-
-
+
def _assert (self,**assertParam):
'''
It will take the arguments :
@@ -265,7 +257,7 @@
try :
parsedInfo = ConfigObj(self.fileName)
return parsedInfo
- except :
+ except Exception:
print "There is no such file to parse "+fileName
else:
return 0
diff --git a/TestON/core/xmldict.py b/TestON/core/xmldict.py
index 34e9cfc..f873014 100644
--- a/TestON/core/xmldict.py
+++ b/TestON/core/xmldict.py
@@ -37,7 +37,7 @@
root = ElementTree.XML(root_or_str)
try :
return {root.tag: _from_xml(root, strict)}
- except :
+ except Exception:
return None
def dict_to_xml(dict_xml):
diff --git a/TestON/core/xmlparser.py b/TestON/core/xmlparser.py
index 3cb4aee..a46750a 100644
--- a/TestON/core/xmlparser.py
+++ b/TestON/core/xmlparser.py
@@ -39,7 +39,7 @@
try :
parsedInfo = xmldict.xml_to_dict(xml)
return parsedInfo
- except :
+ except Exception:
print "There is no such file to parse " + fileName
else :
print "file name is not correct"
diff --git a/TestON/dependencies/Jenkins_getresult_HA.py b/TestON/dependencies/Jenkins_getresult_HA.py
index f3ea459..181e1a9 100755
--- a/TestON/dependencies/Jenkins_getresult_HA.py
+++ b/TestON/dependencies/Jenkins_getresult_HA.py
@@ -6,6 +6,7 @@
import datetime
import time
import argparse
+import glob
import shutil
parser = argparse.ArgumentParser()
@@ -43,10 +44,10 @@
##Graphs
graphs += '<ac:structured-macro ac:name="html">\n'
graphs += '<ac:plain-text-body><![CDATA[\n'
- graphs += '<iframe src="https://onos-jenkins.onlab.us/job/'+job+'/plot/getPlot?index=2&width=500&height=300" noborder="0" width="500" height="300" scrolling="yes" seamless="seamless"></iframe>\n'
- graphs += '<iframe src="https://onos-jenkins.onlab.us/job/'+job+'/plot/getPlot?index=1&width=500&height=300" noborder="0" width="500" height="300" scrolling="yes" seamless="seamless"></iframe>\n'
- graphs += '<iframe src="https://onos-jenkins.onlab.us/job/'+job+'/plot/getPlot?index=0&width=500&height=300" noborder="0" width="500" height="300" scrolling="yes" seamless="seamless"></iframe>\n'
- graphs += '<iframe src="https://onos-jenkins.onlab.us/job/'+job+'/plot/getPlot?index=3&width=500&height=300" noborder="0" width="500" height="300" scrolling="yes" seamless="seamless"></iframe>\n'
+ graphs += '<iframe src="https://onos-jenkins.onlab.us/job/'+job+'/plot/Plot-HA/getPlot?index=2&width=500&height=300" noborder="0" width="500" height="300" scrolling="yes" seamless="seamless"></iframe>\n'
+ graphs += '<iframe src="https://onos-jenkins.onlab.us/job/'+job+'/plot/Plot-HA/getPlot?index=1&width=500&height=300" noborder="0" width="500" height="300" scrolling="yes" seamless="seamless"></iframe>\n'
+ graphs += '<iframe src="https://onos-jenkins.onlab.us/job/'+job+'/plot/Plot-HA/getPlot?index=0&width=500&height=300" noborder="0" width="500" height="300" scrolling="yes" seamless="seamless"></iframe>\n'
+ graphs += '<iframe src="https://onos-jenkins.onlab.us/job/'+job+'/plot/Plot-HA/getPlot?index=3&width=500&height=300" noborder="0" width="500" height="300" scrolling="yes" seamless="seamless"></iframe>\n'
graphs += ']]></ac:plain-text-body>\n'
graphs += '</ac:structured-macro>\n'
header +="<p> <a href='https://wiki.onosproject.org/display/OST/Test+Plan+-+HA'>Test Plan for HA Test Cases</a></p>"
@@ -63,14 +64,15 @@
path = "/home/admin/ONLabTest/TestON/logs/" + name + "/"
try:
#IF exists, move the csv file to the workspace
- shutil.copy(path + test + ".csv", workspace)
+ for csvFile in glob.glob( path + '*.csv' ):
+ shutil.copy( csvFile, workspace )
except IOError:
#File probably doesn't exist
pass
output +="<p></p>"
#output +=" Date: %s, %s %s" % (name.split("_")[2], name.split("_")[1], name.split("_")[3]) + "<p>*******************<p>"
- #Open the latest log folder
+ #Open the latest log folder
output += "<h2>Test "+str(test)+"</h2><p>************************************</p>"
f = open(path + name + ".rpt")
@@ -101,9 +103,15 @@
f.close()
#https://wiki.onosproject.org/display/OST/Test+Results+-+HA#Test+Results+-+HA
#Example anchor on new wiki: #TestResults-HA-TestHATestSanity
- page_name = "TestResults-HA-Test"
+ page_name = "Master-HA"
+ if "ONOS-HA-1.1.X" in job:
+ page_name = "Blackbird-HA"
+ elif "ONOS-HA-Maint" in job:
+ # NOTE if page name starts with number confluence prepends 'id-'
+ # to anchor links
+ page_name = "id-1.0-HA"
- header += "<li><a href=\'#" + str(page_name) + str(test) + "\'> " + str(test) + " - Results: " + str(passes) + " Passed, " + str(fails) + " Failed</a></li>"
+ header += "<li><a href=\'#" + str(page_name) + "-Test" + str(test) + "\'> " + str(test) + " - Results: " + str(passes) + " Passed, " + str(fails) + " Failed</a></li>"
#*********************
#include any other phrase specific to case you would like to include in wiki here
diff --git a/TestON/dependencies/onos.properties.proactive b/TestON/dependencies/onos.properties.proactive
deleted file mode 100644
index 2b5150a..0000000
--- a/TestON/dependencies/onos.properties.proactive
+++ /dev/null
@@ -1,16 +0,0 @@
-floodlight.modules = net.floodlightcontroller.core.FloodlightProvider,\
-net.floodlightcontroller.threadpool.ThreadPool,\
-net.onrc.onos.core.topology.TopologyPublisher, \
-net.onrc.onos.core.datagrid.HazelcastDatagrid,\
-net.onrc.onos.core.flowprogrammer.FlowProgrammer,\
-net.onrc.onos.core.intent.runtime.PathCalcRuntimeModule,\
-net.onrc.onos.core.intent.runtime.PlanInstallModule,\
-net.onrc.onos.core.registry.ZookeeperRegistry
-net.floodlightcontroller.restserver.RestApiServer.port = 8080
-net.floodlightcontroller.core.FloodlightProvider.openflowport = 6633
-net.floodlightcontroller.core.FloodlightProvider.workerthreads = 16
-net.floodlightcontroller.forwarding.Forwarding.idletimeout = 5
-net.floodlightcontroller.forwarding.Forwarding.hardtimeout = 0
-net.onrc.onos.core.datagrid.HazelcastDatagrid.datagridConfig = conf/hazelcast.xml
-net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher.dbconf = conf/ramcloud.conf
-net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher.graph_db_store = ramcloud
diff --git a/TestON/dependencies/onos.properties.reactive b/TestON/dependencies/onos.properties.reactive
deleted file mode 100644
index 8d78222..0000000
--- a/TestON/dependencies/onos.properties.reactive
+++ /dev/null
@@ -1,19 +0,0 @@
-floodlight.modules = net.floodlightcontroller.core.FloodlightProvider,\
-net.floodlightcontroller.threadpool.ThreadPool,\
-net.onrc.onos.core.topology.TopologyPublisher, \
-net.onrc.onos.core.datagrid.HazelcastDatagrid,\
-net.onrc.onos.core.flowprogrammer.FlowProgrammer,\
-net.onrc.onos.core.intent.runtime.PathCalcRuntimeModule,\
-net.onrc.onos.core.intent.runtime.PlanInstallModule,\
-net.onrc.onos.core.registry.ZookeeperRegistry,\
-net.onrc.onos.apps.proxyarp.ProxyArpManager,\
-net.onrc.onos.core.main.config.DefaultConfiguration,\
-net.onrc.onos.apps.forwarding.Forwarding
-net.floodlightcontroller.restserver.RestApiServer.port = 8080
-net.floodlightcontroller.core.FloodlightProvider.openflowport = 6633
-net.floodlightcontroller.core.FloodlightProvider.workerthreads = 16
-net.floodlightcontroller.forwarding.Forwarding.idletimeout = 5
-net.floodlightcontroller.forwarding.Forwarding.hardtimeout = 0
-net.onrc.onos.core.datagrid.HazelcastDatagrid.datagridConfig = conf/hazelcast.xml
-net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher.dbconf = conf/ramcloud.conf
-net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher.graph_db_store = ramcloud
diff --git a/TestON/dependencies/pyintents.py b/TestON/dependencies/pyintents.py
deleted file mode 100755
index b593845..0000000
--- a/TestON/dependencies/pyintents.py
+++ /dev/null
@@ -1,46 +0,0 @@
-#! /usr/bin/env python
-'''
-This file creates the ONOS intents for the sanity 4 nodes tests. These intents will be translated into flows by ONOS and pushed to the switches.
-'''
-
-import json
-import requests
-
-url = 'http://127.0.0.1:8080/wm/onos/datagrid/add/intents/json'
-headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
-
-
-'''response
-[{'intent_id':'5','status':'CREATED','log':['created, time:73268214932534']}]
-'''
-
-
-
-for i in range(6,16):
- #intent = [{'intent_id': '%d' %i,'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':'8249','srcPort':1,'srcMac':'00:00:00:00:00:01','dstSwitch':'4103','dstPort':1,'dstMac':'00:00:00:00:00:02'}]
- srcMac = '00:00:00:00:00:'+ str(hex(i)[2:]).zfill(2)
- dstMac = '00:00:00:00:00:'+ str(hex(i+10)[2:])
- srcSwitch = '00:00:00:00:00:00:10:'+ str(i).zfill(2)
- dstSwitch = '00:00:00:00:00:00:20:'+ str(i+25)
- srcPort = 1
- dstPort = 1
-
- intent = [{'intent_id': '%d' %(i),'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':srcSwitch,'srcPort':srcPort,'srcMac':srcMac,'dstSwitch':dstSwitch,'dstPort':dstPort,'dstMac':dstMac}]
-
-
- print json.dumps(intent, sort_keys = True)
-
-
- #r = requests.post(url, data=json.dumps(iid, sort_keys=True)+json.dumps(intent, sort_keys=True), headers = headers)
- r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
- print r
- print r.content
-
-
-
- intent = [{'intent_id': '%d' %(i+10),'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':dstSwitch,'srcPort':dstPort,'srcMac':dstMac,'dstSwitch':srcSwitch,'dstPort':srcPort,'dstMac':srcMac}]
- print json.dumps(intent, sort_keys = True)
- r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
- print r
- print r.content
-
diff --git a/TestON/dependencies/rmpyintents.py b/TestON/dependencies/rmpyintents.py
deleted file mode 100755
index 10bb5d4..0000000
--- a/TestON/dependencies/rmpyintents.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#! /usr/bin/env python
-
-'''
-This file removes the ONOS intents for the sanity 4 nodes tests. The flows associated with these intents should be deleted from the switches.
-'''
-
-import json
-import requests
-
-
-
-url = 'http://127.0.0.1:8080/wm/onos/datagrid/add/intents/json'
-headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
-
-
-'''response
-[{'intent_id':'5','status':'CREATED','log':['created, time:73268214932534']}]
-'''
-
-
-
-for i in range(6,16):
- #intent = [{'intent_id': '%d' %i,'intent_type':'shortest_intent_type','intent_op':'remove','srcSwitch':'8249','srcPort':1,'srcMac':'00:00:00:00:00:01','dstSwitch':'4103','dstPort':1,'dstMac':'00:00:00:00:00:02'}]
- srcMac = '00:00:00:00:00:'+ str(hex(i)[2:]).zfill(2)
- dstMac = '00:00:00:00:00:'+ str(hex(i+10)[2:])
- srcSwitch = '00:00:00:00:00:00:10:'+ str(i).zfill(2)
- dstSwitch = '00:00:00:00:00:00:20:'+ str(i+25)
- srcPort = 1
- dstPort = 1
-
- intent = [{'intent_id': '%d' %(i),'intent_type':'shortest_intent_type','intent_op':'remove','srcSwitch':srcSwitch,'srcPort':srcPort,'srcMac':srcMac,'dstSwitch':dstSwitch,'dstPort':dstPort,'dstMac':dstMac}]
-
-
- print json.dumps(intent, sort_keys = True)
-
-
- #r = requests.post(url, data=json.dumps(iid, sort_keys=True)+json.dumps(intent, sort_keys=True), headers = headers)
- r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
- print r
- print r.content
-
-
-
- intent = [{'intent_id': '%d' %(i+10),'intent_type':'shortest_intent_type','intent_op':'remove','srcSwitch':dstSwitch,'srcPort':dstPort,'srcMac':dstMac,'dstSwitch':srcSwitch,'dstPort':srcPort,'dstMac':srcMac}]
- print json.dumps(intent, sort_keys = True)
- r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
- print r
- print r.content
-
diff --git a/TestON/dependencies/rotate.sh b/TestON/dependencies/rotate.sh
index 0f879b6..7136ac6 100755
--- a/TestON/dependencies/rotate.sh
+++ b/TestON/dependencies/rotate.sh
@@ -49,6 +49,6 @@
root_dir="/home/admin/packet_captures"
timestamp=`date +%Y_%B_%d_%H_%M_%S`
#Maybe this should be an argument? pack-and-rotate supports that
-nr_max=20
+nr_max=10
-pack-rotate-log ${root_dir}'/'${base_name} "${root_dir}/${base_name}*.pcap ${root_dir}/${base_name}*.log" ${nr_max}
+pack-rotate-log ${root_dir}'/'${base_name} "${root_dir}/${base_name}*.pcap ${root_dir}/${base_name}*.log*" ${nr_max}
diff --git a/TestON/dependencies/topo-HA.py b/TestON/dependencies/topo-HA.py
new file mode 100644
index 0000000..65613d6
--- /dev/null
+++ b/TestON/dependencies/topo-HA.py
@@ -0,0 +1,63 @@
+from mininet.topo import Topo
+class MyTopo( Topo ):
+ def __init__( self ):
+ Topo.__init__( self )
+ topSwitch = self.addSwitch('s1',dpid='1000'.zfill(16))
+ leftTopSwitch = self.addSwitch('s2',dpid='2000'.zfill(16))
+ rightTopSwitch = self.addSwitch('s5',dpid='5000'.zfill(16))
+ leftBotSwitch = self.addSwitch('s3',dpid='3000'.zfill(16))
+ rightBotSwitch = self.addSwitch('s6',dpid='6000'.zfill(16))
+ midBotSwitch = self.addSwitch('s28',dpid='2800'.zfill(16))
+
+ topHost = self.addHost( 'h1' )
+ leftTopHost = self.addHost('h2')
+ rightTopHost = self.addHost('h5')
+ leftBotHost = self.addHost('h3')
+ rightBotHost = self.addHost('h6')
+ midBotHost = self.addHost('h28')
+ self.addLink(topSwitch,topHost)
+ self.addLink(leftTopSwitch,leftTopHost)
+ self.addLink(rightTopSwitch,rightTopHost)
+ self.addLink(leftBotSwitch,leftBotHost)
+ self.addLink(rightBotSwitch,rightBotHost)
+ self.addLink(midBotSwitch,midBotHost)
+ self.addLink(leftTopSwitch,rightTopSwitch)
+ self.addLink(topSwitch,leftTopSwitch)
+ self.addLink(topSwitch,rightTopSwitch)
+ self.addLink(leftTopSwitch,leftBotSwitch)
+ self.addLink(rightTopSwitch,rightBotSwitch)
+ self.addLink(leftBotSwitch,midBotSwitch)
+ self.addLink(midBotSwitch,rightBotSwitch)
+
+ agg1Switch = self.addSwitch('s4',dpid = '3004'.zfill(16))
+ agg2Switch = self.addSwitch('s7',dpid = '6007'.zfill(16))
+ agg1Host = self.addHost('h4')
+ agg2Host = self.addHost('h7')
+ self.addLink(agg1Switch,agg1Host)
+ self.addLink(agg2Switch,agg2Host)
+ self.addLink(agg1Switch, leftBotSwitch)
+ self.addLink(agg2Switch, rightBotSwitch)
+
+ for i in range(10):
+ num = str(i+8)
+ switch = self.addSwitch('s'+num,dpid = ('30'+num.zfill(2)).zfill(16))
+ host = self.addHost('h'+num)
+ self.addLink(switch, host)
+ self.addLink(switch, agg1Switch)
+
+ for i in range(10):
+ num = str(i+18)
+ switch = self.addSwitch('s'+num,dpid = ('60'+num.zfill(2)).zfill(16))
+ host = self.addHost('h'+num)
+ self.addLink(switch, host)
+ self.addLink(switch, agg2Switch)
+
+topos = { 'mytopo': (lambda: MyTopo() ) }
+
+
+
+
+
+
+
+
diff --git a/TestON/drivers/common/cli/dpclidriver.py b/TestON/drivers/common/cli/dpclidriver.py
index 057a3f1..81743d3 100644
--- a/TestON/drivers/common/cli/dpclidriver.py
+++ b/TestON/drivers/common/cli/dpclidriver.py
@@ -1,16 +1,8 @@
"""
Driver for blank dataplane VMs. Created for SDNIP test.
"""
-import time
import pexpect
-import struct
-import fcntl
-import os
import sys
-import signal
-import sys
-import re
-import json
sys.path.append( "../" )
from drivers.common.clidriver import CLI
@@ -26,9 +18,9 @@
self.name = self.options[ 'name' ]
self.handle = super( DPCliDriver, self ).connect( user_name=self.user_name,
- ip_address=self.ip_address,
- port=self.port,
- pwd=self.pwd )
+ ip_address=self.ip_address,
+ port=self.port,
+ pwd=self.pwd )
if self.handle:
return self.handle
@@ -38,11 +30,17 @@
def create_interfaces( self, net, number, start ):
"""
- Creates a number,specified by 'number,' of subinterfaces on eth0. Ip addresses start at 'net'.'start'.1.1 with a 24 bit netmask. Addresses increment sequentially in the third quad,
- therefore all interfaces are in different subnets on the same machine. When the third quad reaches 255, it is reset to 1 and the second quad is incremented.
- Every single ip address is placed in a file in /tmp titled 'ip_table{net}.txt'
- The file is used by 'pingall_interfaces()' as a fping argument
- This method returns true if all interfaces are created without a hitch, and false if a single interface has issues
+ Creates a number,specified by 'number,' of subinterfaces on eth0.
+ Ip addresses start at 'net'.'start'.1.1 with a 24 bit netmask.
+ Addresses increment sequentially in the third quad, therefore all
+ interfaces are in different subnets on the same machine. When the
+ third quad reaches 255, it is reset to 1 and the second quad is
+ incremented. Every single ip address is placed in a file in /tmp
+ titled 'ip_table{net}.txt'. The file is used by 'pingall_interfaces()'
+ as a fping argument
+
+ This method returns true if all interfaces are created without a hitch,
+ and false if a single interface has issues
"""
self.handle.sendline( "" )
self.handle.expect( "\$" )
@@ -68,11 +66,11 @@
intf ) + " " + ip + " netmask 255.255.255.0" )
i = self.handle.expect( [
- "\$",
+ "\$",
"password",
pexpect.TIMEOUT,
pexpect.EOF ],
- timeout=120 )
+ timeout=120 )
if i == 0:
self.handle.sendline(
@@ -88,22 +86,27 @@
def pingall_interfaces( self, netsrc, netstrt, netdst, destlogin, destip ):
"""
- Copies the /tmp/ip_table{ net }.txt file from the machine you wish to ping, then runs fping with a source address of { netsrc }.{ netstrt }.1.1 on the copied file.
- Check every single response for reachable or unreachable. If all are reachable, function returns true. If a SINGLE host is unreachable, then the function stops and returns false
- If fping is not installed, this function will install fping then run the same command
+ Copies the /tmp/ip_table{ net }.txt file from the machine you wish to
+ ping, then runs fping with a source address of
+ { netsrc }.{ netstrt }.1.1 on the copied file.
+ Check every single response for reachable or unreachable. If all are
+ reachable, function returns true. If a SINGLE host is unreachable,
+ then the function stops and returns false. If fping is not installed,
+ this function will install fping then run the same command
"""
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "scp " + str( destlogin ) + "@" +
- str( destip ) + ":/tmp/local_ip.txt /tmp/ip_table" +
- str( net ) + ".txt" )
-
- i = self.handle.expect( [
- "100%",
+ self.handle.sendline( "scp " + str( destlogin ) + "@" +
+ str( destip ) +
+ ":/tmp/local_ip.txt /tmp/ip_table" +
+ str( netsrc ) + ".txt" )
+
+ i = self.handle.expect( [
+ "100%",
"password",
pexpect.TIMEOUT ],
- timeout=30 )
+ timeout=30 )
if i == 0:
main.log.info( "Copied ping file successfully" )
@@ -120,20 +123,20 @@
self.handle.expect( "\$" )
main.log.info( "Pinging interfaces on the " + str( netdst ) +
- " network from " + str( netsrc ) + "." +
- str( netstrt ) + ".1.1" )
+ " network from " + str( netsrc ) + "." +
+ str( netstrt ) + ".1.1" )
self.handle.sendline( "sudo fping -S " + str( netsrc ) + "." +
- str( netstrt ) + ".1.1 -f /tmp/ip_table" +
- str( netdst ) + ".txt" )
+ str( netstrt ) + ".1.1 -f /tmp/ip_table" +
+ str( netdst ) + ".txt" )
while 1:
i = self.handle.expect( [
- "reachable",
+ "reachable",
"unreachable",
"\$",
"password",
pexpect.TIMEOUT,
"not installed" ],
- timeout=45 )
+ timeout=45 )
if i == 0:
result = main.TRUE
elif i == 1:
@@ -142,6 +145,7 @@
return result
elif i == 2:
main.log.info( "All interfaces reachable" )
+ result = main.FALSE
return result
elif i == 3:
self.handle.sendline( self.pwd )
@@ -152,11 +156,10 @@
elif i == 5:
main.log.info( "fping not installed, installing fping" )
self.handle.sendline( "sudo apt-get install fping" )
- i = self.handle.expect(
- [ "password",
- "\$",
- pexpect.TIMEOUT ],
- timeout=60 )
+ i = self.handle.expect( [ "password",
+ "\$",
+ pexpect.TIMEOUT ],
+ timeout=60 )
if i == 0:
self.handle.sendline( self.pwd )
self.handle.expect( "\$", timeout=30 )
@@ -183,8 +186,8 @@
try:
self.handle.sendline( "exit" )
self.handle.expect( "closed" )
- except:
- main.log.error( "Connection failed to the host" )
+ except pexpect.ExceptionPexpect:
+ main.log.exception( "Connection failed to the host" )
response = main.FALSE
return response
diff --git a/TestON/drivers/common/cli/emulator/flowvisordriver.py b/TestON/drivers/common/cli/emulator/flowvisordriver.py
index d0e6ea5..46c47a7 100644
--- a/TestON/drivers/common/cli/emulator/flowvisordriver.py
+++ b/TestON/drivers/common/cli/emulator/flowvisordriver.py
@@ -21,17 +21,10 @@
FlowVisorDriver is the basic driver which will handle the Mininet functions
"""
-import pexpect
-import struct
-import fcntl
-import os
-import signal
import re
import sys
-import core.teston
sys.path.append( "../" )
from drivers.common.cli.emulatordriver import Emulator
-from drivers.common.clidriver import CLI
class FlowVisorDriver( Emulator ):
@@ -147,15 +140,15 @@
try :
if self.dl_src and self.nw_dst:
flowspace = "any 100 dl_type=0x806,dl_src="+self.dl_src+",nw_dst="+self.nw_dst+" Slice:"+self.Slice+"=4"
- except :
+ except Exception:
try :
if self.nw_src and self.tp_dst:
flowspace = "any 100 dl_type=0x800,nw_proto=6,nw_src="+self.nw_src+",tp_dst="+self.tp_dst+" Slice:"+self.Slice+"=4"
- except :
+ except Exception:
try :
if self.nw_src and self.tp_src:
flowspace = "any 100 dl_type=0x800,nw_proto=6,nw_src="+self.nw_src+",tp_src="+self.tp_dst+" Slice:"+self.Slice+"=4"
- except :
+ except Exception:
main.log.error( "Please specify flowspace properly" )
"""
# self.execute( cmd="clear",prompt="\$",timeout=10 )
diff --git a/TestON/drivers/common/cli/emulator/lincoedriver.py b/TestON/drivers/common/cli/emulator/lincoedriver.py
index a82cfa4..0f22b28 100644
--- a/TestON/drivers/common/cli/emulator/lincoedriver.py
+++ b/TestON/drivers/common/cli/emulator/lincoedriver.py
@@ -14,20 +14,11 @@
OCT 20 2014
"""
-import traceback
+
import pexpect
-import struct
-import fcntl
-import os
-import signal
-import re
import sys
-import core.teston
-import time
sys.path.append( "../" )
-from math import pow
from drivers.common.cli.emulatordriver import Emulator
-from drivers.common.clidriver import CLI
class LincOEDriver( Emulator ):
@@ -45,7 +36,6 @@
"""
Create ssh handle for Linc-OE cli
"""
- import time
for key in connectargs:
vars( self )[ key ] = connectargs[ key ]
@@ -127,10 +117,8 @@
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 + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -153,10 +141,8 @@
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 + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -175,10 +161,8 @@
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 + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -197,10 +181,8 @@
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 + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -220,13 +202,31 @@
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 + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
+ def attachLincOESession( self ):
+ """
+ Since executing opticalTest.py will give you mininet
+ prompt, you would at some point require to get onto
+ console of LincOE ((linc@onosTestBench)1>) to execute
+ commands like bring a optical port up or down on a ROADM
+ You can attach to console of Linc-OE session by a cmd:
+ sudo ~/linc-oe/rel/linc/bin/linc attach
+ """
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "sudo ~/linc-oe/rel/linc/bin/linc attach" )
+ self.handle.expect( ">" )
+ return main.TRUE
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ return main.FALSE
+
def listPorts( self, swId ):
"""
List all ports of a switch by switch id
@@ -242,10 +242,8 @@
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 + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -265,10 +263,8 @@
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 + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -288,10 +284,8 @@
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 + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -329,16 +323,18 @@
cmd = "sudo kill -9 `pgrep -f linc`"
self.handle.sendline( cmd )
self.handle.expect( "\$" )
-
+ # Close the ssh connection
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "exit" )
+ self.handle.expect( "closed" )
except pexpect.EOF:
main.log.error( self.name + ": EOF exception" )
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 + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index a45ed20..8f22fcf 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -35,7 +35,6 @@
Note that you may need to run 'sudo make develop' if your mnexec.c file
changed when switching branches."""
-import traceback
import pexpect
import re
import sys
@@ -52,6 +51,7 @@
def __init__( self ):
super( Emulator, self ).__init__()
self.handle = self
+ self.name = None
self.wrapped = sys.modules[ __name__ ]
self.flag = 0
@@ -59,82 +59,128 @@
"""
Here the main is the TestON instance after creating
all the log handles."""
- for key in connectargs:
- vars( self )[ key ] = connectargs[ key ]
+ try:
+ for key in connectargs:
+ vars( self )[ key ] = connectargs[ key ]
- self.name = self.options[ 'name' ]
- self.handle = super(
- MininetCliDriver,
- self ).connect(
- user_name=self.user_name,
- ip_address=self.ip_address,
- port=None,
- pwd=self.pwd )
+ self.name = self.options[ 'name' ]
+ self.handle = super(
+ MininetCliDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=None,
+ pwd=self.pwd )
- self.sshHandle = self.handle
+ if self.handle:
+ main.log.info( "Connection successful to the host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
+ return main.TRUE
+ else:
+ main.log.error( "Connection failed to the host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
+ main.log.error( "Failed to connect to the Mininet CLI" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+ def startNet( self, topoFile='', args='', timeout=120 ):
+ """
+ Starts Mininet accepts a topology(.py) file and/or an optional
+ argument ,to start the mininet, as a parameter.
+ Returns main.TRUE if the mininet starts successfully and
+ main.FALSE otherwise
+ """
if self.handle:
- main.log.info(
- self.name +
- ": Clearing any residual state or processes" )
+ # make sure old networks are cleaned up
+ main.log.info( self.name +
+ ": Clearing any residual state or processes" )
self.handle.sendline( "sudo mn -c" )
i = self.handle.expect( [ 'password\sfor\s',
'Cleanup\scomplete',
pexpect.EOF,
pexpect.TIMEOUT ],
- 120 )
+ timeout )
if i == 0:
+ # Sudo asking for password
main.log.info( self.name + ": Sending sudo password" )
self.handle.sendline( self.pwd )
- i = self.handle.expect( [ '%s:' % ( self.user ),
+ i = self.handle.expect( [ '%s:' % self.user,
'\$',
pexpect.EOF,
pexpect.TIMEOUT ],
- 120 )
+ timeout )
if i == 1:
main.log.info( self.name + ": Clean" )
elif i == 2:
main.log.error( self.name + ": Connection terminated" )
elif i == 3: # timeout
- main.log.error(
- self.name +
- ": Something while cleaning MN took too long... " )
-
- main.log.info( self.name + ": building fresh mininet" )
- # for reactive/PARP enabled tests
- cmdString = "sudo mn " + self.options[ 'arg1' ] +\
- " " + self.options[ 'arg2' ] +\
- " --mac --controller " +\
- self.options[ 'controller' ] + " " +\
- self.options[ 'arg3' ]
-
- argList = self.options[ 'arg1' ].split( "," )
- global topoArgList
- topoArgList = argList[ 0 ].split( " " )
- argList = map( int, argList[ 1: ] )
- topoArgList = topoArgList[ 1: ] + argList
-
+ main.log.error( self.name + ": Something while cleaning " +
+ "Mininet took too long... " )
+ # Craft the string to start mininet
+ cmdString = "sudo "
+ if topoFile is None or topoFile == '': # If no file is given
+ main.log.info( self.name + ": building fresh Mininet" )
+ cmdString += "mn "
+ if args is None or args == '':
+ # If no args given, use args from .topo file
+ args = self.options[ 'arg1' ] +\
+ " " + self.options[ 'arg2' ] +\
+ " --mac --controller " +\
+ self.options[ 'controller' ] + " " +\
+ self.options[ 'arg3' ]
+ else: # else only use given args
+ pass
+ # TODO: allow use of topo args and method args?
+ else: # Use given topology file
+ main.log.info( "Starting Mininet from topo file " + topoFile )
+ cmdString += topoFile + " "
+ if args is None:
+ args = ''
+ # TODO: allow use of args from .topo file?
+ cmdString += args
+ # Send the command and check if network started
+ self.handle.sendline( "" )
+ self.handle.expect( '\$' )
+ main.log.info( "Sending '" + cmdString + "' to " + self.name )
self.handle.sendline( cmdString )
- self.handle.expect( [ "sudo mn", pexpect.EOF, pexpect.TIMEOUT ] )
while True:
i = self.handle.expect( [ 'mininet>',
- '\*\*\*',
'Exception',
+ '\*\*\*',
pexpect.EOF,
pexpect.TIMEOUT ],
- 300 )
+ timeout )
if i == 0:
- main.log.info( self.name + ": mininet built" )
+ main.log.info( self.name + ": Mininet built" )
return main.TRUE
- if i == 1:
- self.handle.expect(
- [ "\n", pexpect.EOF, pexpect.TIMEOUT ] )
- main.log.info( self.handle.before )
- elif i == 2:
+ elif i == 1:
+ response = str( self.handle.before +
+ self.handle.after )
+ self.handle.expect( '\$' )
+ response += str( self.handle.before +
+ self.handle.after )
main.log.error(
self.name +
- ": Launching mininet failed..." )
+ ": Launching Mininet failed: " + response )
return main.FALSE
+ elif i == 2:
+ self.handle.expect( [ "\n",
+ pexpect.EOF,
+ pexpect.TIMEOUT ],
+ timeout )
+ main.log.info( self.handle.before )
elif i == 3:
main.log.error( self.name + ": Connection timeout" )
return main.FALSE
@@ -143,14 +189,12 @@
self.name +
": Something took too long... " )
return main.FALSE
- return main.TRUE
+ # Why did we hit this part?
+ main.log.error( "startNet did not return correctly" )
+ return main.FASLE
else: # if no handle
- main.log.error(
- self.name +
- ": Connection failed to the host " +
- self.user_name +
- "@" +
- self.ip_address )
+ main.log.error( self.name + ": Connection failed to the host " +
+ self.user_name + "@" + self.ip_address )
main.log.error( self.name + ": Failed to connect to the Mininet" )
return main.FALSE
@@ -186,61 +230,118 @@
numLinks = totalNumHosts + ( numSwitches - 1 )
print "num_switches for %s(%d,%d) = %d and links=%d" %\
( topoType, depth, fanout, numSwitches, numLinks )
- topoDict = {}
- topoDict = {
- "num_switches": int( numSwitches ),
- "num_corelinks": int( numLinks ) }
+ topoDict = { "num_switches": int( numSwitches ),
+ "num_corelinks": int( numLinks ) }
return topoDict
def calculateSwAndLinks( self ):
- topoDict = self.numSwitchesN_links( *topoArgList )
+ """
+ Calculate the number of switches and links in a topo."""
+ # TODO: combine this function and numSwitchesNlinks
+ argList = self.options[ 'arg1' ].split( "," )
+ topoArgList = argList[ 0 ].split( " " )
+ argList = map( int, argList[ 1: ] )
+ topoArgList = topoArgList[ 1: ] + argList
+
+ topoDict = self.numSwitchesNlinks( *topoArgList )
return topoDict
- def pingall( self, timeout=300 ):
+ def pingall( self, timeout=300, shortCircuit=False, acceptableFailed=0):
"""
Verifies the reachability of the hosts using pingall command.
Optional parameter timeout allows you to specify how long to
wait for pingall to complete
+ Optional:
+ timeout(seconds) - How long to wait before breaking the pingall
+ shortCircuit - Break the pingall based on the number of failed hosts
+ ping
+ acceptableFailed - Set the number of acceptable failed pings for the
+ function to still return main.TRUE
Returns:
main.TRUE if pingall completes with no pings dropped
- otherwise main.FALSE"""
- if self.handle:
- main.log.info(
- self.name +
- ": Checking reachabilty to the hosts using pingall" )
- try:
- response = self.execute(
- cmd="pingall",
- prompt="mininet>",
- timeout=int( timeout ) )
- except pexpect.EOF:
- main.log.error( self.name + ": EOF exception found" )
- main.log.error( self.name + ": " + self.handle.before )
+ otherwise main.FALSE
+ """
+ import time
+ try:
+ timeout = int( timeout )
+ if self.handle:
+ main.log.info(
+ self.name +
+ ": Checking reachabilty to the hosts using pingall" )
+ response = ""
+ failedPings = 0
+ returnValue = main.TRUE
+ self.handle.sendline( "pingall" )
+ startTime = time.time()
+ while True:
+ i = self.handle.expect( [ "mininet>","X",
+ pexpect.EOF,
+ pexpect.TIMEOUT ],
+ timeout )
+ if i == 0:
+ main.log.info( self.name + ": pingall finished")
+ response += self.handle.before
+ break
+ elif i == 1:
+ response += self.handle.before + self.handle.after
+ failedPings = failedPings + 1
+ if failedPings > acceptableFailed:
+ returnValue = main.FALSE
+ if shortCircuit:
+ main.log.error( self.name +
+ ": Aborting pingall - "
+ + str( failedPings ) +
+ " pings failed" )
+ break
+ if ( time.time() - startTime ) > timeout:
+ returnValue = main.FALSE
+ main.log.error( self.name +
+ ": Aborting pingall - " +
+ "Function took too long " )
+ break
+ elif i == 2:
+ main.log.error( self.name +
+ ": EOF exception found" )
+ main.log.error( self.name + ": " +
+ self.handle.before )
+ main.cleanup()
+ main.exit()
+ elif i == 3:
+ response += self.handle.before
+ main.log.error( self.name +
+ ": TIMEOUT exception found" )
+ main.log.error( self.name +
+ ": " +
+ str( response ) )
+ # NOTE: Send ctrl-c to make sure pingall is done
+ self.handle.sendline( "\x03" )
+ self.handle.expect( "Interrupt" )
+ self.handle.expect( "mininet>" )
+ break
+ pattern = "Results\:"
+ main.log.info( "Pingall output: " + str( response ) )
+ if re.search( pattern, response ):
+ main.log.info( self.name + ": Pingall finished with "
+ + str( failedPings ) + " failed pings" )
+ return returnValue
+ else:
+ # NOTE: Send ctrl-c to make sure pingall is done
+ self.handle.sendline( "\x03" )
+ self.handle.expect( "Interrupt" )
+ self.handle.expect( "mininet>" )
+ return main.FALSE
+ else:
+ main.log.error( self.name + ": Connection failed to the host" )
main.cleanup()
main.exit()
- except pexpect.TIMEOUT:
- # We may not want to kill the test if pexpect times out
- main.log.error( self.name + ": TIMEOUT exception found" )
- main.log.error( self.name +
- ": " +
- str( self.handle.before ) )
- # NOTE: mininet's pingall rounds, so we will check the number of
- # passed and number of failed
- pattern = "Results\:\s0\%\sdropped\s\(" +\
- "(?P<passed>[\d]+)/(?P=passed)"
- if re.search( pattern, response ):
- main.log.info( self.name + ": All hosts are reachable" )
- return main.TRUE
- else:
- main.log.error( self.name + ": Unable to reach all the hosts" )
+ except pexpect.TIMEOUT:
+ if response:
main.log.info( "Pingall output: " + str( response ) )
- # NOTE: Send ctrl-c to make sure pingall is done
- self.handle.send( "\x03" )
- self.handle.expect( "Interrupt" )
- self.handle.expect( "mininet>" )
- return main.FALSE
- else:
- main.log.error( self.name + ": Connection failed to the host" )
+ main.log.error( self.name + ": pexpect.TIMEOUT found" )
+ 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()
@@ -266,6 +367,64 @@
main.log.info( self.name + ": \n---\n" + response )
return main.FALSE
+ def pingallHosts( self, hostList, pingType='ipv4' ):
+ """
+ Ping all specified hosts with a specific ping type
+
+ Acceptable pingTypes:
+ - 'ipv4'
+ - 'ipv6'
+
+ Acceptable hostList:
+ - ['h1','h2','h3','h4']
+
+ Returns main.TRUE if all hosts specified can reach
+ each other
+
+ Returns main.FALSE if one or more of hosts specified
+ cannot reach each other"""
+
+ if pingType == "ipv4":
+ cmd = " ping -c 1 -i 1 -W 8 "
+ elif pingType == "ipv6":
+ cmd = " ping6 -c 1 -i 1 -W 8 "
+ else:
+ main.log.warn( "Invalid pingType specified" )
+ return
+
+ try:
+ main.log.info( "Testing reachability between specified hosts" )
+
+ isReachable = main.TRUE
+
+ for host in hostList:
+ listIndex = hostList.index(host)
+ # List of hosts to ping other than itself
+ pingList = hostList[:listIndex] + hostList[(listIndex+1):]
+
+ for temp in pingList:
+ # Current host pings all other hosts specified
+ pingCmd = str(host) + cmd + str(temp)
+ self.handle.sendline( pingCmd )
+ i = self.handle.expect( [ pingCmd, pexpect.TIMEOUT ] )
+ j = self.handle.expect( [ "mininet>", pexpect.TIMEOUT ] )
+ response = self.handle.before
+ if re.search( ',\s0\%\spacket\sloss', response ):
+ main.log.info( str(host) + " -> " + str(temp) )
+ else:
+ main.log.info( str(host) + " -> X ("+str(temp)+") "
+ " Destination Unreachable" )
+ # One of the host to host pair is unreachable
+ isReachable = main.FALSE
+
+ return isReachable
+
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+
def pingHost( self, **pingParams ):
"""
Ping from one mininet host to another
@@ -274,7 +433,7 @@
command = args[ "SRC" ] + " ping " + \
args[ "TARGET" ] + " -c 1 -i 1 -W 8"
try:
- main.log.warn( "Sending: " + command )
+ main.log.info( "Sending: " + command )
self.handle.sendline( command )
i = self.handle.expect( [ command, pexpect.TIMEOUT ] )
if i == 1:
@@ -339,6 +498,7 @@
main.log.error( self.name + ": Connection failed to the host" )
def verifySSH( self, **connectargs ):
+ # FIXME: Who uses this and what is the purpose? seems very specific
try:
response = self.execute(
cmd="h1 /usr/sbin/sshd -D&",
@@ -367,6 +527,99 @@
else:
return main.TRUE
+ def moveHost( self, host, oldSw, newSw, ):
+ """
+ Moves a host from one switch to another on the fly
+ Note: The intf between host and oldSw when detached
+ using detach(), will still show up in the 'net'
+ cmd, because switch.detach() doesn't affect switch.intfs[]
+ (which is correct behavior since the interfaces
+ haven't moved).
+ """
+ if self.handle:
+ try:
+ # Bring link between oldSw-host down
+ cmd = "py net.configLinkStatus('" + oldSw + "'," + "'"+ host +\
+ "'," + "'down')"
+ print "cmd1= ", cmd
+ response = self.execute( cmd=cmd,
+ prompt="mininet>",
+ timeout=10 )
+
+ # Determine hostintf and Oldswitchintf
+ cmd = "px hintf,sintf = " + host + ".connectionsTo(" + oldSw +\
+ ")[0]"
+ print "cmd2= ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+
+ # Determine ip and mac address of the host-oldSw interface
+ cmd = "px ipaddr = hintf.IP()"
+ print "cmd3= ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+
+ cmd = "px macaddr = hintf.MAC()"
+ print "cmd3= ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+
+ # Detach interface between oldSw-host
+ cmd = "px " + oldSw + ".detach( sintf )"
+ print "cmd4= ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+
+ # Add link between host-newSw
+ cmd = "py net.addLink(" + host + "," + newSw + ")"
+ print "cmd5= ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+
+ # Determine hostintf and Newswitchintf
+ cmd = "px hintf,sintf = " + host + ".connectionsTo(" + newSw +\
+ ")[0]"
+ print "cmd6= ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+
+ # Attach interface between newSw-host
+ cmd = "px " + newSw + ".attach( sintf )"
+ print "cmd3= ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+
+ # Set ipaddress of the host-newSw interface
+ cmd = "px " + host + ".setIP( ip = ipaddr, intf = hintf)"
+ print "cmd7 = ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+
+ # Set macaddress of the host-newSw interface
+ cmd = "px " + host + ".setMAC( mac = macaddr, intf = hintf)"
+ print "cmd8 = ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+
+ cmd = "net"
+ print "cmd9 = ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+ print "output = ", self.handle.before
+
+ # Determine ipaddress of the host-newSw interface
+ cmd = host + " ifconfig"
+ print "cmd10= ", cmd
+ self.handle.sendline( cmd )
+ self.handle.expect( "mininet>" )
+ print "ifconfig o/p = ", self.handle.before
+
+ return main.TRUE
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ return main.FALSE
+
def changeIP( self, host, intf, newIP, newNetmask ):
"""
Changes the ip address of a host on the fly
@@ -414,7 +667,7 @@
def addStaticMACAddress( self, host, GW, macaddr ):
"""
- Changes the mac address of a geateway host"""
+ Changes the mac address of a gateway host"""
if self.handle:
try:
# h1 arp -s 10.0.1.254 00:00:00:00:11:11
@@ -424,7 +677,7 @@
response = self.handle.before
main.log.info( "response = " + response )
main.log.info(
- "Mac adrress of gateway " +
+ "Mac address of gateway " +
GW +
" changed to " +
macaddr )
@@ -653,7 +906,7 @@
self.handle.expect( "mininet>" )
response = self.handle.before
if re.search( 'Results:', response ):
- main.log.info( self.name + ": iperf test succssful" )
+ main.log.info( self.name + ": iperf test successful" )
return main.TRUE
else:
main.log.error( self.name + ": iperf test failed" )
@@ -805,6 +1058,8 @@
return main.TRUE
def getVersion( self ):
+ #FIXME: What uses this? This should be refactored to get
+ # version from MN and not some other file
fileInput = path + '/lib/Mininet/INSTALL'
version = super( Mininet, self ).getVersion()
pattern = 'Mininet\s\w\.\w\.\w\w*'
@@ -880,10 +1135,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 50 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 50 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -911,10 +1164,10 @@
dynamic_topo branch
NOTE: cannot currently specify what type of switch
required params:
- switchname = name of the new switch as a string
- optional keyvalues:
+ sw = name of the new switch as a string
+ optional keywords:
dpid = "dpid"
- returns: main.FASLE on an error, else main.TRUE
+ returns: main.FALSE on an error, else main.TRUE
"""
dpid = kwargs.get( 'dpid', '' )
command = "addswitch " + str( sw ) + " " + str( dpid )
@@ -946,8 +1199,8 @@
NOTE: This uses a custom mn function. MN repo should be on
dynamic_topo branch
required params:
- switchname = name of the switch as a string
- returns: main.FASLE on an error, else main.TRUE"""
+ sw = name of the switch as a string
+ returns: main.FALSE on an error, else main.TRUE"""
command = "delswitch " + str( sw )
try:
response = self.execute(
@@ -980,7 +1233,7 @@
required params:
node1 = the string node name of the first endpoint of the link
node2 = the string node name of the second endpoint of the link
- returns: main.FASLE on an error, else main.TRUE"""
+ returns: main.FALSE on an error, else main.TRUE"""
command = "addlink " + str( node1 ) + " " + str( node2 )
try:
response = self.execute(
@@ -1012,7 +1265,7 @@
required params:
node1 = the string node name of the first endpoint of the link
node2 = the string node name of the second endpoint of the link
- returns: main.FASLE on an error, else main.TRUE"""
+ returns: main.FALSE on an error, else main.TRUE"""
command = "dellink " + str( node1 ) + " " + str( node2 )
try:
response = self.execute(
@@ -1046,7 +1299,7 @@
hostname = the string hostname
optional key-value params
switch = "switch name"
- returns: main.FASLE on an error, else main.TRUE
+ returns: main.FALSE on an error, else main.TRUE
"""
switch = kwargs.get( 'switch', '' )
command = "addhost " + str( hostname ) + " " + str( switch )
@@ -1083,7 +1336,7 @@
NOTE: this uses a custom mn function
required params:
hostname = the string hostname
- returns: main.FASLE on an error, else main.TRUE"""
+ returns: main.FALSE on an error, else main.TRUE"""
command = "delhost " + str( hostname )
try:
response = self.execute(
@@ -1108,20 +1361,70 @@
main.exit()
def disconnect( self ):
- main.log.info( self.name + ": Disconnecting mininet..." )
+ """
+ Called at the end of the test to stop the mininet and
+ disconnect the handle.
+ """
+ self.handle.sendline('')
+ i = self.handle.expect( [ 'mininet>', pexpect.EOF, pexpect.TIMEOUT ],
+ timeout=2)
+ response = main.TRUE
+ if i == 0:
+ response = self.stopNet()
+ elif i == 1:
+ return main.TRUE
+ # print "Disconnecting Mininet"
+ if self.handle:
+ self.handle.sendline( "exit" )
+ self.handle.expect( "exit" )
+ self.handle.expect( "(.*)" )
+ else:
+ main.log.error( "Connection failed to the host" )
+ return response
+
+ def stopNet( self, fileName = "", timeout=5):
+ """
+ Stops mininet.
+ Returns main.TRUE if the mininet successfully stops and
+ main.FALSE if the pexpect handle does not exist.
+
+ Will cleanup and exit the test if mininet fails to stop
+ """
+
+ main.log.info( self.name + ": Stopping mininet..." )
response = ''
if self.handle:
try:
+ self.handle.sendline("")
+ i = self.handle.expect( [ 'mininet>',
+ '\$',
+ pexpect.EOF,
+ pexpect.TIMEOUT ],
+ timeout )
+ if i == 0:
+ main.log.info( "Exiting mininet..." )
+
response = self.execute(
cmd="exit",
prompt="(.*)",
timeout=120 )
- response = self.execute(
- cmd="exit",
- prompt="(.*)",
- timeout=120 )
+ main.log.info( self.name + ": Stopped")
self.handle.sendline( "sudo mn -c" )
response = main.TRUE
+
+ if i == 1:
+ main.log.info( " Mininet trying to exit while not " +
+ "in the mininet prompt" )
+ elif i == 2:
+ main.log.error( "Something went wrong exiting mininet" )
+ elif i == 3: # timeout
+ main.log.error( "Something went wrong exiting mininet " +
+ "TIMEOUT" )
+
+ if fileName:
+ self.handle.sendline("")
+ self.handle.expect('\$')
+ self.handle.sendline("sudo kill -9 \`ps -ef | grep \""+ fileName +"\" | grep -v grep | awk '{print $2}'\`")
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1142,7 +1445,7 @@
main.log.info( self.name + ": ARP successful" )
self.handle.expect( [ "mininet", pexpect.EOF, pexpect.TIMEOUT ] )
return main.TRUE
- except:
+ except Exception:
main.log.warn( self.name + ": ARP FAILURE" )
self.handle.expect( [ "mininet", pexpect.EOF, pexpect.TIMEOUT ] )
return main.FALSE
@@ -1193,12 +1496,10 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- else:
- main.log.info( response )
def startTcpdump( self, filename, intf="eth0", port="port 6633" ):
"""
- Runs tpdump on an intferface and saves the file
+ Runs tpdump on an interface and saves the file
intf can be specified, or the default eth0 is used"""
try:
self.handle.sendline( "" )
@@ -1248,15 +1549,14 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 50 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 50 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def stopTcpdump( self ):
- "pkills tcpdump"
+ """
+ pkills tcpdump"""
try:
self.handle.sendline( "sh sudo pkill tcpdump" )
self.handle.expect( "mininet>" )
@@ -1267,10 +1567,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 50 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 50 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1289,8 +1587,7 @@
ports = []
for port in switch.ports.values():
ports.append( { 'of_port': port.port_no,
- 'mac': str( port.hw_addr ).replace( '\'',
- '' ),
+ 'mac': str( port.hw_addr ).replace( '\'', '' ),
'name': port.name } )
output[ 'switches' ].append( {
"name": switch.name,
@@ -1299,12 +1596,12 @@
# print "mn"
# print json.dumps( output,
- # sortKeys=True,
+ # sort_keys=True,
# indent=4,
# separators=( ',', ': ' ) )
# print "onos"
# print json.dumps( switchesJson,
- # sortKeys=True,
+ # sort_keys=True,
# indent=4,
# separators=( ',', ': ' ) )
@@ -1318,7 +1615,7 @@
if switchesJson == "": # if rest call fails
main.log.error(
self.name +
- ".compare_switches(): Empty JSON object given from ONOS" )
+ ".compareSwitches(): Empty JSON object given from ONOS" )
return main.FALSE
onos = switchesJson
onosDPIDs = []
@@ -1371,17 +1668,15 @@
ports = []
for port in switch.ports.values():
# print port.hw_addr.toStr( separator='' )
- tmpPort = {}
- tmpPort[ 'of_port' ] = port.port_no
- tmpPort[ 'mac' ] = str( port.hw_addr ).replace( '\'', '' )
- tmpPort[ 'name' ] = port.name
- tmpPort[ 'enabled' ] = port.enabled
+ tmpPort = { 'of_port': port.port_no,
+ 'mac': str( port.hw_addr ).replace( '\'', '' ),
+ 'name': port.name,
+ 'enabled': port.enabled }
ports.append( tmpPort )
- tmpSwitch = {}
- tmpSwitch[ 'name' ] = switch.name
- tmpSwitch[ 'dpid' ] = str( switch.dpid ).zfill( 16 )
- tmpSwitch[ 'ports' ] = ports
+ tmpSwitch = { 'name': switch.name,
+ 'dpid': str( switch.dpid ).zfill( 16 ),
+ 'ports': ports }
output[ 'switches' ].append( tmpSwitch )
@@ -1462,8 +1757,7 @@
This uses the sts TestONTopology object"""
# FIXME: this does not look for extra links in ONOS, only checks that
- # ONOS has what is in MN
- linkResults = main.TRUE
+ # ONOS has what is in MN
output = { "switches": [] }
onos = linksJson
# iterate through the MN topology and pull out switches and and port
@@ -1475,8 +1769,7 @@
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( '\'',
- '' ),
+ 'mac': str( port.hw_addr ).replace( '\'', '' ),
'name': port.name } )
output[ 'switches' ].append( {
"name": switch.name,
@@ -1552,7 +1845,7 @@
main.log.warn(
'The port numbers do not match for ' +
str( link ) +
- ' between ONOS and MN. When cheking ONOS for ' +
+ ' between ONOS and MN. When checking ONOS for ' +
'link %s/%s -> %s/%s' %
( node1,
port1,
@@ -1574,7 +1867,7 @@
main.log.warn(
'The port numbers do not match for ' +
str( link ) +
- ' between ONOS and MN. When cheking ONOS for ' +
+ ' between ONOS and MN. When checking ONOS for ' +
'link %s/%s -> %s/%s' %
( node2,
port2,
@@ -1598,6 +1891,64 @@
linkResults = linkResults and firstDir and secondDir
return linkResults
+ def compareHosts( self, topo, hostsJson ):
+ """
+ Compare mn and onos Hosts.
+ Since Mininet hosts are quiet, ONOS will only know of them when they
+ speak. For this reason, we will only check that the hosts in ONOS
+ stores are in Mininet, and not vice versa.
+ topo: sts TestONTopology object
+ hostsJson: parsed json object from the onos hosts api
+
+ This uses the sts TestONTopology object"""
+ import json
+ hostResults = main.TRUE
+ hosts = []
+ # iterate through the MN topology and pull out hosts
+ for mnHost in topo.graph.hosts:
+ interfaces = []
+ for intf in mnHost.interfaces:
+ interfaces.append( {
+ "name": intf.name, # str
+ "ips": [ str( ip ) for ip in intf.ips ], # list of IPAddrs
+ # hw_addr is of type EthAddr, Not JSON serializable
+ "hw_addr": str( intf.hw_addr ) } )
+ hosts.append( {
+ "name": mnHost.name, # str
+ "interfaces": interfaces } ) # list
+ for onosHost in hostsJson:
+ onosMAC = onosHost[ 'mac' ].lower()
+ match = False
+ for mnHost in hosts:
+ for mnIntf in mnHost[ 'interfaces' ]:
+ if onosMAC == mnIntf[ 'hw_addr' ].lower() :
+ match = True
+ for ip in mnIntf[ 'ips' ]:
+ if ip in onosHost[ 'ipAddresses' ]:
+ pass # all is well
+ else:
+ # misssing ip
+ main.log.error( "ONOS host " + onosHost[ 'id' ]
+ + " has a different IP than " +
+ "the Mininet host." )
+ output = json.dumps(
+ onosHost,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) )
+ main.log.info( output )
+ hostResults = main.FALSE
+ if not match:
+ hostResults = main.FALSE
+ main.log.error( "ONOS host " + onosHost[ 'id' ] + " has no " +
+ "corresponding Mininet host." )
+ output = json.dumps( onosHost,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) )
+ main.log.info( output )
+ return hostResults
+
def getHosts( self ):
"""
Returns a list of all hosts
@@ -1627,7 +1978,7 @@
updates the port address and status information for
each port in mn"""
# TODO: Add error checking. currently the mininet command has no output
- main.log.info( "Updateing MN port information" )
+ main.log.info( "Updating MN port information" )
try:
self.handle.sendline( "" )
self.handle.expect( "mininet>" )
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index e15e53c..0958531 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -21,7 +21,6 @@
MininetCliDriver is the basic driver which will handle the Mininet functions
"""
-import traceback
import pexpect
import re
import sys
@@ -40,6 +39,7 @@
def __init__( self ):
super( Emulator, self ).__init__()
self.handle = self
+ self.name = None
self.wrapped = sys.modules[ __name__ ]
self.flag = 0
@@ -59,8 +59,6 @@
port=None,
pwd=self.pwd )
- self.sshHandle = self.handle
-
# Copying the readme file to process the
if self.handle:
return main.TRUE
@@ -94,12 +92,12 @@
return main.ERROR
else:
main.log.error( "Error, unexpected output in the ping file" )
- main.log.warn( outputs )
+ #main.log.warn( outputs )
return main.TRUE
def pingLong( self, **pingParams ):
"""
- Starts a continuous ping on the mininet host outputing
+ Starts a continuous ping on the mininet host outputting
to a file in the /tmp dir.
"""
self.handle.sendline( "" )
@@ -109,8 +107,9 @@
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' ] ) +\
- " -D > /tmp/ping." + args[ "SRC" ] + " &"
+ 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( "" )
@@ -182,7 +181,7 @@
def pingHostOptical( self, **pingParams ):
"""
- This function is only for Packey Optical related ping
+ This function is only for Packet Optical related ping
Use the next pingHost() function for all normal scenarios )
Ping from one mininet host to another
Currently the only supported Params: SRC and TARGET
@@ -281,7 +280,7 @@
port="port 6633",
user="admin" ):
"""
- Runs tpdump on an intferface and saves the file
+ Runs tcpdump on an interface and saves the file
intf can be specified, or the default eth0 is used
"""
try:
@@ -300,7 +299,7 @@
self.handle.sendline( "" )
i = self.handle.expect( [ 'No\ssuch\device', 'listening\son',
pexpect.TIMEOUT, "\$" ], timeout=10 )
- main.log.warn( self.handle.before + self.handle.after )
+ main.log.info( self.handle.before + self.handle.after )
if i == 0:
main.log.error( self.name + ": tcpdump - No such device exists.\
tcpdump attempted on: " + intf )
@@ -323,46 +322,72 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info(
- self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 80 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def stopTcpdump( self ):
- "pkills tcpdump"
+ """
+ pkills tcpdump"""
try:
self.handle.sendline( "sudo pkill tcpdump" )
self.handle.sendline( "" )
- self.handle.sendline( "" )
self.handle.expect( "\$" )
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 + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 80 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
- def runOpticalMnScript( self ):
+ def runOpticalMnScript( self, ctrllerIP = None ):
+ import time
"""
This function is only meant for Packet Optical.
- It runs the python script "optical.py" to create the
- packet layer( mn ) topology
+ It runs python script "opticalTest.py" to create the
+ packet layer( mn ) and optical topology
+
+ TODO: If no ctrllerIP is provided, a default
+ $OC1 can be accepted
"""
try:
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "cd ~" )
+ self.handle.sendline( "cd ~/onos/tools/test/topos" )
+ self.handle.expect( "topos\$" )
+ if ctrllerIP == None:
+ main.log.info( "You need to specify the IP" )
+ return main.FALSE
+ else:
+ cmd = "sudo -E python opticalTest.py " + ctrllerIP
+ self.handle.sendline( cmd )
+ self.handle.expect( "Press ENTER to push Topology.json" )
+ time.sleep(15)
+ self.handle.sendline( "" )
+ self.handle.expect("mininet>")
+ return main.TRUE
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ return main.FALSE
+
+ def attachLincOESession( self ):
+ """
+ Since executing opticalTest.py will give you mininet
+ prompt, you would at some point require to get onto
+ console of LincOE ((linc@onosTestBench)1>) to execute
+ commands like bring a optical port up or down on a ROADM
+ You can attach to console of Linc-OE session by a cmd:
+ sudo ~/linc-oe/rel/linc/bin/linc attach
+ """
+ try:
+ self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "sudo python optical.py" )
+ self.handle.sendline( "sudo ~/linc-oe/rel/linc/bin/linc attach" )
self.handle.expect( ">" )
return main.TRUE
except pexpect.EOF:
@@ -374,23 +399,30 @@
"""
Called at the end of the test to disconnect the handle.
"""
- response = ''
- # print "Disconnecting Mininet"
if self.handle:
- self.handle.sendline( "exit" )
- self.handle.expect( "exit" )
- self.handle.expect( "(.*)" )
- response = self.handle.before
-
+ # Close the ssh connection
+ self.handle.sendline( "" )
+ # self.handle.expect( "\$" )
+ i = self.handle.expect( [ '\$', 'mininet>', pexpect.TIMEOUT,
+ pexpect.EOF ], timeout=2 )
+ if i == 0:
+ self.handle.sendline( "exit" )
+ self.handle.expect( "closed" )
+ elif i == 1:
+ self.handle.sendline( "exit" )
+ self.handle.expect( "exit" )
+ self.handle.expect('\$')
+ self.handle.sendline( "exit" )
+ self.handle.expect( "exit" )
+ self.handle.expect( "closed" )
else:
main.log.error( "Connection failed to the host" )
- response = main.FALSE
- return response
+ return main.TRUE
def getFlowTable( self, protoVersion, sw ):
"""
TODO document usage
- TODO add option to look at cookies. ignoreing them for now
+ TODO add option to look at cookies. ignoring them for now
print "get_flowTable(" + str( protoVersion ) +" " + str( sw ) +")"
NOTE: Use format to force consistent flow table output across
@@ -563,7 +595,7 @@
str( rule ) )
infoString = "Rules added to " + str( self.name )
- infoString += "iptable rule added to block IP: " + \
+ infoString += "iptables rule added to block IP: " + \
str( dstIp )
infoString += "Port: " + \
str( dstPort ) + " Rule: " + str( rule )
@@ -576,8 +608,9 @@
main.log.error(
self.name +
": Timeout exception in setIpTables function" )
- except:
- main.log.error( traceback.print_exc() )
+ except Exception:
+ main.log.exception( self.name +
+ ": Uncaught exception!" )
main.cleanup()
main.exit()
else:
@@ -619,8 +652,9 @@
main.log.error(
self.name +
": Timeout exception in setIpTables function" )
- except:
- main.log.error( traceback.print_exc() )
+ except Exception:
+ main.log.exception( self.name +
+ ": Uncaught exception!" )
main.cleanup()
main.exit()
else:
diff --git a/TestON/drivers/common/cli/emulatordriver.py b/TestON/drivers/common/cli/emulatordriver.py
index bb8da7c..778a32b 100644
--- a/TestON/drivers/common/cli/emulatordriver.py
+++ b/TestON/drivers/common/cli/emulatordriver.py
@@ -19,12 +19,6 @@
"""
-import pexpect
-import struct
-import fcntl
-import os
-import sys
-import signal
import sys
sys.path.append( "../" )
from drivers.common.clidriver import CLI
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 097a303..c7e25e0 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -19,7 +19,9 @@
import sys
import pexpect
import re
-import traceback
+import json
+import types
+import time
sys.path.append( "../" )
from drivers.common.clidriver import CLI
@@ -30,6 +32,9 @@
"""
Initialize client
"""
+ self.name = None
+ self.home = None
+ self.handle = None
super( CLI, self ).__init__()
def connect( self, **connectargs ):
@@ -39,11 +44,13 @@
try:
for key in connectargs:
vars( self )[ key ] = connectargs[ key ]
- self.home = "~/ONOS"
+ self.home = "~/onos"
for key in self.options:
if key == "home":
self.home = self.options[ 'home' ]
break
+ if self.home is None or self.home == "":
+ self.home = "~/onos"
self.name = self.options[ 'name' ]
self.handle = super( OnosCliDriver, self ).connect(
@@ -60,15 +67,16 @@
else:
main.log.info( "NO ONOS HANDLE" )
return main.FALSE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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( ":::::::::::::::::::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -76,53 +84,65 @@
"""
Called when Test is complete to disconnect the ONOS handle.
"""
- response = ''
+ response = main.TRUE
try:
- self.handle.sendline( "" )
- i = self.handle.expect( [ "onos>", "\$" ] )
- if i == 0:
- self.handle.sendline( "system:shutdown" )
- self.handle.expect( "Confirm" )
- self.handle.sendline( "yes" )
- self.handle.expect( "\$" )
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
- self.handle.sendline( "exit" )
- self.handle.expect( "closed" )
-
+ if self.handle:
+ i = self.logout()
+ if i == main.TRUE:
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "exit" )
+ self.handle.expect( "closed" )
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ response = main.FALSE
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
- main.log.error( self.name + ": Connection failed to the host" )
+ except ValueError:
+ main.log.exception( "Exception in disconnect of " + self.name )
+ response = main.TRUE
+ except Exception:
+ main.log.exception( self.name + ": Connection failed to the host" )
response = main.FALSE
return response
def logout( self ):
"""
Sends 'logout' command to ONOS cli
+ Returns main.TRUE if exited CLI and
+ main.FALSE on timeout (not guranteed you are disconnected)
+ None on TypeError
+ Exits test on unknown error or pexpect exits unexpectedly
"""
try:
- self.handle.sendline( "" )
- i = self.handle.expect( [
- "onos>",
- "\$" ], timeout=10 )
- if i == 0:
- self.handle.sendline( "logout" )
- self.handle.expect( "\$" )
- elif i == 1:
+ if self.handle:
+ self.handle.sendline( "" )
+ i = self.handle.expect( [ "onos>", "\$", pexpect.TIMEOUT ],
+ timeout=10 )
+ if i == 0: # In ONOS CLI
+ self.handle.sendline( "logout" )
+ self.handle.expect( "\$" )
+ return main.TRUE
+ elif i == 1: # not in CLI
+ return main.TRUE
+ elif i == 3: # Timeout
+ return main.FALSE
+ else:
return main.TRUE
-
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
except pexpect.EOF:
main.log.error( self.name + ": eof exception found" )
- main.log.error( self.name + ": " +
- self.handle.before )
+ 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 + " ::::::" )
+ except ValueError:
+ main.log.error( self.name +
+ "ValueError exception in logout method" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -142,12 +162,12 @@
# Expect the cellname in the ONOSCELL variable.
# Note that this variable name is subject to change
# and that this driver will have to change accordingly
- self.handle.expect( "ONOS_CELL=" + str( cellname ) )
+ self.handle.expect(str(cellname))
handleBefore = self.handle.before
handleAfter = self.handle.after
# Get the rest of the handle
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.sendline("")
+ self.handle.expect("\$")
handleMore = self.handle.before
main.log.info( "Cell call returned: " + handleBefore +
@@ -155,21 +175,22 @@
return main.TRUE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def startOnosCli( self, ONOSIp, karafTimeout="" ):
"""
- karafTimeout is an optional arugument. karafTimeout value passed
+ karafTimeout is an optional argument. karafTimeout value passed
by user would be used to set the current karaf shell idle timeout.
Note that when ever this property is modified the shell will exit and
the subsequent login would reflect new idle timeout.
@@ -232,19 +253,54 @@
str( ONOSIp ) + " timeout" )
return main.FALSE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
- def sendline( self, cmdStr ):
+ def log( self, cmdStr, level="" ):
+ """
+ log the commands in the onos CLI.
+ returns main.TRUE on success
+ returns main.FALSE if Error occurred
+ Available level: DEBUG, TRACE, INFO, WARN, ERROR
+ Level defaults to INFO
+ """
+ try:
+ lvlStr = ""
+ if level:
+ lvlStr = "--level=" + level
+
+ self.handle.sendline( "" )
+ self.handle.expect( "onos>" )
+ self.handle.sendline( "log:log " + lvlStr + " " + cmdStr )
+ self.handle.expect( "log:log" )
+ self.handle.expect( "onos>" )
+
+ response = self.handle.before
+ if re.search( "Error", response ):
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def sendline( self, cmdStr, debug=False ):
"""
Send a completely user specified string to
the onos> prompt. Use this function if you have
@@ -254,38 +310,67 @@
sent using this method.
"""
try:
- self.handle.sendline( "" )
- self.handle.expect( "onos>" )
-
- self.handle.sendline( "log:log \"Sending CLI command: '"
- + cmdStr + "'\"" )
- self.handle.expect( "onos>" )
+ logStr = "\"Sending CLI command: '" + cmdStr + "'\""
+ self.log( logStr )
self.handle.sendline( cmdStr )
- self.handle.expect( "onos>" )
+ i = self.handle.expect( ["onos>", "\$", pexpect.TIMEOUT] )
+ response = self.handle.before
+ if i == 2:
+ self.handle.sendline()
+ self.handle.expect( ["\$", pexpect.TIMEOUT] )
+ response += self.handle.before
+ print response
+ try:
+ print self.handle.after
+ except TypeError:
+ pass
+ # TODO: do something with i
main.log.info( "Command '" + str( cmdStr ) + "' sent to "
+ self.name + "." )
+ if debug:
+ main.log.debug( self.name + ": Raw output" )
+ main.log.debug( self.name + ": " + repr( response ) )
- handle = self.handle.before
- # Remove control strings from output
+ # Remove ANSI color control strings from output
ansiEscape = re.compile( r'\x1b[^m]*m' )
- handle = ansiEscape.sub( '', handle )
- #Remove extra return chars that get added
- handle = re.sub( r"\s\r", "", handle )
- handle = handle.strip()
- # parse for just the output, remove the cmd from handle
- output = handle.split( cmdStr, 1 )[1]
+ response = ansiEscape.sub( '', response )
+ if debug:
+ main.log.debug( self.name + ": ansiEscape output" )
+ main.log.debug( self.name + ": " + repr( response ) )
+ # Remove extra return chars that get added
+ response = re.sub( r"\s\r", "", response )
+ if debug:
+ main.log.debug( self.name + ": Removed extra returns " +
+ "from output" )
+ main.log.debug( self.name + ": " + repr( response ) )
- return output
+ # Strip excess whitespace
+ response = response.strip()
+ if debug:
+ main.log.debug( self.name + ": parsed and stripped output" )
+ main.log.debug( self.name + ": " + repr( response ) )
+
+ # parse for just the output, remove the cmd from response
+ output = response.split( cmdStr.strip(), 1 )
+ if debug:
+ main.log.debug( self.name + ": split output" )
+ for r in output:
+ main.log.debug( self.name + ": " + repr( r ) )
+ return output[1].strip()
+ except IndexError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -316,15 +401,16 @@
else:
main.log.info( "Node " + str( ONOSIp ) + " added" )
return main.TRUE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -338,78 +424,96 @@
try:
cmdStr = "remove-node " + str( nodeId )
- self.sendline( cmdStr )
- # TODO: add error checking. Does ONOS give any errors?
-
- return main.TRUE
-
+ handle = self.sendline( cmdStr )
+ if re.search( "Error", handle ):
+ main.log.error( "Error in removing node" )
+ main.log.error( handle )
+ return main.FALSE
+ else:
+ return main.TRUE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
- def nodes( self ):
+ def nodes( self, jsonFormat=True):
"""
List the nodes currently visible
Issues command: 'nodes'
- Returns: entire handle of list of nodes
+ Optional argument:
+ * jsonFormat - boolean indicating if you want output in json
"""
try:
cmdStr = "nodes"
- handle = self.sendline( cmdStr )
- return handle
+ if jsonFormat:
+ cmdStr += " -j"
+ output = self.sendline( cmdStr )
+ return output
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def topology( self ):
"""
- Shows the current state of the topology
- by issusing command: 'onos> onos:topology'
+ Definition:
+ Returns the output of topology command.
+ Return:
+ topology = current ONOS topology
"""
try:
- # either onos:topology or 'topology' will work in CLI
- cmdStr = "onos:topology"
+ cmdStr = "topology -j"
handle = self.sendline( cmdStr )
- main.log.info( "onos:topology returned: " + str( handle ) )
+ main.log.info( cmdStr + " returned: " + str( handle ) )
return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def featureInstall( self, featureStr ):
"""
- Installs a specified feature
- by issuing command: 'onos> feature:install <feature_str>'
+ Installs a specified feature by issuing command:
+ 'feature:install <feature_str>'
+ NOTE: This is now deprecated, you should use the activateApp method
+ instead
"""
try:
cmdStr = "feature:install " + str( featureStr )
- self.sendline( cmdStr )
- # TODO: Check for possible error responses from karaf
- return main.TRUE
+ handle = self.sendline( cmdStr )
+ if re.search( "Error", handle ):
+ main.log.error( "Error in installing feature" )
+ main.log.error( handle )
+ return main.FALSE
+ else:
+ return main.TRUE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -417,34 +521,75 @@
main.log.report( "Exiting test" )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + " ::::::" )
- main.log.error( traceback.print_exc() )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.log.report( "Failed to install feature" )
main.log.report( "Exiting test" )
- main.log.info( self.name + " ::::::" )
main.cleanup()
main.exit()
def featureUninstall( self, featureStr ):
"""
- Uninstalls a specified feature
- by issuing command: 'onos> feature:uninstall <feature_str>'
+ Uninstalls a specified feature by issuing command:
+ 'feature:uninstall <feature_str>'
+ NOTE: This is now deprecated, you should use the deactivateApp method
+ instead
"""
try:
- cmdStr = "feature:uninstall " + str( featureStr )
- self.sendline( cmdStr )
- # TODO: Check for possible error responses from karaf
- return main.TRUE
+ cmdStr = 'feature:list -i | grep "' + featureStr + '"'
+ handle = self.sendline( cmdStr )
+ if handle != '':
+ cmdStr = "feature:uninstall " + str( featureStr )
+ output = self.sendline( cmdStr )
+ # TODO: Check for possible error responses from karaf
+ else:
+ main.log.info( "Feature needs to be installed before " +
+ "uninstalling it" )
+ return main.TRUE
+ if re.search( "Error", output ):
+ main.log.error( "Error in uninstalling feature" )
+ main.log.error( output )
+ return main.FALSE
+ else:
+ return main.TRUE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def deviceRemove( self, deviceId ):
+ """
+ Removes particular device from storage
+
+ TODO: refactor this function
+ """
+ try:
+ cmdStr = "device-remove " + str( deviceId )
+ handle = self.sendline( cmdStr )
+ if re.search( "Error", handle ):
+ main.log.error( "Error in removing device" )
+ main.log.error( handle )
+ return main.FALSE
+ else:
+ return main.TRUE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -455,38 +600,21 @@
* jsonFormat - boolean indicating if you want output in json
"""
try:
+ cmdStr = "devices"
if jsonFormat:
- cmdStr = "devices -j"
- handle = self.sendline( cmdStr )
- """
- 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:
-
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- """
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- return handle1
- else:
- cmdStr = "devices"
- handle = self.sendline( cmdStr )
- return handle
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
+ return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -498,18 +626,23 @@
"""
try:
cmdStr = "onos:balance-masters"
- self.sendline( cmdStr )
- # TODO: Check for error responses from ONOS
- return main.TRUE
+ handle = self.sendline( cmdStr )
+ if re.search( "Error", handle ):
+ main.log.error( "Error in balancing masters" )
+ main.log.error( handle )
+ return main.FALSE
+ else:
+ return main.TRUE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -520,38 +653,21 @@
* jsonFormat - boolean indicating if you want output in json
"""
try:
+ cmdStr = "links"
if jsonFormat:
- cmdStr = "links -j"
- handle = self.sendline( cmdStr )
- """
- 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:
-
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- """
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- return handle1
- else:
- cmdStr = "links"
- handle = self.sendline( cmdStr )
- return handle
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
+ return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -562,39 +678,21 @@
* jsonFormat - boolean indicating if you want output in json
"""
try:
+ cmdStr = "ports"
if jsonFormat:
- cmdStr = "ports -j"
- handle = self.sendline( cmdStr )
- """
- 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:
-
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- """
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- return handle1
-
- else:
- cmdStr = "ports"
- handle = self.sendline( cmdStr )
- return handle
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
+ return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -605,41 +703,21 @@
* jsonFormat - boolean indicating if you want output in json
"""
try:
+ cmdStr = "roles"
if jsonFormat:
- cmdStr = "roles -j"
- handle = self.sendline( cmdStr )
- """
- 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:
-
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- """
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- return handle1
-
- else:
- cmdStr = "roles"
- handle = self.sendline( cmdStr )
- return handle
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
+ return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -655,7 +733,6 @@
None if no match
"""
try:
- import json
if deviceId is None:
return None
else:
@@ -667,16 +744,16 @@
if str( deviceId ) in device[ 'id' ]:
return device
return None
-
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -687,7 +764,6 @@
main.FALSE any device has no master
"""
try:
- import json
rawRoles = self.roles()
rolesJson = json.loads( rawRoles )
# search json for the device with id then return the device
@@ -698,15 +774,16 @@
return main.FALSE
return main.TRUE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -725,15 +802,16 @@
path = handle.split( ";" )[ 0 ]
cost = handle.split( ";" )[ 1 ]
return ( path, cost )
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return ( handle, "Error" )
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -744,38 +822,21 @@
* jsonFormat - boolean indicating if you want output in json
"""
try:
+ cmdStr = "hosts"
if jsonFormat:
- cmdStr = "hosts -j"
- handle = self.sendline( cmdStr )
- """
- 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:
-
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- """
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- return handle1
- else:
- cmdStr = "hosts"
- handle = self.sendline( cmdStr )
- return handle
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
+ return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -783,12 +844,11 @@
"""
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
+ Note: mac must be a colon separated mac address, but could be a
partial mac address
Return None if there is no match
"""
- import json
try:
if mac is None:
return None
@@ -799,18 +859,21 @@
# search json for the host with mac then return the device
for host in hostsJson:
# print "%s in %s?" % ( mac, host[ 'id' ] )
- if mac in host[ 'id' ]:
+ if not host:
+ pass
+ elif mac in host[ 'id' ]:
return host
return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -843,15 +906,16 @@
return onosHostList
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -861,8 +925,10 @@
* hostIdOne: ONOS host id for host1
* hostIdTwo: ONOS host id for host2
Description:
- Adds a host-to-host intent ( bidrectional ) by
+ Adds a host-to-host intent ( bidirectional ) by
specifying the two hosts.
+ Returns:
+ A string of the intent id or None on Error
"""
try:
cmdStr = "add-host-intent " + str( hostIdOne ) +\
@@ -870,21 +936,29 @@
handle = self.sendline( cmdStr )
if re.search( "Error", handle ):
main.log.error( "Error in adding Host intent" )
- return handle
+ main.log.debug( "Response from ONOS was: " + repr( handle ) )
+ return None
else:
main.log.info( "Host intent installed between " +
- str( hostIdOne ) + " and " + str( hostIdTwo ) )
- return main.TRUE
-
+ str( hostIdOne ) + " and " + str( hostIdTwo ) )
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ main.log.debug( "Response from ONOS was: " +
+ repr( handle ) )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -895,6 +969,10 @@
* egressDevice: device id of egress device
Optional:
TODO: Still needs to be implemented via dev side
+ Description:
+ Adds an optical intent by specifying an ingress and egress device
+ Returns:
+ A string of the intent id or None on error
"""
try:
cmdStr = "add-optical-intent " + str( ingressDevice ) +\
@@ -902,18 +980,28 @@
handle = self.sendline( cmdStr )
# If error, return error message
if re.search( "Error", handle ):
- return handle
+ main.log.error( "Error in adding Optical intent" )
+ return None
else:
- return main.TRUE
+ main.log.info( "Optical intent installed between " +
+ str( ingressDevice ) + " and " +
+ str( egressDevice ) )
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -952,14 +1040,14 @@
Description:
Adds a point-to-point intent ( uni-directional ) by
specifying device id's and optional fields
+ Returns:
+ A string of the intent id or None on error
NOTE: This function may change depending on the
options developers provide for point-to-point
intent via cli
"""
try:
- cmd = ""
-
# If there are no optional arguments
if not ethType and not ethSrc and not ethDst\
and not bandwidth and not lambdaAlloc \
@@ -997,10 +1085,11 @@
cmd += " " + str( ingressDevice )
else:
if not portIngress:
- main.log.error( "You must specify " +
- "the ingress port" )
+ main.log.error( "You must specify the ingress port" )
# TODO: perhaps more meaningful return
- return main.FALSE
+ # Would it make sense to throw an exception and exit
+ # the test?
+ return None
cmd += " " + \
str( ingressDevice ) + "/" +\
@@ -1010,38 +1099,47 @@
cmd += " " + str( egressDevice )
else:
if not portEgress:
- main.log.error( "You must specify " +
- "the egress port" )
- return main.FALSE
+ main.log.error( "You must specify the egress port" )
+ return None
cmd += " " +\
str( egressDevice ) + "/" +\
str( portEgress )
handle = self.sendline( cmd )
+ # If error, return error message
if re.search( "Error", handle ):
main.log.error( "Error in adding point-to-point intent" )
- return main.FALSE
+ return None
else:
- return main.TRUE
+ # TODO: print out all the options in this message?
+ main.log.info( "Point-to-point intent installed between " +
+ str( ingressDevice ) + " and " +
+ str( egressDevice ) )
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def addMultipointToSinglepointIntent(
self,
- ingressDevice1,
- ingressDevice2,
+ ingressDeviceList,
egressDevice,
- portIngress="",
+ portIngressList=None,
portEgress="",
ethType="",
ethSrc="",
@@ -1057,12 +1155,13 @@
setEthDst="" ):
"""
Note:
- This function assumes that there would be 2 ingress devices and
- one egress device. For more number of ingress devices, this
- function needs to be modified
+ This function assumes the format of all ingress devices
+ is same. That is, all ingress devices include port numbers
+ with a "/" or all ingress devices could specify device
+ ids and port numbers seperately.
Required:
- * ingressDevice1: device id of ingress device1
- * ingressDevice2: device id of ingress device2
+ * ingressDeviceList: List of device ids of ingress device
+ ( Atleast 2 ingress devices required in the list )
* egressDevice: device id of egress device
Optional:
* ethType: specify ethType
@@ -1081,14 +1180,14 @@
Description:
Adds a multipoint-to-singlepoint intent ( uni-directional ) by
specifying device id's and optional fields
+ Returns:
+ A string of the intent id or None on error
NOTE: This function may change depending on the
- options developers provide for multipointpoint-to-singlepoint
+ options developers provide for multipoint-to-singlepoint
intent via cli
"""
try:
- cmd = ""
-
# If there are no optional arguments
if not ethType and not ethSrc and not ethDst\
and not bandwidth and not lambdaAlloc\
@@ -1127,32 +1226,27 @@
# Check whether the user appended the port
# or provided it as an input
- if "/" in ingressDevice1:
- cmd += " " + str( ingressDevice1 )
+
+ if portIngressList is None:
+ for ingressDevice in ingressDeviceList:
+ if "/" in ingressDevice:
+ cmd += " " + str( ingressDevice )
+ else:
+ main.log.error( "You must specify " +
+ "the ingress port" )
+ # TODO: perhaps more meaningful return
+ return main.FALSE
else:
- if not portIngress1:
- main.log.error( "You must specify " +
- "the ingress port1" )
- # TODO: perhaps more meaningful return
+ if len( ingressDeviceList ) == len( portIngressList ):
+ for ingressDevice, portIngress in zip( ingressDeviceList,
+ portIngressList ):
+ cmd += " " + \
+ str( ingressDevice ) + "/" +\
+ str( portIngress ) + " "
+ else:
+ main.log.error( "Device list and port list does not " +
+ "have the same length" )
return main.FALSE
-
- cmd += " " + \
- str( ingressDevice1 ) + "/" +\
- str( portIngress1 ) + " "
-
- if "/" in ingressDevice2:
- cmd += " " + str( ingressDevice2 )
- else:
- if not portIngress2:
- main.log.error( "You must specify " +
- "the ingress port2" )
- # TODO: perhaps more meaningful return
- return main.FALSE
-
- cmd += " " + \
- str( ingressDevice2 ) + "/" +\
- str( portIngress2 ) + " "
-
if "/" in egressDevice:
cmd += " " + str( egressDevice )
else:
@@ -1164,35 +1258,341 @@
cmd += " " +\
str( egressDevice ) + "/" +\
str( portEgress )
- print "cmd= ", cmd
handle = self.sendline( cmd )
+ # If error, return error message
if re.search( "Error", handle ):
- main.log.error( "Error in adding point-to-point intent" )
- return self.handle
+ main.log.error( "Error in adding multipoint-to-singlepoint " +
+ "intent" )
+ return None
else:
- return main.TRUE
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
- def removeIntent( self, intentId ):
+ def addSinglepointToMultipointIntent(
+ self,
+ ingressDevice,
+ egressDeviceList,
+ portIngress="",
+ portEgressList=None,
+ ethType="",
+ ethSrc="",
+ ethDst="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="",
+ setEthSrc="",
+ setEthDst="" ):
"""
- Remove intent for specified intent id
+ Note:
+ This function assumes the format of all egress devices
+ is same. That is, all egress devices include port numbers
+ with a "/" or all egress devices could specify device
+ ids and port numbers seperately.
+ Required:
+ * EgressDeviceList: List of device ids of egress device
+ ( Atleast 2 eress devices required in the list )
+ * ingressDevice: device id of ingress device
+ Optional:
+ * ethType: specify ethType
+ * ethSrc: specify ethSrc ( i.e. src mac addr )
+ * ethDst: specify ethDst ( i.e. dst mac addr )
+ * bandwidth: specify bandwidth capacity of link
+ * lambdaAlloc: if True, intent will allocate lambda
+ for the specified intent
+ * ipProto: specify ip protocol
+ * ipSrc: specify ip source address
+ * ipDst: specify ip destination address
+ * tcpSrc: specify tcp source port
+ * tcpDst: specify tcp destination port
+ * setEthSrc: action to Rewrite Source MAC Address
+ * setEthDst: action to Rewrite Destination MAC Address
+ Description:
+ Adds a singlepoint-to-multipoint intent ( uni-directional ) by
+ specifying device id's and optional fields
+ Returns:
+ A string of the intent id or None on error
+
+ NOTE: This function may change depending on the
+ options developers provide for singlepoint-to-multipoint
+ intent via cli
+ """
+ try:
+ # If there are no optional arguments
+ if not ethType and not ethSrc and not ethDst\
+ and not bandwidth and not lambdaAlloc\
+ and not ipProto and not ipSrc and not ipDst\
+ and not tcpSrc and not tcpDst and not setEthSrc\
+ and not setEthDst:
+ cmd = "add-single-to-multi-intent"
+
+ else:
+ cmd = "add-single-to-multi-intent"
+
+ if ethType:
+ cmd += " --ethType " + str( ethType )
+ if ethSrc:
+ cmd += " --ethSrc " + str( ethSrc )
+ if ethDst:
+ cmd += " --ethDst " + str( ethDst )
+ if bandwidth:
+ cmd += " --bandwidth " + str( bandwidth )
+ if lambdaAlloc:
+ cmd += " --lambda "
+ if ipProto:
+ cmd += " --ipProto " + str( ipProto )
+ if ipSrc:
+ cmd += " --ipSrc " + str( ipSrc )
+ if ipDst:
+ cmd += " --ipDst " + str( ipDst )
+ if tcpSrc:
+ cmd += " --tcpSrc " + str( tcpSrc )
+ if tcpDst:
+ cmd += " --tcpDst " + str( tcpDst )
+ if setEthSrc:
+ cmd += " --setEthSrc " + str( setEthSrc )
+ if setEthDst:
+ cmd += " --setEthDst " + str( setEthDst )
+
+ # Check whether the user appended the port
+ # or provided it as an input
+
+ if "/" in ingressDevice:
+ cmd += " " + str( ingressDevice )
+ else:
+ if not portIngress:
+ main.log.error( "You must specify " +
+ "the Ingress port" )
+ return main.FALSE
+
+ cmd += " " +\
+ str( ingressDevice ) + "/" +\
+ str( portIngress )
+
+ if portEgressList is None:
+ for egressDevice in egressDeviceList:
+ if "/" in egressDevice:
+ cmd += " " + str( egressDevice )
+ else:
+ main.log.error( "You must specify " +
+ "the egress port" )
+ # TODO: perhaps more meaningful return
+ return main.FALSE
+ else:
+ if len( egressDeviceList ) == len( portEgressList ):
+ for egressDevice, portEgress in zip( egressDeviceList,
+ portEgressList ):
+ cmd += " " + \
+ str( egressDevice ) + "/" +\
+ str( portEgress )
+ else:
+ main.log.error( "Device list and port list does not " +
+ "have the same length" )
+ return main.FALSE
+ handle = self.sendline( cmd )
+ # If error, return error message
+ if re.search( "Error", handle ):
+ main.log.error( "Error in adding singlepoint-to-multipoint " +
+ "intent" )
+ return None
+ else:
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def addMplsIntent(
+ self,
+ ingressDevice,
+ egressDevice,
+ ingressPort="",
+ egressPort="",
+ ethType="",
+ ethSrc="",
+ ethDst="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="",
+ ingressLabel="",
+ egressLabel="",
+ priority=""):
+ """
+ Required:
+ * ingressDevice: device id of ingress device
+ * egressDevice: device id of egress device
+ Optional:
+ * ethType: specify ethType
+ * ethSrc: specify ethSrc ( i.e. src mac addr )
+ * ethDst: specify ethDst ( i.e. dst mac addr )
+ * bandwidth: specify bandwidth capacity of link
+ * lambdaAlloc: if True, intent will allocate lambda
+ for the specified intent
+ * ipProto: specify ip protocol
+ * ipSrc: specify ip source address
+ * ipDst: specify ip destination address
+ * tcpSrc: specify tcp source port
+ * tcpDst: specify tcp destination port
+ * ingressLabel: Ingress MPLS label
+ * egressLabel: Egress MPLS label
+ Description:
+ Adds MPLS intent by
+ specifying device id's and optional fields
+ Returns:
+ A string of the intent id or None on error
+
+ NOTE: This function may change depending on the
+ options developers provide for MPLS
+ intent via cli
+ """
+ try:
+ # If there are no optional arguments
+ if not ethType and not ethSrc and not ethDst\
+ and not bandwidth and not lambdaAlloc \
+ and not ipProto and not ipSrc and not ipDst \
+ and not tcpSrc and not tcpDst and not ingressLabel \
+ and not egressLabel:
+ cmd = "add-mpls-intent"
+
+ else:
+ cmd = "add-mpls-intent"
+
+ if ethType:
+ cmd += " --ethType " + str( ethType )
+ if ethSrc:
+ cmd += " --ethSrc " + str( ethSrc )
+ if ethDst:
+ cmd += " --ethDst " + str( ethDst )
+ if bandwidth:
+ cmd += " --bandwidth " + str( bandwidth )
+ if lambdaAlloc:
+ cmd += " --lambda "
+ if ipProto:
+ cmd += " --ipProto " + str( ipProto )
+ if ipSrc:
+ cmd += " --ipSrc " + str( ipSrc )
+ if ipDst:
+ cmd += " --ipDst " + str( ipDst )
+ if tcpSrc:
+ cmd += " --tcpSrc " + str( tcpSrc )
+ if tcpDst:
+ cmd += " --tcpDst " + str( tcpDst )
+ if ingressLabel:
+ cmd += " --ingressLabel " + str( ingressLabel )
+ if egressLabel:
+ cmd += " --egressLabel " + str( egressLabel )
+ if priority:
+ cmd += " --priority " + str( priority )
+
+ # Check whether the user appended the port
+ # or provided it as an input
+ if "/" in ingressDevice:
+ cmd += " " + str( ingressDevice )
+ else:
+ if not ingressPort:
+ main.log.error( "You must specify the ingress port" )
+ return None
+
+ cmd += " " + \
+ str( ingressDevice ) + "/" +\
+ str( ingressPort ) + " "
+
+ if "/" in egressDevice:
+ cmd += " " + str( egressDevice )
+ else:
+ if not egressPort:
+ main.log.error( "You must specify the egress port" )
+ return None
+
+ cmd += " " +\
+ str( egressDevice ) + "/" +\
+ str( egressPort )
+
+ handle = self.sendline( cmd )
+ # If error, return error message
+ if re.search( "Error", handle ):
+ main.log.error( "Error in adding mpls intent" )
+ return None
+ else:
+ # TODO: print out all the options in this message?
+ main.log.info( "MPLS intent installed between " +
+ str( ingressDevice ) + " and " +
+ str( egressDevice ) )
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def removeIntent( self, intentId, app='org.onosproject.cli',
+ purge=False, sync=False ):
+ """
+ Remove intent for specified application id and intent id
+ Optional args:-
+ -s or --sync: Waits for the removal before returning
+ -p or --purge: Purge the intent from the store after removal
Returns:
main.False on error and
cli output otherwise
"""
try:
- cmdStr = "remove-intent " + str( intentId )
+ cmdStr = "remove-intent"
+ if purge:
+ cmdStr += " -p"
+ if sync:
+ cmdStr += " -s"
+
+ cmdStr += " " + app + " " + str( intentId )
handle = self.sendline( cmdStr )
if re.search( "Error", handle ):
main.log.error( "Error in removing intent" )
@@ -1200,15 +1600,16 @@
else:
# TODO: Should this be main.TRUE
return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1222,24 +1623,21 @@
Obtain all routes in the system
"""
try:
+ cmdStr = "routes"
if jsonFormat:
- cmdStr = "routes -j"
- handleTmp = self.sendline( cmdStr )
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansiEscape.sub( '', handleTmp )
- else:
- cmdStr = "routes"
- handle = self.sendline( cmdStr )
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1251,24 +1649,127 @@
Obtain intents currently installed
"""
try:
+ cmdStr = "intents"
if jsonFormat:
- cmdStr = "intents -j"
- handle = self.sendline( cmdStr )
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansiEscape.sub( '', handle )
- else:
- cmdStr = "intents"
- handle = self.sendline( cmdStr )
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def getIntentState(self, intentsId, intentsJson=None):
+ """
+ Check intent state.
+ Accepts a single intent ID (string type) or a list of intent IDs.
+ Returns the state(string type) of the id if a single intent ID is
+ accepted.
+ Returns a dictionary with intent IDs as the key and its
+ corresponding states as the values
+ Parameters:
+ intentId: intent ID (string type)
+ intentsJson: parsed json object from the onos:intents api
+ Returns:
+ state = An intent's state- INSTALL,WITHDRAWN etc.
+ stateDict = Dictionary of intent's state. intent ID as the keys and
+ state as the values.
+ """
+ try:
+ state = "State is Undefined"
+ if not intentsJson:
+ intentsJsonTemp = json.loads( self.intents() )
+ else:
+ intentsJsonTemp = json.loads( intentsJson )
+ if isinstance( intentsId, types.StringType ):
+ for intent in intentsJsonTemp:
+ if intentsId == intent[ 'id' ]:
+ state = intent[ 'state' ]
+ return state
+ main.log.info( "Cannot find intent ID" + str( intentsId ) +
+ " on the list" )
+ return state
+ elif isinstance( intentsId, types.ListType ):
+ dictList = []
+ for i in xrange( len( intentsId ) ):
+ stateDict = {}
+ for intents in intentsJsonTemp:
+ if intentsId[ i ] == intents[ 'id' ]:
+ stateDict[ 'state' ] = intents[ 'state' ]
+ stateDict[ 'id' ] = intentsId[ i ]
+ dictList.append( stateDict )
+ break
+ if len( intentsId ) != len( dictList ):
+ main.log.info( "Cannot find some of the intent ID state" )
+ return dictList
+ else:
+ main.log.info( "Invalid intents ID entry" )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def checkIntentState( self, intentsId, expectedState = 'INSTALLED' ):
+ """
+ Description:
+ Check intents state
+ Required:
+ intentsId - List of intents ID to be checked
+ Optional:
+ expectedState - Check this expected state of each intents state
+ in the list. Defaults to INSTALLED
+ Return:
+ Returns main.TRUE only if all intent are the same as expectedState,
+ , otherwise,returns main.FALSE.
+ """
+ try:
+ # Generating a dictionary: intent id as a key and state as value
+ intentsDict = self.getIntentState( intentsId )
+ #print "len of intentsDict ", str( len( intentsDict ) )
+ if len( intentsId ) != len( intentsDict ):
+ main.log.info( self.name + "There is something wrong " +
+ "getting intents state" )
+ return main.FALSE
+ returnValue = main.TRUE
+ for intents in intentsDict:
+ if intents.get( 'state' ) != expectedState:
+ main.log.info( self.name + " : " + intents.get( 'id' ) +
+ " actual state = " + intents.get( 'state' )
+ + " does not equal expected state = "
+ + expectedState )
+ returnValue = main.FALSE
+ if returnValue == main.TRUE:
+ main.log.info( self.name + ": All " +
+ str( len( intentsDict ) ) +
+ " intents are in " + expectedState + " state")
+ return returnValue
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1280,32 +1781,64 @@
Obtain flows currently installed
"""
try:
+ cmdStr = "flows"
if jsonFormat:
- cmdStr = "flows -j"
- handle = self.sendline( cmdStr )
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansiEscape.sub( '', handle )
- else:
- cmdStr = "flows"
- handle = self.sendline( cmdStr )
- if re.search( "Error\sexecuting\scommand:", handle ):
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
+ if re.search( "Error:", handle ):
main.log.error( self.name + ".flows() response: " +
str( handle ) )
return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def checkFlowsState( self ):
+ """
+ Description:
+ Check the if all the current flows are in ADDED state or
+ PENDING_ADD state
+ Return:
+ returnValue - Returns main.TRUE only if all flows are in
+ ADDED state or PENDING_ADD, return main.FALSE
+ otherwise.
+ """
+ try:
+ tempFlows = json.loads( self.flows() )
+ returnValue = main.TRUE
+ for device in tempFlows:
+ for flow in device.get( 'flows' ):
+ if flow.get( 'state' ) != 'ADDED' and flow.get( 'state' ) != \
+ 'PENDING_ADD':
+ main.log.info( self.name + ": flow Id: " +
+ flow.get( 'id' ) +
+ " | state:" + flow.get( 'state' ) )
+ returnValue = main.FALSE
+ return returnValue
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def pushTestIntents( self, dpidSrc, dpidDst, numIntents,
- numMult="", appId="", report=True ):
+ numMult="", appId="", report=True ):
"""
Description:
Push a number of intents in a batch format to
@@ -1332,8 +1865,6 @@
if appId:
cmd += " " + str( appId )
handle = self.sendline( cmd )
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansiEscape.sub( '', handle )
if report:
latResult = []
main.log.info( handle )
@@ -1350,15 +1881,16 @@
return latResult
else:
return main.TRUE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1369,25 +1901,21 @@
* jsonFormat: enable json formatting of output
"""
try:
+ cmdStr = "intents-events-metrics"
if jsonFormat:
- cmdStr = "intents-events-metrics -j"
- handle = self.sendline( cmdStr )
- # Some color thing that we want to escape
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansiEscape.sub( '', handle )
- else:
- cmdStr = "intents-events-metrics"
- handle = self.sendline( cmdStr )
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1398,25 +1926,27 @@
* jsonFormat: enable json formatting of output
"""
try:
+ cmdStr = "topology-events-metrics"
if jsonFormat:
- cmdStr = "topology-events-metrics -j"
- handle = self.sendline( cmdStr )
- # Some color thing that we want to escape
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansiEscape.sub( '', handle )
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
+ if handle:
+ return handle
+ elif jsonFormat:
+ # Return empty json
+ return '{}'
else:
- cmdStr = "topology-events-metrics"
- handle = self.sendline( cmdStr )
- return handle
+ return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1434,40 +1964,48 @@
"""
try:
# Obtain output of intents function
- intentsStr = self.intents()
- allIntentList = []
+ intentsStr = self.intents(jsonFormat=False)
intentIdList = []
# Parse the intents output for ID's
intentsList = [ s.strip() for s in intentsStr.splitlines() ]
for intents in intentsList:
- if "onos>" in intents:
- continue
- elif "intents" in intents:
- continue
- else:
- lineList = intents.split( " " )
- allIntentList.append( lineList[ 0 ] )
-
- allIntentList = allIntentList[ 1:-2 ]
-
- for intents in allIntentList:
- if not intents:
- continue
- else:
- intentIdList.append( intents )
-
+ match = re.search('id=0x([\da-f]+),', intents)
+ if match:
+ tmpId = match.group()[3:-1]
+ intentIdList.append( tmpId )
return intentIdList
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def FlowAddedCount( self, deviceId ):
+ """
+ Determine the number of flow rules for the given device id that are
+ in the added state
+ """
+ try:
+ cmdStr = "flows any " + str( deviceId ) + " | " +\
+ "grep 'state=ADDED' | wc -l"
+ handle = self.sendline( cmdStr )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1504,15 +2042,16 @@
idList.append( arg.split( "id=" )[ 1 ] )
return idList
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1525,33 +2064,27 @@
list of node id's
"""
try:
- nodesStr = self.nodes()
+ nodesStr = self.nodes( jsonFormat=True )
idList = []
-
+ # Sample nodesStr output
+ # id=local, address=127.0.0.1:9876, state=ACTIVE *
if not nodesStr:
main.log.info( "There are no nodes to get id from" )
return idList
-
- # Sample nodesStr output
- # id=local, address=127.0.0.1:9876, state=ACTIVE *
-
- # Split the string into list by comma
- nodesList = nodesStr.split( "," )
- tempList = [ node for node in nodesList if "id=" in node ]
- for arg in tempList:
- idList.append( arg.split( "id=" )[ 1 ] )
-
+ nodesJson = json.loads( nodesStr )
+ idList = [ node.get('id') for node in nodesJson ]
return idList
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1560,7 +2093,6 @@
Return the first device from the devices api whose 'id' contains 'dpid'
Return None if there is no match
"""
- import json
try:
if dpid is None:
return None
@@ -1574,35 +2106,36 @@
if dpid in device[ 'id' ]:
return device
return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def checkStatus( self, ip, numoswitch, numolink, logLevel="info" ):
"""
- Checks the number of swithes & links that ONOS sees against the
+ Checks the number of switches & links that ONOS sees against the
supplied values. By default this will report to main.log, but the
- log level can be specifid.
+ log level can be specified.
Params: ip = ip used for the onos cli
numoswitch = expected number of switches
- numlink = expected number of links
+ numolink = expected number of links
logLevel = level to log to. Currently accepts
'info', 'warn' and 'report'
logLevel can
- Returns: main.TRUE if the number of switchs and links are correct,
- main.FALSE if the numer of switches and links is incorrect,
+ Returns: main.TRUE if the number of switches and links are correct,
+ main.FALSE if the number of switches and links is incorrect,
and main.ERROR otherwise
"""
try:
@@ -1613,20 +2146,19 @@
# 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:
+ if devices is False or links is False:
return main.ERROR
switchCheck = ( int( devices ) == int( numoswitch ) )
# Is the number of links is what we expected
linkCheck = ( int( links ) == int( numolink ) )
if ( switchCheck and linkCheck ):
# We expected the correct numbers
- output = output + "The number of links and switches match "\
- + "what was expected"
+ 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 matc\
- h what was expected"
+ 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)" % (
@@ -1637,17 +2169,18 @@
elif logLevel == "warn":
main.log.warn( output )
else:
- main.log.info( output )
+ main.log.info( self.name + ": " + output )
return result
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1681,15 +2214,16 @@
main.log.error( "Invalid 'role' given to device_role(). " +
"Value was '" + str(role) + "'." )
return main.FALSE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1700,38 +2234,21 @@
* jsonFormat - boolean indicating if you want output in json
"""
try:
+ cmdStr = "clusters"
if jsonFormat:
- cmdStr = "clusters -j"
- handle = self.sendline( cmdStr )
- """
- 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:
-
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- """
- ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansiEscape.sub( '', handle )
- return handle1
- else:
- cmdStr = "clusters"
- handle = self.sendline( cmdStr )
- return handle
+ cmdStr += " -j"
+ handle = self.sendline( cmdStr )
+ return handle
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1770,19 +2287,20 @@
# TODO: Should this be main.ERROR?
return main.FALSE
else:
- main.log.error( "Error in election_test_leader: " +
- "unexpected response" )
+ main.log.error( "Error in electionTestLeader on " + self.name +
+ ": " + "unexpected response" )
main.log.error( repr( response ) )
return main.FALSE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1810,19 +2328,20 @@
main.log.error( "Election app is not loaded on " + self.name )
return main.FALSE
else:
- main.log.error( "Error in election_test_run: " +
- "unexpected response" )
+ main.log.error( "Error in electionTestRun on " + self.name +
+ ": " + "unexpected response" )
main.log.error( repr( response ) )
return main.FALSE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1850,19 +2369,20 @@
main.log.error( "Election app is not loaded on " + self.name )
return main.FALSE
else:
- main.log.error( "Error in election_test_withdraw: " +
- "unexpected response" )
+ main.log.error( "Error in electionTestWithdraw on " +
+ self.name + ": " + "unexpected response" )
main.log.error( repr( response ) )
return main.FALSE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1879,15 +2399,16 @@
return ( output, "Error" )
else:
return output
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return ( output, "Error" )
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1904,15 +2425,16 @@
return ( output, "Error " )
else:
return output
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return ( output, "Error " )
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1928,14 +2450,1102 @@
return ( output, "Error" )
else:
return output
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return ( output, "Error" )
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
+
+ def intentSummary( self ):
+ """
+ Returns a dictionary containing the current intent states and the count
+ """
+ try:
+ intents = self.intents( )
+ states = []
+ for intent in json.loads( intents ):
+ states.append( intent.get( 'state', None ) )
+ out = [ ( i, states.count( i ) ) for i in set( states ) ]
+ main.log.info( dict( out ) )
+ return dict( out )
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def leaders( self, jsonFormat=True ):
+ """
+ Returns the output of the leaders command.
+ Optional argument:
+ * jsonFormat - boolean indicating if you want output in json
+ """
+ # FIXME: add json output
+ # Sample JSON
+ # {
+ # "electedTime": "13m ago",
+ # "epoch": 4,
+ # "leader": "10.128.30.17",
+ # "topic": "intent-partition-3"
+ # },
+ try:
+ cmdStr = "onos:leaders"
+ if jsonFormat:
+ cmdStr += " -j"
+ output = self.sendline( cmdStr )
+ return output
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def pendingMap( self, jsonFormat=True ):
+ """
+ Returns the output of the intent Pending map.
+ """
+ try:
+ cmdStr = "onos:intents -p"
+ if jsonFormat:
+ cmdStr += " -j"
+ output = self.sendline( cmdStr )
+ return output
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def partitions( self, jsonFormat=True ):
+ """
+ Returns the output of the raft partitions command for ONOS.
+ """
+ # Sample JSON
+ # {
+ # "leader": "tcp://10.128.30.11:7238",
+ # "members": [
+ # "tcp://10.128.30.11:7238",
+ # "tcp://10.128.30.17:7238",
+ # "tcp://10.128.30.13:7238",
+ # ],
+ # "name": "p1",
+ # "term": 3
+ # },
+ try:
+ cmdStr = "onos:partitions"
+ if jsonFormat:
+ cmdStr += " -j"
+ output = self.sendline( cmdStr )
+ return output
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def apps( self, jsonFormat=True ):
+ """
+ Returns the output of the apps command for ONOS. This command lists
+ information about installed ONOS applications
+ """
+ # Sample JSON object
+ # [{"name":"org.onosproject.openflow","id":0,"version":"1.2.0",
+ # "description":"ONOS OpenFlow protocol southbound providers",
+ # "origin":"ON.Lab","permissions":"[]","featuresRepo":"",
+ # "features":"[onos-openflow]","state":"ACTIVE"}]
+ try:
+ cmdStr = "onos:apps"
+ if jsonFormat:
+ cmdStr += " -j"
+ output = self.sendline( cmdStr )
+ assert "Error executing command" not in output
+ return output
+ # FIXME: look at specific exceptions/Errors
+ except AssertionError:
+ main.log.error( "Error in processing onos:app command: " +
+ str( output ) )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def appStatus( self, appName ):
+ """
+ Uses the onos:apps cli command to return the status of an application.
+ Returns:
+ "ACTIVE" - If app is installed and activated
+ "INSTALLED" - If app is installed and deactivated
+ "UNINSTALLED" - If app is not installed
+ None - on error
+ """
+ try:
+ if not isinstance( appName, types.StringType ):
+ main.log.error( self.name + ".appStatus(): appName must be" +
+ " a string" )
+ return None
+ output = self.apps( jsonFormat=True )
+ appsJson = json.loads( output )
+ state = None
+ for app in appsJson:
+ if appName == app.get('name'):
+ state = app.get('state')
+ break
+ if state == "ACTIVE" or state == "INSTALLED":
+ return state
+ elif state is None:
+ return "UNINSTALLED"
+ elif state:
+ main.log.error( "Unexpected state from 'onos:apps': " +
+ str( state ) )
+ return state
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def app( self, appName, option ):
+ """
+ Interacts with the app command for ONOS. This command manages
+ application inventory.
+ """
+ try:
+ # Validate argument types
+ valid = True
+ if not isinstance( appName, types.StringType ):
+ main.log.error( self.name + ".app(): appName must be a " +
+ "string" )
+ valid = False
+ if not isinstance( option, types.StringType ):
+ main.log.error( self.name + ".app(): option must be a string" )
+ valid = False
+ if not valid:
+ return main.FALSE
+ # Validate Option
+ option = option.lower()
+ # NOTE: Install may become a valid option
+ if option == "activate":
+ pass
+ elif option == "deactivate":
+ pass
+ elif option == "uninstall":
+ pass
+ else:
+ # Invalid option
+ main.log.error( "The ONOS app command argument only takes " +
+ "the values: (activate|deactivate|uninstall)" +
+ "; was given '" + option + "'")
+ return main.FALSE
+ cmdStr = "onos:app " + option + " " + appName
+ output = self.sendline( cmdStr )
+ if "Error executing command" in output:
+ main.log.error( "Error in processing onos:app command: " +
+ str( output ) )
+ return main.FALSE
+ elif "No such application" in output:
+ main.log.error( "The application '" + appName +
+ "' is not installed in ONOS" )
+ return main.FALSE
+ elif "Command not found:" in output:
+ main.log.error( "Error in processing onos:app command: " +
+ str( output ) )
+ return main.FALSE
+ elif "Unsupported command:" in output:
+ main.log.error( "Incorrect command given to 'app': " +
+ str( output ) )
+ # NOTE: we may need to add more checks here
+ # else: Command was successful
+ # main.log.debug( "app response: " + repr( output ) )
+ return main.TRUE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def activateApp( self, appName, check=True ):
+ """
+ Activate an app that is already installed in ONOS
+ appName is the hierarchical app name, not the feature name
+ If check is True, method will check the status of the app after the
+ command is issued
+ Returns main.TRUE if the command was successfully sent
+ main.FALSE if the cli responded with an error or given
+ incorrect input
+ """
+ try:
+ if not isinstance( appName, types.StringType ):
+ main.log.error( self.name + ".activateApp(): appName must be" +
+ " a string" )
+ return main.FALSE
+ status = self.appStatus( appName )
+ if status == "INSTALLED":
+ response = self.app( appName, "activate" )
+ if check and response == main.TRUE:
+ for i in range(10): # try 10 times then give up
+ # TODO: Check with Thomas about this delay
+ status = self.appStatus( appName )
+ if status == "ACTIVE":
+ return main.TRUE
+ else:
+ main.log.debug( "The state of application " +
+ appName + " is " + status )
+ time.sleep( 1 )
+ return main.FALSE
+ else: # not 'check' or command didn't succeed
+ return response
+ elif status == "ACTIVE":
+ return main.TRUE
+ elif status == "UNINSTALLED":
+ main.log.error( self.name + ": Tried to activate the " +
+ "application '" + appName + "' which is not " +
+ "installed." )
+ else:
+ main.log.error( "Unexpected return value from appStatus: " +
+ str( status ) )
+ return main.ERROR
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def deactivateApp( self, appName, check=True ):
+ """
+ Deactivate an app that is already activated in ONOS
+ appName is the hierarchical app name, not the feature name
+ If check is True, method will check the status of the app after the
+ command is issued
+ Returns main.TRUE if the command was successfully sent
+ main.FALSE if the cli responded with an error or given
+ incorrect input
+ """
+ try:
+ if not isinstance( appName, types.StringType ):
+ main.log.error( self.name + ".deactivateApp(): appName must " +
+ "be a string" )
+ return main.FALSE
+ status = self.appStatus( appName )
+ if status == "INSTALLED":
+ return main.TRUE
+ elif status == "ACTIVE":
+ response = self.app( appName, "deactivate" )
+ if check and response == main.TRUE:
+ for i in range(10): # try 10 times then give up
+ status = self.appStatus( appName )
+ if status == "INSTALLED":
+ return main.TRUE
+ else:
+ time.sleep( 1 )
+ return main.FALSE
+ else: # not check or command didn't succeed
+ return response
+ elif status == "UNINSTALLED":
+ main.log.warn( self.name + ": Tried to deactivate the " +
+ "application '" + appName + "' which is not " +
+ "installed." )
+ return main.TRUE
+ else:
+ main.log.error( "Unexpected return value from appStatus: " +
+ str( status ) )
+ return main.ERROR
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def uninstallApp( self, appName, check=True ):
+ """
+ Uninstall an app that is already installed in ONOS
+ appName is the hierarchical app name, not the feature name
+ If check is True, method will check the status of the app after the
+ command is issued
+ Returns main.TRUE if the command was successfully sent
+ main.FALSE if the cli responded with an error or given
+ incorrect input
+ """
+ # TODO: check with Thomas about the state machine for apps
+ try:
+ if not isinstance( appName, types.StringType ):
+ main.log.error( self.name + ".uninstallApp(): appName must " +
+ "be a string" )
+ return main.FALSE
+ status = self.appStatus( appName )
+ if status == "INSTALLED":
+ response = self.app( appName, "uninstall" )
+ if check and response == main.TRUE:
+ for i in range(10): # try 10 times then give up
+ status = self.appStatus( appName )
+ if status == "UNINSTALLED":
+ return main.TRUE
+ else:
+ time.sleep( 1 )
+ return main.FALSE
+ else: # not check or command didn't succeed
+ return response
+ elif status == "ACTIVE":
+ main.log.warn( self.name + ": Tried to uninstall the " +
+ "application '" + appName + "' which is " +
+ "currently active." )
+ response = self.app( appName, "uninstall" )
+ if check and response == main.TRUE:
+ for i in range(10): # try 10 times then give up
+ status = self.appStatus( appName )
+ if status == "UNINSTALLED":
+ return main.TRUE
+ else:
+ time.sleep( 1 )
+ return main.FALSE
+ else: # not check or command didn't succeed
+ return response
+ elif status == "UNINSTALLED":
+ return main.TRUE
+ else:
+ main.log.error( "Unexpected return value from appStatus: " +
+ str( status ) )
+ return main.ERROR
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def appIDs( self, jsonFormat=True ):
+ """
+ Show the mappings between app id and app names given by the 'app-ids'
+ cli command
+ """
+ try:
+ cmdStr = "app-ids"
+ if jsonFormat:
+ cmdStr += " -j"
+ output = self.sendline( cmdStr )
+ assert "Error executing command" not in output
+ return output
+ except AssertionError:
+ main.log.error( "Error in processing onos:app-ids command: " +
+ str( output ) )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def appToIDCheck( self ):
+ """
+ This method will check that each application's ID listed in 'apps' is
+ the same as the ID listed in 'app-ids'. The check will also check that
+ there are no duplicate IDs issued. Note that an app ID should be
+ a globaly unique numerical identifier for app/app-like features. Once
+ an ID is registered, the ID is never freed up so that if an app is
+ reinstalled it will have the same ID.
+
+ Returns: main.TRUE if the check passes and
+ main.FALSE if the check fails or
+ main.ERROR if there is some error in processing the test
+ """
+ try:
+ bail = False
+ ids = self.appIDs( jsonFormat=True )
+ if ids:
+ ids = json.loads( ids )
+ else:
+ main.log.error( "app-ids returned nothing:" + repr( ids ) )
+ bail = True
+ apps = self.apps( jsonFormat=True )
+ if apps:
+ apps = json.loads( apps )
+ else:
+ main.log.error( "apps returned nothing:" + repr( apps ) )
+ bail = True
+ if bail:
+ return main.FALSE
+ result = main.TRUE
+ for app in apps:
+ appID = app.get( 'id' )
+ if appID is None:
+ main.log.error( "Error parsing app: " + str( app ) )
+ result = main.FALSE
+ appName = app.get( 'name' )
+ if appName is None:
+ main.log.error( "Error parsing app: " + str( app ) )
+ result = main.FALSE
+ # get the entry in ids that has the same appID
+ current = filter( lambda item: item[ 'id' ] == appID, ids )
+ # main.log.debug( "Comparing " + str( app ) + " to " +
+ # str( current ) )
+ if not current: # if ids doesn't have this id
+ result = main.FALSE
+ main.log.error( "'app-ids' does not have the ID for " +
+ str( appName ) + " that apps does." )
+ elif len( current ) > 1:
+ # there is more than one app with this ID
+ result = main.FALSE
+ # We will log this later in the method
+ elif not current[0][ 'name' ] == appName:
+ currentName = current[0][ 'name' ]
+ result = main.FALSE
+ main.log.error( "'app-ids' has " + str( currentName ) +
+ " registered under id:" + str( appID ) +
+ " but 'apps' has " + str( appName ) )
+ else:
+ pass # id and name match!
+ # now make sure that app-ids has no duplicates
+ idsList = []
+ namesList = []
+ for item in ids:
+ idsList.append( item[ 'id' ] )
+ namesList.append( item[ 'name' ] )
+ if len( idsList ) != len( set( idsList ) ) or\
+ len( namesList ) != len( set( namesList ) ):
+ main.log.error( "'app-ids' has some duplicate entries: \n"
+ + json.dumps( ids,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ result = main.FALSE
+ return result
+ except ( ValueError, TypeError ):
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def getCfg( self, component=None, propName=None, short=False,
+ jsonFormat=True ):
+ """
+ Get configuration settings from onos cli
+ Optional arguments:
+ component - Optionally only list configurations for a specific
+ component. If None, all components with configurations
+ are displayed. Case Sensitive string.
+ propName - If component is specified, propName option will show
+ only this specific configuration from that component.
+ Case Sensitive string.
+ jsonFormat - Returns output as json. Note that this will override
+ the short option
+ short - Short, less verbose, version of configurations.
+ This is overridden by the json option
+ returns:
+ Output from cli as a string or None on error
+ """
+ try:
+ baseStr = "cfg"
+ cmdStr = " get"
+ componentStr = ""
+ if component:
+ componentStr += " " + component
+ if propName:
+ componentStr += " " + propName
+ if jsonFormat:
+ baseStr += " -j"
+ elif short:
+ baseStr += " -s"
+ output = self.sendline( baseStr + cmdStr + componentStr )
+ assert "Error executing command" not in output
+ return output
+ except AssertionError:
+ main.log.error( "Error in processing 'cfg get' command: " +
+ str( output ) )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def setCfg( self, component, propName, value=None, check=True ):
+ """
+ Set/Unset configuration settings from ONOS cli
+ Required arguments:
+ component - The case sensitive name of the component whose
+ property is to be set
+ propName - The case sensitive name of the property to be set/unset
+ Optional arguments:
+ value - The value to set the property to. If None, will unset the
+ property and revert it to it's default value(if applicable)
+ check - Boolean, Check whether the option was successfully set this
+ only applies when a value is given.
+ returns:
+ main.TRUE on success or main.FALSE on failure. If check is False,
+ will return main.TRUE unless there is an error
+ """
+ try:
+ baseStr = "cfg"
+ cmdStr = " set " + str( component ) + " " + str( propName )
+ if value is not None:
+ cmdStr += " " + str( value )
+ output = self.sendline( baseStr + cmdStr )
+ assert "Error executing command" not in output
+ if value and check:
+ results = self.getCfg( component=str( component ),
+ propName=str( propName ),
+ jsonFormat=True )
+ # Check if current value is what we just set
+ try:
+ jsonOutput = json.loads( results )
+ current = jsonOutput[ 'value' ]
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing cfg output" )
+ main.log.error( "output:" + repr( results ) )
+ return main.FALSE
+ if current == str( value ):
+ return main.TRUE
+ return main.FALSE
+ return main.TRUE
+ except AssertionError:
+ main.log.error( "Error in processing 'cfg set' command: " +
+ str( output ) )
+ return main.FALSE
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def setTestAdd( self, setName, values ):
+ """
+ CLI command to add elements to a distributed set.
+ Arguments:
+ setName - The name of the set to add to.
+ values - The value(s) to add to the set, space seperated.
+ Example usages:
+ setTestAdd( "set1", "a b c" )
+ setTestAdd( "set2", "1" )
+ returns:
+ main.TRUE on success OR
+ main.FALSE if elements were already in the set OR
+ main.ERROR on error
+ """
+ try:
+ cmdStr = "set-test-add " + str( setName ) + " " + str( values )
+ output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
+ assert "Error executing command" not in output
+ positiveMatch = "\[(.*)\] was added to the set " + str( setName )
+ negativeMatch = "\[(.*)\] was already in set " + str( setName )
+ main.log.info( self.name + ": " + output )
+ if re.search( positiveMatch, output):
+ return main.TRUE
+ elif re.search( negativeMatch, output):
+ return main.FALSE
+ else:
+ main.log.error( self.name + ": setTestAdd did not" +
+ " match expected output" )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ return main.ERROR
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' command: " +
+ str( output ) )
+ return main.ERROR
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def setTestRemove( self, setName, values, clear=False, retain=False ):
+ """
+ CLI command to remove elements from a distributed set.
+ Required arguments:
+ setName - The name of the set to remove from.
+ values - The value(s) to remove from the set, space seperated.
+ Optional arguments:
+ clear - Clear all elements from the set
+ retain - Retain only the given values. (intersection of the
+ original set and the given set)
+ returns:
+ main.TRUE on success OR
+ main.FALSE if the set was not changed OR
+ main.ERROR on error
+ """
+ try:
+ cmdStr = "set-test-remove "
+ if clear:
+ cmdStr += "-c " + str( setName )
+ elif retain:
+ cmdStr += "-r " + str( setName ) + " " + str( values )
+ else:
+ cmdStr += str( setName ) + " " + str( values )
+ output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
+ assert "Error executing command" not in output
+ main.log.info( self.name + ": " + output )
+ if clear:
+ pattern = "Set " + str( setName ) + " cleared"
+ if re.search( pattern, output ):
+ return main.TRUE
+ elif retain:
+ positivePattern = str( setName ) + " was pruned to contain " +\
+ "only elements of set \[(.*)\]"
+ negativePattern = str( setName ) + " was not changed by " +\
+ "retaining only elements of the set " +\
+ "\[(.*)\]"
+ if re.search( positivePattern, output ):
+ return main.TRUE
+ elif re.search( negativePattern, output ):
+ return main.FALSE
+ else:
+ positivePattern = "\[(.*)\] was removed from the set " +\
+ str( setName )
+ if ( len( values.split() ) == 1 ):
+ negativePattern = "\[(.*)\] was not in set " +\
+ str( setName )
+ else:
+ negativePattern = "No element of \[(.*)\] was in set " +\
+ str( setName )
+ if re.search( positivePattern, output ):
+ return main.TRUE
+ elif re.search( negativePattern, output ):
+ return main.FALSE
+ main.log.error( self.name + ": setTestRemove did not" +
+ " match expected output" )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ return main.ERROR
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-remove' command: " +
+ str( output ) )
+ return main.ERROR
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def setTestGet( self, setName, values="" ):
+ """
+ CLI command to get the elements in a distributed set.
+ Required arguments:
+ setName - The name of the set to remove from.
+ Optional arguments:
+ values - The value(s) to check if in the set, space seperated.
+ returns:
+ main.ERROR on error OR
+ A list of elements in the set if no optional arguments are
+ supplied OR
+ A tuple containing the list then:
+ main.FALSE if the given values are not in the set OR
+ main.TRUE if the given values are in the set OR
+ """
+ try:
+ values = str( values ).strip()
+ setName = str( setName ).strip()
+ length = len( values.split() )
+ containsCheck = None
+ # Patterns to match
+ setPattern = "\[(.*)\]"
+ pattern = "Items in set " + setName + ":\n" + setPattern
+ containsTrue = "Set " + setName + " contains the value " + values
+ containsFalse = "Set " + setName + " did not contain the value " +\
+ values
+ containsAllTrue = "Set " + setName + " contains the the subset " +\
+ setPattern
+ containsAllFalse = "Set " + setName + " did not contain the the" +\
+ " subset " + setPattern
+
+ cmdStr = "set-test-get "
+ cmdStr += setName + " " + values
+ output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
+ assert "Error executing command" not in output
+ main.log.info( self.name + ": " + output )
+
+ if length == 0:
+ match = re.search( pattern, output )
+ else: # if given values
+ if length == 1: # Contains output
+ patternTrue = pattern + "\n" + containsTrue
+ patternFalse = pattern + "\n" + containsFalse
+ else: # ContainsAll output
+ patternTrue = pattern + "\n" + containsAllTrue
+ patternFalse = pattern + "\n" + containsAllFalse
+ matchTrue = re.search( patternTrue, output )
+ matchFalse = re.search( patternFalse, output )
+ if matchTrue:
+ containsCheck = main.TRUE
+ match = matchTrue
+ elif matchFalse:
+ containsCheck = main.FALSE
+ match = matchFalse
+ else:
+ main.log.error( self.name + " setTestGet did not match " +\
+ "expected output" )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ match = None
+ if match:
+ setMatch = match.group( 1 )
+ if setMatch == '':
+ setList = []
+ else:
+ setList = setMatch.split( ", " )
+ if length > 0:
+ return ( setList, containsCheck )
+ else:
+ return setList
+ else: # no match
+ main.log.error( self.name + ": setTestGet did not" +
+ " match expected output" )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ return main.ERROR
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-get' command: " +
+ str( output ) )
+ return main.ERROR
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def setTestSize( self, setName ):
+ """
+ CLI command to get the elements in a distributed set.
+ Required arguments:
+ setName - The name of the set to remove from.
+ returns:
+ The integer value of the size returned or
+ None on error
+ """
+ try:
+ # TODO: Should this check against the number of elements returned
+ # and then return true/false based on that?
+ setName = str( setName ).strip()
+ # Patterns to match
+ setPattern = "\[(.*)\]"
+ pattern = "There are (\d+) items in set " + setName + ":\n" +\
+ setPattern
+ cmdStr = "set-test-get -s "
+ cmdStr += setName
+ output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
+ assert "Error executing command" not in output
+ main.log.info( self.name + ": " + output )
+ match = re.search( pattern, output )
+ if match:
+ setSize = int( match.group( 1 ) )
+ setMatch = match.group( 2 )
+ if len( setMatch.split() ) == setSize:
+ main.log.info( "The size returned by " + self.name +
+ " matches the number of elements in " +
+ "the returned set" )
+ else:
+ main.log.error( "The size returned by " + self.name +
+ " does not match the number of " +
+ "elements in the returned set." )
+ return setSize
+ else: # no match
+ main.log.error( self.name + ": setTestGet did not" +
+ " match expected output" )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ return None
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-get' command: " +
+ str( output ) )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def counters( self ):
+ """
+ Command to list the various counters in the system.
+ returns:
+ A dict containing the counters in the system with the counter
+ names being the keys and the value of the counters being the
+ values OR
+ None on error
+ """
+ #FIXME: JSON FORMAT
+ try:
+ counters = {}
+ cmdStr = "counters"
+ output = self.sendline( cmdStr )
+ assert "Error executing command" not in output
+ main.log.info( self.name + ": " + output )
+ for line in output.splitlines():
+ match = re.search( "name=(\S+) value=(\d+)", line )
+ if match:
+ key = match.group( 1 )
+ value = int( match.group( 2 ) )
+ counters[key] = value
+ else:
+ main.log.error( self.name + ": counters did not match " +
+ "expected output" )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ return None
+ return counters
+ except AssertionError:
+ main.log.error( "Error in processing 'counters' command: " +
+ str( output ) )
+ return main.ERROR
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def counterTestIncrement( self, counter, inMemory=False ):
+ """
+ CLI command to increment and get a distributed counter.
+ Required arguments:
+ counter - The name of the counter to increment.
+ Optional arguments:
+ inMemory - use in memory map for the counter
+ returns:
+ integer value of the counter or
+ None on Error
+ """
+ try:
+ counter = str( counter )
+ cmdStr = "counter-test-increment "
+ if inMemory:
+ cmdStr += "-i "
+ cmdStr += counter
+ output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
+ assert "Error executing command" not in output
+ main.log.info( self.name + ": " + output )
+ pattern = counter + " was incremented to (\d+)"
+ match = re.search( pattern, output )
+ if match:
+ return int( match.group( 1 ) )
+ else:
+ main.log.error( self.name + ": counterTestIncrement did not" +
+ " match expected output." )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ return None
+ except AssertionError:
+ main.log.error( "Error in processing 'counter-test-increment'" +
+ " command: " + str( output ) )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 7d6587c..a0a1b44 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -19,7 +19,6 @@
import sys
import time
import pexpect
-import traceback
import os.path
from requests.models import Response
sys.path.append( "../" )
@@ -32,6 +31,9 @@
"""
Initialize client
"""
+ self.name = None
+ self.home = None
+ self.handle = None
super( CLI, self ).__init__()
def connect( self, **connectargs ):
@@ -41,11 +43,13 @@
try:
for key in connectargs:
vars( self )[ key ] = connectargs[ key ]
- self.home = "~/ONOS"
+ self.home = "~/onos"
for key in self.options:
if key == "home":
self.home = self.options[ 'home' ]
break
+ if self.home is None or self.home == "":
+ self.home = "~/onos"
self.name = self.options[ 'name' ]
self.handle = super( OnosDriver, self ).connect(
@@ -67,10 +71,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 30 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 30 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -78,17 +80,21 @@
"""
Called when Test is complete to disconnect the ONOS handle.
"""
- response = ''
+ response = main.TRUE
try:
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
- self.handle.sendline( "exit" )
- self.handle.expect( "closed" )
+ if self.handle:
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "exit" )
+ self.handle.expect( "closed" )
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
- main.log.error( self.name + ": Connection failed to the host" )
+ except ValueError:
+ main.log.exception( "Exception in disconnect of " + self.name )
+ response = main.TRUE
+ except Exception:
+ main.log.exception( self.name + ": Connection failed to the host" )
response = main.FALSE
return response
@@ -112,8 +118,8 @@
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
- main.log.error( "Failed to package ONOS" )
+ except Exception:
+ main.log.exception( "Failed to package ONOS" )
main.cleanup()
main.exit()
@@ -142,8 +148,8 @@
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
- main.log.error( "Failed to build ONOS" )
+ except Exception:
+ main.log.exception( "Failed to build ONOS" )
main.cleanup()
main.exit()
@@ -168,10 +174,11 @@
self.handle.expect( "mvn clean install" )
while True:
i = self.handle.expect( [
- 'There\sis\sinsufficient\smemory\sfor\sthe\sJava\s\
- Runtime\sEnvironment\sto\scontinue',
+ 'There\sis\sinsufficient\smemory\sfor\sthe\sJava\s' +
+ 'Runtime\sEnvironment\sto\scontinue',
'BUILD\sFAILURE',
'BUILD\sSUCCESS',
+ 'onos\$', #TODO: fix this to be more generic?
'ONOS\$',
pexpect.TIMEOUT ], timeout=600 )
if i == 0:
@@ -187,7 +194,7 @@
main.exit()
elif i == 2:
main.log.info( self.name + ": Build success!" )
- elif i == 3:
+ elif i == 3 or i == 4:
main.log.info( self.name + ": Build complete" )
# Print the build time
for line in self.handle.before.splitlines():
@@ -196,7 +203,7 @@
self.handle.sendline( "" )
self.handle.expect( "\$", timeout=60 )
return main.TRUE
- elif i == 4:
+ elif i == 5:
main.log.error(
self.name +
": mvn clean install TIMEOUT!" )
@@ -204,8 +211,8 @@
main.cleanup()
main.exit()
else:
- main.log.error( self.name + ": unexpected response from \
- mvn clean install" )
+ main.log.error( self.name + ": unexpected response from " +
+ "mvn clean install" )
# return main.FALSE
main.cleanup()
main.exit()
@@ -214,17 +221,19 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 60 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
- def gitPull( self, comp1="" ):
+ def gitPull( self, comp1="", fastForward=True ):
"""
Assumes that "git pull" works without login
+ If the fastForward boolean is set to true, only git pulls that can
+ be fast forwarded will be performed. IE if you have not local commits
+ in your branch.
+
This function will perform a git pull on the ONOS instance.
If used as gitPull( "NODE" ) it will do git pull + NODE. This is
for the purpose of pulling from other nodes if necessary.
@@ -239,12 +248,13 @@
# main.log.info( self.name + ": Stopping ONOS" )
# self.stop()
self.handle.sendline( "cd " + self.home )
- self.handle.expect( "ONOS\$" )
- if comp1 == "":
- self.handle.sendline( "git pull" )
- else:
- self.handle.sendline( "git pull " + comp1 )
-
+ self.handle.expect( self.home + "\$" )
+ cmd = "git pull"
+ if comp1 != "":
+ cmd += ' ' + comp1
+ if fastForward:
+ cmd += ' ' + " --ff-only"
+ self.handle.sendline( cmd )
i = self.handle.expect(
[
'fatal',
@@ -253,10 +263,11 @@
'Already up-to-date',
'Aborting',
'You\sare\snot\scurrently\son\sa\sbranch',
- 'You\sasked\sme\sto\spull\swithout\stelling\sme\swhich\
- \sbranch\syou',
- 'Pull\sis\snot\spossible\sbecause\syou\shave\sunmerged\
- \sfiles',
+ 'You asked me to pull without telling me which branch you',
+ 'Pull is not possible because you have unmerged files',
+ 'Please enter a commit message to explain why this merge',
+ 'Found a swap file by the name',
+ 'Please, commit your changes before you can merge.',
pexpect.TIMEOUT ],
timeout=300 )
# debug
@@ -264,7 +275,11 @@
# "git pull response: " +
# str( self.handle.before ) + str( self.handle.after ) )
if i == 0:
- main.log.error( self.name + ": Git pull had some issue..." )
+ main.log.error( self.name + ": Git pull had some issue" )
+ output = self.handle.after
+ self.handle.expect( '\$' )
+ output += self.handle.before
+ main.log.warn( output )
return main.ERROR
elif i == 1:
main.log.error(
@@ -275,7 +290,7 @@
main.log.info(
self.name +
": Git Pull - pulling repository now" )
- self.handle.expect( "ONOS\$", 120 )
+ self.handle.expect( self.home + "\$", 120 )
# So that only when git pull is done, we do mvn clean compile
return main.TRUE
elif i == 3:
@@ -284,29 +299,51 @@
elif i == 4:
main.log.info(
self.name +
- ": Git Pull - Aborting...\
- Are there conflicting git files?" )
+ ": Git Pull - Aborting..." +
+ "Are there conflicting git files?" )
return main.ERROR
elif i == 5:
main.log.info(
self.name +
- ": Git Pull - You are not currently\
- on a branch so git pull failed!" )
+ ": Git Pull - You are not currently " +
+ "on a branch so git pull failed!" )
return main.ERROR
elif i == 6:
main.log.info(
self.name +
- ": Git Pull - You have not configured\
- an upstream branch to pull from\
- . Git pull failed!" )
+ ": Git Pull - You have not configured an upstream " +
+ "branch to pull from. Git pull failed!" )
return main.ERROR
elif i == 7:
main.log.info(
self.name +
- ": Git Pull - Pull is not possible\
- because you have unmerged files." )
+ ": Git Pull - Pull is not possible because " +
+ "you have unmerged files." )
return main.ERROR
elif i == 8:
+ # NOTE: abandoning test since we can't reliably handle this
+ # there could be different default text editors and we
+ # also don't know if we actually want to make the commit
+ main.log.error( "Git pull resulted in a merge commit message" +
+ ". Exiting test!" )
+ main.cleanup()
+ main.exit()
+ elif i == 9: # Merge commit message but swap file exists
+ main.log.error( "Git pull resulted in a merge commit message" +
+ " but a swap file exists." )
+ try:
+ self.handle.send( 'A' ) # Abort
+ self.handle.expect( "\$" )
+ return main.ERROR
+ except Exception:
+ main.log.exception( "Couldn't exit editor prompt!")
+ main.cleanup()
+ main.exit()
+ elif i == 10: # In the middle of a merge commit
+ main.log.error( "Git branch is in the middle of a merge. " )
+ main.log.warn( self.handle.before + self.handle.after )
+ return main.ERROR
+ elif i == 11:
main.log.error( self.name + ": Git Pull - TIMEOUT" )
main.log.error(
self.name + " Response was: " + str(
@@ -322,10 +359,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 80 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -346,28 +381,24 @@
"""
try:
self.handle.sendline( "cd " + self.home )
- self.handle.expect( "ONOS\$" )
- main.log.info(
- self.name +
- ": Checking out git branch: " +
- branch +
- "..." )
+ self.handle.expect( self.home + "\$" )
+ main.log.info( self.name +
+ ": Checking out git branch/ref: " + branch + "..." )
cmd = "git checkout " + branch
self.handle.sendline( cmd )
self.handle.expect( cmd )
i = self.handle.expect(
- [
- 'fatal',
- 'Username\sfor\s(.*):\s',
- 'Already\son\s\'',
- 'Switched\sto\sbranch\s\'' +
- str( branch ),
- pexpect.TIMEOUT,
- 'error: Your local changes to the following files\
- would be overwritten by checkout:',
- 'error: you need to resolve your current index first' ],
+ [ 'fatal',
+ 'Username for (.*): ',
+ 'Already on \'',
+ 'Switched to branch \'' + str( branch ),
+ pexpect.TIMEOUT,
+ 'error: Your local changes to the following files' +
+ 'would be overwritten by checkout:',
+ 'error: you need to resolve your current index first',
+ "You are in 'detached HEAD' state.",
+ "HEAD is now at " ],
timeout=60 )
-
if i == 0:
main.log.error(
self.name +
@@ -380,55 +411,66 @@
": Git checkout asking for username." +
" Please configure your local git repository to be able " +
"to access your remote repository passwordlessly" )
+ # TODO add support for authenticating
return main.ERROR
elif i == 2:
main.log.info(
self.name +
- ": Git Checkout %s : Already on this branch" %
- branch )
- self.handle.expect( "ONOS\$" )
+ ": Git Checkout %s : Already on this branch" % branch )
+ self.handle.expect( self.home + "\$" )
# main.log.info( "DEBUG: after checkout cmd = "+
# self.handle.before )
return main.TRUE
elif i == 3:
main.log.info(
self.name +
- ": Git checkout %s - Switched to this branch" %
- branch )
- self.handle.expect( "ONOS\$" )
+ ": Git checkout %s - Switched to this branch" % branch )
+ self.handle.expect( self.home + "\$" )
# main.log.info( "DEBUG: after checkout cmd = "+
# self.handle.before )
return main.TRUE
elif i == 4:
main.log.error( self.name + ": Git Checkout- TIMEOUT" )
main.log.error(
- self.name + " Response was: " + str(
- self.handle.before ) )
+ self.name + " Response was: " + str( self.handle.before ) )
return main.ERROR
elif i == 5:
self.handle.expect( "Aborting" )
main.log.error(
self.name +
": Git checkout error: \n" +
- "Your local changes to the following\
- files would be overwritten by checkout:" +
- str(
- self.handle.before ) )
- self.handle.expect( "ONOS\$" )
+ "Your local changes to the following files would" +
+ " be overwritten by checkout:" +
+ str( self.handle.before ) )
+ self.handle.expect( self.home + "\$" )
return main.ERROR
elif i == 6:
- main.log.error( self.name +
- ": Git checkout error: \n" +
- "You need to resolve your\
- current index first:" +
- str( self.handle.before ) )
- self.handle.expect( "ONOS\$" )
+ main.log.error(
+ self.name +
+ ": Git checkout error: \n" +
+ "You need to resolve your current index first:" +
+ str( self.handle.before ) )
+ self.handle.expect( self.home + "\$" )
return main.ERROR
+ elif i == 7:
+ main.log.info(
+ self.name +
+ ": Git checkout " + str( branch ) +
+ " - You are in 'detached HEAD' state. HEAD is now at " +
+ str( branch ) )
+ self.handle.expect( self.home + "\$" )
+ return main.TRUE
+ elif i == 8: # Already in detached HEAD on the specified commit
+ main.log.info(
+ self.name +
+ ": Git Checkout %s : Already on commit" % branch )
+ self.handle.expect( self.home + "\$" )
+ return main.TRUE
else:
main.log.error(
self.name +
- ": Git Checkout - Unexpected response,\
- check for pull errors" )
+ ": Git Checkout - Unexpected response, " +
+ "check for pull errors" )
main.log.error( self.name + ": " + self.handle.before )
return main.ERROR
@@ -437,10 +479,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 80 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -462,8 +502,8 @@
def getVersion( self, report=False ):
"""
- Writes the COMMIT number to the report to be parsed\
- by Jenkins data collecter.
+ Writes the COMMIT number to the report to be parsed
+ by Jenkins data collector.
"""
try:
self.handle.sendline( "" )
@@ -471,8 +511,8 @@
self.handle.sendline(
"cd " +
self.home +
- "; git log -1 --pretty=fuller --decorate=short | grep -A 6\
- \"commit\" --color=never" )
+ "; git log -1 --pretty=fuller --decorate=short | grep -A 6 " +
+ " \"commit\" --color=never" )
# NOTE: for some reason there are backspaces inserted in this
# phrase when run from Jenkins on some tests
self.handle.expect( "never" )
@@ -485,13 +525,18 @@
for line in lines:
print line
if report:
+ main.log.wiki( "<blockquote>" )
for line in lines[ 2:-1 ]:
# Bracket replacement is for Wiki-compliant
# formatting. '<' or '>' are interpreted
# as xml specific tags that cause errors
line = line.replace( "<", "[" )
line = line.replace( ">", "]" )
- main.log.report( "\t" + line )
+ #main.log.wiki( "\t" + line )
+ main.log.wiki( line + "<br /> " )
+ main.log.summary( line )
+ main.log.wiki( "</blockquote>" )
+ main.log.summary("\n")
return lines[ 2 ]
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -503,15 +548,13 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 80 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def createCellFile( self, benchIp, fileName, mnIpAddrs,
- extraFeatureString, *onosIpAddrs ):
+ appString, *onosIpAddrs ):
"""
Creates a cell file based on arguments
Required:
@@ -535,12 +578,11 @@
# Create the cell file in the directory for writing ( w+ )
cellFile = open( tempDirectory + fileName, 'w+' )
- # Feature string is hardcoded environment variables
+ # App string is hardcoded environment variables
# That you may wish to use by default on startup.
- # Note that you may not want certain features listed
+ # Note that you may not want certain apps listed
# on here.
- coreFeatureString = "export ONOS_FEATURES=webconsole,onos-api," +\
- "onos-cli,onos-openflow," + extraFeatureString
+ appString = "export ONOS_APPS=" + appString
mnString = "export OCN="
onosString = "export OC"
tempCount = 1
@@ -569,7 +611,7 @@
tempCount = tempCount + 1
cellFile.write( mnString + "\"" + mnIpAddrs + "\"" + "\n" )
- cellFile.write( coreFeatureString + "\n" )
+ cellFile.write( appString + "\n" )
cellFile.close()
# We use os.system to send the command to TestON cluster
@@ -588,10 +630,8 @@
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( ":::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -609,12 +649,12 @@
# Expect the cellname in the ONOSCELL variable.
# Note that this variable name is subject to change
# and that this driver will have to change accordingly
- self.handle.expect( "ONOS_CELL=" + str( cellname ) )
+ self.handle.expect(str(cellname))
handleBefore = self.handle.before
handleAfter = self.handle.after
# Get the rest of the handle
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.sendline("")
+ self.handle.expect("\$")
handleMore = self.handle.before
main.log.info( "Cell call returned: " + handleBefore +
@@ -627,10 +667,8 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -657,15 +695,55 @@
handleAfter + handleMore )
return main.TRUE
- except pexpect.EOF:
- main.log.error( self.name + ": EOF exception found" )
+ except pexpect.ExceptionPexpect as e:
+ main.log.error( self.name + ": Pexpect exception found of type " +
+ str( type( e ) ) )
+ main.log.error ( e.get_trace() )
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def onosCfgSet( self, ONOSIp, configName, configParam ):
+ """
+ Uses 'onos <node-ip> cfg set' to change a parameter value of an
+ application.
+
+ ex)
+ onos 10.0.0.1 cfg set org.onosproject.myapp appSetting 1
+
+ ONOSIp = '10.0.0.1'
+ configName = 'org.onosproject.myapp'
+ configParam = 'appSetting 1'
+
+ """
+ try:
+ cfgStr = ( "onos "+str(ONOSIp)+" cfg set "+
+ str(configName) + " " +
+ str(configParam)
+ )
+
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( cfgStr )
+ self.handle.expect( "\$" )
+
+ # TODO: Add meaningful assertion
+
+ return main.TRUE
+
+ except pexpect.ExceptionPexpect as e:
+ main.log.error( self.name + ": Pexpect exception found of type " +
+ str( type( e ) ) )
+ main.log.error ( e.get_trace() )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -723,10 +801,8 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -778,10 +854,8 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -816,10 +890,8 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -835,6 +907,7 @@
" stop" )
i = self.handle.expect( [
"stop/waiting",
+ "Could not resolve hostname",
"Unknown\sinstance",
pexpect.TIMEOUT ], timeout=60 )
@@ -842,9 +915,12 @@
main.log.info( "ONOS service stopped" )
return main.TRUE
elif i == 1:
- main.log.info( "Unknown ONOS instance specified: " +
+ main.log.info( "onosStop() Unknown ONOS instance specified: " +
str( nodeIp ) )
return main.FALSE
+ elif i == 2:
+ main.log.warn( "ONOS wasn't running" )
+ return main.TRUE
else:
main.log.error( "ONOS service failed to stop" )
return main.FALSE
@@ -854,10 +930,8 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -869,7 +943,7 @@
"""
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( "\$", timeout=60 )
self.handle.sendline( "onos-uninstall " + str( nodeIp ) )
self.handle.expect( "\$" )
@@ -878,15 +952,16 @@
# onos-uninstall command does not return any text
return main.TRUE
+ except pexpect.TIMEOUT:
+ main.log.exception( self.name + ": Timeout in onosUninstall" )
+ 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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -916,10 +991,8 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -954,7 +1027,7 @@
" not configured" )
return main.FALSE
else:
- main.log.info( "ONOS instasnce was not killed" )
+ main.log.info( "ONOS instance was not killed" )
return main.FALSE
except pexpect.EOF:
@@ -962,10 +1035,8 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -990,8 +1061,8 @@
timeout=120 )
if i == 1:
return main.FALSE
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ #self.handle.sendline( "" )
+ #self.handle.expect( "\$" )
return main.TRUE
except pexpect.EOF:
@@ -999,10 +1070,8 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1038,25 +1107,23 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
- def isup( self, node="" ):
+ def isup(self, node = "", timeout = 120):
"""
Run's onos-wait-for-start which only returns once ONOS is at run
- level 100( ready for use )
+ level 100(ready for use)
Returns: main.TRUE if ONOS is running and main.FALSE on timeout
"""
try:
- self.handle.sendline( "onos-wait-for-start " + node )
- self.handle.expect( "onos-wait-for-start" )
+ self.handle.sendline("onos-wait-for-start " + node )
+ self.handle.expect("onos-wait-for-start")
# NOTE: this timeout is arbitrary"
- i = self.handle.expect( [ "\$", pexpect.TIMEOUT ], timeout=120 )
+ i = self.handle.expect(["\$", pexpect.TIMEOUT], timeout)
if i == 0:
main.log.info( self.name + ": " + node + " is up" )
return main.TRUE
@@ -1072,10 +1139,8 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1136,58 +1201,31 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def getTopology( self, topologyOutput ):
"""
- parses the onos:topology output
- Returns: a topology dict populated by the key values found in
- the cli command.
+ Definition:
+ Loads a json topology output
+ Return:
+ topology = current ONOS topology
"""
+ import json
try:
- # call the cli to get the topology summary
- # cmdstr = "onos:topology"
- # cliResult = self.onosCli( ip, cmdstr )
- # print "cli_result = ", cliResult
-
- # Parse the output
- topology = {}
- # for line in cliResult.split( "\n" ):
- for line in topologyOutput.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 = ", topology
- # devices = topology.get( 'devices', False )
- # print "devices = ", devices
- # links = topology.get( 'links', False )
- # print "links = ", links
- # SCCs = topology.get( 'SCC(s)', False )
- # print "SCCs = ", SCCs
- # paths = topology.get( 'paths', False )
- # print "paths = ", paths
-
+ # either onos:topology or 'topology' will work in CLI
+ topology = json.loads(topologyOutput)
+ print topology
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1198,21 +1236,21 @@
numolink,
logLevel="info" ):
"""
- Checks the number of swithes & links that ONOS sees against the
+ Checks the number of switches & links that ONOS sees against the
supplied values. By default this will report to main.log, but the
- log level can be specifid.
+ log level can be specific.
Params: ip = ip used for the onos cli
numoswitch = expected number of switches
- numlink = expected number of links
+ numolink = expected number of links
logLevel = level to log to.
Currently accepts 'info', 'warn' and 'report'
logLevel can
- Returns: main.TRUE if the number of switchs and links are correct,
- main.FALSE if the numer of switches and links is incorrect,
+ Returns: main.TRUE if the number of switches and links are correct,
+ main.FALSE if the number of switches and links is incorrect,
and main.ERROR otherwise
"""
try:
@@ -1221,27 +1259,27 @@
return main.ERROR
output = ""
# Is the number of switches is what we expected
- devices = topology.get( 'devices', False )
- links = topology.get( 'links', False )
+ devices = topology.get( 'deviceCount', False )
+ links = topology.get( 'linkCount', False )
if not devices or not links:
return main.ERROR
switchCheck = ( int( devices ) == int( numoswitch ) )
# Is the number of links is what we expected
linkCheck = ( int( links ) == int( numolink ) )
- if ( switchCheck and linkCheck ):
+ if switchCheck and linkCheck:
# 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"
+ "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 ) )
+ output = output + "\n ONOS sees %i devices" % int( devices )
+ output = output + " (%i expected) " % int( numoswitch )
+ output = output + "and %i links " % int( links )
+ output = output + "(%i expected)" % int( numolink )
if logLevel == "report":
main.log.report( output )
elif logLevel == "warn":
@@ -1254,10 +1292,8 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1270,31 +1306,41 @@
* interface: interface to capture
* dir: directory/filename to store pcap
"""
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
- self.handle.sendline( "tshark -i " + str( interface ) +
- " -t e -w " + str( dirFile ) + " &" )
- self.handle.sendline( "\r" )
- self.handle.expect( "Capturing on" )
- self.handle.sendline( "\r" )
- self.handle.expect( "\$" )
+ self.handle.sendline( "tshark -i " + str( interface ) +
+ " -t e -w " + str( dirFile ) + " &" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "Capturing on" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "\$" )
- main.log.info( "Tshark started capturing files on " +
- str( interface ) + " and saving to directory: " +
- str( dirFile ) )
+ main.log.info( "Tshark started capturing files on " +
+ str( interface ) + " and saving to directory: " +
+ str( dirFile ) )
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def runOnosTopoCfg( self, instanceName, jsonFile ):
"""
On ONOS bench, run this command:
- ./~/ONOS/tools/test/bin/onos-topo-cfg $OC1 filename
+ {ONOS_HOME}/tools/test/bin/onos-topo-cfg $OC1 filename
which starts the rest and copies
the json file to the onos instance
"""
try:
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "cd ~/ONOS/tools/test/bin" )
+ self.handle.sendline( "cd " + self.home + "/tools/test/bin" )
self.handle.expect( "/bin$" )
cmd = "./onos-topo-cfg " + instanceName + " " + jsonFile
print "cmd = ", cmd
@@ -1303,48 +1349,82 @@
self.handle.sendline( "cd ~" )
self.handle.expect( "\$" )
return main.TRUE
- except:
- 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
- def tsharkGrep( self, grep, directory, interface='eth0' ):
+ def tsharkGrep( self, grep, directory, interface='eth0', grepOptions='' ):
"""
Required:
* grep string
* directory to store results
Optional:
* interface - default: eth0
+ * grepOptions - options for grep
Description:
Uses tshark command to grep specific group of packets
and stores the results to specified directory.
The timestamp is hardcoded to be in epoch
"""
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
- self.handle.sendline( "" )
- self.handle.sendline(
- "tshark -i " +
- str( interface ) +
- " -t e | grep --line-buffered \"" +
- str(grep) +
- "\" >" +
- directory +
- " &" )
- self.handle.sendline( "\r" )
- self.handle.expect( "Capturing on" )
- self.handle.sendline( "\r" )
- self.handle.expect( "\$" )
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "" )
+ if grepOptions:
+ grepStr = "grep "+str(grepOptions)
+ else:
+ grepStr = "grep"
+
+ self.handle.sendline(
+ "tshark -i " +
+ str( interface ) +
+ " -t e | " +
+ grepStr + " --line-buffered \"" +
+ str(grep) +
+ "\" >" +
+ directory +
+ " &" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "Capturing on" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "\$" )
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def tsharkStop( self ):
"""
Removes wireshark files from /tmp and kills all tshark processes
"""
# Remove all pcap from previous captures
- self.execute( cmd="sudo rm /tmp/wireshark*" )
- self.handle.sendline( "" )
- self.handle.sendline( "sudo kill -9 `ps -ef | grep \"tshark -i\" |" +
- " grep -v grep | awk '{print $2}'`" )
- self.handle.sendline( "" )
- main.log.info( "Tshark stopped" )
+ try:
+ self.execute( cmd="sudo rm /tmp/wireshark*" )
+ self.handle.sendline( "" )
+ self.handle.sendline( "sudo kill -9 `ps -ef | grep \"tshark -i\"" +
+ " | grep -v grep | awk '{print $2}'`" )
+ self.handle.sendline( "" )
+ main.log.info( "Tshark stopped" )
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def ptpd( self, args ):
"""
@@ -1379,15 +1459,13 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
def cpLogsToDir( self, logToCopy,
- destDir, copyFileName="" ):
+ destDir, copyFileName="" ):
"""
Copies logs to a desired directory.
Current implementation of ONOS deletes its karaf
@@ -1419,13 +1497,9 @@
destDir += "/"
if copyFileName:
- self.handle.sendline(
- "cp " +
- str( logToCopy ) +
- " " +
- str( destDir ) +
- str( copyFileName ) +
- localtime )
+ self.handle.sendline( "cp " + str( logToCopy ) + " " +
+ str( destDir ) + str( copyFileName ) +
+ localtime )
self.handle.expect( "cp" )
self.handle.expect( "\$" )
else:
@@ -1440,11 +1514,8 @@
main.log.error( "Copying files failed" )
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
- main.log.error( "Copying files failed" )
- main.log.info( self.name + " ::::::" )
- main.log.error( traceback.print_exc() )
- main.log.info( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( "Copying files failed" )
def checkLogs( self, onosIp ):
"""
@@ -1462,11 +1533,10 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def onosStatus( self, node="" ):
"""
@@ -1487,8 +1557,6 @@
return main.TRUE
elif i == 1:
main.log.info( "ONOS is stopped" )
- return main.FALSE
- else:
main.log.error( "ONOS service failed to check the status" )
main.cleanup()
main.exit()
@@ -1497,9 +1565,503 @@
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 + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
+
+ def setIpTables( self, ip, port='', action='add', packet_type='',
+ direction='INPUT', rule='DROP', states=True ):
+ """
+ Description:
+ add or remove iptables rule to DROP (default) packets from
+ specific IP and PORT
+ Usage:
+ * specify action ('add' or 'remove')
+ when removing, pass in the same argument as you would add. It will
+ delete that specific rule.
+ * specify the ip to block
+ * specify the destination port to block (defaults to all ports)
+ * optional packet type to block (default tcp)
+ * optional iptables rule (default DROP)
+ * optional direction to block (default 'INPUT')
+ * States boolean toggles adding all supported tcp states to the
+ firewall rule
+ Returns:
+ main.TRUE on success or
+ main.FALSE if given invalid input or
+ main.ERROR if there is an error in response from iptables
+ WARNING:
+ * This function uses root privilege iptables command which may result
+ in unwanted network errors. USE WITH CAUTION
+ """
+ import time
+
+ # NOTE*********
+ # The strict checking methods of this driver function is intentional
+ # to discourage any misuse or error of iptables, which can cause
+ # severe network errors
+ # *************
+
+ # NOTE: Sleep needed to give some time for rule to be added and
+ # registered to the instance. If you are calling this function
+ # multiple times this sleep will prevent any errors.
+ # DO NOT REMOVE
+ # time.sleep( 5 )
+ try:
+ # input validation
+ action_type = action.lower()
+ rule = rule.upper()
+ direction = direction.upper()
+ if action_type != 'add' and action_type != 'remove':
+ main.log.error( "Invalid action type. Use 'add' or "
+ "'remove' table rule" )
+ if rule != 'DROP' and rule != 'ACCEPT' and rule != 'LOG':
+ # NOTE Currently only supports rules DROP, ACCEPT, and LOG
+ main.log.error( "Invalid rule. Valid rules are 'DROP' or "
+ "'ACCEPT' or 'LOG' only." )
+ if direction != 'INPUT' and direction != 'OUTPUT':
+ # NOTE currently only supports rules INPUT and OUPTUT
+ main.log.error( "Invalid rule. Valid directions are"
+ " 'OUTPUT' or 'INPUT'" )
+ return main.FALSE
+ return main.FALSE
+ return main.FALSE
+ if action_type == 'add':
+ # -A is the 'append' action of iptables
+ actionFlag = '-A'
+ elif action_type == 'remove':
+ # -D is the 'delete' rule of iptables
+ actionFlag = '-D'
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ cmd = "sudo iptables " + actionFlag + " " +\
+ direction +\
+ " -s " + str( ip )
+ # " -p " + str( packet_type ) +\
+ if packet_type:
+ cmd += " -p " + str( packet_type )
+ if port:
+ cmd += " --dport " + str( port )
+ if states:
+ cmd += " -m state --state="
+ #FIXME- Allow user to configure which states to block
+ cmd += "INVALID,ESTABLISHED,NEW,RELATED,UNTRACKED"
+ cmd += " -j " + str( rule )
+
+ self.handle.sendline( cmd )
+ self.handle.expect( "\$" )
+ main.log.warn( self.handle.before )
+
+ info_string = "On " + str( self.name )
+ info_string += " " + str( action_type )
+ info_string += " iptable rule [ "
+ info_string += " IP: " + str( ip )
+ info_string += " Port: " + str( port )
+ info_string += " Rule: " + str( rule )
+ info_string += " Direction: " + str( direction ) + " ]"
+ main.log.info( info_string )
+ return main.TRUE
+ except pexpect.TIMEOUT:
+ main.log.exception( self.name + ": Timeout exception in "
+ "setIpTables function" )
+ return main.ERROR
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def detailed_status(self, log_filename):
+ """
+ This method is used by STS to check the status of the controller
+ Reports RUNNING, STARTING, STOPPED, FROZEN, ERROR (and reason)
+ """
+ import re
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "cd " + self.home )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "service onos status" )
+ self.handle.expect( "\$" )
+ response = self.handle.before
+ if re.search( "onos start/running", response ):
+ # onos start/running, process 10457
+ return 'RUNNING'
+ # FIXME: Implement this case
+ # elif re.search( pattern, response ):
+ # return 'STARTING'
+ elif re.search( "onos stop/", response ):
+ # onos stop/waiting
+ # FIXME handle this differently?: onos stop/pre-stop
+ return 'STOPPED'
+ # FIXME: Implement this case
+ # elif re.search( pattern, response ):
+ # return 'FROZEN'
+ else:
+ main.log.warn( self.name +
+ " WARNING: status received unknown response" )
+ main.log.warn( response )
+ return 'ERROR', "Unknown response: %s" % response
+ except pexpect.TIMEOUT:
+ main.log.exception( self.name + ": Timeout exception in "
+ "setIpTables function" )
+ return 'ERROR', "Pexpect Timeout"
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def createLinkGraphFile( self, benchIp, ONOSIpList, deviceCount):
+ '''
+ Create/formats the LinkGraph.cfg file based on arguments
+ -only creates a linear topology and connects islands
+ -evenly distributes devices
+ -must be called by ONOSbench
+
+ ONOSIpList - list of all of the node IPs to be used
+
+ deviceCount - number of switches to be assigned
+ '''
+ main.log.step("Creating link graph configuration file." )
+ linkGraphPath = self.home + "/tools/package/etc/linkGraph.cfg"
+ tempFile = "/tmp/linkGraph.cfg"
+
+ linkGraph = open(tempFile, 'w+')
+ linkGraph.write("# NullLinkProvider topology description (config file).\n")
+ linkGraph.write("# The NodeId is only added if the destination is another node's device.\n")
+ linkGraph.write("# Bugs: Comments cannot be appended to a line to be read.\n")
+
+ clusterCount = len(ONOSIpList)
+
+ if type(deviceCount) is int or type(deviceCount) is str:
+ deviceCount = int(deviceCount)
+ switchList = [0]*(clusterCount+1)
+ baselineSwitchCount = deviceCount/clusterCount
+
+ for node in range(1, clusterCount + 1):
+ switchList[node] = baselineSwitchCount
+
+ for node in range(1, (deviceCount%clusterCount)+1):
+ switchList[node] += 1
+
+ if type(deviceCount) is list:
+ main.log.info("Using provided device distribution")
+ switchList = [0]
+ for i in deviceCount:
+ switchList.append(int(i))
+
+ tempList = ['0']
+ tempList.extend(ONOSIpList)
+ ONOSIpList = tempList
+
+ myPort = 6
+ lastSwitch = 0
+ for node in range(1, clusterCount+1):
+ if switchList[node] == 0:
+ continue
+
+ linkGraph.write("graph " + ONOSIpList[node] + " {\n")
+
+ if node > 1:
+ #connect to last device on previous node
+ line = ("\t0:5 -> " + str(lastSwitch) + ":6:" + lastIp + "\n") #ONOSIpList[node-1]
+ linkGraph.write(line)
+
+ lastSwitch = 0
+ for switch in range (0, switchList[node]-1):
+ line = ""
+ line = ("\t" + str(switch) + ":" + str(myPort))
+ line += " -- "
+ line += (str(switch+1) + ":" + str(myPort-1) + "\n")
+ linkGraph.write(line)
+ lastSwitch = switch+1
+ lastIp = ONOSIpList[node]
+
+ #lastSwitch += 1
+ if node < (clusterCount):
+ #connect to first device on the next node
+ line = ("\t" + str(lastSwitch) + ":6 -> 0:5:" + ONOSIpList[node+1] + "\n")
+ linkGraph.write(line)
+
+ linkGraph.write("}\n")
+ linkGraph.close()
+
+ #SCP
+ os.system( "scp " + tempFile + " admin@" + benchIp + ":" + linkGraphPath)
+ main.log.info("linkGraph.cfg creation complete")
+
+ def configNullDev( self, ONOSIpList, deviceCount, numPorts=10):
+
+ '''
+ ONOSIpList = list of Ip addresses of nodes switches will be devided amongst
+ deviceCount = number of switches to distribute, or list of values to use as custom distribution
+ numPorts = number of ports per device. Defaults to 10 both in this function and in ONOS. Optional arg
+ '''
+
+ main.log.step("Configuring Null Device Provider" )
+ clusterCount = len(ONOSIpList)
+
+ try:
+
+ if type(deviceCount) is int or type(deviceCount) is str:
+ main.log.step("Creating device distribution")
+ deviceCount = int(deviceCount)
+ switchList = [0]*(clusterCount+1)
+ baselineSwitchCount = deviceCount/clusterCount
+
+ for node in range(1, clusterCount + 1):
+ switchList[node] = baselineSwitchCount
+
+ for node in range(1, (deviceCount%clusterCount)+1):
+ switchList[node] += 1
+
+ if type(deviceCount) is list:
+ main.log.info("Using provided device distribution")
+
+ if len(deviceCount) == clusterCount:
+ switchList = ['0']
+ switchList.extend(deviceCount)
+
+ if len(deviceCount) == (clusterCount + 1):
+ if deviceCount[0] == '0' or deviceCount[0] == 0:
+ switchList = deviceCount
+
+ assert len(switchList) == (clusterCount + 1)
+
+ except AssertionError:
+ main.log.error( "Bad device/Ip list match")
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+
+ ONOSIp = [0]
+ ONOSIp.extend(ONOSIpList)
+
+ devicesString = "devConfigs = "
+ for node in range(1, len(ONOSIp)):
+ devicesString += (ONOSIp[node] + ":" + str(switchList[node] ))
+ if node < clusterCount:
+ devicesString += (",")
+
+ try:
+ self.handle.sendline("onos $OC1 cfg set org.onosproject.provider.nil.device.impl.NullDeviceProvider devConfigs " + devicesString )
+ self.handle.expect(":~")
+ self.handle.sendline("onos $OC1 cfg set org.onosproject.provider.nil.device.impl.NullDeviceProvider numPorts " + str(numPorts) )
+ self.handle.expect(":~")
+
+ for i in range(10):
+ self.handle.sendline("onos $OC1 cfg get org.onosproject.provider.nil.device.impl.NullDeviceProvider")
+ self.handle.expect(":~")
+ verification = self.handle.before
+ if (" value=" + str(numPorts)) in verification and (" value=" + devicesString) in verification:
+ break
+ else:
+ time.sleep(1)
+
+ assert ("value=" + str(numPorts)) in verification and (" value=" + devicesString) in verification
+
+ except AssertionError:
+ main.log.error("Incorrect Config settings: " + verification)
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def configNullLink( self,fileName="/opt/onos/apache-karaf-3.0.3/etc/linkGraph.cfg", eventRate=0):
+ '''
+ fileName default is currently the same as the default on ONOS, specify alternate file if
+ you want to use a different topology file than linkGraph.cfg
+ '''
+
+
+ try:
+ self.handle.sendline("onos $OC1 cfg set org.onosproject.provider.nil.link.impl.NullLinkProvider eventRate " + str(eventRate))
+ self.handle.expect(":~")
+ self.handle.sendline("onos $OC1 cfg set org.onosproject.provider.nil.link.impl.NullLinkProvider cfgFile " + fileName )
+ self.handle.expect(":~")
+
+ for i in range(10):
+ self.handle.sendline("onos $OC1 cfg get org.onosproject.provider.nil.link.impl.NullLinkProvider")
+ self.handle.expect(":~")
+ verification = self.handle.before
+ if (" value=" + str(eventRate)) in verification and (" value=" + fileName) in verification:
+ break
+ else:
+ time.sleep(1)
+
+ assert ("value=" + str(eventRate)) in verification and (" value=" + fileName) in verification
+
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except AssertionError:
+ main.log.info("Settings did not post to ONOS")
+ main.log.error(varification)
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.log.error(varification)
+ main.cleanup()
+ main.exit()
+
+
+ def getOnosIpFromEnv(self):
+
+ import string
+
+ # returns a list of ip addresses for the onos nodes, will work with up to 7 nodes + OCN and OCI
+ # returns in format [ 'x', OC1 ip, OC2 i... ect. ... , ONN ip ]
+
+ self.handle.sendline("env| grep OC")
+ self.handle.expect(":~")
+ rawOutput = self.handle.before
+ print rawOutput
+ print "-----------------------------"
+ print repr(rawOutput)
+ mpa = dict.fromkeys(range(32))
+ translated = rawOutput.translate(mpa)
+ print translated
+
+
+ # create list with only the lines that have the needed IPs
+ unparsedIps = []
+
+ # remove preceeding or trailing lines
+ for line in rawOutput:
+ if "OC" in line and "=" in line:
+ unparsedIps.append(str(line))
+
+ # determine cluster size
+ clusterCount = 0
+ for line in unparsedIps:
+ line = str(line)
+ print line
+ temp = line.replace("OC","")
+ print("line index " + str(line.index("=")))
+ OCindex = temp[0]
+ for i in range(0, 7):
+ if OCindex == str(i) and i > clusterCount:
+ clusterCount == i
+ print(clusterCount)
+ # create list to hold ips such that OC1 is at list[1] and OCN and OCI are at the end (in that order)
+ ONOSIps = ["x"] * (clusterCount + 3)
+
+ # populate list
+ for line in unparsedIps:
+ main.log.info(line)##########
+ temp = str(line.replace("OC",""))
+ main.log.info(str(list(temp)))
+ OCindex = temp[0]
+ main.log.info(OCindex)############
+ if OCindex == "N":
+ ONOSIps[ clusterCount + 1 ] = temp.replace("N=","")
+
+ if OCindex == "I":
+ ONOSIps[ clusterCount + 2 ] = temp.replace("I=","")
+
+ else:
+ ONOSIps[ int(OCindex) ] = temp.replace((OCindex + "=") ,"")
+
+ # validate
+ for x in ONOSIps:
+ if ONOSIps.index(x) != 0 and x == "x":
+ main.log.error("ENV READ FAILURE, MISSING DATA: \n\n" + str(ONOSIps) + "\n\n")
+
+ return ONOSIps
+
+
+ def onosErrorLog(self, nodeIp):
+
+ cmd = "onos-ssh " + nodeIp + " cat /opt/onos/log/karaf.log | grep WARN"
+ self.handle.sendline(cmd)
+ self.handle.expect(":~")
+ before = (self.handle.before).splitlines()
+
+ warnings = []
+
+ for line in before:
+ if "WARN" in line and "grep" not in line:
+ warnings.append(line)
+ main.warnings[main.warnings[0]+1] = line
+ main.warnings[0] += 1
+ if main.warnings[0] >= 10:
+ main.warnings[0] = 0
+
+ cmd = "onos-ssh " + nodeIp + " cat /opt/onos/log/karaf.log | grep ERROR"
+ self.handle.sendline(cmd)
+ self.handle.expect(":~")
+ before = (self.handle.before).splitlines()
+
+ errors = []
+
+ for line in before:
+ if "ERROR" in line and "grep" not in line:
+ errors.append(line)
+ main.errors[main.errors[0]+1] = line
+ main.errors[0] += 1
+ if main.errors[0] >= 10:
+ main.errors[0] = 0
+
+ cmd = "onos-ssh " + nodeIp + " cat /opt/onos/log/karaf.log | grep Exept"
+ self.handle.sendline(cmd)
+ self.handle.expect(":~")
+ before = (self.handle.before).splitlines()
+
+ exceptions = []
+
+ for line in before:
+ if "Except" in line and "grep" not in line:
+ exceptions.append(line)
+ main.exceptions[main.errors[0]+1] = line
+ main.exceptions[0] += 1
+ if main.exceptions[0] >= 10:
+ main.exceptions[0] = 0
+
+
+
+ ################################################################
+
+ msg1 = "WARNINGS: \n"
+ for i in main.warnings:
+ if type(i) is not int:
+ msg1 += ( i + "\n")
+
+ msg2 = "ERRORS: \n"
+ for i in main.errors:
+ if type(i) is not int:
+ msg2 += ( i + "\n")
+
+ msg3 = "EXCEPTIONS: \n"
+ for i in main.exceptions:
+ if type(i) is not int:
+ msg3 += ( i + "\n")
+
+ main.log.info("===============================================================\n")
+ main.log.info( "Warnings: " + str(len(warnings)))
+ main.log.info( "Errors: " + str(len(errors)))
+ main.log.info( "Exceptions: " + str(len(exceptions)))
+ if len(warnings) > 0:
+ main.log.info(msg1)
+ if len(errors) > 0:
+ main.log.info(msg2)
+ if len(exceptions) > 0:
+ main.log.info(msg3)
+ main.log.info("===============================================================\n")
+
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 87de64d..f391e3a 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -2,13 +2,7 @@
import time
import pexpect
-import struct
-import fcntl
-import os
import sys
-import signal
-import sys
-import re
import json
sys.path.append( "../" )
from drivers.common.clidriver import CLI
@@ -23,7 +17,20 @@
def connect( self, **connectargs ):
for key in connectargs:
vars( self )[ key ] = connectargs[ key ]
+ self.name = self.options[ 'name' ]
+ self.handle = super( QuaggaCliDriver, self ).connect(
+ user_name=self.user_name,
+ ip_address="127.0.0.1",
+ port=self.port,
+ pwd=self.pwd )
+ if self.handle:
+ return self.handle
+ else:
+ main.log.info( "NO HANDLE" )
+ return main.FALSE
+
+ def connectQuagga( self ):
self.name = self.options[ 'name' ]
# self.handle = super( QuaggaCliDriver,self ).connect(
# user_name=self.user_name, ip_address=self.ip_address,port=self.port,
@@ -87,7 +94,7 @@
try:
self.handle.sendline( "" )
self.handle.expect( "bgpd#" )
- except:
+ except Exception:
main.log.warn( "Probably not currently in enable mode!" )
self.disconnect()
return main.FALSE
@@ -98,7 +105,7 @@
self.handle.sendline( routerAS )
self.handle.expect( "config-router", timeout=5 )
return main.TRUE
- except:
+ except Exception:
return main.FALSE
def generatePrefixes( self, net, numRoutes ):
@@ -183,11 +190,12 @@
routesJsonObj = json.loads( getRoutesResult )
allRoutesActual = []
- for route in routesJsonObj:
- if route[ 'prefix' ] == '172.16.10.0/24':
- continue
- allRoutesActual.append(
- route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
+ for route in routesJsonObj['routes4']:
+ if 'prefix' in route:
+ if route[ 'prefix' ] == '172.16.10.0/24':
+ continue
+ allRoutesActual.append(
+ route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
return sorted( allRoutesActual )
@@ -347,21 +355,40 @@
self.handle.sendline( "" )
# self.handle.expect( "config-router" )
self.handle.expect( "config-router", timeout=5 )
- except:
+ except Exception:
main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
main.log.info( "Start to add routes" )
- for i in range( 0, len( routes ) ):
- routeCmd = "network " + routes[ i ]
+ chunk_size = 20
+
+ if len(routes) > chunk_size:
+ num_iter = (int) (len(routes) / chunk_size)
+ else:
+ num_iter = 1;
+
+ total = 0
+ for n in range( 0, num_iter + 1):
+ routeCmd = ""
+ if (len( routes ) - (n * chunk_size)) >= chunk_size:
+ m = (n + 1) * chunk_size
+ else:
+ m = len( routes )
+ for i in range( n * chunk_size, m ):
+ routeCmd = routeCmd + "network " + routes[ i ] + "\n"
+ total = total + 1
+
+ main.log.info(routeCmd)
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd", timeout=5 )
- except:
+ except Exception:
main.log.warn( "Failed to add route" )
self.disconnect()
+
# waitTimer = 1.00 / routeRate
- # time.sleep( waitTimer )
+ main.log.info("Total routes so far " + ((str) (total)) + " wait for 0 sec")
+ #time.sleep( 1 )
if routesAdded == len( routes ):
main.log.info( "Finished adding routes" )
return main.TRUE
@@ -375,7 +402,7 @@
self.handle.sendline( "" )
# self.handle.expect( "config-router" )
self.handle.expect( "config-router", timeout=5 )
- except:
+ except Exception:
main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
main.log.info( "Start to delete routes" )
@@ -385,7 +412,7 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd", timeout=5 )
- except:
+ except Exception:
main.log.warn( "Failed to delete route" )
self.disconnect()
# waitTimer = 1.00 / routeRate
@@ -424,12 +451,13 @@
main.log.info( "NO HANDLE" )
return main.FALSE
+
# Please use the generateRoutes plus addRoutes instead of this one!
def addRoute( self, net, numRoutes, routeRate ):
try:
self.handle.sendline( "" )
self.handle.expect( "config-router" )
- except:
+ except Exception:
main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
main.log.info( "Adding Routes" )
@@ -450,7 +478,7 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd" )
- except:
+ except Exception:
main.log.warn( "failed to add route" )
self.disconnect()
waitTimer = 1.00 / routeRate
@@ -464,9 +492,9 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd" )
- except:
+ except Exception:
main.log.warn( "failed to add route" )
- self.disconnect
+ self.disconnect()
waitTimer = 1.00 / routeRate
time.sleep( waitTimer )
routesAdded = routesAdded + 1
@@ -479,7 +507,7 @@
try:
self.handle.sendline( "" )
self.handle.expect( "config-router" )
- except:
+ except Exception:
main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
main.log.info( "Deleting Routes" )
@@ -500,7 +528,7 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd" )
- except:
+ except Exception:
main.log.warn( "Failed to delete route" )
self.disconnect()
waitTimer = 1.00 / routeRate
@@ -514,7 +542,7 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd" )
- except:
+ except Exception:
main.log.warn( "Failed to delete route" )
self.disconnect()
waitTimer = 1.00 / routeRate
@@ -583,6 +611,46 @@
# elif brand == "cisco" or brand == "CISCO":
# cisco( ip,user,passwd )
+ def disable_bgp_peer( self, peer, peer_as ):
+ main.log.info( "I am in disconnect_peer_session method!" )
+
+ try:
+ self.handle.sendline( "" )
+ # self.handle.expect( "config-router" )
+ self.handle.expect( "config-router", timeout=5 )
+ except Exception:
+ main.log.warn( "Probably not in config-router mode!" )
+ self.disconnect()
+ main.log.info( "Start to disable peer" )
+
+ cmd = "no neighbor " + peer + " remote-as " + peer_as
+ try:
+ self.handle.sendline( cmd )
+ self.handle.expect( "bgpd", timeout=5 )
+ except Exception:
+ main.log.warn( "Failed to disable peer" )
+ self.disconnect()
+
+ def enable_bgp_peer( self, peer, peer_as ):
+ main.log.info( "I am in enable_bgp_peer method!" )
+
+ try:
+ self.handle.sendline( "" )
+ # self.handle.expect( "config-router" )
+ self.handle.expect( "config-router", timeout=5 )
+ except Exception:
+ main.log.warn( "Probably not in config-router mode!" )
+ self.disconnect()
+ main.log.info( "Start to disable peer" )
+
+ cmd = "neighbor " + peer + " remote-as " + peer_as
+ try:
+ self.handle.sendline( cmd )
+ self.handle.expect( "bgpd", timeout=5 )
+ except Exception:
+ main.log.warn( "Failed to enable peer" )
+ self.disconnect()
+
def disconnect( self ):
"""
Called when Test is complete to disconnect the Quagga handle.
@@ -590,7 +658,7 @@
response = ''
try:
self.handle.close()
- except:
+ except Exception:
main.log.error( "Connection failed to the host" )
response = main.FALSE
return response
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index 1b8998b..44552ae 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -81,7 +81,7 @@
while i == 5:
i = self.handle.expect( [
ssh_newkey,
- 'password:|\$',
+ 'password:',
pexpect.EOF,
pexpect.TIMEOUT,
refused,
@@ -94,10 +94,17 @@
i = self.handle.expect(
[ ssh_newkey, 'password:', pexpect.EOF ] )
if i == 1:
- main.log.info(
- "ssh connection asked for password, gave password" )
- self.handle.sendline( self.pwd )
- self.handle.expect( '>|#|\$' )
+ if self.pwd:
+ main.log.info(
+ "ssh connection asked for password, gave password" )
+ self.handle.sendline( self.pwd )
+ self.handle.expect( '>|#|\$' )
+ else:
+ # FIXME: TestON does not support a username having no
+ # password
+ main.log.error( "Server asked for password, but none was "
+ "given in the .topo file" )
+ main.exit()
elif i == 2:
main.log.error( "Connection timeout" )
return main.FALSE
diff --git a/TestON/drivers/component.py b/TestON/drivers/component.py
index 1e87d03..f05be55 100644
--- a/TestON/drivers/component.py
+++ b/TestON/drivers/component.py
@@ -23,9 +23,6 @@
"""
-import re
-from logging import Logger
-
class Component( object ):
@@ -35,30 +32,39 @@
def __init__( self ):
self.default = ''
self.wrapped = sys.modules[ __name__ ]
+ self.count = 0
def __getattr__( self, name ):
"""
This will invoke, if the attribute wasn't found the usual ways.
- Here it will look for assert_attribute and will execute when AttributeError occurs.
- It will return the result of the assert_attribute.
+ Here it will look for assert_attribute and will execute when
+ AttributeError occurs.
+ It will return the result of the assert_attribute.
"""
try:
return getattr( self.wrapped, name )
- except AttributeError:
+ except AttributeError as error:
+ # NOTE: The first time we load a driver module we get this error
+ if "'module' object has no attribute '__path__'" in error\
+ and self.count == 0:
+ self.count += 1
+ else:
+ main.log.error( str(error.__class__) + " " + str(error) )
try:
- def experimentHandling( **kwargs ):
+ def experimentHandling( *args, **kwargs ):
if main.EXPERIMENTAL_MODE == main.TRUE:
- result = self.experimentRun( **kwargs )
- main.log.info( "EXPERIMENTAL MODE. API " + str(
- name ) + " not yet implemented. Returning dummy values" )
+ result = self.experimentRun( *args, **kwargs )
+ main.log.info( "EXPERIMENTAL MODE. API " +
+ str( name ) +
+ " not yet implemented. " +
+ "Returning dummy values" )
return result
else:
return main.FALSE
return experimentHandling
except TypeError as e:
- main.log.error(
- "Arguments for experimental mode does not have key 'retruns'" +
- e )
+ main.log.error( "Arguments for experimental mode does not" +
+ " have key 'retruns'" + e )
def connect( self ):
@@ -110,7 +116,8 @@
def get_version( self ):
return "Version unknown"
- def experimentRun( self, **kwargs ):
+ def experimentRun( self, *args, **kwargs ):
+ # FIXME handle *args
args = utilities.parse_args( [ "RETURNS" ], **kwargs )
return args[ "RETURNS" ]
diff --git a/TestON/tests/FuncIntent/FuncIntent.params b/TestON/tests/FuncIntent/FuncIntent.params
new file mode 100755
index 0000000..3d2ef8a
--- /dev/null
+++ b/TestON/tests/FuncIntent/FuncIntent.params
@@ -0,0 +1,34 @@
+<PARAMS>
+
+ <testcases>10,11,12,1001,10,12,1001</testcases>
+
+ <SCALE>1,3</SCALE>
+ <availableNodes>3</availableNodes>
+ <ENV>
+ <cellName>single_func</cellName>
+ <cellApps>drivers,openflow,proxyarp,mobility</cellApps>
+ </ENV>
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
+ <CTRL>
+ <num>3</num>
+ <ip1>OC1</ip1>
+ <port1>6633</port1>
+ <ip2>OC2</ip2>
+ <port2>6633</port2>
+ <ip3>OC3</ip3>
+ <port3>6633</port3>
+ </CTRL>
+ <BENCH>
+ <user>admin</user>
+ <ip1>10.128.10.20</ip1>
+ </BENCH>
+ <MININET>
+ <switch>7</switch>
+ <links>20</links>
+ <topo>~/mininet/custom/newFuncTopo.py</topo>
+ </MININET>
+
+</PARAMS>
diff --git a/TestON/tests/FuncIntent/FuncIntent.py b/TestON/tests/FuncIntent/FuncIntent.py
new file mode 100644
index 0000000..1db5752
--- /dev/null
+++ b/TestON/tests/FuncIntent/FuncIntent.py
@@ -0,0 +1,501 @@
+
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
+
+import time
+import json
+
+time.sleep( 1 )
+
+class FuncIntent:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE10( self, main ):
+ import time
+ import os
+ """
+ Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-log
+ git pull
+ mvn clean install
+ onos-package
+ onos-install -f
+ onos-wait-for-start
+ """
+ global init
+ try:
+ if type(init) is not bool:
+ init = False
+ except NameError:
+ init = False
+ #Local variables
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ apps = main.params[ 'ENV' ][ 'cellApps' ]
+ gitBranch = main.params[ 'GIT' ][ 'branch' ]
+ #benchIp = main.params[ 'BENCH' ][ 'ip1' ]
+ benchUser = main.params[ 'BENCH' ][ 'user' ]
+ topology = main.params[ 'MININET' ][ 'topo' ]
+ #maxNodes = int( main.params[ 'availableNodes' ] )
+ main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
+ main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
+ main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
+ PULLCODE = False
+ if main.params[ 'GIT' ][ 'pull' ] == 'True':
+ PULLCODE = True
+ main.case( "Setting up test environment" )
+ main.CLIs = []
+ for i in range( 1, int( main.numCtrls ) + 1 ):
+ main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
+ if init == False:
+ init = True
+
+ #main.ONOSip = []
+ main.ONOSport = []
+ main.scale = ( main.params[ 'SCALE' ] ).split( "," )
+ main.numCtrls = int( main.scale[ 0 ] )
+
+ if PULLCODE:
+ main.step( "Git checkout and pull " + gitBranch )
+ main.ONOSbench.gitCheckout( gitBranch )
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == main.ERROR:
+ main.log.error( "Error pulling git branch" )
+ main.step( "Using mvn clean & install" )
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ stepResult = cleanInstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully compiled " +
+ "latest ONOS",
+ onfail="Failed to compile " +
+ "latest ONOS" )
+ else:
+ main.log.warn( "Did not pull new code so skipping mvn " +
+ "clean install" )
+ # Populate main.ONOSip with ips from params
+ #for i in range( 1, maxNodes + 1):
+ # main.ONOSip.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
+ # main.ONOSport.append( main.params[ 'CTRL' ][ 'port' +
+ # str( i ) ])
+
+ ONOSip = main.ONOSbench.getOnosIpFromEnv()
+ main.log.info("\t\t CLUSTER IPs: \n\n" + str(ONOSip) + "\n\n")
+
+ main.numCtrls = int( main.scale[ 0 ] )
+ main.scale.remove( main.scale[ 0 ] )
+
+ #kill off all onos processes
+ main.log.info( "Safety check, killing all ONOS processes" +
+ " before initiating enviornment setup" )
+ for i in range( maxNodes ):
+ main.ONOSbench.onosDie( main.ONOSip[ i ] )
+ """
+ main.step( "Apply cell to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ stepResult = cellResult and verifyResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully applied cell to " + \
+ "environment",
+ onfail="Failed to apply cell to environment " )
+ """
+ """main.step( "Removing raft logs" )
+ removeRaftResult = main.ONOSbench.onosRemoveRaftLogs()
+ stepResult = removeRaftResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully removed raft logs",
+ onfail="Failed to remove raft logs" )
+ """
+ print "NODE COUNT = ", main.numCtrls
+ main.log.info( "Creating cell file" )
+ cellIp = []
+ for i in range( main.numCtrls ):
+ cellIp.append( str( main.ONOSip[ i ] ) )
+ print cellIp
+ main.ONOSbench.createCellFile( benchIp, cellName, "",
+ str( apps ), *cellIp )
+
+ main.step( "Apply cell to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ stepResult = cellResult and verifyResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully applied cell to " + \
+ "environment",
+ onfail="Failed to apply cell to environment " )
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+ stepResult = packageResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully created ONOS package",
+ onfail="Failed to create ONOS package" )
+
+ main.step( "Uninstalling ONOS package" )
+ onosUninstallResult = main.TRUE
+ for i in range( main.numCtrls):
+ onosUninstallResult = onosUninstallResult and \
+ main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
+ stepResult = onosUninstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully uninstalled ONOS package",
+ onfail="Failed to uninstall ONOS package" )
+ time.sleep( 5 )
+ main.step( "Installing ONOS package" )
+ onosInstallResult = main.TRUE
+ for i in range( main.numCtrls):
+ onosInstallResult = onosInstallResult and \
+ main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
+ stepResult = onosInstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully installed ONOS package",
+ onfail="Failed to install ONOS package" )
+
+ time.sleep( 5 )
+ main.step( "Starting ONOS service" )
+ stopResult = main.TRUE
+ startResult = main.TRUE
+ onosIsUp = main.TRUE
+ for i in range( main.numCtrls ):
+ onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+ if onosIsUp == main.TRUE:
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up, stop and " +
+ "start ONOS again " )
+ for i in range( main.numCtrls ):
+ stopResult = stopResult and \
+ main.ONOSbench.onosStop( main.ONOSip[ i ] )
+ for i in range( main.numCtrls ):
+ startResult = startResult and \
+ main.ONOSbench.onosStart( main.ONOSip[ i ] )
+ stepResult = onosIsUp and stopResult and startResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="ONOS service is ready",
+ onfail="ONOS service did not start properly" )
+
+ main.step( "Start ONOS cli" )
+ cliResult = main.TRUE
+ for i in range( main.numCtrls ):
+ cliResult = cliResult and \
+ main.CLIs[i].startOnosCli( main.ONOSip[ i ] )
+ stepResult = cliResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully start ONOS cli",
+ onfail="Failed to start ONOS cli" )
+
+ def CASE11( self, main ):
+ """
+ Start mininet
+ """
+ main.log.report( "Start Mininet topology" )
+ main.log.case( "Start Mininet topology" )
+
+ main.step( "Starting Mininet Topology" )
+ topoResult = main.Mininet1.startNet( topoFile=topology )
+ stepResult = topoResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully loaded topology",
+ onfail="Failed to load topology" )
+ # Exit if topology did not load properly
+ if not topoResult:
+ main.cleanup()
+ main.exit()
+
+ def CASE12( self, main ):
+ """
+ Assign mastership to controllers
+ """
+ import re
+
+ main.step( "Assigning switches to controllers" )
+ assignResult = main.TRUE
+ for i in range( 1, ( main.numSwitch + 1 ) ):
+ main.Mininet1.assignSwController( sw=str( i ),
+ count=1,
+ ip1=main.ONOSip[ 0 ],
+ port1=main.ONOSport[ 0 ] )
+ for i in range( 1, ( main.numSwitch + 1 ) ):
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
+ assignResult = assignResult and main.TRUE
+ else:
+ assignResult = main.FALSE
+ stepResult = assignResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully assigned switches" +
+ "to controller",
+ onfail="Failed to assign switches to " +
+ "controller" )
+
+ def CASE1001( self, main ):
+ """
+ Add host intents between 2 host:
+ - Discover hosts
+ - Add host intents
+ - Check intents
+ - Check flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Ping hosts
+ - Link up
+ - Ping hosts
+ - Remove intents
+ """
+ import time
+ import json
+ import re
+ """
+ Create your item(s) here
+ item = { 'name': '', 'host1':
+ { 'name': '', 'MAC': '00:00:00:00:00:0X',
+ 'id':'00:00:00:00:00:0X/-X' } , 'host2':
+ { 'name': '', 'MAC': '00:00:00:00:00:0X',
+ 'id':'00:00:00:00:00:0X/-X'}, 'link': { 'switch1': '',
+ 'switch2': '', 'num':'' } }
+ """
+ # Local variables
+ items = []
+ ipv4 = { 'name': 'IPV4', 'host1':
+ { 'name': 'h1', 'MAC': '00:00:00:00:00:01',
+ 'id':'00:00:00:00:00:01/-1' } , 'host2':
+ { 'name': 'h9', 'MAC': '00:00:00:00:00:09',
+ 'id':'00:00:00:00:00:09/-1'}, 'link': { 'switch1': 's5',
+ 'switch2': 's2', 'num':'18' } }
+ dualStack1 = { 'name': 'DUALSTACK1', 'host1':
+ { 'name': 'h3', 'MAC': '00:00:00:00:00:03',
+ 'id':'00:00:00:00:00:03/-1' } , 'host2':
+ { 'name': 'h11', 'MAC': '00:00:00:00:00:0B',
+ 'id':'00:00:00:00:00:0B/-1'}, 'link': { 'switch1': 's5',
+ 'switch2': 's2', 'num':'18' } }
+ items.append( ipv4 )
+ items.append( dualStack1 )
+ # Global variables
+
+ main.log.case( "Add host intents between 2 host" )
+
+ for item in items:
+ stepResult = main.TRUE
+ itemName = item[ 'name' ]
+ h1Name = item[ 'host1' ][ 'name' ]
+ h2Name = item[ 'host2' ][ 'name' ]
+ h1Mac = item[ 'host1' ][ 'MAC' ]
+ h2Mac = item[ 'host2' ][ 'MAC' ]
+ h1Id = item[ 'host1' ][ 'id']
+ h2Id = item[ 'host2' ][ 'id']
+ # Link down/up for rerouting
+ sw1 = item[ 'link' ][ 'switch1' ]
+ sw2 = item[ 'link' ][ 'switch2' ]
+ remLink = item[ 'link' ][ 'num' ]
+ pingResult = main.TRUE
+ statusResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+ intentsId = []
+ main.step( itemName + ": Add host intents between " + h1Name
+ + " and " + h2Name )
+ main.log.info( itemName + ": Discover host using arping" )
+ main.Mininet1.arping( host=h1Name )
+ main.Mininet1.arping( host=h2Name )
+ host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
+ host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
+ print host1
+ print host2
+ # Adding intents
+ main.log.info( itemName + ": Adding host intents" )
+ intent1 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h1Id,
+ hostIdTwo=h2Id )
+ intentsId.append( intent1 )
+ time.sleep( 5 )
+ intent2 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h2Id,
+ hostIdTwo=h1Id )
+ intentsId.append( intent2 )
+ # Checking intents
+ main.log.info( itemName + ": Check host intents state" )
+ time.sleep( 30 )
+ for i in range( main.numCtrls ):
+ intentResult = main.CLIs[ i ].checkIntentState(
+ intentsId=intentsId )
+ if not intentResult:
+ main.log.info( itemName + ": Check host intents state" +
+ " again")
+ for i in range( main.numCtrls ):
+ intentResult = main.CLIs[ i ].checkIntentState(
+ intentsId=intentsId )
+ # Ping hosts
+ time.sleep( 10 )
+ main.log.info( itemName + ": Ping " + h1Name + " and " +
+ h2Name )
+ pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
+ if not pingResult1:
+ main.log.info( itemName + ": " + h1Name + " cannot ping "
+ + h2Name )
+ pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
+ if not pingResult2:
+ main.log.info( itemName + ": " + h2Name + " cannot ping "
+ + h1Name )
+ pingResult = pingResult1 and pingResult2
+ if pingResult:
+ main.log.info( itemName + ": Successfully pinged " +
+ "both hosts" )
+ else:
+ main.log.info( itemName + ": Failed to ping " +
+ "both hosts" )
+ # Rerouting ( link down )
+ main.log.info( itemName + ": Bring link down between " +
+ sw1 + " and " + sw2 )
+ main.Mininet1.link( end1=sw1,
+ end2=sw2,
+ option="down" )
+ time.sleep( 5 )
+
+ # Check onos topology
+ main.log.info( itemName + ": Checking ONOS topology " )
+
+ for i in range( main.numCtrls ):
+ topologyResult = main.CLIs[ i ].topology()
+ linkDownResult = main.ONOSbench.checkStatus( topologyResult,
+ main.numSwitch,
+ remLink )\
+ and linkDownResult
+ if not linkDownResult:
+ main.log.info( itemName + ": Topology mismatch" )
+ else:
+ main.log.info( itemName + ": Topology match" )
+
+ # Ping hosts
+ main.log.info( itemName + ": Ping " + h1Name + " and " +
+ h2Name )
+ pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
+ if not pingResult1:
+ main.log.info( itemName + ": " + h1Name + " cannot ping "
+ + h2Name )
+ pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
+ if not pingResult2:
+ main.log.info( itemName + ": " + h2Name + " cannot ping "
+ + h1Name )
+ pingResult = pingResult1 and pingResult2
+ if pingResult:
+ main.log.info( itemName + ": Successfully pinged " +
+ "both hosts" )
+ else:
+ main.log.info( itemName + ": Failed to ping " +
+ "both hosts" )
+ # link up
+ main.log.info( itemName + ": Bring link up between " +
+ sw1 + " and " + sw2 )
+ main.Mininet1.link( end1=sw1,
+ end2=sw2,
+ option="up" )
+ time.sleep( 5 )
+
+ # Check onos topology
+ main.log.info( itemName + ": Checking ONOS topology " )
+ for i in range( main.numCtrls ):
+ topologyResult = main.CLIs[ i ].topology()
+ linkUpResult = main.ONOSbench.checkStatus( topologyResult,
+ main.numSwitch,
+ main.numLinks )\
+ and linkUpResult
+ if not linkUpResult:
+ main.log.info( itemName + ": Topology mismatch" )
+ else:
+ main.log.info( itemName + ": Topology match" )
+
+ # Ping hosts
+ main.log.info( itemName + ": Ping " + h1Name + " and " +
+ h2Name )
+ pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
+ if not pingResult1:
+ main.log.info( itemName + ": " + h1Name + " cannot ping "
+ + h2Name )
+ pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
+ if not pingResult2:
+ main.log.info( itemName + ": " + h2Name + " cannot ping "
+ + h1Name )
+ pingResult = pingResult1 and pingResult2
+ if pingResult:
+ main.log.info( itemName + ": Successfully pinged " +
+ "both hosts" )
+ else:
+ main.log.info( itemName + ": Failed to ping " +
+ "both hosts" )
+
+ # Remove intents
+ for intent in intentsId:
+ main.CLIs[ 0 ].removeIntent( intentId=intent, purge=True )
+
+ print main.CLIs[ 0 ].intents()
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass=itemName +
+ ": host intent successful",
+ onfail=itemName +
+ ": Add host intent failed" )
+ def CASE1002( self, main ):
+ """
+ Add point intents between 2 hosts:
+ - Get device ids
+ - Add point intents
+ - Check intents
+ - Check flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Ping hosts
+ - Link up
+ - Ping hosts
+ - Remove intents
+ """
+
+ def CASE1003( self, main ):
+ """
+ Add single point to multi point intents
+ - Get device ids
+ - Add single point to multi point intents
+ - Check intents
+ - Check flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Ping hosts
+ - Link up
+ - Ping hosts
+ - Remove intents
+ """
+
+ def CASE1004( self, main ):
+ """
+ Add multi point to single point intents
+ - Get device ids
+ - Add multi point to single point intents
+ - Check intents
+ - Check flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Ping hosts
+ - Link up
+ - Ping hosts
+ - Remove intents
+ """
diff --git a/TestON/tests/FuncIntent/FuncIntent.topo b/TestON/tests/FuncIntent/FuncIntent.topo
new file mode 100755
index 0000000..e85b397
--- /dev/null
+++ b/TestON/tests/FuncIntent/FuncIntent.topo
@@ -0,0 +1,52 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ <home>~/ONOS</home>
+ </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli3>
+
+ <Mininet1>
+ <host>10.128.10.20</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </Mininet1>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.params b/TestON/tests/HATestClusterRestart/HATestClusterRestart.params
index 6f2002d..500c3ad 100644
--- a/TestON/tests/HATestClusterRestart/HATestClusterRestart.params
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.params
@@ -1,7 +1,7 @@
<PARAMS>
- <testcases>1,2,8,3,4,5,14,[6],8,3,7,4,15,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ <testcases>1,2,8,3,4,5,14,16,17,[6],8,3,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
<ENV>
- <cellName>HA</cellName>
+ <cellName>HA</cellName>
</ENV>
<Git>False</Git>
<branch> master </branch>
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.py b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
index 791d55c..bb69fcc 100644
--- a/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
@@ -18,6 +18,8 @@
CASE13: Clean up
CASE14: start election app on all onos nodes
CASE15: Check that Leadership Election is still functional
+CASE16: Install Distributed Primitives app
+CASE17: Check for basic functionality with distributed primitives
"""
@@ -31,21 +33,28 @@
CASE1 is to compile ONOS and push it to the test machines
Startup sequence:
- git pull
- mvn clean install
- onos-package
cell <name>
onos-verify-cell
NOTE: temporary - onos-remove-raft-logs
+ onos-uninstall
+ start mininet
+ git pull
+ mvn clean install
+ onos-package
onos-install -f
onos-wait-for-start
+ start cli sessions
+ start tcpdump
"""
main.log.report( "ONOS HA test: Restart all ONOS nodes - " +
"initialization" )
main.case( "Setting up test environment" )
+ main.caseExplaination = "Setup the test environment including " +\
+ "installing ONOS, starting Mininet and ONOS" +\
+ "cli sessions."
# TODO: save all the timers and output them for plotting
- # load some vairables from the params file
+ # load some variables from the params file
PULLCODE = False
if main.params[ 'Git' ] == 'True':
PULLCODE = True
@@ -53,38 +62,34 @@
cellName = main.params[ 'ENV' ][ 'cellName' ]
# set global variables
- global ONOS1Ip
global ONOS1Port
- global ONOS2Ip
global ONOS2Port
- global ONOS3Ip
global ONOS3Port
- global ONOS4Ip
global ONOS4Port
- global ONOS5Ip
global ONOS5Port
- global ONOS6Ip
global ONOS6Port
- global ONOS7Ip
global ONOS7Port
global numControllers
-
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
- ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
- ONOS4Port = main.params[ 'CTRL' ][ 'port4' ]
- ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
- ONOS5Port = main.params[ 'CTRL' ][ 'port5' ]
- ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
- ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
- ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
- ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
numControllers = int( main.params[ 'num_controllers' ] )
+ # FIXME: just get controller port from params?
+ # TODO: do we really need all these?
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+ ONOS4Port = main.params[ 'CTRL' ][ 'port4' ]
+ ONOS5Port = main.params[ 'CTRL' ][ 'port5' ]
+ ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
+ ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
+
+ global CLIs
+ CLIs = []
+ global nodes
+ nodes = []
+ for i in range( 1, numControllers + 1 ):
+ CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+ nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+
main.step( "Applying cell variable to environment" )
cellResult = main.ONOSbench.setCell( cellName )
verifyResult = main.ONOSbench.verifyCell()
@@ -92,93 +97,112 @@
# FIXME:this is short term fix
main.log.report( "Removing raft logs" )
main.ONOSbench.onosRemoveRaftLogs()
+
main.log.report( "Uninstalling ONOS" )
- main.ONOSbench.onosUninstall( ONOS1Ip )
- main.ONOSbench.onosUninstall( ONOS2Ip )
- main.ONOSbench.onosUninstall( ONOS3Ip )
- main.ONOSbench.onosUninstall( ONOS4Ip )
- main.ONOSbench.onosUninstall( ONOS5Ip )
- main.ONOSbench.onosUninstall( ONOS6Ip )
- main.ONOSbench.onosUninstall( ONOS7Ip )
+ for node in nodes:
+ main.ONOSbench.onosUninstall( node.ip_address )
+
+ # Make sure ONOS is DEAD
+ main.log.report( "Killing any ONOS processes" )
+ killResults = main.TRUE
+ for node in nodes:
+ killed = main.ONOSbench.onosKill( node.ip_address )
+ killResults = killResults and killed
cleanInstallResult = main.TRUE
gitPullResult = main.TRUE
- main.step( "Compiling the latest version of ONOS" )
+ main.step( "Starting Mininet" )
+ mnResult = main.Mininet1.startNet( )
+ utilities.assert_equals( expect=main.TRUE, actual=mnResult,
+ onpass="Mininet Started",
+ onfail="Error starting Mininet" )
+
+ main.step( "Git checkout and pull " + gitBranch )
if PULLCODE:
- # TODO Configure branch in params
- main.step( "Git checkout and pull master" )
main.ONOSbench.gitCheckout( gitBranch )
gitPullResult = main.ONOSbench.gitPull()
-
- main.step( "Using mvn clean & install" )
- cleanInstallResult = main.ONOSbench.cleanInstall()
+ # values of 1 or 3 are good
+ utilities.assert_lesser( expect=0, actual=gitPullResult,
+ onpass="Git pull successful",
+ onfail="Git pull failed" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
- main.ONOSbench.getVersion( report=True )
+ main.ONOSbench.getVersion( report=True )
+
+ main.step( "Using mvn clean install" )
+ cleanInstallResult = main.TRUE
+ if gitPullResult == main.TRUE:
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cleanInstallResult,
+ onpass="MCI successful",
+ onfail="MCI failed" )
+ # GRAPHS
+ # NOTE: important params here:
+ # job = name of Jenkins job
+ # Plot Name = Plot-HA, only can be used if multiple plots
+ # index = The number of the graph under plot name
+ job = "HAClusterRestart"
+ graphs = '<ac:structured-macro ac:name="html">\n'
+ graphs += '<ac:plain-text-body><![CDATA[\n'
+ graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
+ '/plot/getPlot?index=0&width=500&height=300"' +\
+ 'noborder="0" width="500" height="300" scrolling="yes" ' +\
+ 'seamless="seamless"></iframe>\n'
+ graphs += ']]></ac:plain-text-body>\n'
+ graphs += '</ac:structured-macro>\n'
+ main.log.wiki(graphs)
main.step( "Creating ONOS package" )
packageResult = main.ONOSbench.onosPackage()
+ utilities.assert_equals( expect=main.TRUE, actual=packageResult,
+ onpass="ONOS package successful",
+ onfail="ONOS package failed" )
main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS1Ip )
- onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS2Ip )
- onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS3Ip )
- onos4InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS4Ip )
- onos5InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS5Ip )
- onos6InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS6Ip )
- onos7InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS7Ip )
- onosInstallResult = onos1InstallResult and onos2InstallResult\
- and onos3InstallResult and onos4InstallResult\
- and onos5InstallResult and onos6InstallResult\
- and onos7InstallResult
+ onosInstallResult = main.TRUE
+ for node in nodes:
+ tmpResult = main.ONOSbench.onosInstall( options="-f",
+ node=node.ip_address )
+ onosInstallResult = onosInstallResult and tmpResult
+ utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
+ onpass="ONOS install successful",
+ onfail="ONOS install failed" )
main.step( "Checking if ONOS is up yet" )
- # TODO check bundle:list?
for i in range( 2 ):
- onos1Isup = main.ONOSbench.isup( ONOS1Ip )
- if not onos1Isup:
- main.log.report( "ONOS1 didn't start!" )
- onos2Isup = main.ONOSbench.isup( ONOS2Ip )
- if not onos2Isup:
- main.log.report( "ONOS2 didn't start!" )
- onos3Isup = main.ONOSbench.isup( ONOS3Ip )
- if not onos3Isup:
- main.log.report( "ONOS3 didn't start!" )
- onos4Isup = main.ONOSbench.isup( ONOS4Ip )
- if not onos4Isup:
- main.log.report( "ONOS4 didn't start!" )
- onos5Isup = main.ONOSbench.isup( ONOS5Ip )
- if not onos5Isup:
- main.log.report( "ONOS5 didn't start!" )
- onos6Isup = main.ONOSbench.isup( ONOS6Ip )
- if not onos6Isup:
- main.log.report( "ONOS6 didn't start!" )
- onos7Isup = main.ONOSbench.isup( ONOS7Ip )
- if not onos7Isup:
- main.log.report( "ONOS7 didn't start!" )
- onosIsupResult = onos1Isup and onos2Isup and onos3Isup\
- and onos4Isup and onos5Isup and onos6Isup and onos7Isup
+ onosIsupResult = main.TRUE
+ for node in nodes:
+ started = main.ONOSbench.isup( node.ip_address )
+ if not started:
+ main.log.report( node.name + " didn't start!" )
+ main.ONOSbench.onosStop( node.ip_address )
+ main.ONOSbench.onosStart( node.ip_address )
+ onosIsupResult = onosIsupResult and started
if onosIsupResult == main.TRUE:
break
+ utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult,
+ onpass="ONOS startup successful",
+ onfail="ONOS startup failed" )
- cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip )
- cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip )
- cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip )
- cliResult4 = main.ONOScli4.startOnosCli( ONOS4Ip )
- cliResult5 = main.ONOScli5.startOnosCli( ONOS5Ip )
- cliResult6 = main.ONOScli6.startOnosCli( ONOS6Ip )
- cliResult7 = main.ONOScli7.startOnosCli( ONOS7Ip )
- cliResults = cliResult1 and cliResult2 and cliResult3 and\
- cliResult4 and cliResult5 and cliResult6 and cliResult7
+ main.log.step( "Starting ONOS CLI sessions" )
+ cliResults = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].startOnosCli,
+ name="startOnosCli-" + str( i ),
+ args=[nodes[i].ip_address] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ cliResults = cliResults and t.result
+ utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+ onpass="ONOS cli startup successful",
+ onfail="ONOS cli startup failed" )
main.step( "Start Packet Capture MN" )
main.Mininet2.startTcpdump(
@@ -187,15 +211,28 @@
intf=main.params[ 'MNtcpdump' ][ 'intf' ],
port=main.params[ 'MNtcpdump' ][ 'port' ] )
- case1Result = ( cleanInstallResult and packageResult and
- cellResult and verifyResult and onosInstallResult
- and onosIsupResult and cliResults )
+ main.step( "App Ids check" )
+ appCheck = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
- utilities.assert_equals( expect=main.TRUE, actual=case1Result,
- onpass="Test startup successful",
- onfail="Test startup NOT successful" )
+ for t in threads:
+ t.join()
+ appCheck = appCheck and t.result
+ if appCheck != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
- if case1Result == main.FALSE:
+ if cliResults == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -204,40 +241,57 @@
Assign mastership to controllers
"""
import re
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
- main.log.report( "Assigning switches to controllers" )
main.case( "Assigning Controllers" )
+ main.caseExplaination = "Assign switches to ONOS using 'ovs-vsctl' " +\
+ "and check that an ONOS node becomes the " +\
+ "master of the device. Then manually assign" +\
+ " mastership to specific ONOS nodes using" +\
+ " 'device-role'"
main.step( "Assign switches to controllers" )
+ # TODO: rewrite this function to take lists of ips and ports?
+ # or list of tuples?
for i in range( 1, 29 ):
main.Mininet1.assignSwController(
sw=str( i ),
count=numControllers,
- ip1=ONOS1Ip, port1=ONOS1Port,
- ip2=ONOS2Ip, port2=ONOS2Port,
- ip3=ONOS3Ip, port3=ONOS3Port,
- ip4=ONOS4Ip, port4=ONOS4Port,
- ip5=ONOS5Ip, port5=ONOS5Port,
- ip6=ONOS6Ip, port6=ONOS6Port,
- ip7=ONOS7Ip, port7=ONOS7Port )
+ ip1=nodes[ 0 ].ip_address, port1=ONOS1Port,
+ ip2=nodes[ 1 ].ip_address, port2=ONOS2Port,
+ ip3=nodes[ 2 ].ip_address, port3=ONOS3Port,
+ ip4=nodes[ 3 ].ip_address, port4=ONOS4Port,
+ ip5=nodes[ 4 ].ip_address, port5=ONOS5Port,
+ ip6=nodes[ 5 ].ip_address, port6=ONOS6Port,
+ ip7=nodes[ 6 ].ip_address, port7=ONOS7Port )
mastershipCheck = main.TRUE
for i in range( 1, 29 ):
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
- if re.search( "tcp:" + ONOS1Ip, response )\
- and re.search( "tcp:" + ONOS2Ip, response )\
- and re.search( "tcp:" + ONOS3Ip, response )\
- and re.search( "tcp:" + ONOS4Ip, response )\
- and re.search( "tcp:" + ONOS5Ip, response )\
- and re.search( "tcp:" + ONOS6Ip, response )\
- and re.search( "tcp:" + ONOS7Ip, response ):
- mastershipCheck = mastershipCheck and main.TRUE
- else:
- mastershipCheck = main.FALSE
+ for node in nodes:
+ if re.search( "tcp:" + node.ip_address, response ):
+ mastershipCheck = mastershipCheck and main.TRUE
+ else:
+ main.log.error( "Error, node " + node.ip_address + " is " +
+ "not in the list of controllers s" +
+ str( i ) + " is connecting to." )
+ mastershipCheck = main.FALSE
if mastershipCheck == main.TRUE:
main.log.report( "Switch mastership assigned correctly" )
utilities.assert_equals(
@@ -246,127 +300,84 @@
onpass="Switch mastership assigned correctly",
onfail="Switches not assigned correctly to controllers" )
+ main.step( "Assign mastership of switches to specific controllers" )
# Manually assign mastership to the controller we want
roleCall = main.TRUE
- roleCheck = main.TRUE
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS1Ip )
- # Check assignment
- if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS1Ip )
- # Check assignment
- if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS2Ip )
- # Check assignment
- if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS2Ip )
- # Check assignment
- if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS3Ip )
- # Check assignment
- if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS3Ip )
- # Check assignment
- if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS4Ip )
- # Check assignment
- if ONOS4Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- for i in range( 8, 18 ):
- dpid = '3' + str( i ).zfill( 3 )
- deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS5Ip )
- # Check assignment
- if ONOS5Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS6Ip )
- # Check assignment
- if ONOS6Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- for i in range( 18, 28 ):
- dpid = '6' + str( i ).zfill( 3 )
- deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS7Ip )
- # Check assignment
- if ONOS7Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
+ ipList = [ ]
+ deviceList = []
+ try:
+ for i in range( 1, 29 ): # switches 1 through 28
+ # set up correct variables:
+ if i == 1:
+ ip = nodes[ 0 ].ip_address # ONOS1
+ deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
+ elif i == 2:
+ ip = nodes[ 1 ].ip_address # ONOS2
+ deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' )
+ elif i == 3:
+ ip = nodes[ 1 ].ip_address # ONOS2
+ deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' )
+ elif i == 4:
+ ip = nodes[ 3 ].ip_address # ONOS4
+ deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' )
+ elif i == 5:
+ ip = nodes[ 2 ].ip_address # ONOS3
+ deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' )
+ elif i == 6:
+ ip = nodes[ 2 ].ip_address # ONOS3
+ deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' )
+ elif i == 7:
+ ip = nodes[ 5 ].ip_address # ONOS6
+ deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' )
+ elif i >= 8 and i <= 17:
+ ip = nodes[ 4 ].ip_address # ONOS5
+ dpid = '3' + str( i ).zfill( 3 )
+ deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
+ elif i >= 18 and i <= 27:
+ ip = nodes[ 6 ].ip_address # ONOS7
+ dpid = '6' + str( i ).zfill( 3 )
+ deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
+ elif i == 28:
+ ip = nodes[ 0 ].ip_address # ONOS1
+ deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' )
+ else:
+ main.log.error( "You didn't write an else statement for " +
+ "switch s" + str( i ) )
+ # Assign switch
+ assert deviceId, "No device id for s" + str( i ) + " in ONOS"
+ # TODO: make this controller dynamic
+ roleCall = roleCall and main.ONOScli1.deviceRole( deviceId,
+ ip )
+ ipList.append( ip )
+ deviceList.append( deviceId )
+ except ( AttributeError, AssertionError ):
+ main.log.exception( "Something is wrong with ONOS device view" )
+ main.log.info( main.ONOScli1.devices() )
utilities.assert_equals(
expect=main.TRUE,
actual=roleCall,
onpass="Re-assigned switch mastership to designated controller",
onfail="Something wrong with deviceRole calls" )
+ main.step( "Check mastership was correctly assigned" )
+ roleCheck = main.TRUE
+ # NOTE: This is due to the fact that device mastership change is not
+ # atomic and is actually a multi step process
+ time.sleep( 5 )
+ for i in range( len( ipList ) ):
+ ip = ipList[i]
+ deviceId = deviceList[i]
+ # Check assignment
+ master = main.ONOScli1.getRole( deviceId ).get( 'master' )
+ if ip in master:
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+ main.log.error( "Error, controller " + ip + " is not" +
+ " master " + "of device " +
+ str( deviceId ) + ". Master is " +
+ repr( master ) + "." )
utilities.assert_equals(
expect=main.TRUE,
actual=roleCheck,
@@ -375,60 +386,108 @@
onfail="Switches were not successfully reassigned" )
mastershipCheck = mastershipCheck and roleCall and roleCheck
utilities.assert_equals( expect=main.TRUE, actual=mastershipCheck,
- onpass="Switch mastership correctly assigned",
- onfail="Error in ( re )assigning switch" +
- " mastership" )
+ onpass="Switch mastership correctly assigned",
+ onfail="Error in (re)assigning switch" +
+ " mastership" )
def CASE3( self, main ):
"""
Assign intents
"""
- # FIXME: we must reinstall intents until we have a persistant
- # datastore!
import time
- main.log.report( "Adding host intents" )
+ import json
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ # NOTE: we must reinstall intents until we have a persistant intent
+ # datastore!
main.case( "Adding host Intents" )
-
- main.step( "Discovering Hosts( Via pingall for now )" )
- # FIXME: Once we have a host discovery mechanism, use that instead
+ main.caseExplaination = "Discover hosts by using pingall then " +\
+ "assign predetermined host-to-host intents." +\
+ " After installation, check that the intent" +\
+ " is distributed to all nodes and the state" +\
+ " is INSTALLED"
# install onos-app-fwd
- main.log.info( "Install reactive forwarding app" )
- main.ONOScli1.featureInstall( "onos-app-fwd" )
- main.ONOScli2.featureInstall( "onos-app-fwd" )
- main.ONOScli3.featureInstall( "onos-app-fwd" )
- main.ONOScli4.featureInstall( "onos-app-fwd" )
- main.ONOScli5.featureInstall( "onos-app-fwd" )
- main.ONOScli6.featureInstall( "onos-app-fwd" )
- main.ONOScli7.featureInstall( "onos-app-fwd" )
+ main.step( "Install reactive forwarding app" )
+ installResults = CLIs[0].activateApp( "org.onosproject.fwd" )
+ utilities.assert_equals( expect=main.TRUE, actual=installResults,
+ onpass="Install fwd successful",
+ onfail="Install fwd failed" )
+ main.step( "Check app ids" )
+ appCheck = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ appCheck = appCheck and t.result
+ if appCheck != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+
+ main.step( "Discovering Hosts( Via pingall for now )" )
+ # FIXME: Once we have a host discovery mechanism, use that instead
# REACTIVE FWD test
pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall()
- utilities.assert_equals(
- expect=main.TRUE,
- actual=pingResult,
- onpass="Reactive Pingall test passed",
- onfail="Reactive Pingall failed, one or more ping pairs failed" )
- time2 = time.time()
- main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) )
-
- # uninstall onos-app-fwd
- main.log.info( "Uninstall reactive forwarding app" )
- main.ONOScli1.featureUninstall( "onos-app-fwd" )
- main.ONOScli2.featureUninstall( "onos-app-fwd" )
- main.ONOScli3.featureUninstall( "onos-app-fwd" )
- main.ONOScli4.featureUninstall( "onos-app-fwd" )
- main.ONOScli5.featureUninstall( "onos-app-fwd" )
- main.ONOScli6.featureUninstall( "onos-app-fwd" )
- main.ONOScli7.featureUninstall( "onos-app-fwd" )
+ for i in range(2): # Retry if pingall fails first time
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=pingResult,
+ onpass="Reactive Pingall test passed",
+ onfail="Reactive Pingall failed, " +
+ "one or more ping pairs failed" )
+ time2 = time.time()
+ main.log.info( "Time for pingall: %2f seconds" %
+ ( time2 - time1 ) )
# timeout for fwd flows
- time.sleep( 10 )
+ time.sleep( 11 )
+ # uninstall onos-app-fwd
+ main.step( "Uninstall reactive forwarding app" )
+ uninstallResult = CLIs[0].deactivateApp( "org.onosproject.fwd" )
+ utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
+ onpass="Uninstall fwd successful",
+ onfail="Uninstall fwd failed" )
- main.step( "Add host intents" )
+ main.step( "Check app ids" )
+ threads = []
+ appCheck2 = main.TRUE
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ appCheck2 = appCheck2 and t.result
+ if appCheck2 != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck2,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+
+ main.step( "Add host intents via cli" )
+ intentIds = []
# TODO: move the host numbers to params
+ # Maybe look at all the paths we ping?
intentAddResult = True
+ hostResult = main.TRUE
for i in range( 8, 18 ):
main.log.info( "Adding host intent between h" + str( i ) +
" and h" + str( i + 10 ) )
@@ -436,53 +495,300 @@
str( hex( i )[ 2: ] ).zfill( 2 ).upper()
host2 = "00:00:00:00:00:" + \
str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
- host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
- # NOTE: get host can return None
+ # NOTE: getHost can return None
+ host1Dict = main.ONOScli1.getHost( host1 )
+ host2Dict = main.ONOScli1.getHost( host2 )
+ host1Id = None
+ host2Id = None
+ if host1Dict and host2Dict:
+ host1Id = host1Dict.get( 'id', None )
+ host2Id = host2Dict.get( 'id', None )
if host1Id and host2Id:
- tmpResult = main.ONOScli1.addHostIntent(
- host1Id,
- host2Id )
+ nodeNum = ( i % 7 )
+ tmpId = CLIs[ nodeNum ].addHostIntent( host1Id, host2Id )
+ if tmpId:
+ main.log.info( "Added intent with id: " + tmpId )
+ intentIds.append( tmpId )
+ else:
+ main.log.error( "addHostIntent returned: " +
+ repr( tmpId ) )
else:
- main.log.error( "Error, getHost() failed" )
- tmpResult = main.FALSE
- intentAddResult = bool( pingResult and intentAddResult
- and tmpResult )
- # TODO Check that intents were added?
- utilities.assert_equals(
- expect=True,
- actual=intentAddResult,
- onpass="Pushed host intents to ONOS",
- onfail="Error in pushing host intents to ONOS" )
- # TODO Check if intents all exist in datastore
+ main.log.error( "Error, getHost() failed for h" + str( i ) +
+ " and/or h" + str( i + 10 ) )
+ hosts = CLIs[ 0 ].hosts()
+ main.log.warn( "Hosts output: " )
+ try:
+ main.log.warn( json.dumps( json.loads( hosts ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( hosts ) )
+ hostResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE, actual=hostResult,
+ onpass="Found a host id for each host",
+ onfail="Error looking up host ids" )
+
+ intentStart = time.time()
+ onosIds = main.ONOScli1.getAllIntentsId()
+ main.log.info( "Submitted intents: " + str( intentIds ) )
+ main.log.info( "Intents in ONOS: " + str( onosIds ) )
+ for intent in intentIds:
+ if intent in onosIds:
+ pass # intent submitted is in onos
+ else:
+ intentAddResult = False
+ # FIXME: DEBUG
+ if intentAddResult:
+ intentStop = time.time()
+ else:
+ intentStop = None
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ installedCheck = True
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents" )
+ # add submitted intents not in the store
+ tmplist = [ i for i, s in intentStates ]
+ missingIntents = False
+ for i in intentIds:
+ if i not in tmplist:
+ intentStates.append( ( i, " - " ) )
+ missingIntents = True
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+
+ intentAddResult = bool( intentAddResult and not missingIntents and
+ installedCheck )
+ if not intentAddResult:
+ main.log.error( "Error in pushing host intents to ONOS" )
+
+ main.step( "Intent Anti-Entropy dispersion" )
+ for i in range(100):
+ correct = True
+ main.log.info( "Submitted intents: " + str( sorted( intentIds ) ) )
+ for cli in CLIs:
+ onosIds = []
+ ids = cli.getAllIntentsId()
+ onosIds.append( ids )
+ main.log.debug( "Intents in " + cli.name + ": " +
+ str( sorted( onosIds ) ) )
+ if sorted( ids ) != sorted( intentIds ):
+ correct = False
+ if correct:
+ break
+ else:
+ time.sleep(1)
+ if not intentStop:
+ intentStop = time.time()
+ global gossipTime
+ gossipTime = intentStop - intentStart
+ main.log.info( "It took about " + str( gossipTime ) +
+ " seconds for all intents to appear in each node" )
+ # FIXME: make this time configurable/calculate based off of number of
+ # nodes and gossip rounds
+ utilities.assert_greater_equals(
+ expect=40, actual=gossipTime,
+ onpass="ECM anti-entropy for intents worked within " +
+ "expected time",
+ onfail="Intent ECM anti-entropy took too long" )
+ if gossipTime <= 40:
+ intentAddResult = True
+
+ if not intentAddResult or "key" in pendingMap:
+ import time
+ installedCheck = True
+ main.log.info( "Sleeping 60 seconds to see if intents are found" )
+ time.sleep( 60 )
+ onosIds = main.ONOScli1.getAllIntentsId()
+ main.log.info( "Submitted intents: " + str( intentIds ) )
+ main.log.info( "Intents in ONOS: " + str( onosIds ) )
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ try:
+ for intent in json.loads( intents ):
+ # Iter through intents of a node
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents" )
+ # add submitted intents not in the store
+ tmplist = [ i for i, s in intentStates ]
+ for i in intentIds:
+ if i not in tmplist:
+ intentStates.append( ( i, " - " ) )
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ topics.append( "org.onosproject.election" )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
def CASE4( self, main ):
"""
Ping across added host intents
"""
- description = " Ping across added host intents"
- main.log.report( description )
- main.case( description )
+ import json
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ main.case( "Verify connectivity by sendind traffic across Intents" )
+ main.caseExplaination = "Ping across added host intents to check " +\
+ "functionality and check the state of " +\
+ "the intent"
+ main.step( "Ping across added host intents" )
PingResult = main.TRUE
for i in range( 8, 18 ):
- ping = main.Mininet1.pingHost(
- src="h" + str( i ), target="h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
PingResult = PingResult and ping
if ping == main.FALSE:
main.log.warn( "Ping failed between h" + str( i ) +
" and h" + str( i + 10 ) )
elif ping == main.TRUE:
main.log.info( "Ping test passed!" )
- PingResult = main.TRUE
+ # Don't set PingResult or you'd override failures
if PingResult == main.FALSE:
main.log.report(
"Intents have not been installed correctly, pings failed." )
- #TODO: pretty print
- main.log.warn( "ONSO1 intents: " )
- main.log.warn( json.dumps( json.loads( main.ONOScli1.intents() ),
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
if PingResult == main.TRUE:
main.log.report(
"Intents have been installed correctly and verified by pings" )
@@ -492,342 +798,495 @@
onpass="Intents have been installed correctly and pings work",
onfail="Intents have not been installed correctly, pings failed." )
+ main.step( "Check Intent state" )
+ installedCheck = True
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents." )
+ # Print states
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ utilities.assert_equals( expect=True, actual=installedCheck,
+ onpass="Intents are all INSTALLED",
+ onfail="Intents are not all in " +\
+ "INSTALLED state" )
+
+ main.step( "Check leadership of topics" )
+ leaders = main.ONOScli1.leaders()
+ topicCheck = main.TRUE
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ # TODO: Look at Devices as topics now that it uses this system
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ # FIXME: topics.append( "org.onosproject.election" )
+ # Print leaders output
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ topicCheck = main.FALSE
+ else:
+ main.log.error( "leaders() returned None" )
+ topicCheck = main.FALSE
+ except ( ValueError, TypeError ):
+ topicCheck = main.FALSE
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ # TODO: Check for a leader of these topics
+ utilities.assert_equals( expect=main.TRUE, actual=topicCheck,
+ onpass="intent Partitions is in leaders",
+ onfail="Some topics were lost " )
+ # Print partitions
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ # Print Pending Map
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+
+ if not installedCheck:
+ main.log.info( "Waiting 60 seconds to see if the state of " +
+ "intents change" )
+ time.sleep( 60 )
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents." )
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ topics.append( "org.onosproject.election" )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+ main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+
+ main.step( "Wait a minute then ping again" )
+ PingResult = main.TRUE
+ for i in range( 8, 18 ):
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
+ PingResult = PingResult and ping
+ if ping == main.FALSE:
+ main.log.warn( "Ping failed between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ elif ping == main.TRUE:
+ main.log.info( "Ping test passed!" )
+ # Don't set PingResult or you'd override failures
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Intents have not been installed correctly, pings failed." )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=PingResult,
+ onpass="Intents have been installed correctly and pings work",
+ onfail="Intents have not been installed correctly, pings failed." )
+
def CASE5( self, main ):
"""
Reading state of ONOS
"""
import json
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
- main.log.report( "Setting up and gathering data for current state" )
main.case( "Setting up and gathering data for current state" )
# The general idea for this test case is to pull the state of
# ( intents,flows, topology,... ) from each ONOS node
- # We can then compare them with eachother and also with past states
+ # We can then compare them with each other and also with past states
- main.step( "Get the Mastership of each switch from each controller" )
+ main.step( "Check that each switch has a master" )
global mastershipState
- mastershipState = []
+ mastershipState = '[]'
# Assert that each device has a master
- ONOS1MasterNotNull = main.ONOScli1.rolesNotNull()
- ONOS2MasterNotNull = main.ONOScli2.rolesNotNull()
- ONOS3MasterNotNull = main.ONOScli3.rolesNotNull()
- ONOS4MasterNotNull = main.ONOScli4.rolesNotNull()
- ONOS5MasterNotNull = main.ONOScli5.rolesNotNull()
- ONOS6MasterNotNull = main.ONOScli6.rolesNotNull()
- ONOS7MasterNotNull = main.ONOScli7.rolesNotNull()
- rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\
- ONOS3MasterNotNull and ONOS4MasterNotNull and\
- ONOS5MasterNotNull and ONOS6MasterNotNull and\
- ONOS7MasterNotNull
+ rolesNotNull = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].rolesNotNull,
+ name="rolesNotNull-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ rolesNotNull = rolesNotNull and t.result
utilities.assert_equals(
expect=main.TRUE,
actual=rolesNotNull,
onpass="Each device has a master",
onfail="Some devices don't have a master assigned" )
- ONOS1Mastership = main.ONOScli1.roles()
- ONOS2Mastership = main.ONOScli2.roles()
- ONOS3Mastership = main.ONOScli3.roles()
- ONOS4Mastership = main.ONOScli4.roles()
- ONOS5Mastership = main.ONOScli5.roles()
- ONOS6Mastership = main.ONOScli6.roles()
- ONOS7Mastership = main.ONOScli7.roles()
- if "Error" in ONOS1Mastership or not ONOS1Mastership\
- or "Error" in ONOS2Mastership or not ONOS2Mastership\
- or "Error" in ONOS3Mastership or not ONOS3Mastership\
- or "Error" in ONOS4Mastership or not ONOS4Mastership\
- or "Error" in ONOS5Mastership or not ONOS5Mastership\
- or "Error" in ONOS6Mastership or not ONOS6Mastership\
- or "Error" in ONOS7Mastership or not ONOS7Mastership:
- main.log.report( "Error in getting ONOS roles" )
- main.log.warn(
- "ONOS1 mastership response: " +
- repr( ONOS1Mastership ) )
- main.log.warn(
- "ONOS2 mastership response: " +
- repr( ONOS2Mastership ) )
- main.log.warn(
- "ONOS3 mastership response: " +
- repr( ONOS3Mastership ) )
- main.log.warn(
- "ONOS4 mastership response: " +
- repr( ONOS4Mastership ) )
- main.log.warn(
- "ONOS5 mastership response: " +
- repr( ONOS5Mastership ) )
- main.log.warn(
- "ONOS6 mastership response: " +
- repr( ONOS6Mastership ) )
- main.log.warn(
- "ONOS7 mastership response: " +
- repr( ONOS7Mastership ) )
- consistentMastership = main.FALSE
- elif ONOS1Mastership == ONOS2Mastership\
- and ONOS1Mastership == ONOS3Mastership\
- and ONOS1Mastership == ONOS4Mastership\
- and ONOS1Mastership == ONOS5Mastership\
- and ONOS1Mastership == ONOS6Mastership\
- and ONOS1Mastership == ONOS7Mastership:
- mastershipState = ONOS1Mastership
- consistentMastership = main.TRUE
+ main.step( "Get the Mastership of each switch from each controller" )
+ ONOSMastership = []
+ mastershipCheck = main.FALSE
+ consistentMastership = True
+ rolesResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].roles,
+ name="roles-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSMastership.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " roles" )
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " mastership response: " +
+ repr( ONOSMastership[i] ) )
+ rolesResults = False
+ utilities.assert_equals(
+ expect=True,
+ actual=rolesResults,
+ onpass="No error in reading roles output",
+ onfail="Error in reading roles from ONOS" )
+
+ main.step( "Check for consistency in roles from each controller" )
+ if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
main.log.report(
"Switch roles are consistent across all ONOS nodes" )
else:
- main.log.warn(
- "ONOS1 roles: ",
- json.dumps(
- json.loads( ONOS1Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS2 roles: ",
- json.dumps(
- json.loads( ONOS2Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS3 roles: ",
- json.dumps(
- json.loads( ONOS3Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS4 roles: ",
- json.dumps(
- json.loads( ONOS4Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS5 roles: ",
- json.dumps(
- json.loads( ONOS5Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS6 roles: ",
- json.dumps(
- json.loads( ONOS6Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS7 roles: ",
- json.dumps(
- json.loads( ONOS7Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- consistentMastership = main.FALSE
+ consistentMastership = False
utilities.assert_equals(
- expect=main.TRUE,
+ expect=True,
actual=consistentMastership,
onpass="Switch roles are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of switch roles" )
+ if rolesResults and not consistentMastership:
+ for i in range( numControllers ):
+ try:
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " roles: ",
+ json.dumps(
+ json.loads( ONOSMastership[ i ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( ONOSMastership[ i ] ) )
+ elif rolesResults and consistentMastership:
+ mastershipCheck = main.TRUE
+ mastershipState = ONOSMastership[ 0 ]
+
main.step( "Get the intents from each controller" )
global intentState
intentState = []
- ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
- ONOS2Intents = main.ONOScli2.intents( jsonFormat=True )
- ONOS3Intents = main.ONOScli3.intents( jsonFormat=True )
- ONOS4Intents = main.ONOScli4.intents( jsonFormat=True )
- ONOS5Intents = main.ONOScli5.intents( jsonFormat=True )
- ONOS6Intents = main.ONOScli6.intents( jsonFormat=True )
- ONOS7Intents = main.ONOScli7.intents( jsonFormat=True )
+ ONOSIntents = []
intentCheck = main.FALSE
- if "Error" in ONOS1Intents or not ONOS1Intents\
- or "Error" in ONOS2Intents or not ONOS2Intents\
- or "Error" in ONOS3Intents or not ONOS3Intents\
- or "Error" in ONOS4Intents or not ONOS4Intents\
- or "Error" in ONOS5Intents or not ONOS5Intents\
- or "Error" in ONOS6Intents or not ONOS6Intents\
- or "Error" in ONOS7Intents or not ONOS7Intents:
- main.log.report( "Error in getting ONOS intents" )
- main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
- main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) )
- main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) )
- main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) )
- main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) )
- main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) )
- main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) )
- elif ONOS1Intents == ONOS2Intents\
- and ONOS1Intents == ONOS3Intents\
- and ONOS1Intents == ONOS4Intents\
- and ONOS1Intents == ONOS5Intents\
- and ONOS1Intents == ONOS6Intents\
- and ONOS1Intents == ONOS7Intents:
- intentState = ONOS1Intents
- intentCheck = main.TRUE
- main.log.report( "Intents are consistent across all ONOS nodes" )
- else:
- main.log.warn(
- "ONOS1 intents: ",
- json.dumps(
- json.loads( ONOS1Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS2 intents: ",
- json.dumps(
- json.loads( ONOS2Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS3 intents: ",
- json.dumps(
- json.loads( ONOS3Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS4 intents: ",
- json.dumps(
- json.loads( ONOS4Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS5 intents: ",
- json.dumps(
- json.loads( ONOS5Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS6 intents: ",
- json.dumps(
- json.loads( ONOS6Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS7 intents: ",
- json.dumps(
- json.loads( ONOS7Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
+ consistentIntents = True
+ intentsResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].intents,
+ name="intents-" + str( i ),
+ args=[],
+ kwargs={ 'jsonFormat': True } )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSIntents.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " intents" )
+ main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
+ repr( ONOSIntents[ i ] ) )
+ intentsResults = False
utilities.assert_equals(
- expect=main.TRUE,
- actual=intentCheck,
+ expect=True,
+ actual=intentsResults,
+ onpass="No error in reading intents output",
+ onfail="Error in reading intents from ONOS" )
+
+ main.step( "Check for consistency in Intents from each controller" )
+ if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
+ main.log.report( "Intents are consistent across all ONOS " +
+ "nodes" )
+ else:
+ consistentIntents = False
+ main.log.report( "Intents not consistent" )
+ utilities.assert_equals(
+ expect=True,
+ actual=consistentIntents,
onpass="Intents are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of intents" )
+ if intentsResults:
+ # Try to make it easy to figure out what is happening
+ #
+ # Intent ONOS1 ONOS2 ...
+ # 0x01 INSTALLED INSTALLING
+ # ... ... ...
+ # ... ... ...
+ title = " Id"
+ for n in range( numControllers ):
+ title += " " * 10 + "ONOS" + str( n + 1 )
+ main.log.warn( title )
+ # get all intent keys in the cluster
+ keys = []
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ keys.append( intent.get( 'id' ) )
+ keys = set( keys )
+ for key in keys:
+ row = "%-13s" % key
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ if intent.get( 'id', "Error" ) == key:
+ row += "%-15s" % intent.get( 'state' )
+ main.log.warn( row )
+ # End table view
+
+ if intentsResults and not consistentIntents:
+ # print the json objects
+ n = len(ONOSIntents)
+ main.log.debug( "ONOS" + str( n ) + " intents: " )
+ main.log.debug( json.dumps( json.loads( ONOSIntents[ -1 ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ for i in range( numControllers ):
+ if ONOSIntents[ i ] != ONOSIntents[ -1 ]:
+ main.log.debug( "ONOS" + str( i + 1 ) + " intents: " )
+ main.log.debug( json.dumps( json.loads( ONOSIntents[i] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ else:
+ main.log.debug( nodes[ i ].name + " intents match ONOS" +
+ str( n ) + " intents" )
+ elif intentsResults and consistentIntents:
+ intentCheck = main.TRUE
+ intentState = ONOSIntents[ 0 ]
+
main.step( "Get the flows from each controller" )
global flowState
flowState = []
- ONOS1Flows = main.ONOScli1.flows( jsonFormat=True )
- ONOS2Flows = main.ONOScli2.flows( jsonFormat=True )
- ONOS3Flows = main.ONOScli3.flows( jsonFormat=True )
- ONOS4Flows = main.ONOScli4.flows( jsonFormat=True )
- ONOS5Flows = main.ONOScli5.flows( jsonFormat=True )
- ONOS6Flows = main.ONOScli6.flows( jsonFormat=True )
- ONOS7Flows = main.ONOScli7.flows( jsonFormat=True )
- ONOS1FlowsJson = json.loads( ONOS1Flows )
- ONOS2FlowsJson = json.loads( ONOS2Flows )
- ONOS3FlowsJson = json.loads( ONOS3Flows )
- ONOS4FlowsJson = json.loads( ONOS4Flows )
- ONOS5FlowsJson = json.loads( ONOS5Flows )
- ONOS6FlowsJson = json.loads( ONOS6Flows )
- ONOS7FlowsJson = json.loads( ONOS7Flows )
+ ONOSFlows = []
+ ONOSFlowsJson = []
flowCheck = main.FALSE
- if "Error" in ONOS1Flows or not ONOS1Flows\
- or "Error" in ONOS2Flows or not ONOS2Flows\
- or "Error" in ONOS3Flows or not ONOS3Flows\
- or "Error" in ONOS4Flows or not ONOS4Flows\
- or "Error" in ONOS5Flows or not ONOS5Flows\
- or "Error" in ONOS6Flows or not ONOS6Flows\
- or "Error" in ONOS7Flows or not ONOS7Flows:
- main.log.report( "Error in getting ONOS intents" )
- main.log.warn( "ONOS1 flows repsponse: " + ONOS1Flows )
- main.log.warn( "ONOS2 flows repsponse: " + ONOS2Flows )
- main.log.warn( "ONOS3 flows repsponse: " + ONOS3Flows )
- main.log.warn( "ONOS4 flows repsponse: " + ONOS4Flows )
- main.log.warn( "ONOS5 flows repsponse: " + ONOS5Flows )
- main.log.warn( "ONOS6 flows repsponse: " + ONOS6Flows )
- main.log.warn( "ONOS7 flows repsponse: " + ONOS7Flows )
- elif len( ONOS1FlowsJson ) == len( ONOS2FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS3FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS4FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS5FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS6FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS7FlowsJson ):
- # TODO: Do a better check, maybe compare flows on switches?
- flowState = ONOS1Flows
- flowCheck = main.TRUE
+ consistentFlows = True
+ flowsResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].flows,
+ name="flows-" + str( i ),
+ args=[],
+ kwargs={ 'jsonFormat': True } )
+ threads.append( t )
+ t.start()
+
+ # NOTE: Flows command can take some time to run
+ time.sleep(30)
+ for t in threads:
+ t.join()
+ result = t.result
+ ONOSFlows.append( result )
+
+ for i in range( numControllers ):
+ num = str( i + 1 )
+ if not ONOSFlows[ i ] or "Error" in ONOSFlows[ i ]:
+ main.log.report( "Error in getting ONOS" + num + " flows" )
+ main.log.warn( "ONOS" + num + " flows response: " +
+ repr( ONOSFlows[ i ] ) )
+ flowsResults = False
+ ONOSFlowsJson.append( None )
+ else:
+ try:
+ ONOSFlowsJson.append( json.loads( ONOSFlows[ i ] ) )
+ except ( ValueError, TypeError ):
+ # FIXME: change this to log.error?
+ main.log.exception( "Error in parsing ONOS" + num +
+ " response as json." )
+ main.log.error( repr( ONOSFlows[ i ] ) )
+ ONOSFlowsJson.append( None )
+ flowsResults = False
+ utilities.assert_equals(
+ expect=True,
+ actual=flowsResults,
+ onpass="No error in reading flows output",
+ onfail="Error in reading flows from ONOS" )
+
+ main.step( "Check for consistency in Flows from each controller" )
+ tmp = [ len( i ) == len( ONOSFlowsJson[ 0 ] ) for i in ONOSFlowsJson ]
+ if all( tmp ):
main.log.report( "Flow count is consistent across all ONOS nodes" )
else:
- main.log.warn( "ONOS1 flows: " +
- json.dumps( ONOS1FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS2 flows: " +
- json.dumps( ONOS2FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS3 flows: " +
- json.dumps( ONOS3FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS4 flows: " +
- json.dumps( ONOS4FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS5 flows: " +
- json.dumps( ONOS5FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS6 flows: " +
- json.dumps( ONOS6FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS7 flows: " +
- json.dumps( ONOS7FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
+ consistentFlows = False
utilities.assert_equals(
- expect=main.TRUE,
- actual=flowCheck,
+ expect=True,
+ actual=consistentFlows,
onpass="The flow count is consistent across all ONOS nodes",
onfail="ONOS nodes have different flow counts" )
+ if flowsResults and not consistentFlows:
+ for i in range( numControllers ):
+ try:
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " flows: " +
+ json.dumps( json.loads( ONOSFlows[i] ), sort_keys=True,
+ indent=4, separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " flows: " +
+ repr( ONOSFlows[ i ] ) )
+ elif flowsResults and consistentFlows:
+ flowCheck = main.TRUE
+ flowState = ONOSFlows[ 0 ]
+
main.step( "Get the OF Table entries" )
global flows
flows = []
for i in range( 1, 29 ):
flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) )
-
+ if flowCheck == main.FALSE:
+ for table in flows:
+ main.log.warn( table )
# TODO: Compare switch flow tables with ONOS flow tables
main.step( "Start continuous pings" )
@@ -874,67 +1333,84 @@
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
+ for node in nodes:
+ temp = ( node, node.name, node.ip_address, 6633 )
+ ctrls.append( temp )
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
main.step( "Collecting topology information from ONOS" )
devices = []
- devices.append( main.ONOScli1.devices() )
- devices.append( main.ONOScli2.devices() )
- devices.append( main.ONOScli3.devices() )
- devices.append( main.ONOScli4.devices() )
- devices.append( main.ONOScli5.devices() )
- devices.append( main.ONOScli6.devices() )
- devices.append( main.ONOScli7.devices() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].devices,
+ name="devices-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ devices.append( t.result )
hosts = []
- hosts.append( main.ONOScli1.hosts() )
- hosts.append( main.ONOScli2.hosts() )
- hosts.append( main.ONOScli3.hosts() )
- hosts.append( main.ONOScli4.hosts() )
- hosts.append( main.ONOScli5.hosts() )
- hosts.append( main.ONOScli6.hosts() )
- hosts.append( main.ONOScli7.hosts() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].hosts,
+ name="hosts-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ try:
+ hosts.append( json.loads( t.result ) )
+ except ( ValueError, TypeError ):
+ # FIXME: better handling of this, print which node
+ # Maybe use thread name?
+ main.log.exception( "Error parsing json output of hosts" )
+ # FIXME: should this be an empty json object instead?
+ hosts.append( None )
+
ports = []
- ports.append( main.ONOScli1.ports() )
- ports.append( main.ONOScli2.ports() )
- ports.append( main.ONOScli3.ports() )
- ports.append( main.ONOScli4.ports() )
- ports.append( main.ONOScli5.ports() )
- ports.append( main.ONOScli6.ports() )
- ports.append( main.ONOScli7.ports() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].ports,
+ name="ports-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ports.append( t.result )
links = []
- links.append( main.ONOScli1.links() )
- links.append( main.ONOScli2.links() )
- links.append( main.ONOScli3.links() )
- links.append( main.ONOScli4.links() )
- links.append( main.ONOScli5.links() )
- links.append( main.ONOScli6.links() )
- links.append( main.ONOScli7.links() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].links,
+ name="links-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ links.append( t.result )
clusters = []
- clusters.append( main.ONOScli1.clusters() )
- clusters.append( main.ONOScli2.clusters() )
- clusters.append( main.ONOScli3.clusters() )
- clusters.append( main.ONOScli4.clusters() )
- clusters.append( main.ONOScli5.clusters() )
- clusters.append( main.ONOScli6.clusters() )
- clusters.append( main.ONOScli7.clusters() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].clusters,
+ name="clusters-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ clusters.append( t.result )
# Compare json objects for hosts and dataplane clusters
# hosts
+ main.step( "Host view is consistent across ONOS nodes" )
consistentHostsResult = main.TRUE
for controller in range( len( hosts ) ):
controllerStr = str( controller + 1 )
@@ -961,15 +1437,31 @@
onpass="Hosts view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of hosts" )
+ main.step( "Each host has an IP address" )
+ ipResult = main.TRUE
+ for controller in range( 0, len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ for host in hosts[ controller ]:
+ if not host.get( 'ipAddresses', [ ] ):
+ main.log.error( "DEBUG:Error with host ips on controller" +
+ controllerStr + ": " + str( host ) )
+ ipResult = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=ipResult,
+ onpass="The ips of the hosts aren't empty",
+ onfail="The ip of at least one host is missing" )
+
# Strongly connected clusters of devices
+ main.step( "Cluster view is consistent across ONOS nodes" )
consistentClustersResult = main.TRUE
for controller in range( len( clusters ) ):
+ controllerStr = str( controller + 1 )
if "Error" not in clusters[ controller ]:
if clusters[ controller ] == clusters[ 0 ]:
continue
else: # clusters not consistent
- main.log.report( "clusters from ONOS" +
- controllerStr +
+ main.log.report( "clusters from ONOS" + controllerStr +
" is inconsistent with ONOS1" )
consistentClustersResult = main.FALSE
@@ -986,14 +1478,20 @@
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
# there should always only be one cluster
- numClusters = len( json.loads( clusters[ 0 ] ) )
+ main.step( "Cluster view correct across ONOS nodes" )
+ try:
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing clusters[0]: " +
+ repr( clusters[ 0 ] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
utilities.assert_equals(
expect=1,
actual=numClusters,
onpass="ONOS shows 1 SCC",
- onfail="ONOS shows " +
- str( numClusters ) +
- " SCCs" )
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
@@ -1004,214 +1502,240 @@
if devices[ controller ] or "Error" not in devices[ controller ]:
currentDevicesResult = main.Mininet1.compareSwitches(
MNTopo,
- json.loads(
- devices[ controller ] ) )
+ json.loads( devices[ controller ] ) )
else:
currentDevicesResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentDevicesResult,
- onpass="ONOS" + controllerStr +
- " Switches view is correct",
- onfail="ONOS" + controllerStr +
- " Switches view is incorrect" )
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
if ports[ controller ] or "Error" not in ports[ controller ]:
currentPortsResult = main.Mininet1.comparePorts(
MNTopo,
- json.loads(
- ports[ controller ] ) )
+ json.loads( ports[ controller ] ) )
else:
currentPortsResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentPortsResult,
- onpass="ONOS" + controllerStr +
- " ports view is correct",
- onfail="ONOS" + controllerStr +
- " ports view is incorrect" )
+ actual=currentPortsResult,
+ onpass="ONOS" + controllerStr +
+ " ports view is correct",
+ onfail="ONOS" + controllerStr +
+ " ports view is incorrect" )
if links[ controller ] or "Error" not in links[ controller ]:
currentLinksResult = main.Mininet1.compareLinks(
MNTopo,
- json.loads(
- links[ controller ] ) )
+ json.loads( links[ controller ] ) )
else:
currentLinksResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentLinksResult,
- onpass="ONOS" + controllerStr +
- " links view is correct",
- onfail="ONOS" + controllerStr +
- " links view is incorrect" )
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
devicesResults = devicesResults and currentDevicesResult
portsResults = portsResults and currentPortsResult
linksResults = linksResults and currentLinksResult
- topoResult = devicesResults and portsResults and linksResults\
- and consistentHostsResult and consistentClustersResult
+ topoResult = ( devicesResults and portsResults and linksResults
+ and consistentHostsResult and consistentClustersResult
+ and clusterResults and ipResult )
utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
-
- finalAssert = main.TRUE
- finalAssert = finalAssert and topoResult and flowCheck \
- and intentCheck and consistentMastership and rolesNotNull
- utilities.assert_equals( expect=main.TRUE, actual=finalAssert,
- onpass="State check successful",
- onfail="State check NOT successful" )
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
def CASE6( self, main ):
"""
The Failure case.
"""
- main.log.report( "Restart entire ONOS cluster" )
- main.log.case( "Restart entire ONOS cluster" )
- main.ONOSbench.onosKill( ONOS1Ip )
- main.ONOSbench.onosKill( ONOS2Ip )
- main.ONOSbench.onosKill( ONOS3Ip )
- main.ONOSbench.onosKill( ONOS4Ip )
- main.ONOSbench.onosKill( ONOS5Ip )
- main.ONOSbench.onosKill( ONOS6Ip )
- main.ONOSbench.onosKill( ONOS7Ip )
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+
+ # Reset non-persistent variables
+ try:
+ iCounterValue = 0
+ except NameError:
+ main.log.error( "iCounterValue not defined, setting to 0" )
+ iCounterValue = 0
+
+ main.case( "Restart entire ONOS cluster" )
+ main.step( "Killing ONOS nodes" )
+ killResults = main.TRUE
+ killTime = time.time()
+ for node in nodes:
+ killed = main.ONOSbench.onosKill( node.ip_address )
+ killResults = killResults and killed
+ utilities.assert_equals( expect=main.TRUE, actual=killResults,
+ onpass="ONOS nodes killed",
+ onfail="ONOS kill unsuccessful" )
main.step( "Checking if ONOS is up yet" )
- count = 0
- onosIsupResult = main.FALSE
- while onosIsupResult == main.FALSE and count < 10:
- onos1Isup = main.ONOSbench.isup( ONOS1Ip )
- onos2Isup = main.ONOSbench.isup( ONOS2Ip )
- onos3Isup = main.ONOSbench.isup( ONOS3Ip )
- onos4Isup = main.ONOSbench.isup( ONOS4Ip )
- onos5Isup = main.ONOSbench.isup( ONOS5Ip )
- onos6Isup = main.ONOSbench.isup( ONOS6Ip )
- onos7Isup = main.ONOSbench.isup( ONOS7Ip )
- onosIsupResult = onos1Isup and onos2Isup and onos3Isup\
- and onos4Isup and onos5Isup and onos6Isup and onos7Isup
- count = count + 1
- # TODO: if it becomes an issue, we can retry this step a few times
+ for i in range( 2 ):
+ onosIsupResult = main.TRUE
+ for node in nodes:
+ started = main.ONOSbench.isup( node.ip_address )
+ if not started:
+ main.log.report( node.name + " didn't start!" )
+ onosIsupResult = onosIsupResult and started
+ if onosIsupResult == main.TRUE:
+ break
+ utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult,
+ onpass="ONOS restarted",
+ onfail="ONOS restart NOT successful" )
- cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip )
- cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip )
- cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip )
- cliResult4 = main.ONOScli4.startOnosCli( ONOS4Ip )
- cliResult5 = main.ONOScli5.startOnosCli( ONOS5Ip )
- cliResult6 = main.ONOScli6.startOnosCli( ONOS6Ip )
- cliResult7 = main.ONOScli7.startOnosCli( ONOS7Ip )
- cliResults = cliResult1 and cliResult2 and cliResult3\
- and cliResult4 and cliResult5 and cliResult6\
- and cliResult7
+ main.log.step( "Starting ONOS CLI sessions" )
+ cliResults = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].startOnosCli,
+ name="startOnosCli-" + str( i ),
+ args=[nodes[i].ip_address] )
+ threads.append( t )
+ t.start()
- caseResults = main.TRUE and onosIsupResult and cliResults
- utilities.assert_equals( expect=main.TRUE, actual=caseResults,
- onpass="ONOS restart successful",
- onfail="ONOS restart NOT successful" )
+ for t in threads:
+ t.join()
+ cliResults = cliResults and t.result
+ utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+ onpass="ONOS cli started",
+ onfail="ONOS clis did not restart" )
+
+ # Grab the time of restart so we chan check how long the gossip
+ # protocol has had time to work
+ main.restartTime = time.time() - killTime
+ main.log.debug( "Restart time: " + str( main.restartTime ) )
+ '''
+ # FIXME: revisit test plan for election with madan
+ # Rerun for election on restarted nodes
+ run1 = CLIs[0].electionTestRun()
+ run2 = CLIs[1].electionTestRun()
+ run3 = CLIs[2].electionTestRun()
+ ...
+ ...
+ runResults = run1 and run2 and run3
+ utilities.assert_equals( expect=main.TRUE, actual=runResults,
+ onpass="Reran for election",
+ onfail="Failed to rerun for election" )
+ '''
+ # TODO: Make this configurable
+ time.sleep( 60 )
+ main.log.debug( CLIs[0].nodes( jsonFormat=False ) )
+ main.log.debug( CLIs[0].leaders( jsonFormat=False ) )
+ main.log.debug( CLIs[0].partitions( jsonFormat=False ) )
def CASE7( self, main ):
"""
Check state after ONOS failure
"""
import json
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
main.case( "Running ONOS Constant State Tests" )
+ main.step( "Check that each switch has a master" )
# Assert that each device has a master
- ONOS1MasterNotNull = main.ONOScli1.rolesNotNull()
- ONOS2MasterNotNull = main.ONOScli2.rolesNotNull()
- ONOS3MasterNotNull = main.ONOScli3.rolesNotNull()
- ONOS4MasterNotNull = main.ONOScli4.rolesNotNull()
- ONOS5MasterNotNull = main.ONOScli5.rolesNotNull()
- ONOS6MasterNotNull = main.ONOScli6.rolesNotNull()
- ONOS7MasterNotNull = main.ONOScli7.rolesNotNull()
- rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\
- ONOS3MasterNotNull and ONOS4MasterNotNull and\
- ONOS5MasterNotNull and ONOS6MasterNotNull and\
- ONOS7MasterNotNull
+ rolesNotNull = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].rolesNotNull,
+ name="rolesNotNull-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ rolesNotNull = rolesNotNull and t.result
utilities.assert_equals(
expect=main.TRUE,
actual=rolesNotNull,
onpass="Each device has a master",
onfail="Some devices don't have a master assigned" )
- main.step( "Check if switch roles are consistent across all nodes" )
- ONOS1Mastership = main.ONOScli1.roles()
- ONOS2Mastership = main.ONOScli2.roles()
- ONOS3Mastership = main.ONOScli3.roles()
- ONOS4Mastership = main.ONOScli4.roles()
- ONOS5Mastership = main.ONOScli5.roles()
- ONOS6Mastership = main.ONOScli6.roles()
- ONOS7Mastership = main.ONOScli7.roles()
- if "Error" in ONOS1Mastership or not ONOS1Mastership\
- or "Error" in ONOS2Mastership or not ONOS2Mastership\
- or "Error" in ONOS3Mastership or not ONOS3Mastership\
- or "Error" in ONOS4Mastership or not ONOS4Mastership\
- or "Error" in ONOS5Mastership or not ONOS5Mastership\
- or "Error" in ONOS6Mastership or not ONOS6Mastership\
- or "Error" in ONOS7Mastership or not ONOS7Mastership:
- main.log.error( "Error in getting ONOS mastership" )
- main.log.warn( "ONOS1 mastership response: " +
- repr( ONOS1Mastership ) )
- main.log.warn( "ONOS2 mastership response: " +
- repr( ONOS2Mastership ) )
- main.log.warn( "ONOS3 mastership response: " +
- repr( ONOS3Mastership ) )
- main.log.warn( "ONOS4 mastership response: " +
- repr( ONOS4Mastership ) )
- main.log.warn( "ONOS5 mastership response: " +
- repr( ONOS5Mastership ) )
- main.log.warn( "ONOS6 mastership response: " +
- repr( ONOS6Mastership ) )
- main.log.warn( "ONOS7 mastership response: " +
- repr( ONOS7Mastership ) )
- consistentMastership = main.FALSE
- elif ONOS1Mastership == ONOS2Mastership\
- and ONOS1Mastership == ONOS3Mastership\
- and ONOS1Mastership == ONOS4Mastership\
- and ONOS1Mastership == ONOS5Mastership\
- and ONOS1Mastership == ONOS6Mastership\
- and ONOS1Mastership == ONOS7Mastership:
- consistentMastership = main.TRUE
+ main.step( "Read device roles from ONOS" )
+ ONOSMastership = []
+ mastershipCheck = main.FALSE
+ consistentMastership = True
+ rolesResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].roles,
+ name="roles-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSMastership.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " roles" )
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " mastership response: " +
+ repr( ONOSMastership[i] ) )
+ rolesResults = False
+ utilities.assert_equals(
+ expect=True,
+ actual=rolesResults,
+ onpass="No error in reading roles output",
+ onfail="Error in reading roles from ONOS" )
+
+ main.step( "Check for consistency in roles from each controller" )
+ if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
main.log.report(
"Switch roles are consistent across all ONOS nodes" )
else:
- main.log.warn( "ONOS1 roles: ", json.dumps(
- json.loads( ONOS1Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS2 roles: ", json.dumps(
- json.loads( ONOS2Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS3 roles: ", json.dumps(
- json.loads( ONOS3Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS4 roles: ", json.dumps(
- json.loads( ONOS4Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS5 roles: ", json.dumps(
- json.loads( ONOS5Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS6 roles: ", json.dumps(
- json.loads( ONOS6Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS7 roles: ", json.dumps(
- json.loads( ONOS7Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- consistentMastership = main.FALSE
+ consistentMastership = False
utilities.assert_equals(
- expect=main.TRUE,
+ expect=True,
actual=consistentMastership,
onpass="Switch roles are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of switch roles" )
+ if rolesResults and not consistentMastership:
+ for i in range( numControllers ):
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " roles: ",
+ json.dumps(
+ json.loads( ONOSMastership[ i ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ elif rolesResults and not consistentMastership:
+ mastershipCheck = main.TRUE
+
+ '''
description2 = "Compare switch roles from before failure"
main.step( description2 )
-
- currentJson = json.loads( ONOS1Mastership )
- oldJson = json.loads( mastershipState )
+ try:
+ currentJson = json.loads( ONOSMastership[0] )
+ oldJson = json.loads( mastershipState )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Something is wrong with parsing " +
+ "ONOSMastership[0] or mastershipState" )
+ main.log.error( "ONOSMastership[0]: " + repr( ONOSMastership[0] ) )
+ main.log.error( "mastershipState" + repr( mastershipState ) )
+ main.cleanup()
+ main.exit()
mastershipCheck = main.TRUE
for i in range( 1, 29 ):
switchDPID = str(
- main.Mininet1.getSwitchDPID(
- switch="s" +
- str( i ) ) )
-
+ main.Mininet1.getSwitchDPID( switch="s" + str( i ) ) )
current = [ switch[ 'master' ] for switch in currentJson
if switchDPID in switch[ 'id' ] ]
old = [ switch[ 'master' ] for switch in oldJson
@@ -1221,95 +1745,130 @@
else:
main.log.warn( "Mastership of switch %s changed" % switchDPID )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Mastership of Switches was not changed" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
onpass="Mastership of Switches was not changed",
onfail="Mastership of some switches changed" )
+ '''
# NOTE: we expect mastership to change on controller failure
- mastershipCheck = mastershipCheck and consistentMastership
main.step( "Get the intents and compare across all nodes" )
- ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
- ONOS2Intents = main.ONOScli2.intents( jsonFormat=True )
- ONOS3Intents = main.ONOScli3.intents( jsonFormat=True )
- ONOS4Intents = main.ONOScli4.intents( jsonFormat=True )
- ONOS5Intents = main.ONOScli5.intents( jsonFormat=True )
- ONOS6Intents = main.ONOScli6.intents( jsonFormat=True )
- ONOS7Intents = main.ONOScli7.intents( jsonFormat=True )
+ ONOSIntents = []
intentCheck = main.FALSE
- if "Error" in ONOS1Intents or not ONOS1Intents\
- or "Error" in ONOS2Intents or not ONOS2Intents\
- or "Error" in ONOS3Intents or not ONOS3Intents\
- or "Error" in ONOS4Intents or not ONOS4Intents\
- or "Error" in ONOS5Intents or not ONOS5Intents\
- or "Error" in ONOS6Intents or not ONOS6Intents\
- or "Error" in ONOS7Intents or not ONOS7Intents:
- main.log.report( "Error in getting ONOS intents" )
- main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
- main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) )
- main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) )
- main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) )
- main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) )
- main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) )
- main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) )
- elif ONOS1Intents == ONOS2Intents\
- and ONOS1Intents == ONOS3Intents\
- and ONOS1Intents == ONOS4Intents\
- and ONOS1Intents == ONOS5Intents\
- and ONOS1Intents == ONOS6Intents\
- and ONOS1Intents == ONOS7Intents:
- intentCheck = main.TRUE
- main.log.report( "Intents are consistent across all ONOS nodes" )
- else:
- main.log.warn( "ONOS1 intents: " )
- print json.dumps( json.loads( ONOS1Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS2 intents: " )
- print json.dumps( json.loads( ONOS2Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS3 intents: " )
- print json.dumps( json.loads( ONOS3Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS4 intents: " )
- print json.dumps( json.loads( ONOS4Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS5 intents: " )
- print json.dumps( json.loads( ONOS5Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS6 intents: " )
- print json.dumps( json.loads( ONOS6Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS7 intents: " )
- print json.dumps( json.loads( ONOS7Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
+ consistentIntents = True
+ intentsResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].intents,
+ name="intents-" + str( i ),
+ args=[],
+ kwargs={ 'jsonFormat': True } )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSIntents.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " intents" )
+ main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
+ repr( ONOSIntents[ i ] ) )
+ intentsResults = False
utilities.assert_equals(
- expect=main.TRUE,
- actual=intentCheck,
+ expect=True,
+ actual=intentsResults,
+ onpass="No error in reading intents output",
+ onfail="Error in reading intents from ONOS" )
+
+ main.step( "Check for consistency in Intents from each controller" )
+ if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
+ main.log.report( "Intents are consistent across all ONOS " +
+ "nodes" )
+ else:
+ consistentIntents = False
+
+ # Try to make it easy to figure out what is happening
+ #
+ # Intent ONOS1 ONOS2 ...
+ # 0x01 INSTALLED INSTALLING
+ # ... ... ...
+ # ... ... ...
+ title = " ID"
+ for n in range( numControllers ):
+ title += " " * 10 + "ONOS" + str( n + 1 )
+ main.log.warn( title )
+ # get all intent keys in the cluster
+ keys = []
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ keys.append( intent.get( 'id' ) )
+ keys = set( keys )
+ for key in keys:
+ row = "%-13s" % key
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ if intent.get( 'id' ) == key:
+ row += "%-15s" % intent.get( 'state' )
+ main.log.warn( row )
+ # End table view
+
+ utilities.assert_equals(
+ expect=True,
+ actual=consistentIntents,
onpass="Intents are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of intents" )
+ intentStates = []
+ for node in ONOSIntents: # Iter through ONOS nodes
+ nodeStates = []
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( node ):
+ nodeStates.append( intent[ 'state' ] )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error in parsing intents" )
+ main.log.error( repr( node ) )
+ intentStates.append( nodeStates )
+ out = [ (i, nodeStates.count( i ) ) for i in set( nodeStates ) ]
+ main.log.info( dict( out ) )
- # NOTE: Hazelcast has no durability, so intents are lost across system
- # restarts
+ if intentsResults and not consistentIntents:
+ for i in range( numControllers ):
+ main.log.warn( "ONOS" + str( i + 1 ) + " intents: " )
+ main.log.warn( json.dumps(
+ json.loads( ONOSIntents[ i ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ elif intentsResults and consistentIntents:
+ intentCheck = main.TRUE
+
+ # NOTE: Store has no durability, so intents are lost across system
+ # restarts
"""
main.step( "Compare current intents with intents before the failure" )
# NOTE: this requires case 5 to pass for intentState to be set.
# maybe we should stop the test if that fails?
- if intentState == ONOS1Intents:
+ sameIntents = main.TRUE
+ if intentState and intentState == ONOSIntents[ 0 ]:
sameIntents = main.TRUE
- main.log.report( "Intents are consistent with before failure" )
+ main.log.info( "Intents are consistent with before failure" )
# TODO: possibly the states have changed? we may need to figure out
- # what the aceptable states are
+ # what the acceptable states are
else:
try:
- main.log.warn( "ONOS1 intents: " )
- print json.dumps( json.loads( ONOS1Intents ),
- sort_keys=True, indent=4,
- separators=( ',', ': ' ) )
- except:
- pass
+ main.log.warn( "ONOS intents: " )
+ main.log.warn( json.dumps( json.loads( ONOSIntents[ 0 ] ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Exception printing intents" )
+ main.log.warn( repr( ONOSIntents[0] ) )
sameIntents = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
@@ -1333,8 +1892,6 @@
if FlowTables == main.FALSE:
main.log.info( "Differences in flow table for switch: s" +
str( i + 1 ) )
- if FlowTables == main.TRUE:
- main.log.report( "No changes were found in the flow tables" )
utilities.assert_equals(
expect=main.TRUE,
actual=FlowTables,
@@ -1343,12 +1900,8 @@
main.step( "Check the continuous pings to ensure that no packets " +
"were dropped during component failure" )
- # FIXME: This check is always failing. Investigate cause
- # NOTE: this may be something to do with file permsissions
- # or slight change in format
- main.Mininet2.pingKill(
- main.params[ 'TESTONUSER' ],
- main.params[ 'TESTONIP' ] )
+ main.Mininet2.pingKill( main.params[ 'TESTONUSER' ],
+ main.params[ 'TESTONIP' ] )
LossInPings = main.FALSE
# NOTE: checkForLoss returns main.FALSE with 0% packet loss
for i in range( 8, 18 ):
@@ -1370,25 +1923,25 @@
actual=LossInPings,
onpass="No Loss of connectivity",
onfail="Loss of dataplane connectivity detected" )
- # NOTE: Since intents are not persisted with Hazelcast, we expect this
+ # NOTE: Since intents are not persisted with IntnentStore,
+ # we expect loss in dataplane connectivity
LossInPings = main.FALSE
+ main.step( "Leadership Election is still functional" )
# Test of LeadershipElection
leaderList = []
leaderResult = main.TRUE
- for controller in range( 1, numControllers + 1 ):
- # loop through ONOScli handlers
- node = getattr( main, ( 'ONOScli' + str( controller ) ) )
- leaderN = node.electionTestLeader()
+ for cli in CLIs:
+ leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == main.FALSE:
- # error in response
+ # error in response
main.log.report( "Something is wrong with " +
"electionTestLeader function, check the" +
" error logs" )
leaderResult = main.FALSE
elif leaderN is None:
- main.log.report( "ONOS" + str( controller ) +
+ main.log.report( cli.name +
" shows no leader for the election-app was" +
" elected after the old one died" )
leaderResult = main.FALSE
@@ -1397,25 +1950,12 @@
main.log.error(
"Inconsistent view of leader for the election test app" )
# TODO: print the list
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was re-elected if applicable )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
onpass="Leadership election passed",
onfail="Something went wrong with Leadership election" )
- result = ( mastershipCheck and intentCheck and FlowTables and
- ( not LossInPings ) and rolesNotNull and leaderResult )
- result = int( result )
- if result == main.TRUE:
- main.log.report( "Constant State Tests Passed" )
- utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Constant State Tests Passed",
- onfail="Constant state tests failed" )
-
def CASE8( self, main ):
"""
Compare topo
@@ -1427,94 +1967,121 @@
from sts.topology.teston_topology import TestONTopology
import json
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
- description = "Compare ONOS Topology view to Mininet topology"
- main.case( description )
- main.log.report( description )
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplaination = "Compare topology objects between Mininet" +\
+ " and ONOS"
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 ) ] ), )
+ try:
+ ctrls = []
+ for node in nodes:
+ temp = ( node, node.name, node.ip_address, 6633 )
ctrls.append( temp )
- count = count + 1
- else:
- break
- MNTopo = TestONTopology(
- main.Mininet1,
- ctrls ) # can also add Intent API info for intent operations
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
+ except Exception:
+ objResult = main.FALSE
+ else:
+ objResult = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=objResult,
+ onpass="Created TestONTopology object",
+ onfail="Exception while creating " +
+ "TestONTopology object" )
main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
portsResults = main.TRUE
linksResults = main.TRUE
+ hostsResults = main.TRUE
topoResult = main.FALSE
elapsed = 0
count = 0
main.step( "Collecting topology information from ONOS" )
startTime = time.time()
+ # Give time for Gossip to work
while topoResult == main.FALSE and elapsed < 60:
- count = count + 1
+ count += 1
if count > 1:
- # TODO: Depricate STS usage
- MNTopo = TestONTopology(
- main.Mininet1,
- ctrls )
+ # TODO: Deprecate STS usage
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
cliStart = time.time()
devices = []
- devices.append( main.ONOScli1.devices() )
- devices.append( main.ONOScli2.devices() )
- devices.append( main.ONOScli3.devices() )
- devices.append( main.ONOScli4.devices() )
- devices.append( main.ONOScli5.devices() )
- devices.append( main.ONOScli6.devices() )
- devices.append( main.ONOScli7.devices() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].devices,
+ name="devices-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ devices.append( t.result )
hosts = []
- hosts.append( json.loads( main.ONOScli1.hosts() ) )
- hosts.append( json.loads( main.ONOScli2.hosts() ) )
- hosts.append( json.loads( main.ONOScli3.hosts() ) )
- hosts.append( json.loads( main.ONOScli4.hosts() ) )
- hosts.append( json.loads( main.ONOScli5.hosts() ) )
- hosts.append( json.loads( main.ONOScli6.hosts() ) )
- hosts.append( json.loads( main.ONOScli7.hosts() ) )
+ ipResult = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].hosts,
+ name="hosts-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ try:
+ hosts.append( json.loads( t.result ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing hosts results" )
+ main.log.error( repr( t.result ) )
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- host
- if host[ 'ips' ] == []:
+ if host is None or host.get( 'ipAddresses', [] ) == []:
main.log.error(
- "DEBUG:Error with host ips on controller" +
+ "DEBUG:Error with host ipAddresses on controller" +
controllerStr + ": " + str( host ) )
+ ipResult = main.FALSE
ports = []
- ports.append( main.ONOScli1.ports() )
- ports.append( main.ONOScli2.ports() )
- ports.append( main.ONOScli3.ports() )
- ports.append( main.ONOScli4.ports() )
- ports.append( main.ONOScli5.ports() )
- ports.append( main.ONOScli6.ports() )
- ports.append( main.ONOScli7.ports() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].ports,
+ name="ports-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ports.append( t.result )
links = []
- links.append( main.ONOScli1.links() )
- links.append( main.ONOScli2.links() )
- links.append( main.ONOScli3.links() )
- links.append( main.ONOScli4.links() )
- links.append( main.ONOScli5.links() )
- links.append( main.ONOScli6.links() )
- links.append( main.ONOScli7.links() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].links,
+ name="links-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ links.append( t.result )
clusters = []
- clusters.append( main.ONOScli1.clusters() )
- clusters.append( main.ONOScli2.clusters() )
- clusters.append( main.ONOScli3.clusters() )
- clusters.append( main.ONOScli4.clusters() )
- clusters.append( main.ONOScli5.clusters() )
- clusters.append( main.ONOScli6.clusters() )
- clusters.append( main.ONOScli7.clusters() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].clusters,
+ name="clusters-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ clusters.append( t.result )
elapsed = time.time() - startTime
cliTime = time.time() - cliStart
@@ -1526,51 +2093,63 @@
controller ]:
currentDevicesResult = main.Mininet1.compareSwitches(
MNTopo,
- json.loads(
- devices[ controller ] ) )
+ json.loads( devices[ controller ] ) )
else:
currentDevicesResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentDevicesResult,
- onpass="ONOS" + controllerStr +
- " Switches view is correct",
- onfail="ONOS" + controllerStr +
- " Switches view is incorrect" )
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
if ports[ controller ] or "Error" not in ports[ controller ]:
currentPortsResult = main.Mininet1.comparePorts(
MNTopo,
- json.loads(
- ports[ controller ] ) )
+ json.loads( ports[ controller ] ) )
else:
currentPortsResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentPortsResult,
- onpass="ONOS" + controllerStr +
- " ports view is correct",
- onfail="ONOS" + controllerStr +
- " ports view is incorrect" )
+ actual=currentPortsResult,
+ onpass="ONOS" + controllerStr +
+ " ports view is correct",
+ onfail="ONOS" + controllerStr +
+ " ports view is incorrect" )
if links[ controller ] or "Error" not in links[ controller ]:
currentLinksResult = main.Mininet1.compareLinks(
MNTopo,
- json.loads(
- links[ controller ] ) )
+ json.loads( links[ controller ] ) )
else:
currentLinksResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentLinksResult,
- onpass="ONOS" + controllerStr +
- " links view is correct",
- onfail="ONOS" + controllerStr +
- " links view is incorrect" )
- devicesResults = devicesResults and currentDevicesResult
- portsResults = portsResults and currentPortsResult
- linksResults = linksResults and currentLinksResult
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
+
+ if hosts[ controller ] or "Error" not in hosts[ controller ]:
+ currentHostsResult = main.Mininet1.compareHosts(
+ MNTopo, hosts[ controller ] )
+ else:
+ currentHostsResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentHostsResult,
+ onpass="ONOS" + controllerStr +
+ " hosts exist in Mininet",
+ onfail="ONOS" + controllerStr +
+ " hosts don't match Mininet" )
+
+ devicesResults = devicesResults and currentDevicesResult
+ portsResults = portsResults and currentPortsResult
+ linksResults = linksResults and currentLinksResult
+ hostsResults = hostsResults and currentHostsResult
# Compare json objects for hosts and dataplane clusters
# hosts
+ main.step( "Hosts view is consistent across all ONOS nodes" )
consistentHostsResult = main.TRUE
for controller in range( len( hosts ) ):
controllerStr = str( controller + 1 )
@@ -1597,6 +2176,7 @@
onfail="ONOS nodes have different views of hosts" )
# Strongly connected clusters of devices
+ main.step( "Clusters view is consistent across all ONOS nodes" )
consistentClustersResult = main.TRUE
for controller in range( len( clusters ) ):
controllerStr = str( controller + 1 )
@@ -1622,57 +2202,106 @@
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
# there should always only be one cluster
- numClusters = len( json.loads( clusters[ 0 ] ) )
+ main.step( "Topology view is correct and consistent across all " +
+ "ONOS nodes" )
+ try:
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing clusters[0]: " +
+ repr( clusters[0] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
utilities.assert_equals(
expect=1,
actual=numClusters,
onpass="ONOS shows 1 SCC",
- onfail="ONOS shows " +
- str( numClusters ) +
- " SCCs" )
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
topoResult = ( devicesResults and portsResults and linksResults
- and consistentHostsResult
- and consistentClustersResult )
+ and hostsResults and consistentHostsResult
+ and consistentClustersResult and clusterResults
+ and ipResult )
topoResult = topoResult and int( count <= 2 )
note = "note it takes about " + str( int( cliTime ) ) + \
" seconds for the test to make all the cli calls to fetch " +\
"the topology from each ONOS instance"
- main.log.report(
+ main.log.info(
"Very crass estimate for topology discovery/convergence( " +
str( note ) + " ): " + str( elapsed ) + " seconds, " +
str( count ) + " tries" )
utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
- if topoResult == main.TRUE:
- main.log.report( "ONOS topology view matches Mininet topology" )
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
+
+ # FIXME: move this to an ONOS state case
+ main.step( "Checking ONOS nodes" )
+ nodesOutput = []
+ nodeResults = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].nodes,
+ name="nodes-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ nodesOutput.append( t.result )
+ ips = [ node.ip_address for node in nodes ]
+ for i in nodesOutput:
+ try:
+ current = json.loads( i )
+ for node in current:
+ currentResult = main.FALSE
+ if node['ip'] in ips: # node in nodes() output is in cell
+ if node['state'] == 'ACTIVE':
+ currentResult = main.TRUE
+ else:
+ main.log.error( "Error in ONOS node availability" )
+ main.log.error(
+ json.dumps( current,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ break
+ nodeResults = nodeResults and currentResult
+ except ( ValueError, TypeError ):
+ main.log.error( "Error parsing nodes output" )
+ main.log.warn( repr( i ) )
+ utilities.assert_equals( expect=main.TRUE, actual=nodeResults,
+ onpass="Nodes check successful",
+ onfail="Nodes check NOT successful" )
def CASE9( self, main ):
"""
Link s3-s28 down
"""
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# NOTE: You should probably run a topology check after this
linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
description = "Turn off a link to ensure that Link Discovery " +\
- "is working properly"
+ "is working properly"
main.log.report( description )
main.case( description )
main.step( "Kill Link between s3 and s28" )
LinkDown = main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
- main.log.info(
- "Waiting " +
- str( linkSleep ) +
- " seconds for link down to be discovered" )
+ main.log.info( "Waiting " + str( linkSleep ) +
+ " seconds for link down to be discovered" )
time.sleep( linkSleep )
utilities.assert_equals( expect=main.TRUE, actual=LinkDown,
- onpass="Link down succesful",
- onfail="Failed to bring link down" )
+ onpass="Link down successful",
+ onfail="Failed to bring link down" )
# TODO do some sort of check here
def CASE10( self, main ):
@@ -1680,25 +2309,28 @@
Link s3-s28 up
"""
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# NOTE: You should probably run a topology check after this
linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
description = "Restore a link to ensure that Link Discovery is " + \
- "working properly"
+ "working properly"
main.log.report( description )
main.case( description )
main.step( "Bring link between s3 and s28 back up" )
LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
- main.log.info(
- "Waiting " +
- str( linkSleep ) +
- " seconds for link up to be discovered" )
+ main.log.info( "Waiting " + str( linkSleep ) +
+ " seconds for link up to be discovered" )
time.sleep( linkSleep )
utilities.assert_equals( expect=main.TRUE, actual=LinkUp,
- onpass="Link up succesful",
- onfail="Failed to bring link up" )
+ onpass="Link up successful",
+ onfail="Failed to bring link up" )
# TODO do some sort of check here
def CASE11( self, main ):
@@ -1707,6 +2339,11 @@
"""
# NOTE: You should probably run a topology check after this
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
@@ -1730,8 +2367,8 @@
if device and device[ 'available' ] is False:
result = main.TRUE
utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Kill switch succesful",
- onfail="Failed to kill switch?" )
+ onpass="Kill switch successful",
+ onfail="Failed to kill switch?" )
def CASE12( self, main ):
"""
@@ -1739,6 +2376,18 @@
"""
# NOTE: You should probably run a topology check after this
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
switch = main.params[ 'kill' ][ 'switch' ]
@@ -1751,30 +2400,26 @@
main.step( "Add back " + switch )
main.log.report( "Adding back " + switch )
main.Mininet1.addSwitch( switch, dpid=switchDPID )
- # TODO: New dpid or same? Ask Thomas?
for peer in links:
main.Mininet1.addLink( switch, peer )
- main.Mininet1.assignSwController(
- sw=switch.split( 's' )[ 1 ],
- count=numControllers,
- ip1=ONOS1Ip,
- port1=ONOS1Port,
- ip2=ONOS2Ip,
- port2=ONOS2Port,
- ip3=ONOS3Ip,
- port3=ONOS3Port,
- ip4=ONOS4Ip,
- port4=ONOS4Port,
- ip5=ONOS5Ip,
- port5=ONOS5Port,
- ip6=ONOS6Ip,
- port6=ONOS6Port,
- ip7=ONOS7Ip,
- port7=ONOS7Port )
- main.log.info(
- "Waiting " +
- str( switchSleep ) +
- " seconds for switch up to be discovered" )
+ main.Mininet1.assignSwController( sw=switch.split( 's' )[ 1 ],
+ count=numControllers,
+ ip1=nodes[ 0 ].ip_address,
+ port1=ONOS1Port,
+ ip2=nodes[ 1 ].ip_address,
+ port2=ONOS2Port,
+ ip3=nodes[ 2 ].ip_address,
+ port3=ONOS3Port,
+ ip4=nodes[ 3 ].ip_address,
+ port4=ONOS4Port,
+ ip5=nodes[ 4 ].ip_address,
+ port5=ONOS5Port,
+ ip6=nodes[ 5 ].ip_address,
+ port6=ONOS6Port,
+ ip7=nodes[ 6 ].ip_address,
+ port7=ONOS7Port )
+ main.log.info( "Waiting " + str( switchSleep ) +
+ " seconds for switch up to be discovered" )
time.sleep( switchSleep )
device = main.ONOScli1.getDevice( dpid=switchDPID )
# Peek at the deleted switch
@@ -1783,8 +2428,8 @@
if device and device[ 'available' ]:
result = main.TRUE
utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="add switch succesful",
- onfail="Failed to add switch?" )
+ onpass="add switch successful",
+ onfail="Failed to add switch?" )
def CASE13( self, main ):
"""
@@ -1792,37 +2437,22 @@
"""
import os
import time
- # TODO: make use of this elsewhere
- ips = []
- ips.append( ONOS1Ip )
- ips.append( ONOS2Ip )
- ips.append( ONOS3Ip )
- ips.append( ONOS4Ip )
- ips.append( ONOS5Ip )
- ips.append( ONOS6Ip )
- ips.append( ONOS7Ip )
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# printing colors to terminal
- colors = {}
- colors[ 'cyan' ] = '\033[96m'
- colors[ 'purple' ] = '\033[95m'
- colors[ 'blue' ] = '\033[94m'
- colors[ 'green' ] = '\033[92m'
- colors[ 'yellow' ] = '\033[93m'
- colors[ 'red' ] = '\033[91m'
- colors[ 'end' ] = '\033[0m'
+ colors = { 'cyan': '\033[96m', 'purple': '\033[95m',
+ 'blue': '\033[94m', 'green': '\033[92m',
+ 'yellow': '\033[93m', 'red': '\033[91m', 'end': '\033[0m' }
description = "Test Cleanup"
main.log.report( description )
main.case( description )
main.step( "Killing tcpdumps" )
main.Mininet2.stopTcpdump()
- main.step( "Checking ONOS Logs for errors" )
- for i in range( 7 ):
- print colors[ 'purple' ] + "Checking logs for errors on " + \
- "ONOS" + str( i + 1 ) + ":" + colors[ 'end' ]
- print main.ONOSbench.checkLogs( ips[ i ] )
-
main.step( "Copying MN pcap and ONOS log files to test station" )
testname = main.TEST
teststationUser = main.params[ 'TESTONUSER' ]
@@ -1838,14 +2468,15 @@
# NOTE: must end in /
dstDir = "~/packet_captures/"
for f in logFiles:
- for i in range( 7 ):
- main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" +
- logFolder + f + " " +
+ for node in nodes:
+ main.ONOSbench.handle.sendline( "scp sdn@" + node.ip_address +
+ ":" + logFolder + f + " " +
teststationUser + "@" +
teststationIP + ":" +
dstDir + str( testname ) +
- "-ONOS" + str( i + 1 ) + "-" +
- f )
+ "-" + node.name + "-" + f )
+ main.ONOSbench.handle.expect( "\$" )
+
# std*.log's
# NOTE: must end in /
logFolder = "/opt/onos/var/"
@@ -1853,157 +2484,186 @@
# NOTE: must end in /
dstDir = "~/packet_captures/"
for f in logFiles:
- for i in range( 7 ):
- main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" +
- logFolder + f + " " +
+ for node in nodes:
+ main.ONOSbench.handle.sendline( "scp sdn@" + node.ip_address +
+ ":" + logFolder + f + " " +
teststationUser + "@" +
teststationIP + ":" +
dstDir + str( testname ) +
- "-ONOS" + str( i + 1 ) + "-" +
- f )
+ "-" + node.name + "-" + f )
+ main.ONOSbench.handle.expect( "\$" )
# sleep so scp can finish
time.sleep( 10 )
+
+ main.step( "Stopping Mininet" )
+ mnResult = main.Mininet1.stopNet()
+ utilities.assert_equals( expect=main.TRUE, actual=mnResult,
+ onpass="Mininet stopped",
+ onfail="MN cleanup NOT successful" )
+
+ main.step( "Checking ONOS Logs for errors" )
+ for node in nodes:
+ print colors[ 'purple' ] + "Checking logs for errors on " + \
+ node.name + ":" + colors[ 'end' ]
+ print main.ONOSbench.checkLogs( node.ip_address )
+
main.step( "Packing and rotating pcap archives" )
os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
- # TODO: actually check something here
- utilities.assert_equals( expect=main.TRUE, actual=main.TRUE,
- onpass="Test cleanup successful",
- onfail="Test cleanup NOT successful" )
+ try:
+ timerLog = open( main.logdir + "/Timers.csv", 'w')
+ # Overwrite with empty line and close
+ timerLog.write( "Restart\n" )
+ timerLog.write( str( main.restartTime ) )
+ timerLog.close()
+ except NameError, e:
+ main.log.exception(e)
def CASE14( self, main ):
"""
start election app on all onos nodes
"""
- leaderResult = main.TRUE
- # install app on onos 1
- main.log.info( "Install leadership election app" )
- main.ONOScli1.featureInstall( "onos-app-election" )
- # wait for election
- # check for leader
- leader = main.ONOScli1.electionTestLeader()
- # verify leader is ONOS1
- if leader == ONOS1Ip:
- # all is well
- pass
- elif leader is None:
- # No leader elected
- main.log.report( "No leader was elected" )
- leaderResult = main.FALSE
- elif leader == main.FALSE:
- # error in response
- # TODO: add check for "Command not found:" in the driver, this
- # means the app isn't loaded
- main.log.report( "Something is wrong with electionTestLeader" +
- " function, check the error logs" )
- leaderResult = main.FALSE
- else:
- # error in response
- main.log.report(
- "Unexpected response from electionTestLeader function:'" +
- str( leader ) +
- "'" )
- leaderResult = main.FALSE
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
- # install on other nodes and check for leader.
- # Should be onos1 and each app should show the same leader
- for controller in range( 2, numControllers + 1 ):
- # loop through ONOScli handlers
- node = getattr( main, ( 'ONOScli' + str( controller ) ) )
- node.featureInstall( "onos-app-election" )
- leaderN = node.electionTestLeader()
- # verify leader is ONOS1
- if leaderN == ONOS1Ip:
- # all is well
- pass
- elif leaderN == main.FALSE:
- # error in response
- # TODO: add check for "Command not found:" in the driver, this
- # means the app isn't loaded
- main.log.report( "Something is wrong with " +
- "electionTestLeader function, check the" +
- " error logs" )
+ main.case("Start Leadership Election app")
+ main.step( "Install leadership election app" )
+ appResult = main.ONOScli1.activateApp( "org.onosproject.election" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=appResult,
+ onpass="Election app installed",
+ onfail="Something went wrong with installing Leadership election" )
+
+ main.step( "Run for election on each node" )
+ leaderResult = main.TRUE
+ leaders = []
+ for cli in CLIs:
+ cli.electionTestRun()
+ for cli in CLIs:
+ leader = cli.electionTestLeader()
+ if leader is None or leader == main.FALSE:
+ main.log.report( cli.name + ": Leader for the election app " +
+ "should be an ONOS node, instead got '" +
+ str( leader ) + "'" )
leaderResult = main.FALSE
- elif leader != leaderN:
- leaderResult = main.FALSE
- main.log.report( "ONOS" + str( controller ) + " sees " +
- str( leaderN ) +
- " as the leader of the election app. Leader" +
- " should be " +
- str( leader ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a leader " +
- "was elected )" )
+ leaders.append( leader )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
- onpass="Leadership election passed",
- onfail="Something went wrong with Leadership election" )
+ onpass="Successfully ran for leadership",
+ onfail="Failed to run for leadership" )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
def CASE15( self, main ):
"""
Check that Leadership Election is still functional
"""
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+
leaderResult = main.TRUE
description = "Check that Leadership Election is still functional"
main.log.report( description )
main.case( description )
+ # NOTE: Need to re-run since being a canidate is not persistant
+ main.step( "Run for election on each node" )
+ leaderResult = main.TRUE
+ leaders = []
+ for cli in CLIs:
+ cli.electionTestRun()
+ for cli in CLIs:
+ leader = cli.electionTestLeader()
+ if leader is None or leader == main.FALSE:
+ main.log.report( cli.name + ": Leader for the election app " +
+ "should be an ONOS node, instead got '" +
+ str( leader ) + "'" )
+ leaderResult = main.FALSE
+ leaders.append( leader )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=leaderResult,
+ onpass="Successfully ran for leadership",
+ onfail="Failed to run for leadership" )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
+
main.step( "Find current leader and withdraw" )
leader = main.ONOScli1.electionTestLeader()
- # TODO: do some sanity checking on leader before using it
+ # do some sanity checking on leader before using it
withdrawResult = main.FALSE
- if leader == ONOS1Ip:
- oldLeader = getattr( main, "ONOScli1" )
- elif leader == ONOS2Ip:
- oldLeader = getattr( main, "ONOScli2" )
- elif leader == ONOS3Ip:
- oldLeader = getattr( main, "ONOScli3" )
- elif leader == ONOS4Ip:
- oldLeader = getattr( main, "ONOScli4" )
- elif leader == ONOS5Ip:
- oldLeader = getattr( main, "ONOScli5" )
- elif leader == ONOS6Ip:
- oldLeader = getattr( main, "ONOScli6" )
- elif leader == ONOS7Ip:
- oldLeader = getattr( main, "ONOScli7" )
- elif leader is None or leader == main.FALSE:
- main.log.report(
+ if leader is None or leader == main.FALSE:
+ main.log.error(
"Leader for the election app should be an ONOS node," +
- "instead got '" +
- str( leader ) +
- "'" )
+ "instead got '" + str( leader ) + "'" )
leaderResult = main.FALSE
- withdrawResult = oldLeader.electionTestWithdraw()
+ oldLeader = None
+ for i in range( len( CLIs ) ):
+ if leader == nodes[ i ].ip_address:
+ oldLeader = CLIs[ i ]
+ break
+ else: # FOR/ELSE statement
+ main.log.error( "Leader election, could not find current leader" )
+ if oldLeader:
+ withdrawResult = oldLeader.electionTestWithdraw()
utilities.assert_equals(
expect=main.TRUE,
actual=withdrawResult,
- onpass="App was withdrawn from election",
- onfail="App was not withdrawn from election" )
+ onpass="Node was withdrawn from election",
+ onfail="Node was not withdrawn from election" )
main.step( "Make sure new leader is elected" )
+ # FIXME: use threads
leaderList = []
- for controller in range( 1, numControllers + 1 ):
- # loop through ONOScli handlers
- node = getattr( main, ( 'ONOScli' + str( controller ) ) )
- leaderList.append( node.electionTestLeader() )
- for leaderN in leaderList:
+ for cli in CLIs:
+ leaderN = cli.electionTestLeader()
+ leaderList.append( leaderN )
if leaderN == leader:
- main.log.report(
- "ONOS" +
- str( controller ) +
- " still sees " +
- str( leader ) +
- " as leader after they withdrew" )
+ main.log.report( cli.name + " still sees " + str( leader ) +
+ " as leader after they withdrew" )
leaderResult = main.FALSE
elif leaderN == main.FALSE:
# error in response
# TODO: add check for "Command not found:" in the driver, this
- # means the app isn't loaded
+ # means the app isn't loaded
main.log.report( "Something is wrong with " +
"electionTestLeader function, " +
"check the error logs" )
leaderResult = main.FALSE
+ elif leaderN is None:
+ # node may not have recieved the event yet
+ time.sleep(7)
+ leaderN = cli.electionTestLeader()
+ leaderList.pop()
+ leaderList.append( leaderN )
consistentLeader = main.FALSE
if len( set( leaderList ) ) == 1:
main.log.info( "Each Election-app sees '" +
@@ -2016,37 +2676,1114 @@
for n in range( len( leaderList ) ):
main.log.report( "ONOS" + str( n + 1 ) + " response: " +
str( leaderList[ n ] ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was elected when the old leader " +
- "resigned )" )
+ leaderResult = leaderResult and consistentLeader
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
onpass="Leadership election passed",
onfail="Something went wrong with Leadership election" )
- main.step(
- "Run for election on old leader( just so everyone is in the hat )" )
- runResult = oldLeader.electionTestRun()
+ main.step( "Run for election on old leader( just so everyone " +
+ "is in the hat )" )
+ if oldLeader:
+ runResult = oldLeader.electionTestRun()
+ else:
+ runResult = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
actual=runResult,
onpass="App re-ran for election",
onfail="App failed to run for election" )
- if consistentLeader == main.TRUE:
- afterRun = main.ONOScli1.electionTestLeader()
- # verify leader didn't just change
- if afterRun == leaderList[ 0 ]:
- leaderResult = main.TRUE
- else:
- leaderResult = main.FALSE
- # TODO: assert on run and withdraw results?
+
+ main.step( "Leader did not change when old leader re-ran" )
+ afterRun = main.ONOScli1.electionTestLeader()
+ # verify leader didn't just change
+ if afterRun == leaderList[ 0 ]:
+ afterResult = main.TRUE
+ else:
+ afterResult = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
- actual=leaderResult,
- onpass="Leadership election passed",
+ actual=afterResult,
+ onpass="Old leader successfully re-ran for election",
onfail="Something went wrong with Leadership election after " +
"the old leader re-ran for election" )
+
+ def CASE16( self, main ):
+ """
+ Install Distributed Primitives app
+ """
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+
+ # Variables for the distributed primitives tests
+ global pCounterName
+ global iCounterName
+ global pCounterValue
+ global iCounterValue
+ global onosSet
+ global onosSetName
+ pCounterName = "TestON-Partitions"
+ iCounterName = "TestON-inMemory"
+ pCounterValue = 0
+ iCounterValue = 0
+ onosSet = set([])
+ onosSetName = "TestON-set"
+
+ description = "Install Primitives app"
+ main.case( description )
+ main.step( "Install Primitives app" )
+ appName = "org.onosproject.distributedprimitives"
+ appResults = CLIs[0].activateApp( appName )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=appResults,
+ onpass="Primitives app activated",
+ onfail="Primitives app not activated" )
+ time.sleep (5 ) # To allow all nodes to activate
+
+ def CASE17( self, main ):
+ """
+ Check for basic functionality with distributed primitives
+ """
+ # Make sure variables are defined/set
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert pCounterName, "pCounterName not defined"
+ assert iCounterName, "iCounterName not defined"
+ assert onosSetName, "onosSetName not defined"
+ # NOTE: assert fails if value is 0/None/Empty/False
+ try:
+ pCounterValue
+ except NameError:
+ main.log.error( "pCounterValue not defined, setting to 0" )
+ pCounterValue = 0
+ try:
+ iCounterValue
+ except NameError:
+ main.log.error( "iCounterValue not defined, setting to 0" )
+ iCounterValue = 0
+ try:
+ onosSet
+ except NameError:
+ main.log.error( "onosSet not defined, setting to empty Set" )
+ onosSet = set([])
+ # Variables for the distributed primitives tests. These are local only
+ addValue = "a"
+ addAllValue = "a b c d e f"
+ retainValue = "c d e f"
+
+ description = "Check for basic functionality with distributed " +\
+ "primitives"
+ main.case( description )
+ main.caseExplaination = "Test the methods of the distributed primitives (counters and sets) throught the cli"
+ # DISTRIBUTED ATOMIC COUNTERS
+ main.step( "Increment and get a default counter on each node" )
+ pCounters = []
+ threads = []
+ addedPValues = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counterTestIncrement,
+ name="counterIncrement-" + str( i ),
+ args=[ pCounterName ] )
+ pCounterValue += 1
+ addedPValues.append( pCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ pCounters.append( t.result )
+ # Check that counter incremented numController times
+ pCounterResults = True
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=pCounterResults,
+ onpass="Default counter incremented",
+ onfail="Error incrementing default" +
+ " counter" )
+
+ main.step( "Increment and get an in memory counter on each node" )
+ iCounters = []
+ addedIValues = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counterTestIncrement,
+ name="icounterIncrement-" + str( i ),
+ args=[ iCounterName ],
+ kwargs={ "inMemory": True } )
+ iCounterValue += 1
+ addedIValues.append( iCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ iCounters.append( t.result )
+ # Check that counter incremented numController times
+ iCounterResults = True
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in the in-memory "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=iCounterResults,
+ onpass="In memory counter incremented",
+ onfail="Error incrementing in memory" +
+ " counter" )
+
+ main.step( "Check counters are consistant across nodes" )
+ onosCounters = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counters,
+ name="counters-" + str( i ) )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ onosCounters.append( t.result )
+ tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
+ if all( tmp ):
+ main.log.info( "Counters are consistent across all nodes" )
+ consistentCounterResults = main.TRUE
+ else:
+ main.log.error( "Counters are not consistent across all nodes" )
+ consistentCounterResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=consistentCounterResults,
+ onpass="ONOS counters are consistent " +
+ "across nodes",
+ onfail="ONOS Counters are inconsistent " +
+ "across nodes" )
+
+ main.step( "Counters we added have the correct values" )
+ correctResults = main.TRUE
+ for i in range( numControllers ):
+ current = onosCounters[i]
+ try:
+ pValue = current.get( pCounterName )
+ iValue = current.get( iCounterName )
+ if pValue == pCounterValue:
+ main.log.info( "Partitioned counter value is correct" )
+ else:
+ main.log.error( "Partitioned counter value is incorrect," +
+ " expected value: " + str( pCounterValue )
+ + " current value: " + str( pValue ) )
+ correctResults = main.FALSE
+ if iValue == iCounterValue:
+ main.log.info( "In memory counter value is correct" )
+ else:
+ main.log.error( "In memory counter value is incorrect, " +
+ "expected value: " + str( iCounterValue ) +
+ " current value: " + str( iValue ) )
+ correctResults = main.FALSE
+ except AttributeError, e:
+ main.log.error( "ONOS" + str( i + 1 ) + " counters result " +
+ "is not as expected" )
+ correctResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=correctResults,
+ onpass="Added counters are correct",
+ onfail="Added counters are incorrect" )
+ # DISTRIBUTED SETS
+ main.step( "Distributed Set get" )
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=getResults,
+ onpass="Set elements are correct",
+ onfail="Set elements are incorrect" )
+
+ main.step( "Distributed Set size" )
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=sizeResults,
+ onpass="Set sizes are correct",
+ onfail="Set sizes are incorrect" )
+
+ main.step( "Distributed Set add()" )
+ onosSet.add( addValue )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAdd-" + str( i ),
+ args=[ onosSetName, addValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addResults = main.FALSE
+ else:
+ # unexpected result
+ addResults = main.FALSE
+ if addResults != main.TRUE:
+ main.log.error( "Error executing set add" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addResults = addResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addResults,
+ onpass="Set add correct",
+ onfail="Set add was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set contains()" )
+ containsResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setContains-" + str( i ),
+ args=[ onosSetName ],
+ kwargs={ "values": addValue } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ # NOTE: This is the tuple
+ containsResponses.append( t.result )
+
+ containsResults = main.TRUE
+ for i in range( numControllers ):
+ if containsResponses[ i ] == main.ERROR:
+ containsResults = main.FALSE
+ else:
+ containsResults = containsResults and\
+ containsResponses[ i ][ 1 ]
+ utilities.assert_equals( expect=main.TRUE,
+ actual=containsResults,
+ onpass="Set contains is functional",
+ onfail="Set contains failed" )
+
+ main.step( "Distributed Set containsAll()" )
+ containsAllResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setContainsAll-" + str( i ),
+ args=[ onosSetName ],
+ kwargs={ "values": addAllValue } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ # NOTE: This is the tuple
+ containsAllResponses.append( t.result )
+
+ containsAllResults = main.TRUE
+ for i in range( numControllers ):
+ if containsResponses[ i ] == main.ERROR:
+ containsResults = main.FALSE
+ else:
+ containsResults = containsResults and\
+ containsResponses[ i ][ 1 ]
+ utilities.assert_equals( expect=main.TRUE,
+ actual=containsAllResults,
+ onpass="Set containsAll is functional",
+ onfail="Set containsAll failed" )
+
+ main.step( "Distributed Set remove()" )
+ onosSet.remove( addValue )
+ removeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRemove-" + str( i ),
+ args=[ onosSetName, addValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ removeResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ removeResults = main.TRUE
+ for i in range( numControllers ):
+ if removeResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif removeResponses[ i ] == main.FALSE:
+ # not in set, probably fine
+ pass
+ elif removeResponses[ i ] == main.ERROR:
+ # Error in execution
+ removeResults = main.FALSE
+ else:
+ # unexpected result
+ removeResults = main.FALSE
+ if removeResults != main.TRUE:
+ main.log.error( "Error executing set remove" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ removeResults = removeResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=removeResults,
+ onpass="Set remove correct",
+ onfail="Set remove was incorrect" )
+
+ main.step( "Distributed Set removeAll()" )
+ onosSet.difference_update( addAllValue.split() )
+ removeAllResponses = []
+ threads = []
+ try:
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRemoveAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ removeAllResponses.append( t.result )
+ except Exception, e:
+ main.log.exception(e)
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ removeAllResults = main.TRUE
+ for i in range( numControllers ):
+ if removeAllResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif removeAllResponses[ i ] == main.FALSE:
+ # not in set, probably fine
+ pass
+ elif removeAllResponses[ i ] == main.ERROR:
+ # Error in execution
+ removeAllResults = main.FALSE
+ else:
+ # unexpected result
+ removeAllResults = main.FALSE
+ if removeAllResults != main.TRUE:
+ main.log.error( "Error executing set removeAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ removeAllResults = removeAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=removeAllResults,
+ onpass="Set removeAll correct",
+ onfail="Set removeAll was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set clear()" )
+ onosSet.clear()
+ clearResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestClear-" + str( i ),
+ args=[ onosSetName, " "], # Values doesn't matter
+ kwargs={ "clear": True } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ clearResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ clearResults = main.TRUE
+ for i in range( numControllers ):
+ if clearResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif clearResponses[ i ] == main.FALSE:
+ # Nothing set, probably fine
+ pass
+ elif clearResponses[ i ] == main.ERROR:
+ # Error in execution
+ clearResults = main.FALSE
+ else:
+ # unexpected result
+ clearResults = main.FALSE
+ if clearResults != main.TRUE:
+ main.log.error( "Error executing set clear" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ clearResults = clearResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=clearResults,
+ onpass="Set clear correct",
+ onfail="Set clear was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set retain()" )
+ onosSet.intersection_update( retainValue.split() )
+ retainResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRetain-" + str( i ),
+ args=[ onosSetName, retainValue ],
+ kwargs={ "retain": True } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ retainResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ retainResults = main.TRUE
+ for i in range( numControllers ):
+ if retainResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif retainResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif retainResponses[ i ] == main.ERROR:
+ # Error in execution
+ retainResults = main.FALSE
+ else:
+ # unexpected result
+ retainResults = main.FALSE
+ if retainResults != main.TRUE:
+ main.log.error( "Error executing set retain" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " +
+ str( size ) + " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ retainResults = retainResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=retainResults,
+ onpass="Set retain correct",
+ onfail="Set retain was incorrect" )
+
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.topo b/TestON/tests/HATestClusterRestart/HATestClusterRestart.topo
index 4d4156c..9305025 100644
--- a/TestON/tests/HATestClusterRestart/HATestClusterRestart.topo
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.topo
@@ -151,7 +151,7 @@
<arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
<arg2> --topo mytopo </arg2>
<arg3> </arg3>
- <controller> remote </controller>
+ <controller> none </controller>
</COMPONENTS>
</Mininet1>
@@ -162,11 +162,7 @@
<type>RemoteMininetDriver</type>
<connect_order>17</connect_order>
<COMPONENTS>
- # Specify the Option for mininet
- <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
- <arg2> --topo mytopo --arp</arg2>
- <controller> remote </controller>
- </COMPONENTS>
+ </COMPONENTS>
</Mininet2>
</COMPONENT>
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params
index 7d79860..ca1f915 100644
--- a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params
@@ -1,7 +1,7 @@
<PARAMS>
- <testcases>1,2,8,3,4,5,14,[6],8,7,4,15,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ <testcases>1,2,8,3,4,5,14,16,17,[6],8,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
<ENV>
- <cellName>HA</cellName>
+ <cellName>HA</cellName>
</ENV>
<Git>False</Git>
<branch> master </branch>
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
index 6cca54b..256561a 100644
--- a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
@@ -18,6 +18,8 @@
CASE13: Clean up
CASE14: start election app on all onos nodes
CASE15: Check that Leadership Election is still functional
+CASE16: Install Distributed Primitives app
+CASE17: Check for basic functionality with distributed primitives
"""
@@ -31,21 +33,28 @@
CASE1 is to compile ONOS and push it to the test machines
Startup sequence:
- git pull
- mvn clean install
- onos-package
cell <name>
onos-verify-cell
NOTE: temporary - onos-remove-raft-logs
+ onos-uninstall
+ start mininet
+ git pull
+ mvn clean install
+ onos-package
onos-install -f
onos-wait-for-start
+ start cli sessions
+ start tcpdump
"""
- main.log.report(
- "ONOS HA test: Restart minority of ONOS nodes - initialization" )
+ main.log.report( "ONOS HA test: Restart minority of ONOS nodes - " +
+ "initialization" )
main.case( "Setting up test environment" )
+ main.caseExplaination = "Setup the test environment including " +\
+ "installing ONOS, starting Mininet and ONOS" +\
+ "cli sessions."
# TODO: save all the timers and output them for plotting
- # load some vairables from the params file
+ # load some variables from the params file
PULLCODE = False
if main.params[ 'Git' ] == 'True':
PULLCODE = True
@@ -53,38 +62,34 @@
cellName = main.params[ 'ENV' ][ 'cellName' ]
# set global variables
- global ONOS1Ip
global ONOS1Port
- global ONOS2Ip
global ONOS2Port
- global ONOS3Ip
global ONOS3Port
- global ONOS4Ip
global ONOS4Port
- global ONOS5Ip
global ONOS5Port
- global ONOS6Ip
global ONOS6Port
- global ONOS7Ip
global ONOS7Port
global numControllers
-
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
- ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
- ONOS4Port = main.params[ 'CTRL' ][ 'port4' ]
- ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
- ONOS5Port = main.params[ 'CTRL' ][ 'port5' ]
- ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
- ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
- ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
- ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
numControllers = int( main.params[ 'num_controllers' ] )
+ # FIXME: just get controller port from params?
+ # TODO: do we really need all these?
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+ ONOS4Port = main.params[ 'CTRL' ][ 'port4' ]
+ ONOS5Port = main.params[ 'CTRL' ][ 'port5' ]
+ ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
+ ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
+
+ global CLIs
+ CLIs = []
+ global nodes
+ nodes = []
+ for i in range( 1, numControllers + 1 ):
+ CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+ nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+
main.step( "Applying cell variable to environment" )
cellResult = main.ONOSbench.setCell( cellName )
verifyResult = main.ONOSbench.verifyCell()
@@ -92,93 +97,112 @@
# FIXME:this is short term fix
main.log.report( "Removing raft logs" )
main.ONOSbench.onosRemoveRaftLogs()
+
main.log.report( "Uninstalling ONOS" )
- main.ONOSbench.onosUninstall( ONOS1Ip )
- main.ONOSbench.onosUninstall( ONOS2Ip )
- main.ONOSbench.onosUninstall( ONOS3Ip )
- main.ONOSbench.onosUninstall( ONOS4Ip )
- main.ONOSbench.onosUninstall( ONOS5Ip )
- main.ONOSbench.onosUninstall( ONOS6Ip )
- main.ONOSbench.onosUninstall( ONOS7Ip )
+ for node in nodes:
+ main.ONOSbench.onosUninstall( node.ip_address )
+
+ # Make sure ONOS is DEAD
+ main.log.report( "Killing any ONOS processes" )
+ killResults = main.TRUE
+ for node in nodes:
+ killed = main.ONOSbench.onosKill( node.ip_address )
+ killResults = killResults and killed
cleanInstallResult = main.TRUE
gitPullResult = main.TRUE
- main.step( "Compiling the latest version of ONOS" )
+ main.step( "Starting Mininet" )
+ mnResult = main.Mininet1.startNet( )
+ utilities.assert_equals( expect=main.TRUE, actual=mnResult,
+ onpass="Mininet Started",
+ onfail="Error starting Mininet" )
+
+ main.step( "Git checkout and pull " + gitBranch )
if PULLCODE:
- # TODO Configure branch in params
- main.step( "Git checkout and pull master" )
main.ONOSbench.gitCheckout( gitBranch )
gitPullResult = main.ONOSbench.gitPull()
-
- main.step( "Using mvn clean & install" )
- cleanInstallResult = main.ONOSbench.cleanInstall()
+ # values of 1 or 3 are good
+ utilities.assert_lesser( expect=0, actual=gitPullResult,
+ onpass="Git pull successful",
+ onfail="Git pull failed" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
main.ONOSbench.getVersion( report=True )
+ main.step( "Using mvn clean install" )
+ cleanInstallResult = main.TRUE
+ if gitPullResult == main.TRUE:
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cleanInstallResult,
+ onpass="MCI successful",
+ onfail="MCI failed" )
+ # GRAPHS
+ # NOTE: important params here:
+ # job = name of Jenkins job
+ # Plot Name = Plot-HA, only can be used if multiple plots
+ # index = The number of the graph under plot name
+ job = "HAMinorityRestart"
+ graphs = '<ac:structured-macro ac:name="html">\n'
+ graphs += '<ac:plain-text-body><![CDATA[\n'
+ graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
+ '/plot/getPlot?index=0&width=500&height=300"' +\
+ 'noborder="0" width="500" height="300" scrolling="yes" ' +\
+ 'seamless="seamless"></iframe>\n'
+ graphs += ']]></ac:plain-text-body>\n'
+ graphs += '</ac:structured-macro>\n'
+ main.log.wiki(graphs)
+
main.step( "Creating ONOS package" )
packageResult = main.ONOSbench.onosPackage()
+ utilities.assert_equals( expect=main.TRUE, actual=packageResult,
+ onpass="ONOS package successful",
+ onfail="ONOS package failed" )
main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS1Ip )
- onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS2Ip )
- onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS3Ip )
- onos4InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS4Ip )
- onos5InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS5Ip )
- onos6InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS6Ip )
- onos7InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS7Ip )
- onosInstallResult = onos1InstallResult and onos2InstallResult\
- and onos3InstallResult and onos4InstallResult\
- and onos5InstallResult and onos6InstallResult\
- and onos7InstallResult
+ onosInstallResult = main.TRUE
+ for node in nodes:
+ tmpResult = main.ONOSbench.onosInstall( options="-f",
+ node=node.ip_address )
+ onosInstallResult = onosInstallResult and tmpResult
+ utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
+ onpass="ONOS install successful",
+ onfail="ONOS install failed" )
main.step( "Checking if ONOS is up yet" )
- # TODO check bundle:list?
for i in range( 2 ):
- onos1Isup = main.ONOSbench.isup( ONOS1Ip )
- if not onos1Isup:
- main.log.report( "ONOS1 didn't start!" )
- onos2Isup = main.ONOSbench.isup( ONOS2Ip )
- if not onos2Isup:
- main.log.report( "ONOS2 didn't start!" )
- onos3Isup = main.ONOSbench.isup( ONOS3Ip )
- if not onos3Isup:
- main.log.report( "ONOS3 didn't start!" )
- onos4Isup = main.ONOSbench.isup( ONOS4Ip )
- if not onos4Isup:
- main.log.report( "ONOS4 didn't start!" )
- onos5Isup = main.ONOSbench.isup( ONOS5Ip )
- if not onos5Isup:
- main.log.report( "ONOS5 didn't start!" )
- onos6Isup = main.ONOSbench.isup( ONOS6Ip )
- if not onos6Isup:
- main.log.report( "ONOS6 didn't start!" )
- onos7Isup = main.ONOSbench.isup( ONOS7Ip )
- if not onos7Isup:
- main.log.report( "ONOS7 didn't start!" )
- onosIsupResult = onos1Isup and onos2Isup and onos3Isup\
- and onos4Isup and onos5Isup and onos6Isup and onos7Isup
+ onosIsupResult = main.TRUE
+ for node in nodes:
+ started = main.ONOSbench.isup( node.ip_address )
+ if not started:
+ main.log.report( node.name + " didn't start!" )
+ main.ONOSbench.onosStop( node.ip_address )
+ main.ONOSbench.onosStart( node.ip_address )
+ onosIsupResult = onosIsupResult and started
if onosIsupResult == main.TRUE:
break
+ utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult,
+ onpass="ONOS startup successful",
+ onfail="ONOS startup failed" )
- cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip )
- cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip )
- cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip )
- cliResult4 = main.ONOScli4.startOnosCli( ONOS4Ip )
- cliResult5 = main.ONOScli5.startOnosCli( ONOS5Ip )
- cliResult6 = main.ONOScli6.startOnosCli( ONOS6Ip )
- cliResult7 = main.ONOScli7.startOnosCli( ONOS7Ip )
- cliResults = cliResult1 and cliResult2 and cliResult3 and\
- cliResult4 and cliResult5 and cliResult6 and cliResult7
+ main.log.step( "Starting ONOS CLI sessions" )
+ cliResults = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].startOnosCli,
+ name="startOnosCli-" + str( i ),
+ args=[nodes[i].ip_address] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ cliResults = cliResults and t.result
+ utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+ onpass="ONOS cli startup successful",
+ onfail="ONOS cli startup failed" )
main.step( "Start Packet Capture MN" )
main.Mininet2.startTcpdump(
@@ -187,15 +211,28 @@
intf=main.params[ 'MNtcpdump' ][ 'intf' ],
port=main.params[ 'MNtcpdump' ][ 'port' ] )
- case1Result = ( cleanInstallResult and packageResult and
- cellResult and verifyResult and onosInstallResult
- and onosIsupResult and cliResults )
+ main.step( "App Ids check" )
+ appCheck = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
- utilities.assert_equals( expect=main.TRUE, actual=case1Result,
- onpass="Test startup successful",
- onfail="Test startup NOT successful" )
+ for t in threads:
+ t.join()
+ appCheck = appCheck and t.result
+ if appCheck != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
- if case1Result == main.FALSE:
+ if cliResults == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -204,169 +241,141 @@
Assign mastership to controllers
"""
import re
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
- main.log.report( "Assigning switches to controllers" )
main.case( "Assigning Controllers" )
+ main.caseExplaination = "Assign switches to ONOS using 'ovs-vsctl' " +\
+ "and check that an ONOS node becomes the " +\
+ "master of the device. Then manually assign" +\
+ " mastership to specific ONOS nodes using" +\
+ " 'device-role'"
main.step( "Assign switches to controllers" )
+ # TODO: rewrite this function to take lists of ips and ports?
+ # or list of tuples?
for i in range( 1, 29 ):
main.Mininet1.assignSwController(
sw=str( i ),
count=numControllers,
- ip1=ONOS1Ip, port1=ONOS1Port,
- ip2=ONOS2Ip, port2=ONOS2Port,
- ip3=ONOS3Ip, port3=ONOS3Port,
- ip4=ONOS4Ip, port4=ONOS4Port,
- ip5=ONOS5Ip, port5=ONOS5Port,
- ip6=ONOS6Ip, port6=ONOS6Port,
- ip7=ONOS7Ip, port7=ONOS7Port )
+ ip1=nodes[ 0 ].ip_address, port1=ONOS1Port,
+ ip2=nodes[ 1 ].ip_address, port2=ONOS2Port,
+ ip3=nodes[ 2 ].ip_address, port3=ONOS3Port,
+ ip4=nodes[ 3 ].ip_address, port4=ONOS4Port,
+ ip5=nodes[ 4 ].ip_address, port5=ONOS5Port,
+ ip6=nodes[ 5 ].ip_address, port6=ONOS6Port,
+ ip7=nodes[ 6 ].ip_address, port7=ONOS7Port )
mastershipCheck = main.TRUE
for i in range( 1, 29 ):
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
- if re.search( "tcp:" + ONOS1Ip, response )\
- and re.search( "tcp:" + ONOS2Ip, response )\
- and re.search( "tcp:" + ONOS3Ip, response )\
- and re.search( "tcp:" + ONOS4Ip, response )\
- and re.search( "tcp:" + ONOS5Ip, response )\
- and re.search( "tcp:" + ONOS6Ip, response )\
- and re.search( "tcp:" + ONOS7Ip, response ):
- mastershipCheck = mastershipCheck and main.TRUE
- else:
- mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Switch mastership assigned correctly" )
+ for node in nodes:
+ if re.search( "tcp:" + node.ip_address, response ):
+ mastershipCheck = mastershipCheck and main.TRUE
+ else:
+ main.log.error( "Error, node " + node.ip_address + " is " +
+ "not in the list of controllers s" +
+ str( i ) + " is connecting to." )
+ mastershipCheck = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
onpass="Switch mastership assigned correctly",
onfail="Switches not assigned correctly to controllers" )
+ main.step( "Assign mastership of switches to specific controllers" )
# Manually assign mastership to the controller we want
roleCall = main.TRUE
- roleCheck = main.TRUE
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS1Ip )
- # Check assignment
- if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS1Ip )
- # Check assignment
- if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS2Ip )
- # Check assignment
- if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS2Ip )
- # Check assignment
- if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS3Ip )
- # Check assignment
- if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS3Ip )
- # Check assignment
- if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS4Ip )
- # Check assignment
- if ONOS4Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- for i in range( 8, 18 ):
- dpid = '3' + str( i ).zfill( 3 )
- deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS5Ip )
- # Check assignment
- if ONOS5Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS6Ip )
- # Check assignment
- if ONOS6Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- for i in range( 18, 28 ):
- dpid = '6' + str( i ).zfill( 3 )
- deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS7Ip )
- # Check assignment
- if ONOS7Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
+ ipList = [ ]
+ deviceList = []
+ try:
+ for i in range( 1, 29 ): # switches 1 through 28
+ # set up correct variables:
+ if i == 1:
+ ip = nodes[ 0 ].ip_address # ONOS1
+ deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
+ elif i == 2:
+ ip = nodes[ 1 ].ip_address # ONOS2
+ deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' )
+ elif i == 3:
+ ip = nodes[ 1 ].ip_address # ONOS2
+ deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' )
+ elif i == 4:
+ ip = nodes[ 3 ].ip_address # ONOS4
+ deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' )
+ elif i == 5:
+ ip = nodes[ 2 ].ip_address # ONOS3
+ deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' )
+ elif i == 6:
+ ip = nodes[ 2 ].ip_address # ONOS3
+ deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' )
+ elif i == 7:
+ ip = nodes[ 5 ].ip_address # ONOS6
+ deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' )
+ elif i >= 8 and i <= 17:
+ ip = nodes[ 4 ].ip_address # ONOS5
+ dpid = '3' + str( i ).zfill( 3 )
+ deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
+ elif i >= 18 and i <= 27:
+ ip = nodes[ 6 ].ip_address # ONOS7
+ dpid = '6' + str( i ).zfill( 3 )
+ deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
+ elif i == 28:
+ ip = nodes[ 0 ].ip_address # ONOS1
+ deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' )
+ else:
+ main.log.error( "You didn't write an else statement for " +
+ "switch s" + str( i ) )
+ # Assign switch
+ assert deviceId, "No device id for s" + str( i ) + " in ONOS"
+ # TODO: make this controller dynamic
+ roleCall = roleCall and main.ONOScli1.deviceRole( deviceId,
+ ip )
+ ipList.append( ip )
+ deviceList.append( deviceId )
+ except ( AttributeError, AssertionError ):
+ main.log.exception( "Something is wrong with ONOS device view" )
+ main.log.info( main.ONOScli1.devices() )
utilities.assert_equals(
expect=main.TRUE,
actual=roleCall,
onpass="Re-assigned switch mastership to designated controller",
onfail="Something wrong with deviceRole calls" )
+ main.step( "Check mastership was correctly assigned" )
+ roleCheck = main.TRUE
+ # NOTE: This is due to the fact that device mastership change is not
+ # atomic and is actually a multi step process
+ time.sleep( 5 )
+ for i in range( len( ipList ) ):
+ ip = ipList[i]
+ deviceId = deviceList[i]
+ # Check assignment
+ master = main.ONOScli1.getRole( deviceId ).get( 'master' )
+ if ip in master:
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+ main.log.error( "Error, controller " + ip + " is not" +
+ " master " + "of device " +
+ str( deviceId ) + ". Master is " +
+ repr( master ) + "." )
utilities.assert_equals(
expect=main.TRUE,
actual=roleCheck,
@@ -375,58 +384,106 @@
onfail="Switches were not successfully reassigned" )
mastershipCheck = mastershipCheck and roleCall and roleCheck
utilities.assert_equals( expect=main.TRUE, actual=mastershipCheck,
- onpass="Switch mastership correctly assigned",
- onfail="Error in ( re )assigning switch" +
- " mastership" )
+ onpass="Switch mastership correctly assigned",
+ onfail="Error in (re)assigning switch" +
+ " mastership" )
def CASE3( self, main ):
"""
Assign intents
"""
import time
- main.log.report( "Adding host intents" )
+ import json
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
main.case( "Adding host Intents" )
-
- main.step( "Discovering Hosts( Via pingall for now )" )
- # FIXME: Once we have a host discovery mechanism, use that instead
+ main.caseExplaination = "Discover hosts by using pingall then " +\
+ "assign predetermined host-to-host intents." +\
+ " After installation, check that the intent" +\
+ " is distributed to all nodes and the state" +\
+ " is INSTALLED"
# install onos-app-fwd
- main.log.info( "Install reactive forwarding app" )
- main.ONOScli1.featureInstall( "onos-app-fwd" )
- main.ONOScli2.featureInstall( "onos-app-fwd" )
- main.ONOScli3.featureInstall( "onos-app-fwd" )
- main.ONOScli4.featureInstall( "onos-app-fwd" )
- main.ONOScli5.featureInstall( "onos-app-fwd" )
- main.ONOScli6.featureInstall( "onos-app-fwd" )
- main.ONOScli7.featureInstall( "onos-app-fwd" )
+ main.step( "Install reactive forwarding app" )
+ installResults = CLIs[0].activateApp( "org.onosproject.fwd" )
+ utilities.assert_equals( expect=main.TRUE, actual=installResults,
+ onpass="Install fwd successful",
+ onfail="Install fwd failed" )
+ main.step( "Check app ids" )
+ appCheck = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ appCheck = appCheck and t.result
+ if appCheck != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+
+ main.step( "Discovering Hosts( Via pingall for now )" )
+ # FIXME: Once we have a host discovery mechanism, use that instead
# REACTIVE FWD test
pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall()
- utilities.assert_equals(
- expect=main.TRUE,
- actual=pingResult,
- onpass="Reactive Pingall test passed",
- onfail="Reactive Pingall failed, one or more ping pairs failed" )
- time2 = time.time()
- main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) )
-
- # uninstall onos-app-fwd
- main.log.info( "Uninstall reactive forwarding app" )
- main.ONOScli1.featureUninstall( "onos-app-fwd" )
- main.ONOScli2.featureUninstall( "onos-app-fwd" )
- main.ONOScli3.featureUninstall( "onos-app-fwd" )
- main.ONOScli4.featureUninstall( "onos-app-fwd" )
- main.ONOScli5.featureUninstall( "onos-app-fwd" )
- main.ONOScli6.featureUninstall( "onos-app-fwd" )
- main.ONOScli7.featureUninstall( "onos-app-fwd" )
+ for i in range(2): # Retry if pingall fails first time
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=pingResult,
+ onpass="Reactive Pingall test passed",
+ onfail="Reactive Pingall failed, " +
+ "one or more ping pairs failed" )
+ time2 = time.time()
+ main.log.info( "Time for pingall: %2f seconds" %
+ ( time2 - time1 ) )
# timeout for fwd flows
- time.sleep( 10 )
+ time.sleep( 11 )
+ # uninstall onos-app-fwd
+ main.step( "Uninstall reactive forwarding app" )
+ uninstallResult = CLIs[0].deactivateApp( "org.onosproject.fwd" )
+ utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
+ onpass="Uninstall fwd successful",
+ onfail="Uninstall fwd failed" )
- main.step( "Add host intents" )
+ main.step( "Check app ids" )
+ threads = []
+ appCheck2 = main.TRUE
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ appCheck2 = appCheck2 and t.result
+ if appCheck2 != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck2,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+
+ main.step( "Add host intents via cli" )
+ intentIds = []
# TODO: move the host numbers to params
+ # Maybe look at all the paths we ping?
intentAddResult = True
+ hostResult = main.TRUE
for i in range( 8, 18 ):
main.log.info( "Adding host intent between h" + str( i ) +
" and h" + str( i + 10 ) )
@@ -434,53 +491,300 @@
str( hex( i )[ 2: ] ).zfill( 2 ).upper()
host2 = "00:00:00:00:00:" + \
str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
- host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
- # NOTE: get host can return None
+ # NOTE: getHost can return None
+ host1Dict = main.ONOScli1.getHost( host1 )
+ host2Dict = main.ONOScli1.getHost( host2 )
+ host1Id = None
+ host2Id = None
+ if host1Dict and host2Dict:
+ host1Id = host1Dict.get( 'id', None )
+ host2Id = host2Dict.get( 'id', None )
if host1Id and host2Id:
- tmpResult = main.ONOScli1.addHostIntent(
- host1Id,
- host2Id )
+ nodeNum = ( i % 7 )
+ tmpId = CLIs[ nodeNum ].addHostIntent( host1Id, host2Id )
+ if tmpId:
+ main.log.info( "Added intent with id: " + tmpId )
+ intentIds.append( tmpId )
+ else:
+ main.log.error( "addHostIntent returned: " +
+ repr( tmpId ) )
else:
- main.log.error( "Error, getHost() failed" )
- tmpResult = main.FALSE
- intentAddResult = bool( pingResult and intentAddResult
- and tmpResult )
- # TODO Check that intents were added?
- utilities.assert_equals(
- expect=True,
- actual=intentAddResult,
- onpass="Pushed host intents to ONOS",
- onfail="Error in pushing host intents to ONOS" )
- # TODO Check if intents all exist in datastore
+ main.log.error( "Error, getHost() failed for h" + str( i ) +
+ " and/or h" + str( i + 10 ) )
+ hosts = CLIs[ 0 ].hosts()
+ main.log.warn( "Hosts output: " )
+ try:
+ main.log.warn( json.dumps( json.loads( hosts ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( hosts ) )
+ hostResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE, actual=hostResult,
+ onpass="Found a host id for each host",
+ onfail="Error looking up host ids" )
+
+ intentStart = time.time()
+ onosIds = main.ONOScli1.getAllIntentsId()
+ main.log.info( "Submitted intents: " + str( intentIds ) )
+ main.log.info( "Intents in ONOS: " + str( onosIds ) )
+ for intent in intentIds:
+ if intent in onosIds:
+ pass # intent submitted is in onos
+ else:
+ intentAddResult = False
+ # FIXME: DEBUG
+ if intentAddResult:
+ intentStop = time.time()
+ else:
+ intentStop = None
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ installedCheck = True
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents" )
+ # add submitted intents not in the store
+ tmplist = [ i for i, s in intentStates ]
+ missingIntents = False
+ for i in intentIds:
+ if i not in tmplist:
+ intentStates.append( ( i, " - " ) )
+ missingIntents = True
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+
+ intentAddResult = bool( intentAddResult and not missingIntents and
+ installedCheck )
+ if not intentAddResult:
+ main.log.error( "Error in pushing host intents to ONOS" )
+
+ main.step( "Intent Anti-Entropy dispersion" )
+ for i in range(100):
+ correct = True
+ main.log.info( "Submitted intents: " + str( sorted( intentIds ) ) )
+ for cli in CLIs:
+ onosIds = []
+ ids = cli.getAllIntentsId()
+ onosIds.append( ids )
+ main.log.debug( "Intents in " + cli.name + ": " +
+ str( sorted( onosIds ) ) )
+ if sorted( ids ) != sorted( intentIds ):
+ correct = False
+ if correct:
+ break
+ else:
+ time.sleep(1)
+ if not intentStop:
+ intentStop = time.time()
+ global gossipTime
+ gossipTime = intentStop - intentStart
+ main.log.info( "It took about " + str( gossipTime ) +
+ " seconds for all intents to appear in each node" )
+ # FIXME: make this time configurable/calculate based off of number of
+ # nodes and gossip rounds
+ utilities.assert_greater_equals(
+ expect=40, actual=gossipTime,
+ onpass="ECM anti-entropy for intents worked within " +
+ "expected time",
+ onfail="Intent ECM anti-entropy took too long" )
+ if gossipTime <= 40:
+ intentAddResult = True
+
+ if not intentAddResult or "key" in pendingMap:
+ import time
+ installedCheck = True
+ main.log.info( "Sleeping 60 seconds to see if intents are found" )
+ time.sleep( 60 )
+ onosIds = main.ONOScli1.getAllIntentsId()
+ main.log.info( "Submitted intents: " + str( intentIds ) )
+ main.log.info( "Intents in ONOS: " + str( onosIds ) )
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ try:
+ for intent in json.loads( intents ):
+ # Iter through intents of a node
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents" )
+ # add submitted intents not in the store
+ tmplist = [ i for i, s in intentStates ]
+ for i in intentIds:
+ if i not in tmplist:
+ intentStates.append( ( i, " - " ) )
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ topics.append( "org.onosproject.election" )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
def CASE4( self, main ):
"""
Ping across added host intents
"""
- description = " Ping across added host intents"
- main.log.report( description )
- main.case( description )
+ import json
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ main.case( "Verify connectivity by sendind traffic across Intents" )
+ main.caseExplaination = "Ping across added host intents to check " +\
+ "functionality and check the state of " +\
+ "the intent"
+ main.step( "Ping across added host intents" )
PingResult = main.TRUE
for i in range( 8, 18 ):
- ping = main.Mininet1.pingHost(
- src="h" + str( i ), target="h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
PingResult = PingResult and ping
if ping == main.FALSE:
main.log.warn( "Ping failed between h" + str( i ) +
" and h" + str( i + 10 ) )
elif ping == main.TRUE:
main.log.info( "Ping test passed!" )
- PingResult = main.TRUE
+ # Don't set PingResult or you'd override failures
if PingResult == main.FALSE:
main.log.report(
"Intents have not been installed correctly, pings failed." )
- #TODO: pretty print
- main.log.warn( "ONSO1 intents: " )
- main.log.warn( json.dumps( json.loads( main.ONOScli1.intents() ),
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
if PingResult == main.TRUE:
main.log.report(
"Intents have been installed correctly and verified by pings" )
@@ -490,342 +794,495 @@
onpass="Intents have been installed correctly and pings work",
onfail="Intents have not been installed correctly, pings failed." )
+ main.step( "Check Intent state" )
+ installedCheck = True
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents." )
+ # Print states
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ utilities.assert_equals( expect=True, actual=installedCheck,
+ onpass="Intents are all INSTALLED",
+ onfail="Intents are not all in " +\
+ "INSTALLED state" )
+
+ main.step( "Check leadership of topics" )
+ leaders = main.ONOScli1.leaders()
+ topicCheck = main.TRUE
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ # TODO: Look at Devices as topics now that it uses this system
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ # FIXME: topics.append( "org.onosproject.election" )
+ # Print leaders output
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ topicCheck = main.FALSE
+ else:
+ main.log.error( "leaders() returned None" )
+ topicCheck = main.FALSE
+ except ( ValueError, TypeError ):
+ topicCheck = main.FALSE
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ # TODO: Check for a leader of these topics
+ utilities.assert_equals( expect=main.TRUE, actual=topicCheck,
+ onpass="intent Partitions is in leaders",
+ onfail="Some topics were lost " )
+ # Print partitions
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ # Print Pending Map
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+
+ if not installedCheck:
+ main.log.info( "Waiting 60 seconds to see if the state of " +
+ "intents change" )
+ time.sleep( 60 )
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents." )
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ topics.append( "org.onosproject.election" )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+ main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+
+ main.step( "Wait a minute then ping again" )
+ PingResult = main.TRUE
+ for i in range( 8, 18 ):
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
+ PingResult = PingResult and ping
+ if ping == main.FALSE:
+ main.log.warn( "Ping failed between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ elif ping == main.TRUE:
+ main.log.info( "Ping test passed!" )
+ # Don't set PingResult or you'd override failures
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Intents have not been installed correctly, pings failed." )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=PingResult,
+ onpass="Intents have been installed correctly and pings work",
+ onfail="Intents have not been installed correctly, pings failed." )
+
def CASE5( self, main ):
"""
Reading state of ONOS
"""
import json
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
- main.log.report( "Setting up and gathering data for current state" )
main.case( "Setting up and gathering data for current state" )
# The general idea for this test case is to pull the state of
# ( intents,flows, topology,... ) from each ONOS node
- # We can then compare them with eachother and also with past states
+ # We can then compare them with each other and also with past states
- main.step( "Get the Mastership of each switch from each controller" )
+ main.step( "Check that each switch has a master" )
global mastershipState
- mastershipState = []
+ mastershipState = '[]'
# Assert that each device has a master
- ONOS1MasterNotNull = main.ONOScli1.rolesNotNull()
- ONOS2MasterNotNull = main.ONOScli2.rolesNotNull()
- ONOS3MasterNotNull = main.ONOScli3.rolesNotNull()
- ONOS4MasterNotNull = main.ONOScli4.rolesNotNull()
- ONOS5MasterNotNull = main.ONOScli5.rolesNotNull()
- ONOS6MasterNotNull = main.ONOScli6.rolesNotNull()
- ONOS7MasterNotNull = main.ONOScli7.rolesNotNull()
- rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\
- ONOS3MasterNotNull and ONOS4MasterNotNull and\
- ONOS5MasterNotNull and ONOS6MasterNotNull and\
- ONOS7MasterNotNull
+ rolesNotNull = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].rolesNotNull,
+ name="rolesNotNull-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ rolesNotNull = rolesNotNull and t.result
utilities.assert_equals(
expect=main.TRUE,
actual=rolesNotNull,
onpass="Each device has a master",
onfail="Some devices don't have a master assigned" )
- ONOS1Mastership = main.ONOScli1.roles()
- ONOS2Mastership = main.ONOScli2.roles()
- ONOS3Mastership = main.ONOScli3.roles()
- ONOS4Mastership = main.ONOScli4.roles()
- ONOS5Mastership = main.ONOScli5.roles()
- ONOS6Mastership = main.ONOScli6.roles()
- ONOS7Mastership = main.ONOScli7.roles()
- if "Error" in ONOS1Mastership or not ONOS1Mastership\
- or "Error" in ONOS2Mastership or not ONOS2Mastership\
- or "Error" in ONOS3Mastership or not ONOS3Mastership\
- or "Error" in ONOS4Mastership or not ONOS4Mastership\
- or "Error" in ONOS5Mastership or not ONOS5Mastership\
- or "Error" in ONOS6Mastership or not ONOS6Mastership\
- or "Error" in ONOS7Mastership or not ONOS7Mastership:
- main.log.report( "Error in getting ONOS roles" )
- main.log.warn(
- "ONOS1 mastership response: " +
- repr( ONOS1Mastership ) )
- main.log.warn(
- "ONOS2 mastership response: " +
- repr( ONOS2Mastership ) )
- main.log.warn(
- "ONOS3 mastership response: " +
- repr( ONOS3Mastership ) )
- main.log.warn(
- "ONOS4 mastership response: " +
- repr( ONOS4Mastership ) )
- main.log.warn(
- "ONOS5 mastership response: " +
- repr( ONOS5Mastership ) )
- main.log.warn(
- "ONOS6 mastership response: " +
- repr( ONOS6Mastership ) )
- main.log.warn(
- "ONOS7 mastership response: " +
- repr( ONOS7Mastership ) )
- consistentMastership = main.FALSE
- elif ONOS1Mastership == ONOS2Mastership\
- and ONOS1Mastership == ONOS3Mastership\
- and ONOS1Mastership == ONOS4Mastership\
- and ONOS1Mastership == ONOS5Mastership\
- and ONOS1Mastership == ONOS6Mastership\
- and ONOS1Mastership == ONOS7Mastership:
- mastershipState = ONOS1Mastership
- consistentMastership = main.TRUE
+ main.step( "Get the Mastership of each switch from each controller" )
+ ONOSMastership = []
+ mastershipCheck = main.FALSE
+ consistentMastership = True
+ rolesResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].roles,
+ name="roles-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSMastership.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " roles" )
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " mastership response: " +
+ repr( ONOSMastership[i] ) )
+ rolesResults = False
+ utilities.assert_equals(
+ expect=True,
+ actual=rolesResults,
+ onpass="No error in reading roles output",
+ onfail="Error in reading roles from ONOS" )
+
+ main.step( "Check for consistency in roles from each controller" )
+ if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
main.log.report(
"Switch roles are consistent across all ONOS nodes" )
else:
- main.log.warn(
- "ONOS1 roles: ",
- json.dumps(
- json.loads( ONOS1Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS2 roles: ",
- json.dumps(
- json.loads( ONOS2Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS3 roles: ",
- json.dumps(
- json.loads( ONOS3Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS4 roles: ",
- json.dumps(
- json.loads( ONOS4Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS5 roles: ",
- json.dumps(
- json.loads( ONOS5Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS6 roles: ",
- json.dumps(
- json.loads( ONOS6Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS7 roles: ",
- json.dumps(
- json.loads( ONOS7Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- consistentMastership = main.FALSE
+ consistentMastership = False
utilities.assert_equals(
- expect=main.TRUE,
+ expect=True,
actual=consistentMastership,
onpass="Switch roles are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of switch roles" )
+ if rolesResults and not consistentMastership:
+ for i in range( numControllers ):
+ try:
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " roles: ",
+ json.dumps(
+ json.loads( ONOSMastership[ i ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( ONOSMastership[ i ] ) )
+ elif rolesResults and consistentMastership:
+ mastershipCheck = main.TRUE
+ mastershipState = ONOSMastership[ 0 ]
+
main.step( "Get the intents from each controller" )
global intentState
intentState = []
- ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
- ONOS2Intents = main.ONOScli2.intents( jsonFormat=True )
- ONOS3Intents = main.ONOScli3.intents( jsonFormat=True )
- ONOS4Intents = main.ONOScli4.intents( jsonFormat=True )
- ONOS5Intents = main.ONOScli5.intents( jsonFormat=True )
- ONOS6Intents = main.ONOScli6.intents( jsonFormat=True )
- ONOS7Intents = main.ONOScli7.intents( jsonFormat=True )
+ ONOSIntents = []
intentCheck = main.FALSE
- if "Error" in ONOS1Intents or not ONOS1Intents\
- or "Error" in ONOS2Intents or not ONOS2Intents\
- or "Error" in ONOS3Intents or not ONOS3Intents\
- or "Error" in ONOS4Intents or not ONOS4Intents\
- or "Error" in ONOS5Intents or not ONOS5Intents\
- or "Error" in ONOS6Intents or not ONOS6Intents\
- or "Error" in ONOS7Intents or not ONOS7Intents:
- main.log.report( "Error in getting ONOS intents" )
- main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
- main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) )
- main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) )
- main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) )
- main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) )
- main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) )
- main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) )
- elif ONOS1Intents == ONOS2Intents\
- and ONOS1Intents == ONOS3Intents\
- and ONOS1Intents == ONOS4Intents\
- and ONOS1Intents == ONOS5Intents\
- and ONOS1Intents == ONOS6Intents\
- and ONOS1Intents == ONOS7Intents:
- intentState = ONOS1Intents
- intentCheck = main.TRUE
- main.log.report( "Intents are consistent across all ONOS nodes" )
- else:
- main.log.warn(
- "ONOS1 intents: ",
- json.dumps(
- json.loads( ONOS1Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS2 intents: ",
- json.dumps(
- json.loads( ONOS2Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS3 intents: ",
- json.dumps(
- json.loads( ONOS3Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS4 intents: ",
- json.dumps(
- json.loads( ONOS4Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS5 intents: ",
- json.dumps(
- json.loads( ONOS5Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS6 intents: ",
- json.dumps(
- json.loads( ONOS6Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS7 intents: ",
- json.dumps(
- json.loads( ONOS7Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
+ consistentIntents = True
+ intentsResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].intents,
+ name="intents-" + str( i ),
+ args=[],
+ kwargs={ 'jsonFormat': True } )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSIntents.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " intents" )
+ main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
+ repr( ONOSIntents[ i ] ) )
+ intentsResults = False
utilities.assert_equals(
- expect=main.TRUE,
- actual=intentCheck,
+ expect=True,
+ actual=intentsResults,
+ onpass="No error in reading intents output",
+ onfail="Error in reading intents from ONOS" )
+
+ main.step( "Check for consistency in Intents from each controller" )
+ if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
+ main.log.report( "Intents are consistent across all ONOS " +
+ "nodes" )
+ else:
+ consistentIntents = False
+ main.log.report( "Intents not consistent" )
+ utilities.assert_equals(
+ expect=True,
+ actual=consistentIntents,
onpass="Intents are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of intents" )
+ if intentsResults:
+ # Try to make it easy to figure out what is happening
+ #
+ # Intent ONOS1 ONOS2 ...
+ # 0x01 INSTALLED INSTALLING
+ # ... ... ...
+ # ... ... ...
+ title = " Id"
+ for n in range( numControllers ):
+ title += " " * 10 + "ONOS" + str( n + 1 )
+ main.log.warn( title )
+ # get all intent keys in the cluster
+ keys = []
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ keys.append( intent.get( 'id' ) )
+ keys = set( keys )
+ for key in keys:
+ row = "%-13s" % key
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ if intent.get( 'id', "Error" ) == key:
+ row += "%-15s" % intent.get( 'state' )
+ main.log.warn( row )
+ # End table view
+
+ if intentsResults and not consistentIntents:
+ # print the json objects
+ n = len(ONOSIntents)
+ main.log.debug( "ONOS" + str( n ) + " intents: " )
+ main.log.debug( json.dumps( json.loads( ONOSIntents[ -1 ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ for i in range( numControllers ):
+ if ONOSIntents[ i ] != ONOSIntents[ -1 ]:
+ main.log.debug( "ONOS" + str( i + 1 ) + " intents: " )
+ main.log.debug( json.dumps( json.loads( ONOSIntents[i] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ else:
+ main.log.debug( nodes[ i ].name + " intents match ONOS" +
+ str( n ) + " intents" )
+ elif intentsResults and consistentIntents:
+ intentCheck = main.TRUE
+ intentState = ONOSIntents[ 0 ]
+
main.step( "Get the flows from each controller" )
global flowState
flowState = []
- ONOS1Flows = main.ONOScli1.flows( jsonFormat=True )
- ONOS2Flows = main.ONOScli2.flows( jsonFormat=True )
- ONOS3Flows = main.ONOScli3.flows( jsonFormat=True )
- ONOS4Flows = main.ONOScli4.flows( jsonFormat=True )
- ONOS5Flows = main.ONOScli5.flows( jsonFormat=True )
- ONOS6Flows = main.ONOScli6.flows( jsonFormat=True )
- ONOS7Flows = main.ONOScli7.flows( jsonFormat=True )
- ONOS1FlowsJson = json.loads( ONOS1Flows )
- ONOS2FlowsJson = json.loads( ONOS2Flows )
- ONOS3FlowsJson = json.loads( ONOS3Flows )
- ONOS4FlowsJson = json.loads( ONOS4Flows )
- ONOS5FlowsJson = json.loads( ONOS5Flows )
- ONOS6FlowsJson = json.loads( ONOS6Flows )
- ONOS7FlowsJson = json.loads( ONOS7Flows )
+ ONOSFlows = []
+ ONOSFlowsJson = []
flowCheck = main.FALSE
- if "Error" in ONOS1Flows or not ONOS1Flows\
- or "Error" in ONOS2Flows or not ONOS2Flows\
- or "Error" in ONOS3Flows or not ONOS3Flows\
- or "Error" in ONOS4Flows or not ONOS4Flows\
- or "Error" in ONOS5Flows or not ONOS5Flows\
- or "Error" in ONOS6Flows or not ONOS6Flows\
- or "Error" in ONOS7Flows or not ONOS7Flows:
- main.log.report( "Error in getting ONOS intents" )
- main.log.warn( "ONOS1 flows repsponse: " + ONOS1Flows )
- main.log.warn( "ONOS2 flows repsponse: " + ONOS2Flows )
- main.log.warn( "ONOS3 flows repsponse: " + ONOS3Flows )
- main.log.warn( "ONOS4 flows repsponse: " + ONOS4Flows )
- main.log.warn( "ONOS5 flows repsponse: " + ONOS5Flows )
- main.log.warn( "ONOS6 flows repsponse: " + ONOS6Flows )
- main.log.warn( "ONOS7 flows repsponse: " + ONOS7Flows )
- elif len( ONOS1FlowsJson ) == len( ONOS2FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS3FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS4FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS5FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS6FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS7FlowsJson ):
- # TODO: Do a better check, maybe compare flows on switches?
- flowState = ONOS1Flows
- flowCheck = main.TRUE
+ consistentFlows = True
+ flowsResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].flows,
+ name="flows-" + str( i ),
+ args=[],
+ kwargs={ 'jsonFormat': True } )
+ threads.append( t )
+ t.start()
+
+ # NOTE: Flows command can take some time to run
+ time.sleep(30)
+ for t in threads:
+ t.join()
+ result = t.result
+ ONOSFlows.append( result )
+
+ for i in range( numControllers ):
+ num = str( i + 1 )
+ if not ONOSFlows[ i ] or "Error" in ONOSFlows[ i ]:
+ main.log.report( "Error in getting ONOS" + num + " flows" )
+ main.log.warn( "ONOS" + num + " flows response: " +
+ repr( ONOSFlows[ i ] ) )
+ flowsResults = False
+ ONOSFlowsJson.append( None )
+ else:
+ try:
+ ONOSFlowsJson.append( json.loads( ONOSFlows[ i ] ) )
+ except ( ValueError, TypeError ):
+ # FIXME: change this to log.error?
+ main.log.exception( "Error in parsing ONOS" + num +
+ " response as json." )
+ main.log.error( repr( ONOSFlows[ i ] ) )
+ ONOSFlowsJson.append( None )
+ flowsResults = False
+ utilities.assert_equals(
+ expect=True,
+ actual=flowsResults,
+ onpass="No error in reading flows output",
+ onfail="Error in reading flows from ONOS" )
+
+ main.step( "Check for consistency in Flows from each controller" )
+ tmp = [ len( i ) == len( ONOSFlowsJson[ 0 ] ) for i in ONOSFlowsJson ]
+ if all( tmp ):
main.log.report( "Flow count is consistent across all ONOS nodes" )
else:
- main.log.warn( "ONOS1 flows: " +
- json.dumps( ONOS1FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS2 flows: " +
- json.dumps( ONOS2FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS3 flows: " +
- json.dumps( ONOS3FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS4 flows: " +
- json.dumps( ONOS4FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS5 flows: " +
- json.dumps( ONOS5FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS6 flows: " +
- json.dumps( ONOS6FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS7 flows: " +
- json.dumps( ONOS7FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
+ consistentFlows = False
utilities.assert_equals(
- expect=main.TRUE,
- actual=flowCheck,
+ expect=True,
+ actual=consistentFlows,
onpass="The flow count is consistent across all ONOS nodes",
onfail="ONOS nodes have different flow counts" )
+ if flowsResults and not consistentFlows:
+ for i in range( numControllers ):
+ try:
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " flows: " +
+ json.dumps( json.loads( ONOSFlows[i] ), sort_keys=True,
+ indent=4, separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " flows: " +
+ repr( ONOSFlows[ i ] ) )
+ elif flowsResults and consistentFlows:
+ flowCheck = main.TRUE
+ flowState = ONOSFlows[ 0 ]
+
main.step( "Get the OF Table entries" )
global flows
flows = []
for i in range( 1, 29 ):
flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) )
-
+ if flowCheck == main.FALSE:
+ for table in flows:
+ main.log.warn( table )
# TODO: Compare switch flow tables with ONOS flow tables
main.step( "Start continuous pings" )
@@ -872,73 +1329,84 @@
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
+ for node in nodes:
+ temp = ( node, node.name, node.ip_address, 6633 )
+ ctrls.append( temp )
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
main.step( "Collecting topology information from ONOS" )
devices = []
- devices.append( main.ONOScli1.devices() )
- devices.append( main.ONOScli2.devices() )
- devices.append( main.ONOScli3.devices() )
- devices.append( main.ONOScli4.devices() )
- devices.append( main.ONOScli5.devices() )
- devices.append( main.ONOScli6.devices() )
- devices.append( main.ONOScli7.devices() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].devices,
+ name="devices-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ devices.append( t.result )
hosts = []
- hosts.append( main.ONOScli1.hosts() )
- hosts.append( main.ONOScli2.hosts() )
- hosts.append( main.ONOScli3.hosts() )
- hosts.append( main.ONOScli4.hosts() )
- hosts.append( main.ONOScli5.hosts() )
- hosts.append( main.ONOScli6.hosts() )
- hosts.append( main.ONOScli7.hosts() )
- for controller in range( 0, len( hosts ) ):
- controllerStr = str( controller + 1 )
- for host in hosts[ controller ]:
- if host[ 'ips' ] == []:
- main.log.error( "DEBUG:Error with host ips on controller" +
- controllerStr + ": " + str( host ) )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].hosts,
+ name="hosts-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ try:
+ hosts.append( json.loads( t.result ) )
+ except ( ValueError, TypeError ):
+ # FIXME: better handling of this, print which node
+ # Maybe use thread name?
+ main.log.exception( "Error parsing json output of hosts" )
+ # FIXME: should this be an empty json object instead?
+ hosts.append( None )
+
ports = []
- ports.append( main.ONOScli1.ports() )
- ports.append( main.ONOScli2.ports() )
- ports.append( main.ONOScli3.ports() )
- ports.append( main.ONOScli4.ports() )
- ports.append( main.ONOScli5.ports() )
- ports.append( main.ONOScli6.ports() )
- ports.append( main.ONOScli7.ports() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].ports,
+ name="ports-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ports.append( t.result )
links = []
- links.append( main.ONOScli1.links() )
- links.append( main.ONOScli2.links() )
- links.append( main.ONOScli3.links() )
- links.append( main.ONOScli4.links() )
- links.append( main.ONOScli5.links() )
- links.append( main.ONOScli6.links() )
- links.append( main.ONOScli7.links() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].links,
+ name="links-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ links.append( t.result )
clusters = []
- clusters.append( main.ONOScli1.clusters() )
- clusters.append( main.ONOScli2.clusters() )
- clusters.append( main.ONOScli3.clusters() )
- clusters.append( main.ONOScli4.clusters() )
- clusters.append( main.ONOScli5.clusters() )
- clusters.append( main.ONOScli6.clusters() )
- clusters.append( main.ONOScli7.clusters() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].clusters,
+ name="clusters-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ clusters.append( t.result )
# Compare json objects for hosts and dataplane clusters
# hosts
+ main.step( "Host view is consistent across ONOS nodes" )
consistentHostsResult = main.TRUE
for controller in range( len( hosts ) ):
controllerStr = str( controller + 1 )
@@ -965,15 +1433,31 @@
onpass="Hosts view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of hosts" )
+ main.step( "Each host has an IP address" )
+ ipResult = main.TRUE
+ for controller in range( 0, len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ for host in hosts[ controller ]:
+ if not host.get( 'ipAddresses', [ ] ):
+ main.log.error( "DEBUG:Error with host ips on controller" +
+ controllerStr + ": " + str( host ) )
+ ipResult = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=ipResult,
+ onpass="The ips of the hosts aren't empty",
+ onfail="The ip of at least one host is missing" )
+
# Strongly connected clusters of devices
+ main.step( "Cluster view is consistent across ONOS nodes" )
consistentClustersResult = main.TRUE
for controller in range( len( clusters ) ):
+ controllerStr = str( controller + 1 )
if "Error" not in clusters[ controller ]:
if clusters[ controller ] == clusters[ 0 ]:
continue
else: # clusters not consistent
- main.log.report( "clusters from ONOS" +
- controllerStr +
+ main.log.report( "clusters from ONOS" + controllerStr +
" is inconsistent with ONOS1" )
consistentClustersResult = main.FALSE
@@ -990,14 +1474,20 @@
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
# there should always only be one cluster
- numClusters = len( json.loads( clusters[ 0 ] ) )
+ main.step( "Cluster view correct across ONOS nodes" )
+ try:
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing clusters[0]: " +
+ repr( clusters[ 0 ] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
utilities.assert_equals(
expect=1,
actual=numClusters,
onpass="ONOS shows 1 SCC",
- onfail="ONOS shows " +
- str( numClusters ) +
- " SCCs" )
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
@@ -1008,207 +1498,229 @@
if devices[ controller ] or "Error" not in devices[ controller ]:
currentDevicesResult = main.Mininet1.compareSwitches(
MNTopo,
- json.loads(
- devices[ controller ] ) )
+ json.loads( devices[ controller ] ) )
else:
currentDevicesResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentDevicesResult,
- onpass="ONOS" + controllerStr +
- " Switches view is correct",
- onfail="ONOS" + controllerStr +
- " Switches view is incorrect" )
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
if ports[ controller ] or "Error" not in ports[ controller ]:
currentPortsResult = main.Mininet1.comparePorts(
MNTopo,
- json.loads(
- ports[ controller ] ) )
+ json.loads( ports[ controller ] ) )
else:
currentPortsResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentPortsResult,
- onpass="ONOS" + controllerStr +
- " ports view is correct",
- onfail="ONOS" + controllerStr +
- " ports view is incorrect" )
+ actual=currentPortsResult,
+ onpass="ONOS" + controllerStr +
+ " ports view is correct",
+ onfail="ONOS" + controllerStr +
+ " ports view is incorrect" )
if links[ controller ] or "Error" not in links[ controller ]:
currentLinksResult = main.Mininet1.compareLinks(
MNTopo,
- json.loads(
- links[ controller ] ) )
+ json.loads( links[ controller ] ) )
else:
currentLinksResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentLinksResult,
- onpass="ONOS" + controllerStr +
- " links view is correct",
- onfail="ONOS" + controllerStr +
- " links view is incorrect" )
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
devicesResults = devicesResults and currentDevicesResult
portsResults = portsResults and currentPortsResult
linksResults = linksResults and currentLinksResult
- topoResult = devicesResults and portsResults and linksResults\
- and consistentHostsResult and consistentClustersResult
+ topoResult = ( devicesResults and portsResults and linksResults
+ and consistentHostsResult and consistentClustersResult
+ and clusterResults and ipResult )
utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
-
- finalAssert = main.TRUE
- finalAssert = finalAssert and topoResult and flowCheck \
- and intentCheck and consistentMastership and rolesNotNull
- utilities.assert_equals( expect=main.TRUE, actual=finalAssert,
- onpass="State check successful",
- onfail="State check NOT successful" )
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
def CASE6( self, main ):
"""
The Failure case.
"""
import time
- main.log.report( "Killing 3 ONOS nodes" )
- main.log.case( "Restart minority of ONOS nodes" )
- # TODO: Randomize these nodes
- main.ONOSbench.onosKill( ONOS1Ip )
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ main.case( "Restart minority of ONOS nodes" )
+ main.step( "Killing 3 ONOS nodes" )
+ killTime = time.time()
+ # TODO: Randomize these nodes or base this on partitions
+ # TODO: use threads in this case
+ killResults = main.ONOSbench.onosKill( nodes[0].ip_address )
time.sleep( 10 )
- main.ONOSbench.onosKill( ONOS2Ip )
+ killResults = killResults and\
+ main.ONOSbench.onosKill( nodes[1].ip_address )
time.sleep( 10 )
- main.ONOSbench.onosKill( ONOS3Ip )
+ killResults = killResults and\
+ main.ONOSbench.onosKill( nodes[2].ip_address )
+ utilities.assert_equals( expect=main.TRUE, actual=killResults,
+ onpass="ONOS Killed successfully",
+ onfail="ONOS kill NOT successful" )
main.step( "Checking if ONOS is up yet" )
count = 0
onosIsupResult = main.FALSE
while onosIsupResult == main.FALSE and count < 10:
- onos1Isup = main.ONOSbench.isup( ONOS1Ip )
- onos2Isup = main.ONOSbench.isup( ONOS2Ip )
- onos3Isup = main.ONOSbench.isup( ONOS3Ip )
+ onos1Isup = main.ONOSbench.isup( nodes[0].ip_address )
+ onos2Isup = main.ONOSbench.isup( nodes[1].ip_address )
+ onos3Isup = main.ONOSbench.isup( nodes[2].ip_address )
onosIsupResult = onos1Isup and onos2Isup and onos3Isup
count = count + 1
# TODO: if it becomes an issue, we can retry this step a few times
+ utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult,
+ onpass="ONOS restarted successfully",
+ onfail="ONOS restart NOT successful" )
- cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip )
- cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip )
- cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip )
+ main.step( "Restarting ONOS CLIs" )
+ cliResult1 = main.ONOScli1.startOnosCli( nodes[0].ip_address )
+ cliResult2 = main.ONOScli2.startOnosCli( nodes[1].ip_address )
+ cliResult3 = main.ONOScli3.startOnosCli( nodes[2].ip_address )
cliResults = cliResult1 and cliResult2 and cliResult3
+ utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+ onpass="ONOS cli restarted",
+ onfail="ONOS cli did not restart" )
- main.log.info( "Install leadership election app on restarted node" )
-
- caseResults = main.TRUE and onosIsupResult and cliResults
- utilities.assert_equals( expect=main.TRUE, actual=caseResults,
- onpass="ONOS restart successful",
- onfail="ONOS restart NOT successful" )
+ # Grab the time of restart so we chan check how long the gossip
+ # protocol has had time to work
+ main.restartTime = time.time() - killTime
+ main.log.debug( "Restart time: " + str( main.restartTime ) )
+ '''
+ # FIXME: revisit test plan for election with madan
+ # Rerun for election on restarted nodes
+ run1 = CLIs[0].electionTestRun()
+ run2 = CLIs[1].electionTestRun()
+ run3 = CLIs[2].electionTestRun()
+ runResults = run1 and run2 and run3
+ utilities.assert_equals( expect=main.TRUE, actual=runResults,
+ onpass="Reran for election",
+ onfail="Failed to rerun for election" )
+ '''
+ # TODO: MAke this configurable. Also, we are breaking the above timer
+ time.sleep( 60 )
+ main.log.debug( CLIs[0].nodes( jsonFormat=False ) )
+ main.log.debug( CLIs[0].leaders( jsonFormat=False ) )
+ main.log.debug( CLIs[0].partitions( jsonFormat=False ) )
+ time.sleep( 200 )
+ main.log.debug( CLIs[0].nodes( jsonFormat=False ) )
+ main.log.debug( CLIs[0].leaders( jsonFormat=False ) )
+ main.log.debug( CLIs[0].partitions( jsonFormat=False ) )
def CASE7( self, main ):
"""
Check state after ONOS failure
"""
import json
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
main.case( "Running ONOS Constant State Tests" )
+ main.step( "Check that each switch has a master" )
# Assert that each device has a master
- ONOS1MasterNotNull = main.ONOScli1.rolesNotNull()
- ONOS2MasterNotNull = main.ONOScli2.rolesNotNull()
- ONOS3MasterNotNull = main.ONOScli3.rolesNotNull()
- ONOS4MasterNotNull = main.ONOScli4.rolesNotNull()
- ONOS5MasterNotNull = main.ONOScli5.rolesNotNull()
- ONOS6MasterNotNull = main.ONOScli6.rolesNotNull()
- ONOS7MasterNotNull = main.ONOScli7.rolesNotNull()
- rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\
- ONOS3MasterNotNull and ONOS4MasterNotNull and\
- ONOS5MasterNotNull and ONOS6MasterNotNull and\
- ONOS7MasterNotNull
+ rolesNotNull = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].rolesNotNull,
+ name="rolesNotNull-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ rolesNotNull = rolesNotNull and t.result
utilities.assert_equals(
expect=main.TRUE,
actual=rolesNotNull,
onpass="Each device has a master",
onfail="Some devices don't have a master assigned" )
- main.step( "Check if switch roles are consistent across all nodes" )
- ONOS1Mastership = main.ONOScli1.roles()
- ONOS2Mastership = main.ONOScli2.roles()
- ONOS3Mastership = main.ONOScli3.roles()
- ONOS4Mastership = main.ONOScli4.roles()
- ONOS5Mastership = main.ONOScli5.roles()
- ONOS6Mastership = main.ONOScli6.roles()
- ONOS7Mastership = main.ONOScli7.roles()
- # print json.dumps( json.loads( ONOS1Mastership ), sort_keys=True,
- # indent=4, separators=( ',', ': ' ) )
- if "Error" in ONOS1Mastership or not ONOS1Mastership\
- or "Error" in ONOS2Mastership or not ONOS2Mastership\
- or "Error" in ONOS3Mastership or not ONOS3Mastership\
- or "Error" in ONOS4Mastership or not ONOS4Mastership\
- or "Error" in ONOS5Mastership or not ONOS5Mastership\
- or "Error" in ONOS6Mastership or not ONOS6Mastership\
- or "Error" in ONOS7Mastership or not ONOS7Mastership:
- main.log.error( "Error in getting ONOS mastership" )
- main.log.warn( "ONOS1 mastership response: " +
- repr( ONOS1Mastership ) )
- main.log.warn( "ONOS2 mastership response: " +
- repr( ONOS2Mastership ) )
- main.log.warn( "ONOS3 mastership response: " +
- repr( ONOS3Mastership ) )
- main.log.warn( "ONOS4 mastership response: " +
- repr( ONOS4Mastership ) )
- main.log.warn( "ONOS5 mastership response: " +
- repr( ONOS5Mastership ) )
- main.log.warn( "ONOS6 mastership response: " +
- repr( ONOS6Mastership ) )
- main.log.warn( "ONOS7 mastership response: " +
- repr( ONOS7Mastership ) )
- consistentMastership = main.FALSE
- elif ONOS1Mastership == ONOS2Mastership\
- and ONOS1Mastership == ONOS3Mastership\
- and ONOS1Mastership == ONOS4Mastership\
- and ONOS1Mastership == ONOS5Mastership\
- and ONOS1Mastership == ONOS6Mastership\
- and ONOS1Mastership == ONOS7Mastership:
- consistentMastership = main.TRUE
+ main.step( "Read device roles from ONOS" )
+ ONOSMastership = []
+ consistentMastership = True
+ rolesResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].roles,
+ name="roles-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSMastership.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " roles" )
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " mastership response: " +
+ repr( ONOSMastership[i] ) )
+ rolesResults = False
+ utilities.assert_equals(
+ expect=True,
+ actual=rolesResults,
+ onpass="No error in reading roles output",
+ onfail="Error in reading roles from ONOS" )
+
+ main.step( "Check for consistency in roles from each controller" )
+ if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
main.log.report(
"Switch roles are consistent across all ONOS nodes" )
else:
- main.log.warn( "ONOS1 roles: ", json.dumps(
- json.loads( ONOS1Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS2 roles: ", json.dumps(
- json.loads( ONOS2Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS3 roles: ", json.dumps(
- json.loads( ONOS3Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS4 roles: ", json.dumps(
- json.loads( ONOS4Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS5 roles: ", json.dumps(
- json.loads( ONOS5Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS6 roles: ", json.dumps(
- json.loads( ONOS6Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS7 roles: ", json.dumps(
- json.loads( ONOS7Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- consistentMastership = main.FALSE
+ consistentMastership = False
utilities.assert_equals(
- expect=main.TRUE,
+ expect=True,
actual=consistentMastership,
onpass="Switch roles are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of switch roles" )
+ if rolesResults and not consistentMastership:
+ for i in range( numControllers ):
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " roles: ",
+ json.dumps(
+ json.loads( ONOSMastership[ i ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+
+ # NOTE: we expect mastership to change on controller failure
+ '''
description2 = "Compare switch roles from before failure"
main.step( description2 )
-
- currentJson = json.loads( ONOS1Mastership )
- oldJson = json.loads( mastershipState )
+ try:
+ currentJson = json.loads( ONOSMastership[0] )
+ oldJson = json.loads( mastershipState )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Something is wrong with parsing " +
+ "ONOSMastership[0] or mastershipState" )
+ main.log.error( "ONOSMastership[0]: " + repr( ONOSMastership[0] ) )
+ main.log.error( "mastershipState" + repr( mastershipState ) )
+ main.cleanup()
+ main.exit()
mastershipCheck = main.TRUE
for i in range( 1, 29 ):
switchDPID = str(
- main.Mininet1.getSwitchDPID(
- switch="s" +
- str( i ) ) )
-
+ main.Mininet1.getSwitchDPID( switch="s" + str( i ) ) )
current = [ switch[ 'master' ] for switch in currentJson
if switchDPID in switch[ 'id' ] ]
old = [ switch[ 'master' ] for switch in oldJson
@@ -1218,94 +1730,128 @@
else:
main.log.warn( "Mastership of switch %s changed" % switchDPID )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Mastership of Switches was not changed" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
onpass="Mastership of Switches was not changed",
onfail="Mastership of some switches changed" )
- # NOTE: we expect mastership to change on controller failure
- mastershipCheck = consistentMastership
+ '''
main.step( "Get the intents and compare across all nodes" )
- ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
- ONOS2Intents = main.ONOScli2.intents( jsonFormat=True )
- ONOS3Intents = main.ONOScli3.intents( jsonFormat=True )
- ONOS4Intents = main.ONOScli4.intents( jsonFormat=True )
- ONOS5Intents = main.ONOScli5.intents( jsonFormat=True )
- ONOS6Intents = main.ONOScli6.intents( jsonFormat=True )
- ONOS7Intents = main.ONOScli7.intents( jsonFormat=True )
+ ONOSIntents = []
intentCheck = main.FALSE
- if "Error" in ONOS1Intents or not ONOS1Intents\
- or "Error" in ONOS2Intents or not ONOS2Intents\
- or "Error" in ONOS3Intents or not ONOS3Intents\
- or "Error" in ONOS4Intents or not ONOS4Intents\
- or "Error" in ONOS5Intents or not ONOS5Intents\
- or "Error" in ONOS6Intents or not ONOS6Intents\
- or "Error" in ONOS7Intents or not ONOS7Intents:
- main.log.report( "Error in getting ONOS intents" )
- main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
- main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) )
- main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) )
- main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) )
- main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) )
- main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) )
- main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) )
- elif ONOS1Intents == ONOS2Intents\
- and ONOS1Intents == ONOS3Intents\
- and ONOS1Intents == ONOS4Intents\
- and ONOS1Intents == ONOS5Intents\
- and ONOS1Intents == ONOS6Intents\
- and ONOS1Intents == ONOS7Intents:
- intentCheck = main.TRUE
- main.log.report( "Intents are consistent across all ONOS nodes" )
- else:
- main.log.warn( "ONOS1 intents: " )
- print json.dumps( json.loads( ONOS1Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS2 intents: " )
- print json.dumps( json.loads( ONOS2Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS3 intents: " )
- print json.dumps( json.loads( ONOS3Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS4 intents: " )
- print json.dumps( json.loads( ONOS4Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS5 intents: " )
- print json.dumps( json.loads( ONOS5Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS6 intents: " )
- print json.dumps( json.loads( ONOS6Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS7 intents: " )
- print json.dumps( json.loads( ONOS7Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
+ consistentIntents = True
+ intentsResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].intents,
+ name="intents-" + str( i ),
+ args=[],
+ kwargs={ 'jsonFormat': True } )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSIntents.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " intents" )
+ main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
+ repr( ONOSIntents[ i ] ) )
+ intentsResults = False
utilities.assert_equals(
- expect=main.TRUE,
- actual=intentCheck,
+ expect=True,
+ actual=intentsResults,
+ onpass="No error in reading intents output",
+ onfail="Error in reading intents from ONOS" )
+
+ main.step( "Check for consistency in Intents from each controller" )
+ if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
+ main.log.report( "Intents are consistent across all ONOS " +
+ "nodes" )
+ else:
+ consistentIntents = False
+
+ # Try to make it easy to figure out what is happening
+ #
+ # Intent ONOS1 ONOS2 ...
+ # 0x01 INSTALLED INSTALLING
+ # ... ... ...
+ # ... ... ...
+ title = " ID"
+ for n in range( numControllers ):
+ title += " " * 10 + "ONOS" + str( n + 1 )
+ main.log.warn( title )
+ # get all intent keys in the cluster
+ keys = []
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ keys.append( intent.get( 'id' ) )
+ keys = set( keys )
+ for key in keys:
+ row = "%-13s" % key
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ if intent.get( 'id' ) == key:
+ row += "%-15s" % intent.get( 'state' )
+ main.log.warn( row )
+ # End table view
+
+ utilities.assert_equals(
+ expect=True,
+ actual=consistentIntents,
onpass="Intents are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of intents" )
+ intentStates = []
+ for node in ONOSIntents: # Iter through ONOS nodes
+ nodeStates = []
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( node ):
+ nodeStates.append( intent[ 'state' ] )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error in parsing intents" )
+ main.log.error( repr( node ) )
+ intentStates.append( nodeStates )
+ out = [ (i, nodeStates.count( i ) ) for i in set( nodeStates ) ]
+ main.log.info( dict( out ) )
- # NOTE: Hazelcast has no durability, so intents are lost across system
- # restarts
+ if intentsResults and not consistentIntents:
+ for i in range( numControllers ):
+ main.log.warn( "ONOS" + str( i + 1 ) + " intents: " )
+ main.log.warn( json.dumps(
+ json.loads( ONOSIntents[ i ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ elif intentsResults and consistentIntents:
+ intentCheck = main.TRUE
+
+ # NOTE: Store has no durability, so intents are lost across system
+ # restarts
main.step( "Compare current intents with intents before the failure" )
# NOTE: this requires case 5 to pass for intentState to be set.
# maybe we should stop the test if that fails?
- if intentState == ONOS1Intents:
+ sameIntents = main.TRUE
+ if intentState and intentState == ONOSIntents[ 0 ]:
sameIntents = main.TRUE
- main.log.report( "Intents are consistent with before failure" )
+ main.log.info( "Intents are consistent with before failure" )
# TODO: possibly the states have changed? we may need to figure out
- # what the aceptable states are
+ # what the acceptable states are
else:
try:
- main.log.warn( "ONOS1 intents: " )
- print json.dumps( json.loads( ONOS1Intents ),
- sort_keys=True, indent=4,
- separators=( ',', ': ' ) )
- except:
- pass
+ main.log.warn( "ONOS intents: " )
+ main.log.warn( json.dumps( json.loads( ONOSIntents[ 0 ] ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Exception printing intents" )
+ main.log.warn( repr( ONOSIntents[0] ) )
sameIntents = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
@@ -1329,8 +1875,6 @@
if FlowTables == main.FALSE:
main.log.info( "Differences in flow table for switch: s" +
str( i + 1 ) )
- if FlowTables == main.TRUE:
- main.log.report( "No changes were found in the flow tables" )
utilities.assert_equals(
expect=main.TRUE,
actual=FlowTables,
@@ -1339,12 +1883,8 @@
main.step( "Check the continuous pings to ensure that no packets " +
"were dropped during component failure" )
- # FIXME: This check is always failing. Investigate cause
- # NOTE: this may be something to do with file permsissions
- # or slight change in format
- main.Mininet2.pingKill(
- main.params[ 'TESTONUSER' ],
- main.params[ 'TESTONIP' ] )
+ main.Mininet2.pingKill( main.params[ 'TESTONUSER' ],
+ main.params[ 'TESTONIP' ] )
LossInPings = main.FALSE
# NOTE: checkForLoss returns main.FALSE with 0% packet loss
for i in range( 8, 18 ):
@@ -1367,29 +1907,30 @@
onpass="No Loss of connectivity",
onfail="Loss of dataplane connectivity detected" )
+ main.step( "Leadership Election is still functional" )
# Test of LeadershipElection
leaderList = []
+ # FIXME: make sure this matches nodes that were restarted
+ restarted = [ nodes[0].ip_address, nodes[1].ip_address,
+ nodes[2].ip_address ]
+
leaderResult = main.TRUE
- for controller in range( 1, numControllers + 1 ):
- # loop through ONOScli handlers
- node = getattr( main, ( 'ONOScli' + str( controller ) ) )
- leaderN = node.electionTestLeader()
+ for cli in CLIs:
+ leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == main.FALSE:
- # error in response
+ # error in response
main.log.report( "Something is wrong with " +
"electionTestLeader function, check the" +
" error logs" )
leaderResult = main.FALSE
elif leaderN is None:
- main.log.report( "ONOS" + str( controller ) +
+ main.log.report( cli.name +
" shows no leader for the election-app was" +
" elected after the old one died" )
leaderResult = main.FALSE
- elif leaderN == ONOS1Ip or leaderN == ONOS2Ip or\
- leaderN == ONOS3Ip:
- main.log.report( "ONOS" + str( controller ) +
- " shows " + str( leaderN ) +
+ elif leaderN in restarted:
+ main.log.report( cli.name + " shows " + str( leaderN ) +
" as leader for the election-app, but it " +
"was restarted" )
leaderResult = main.FALSE
@@ -1398,25 +1939,12 @@
main.log.error(
"Inconsistent view of leader for the election test app" )
# TODO: print the list
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was re-elected if applicable )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
onpass="Leadership election passed",
onfail="Something went wrong with Leadership election" )
- result = mastershipCheck and intentCheck and FlowTables and\
- ( not LossInPings ) and rolesNotNull and leaderResult
- result = int( result )
- if result == main.TRUE:
- main.log.report( "Constant State Tests Passed" )
- utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Constant State Tests Passed",
- onfail="Constant state tests failed" )
-
def CASE8( self, main ):
"""
Compare topo
@@ -1428,94 +1956,121 @@
from sts.topology.teston_topology import TestONTopology
import json
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
- description = "Compare ONOS Topology view to Mininet topology"
- main.case( description )
- main.log.report( description )
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplaination = "Compare topology objects between Mininet" +\
+ " and ONOS"
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 ) ] ), )
+ try:
+ ctrls = []
+ for node in nodes:
+ temp = ( node, node.name, node.ip_address, 6633 )
ctrls.append( temp )
- count = count + 1
- else:
- break
- MNTopo = TestONTopology(
- main.Mininet1,
- ctrls ) # can also add Intent API info for intent operations
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
+ except Exception:
+ objResult = main.FALSE
+ else:
+ objResult = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=objResult,
+ onpass="Created TestONTopology object",
+ onfail="Exception while creating " +
+ "TestONTopology object" )
main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
portsResults = main.TRUE
linksResults = main.TRUE
+ hostsResults = main.TRUE
topoResult = main.FALSE
elapsed = 0
count = 0
main.step( "Collecting topology information from ONOS" )
startTime = time.time()
+ # Give time for Gossip to work
while topoResult == main.FALSE and elapsed < 60:
- count = count + 1
+ count += 1
if count > 1:
- # TODO: Depricate STS usage
- MNTopo = TestONTopology(
- main.Mininet1,
- ctrls )
+ # TODO: Deprecate STS usage
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
cliStart = time.time()
devices = []
- devices.append( main.ONOScli1.devices() )
- devices.append( main.ONOScli2.devices() )
- devices.append( main.ONOScli3.devices() )
- devices.append( main.ONOScli4.devices() )
- devices.append( main.ONOScli5.devices() )
- devices.append( main.ONOScli6.devices() )
- devices.append( main.ONOScli7.devices() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].devices,
+ name="devices-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ devices.append( t.result )
hosts = []
- hosts.append( json.loads( main.ONOScli1.hosts() ) )
- hosts.append( json.loads( main.ONOScli2.hosts() ) )
- hosts.append( json.loads( main.ONOScli3.hosts() ) )
- hosts.append( json.loads( main.ONOScli4.hosts() ) )
- hosts.append( json.loads( main.ONOScli5.hosts() ) )
- hosts.append( json.loads( main.ONOScli6.hosts() ) )
- hosts.append( json.loads( main.ONOScli7.hosts() ) )
+ ipResult = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].hosts,
+ name="hosts-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ try:
+ hosts.append( json.loads( t.result ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing hosts results" )
+ main.log.error( repr( t.result ) )
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- host
- if host[ 'ips' ] == []:
+ if host is None or host.get( 'ipAddresses', [] ) == []:
main.log.error(
"DEBUG:Error with host ips on controller" +
controllerStr + ": " + str( host ) )
+ ipResult = main.FALSE
ports = []
- ports.append( main.ONOScli1.ports() )
- ports.append( main.ONOScli2.ports() )
- ports.append( main.ONOScli3.ports() )
- ports.append( main.ONOScli4.ports() )
- ports.append( main.ONOScli5.ports() )
- ports.append( main.ONOScli6.ports() )
- ports.append( main.ONOScli7.ports() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].ports,
+ name="ports-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ports.append( t.result )
links = []
- links.append( main.ONOScli1.links() )
- links.append( main.ONOScli2.links() )
- links.append( main.ONOScli3.links() )
- links.append( main.ONOScli4.links() )
- links.append( main.ONOScli5.links() )
- links.append( main.ONOScli6.links() )
- links.append( main.ONOScli7.links() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].links,
+ name="links-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ links.append( t.result )
clusters = []
- clusters.append( main.ONOScli1.clusters() )
- clusters.append( main.ONOScli2.clusters() )
- clusters.append( main.ONOScli3.clusters() )
- clusters.append( main.ONOScli4.clusters() )
- clusters.append( main.ONOScli5.clusters() )
- clusters.append( main.ONOScli6.clusters() )
- clusters.append( main.ONOScli7.clusters() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].clusters,
+ name="clusters-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ clusters.append( t.result )
elapsed = time.time() - startTime
cliTime = time.time() - cliStart
@@ -1527,51 +2082,63 @@
controller ]:
currentDevicesResult = main.Mininet1.compareSwitches(
MNTopo,
- json.loads(
- devices[ controller ] ) )
+ json.loads( devices[ controller ] ) )
else:
currentDevicesResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentDevicesResult,
- onpass="ONOS" + controllerStr +
- " Switches view is correct",
- onfail="ONOS" + controllerStr +
- " Switches view is incorrect" )
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
if ports[ controller ] or "Error" not in ports[ controller ]:
currentPortsResult = main.Mininet1.comparePorts(
MNTopo,
- json.loads(
- ports[ controller ] ) )
+ json.loads( ports[ controller ] ) )
else:
currentPortsResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentPortsResult,
- onpass="ONOS" + controllerStr +
- " ports view is correct",
- onfail="ONOS" + controllerStr +
- " ports view is incorrect" )
+ actual=currentPortsResult,
+ onpass="ONOS" + controllerStr +
+ " ports view is correct",
+ onfail="ONOS" + controllerStr +
+ " ports view is incorrect" )
if links[ controller ] or "Error" not in links[ controller ]:
currentLinksResult = main.Mininet1.compareLinks(
MNTopo,
- json.loads(
- links[ controller ] ) )
+ json.loads( links[ controller ] ) )
else:
currentLinksResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentLinksResult,
- onpass="ONOS" + controllerStr +
- " links view is correct",
- onfail="ONOS" + controllerStr +
- " links view is incorrect" )
- devicesResults = devicesResults and currentDevicesResult
- portsResults = portsResults and currentPortsResult
- linksResults = linksResults and currentLinksResult
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
+
+ if hosts[ controller ] or "Error" not in hosts[ controller ]:
+ currentHostsResult = main.Mininet1.compareHosts(
+ MNTopo, hosts[ controller ] )
+ else:
+ currentHostsResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentHostsResult,
+ onpass="ONOS" + controllerStr +
+ " hosts exist in Mininet",
+ onfail="ONOS" + controllerStr +
+ " hosts don't match Mininet" )
+
+ devicesResults = devicesResults and currentDevicesResult
+ portsResults = portsResults and currentPortsResult
+ linksResults = linksResults and currentLinksResult
+ hostsResults = hostsResults and currentHostsResult
# Compare json objects for hosts and dataplane clusters
# hosts
+ main.step( "Hosts view is consistent across all ONOS nodes" )
consistentHostsResult = main.TRUE
for controller in range( len( hosts ) ):
controllerStr = str( controller + 1 )
@@ -1598,6 +2165,7 @@
onfail="ONOS nodes have different views of hosts" )
# Strongly connected clusters of devices
+ main.step( "Clusters view is consistent across all ONOS nodes" )
consistentClustersResult = main.TRUE
for controller in range( len( clusters ) ):
controllerStr = str( controller + 1 )
@@ -1623,57 +2191,106 @@
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
# there should always only be one cluster
- numClusters = len( json.loads( clusters[ 0 ] ) )
+ main.step( "Topology view is correct and consistent across all " +
+ "ONOS nodes" )
+ try:
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing clusters[0]: " +
+ repr( clusters[0] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
utilities.assert_equals(
expect=1,
actual=numClusters,
onpass="ONOS shows 1 SCC",
- onfail="ONOS shows " +
- str( numClusters ) +
- " SCCs" )
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
topoResult = ( devicesResults and portsResults and linksResults
- and consistentHostsResult
- and consistentClustersResult )
+ and hostsResults and consistentHostsResult
+ and consistentClustersResult and clusterResults
+ and ipResult )
topoResult = topoResult and int( count <= 2 )
note = "note it takes about " + str( int( cliTime ) ) + \
" seconds for the test to make all the cli calls to fetch " +\
"the topology from each ONOS instance"
- main.log.report(
+ main.log.info(
"Very crass estimate for topology discovery/convergence( " +
str( note ) + " ): " + str( elapsed ) + " seconds, " +
str( count ) + " tries" )
utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
- if topoResult == main.TRUE:
- main.log.report( "ONOS topology view matches Mininet topology" )
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
+
+ # FIXME: move this to an ONOS state case
+ main.step( "Checking ONOS nodes" )
+ nodesOutput = []
+ nodeResults = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].nodes,
+ name="nodes-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ nodesOutput.append( t.result )
+ ips = [ node.ip_address for node in nodes ]
+ for i in nodesOutput:
+ try:
+ current = json.loads( i )
+ for node in current:
+ currentResult = main.FALSE
+ if node['ip'] in ips: # node in nodes() output is in cell
+ if node['state'] == 'ACTIVE':
+ currentResult = main.TRUE
+ else:
+ main.log.error( "Error in ONOS node availability" )
+ main.log.error(
+ json.dumps( current,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ break
+ nodeResults = nodeResults and currentResult
+ except ( ValueError, TypeError ):
+ main.log.error( "Error parsing nodes output" )
+ main.log.warn( repr( i ) )
+ utilities.assert_equals( expect=main.TRUE, actual=nodeResults,
+ onpass="Nodes check successful",
+ onfail="Nodes check NOT successful" )
def CASE9( self, main ):
"""
Link s3-s28 down
"""
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# NOTE: You should probably run a topology check after this
linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
description = "Turn off a link to ensure that Link Discovery " +\
- "is working properly"
+ "is working properly"
main.log.report( description )
main.case( description )
main.step( "Kill Link between s3 and s28" )
LinkDown = main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
- main.log.info(
- "Waiting " +
- str( linkSleep ) +
- " seconds for link down to be discovered" )
+ main.log.info( "Waiting " + str( linkSleep ) +
+ " seconds for link down to be discovered" )
time.sleep( linkSleep )
utilities.assert_equals( expect=main.TRUE, actual=LinkDown,
- onpass="Link down succesful",
- onfail="Failed to bring link down" )
+ onpass="Link down successful",
+ onfail="Failed to bring link down" )
# TODO do some sort of check here
def CASE10( self, main ):
@@ -1681,25 +2298,28 @@
Link s3-s28 up
"""
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# NOTE: You should probably run a topology check after this
linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
description = "Restore a link to ensure that Link Discovery is " + \
- "working properly"
+ "working properly"
main.log.report( description )
main.case( description )
main.step( "Bring link between s3 and s28 back up" )
LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
- main.log.info(
- "Waiting " +
- str( linkSleep ) +
- " seconds for link up to be discovered" )
+ main.log.info( "Waiting " + str( linkSleep ) +
+ " seconds for link up to be discovered" )
time.sleep( linkSleep )
utilities.assert_equals( expect=main.TRUE, actual=LinkUp,
- onpass="Link up succesful",
- onfail="Failed to bring link up" )
+ onpass="Link up successful",
+ onfail="Failed to bring link up" )
# TODO do some sort of check here
def CASE11( self, main ):
@@ -1708,6 +2328,11 @@
"""
# NOTE: You should probably run a topology check after this
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
@@ -1731,8 +2356,8 @@
if device and device[ 'available' ] is False:
result = main.TRUE
utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Kill switch succesful",
- onfail="Failed to kill switch?" )
+ onpass="Kill switch successful",
+ onfail="Failed to kill switch?" )
def CASE12( self, main ):
"""
@@ -1740,6 +2365,18 @@
"""
# NOTE: You should probably run a topology check after this
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
switch = main.params[ 'kill' ][ 'switch' ]
@@ -1752,30 +2389,26 @@
main.step( "Add back " + switch )
main.log.report( "Adding back " + switch )
main.Mininet1.addSwitch( switch, dpid=switchDPID )
- # TODO: New dpid or same? Ask Thomas?
for peer in links:
main.Mininet1.addLink( switch, peer )
- main.Mininet1.assignSwController(
- sw=switch.split( 's' )[ 1 ],
- count=numControllers,
- ip1=ONOS1Ip,
- port1=ONOS1Port,
- ip2=ONOS2Ip,
- port2=ONOS2Port,
- ip3=ONOS3Ip,
- port3=ONOS3Port,
- ip4=ONOS4Ip,
- port4=ONOS4Port,
- ip5=ONOS5Ip,
- port5=ONOS5Port,
- ip6=ONOS6Ip,
- port6=ONOS6Port,
- ip7=ONOS7Ip,
- port7=ONOS7Port )
- main.log.info(
- "Waiting " +
- str( switchSleep ) +
- " seconds for switch up to be discovered" )
+ main.Mininet1.assignSwController( sw=switch.split( 's' )[ 1 ],
+ count=numControllers,
+ ip1=nodes[ 0 ].ip_address,
+ port1=ONOS1Port,
+ ip2=nodes[ 1 ].ip_address,
+ port2=ONOS2Port,
+ ip3=nodes[ 2 ].ip_address,
+ port3=ONOS3Port,
+ ip4=nodes[ 3 ].ip_address,
+ port4=ONOS4Port,
+ ip5=nodes[ 4 ].ip_address,
+ port5=ONOS5Port,
+ ip6=nodes[ 5 ].ip_address,
+ port6=ONOS6Port,
+ ip7=nodes[ 6 ].ip_address,
+ port7=ONOS7Port )
+ main.log.info( "Waiting " + str( switchSleep ) +
+ " seconds for switch up to be discovered" )
time.sleep( switchSleep )
device = main.ONOScli1.getDevice( dpid=switchDPID )
# Peek at the deleted switch
@@ -1784,8 +2417,8 @@
if device and device[ 'available' ]:
result = main.TRUE
utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="add switch succesful",
- onfail="Failed to add switch?" )
+ onpass="add switch successful",
+ onfail="Failed to add switch?" )
def CASE13( self, main ):
"""
@@ -1793,37 +2426,22 @@
"""
import os
import time
- # TODO: make use of this elsewhere
- ips = []
- ips.append( ONOS1Ip )
- ips.append( ONOS2Ip )
- ips.append( ONOS3Ip )
- ips.append( ONOS4Ip )
- ips.append( ONOS5Ip )
- ips.append( ONOS6Ip )
- ips.append( ONOS7Ip )
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# printing colors to terminal
- colors = {}
- colors[ 'cyan' ] = '\033[96m'
- colors[ 'purple' ] = '\033[95m'
- colors[ 'blue' ] = '\033[94m'
- colors[ 'green' ] = '\033[92m'
- colors[ 'yellow' ] = '\033[93m'
- colors[ 'red' ] = '\033[91m'
- colors[ 'end' ] = '\033[0m'
+ colors = { 'cyan': '\033[96m', 'purple': '\033[95m',
+ 'blue': '\033[94m', 'green': '\033[92m',
+ 'yellow': '\033[93m', 'red': '\033[91m', 'end': '\033[0m' }
description = "Test Cleanup"
main.log.report( description )
main.case( description )
main.step( "Killing tcpdumps" )
main.Mininet2.stopTcpdump()
- main.step( "Checking ONOS Logs for errors" )
- for i in range( 7 ):
- print colors[ 'purple' ] + "Checking logs for errors on " + \
- "ONOS" + str( i + 1 ) + ":" + colors[ 'end' ]
- print main.ONOSbench.checkLogs( ips[ i ] )
-
main.step( "Copying MN pcap and ONOS log files to test station" )
testname = main.TEST
teststationUser = main.params[ 'TESTONUSER' ]
@@ -1839,14 +2457,15 @@
# NOTE: must end in /
dstDir = "~/packet_captures/"
for f in logFiles:
- for i in range( 7 ):
- main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" +
- logFolder + f + " " +
+ for node in nodes:
+ main.ONOSbench.handle.sendline( "scp sdn@" + node.ip_address +
+ ":" + logFolder + f + " " +
teststationUser + "@" +
teststationIP + ":" +
dstDir + str( testname ) +
- "-ONOS" + str( i + 1 ) + "-" +
- f )
+ "-" + node.name + "-" + f )
+ main.ONOSbench.handle.expect( "\$" )
+
# std*.log's
# NOTE: must end in /
logFolder = "/opt/onos/var/"
@@ -1854,157 +2473,171 @@
# NOTE: must end in /
dstDir = "~/packet_captures/"
for f in logFiles:
- for i in range( 7 ):
- main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" +
- logFolder + f + " " +
+ for node in nodes:
+ main.ONOSbench.handle.sendline( "scp sdn@" + node.ip_address +
+ ":" + logFolder + f + " " +
teststationUser + "@" +
teststationIP + ":" +
dstDir + str( testname ) +
- "-ONOS" + str( i + 1 ) + "-" +
- f )
+ "-" + node.name + "-" + f )
+ main.ONOSbench.handle.expect( "\$" )
# sleep so scp can finish
time.sleep( 10 )
+
+ main.step( "Stopping Mininet" )
+ mnResult = main.Mininet1.stopNet()
+ utilities.assert_equals( expect=main.TRUE, actual=mnResult,
+ onpass="Mininet stopped",
+ onfail="MN cleanup NOT successful" )
+
+ main.step( "Checking ONOS Logs for errors" )
+ for node in nodes:
+ print colors[ 'purple' ] + "Checking logs for errors on " + \
+ node.name + ":" + colors[ 'end' ]
+ print main.ONOSbench.checkLogs( node.ip_address )
+
main.step( "Packing and rotating pcap archives" )
os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
- # TODO: actually check something here
- utilities.assert_equals( expect=main.TRUE, actual=main.TRUE,
- onpass="Test cleanup successful",
- onfail="Test cleanup NOT successful" )
+ try:
+ timerLog = open( main.logdir + "/Timers.csv", 'w')
+ # Overwrite with empty line and close
+ timerLog.write( "Restart\n" )
+ timerLog.write( str( main.restartTime ) )
+ timerLog.close()
+ except NameError, e:
+ main.log.exception(e)
def CASE14( self, main ):
"""
start election app on all onos nodes
"""
- leaderResult = main.TRUE
- # install app on onos 1
- main.log.info( "Install leadership election app" )
- main.ONOScli1.featureInstall( "onos-app-election" )
- # wait for election
- # check for leader
- leader = main.ONOScli1.electionTestLeader()
- # verify leader is ONOS1
- if leader == ONOS1Ip:
- # all is well
- pass
- elif leader is None:
- # No leader elected
- main.log.report( "No leader was elected" )
- leaderResult = main.FALSE
- elif leader == main.FALSE:
- # error in response
- # TODO: add check for "Command not found:" in the driver, this
- # means the app isn't loaded
- main.log.report( "Something is wrong with electionTestLeader" +
- " function, check the error logs" )
- leaderResult = main.FALSE
- else:
- # error in response
- main.log.report(
- "Unexpected response from electionTestLeader function:'" +
- str( leader ) +
- "'" )
- leaderResult = main.FALSE
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
- # install on other nodes and check for leader.
- # Should be onos1 and each app should show the same leader
- for controller in range( 2, numControllers + 1 ):
- # loop through ONOScli handlers
- node = getattr( main, ( 'ONOScli' + str( controller ) ) )
- node.featureInstall( "onos-app-election" )
- leaderN = node.electionTestLeader()
- # verify leader is ONOS1
- if leaderN == ONOS1Ip:
- # all is well
- pass
- elif leaderN == main.FALSE:
- # error in response
- # TODO: add check for "Command not found:" in the driver, this
- # means the app isn't loaded
- main.log.report( "Something is wrong with " +
- "electionTestLeader function, check the" +
- " error logs" )
+ main.case("Start Leadership Election app")
+ main.step( "Install leadership election app" )
+ appResult = main.ONOScli1.activateApp( "org.onosproject.election" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=appResult,
+ onpass="Election app installed",
+ onfail="Something went wrong with installing Leadership election" )
+
+ main.step( "Run for election on each node" )
+ leaderResult = main.TRUE
+ leaders = []
+ for cli in CLIs:
+ cli.electionTestRun()
+ for cli in CLIs:
+ leader = cli.electionTestLeader()
+ if leader is None or leader == main.FALSE:
+ main.log.report( cli.name + ": Leader for the election app " +
+ "should be an ONOS node, instead got '" +
+ str( leader ) + "'" )
leaderResult = main.FALSE
- elif leader != leaderN:
- leaderResult = main.FALSE
- main.log.report( "ONOS" + str( controller ) + " sees " +
- str( leaderN ) +
- " as the leader of the election app. Leader" +
- " should be " +
- str( leader ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a leader " +
- "was elected )" )
+ leaders.append( leader )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
- onpass="Leadership election passed",
- onfail="Something went wrong with Leadership election" )
+ onpass="Successfully ran for leadership",
+ onfail="Failed to run for leadership" )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
def CASE15( self, main ):
"""
Check that Leadership Election is still functional
"""
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+
leaderResult = main.TRUE
description = "Check that Leadership Election is still functional"
main.log.report( description )
main.case( description )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ leaders = []
+ for cli in CLIs:
+ leader = cli.electionTestLeader()
+ leaders.append( leader )
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
+
main.step( "Find current leader and withdraw" )
leader = main.ONOScli1.electionTestLeader()
- # TODO: do some sanity checking on leader before using it
+ # do some sanity checking on leader before using it
withdrawResult = main.FALSE
- if leader == ONOS1Ip:
- oldLeader = getattr( main, "ONOScli1" )
- elif leader == ONOS2Ip:
- oldLeader = getattr( main, "ONOScli2" )
- elif leader == ONOS3Ip:
- oldLeader = getattr( main, "ONOScli3" )
- elif leader == ONOS4Ip:
- oldLeader = getattr( main, "ONOScli4" )
- elif leader == ONOS5Ip:
- oldLeader = getattr( main, "ONOScli5" )
- elif leader == ONOS6Ip:
- oldLeader = getattr( main, "ONOScli6" )
- elif leader == ONOS7Ip:
- oldLeader = getattr( main, "ONOScli7" )
- elif leader is None or leader == main.FALSE:
- main.log.report(
+ if leader is None or leader == main.FALSE:
+ main.log.error(
"Leader for the election app should be an ONOS node," +
- "instead got '" +
- str( leader ) +
- "'" )
+ "instead got '" + str( leader ) + "'" )
leaderResult = main.FALSE
- withdrawResult = oldLeader.electionTestWithdraw()
+ oldLeader = None
+ for i in range( len( CLIs ) ):
+ if leader == nodes[ i ].ip_address:
+ oldLeader = CLIs[ i ]
+ break
+ else: # FOR/ELSE statement
+ main.log.error( "Leader election, could not find current leader" )
+ if oldLeader:
+ withdrawResult = oldLeader.electionTestWithdraw()
utilities.assert_equals(
expect=main.TRUE,
actual=withdrawResult,
- onpass="App was withdrawn from election",
- onfail="App was not withdrawn from election" )
+ onpass="Node was withdrawn from election",
+ onfail="Node was not withdrawn from election" )
main.step( "Make sure new leader is elected" )
+ # FIXME: use threads
leaderList = []
- for controller in range( 1, numControllers + 1 ):
- # loop through ONOScli handlers
- node = getattr( main, ( 'ONOScli' + str( controller ) ) )
- leaderList.append( node.electionTestLeader() )
- for leaderN in leaderList:
+ for cli in CLIs:
+ leaderN = cli.electionTestLeader()
+ leaderList.append( leaderN )
if leaderN == leader:
- main.log.report(
- "ONOS" +
- str( controller ) +
- " still sees " +
- str( leader ) +
- " as leader after they withdrew" )
+ main.log.report( cli.name + " still sees " + str( leader ) +
+ " as leader after they withdrew" )
leaderResult = main.FALSE
elif leaderN == main.FALSE:
# error in response
# TODO: add check for "Command not found:" in the driver, this
- # means the app isn't loaded
+ # means the app isn't loaded
main.log.report( "Something is wrong with " +
"electionTestLeader function, " +
"check the error logs" )
leaderResult = main.FALSE
+ elif leaderN is None:
+ # node may not have recieved the event yet
+ time.sleep(7)
+ leaderN = cli.electionTestLeader()
+ leaderList.pop()
+ leaderList.append( leaderN )
consistentLeader = main.FALSE
if len( set( leaderList ) ) == 1:
main.log.info( "Each Election-app sees '" +
@@ -2017,37 +2650,1114 @@
for n in range( len( leaderList ) ):
main.log.report( "ONOS" + str( n + 1 ) + " response: " +
str( leaderList[ n ] ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was elected when the old leader " +
- "resigned )" )
+ leaderResult = leaderResult and consistentLeader
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
onpass="Leadership election passed",
onfail="Something went wrong with Leadership election" )
- main.step(
- "Run for election on old leader( just so everyone is in the hat )" )
- runResult = oldLeader.electionTestRun()
+ main.step( "Run for election on old leader( just so everyone " +
+ "is in the hat )" )
+ if oldLeader:
+ runResult = oldLeader.electionTestRun()
+ else:
+ runResult = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
actual=runResult,
onpass="App re-ran for election",
onfail="App failed to run for election" )
- if consistentLeader == main.TRUE:
- afterRun = main.ONOScli1.electionTestLeader()
- # verify leader didn't just change
- if afterRun == leaderList[ 0 ]:
- leaderResult = main.TRUE
- else:
- leaderResult = main.FALSE
- # TODO: assert on run and withdraw results?
+
+ main.step( "Leader did not change when old leader re-ran" )
+ afterRun = main.ONOScli1.electionTestLeader()
+ # verify leader didn't just change
+ if afterRun == leaderList[ 0 ]:
+ afterResult = main.TRUE
+ else:
+ afterResult = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
- actual=leaderResult,
- onpass="Leadership election passed",
+ actual=afterResult,
+ onpass="Old leader successfully re-ran for election",
onfail="Something went wrong with Leadership election after " +
"the old leader re-ran for election" )
+
+ def CASE16( self, main ):
+ """
+ Install Distributed Primitives app
+ """
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+
+ # Variables for the distributed primitives tests
+ global pCounterName
+ global iCounterName
+ global pCounterValue
+ global iCounterValue
+ global onosSet
+ global onosSetName
+ pCounterName = "TestON-Partitions"
+ iCounterName = "TestON-inMemory"
+ pCounterValue = 0
+ iCounterValue = 0
+ onosSet = set([])
+ onosSetName = "TestON-set"
+
+ description = "Install Primitives app"
+ main.case( description )
+ main.step( "Install Primitives app" )
+ appName = "org.onosproject.distributedprimitives"
+ appResults = CLIs[0].activateApp( appName )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=appResults,
+ onpass="Primitives app activated",
+ onfail="Primitives app not activated" )
+ time.sleep (5 ) # To allow all nodes to activate
+
+ def CASE17( self, main ):
+ """
+ Check for basic functionality with distributed primitives
+ """
+ # Make sure variables are defined/set
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert pCounterName, "pCounterName not defined"
+ assert iCounterName, "iCounterName not defined"
+ assert onosSetName, "onosSetName not defined"
+ # NOTE: assert fails if value is 0/None/Empty/False
+ try:
+ pCounterValue
+ except NameError:
+ main.log.error( "pCounterValue not defined, setting to 0" )
+ pCounterValue = 0
+ try:
+ iCounterValue
+ except NameError:
+ main.log.error( "iCounterValue not defined, setting to 0" )
+ iCounterValue = 0
+ try:
+ onosSet
+ except NameError:
+ main.log.error( "onosSet not defined, setting to empty Set" )
+ onosSet = set([])
+ # Variables for the distributed primitives tests. These are local only
+ addValue = "a"
+ addAllValue = "a b c d e f"
+ retainValue = "c d e f"
+
+ description = "Check for basic functionality with distributed " +\
+ "primitives"
+ main.case( description )
+ main.caseExplaination = "Test the methods of the distributed primitives (counters and sets) throught the cli"
+ # DISTRIBUTED ATOMIC COUNTERS
+ main.step( "Increment and get a default counter on each node" )
+ pCounters = []
+ threads = []
+ addedPValues = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counterTestIncrement,
+ name="counterIncrement-" + str( i ),
+ args=[ pCounterName ] )
+ pCounterValue += 1
+ addedPValues.append( pCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ pCounters.append( t.result )
+ # Check that counter incremented numController times
+ pCounterResults = True
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=pCounterResults,
+ onpass="Default counter incremented",
+ onfail="Error incrementing default" +
+ " counter" )
+
+ main.step( "Increment and get an in memory counter on each node" )
+ iCounters = []
+ addedIValues = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counterTestIncrement,
+ name="icounterIncrement-" + str( i ),
+ args=[ iCounterName ],
+ kwargs={ "inMemory": True } )
+ iCounterValue += 1
+ addedIValues.append( iCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ iCounters.append( t.result )
+ # Check that counter incremented numController times
+ iCounterResults = True
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in the in-memory "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=iCounterResults,
+ onpass="In memory counter incremented",
+ onfail="Error incrementing in memory" +
+ " counter" )
+
+ main.step( "Check counters are consistant across nodes" )
+ onosCounters = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counters,
+ name="counters-" + str( i ) )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ onosCounters.append( t.result )
+ tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
+ if all( tmp ):
+ main.log.info( "Counters are consistent across all nodes" )
+ consistentCounterResults = main.TRUE
+ else:
+ main.log.error( "Counters are not consistent across all nodes" )
+ consistentCounterResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=consistentCounterResults,
+ onpass="ONOS counters are consistent " +
+ "across nodes",
+ onfail="ONOS Counters are inconsistent " +
+ "across nodes" )
+
+ main.step( "Counters we added have the correct values" )
+ correctResults = main.TRUE
+ for i in range( numControllers ):
+ current = onosCounters[i]
+ try:
+ pValue = current.get( pCounterName )
+ iValue = current.get( iCounterName )
+ if pValue == pCounterValue:
+ main.log.info( "Partitioned counter value is correct" )
+ else:
+ main.log.error( "Partitioned counter value is incorrect," +
+ " expected value: " + str( pCounterValue )
+ + " current value: " + str( pValue ) )
+ correctResults = main.FALSE
+ if iValue == iCounterValue:
+ main.log.info( "In memory counter value is correct" )
+ else:
+ main.log.error( "In memory counter value is incorrect, " +
+ "expected value: " + str( iCounterValue ) +
+ " current value: " + str( iValue ) )
+ correctResults = main.FALSE
+ except AttributeError, e:
+ main.log.error( "ONOS" + str( i + 1 ) + " counters result " +
+ "is not as expected" )
+ correctResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=correctResults,
+ onpass="Added counters are correct",
+ onfail="Added counters are incorrect" )
+ # DISTRIBUTED SETS
+ main.step( "Distributed Set get" )
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=getResults,
+ onpass="Set elements are correct",
+ onfail="Set elements are incorrect" )
+
+ main.step( "Distributed Set size" )
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=sizeResults,
+ onpass="Set sizes are correct",
+ onfail="Set sizes are incorrect" )
+
+ main.step( "Distributed Set add()" )
+ onosSet.add( addValue )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAdd-" + str( i ),
+ args=[ onosSetName, addValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addResults = main.FALSE
+ else:
+ # unexpected result
+ addResults = main.FALSE
+ if addResults != main.TRUE:
+ main.log.error( "Error executing set add" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addResults = addResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addResults,
+ onpass="Set add correct",
+ onfail="Set add was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set contains()" )
+ containsResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setContains-" + str( i ),
+ args=[ onosSetName ],
+ kwargs={ "values": addValue } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ # NOTE: This is the tuple
+ containsResponses.append( t.result )
+
+ containsResults = main.TRUE
+ for i in range( numControllers ):
+ if containsResponses[ i ] == main.ERROR:
+ containsResults = main.FALSE
+ else:
+ containsResults = containsResults and\
+ containsResponses[ i ][ 1 ]
+ utilities.assert_equals( expect=main.TRUE,
+ actual=containsResults,
+ onpass="Set contains is functional",
+ onfail="Set contains failed" )
+
+ main.step( "Distributed Set containsAll()" )
+ containsAllResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setContainsAll-" + str( i ),
+ args=[ onosSetName ],
+ kwargs={ "values": addAllValue } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ # NOTE: This is the tuple
+ containsAllResponses.append( t.result )
+
+ containsAllResults = main.TRUE
+ for i in range( numControllers ):
+ if containsResponses[ i ] == main.ERROR:
+ containsResults = main.FALSE
+ else:
+ containsResults = containsResults and\
+ containsResponses[ i ][ 1 ]
+ utilities.assert_equals( expect=main.TRUE,
+ actual=containsAllResults,
+ onpass="Set containsAll is functional",
+ onfail="Set containsAll failed" )
+
+ main.step( "Distributed Set remove()" )
+ onosSet.remove( addValue )
+ removeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRemove-" + str( i ),
+ args=[ onosSetName, addValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ removeResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ removeResults = main.TRUE
+ for i in range( numControllers ):
+ if removeResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif removeResponses[ i ] == main.FALSE:
+ # not in set, probably fine
+ pass
+ elif removeResponses[ i ] == main.ERROR:
+ # Error in execution
+ removeResults = main.FALSE
+ else:
+ # unexpected result
+ removeResults = main.FALSE
+ if removeResults != main.TRUE:
+ main.log.error( "Error executing set remove" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ removeResults = removeResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=removeResults,
+ onpass="Set remove correct",
+ onfail="Set remove was incorrect" )
+
+ main.step( "Distributed Set removeAll()" )
+ onosSet.difference_update( addAllValue.split() )
+ removeAllResponses = []
+ threads = []
+ try:
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRemoveAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ removeAllResponses.append( t.result )
+ except Exception, e:
+ main.log.exception(e)
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ removeAllResults = main.TRUE
+ for i in range( numControllers ):
+ if removeAllResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif removeAllResponses[ i ] == main.FALSE:
+ # not in set, probably fine
+ pass
+ elif removeAllResponses[ i ] == main.ERROR:
+ # Error in execution
+ removeAllResults = main.FALSE
+ else:
+ # unexpected result
+ removeAllResults = main.FALSE
+ if removeAllResults != main.TRUE:
+ main.log.error( "Error executing set removeAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ removeAllResults = removeAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=removeAllResults,
+ onpass="Set removeAll correct",
+ onfail="Set removeAll was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set clear()" )
+ onosSet.clear()
+ clearResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestClear-" + str( i ),
+ args=[ onosSetName, " "], # Values doesn't matter
+ kwargs={ "clear": True } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ clearResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ clearResults = main.TRUE
+ for i in range( numControllers ):
+ if clearResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif clearResponses[ i ] == main.FALSE:
+ # Nothing set, probably fine
+ pass
+ elif clearResponses[ i ] == main.ERROR:
+ # Error in execution
+ clearResults = main.FALSE
+ else:
+ # unexpected result
+ clearResults = main.FALSE
+ if clearResults != main.TRUE:
+ main.log.error( "Error executing set clear" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ clearResults = clearResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=clearResults,
+ onpass="Set clear correct",
+ onfail="Set clear was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set retain()" )
+ onosSet.intersection_update( retainValue.split() )
+ retainResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRetain-" + str( i ),
+ args=[ onosSetName, retainValue ],
+ kwargs={ "retain": True } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ retainResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ retainResults = main.TRUE
+ for i in range( numControllers ):
+ if retainResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif retainResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif retainResponses[ i ] == main.ERROR:
+ # Error in execution
+ retainResults = main.FALSE
+ else:
+ # unexpected result
+ retainResults = main.FALSE
+ if retainResults != main.TRUE:
+ main.log.error( "Error executing set retain" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " +
+ str( size ) + " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ retainResults = retainResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=retainResults,
+ onpass="Set retain correct",
+ onfail="Set retain was incorrect" )
+
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.topo b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.topo
index 4d4156c..9305025 100644
--- a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.topo
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.topo
@@ -151,7 +151,7 @@
<arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
<arg2> --topo mytopo </arg2>
<arg3> </arg3>
- <controller> remote </controller>
+ <controller> none </controller>
</COMPONENTS>
</Mininet1>
@@ -162,11 +162,7 @@
<type>RemoteMininetDriver</type>
<connect_order>17</connect_order>
<COMPONENTS>
- # Specify the Option for mininet
- <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
- <arg2> --topo mytopo --arp</arg2>
- <controller> remote </controller>
- </COMPONENTS>
+ </COMPONENTS>
</Mininet2>
</COMPONENT>
diff --git a/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.params b/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.params
new file mode 100644
index 0000000..e1421cd
--- /dev/null
+++ b/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.params
@@ -0,0 +1,89 @@
+<PARAMS>
+
+#List of test cases:
+#CASE1: Compile ONOS and push it to the test machines
+#CASE2: Assign mastership to controllers
+#CASE3: Assign intents
+#CASE4: Ping across added host intents
+#CASE5: Reading state of ONOS
+#CASE6: The Failure case. We will create IPTables rules here.
+#CASE7: Check state after control plane partition.
+#CASE8: Compare topo
+#CASE9: Link s3-s28 down
+#CASE10: Link s3-s28 up
+#CASE11: Switch down
+#CASE12: Switch up
+#CASE13: Clean up
+#CASE14: start election app on all onos nodes
+#CASE15: Check that Leadership Election is still functional
+#CASE16: Repair network partition
+ #1,2,8,3,4,5,14,[6],8,7,4,15,9,8,4,10,8,4,11,8,4,12,8,4,13
+ <testcases>1,2,5,14,[6],8,7,4,15,9,8,4,10,8,4,11,8,4,12,8,4,16,13</testcases>
+ <ENV>
+ <cellName>HA</cellName>
+ </ENV>
+ <Git> False </Git>
+ <branch> master </branch>
+ <num_controllers> 7 </num_controllers>
+
+ <CTRL>
+ <ip1>10.128.30.11</ip1>
+ <port1>6633</port1>
+
+ <ip2>10.128.30.12</ip2>
+ <port2>6633</port2>
+
+ <ip3>10.128.30.13</ip3>
+ <port3>6633</port3>
+
+ <ip4>10.128.30.14</ip4>
+ <port4>6633</port4>
+
+ <ip5>10.128.30.15</ip5>
+ <port5>6633</port5>
+
+ <ip6>10.128.30.16</ip6>
+ <port6>6633</port6>
+
+ <ip7>10.128.30.17</ip7>
+ <port7>6633</port7>
+ </CTRL>
+ <TESTONUSER>admin</TESTONUSER>
+ <TESTONIP>10.128.30.9</TESTONIP>
+ <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>.2</LinkDiscovery>
+ <SwitchDiscovery>.2</SwitchDiscovery>
+ </timers>
+ <kill>
+ <switch> s5 </switch>
+ <dpid> 0000000000005000 </dpid>
+ <links> h5 s2 s1 s6 </links>
+ </kill>
+ <MNtcpdump>
+ <intf>eth0</intf>
+ <port> </port>
+ <folder>~/packet_captures/</folder>
+ </MNtcpdump>
+</PARAMS>
diff --git a/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.py b/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.py
new file mode 100644
index 0000000..e4658e7
--- /dev/null
+++ b/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.py
@@ -0,0 +1,2011 @@
+"""
+Description: This test is to determine how ONOS behaves in a control network
+ partion. ONOS 1,2,3 will be split into a sub cluster and ONOS
+ 4,5,6,7 will be in another sub-cluster.
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Assign mastership to controllers
+CASE3: Assign intents
+CASE4: Ping across added host intents
+CASE5: Reading state of ONOS
+CASE6: The Failure case. We will create IPTables rules here.
+CASE7: Check state after control plane partition.
+CASE8: Compare topo
+CASE9: Link s3-s28 down
+CASE10: Link s3-s28 up
+CASE11: Switch down
+CASE12: Switch up
+CASE13: Clean up
+CASE14: start election app on all onos nodes
+CASE15: Check that Leadership Election is still functional
+CASE16: Repair network partition
+"""
+# FIXME: Add new comparison case for during the failure?
+class HATestNetworkPartition:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ """
+ CASE1 is to compile ONOS and push it to the test machines
+
+ Startup sequence:
+ cell <name>
+ onos-verify-cell
+ NOTE: temporary - onos-remove-raft-logs
+ onos-uninstall
+ start mininet
+ git pull
+ mvn clean install
+ onos-package
+ onos-install -f
+ onos-wait-for-start
+ start cli sessions
+ start tcpdump
+ """
+ main.log.report( "ONOS HA test: Network partition - initialization" )
+ main.log.report( "This test will partition a 7 node cluster into " +
+ "3 node and 4 node sub clusters by blocking " +
+ "communication between nodes." )
+ main.case( "Setting up test environment" )
+ # TODO: save all the timers and output them for plotting
+
+ # load some vairables from the params file
+ PULLCODE = False
+ if main.params[ 'Git' ] == 'True':
+ PULLCODE = True
+ gitBranch = main.params[ 'branch' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+
+ # set global variables
+ global ONOS1Ip
+ global ONOS1Port
+ global ONOS2Ip
+ global ONOS2Port
+ global ONOS3Ip
+ global ONOS3Port
+ global ONOS4Ip
+ global ONOS4Port
+ global ONOS5Ip
+ global ONOS5Port
+ global ONOS6Ip
+ global ONOS6Port
+ global ONOS7Ip
+ global ONOS7Port
+ global numControllers
+
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+ ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
+ ONOS4Port = main.params[ 'CTRL' ][ 'port4' ]
+ ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
+ ONOS5Port = main.params[ 'CTRL' ][ 'port5' ]
+ ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
+ ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
+ ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
+ ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
+ numControllers = int( main.params[ 'num_controllers' ] )
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ # FIXME:this is short term fix
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+ main.ONOSbench.onosUninstall( ONOS2Ip )
+ main.ONOSbench.onosUninstall( ONOS3Ip )
+ main.ONOSbench.onosUninstall( ONOS4Ip )
+ main.ONOSbench.onosUninstall( ONOS5Ip )
+ main.ONOSbench.onosUninstall( ONOS6Ip )
+ main.ONOSbench.onosUninstall( ONOS7Ip )
+
+ cleanInstallResult = main.TRUE
+ gitPullResult = main.TRUE
+
+ main.step( "Starting Mininet" )
+ main.Mininet1.startNet( )
+
+ main.step( "Compiling the latest version of ONOS" )
+ if PULLCODE:
+ main.step( "Git checkout and pull " + gitBranch )
+ main.ONOSbench.gitCheckout( gitBranch )
+ gitPullResult = main.ONOSbench.gitPull()
+
+ main.step( "Using mvn clean and install" )
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ else:
+ main.log.warn( "Did not pull new code so skipping mvn " +
+ "clean install" )
+ main.ONOSbench.getVersion( report=True )
+ # GRAPHS
+ # NOTE: important params here:
+ # job = name of Jenkins job
+ # Plot Name = Plot-HA, only can be used if multiple plots
+ # index = The number of the graph under plot name
+ job = "HANetworkPartition"
+ graphs = '<ac:structured-macro ac:name="html">\n'
+ graphs += '<ac:plain-text-body><![CDATA[\n'
+ graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
+ '/plot/getPlot?index=0&width=500&height=300"' +\
+ 'noborder="0" width="500" height="300" scrolling="yes" '+\
+ 'seamless="seamless"></iframe>\n'
+ graphs += ']]></ac:plain-text-body>\n'
+ graphs += '</ac:structured-macro>\n'
+ main.log.wiki(graphs)
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS1Ip )
+ onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS2Ip )
+ onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS3Ip )
+ onos4InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS4Ip )
+ onos5InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS5Ip )
+ onos6InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS6Ip )
+ onos7InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS7Ip )
+ onosInstallResult = onos1InstallResult and onos2InstallResult\
+ and onos3InstallResult and onos4InstallResult\
+ and onos5InstallResult and onos6InstallResult\
+ and onos7InstallResult
+
+ main.step( "Checking if ONOS is up yet" )
+ for i in range( 2 ):
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+ main.ONOSbench.onosStop( ONOS1Ip )
+ main.ONOSbench.onosStart( ONOS1Ip )
+ onos2Isup = main.ONOSbench.isup( ONOS2Ip )
+ if not onos2Isup:
+ main.log.report( "ONOS2 didn't start!" )
+ main.ONOSbench.onosStop( ONOS2Ip )
+ main.ONOSbench.onosStart( ONOS2Ip )
+ onos3Isup = main.ONOSbench.isup( ONOS3Ip )
+ if not onos3Isup:
+ main.log.report( "ONOS3 didn't start!" )
+ main.ONOSbench.onosStop( ONOS3Ip )
+ main.ONOSbench.onosStart( ONOS3Ip )
+ onos4Isup = main.ONOSbench.isup( ONOS4Ip )
+ if not onos4Isup:
+ main.log.report( "ONOS4 didn't start!" )
+ main.ONOSbench.onosStop( ONOS4Ip )
+ main.ONOSbench.onosStart( ONOS4Ip )
+ onos5Isup = main.ONOSbench.isup( ONOS5Ip )
+ if not onos5Isup:
+ main.log.report( "ONOS5 didn't start!" )
+ main.ONOSbench.onosStop( ONOS5Ip )
+ main.ONOSbench.onosStart( ONOS5Ip )
+ onos6Isup = main.ONOSbench.isup( ONOS6Ip )
+ if not onos6Isup:
+ main.log.report( "ONOS6 didn't start!" )
+ main.ONOSbench.onosStop( ONOS6Ip )
+ main.ONOSbench.onosStart( ONOS6Ip )
+ onos7Isup = main.ONOSbench.isup( ONOS7Ip )
+ if not onos7Isup:
+ main.log.report( "ONOS7 didn't start!" )
+ main.ONOSbench.onosStop( ONOS7Ip )
+ main.ONOSbench.onosStart( ONOS7Ip )
+ onosIsupResult = onos1Isup and onos2Isup and onos3Isup\
+ and onos4Isup and onos5Isup and onos6Isup and onos7Isup
+ if onosIsupResult == main.TRUE:
+ break
+
+ cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip )
+ cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip )
+ cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip )
+ cliResult4 = main.ONOScli4.startOnosCli( ONOS4Ip )
+ cliResult5 = main.ONOScli5.startOnosCli( ONOS5Ip )
+ cliResult6 = main.ONOScli6.startOnosCli( ONOS6Ip )
+ cliResult7 = main.ONOScli7.startOnosCli( ONOS7Ip )
+ cliResults = cliResult1 and cliResult2 and cliResult3 and\
+ cliResult4 and cliResult5 and cliResult6 and cliResult7
+
+ main.step( "Start Packet Capture MN" )
+ main.Mininet2.startTcpdump(
+ str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
+ + "-MN.pcap",
+ intf=main.params[ 'MNtcpdump' ][ 'intf' ],
+ port=main.params[ 'MNtcpdump' ][ 'port' ] )
+
+ case1Result = ( cleanInstallResult and packageResult and
+ cellResult and verifyResult and onosInstallResult
+ and onosIsupResult and cliResults )
+
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ if case1Result == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
+ main.cleanup()
+ main.exit()
+
+ def CASE2( self, main ):
+ """
+ Assign mastership to controllers
+ """
+ import re
+
+ main.log.report( "Assigning switches to controllers" )
+ main.case( "Assigning Controllers" )
+ main.step( "Assign switches to controllers" )
+
+ for i in range( 1, 29 ):
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ count=numControllers,
+ ip1=ONOS1Ip, port1=ONOS1Port,
+ ip2=ONOS2Ip, port2=ONOS2Port,
+ ip3=ONOS3Ip, port3=ONOS3Port,
+ ip4=ONOS4Ip, port4=ONOS4Port,
+ ip5=ONOS5Ip, port5=ONOS5Port,
+ ip6=ONOS6Ip, port6=ONOS6Port,
+ ip7=ONOS7Ip, port7=ONOS7Port )
+
+ mastershipCheck = main.TRUE
+ for i in range( 1, 29 ):
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ try:
+ main.log.info( str( response ) )
+ except:
+ main.log.info( repr( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response )\
+ and re.search( "tcp:" + ONOS2Ip, response )\
+ and re.search( "tcp:" + ONOS3Ip, response )\
+ and re.search( "tcp:" + ONOS4Ip, response )\
+ and re.search( "tcp:" + ONOS5Ip, response )\
+ and re.search( "tcp:" + ONOS6Ip, response )\
+ and re.search( "tcp:" + ONOS7Ip, response ):
+ mastershipCheck = mastershipCheck and main.TRUE
+ else:
+ mastershipCheck = main.FALSE
+ if mastershipCheck == main.TRUE:
+ main.log.report( "Switch mastership assigned correctly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=mastershipCheck,
+ onpass="Switch mastership assigned correctly",
+ onfail="Switches not assigned correctly to controllers" )
+
+ # Manually assign mastership to the controller we want
+ roleCall = main.TRUE
+ roleCheck = main.TRUE
+
+ # Assign switch
+ deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
+ roleCall = roleCall and main.ONOScli1.deviceRole(
+ deviceId,
+ ONOS1Ip )
+ # Check assignment
+ if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+
+ # Assign switch
+ deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' )
+ roleCall = roleCall and main.ONOScli1.deviceRole(
+ deviceId,
+ ONOS1Ip )
+ # Check assignment
+ if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+
+ # Assign switch
+ deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' )
+ roleCall = roleCall and main.ONOScli1.deviceRole(
+ deviceId,
+ ONOS2Ip )
+ # Check assignment
+ if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+
+ # Assign switch
+ deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' )
+ roleCall = roleCall and main.ONOScli1.deviceRole(
+ deviceId,
+ ONOS2Ip )
+ # Check assignment
+ if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+
+ # Assign switch
+ deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' )
+ roleCall = roleCall and main.ONOScli1.deviceRole(
+ deviceId,
+ ONOS3Ip )
+ # Check assignment
+ if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+
+ # Assign switch
+ deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' )
+ roleCall = roleCall and main.ONOScli1.deviceRole(
+ deviceId,
+ ONOS3Ip )
+ # Check assignment
+ if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+
+ # Assign switch
+ deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' )
+ roleCall = roleCall and main.ONOScli1.deviceRole(
+ deviceId,
+ ONOS4Ip )
+ # Check assignment
+ if ONOS4Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+
+ for i in range( 8, 18 ):
+ dpid = '3' + str( i ).zfill( 3 )
+ deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
+ roleCall = roleCall and main.ONOScli1.deviceRole(
+ deviceId,
+ ONOS5Ip )
+ # Check assignment
+ if ONOS5Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+
+ deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' )
+ roleCall = roleCall and main.ONOScli1.deviceRole(
+ deviceId,
+ ONOS6Ip )
+ # Check assignment
+ if ONOS6Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+
+ for i in range( 18, 28 ):
+ dpid = '6' + str( i ).zfill( 3 )
+ deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
+ roleCall = roleCall and main.ONOScli1.deviceRole(
+ deviceId,
+ ONOS7Ip )
+ # Check assignment
+ if ONOS7Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=roleCall,
+ onpass="Re-assigned switch mastership to designated controller",
+ onfail="Something wrong with deviceRole calls" )
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=roleCheck,
+ onpass="Switches were successfully reassigned to designated " +
+ "controller",
+ onfail="Switches were not successfully reassigned" )
+ mastershipCheck = mastershipCheck and roleCall and roleCheck
+ utilities.assert_equals( expect=main.TRUE, actual=mastershipCheck,
+ onpass="Switch mastership correctly assigned",
+ onfail="Error in (re)assigning switch" +
+ " mastership" )
+
+ def CASE3( self, main ):
+ """
+ Assign intents
+ """
+ import time
+ import json
+ main.log.report( "Adding host intents" )
+ main.case( "Adding host Intents" )
+
+ main.step( "Discovering Hosts( Via pingall for now )" )
+ # FIXME: Once we have a host discovery mechanism, use that instead
+
+ # install onos-app-fwd
+ main.log.info( "Install reactive forwarding app" )
+ appResults = CLIs[0].activateApp( "org.onosproject.fwd" )
+ '''
+ main.ONOScli1.featureInstall( "onos-app-fwd" )
+ main.ONOScli2.featureInstall( "onos-app-fwd" )
+ main.ONOScli3.featureInstall( "onos-app-fwd" )
+ main.ONOScli4.featureInstall( "onos-app-fwd" )
+ main.ONOScli5.featureInstall( "onos-app-fwd" )
+ main.ONOScli6.featureInstall( "onos-app-fwd" )
+ main.ONOScli7.featureInstall( "onos-app-fwd" )
+ '''
+
+ # REACTIVE FWD test
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=pingResult,
+ onpass="Reactive Pingall test passed",
+ onfail="Reactive Pingall failed, one or more ping pairs failed" )
+ time2 = time.time()
+ main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) )
+
+ # uninstall onos-app-fwd
+ main.log.info( "Uninstall reactive forwarding app" )
+ appResults = appResults and CLIs[0].deactivateApp( "org.onosproject.fwd" )
+ '''
+ main.ONOScli1.featureUninstall( "onos-app-fwd" )
+ main.ONOScli2.featureUninstall( "onos-app-fwd" )
+ main.ONOScli3.featureUninstall( "onos-app-fwd" )
+ main.ONOScli4.featureUninstall( "onos-app-fwd" )
+ main.ONOScli5.featureUninstall( "onos-app-fwd" )
+ main.ONOScli6.featureUninstall( "onos-app-fwd" )
+ main.ONOScli7.featureUninstall( "onos-app-fwd" )
+ '''
+ # timeout for fwd flows
+ time.sleep( 10 )
+
+ main.step( "Add host intents" )
+ # TODO: move the host numbers to params
+ # Maybe look at all the paths we ping?
+ intentAddResult = True
+ for i in range( 8, 18 ):
+ main.log.info( "Adding host intent between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ # NOTE: getHost can return None
+ host1Dict = main.ONOScli1.getHost( host1 )
+ host2Dict = main.ONOScli1.getHost( host2 )
+ host1Id = None
+ host2Id = None
+ if host1Dict and host2Dict:
+ host1Id = host1Dict.get( 'id', None )
+ host2Id = host2Dict.get( 'id', None )
+ if host1Id and host2Id:
+ # distribute the intents across ONOS nodes
+ nodeNum = ( i % 7 ) + 1
+ node = getattr( main, ( 'ONOScli' + str( nodeNum ) ) )
+ tmpResult = node.addHostIntent(
+ host1Id,
+ host2Id )
+ else:
+ main.log.error( "Error, getHost() failed" )
+ main.log.warn( json.dumps( json.loads( main.ONOScli1.hosts() ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ tmpResult = main.FALSE
+ intentAddResult = bool( pingResult and intentAddResult
+ and tmpResult )
+ # FIXME Check that intents were added?
+ # TODO Use the new return from add host command and look at each
+ # intent individually
+ #
+ #
+ #
+ #
+ #
+ #
+ # End of for loop to add intents
+ # Print the intent states
+ intents = main.ONOScli1.intents( )
+ intentStates = []
+ for intent in json.loads( intents ): # Iter through intents of a node
+ intentStates.append( intent.get( 'state', None ) )
+ out = [ (i, intentStates.count( i ) ) for i in set( intentStates ) ]
+ main.log.info( dict( out ) )
+
+ utilities.assert_equals(
+ expect=True,
+ actual=intentAddResult,
+ onpass="Pushed host intents to ONOS",
+ onfail="Error in pushing host intents to ONOS" )
+ # TODO Check if intents all exist in datastore
+
+ def CASE4( self, main ):
+ """
+ Ping across added host intents
+ """
+ import json
+ description = " Ping across added host intents"
+ main.log.report( description )
+ main.case( description )
+ PingResult = main.TRUE
+ for i in range( 8, 18 ):
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ PingResult = PingResult and ping
+ if ping == main.FALSE:
+ main.log.warn( "Ping failed between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ elif ping == main.TRUE:
+ main.log.info( "Ping test passed!" )
+ # Don't set PingResult or you'd override failures
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Intents have not been installed correctly, pings failed." )
+ main.log.warn( "ONOS1 intents: " )
+ main.log.warn( json.dumps( json.loads( main.ONOScli1.intents() ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ if PingResult == main.TRUE:
+ main.log.report(
+ "Intents have been installed correctly and verified by pings" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=PingResult,
+ onpass="Intents have been installed correctly and pings work",
+ onfail="Intents have not been installed correctly, pings failed." )
+
+ def CASE5( self, main ):
+ """
+ Reading state of ONOS
+ """
+ import json
+ # assumes that sts is already in you PYTHONPATH
+ from sts.topology.teston_topology import TestONTopology
+
+ main.log.report( "Setting up and gathering data for current state" )
+ main.case( "Setting up and gathering data for current state" )
+ # The general idea for this test case is to pull the state of
+ # ( intents,flows, topology,... ) from each ONOS node
+ # We can then compare them with eachother and also with past states
+
+ main.step( "Get the Mastership of each switch from each controller" )
+ global mastershipState
+ mastershipState = []
+
+ # Assert that each device has a master
+ ONOS1MasterNotNull = main.ONOScli1.rolesNotNull()
+ ONOS2MasterNotNull = main.ONOScli2.rolesNotNull()
+ ONOS3MasterNotNull = main.ONOScli3.rolesNotNull()
+ ONOS4MasterNotNull = main.ONOScli4.rolesNotNull()
+ ONOS5MasterNotNull = main.ONOScli5.rolesNotNull()
+ ONOS6MasterNotNull = main.ONOScli6.rolesNotNull()
+ ONOS7MasterNotNull = main.ONOScli7.rolesNotNull()
+ rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\
+ ONOS3MasterNotNull and ONOS4MasterNotNull and\
+ ONOS5MasterNotNull and ONOS6MasterNotNull and\
+ ONOS7MasterNotNull
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=rolesNotNull,
+ onpass="Each device has a master",
+ onfail="Some devices don't have a master assigned" )
+
+ ONOS1Mastership = main.ONOScli1.roles()
+ ONOS2Mastership = main.ONOScli2.roles()
+ ONOS3Mastership = main.ONOScli3.roles()
+ ONOS4Mastership = main.ONOScli4.roles()
+ ONOS5Mastership = main.ONOScli5.roles()
+ ONOS6Mastership = main.ONOScli6.roles()
+ ONOS7Mastership = main.ONOScli7.roles()
+ if "Error" in ONOS1Mastership or not ONOS1Mastership\
+ or "Error" in ONOS2Mastership or not ONOS2Mastership\
+ or "Error" in ONOS3Mastership or not ONOS3Mastership\
+ or "Error" in ONOS4Mastership or not ONOS4Mastership\
+ or "Error" in ONOS5Mastership or not ONOS5Mastership\
+ or "Error" in ONOS6Mastership or not ONOS6Mastership\
+ or "Error" in ONOS7Mastership or not ONOS7Mastership:
+ main.log.report( "Error in getting ONOS roles" )
+ for i in range( 1, numControllers + 1 ):
+ mastership = eval( "ONOS" + str( i ) + "Mastership" )
+ main.log.warn(
+ "ONOS" + str( i ) + " mastership response: " +
+ repr( mastership ) )
+ consistentMastership = main.FALSE
+ elif ONOS1Mastership == ONOS2Mastership\
+ and ONOS1Mastership == ONOS3Mastership\
+ and ONOS1Mastership == ONOS4Mastership\
+ and ONOS1Mastership == ONOS5Mastership\
+ and ONOS1Mastership == ONOS6Mastership\
+ and ONOS1Mastership == ONOS7Mastership:
+ mastershipState = ONOS1Mastership
+ consistentMastership = main.TRUE
+ main.log.report(
+ "Switch roles are consistent across all ONOS nodes" )
+ else:
+ for i in range( 1, numControllers + 1 ):
+ mastership = eval( "ONOS" + str( i ) + "Mastership" )
+ main.log.warn( "ONOS" + str( i ) + " roles: " +
+ json.dumps( json.loads( mastership ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ consistentMastership = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentMastership,
+ onpass="Switch roles are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of switch roles" )
+
+ main.step( "Get the intents from each controller" )
+ global intentState
+ intentState = []
+ ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
+ ONOS2Intents = main.ONOScli2.intents( jsonFormat=True )
+ ONOS3Intents = main.ONOScli3.intents( jsonFormat=True )
+ ONOS4Intents = main.ONOScli4.intents( jsonFormat=True )
+ ONOS5Intents = main.ONOScli5.intents( jsonFormat=True )
+ ONOS6Intents = main.ONOScli6.intents( jsonFormat=True )
+ ONOS7Intents = main.ONOScli7.intents( jsonFormat=True )
+ intentCheck = main.FALSE
+ if "Error" in ONOS1Intents or not ONOS1Intents\
+ or "Error" in ONOS2Intents or not ONOS2Intents\
+ or "Error" in ONOS3Intents or not ONOS3Intents\
+ or "Error" in ONOS4Intents or not ONOS4Intents\
+ or "Error" in ONOS5Intents or not ONOS5Intents\
+ or "Error" in ONOS6Intents or not ONOS6Intents\
+ or "Error" in ONOS7Intents or not ONOS7Intents:
+ main.log.report( "Error in getting ONOS intents" )
+ for i in range( 1, numControllers + 1 ):
+ intents = eval( "ONOS" + str( i ) + "Intents" )
+ main.log.warn(
+ "ONOS" + str( i ) + " intents response: " +
+ repr( intents ) )
+ elif ONOS1Intents == ONOS2Intents\
+ and ONOS1Intents == ONOS3Intents\
+ and ONOS1Intents == ONOS4Intents\
+ and ONOS1Intents == ONOS5Intents\
+ and ONOS1Intents == ONOS6Intents\
+ and ONOS1Intents == ONOS7Intents:
+ intentState = ONOS1Intents
+ intentCheck = main.TRUE
+ main.log.report( "Intents are consistent across all ONOS nodes" )
+ else:
+ for i in range( 1, numControllers + 1 ):
+ intents = eval( "ONOS" + str( i ) + "Intents" )
+ main.log.warn( "ONOS" + str( i ) + " intents: " +
+ json.dumps( json.loads( intents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=intentCheck,
+ onpass="Intents are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of intents" )
+
+ main.step( "Get the flows from each controller" )
+ global flowState
+ flowState = []
+ ONOS1Flows = main.ONOScli1.flows( jsonFormat=True )
+ ONOS2Flows = main.ONOScli2.flows( jsonFormat=True )
+ ONOS3Flows = main.ONOScli3.flows( jsonFormat=True )
+ ONOS4Flows = main.ONOScli4.flows( jsonFormat=True )
+ ONOS5Flows = main.ONOScli5.flows( jsonFormat=True )
+ ONOS6Flows = main.ONOScli6.flows( jsonFormat=True )
+ ONOS7Flows = main.ONOScli7.flows( jsonFormat=True )
+ ONOS1FlowsJson = json.loads( ONOS1Flows )
+ ONOS2FlowsJson = json.loads( ONOS2Flows )
+ ONOS3FlowsJson = json.loads( ONOS3Flows )
+ ONOS4FlowsJson = json.loads( ONOS4Flows )
+ ONOS5FlowsJson = json.loads( ONOS5Flows )
+ ONOS6FlowsJson = json.loads( ONOS6Flows )
+ ONOS7FlowsJson = json.loads( ONOS7Flows )
+ flowCheck = main.FALSE
+ if "Error" in ONOS1Flows or not ONOS1Flows\
+ or "Error" in ONOS2Flows or not ONOS2Flows\
+ or "Error" in ONOS3Flows or not ONOS3Flows\
+ or "Error" in ONOS4Flows or not ONOS4Flows\
+ or "Error" in ONOS5Flows or not ONOS5Flows\
+ or "Error" in ONOS6Flows or not ONOS6Flows\
+ or "Error" in ONOS7Flows or not ONOS7Flows:
+ main.log.report( "Error in getting ONOS intents" )
+ for i in range( 1, numControllers + 1 ):
+ flowsIter = eval( "ONOS" + str( i ) + "Flows" )
+ main.log.warn( "ONOS" + str( i ) + " flows repsponse: " +
+ flowsIter )
+ elif len( ONOS1FlowsJson ) == len( ONOS2FlowsJson )\
+ and len( ONOS1FlowsJson ) == len( ONOS3FlowsJson )\
+ and len( ONOS1FlowsJson ) == len( ONOS4FlowsJson )\
+ and len( ONOS1FlowsJson ) == len( ONOS5FlowsJson )\
+ and len( ONOS1FlowsJson ) == len( ONOS6FlowsJson )\
+ and len( ONOS1FlowsJson ) == len( ONOS7FlowsJson ):
+ # TODO: Do a better check, maybe compare flows on switches?
+ flowState = ONOS1Flows
+ flowCheck = main.TRUE
+ main.log.report( "Flow count is consistent across all ONOS nodes" )
+ else:
+ for i in range( 1, numControllers + 1 ):
+ flowsJson = eval( "ONOS" + str( i ) + "FlowsJson" )
+ main.log.warn( "ONOS" + str( i ) + " flows repsponse: " +
+ json.dumps( flowsJson,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=flowCheck,
+ onpass="The flow count is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different flow counts" )
+
+ main.step( "Get the OF Table entries" )
+ global flows
+ flows = []
+ for i in range( 1, 29 ):
+ flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) )
+
+ # TODO: Compare switch flow tables with ONOS flow tables
+
+ main.step( "Start continuous pings" )
+ for i in range( 1, 11 ):
+ source = main.params[ 'PING' ][ 'source' + str( i ) ]
+ target = main.params[ 'PING' ][ 'target' + str( i ) ]
+ main.Mininet2.pingLong(
+ src=source,
+ target=target,
+ pingTime=500 )
+ 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
+
+ main.step( "Collecting topology information from ONOS" )
+ # TODO Refactor to a loop? We want all similar calls together?
+ # So get all "devices" as close together as possible
+ devices = []
+ print "ONOS1"
+ devices.append( main.ONOScli1.devices() )
+ print "ONOS2"
+ devices.append( main.ONOScli2.devices() )
+ print "ONOS3"
+ devices.append( main.ONOScli3.devices() )
+ print "ONOS4"
+ devices.append( main.ONOScli4.devices() )
+ print "ONOS5"
+ devices.append( main.ONOScli5.devices() )
+ print "ONOS6"
+ devices.append( main.ONOScli6.devices() )
+ print "ONOS7"
+ devices.append( main.ONOScli7.devices() )
+ hosts = []
+ hosts.append( main.ONOScli1.hosts() )
+ hosts.append( main.ONOScli2.hosts() )
+ hosts.append( main.ONOScli3.hosts() )
+ hosts.append( main.ONOScli4.hosts() )
+ hosts.append( main.ONOScli5.hosts() )
+ hosts.append( main.ONOScli6.hosts() )
+ hosts.append( main.ONOScli7.hosts() )
+ ports = []
+ ports.append( main.ONOScli1.ports() )
+ ports.append( main.ONOScli2.ports() )
+ ports.append( main.ONOScli3.ports() )
+ ports.append( main.ONOScli4.ports() )
+ ports.append( main.ONOScli5.ports() )
+ ports.append( main.ONOScli6.ports() )
+ ports.append( main.ONOScli7.ports() )
+ links = []
+ links.append( main.ONOScli1.links() )
+ links.append( main.ONOScli2.links() )
+ links.append( main.ONOScli3.links() )
+ links.append( main.ONOScli4.links() )
+ links.append( main.ONOScli5.links() )
+ links.append( main.ONOScli6.links() )
+ links.append( main.ONOScli7.links() )
+ clusters = []
+ clusters.append( main.ONOScli1.clusters() )
+ clusters.append( main.ONOScli2.clusters() )
+ clusters.append( main.ONOScli3.clusters() )
+ clusters.append( main.ONOScli4.clusters() )
+ clusters.append( main.ONOScli5.clusters() )
+ clusters.append( main.ONOScli6.clusters() )
+ clusters.append( main.ONOScli7.clusters() )
+ # Compare json objects for hosts and dataplane clusters
+
+ # hosts
+ consistentHostsResult = main.TRUE
+ for controller in range( len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in hosts[ controller ]:
+ if hosts[ controller ] == hosts[ 0 ]:
+ continue
+ else: # hosts not consistent
+ main.log.report( "hosts from ONOS" +
+ controllerStr +
+ " is inconsistent with ONOS1" )
+ main.log.warn( repr( hosts[ controller ] ) )
+ consistentHostsResult = main.FALSE
+
+ else:
+ main.log.report( "Error in getting ONOS hosts from ONOS" +
+ controllerStr )
+ consistentHostsResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " hosts response: " +
+ repr( hosts[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentHostsResult,
+ onpass="Hosts view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of hosts" )
+
+ # Strongly connected clusters of devices
+ consistentClustersResult = main.TRUE
+ for controller in range( len( clusters ) ):
+ if "Error" not in clusters[ controller ]:
+ if clusters[ controller ] == clusters[ 0 ]:
+ continue
+ else: # clusters not consistent
+ main.log.report( "clusters from ONOS" +
+ controllerStr +
+ " is inconsistent with ONOS1" )
+ consistentClustersResult = main.FALSE
+
+ else:
+ main.log.report( "Error in getting dataplane clusters " +
+ "from ONOS" + controllerStr )
+ consistentClustersResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " clusters response: " +
+ repr( clusters[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentClustersResult,
+ onpass="Clusters view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of clusters" )
+ # there should always only be one cluster
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ utilities.assert_equals(
+ expect=1,
+ actual=numClusters,
+ onpass="ONOS shows 1 SCC",
+ onfail="ONOS shows " +
+ str( numClusters ) +
+ " SCCs" )
+
+ main.step( "Comparing ONOS topology to MN" )
+ devicesResults = main.TRUE
+ portsResults = main.TRUE
+ linksResults = main.TRUE
+ for controller in range( numControllers ):
+ controllerStr = str( controller + 1 )
+ if devices[ controller ] or "Error" not in devices[ controller ]:
+ currentDevicesResult = main.Mininet1.compareSwitches(
+ MNTopo,
+ json.loads(
+ devices[ controller ] ) )
+ else:
+ currentDevicesResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
+
+ if ports[ controller ] or "Error" not in ports[ controller ]:
+ currentPortsResult = main.Mininet1.comparePorts(
+ MNTopo,
+ json.loads(
+ ports[ controller ] ) )
+ else:
+ currentPortsResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentPortsResult,
+ onpass="ONOS" + controllerStr +
+ " ports view is correct",
+ onfail="ONOS" + controllerStr +
+ " ports view is incorrect" )
+
+ if links[ controller ] or "Error" not in links[ controller ]:
+ currentLinksResult = main.Mininet1.compareLinks(
+ MNTopo,
+ json.loads(
+ links[ controller ] ) )
+ else:
+ currentLinksResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
+
+ devicesResults = devicesResults and currentDevicesResult
+ portsResults = portsResults and currentPortsResult
+ linksResults = linksResults and currentLinksResult
+
+ topoResult = devicesResults and portsResults and linksResults\
+ and consistentHostsResult and consistentClustersResult
+ utilities.assert_equals( expect=main.TRUE, actual=topoResult,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
+
+ finalAssert = main.TRUE
+ finalAssert = finalAssert and topoResult and flowCheck \
+ and intentCheck and consistentMastership and rolesNotNull
+ utilities.assert_equals( expect=main.TRUE, actual=finalAssert,
+ onpass="State check successful",
+ onfail="State check NOT successful" )
+
+ def CASE6( self, main ):
+ """
+ The Failure case. We will create IPTables rules here.
+ """
+ import time
+ main.log.report( "Wait 30 seconds instead of inducing a failure" )
+ time.sleep( 30 )
+
+ # 1 blocks 4,5,6,7, mn
+ # 2 blocks 4,5,6,7, mn
+ # 3 blocks 4,5,6,7, mn
+ # 4 block 1,2,3
+ # 5 blocks 1,2,3
+ # 6 blocks 1,2,3
+ # 7 blocks 1,2,3
+
+ # TODO: use new log command
+ logcmd = "log:log \" About to partition the ONOS nodes\""
+ main.ONOScli1.handle.sendline( logcmd )
+ main.ONOScli1.handle.expect( "onos>" )
+ print main.ONOScli1.handle.before
+ main.ONOScli2.handle.sendline( logcmd )
+ main.ONOScli2.handle.expect( "onos>" )
+ print main.ONOScli2.handle.before
+ main.ONOScli3.handle.sendline( logcmd )
+ main.ONOScli3.handle.expect( "onos>" )
+ print main.ONOScli3.handle.before
+ main.ONOScli4.handle.sendline( logcmd )
+ main.ONOScli4.handle.expect( "onos>" )
+ print main.ONOScli4.handle.before
+ main.ONOScli5.handle.sendline( logcmd )
+ main.ONOScli5.handle.expect( "onos>" )
+ print main.ONOScli5.handle.before
+ main.ONOScli6.handle.sendline( logcmd )
+ main.ONOScli6.handle.expect( "onos>" )
+ print main.ONOScli6.handle.before
+ main.ONOScli7.handle.sendline( logcmd )
+ main.ONOScli7.handle.expect( "onos>" )
+ print main.ONOScli7.handle.before
+
+ nodes = []
+ #create list of ONOS components
+ for controller in range( 1, numControllers + 1 ):
+ # loop through ONOS handlers
+ node = getattr( main, ( 'ONOS' + str( controller ) ) )
+ nodes.append( node )
+ for node in nodes:
+ # if node is in first half (rounded down )
+ # ( 0 through 2 ) < ( 3.5 - 1)
+ if nodes.index( node ) < ( numControllers / 2.0 - 1 ):
+ # blocked nodes are the last half ( rounded up )
+ # // is forced integer division
+ for blockNode in nodes[ (numControllers // 2 + 1) * -1: ]:
+ # block all traffic between these ONOS nodes
+ # NOTE: ONOS 1 and 2 don't support state tracking
+ node.setIpTables( blockNode.ip_address, states=False )
+ node.setIpTables( blockNode.ip_address,
+ direction="OUTPUT" , states=False )
+ # block traffic between smaller subcluster and Mininet
+ # TODO make OF controller port confgigurable
+ # FIXME Remove this once ONOS can deal with the conflicting
+ # device mastership
+ node.setIpTables( main.Mininet1.ip_address, 6633,
+ packet_type="tcp", states=False )
+ else: # the larger subcluster
+ # blocked nodes are the first half
+ for blockNode in nodes[ :(numControllers // 2 ) ]:
+ # block all traffic between these ONOS nodes
+ node.setIpTables( blockNode.ip_address )
+ node.setIpTables( blockNode.ip_address,
+ direction="OUTPUT" )
+ #FIXME update this
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=main.TRUE,
+ onpass="Sleeping 30 seconds",
+ onfail="Something is terribly wrong with my math" )
+ main.ONOScli1.handle.sendline( "devices -j" )
+ main.ONOScli1.handle.expect( ["onos>", "\$"] )
+ print main.ONOScli1.handle.before
+ main.ONOScli2.handle.sendline( "devices -j" )
+ main.ONOScli2.handle.expect( ["onos>", "\$"] )
+ print main.ONOScli2.handle.before
+ main.ONOScli3.handle.sendline( "devices -j" )
+ main.ONOScli3.handle.expect( ["onos>", "\$"] )
+ print main.ONOScli3.handle.before
+ main.ONOScli4.handle.sendline( "devices -j" )
+ main.ONOScli4.handle.expect( ["onos>", "\$"] )
+ print main.ONOScli4.handle.before
+ main.ONOScli5.handle.sendline( "devices -j" )
+ main.ONOScli5.handle.expect( ["onos>", "\$"] )
+ print main.ONOScli5.handle.before
+ main.ONOScli6.handle.sendline( "devices -j" )
+ main.ONOScli6.handle.expect( ["onos>", "\$"] )
+ print main.ONOScli6.handle.before
+ main.ONOScli7.handle.sendline( "devices -j" )
+ main.ONOScli7.handle.expect( ["onos>", "\$"] )
+ print main.ONOScli7.handle.before
+ time.sleep(100000)
+
+
+ def CASE7( self, main ):
+ """
+ Check state after ONOS failure
+ """
+ import json
+ main.case( "Running ONOS Constant State Tests" )
+
+ # Assert that each device has a master
+ ONOS1MasterNotNull = main.ONOScli1.rolesNotNull()
+ ONOS2MasterNotNull = main.ONOScli2.rolesNotNull()
+ ONOS3MasterNotNull = main.ONOScli3.rolesNotNull()
+ ONOS4MasterNotNull = main.ONOScli4.rolesNotNull()
+ ONOS5MasterNotNull = main.ONOScli5.rolesNotNull()
+ ONOS6MasterNotNull = main.ONOScli6.rolesNotNull()
+ ONOS7MasterNotNull = main.ONOScli7.rolesNotNull()
+ rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\
+ ONOS3MasterNotNull and ONOS4MasterNotNull and\
+ ONOS5MasterNotNull and ONOS6MasterNotNull and\
+ ONOS7MasterNotNull
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=rolesNotNull,
+ onpass="Each device has a master",
+ onfail="Some devices don't have a master assigned" )
+
+ main.step( "Check if switch roles are consistent across all nodes" )
+ ONOS1Mastership = main.ONOScli1.roles()
+ ONOS2Mastership = main.ONOScli2.roles()
+ ONOS3Mastership = main.ONOScli3.roles()
+ ONOS4Mastership = main.ONOScli4.roles()
+ ONOS5Mastership = main.ONOScli5.roles()
+ ONOS6Mastership = main.ONOScli6.roles()
+ ONOS7Mastership = main.ONOScli7.roles()
+ if "Error" in ONOS1Mastership or not ONOS1Mastership\
+ or "Error" in ONOS2Mastership or not ONOS2Mastership\
+ or "Error" in ONOS3Mastership or not ONOS3Mastership\
+ or "Error" in ONOS4Mastership or not ONOS4Mastership\
+ or "Error" in ONOS5Mastership or not ONOS5Mastership\
+ or "Error" in ONOS6Mastership or not ONOS6Mastership\
+ or "Error" in ONOS7Mastership or not ONOS7Mastership:
+ main.log.error( "Error in getting ONOS mastership" )
+ main.log.warn( "ONOS1 mastership response: " +
+ repr( ONOS1Mastership ) )
+ main.log.warn( "ONOS2 mastership response: " +
+ repr( ONOS2Mastership ) )
+ main.log.warn( "ONOS3 mastership response: " +
+ repr( ONOS3Mastership ) )
+ main.log.warn( "ONOS4 mastership response: " +
+ repr( ONOS4Mastership ) )
+ main.log.warn( "ONOS5 mastership response: " +
+ repr( ONOS5Mastership ) )
+ main.log.warn( "ONOS6 mastership response: " +
+ repr( ONOS6Mastership ) )
+ main.log.warn( "ONOS7 mastership response: " +
+ repr( ONOS7Mastership ) )
+ consistentMastership = main.FALSE
+ elif ONOS1Mastership == ONOS2Mastership\
+ and ONOS1Mastership == ONOS3Mastership\
+ and ONOS1Mastership == ONOS4Mastership\
+ and ONOS1Mastership == ONOS5Mastership\
+ and ONOS1Mastership == ONOS6Mastership\
+ and ONOS1Mastership == ONOS7Mastership:
+ consistentMastership = main.TRUE
+ main.log.report(
+ "Switch roles are consistent across all ONOS nodes" )
+ else:
+ for i in range( 1, numControllers + 1 ):
+ mastership = eval( "ONOS" + str( i ) + "Mastership" )
+ main.log.warn( "ONOS" + str( i ) + " roles: " +
+ json.dumps( json.loads( mastership ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ consistentMastership = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentMastership,
+ onpass="Switch roles are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of switch roles" )
+
+ description2 = "Compare switch roles from before failure"
+ main.step( description2 )
+
+ currentJson = json.loads( ONOS1Mastership )
+ oldJson = json.loads( mastershipState )
+ mastershipCheck = main.TRUE
+ for i in range( 1, 29 ):
+ switchDPID = str(
+ main.Mininet1.getSwitchDPID( switch="s" + str( i ) ) )
+
+ current = [ switch[ 'master' ] for switch in currentJson
+ if switchDPID in switch[ 'id' ] ]
+ old = [ switch[ 'master' ] for switch in oldJson
+ if switchDPID in switch[ 'id' ] ]
+ if current == old:
+ mastershipCheck = mastershipCheck and main.TRUE
+ else:
+ main.log.warn( "Mastership of switch %s changed" % switchDPID )
+ mastershipCheck = main.FALSE
+ if mastershipCheck == main.TRUE:
+ main.log.report( "Mastership of Switches was not changed" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=mastershipCheck,
+ onpass="Mastership of Switches was not changed",
+ onfail="Mastership of some switches changed" )
+ mastershipCheck = mastershipCheck and consistentMastership
+
+ main.step( "Get the intents and compare across all nodes" )
+ ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
+ ONOS2Intents = main.ONOScli2.intents( jsonFormat=True )
+ ONOS3Intents = main.ONOScli3.intents( jsonFormat=True )
+ ONOS4Intents = main.ONOScli4.intents( jsonFormat=True )
+ ONOS5Intents = main.ONOScli5.intents( jsonFormat=True )
+ ONOS6Intents = main.ONOScli6.intents( jsonFormat=True )
+ ONOS7Intents = main.ONOScli7.intents( jsonFormat=True )
+ intentCheck = main.FALSE
+ if "Error" in ONOS1Intents or not ONOS1Intents\
+ or "Error" in ONOS2Intents or not ONOS2Intents\
+ or "Error" in ONOS3Intents or not ONOS3Intents\
+ or "Error" in ONOS4Intents or not ONOS4Intents\
+ or "Error" in ONOS5Intents or not ONOS5Intents\
+ or "Error" in ONOS6Intents or not ONOS6Intents\
+ or "Error" in ONOS7Intents or not ONOS7Intents:
+ main.log.report( "Error in getting ONOS intents" )
+ main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
+ main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) )
+ main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) )
+ main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) )
+ main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) )
+ main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) )
+ main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) )
+ elif ONOS1Intents == ONOS2Intents\
+ and ONOS1Intents == ONOS3Intents\
+ and ONOS1Intents == ONOS4Intents\
+ and ONOS1Intents == ONOS5Intents\
+ and ONOS1Intents == ONOS6Intents\
+ and ONOS1Intents == ONOS7Intents:
+ intentCheck = main.TRUE
+ main.log.report( "Intents are consistent across all ONOS nodes" )
+ else:
+ for i in range( 1, numControllers + 1 ):
+ intents = eval( "ONOS" + str( i ) + "Intents" )
+ main.log.warn( "ONOS" + str( i ) + " intents: " +
+ json.dumps( json.loads( ONOS1Intents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=intentCheck,
+ onpass="Intents are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of intents" )
+ # Print the intent states
+ intents = []
+ intents.append( ONOS1Intents )
+ intents.append( ONOS2Intents )
+ intents.append( ONOS3Intents )
+ intents.append( ONOS4Intents )
+ intents.append( ONOS5Intents )
+ intents.append( ONOS6Intents )
+ intents.append( ONOS7Intents )
+ intentStates = []
+ for node in intents: # Iter through ONOS nodes
+ nodeStates = []
+ for intent in json.loads( node ): # Iter through intents of a node
+ nodeStates.append( intent[ 'state' ] )
+ intentStates.append( nodeStates )
+ out = [ (i, nodeStates.count( i ) ) for i in set( nodeStates ) ]
+ main.log.info( dict( out ) )
+ # NOTE: Hazelcast has no durability, so intents are lost across system
+ # restarts
+ main.step( "Compare current intents with intents before the failure" )
+ # NOTE: this requires case 5 to pass for intentState to be set.
+ # maybe we should stop the test if that fails?
+ sameIntents = main.TRUE
+ if intentState and intentState == ONOS1Intents:
+ sameIntents = main.TRUE
+ main.log.report( "Intents are consistent with before failure" )
+ # TODO: possibly the states have changed? we may need to figure out
+ # what the aceptable states are
+ else:
+ try:
+ main.log.warn( "ONOS1 intents: " )
+ print json.dumps( json.loads( ONOS1Intents ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) )
+ except:
+ pass
+ sameIntents = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameIntents,
+ onpass="Intents are consistent with before failure",
+ onfail="The Intents changed during failure" )
+ intentCheck = intentCheck and sameIntents
+
+ main.step( "Get the OF Table entries and compare to before " +
+ "component failure" )
+ FlowTables = main.TRUE
+ flows2 = []
+ for i in range( 28 ):
+ main.log.info( "Checking flow table on s" + str( i + 1 ) )
+ tmpFlows = main.Mininet2.getFlowTable( 1.3, "s" + str( i + 1 ) )
+ flows2.append( tmpFlows )
+ tempResult = main.Mininet2.flowComp(
+ flow1=flows[ i ],
+ flow2=tmpFlows )
+ FlowTables = FlowTables and tempResult
+ if FlowTables == main.FALSE:
+ main.log.info( "Differences in flow table for switch: s" +
+ str( i + 1 ) )
+ if FlowTables == main.TRUE:
+ main.log.report( "No changes were found in the flow tables" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=FlowTables,
+ onpass="No changes were found in the flow tables",
+ onfail="Changes were found in the flow tables" )
+
+ main.step( "Check the continuous pings to ensure that no packets " +
+ "were dropped during component failure" )
+ # FIXME: This check is always failing. Investigate cause
+ # NOTE: this may be something to do with file permsissions
+ # or slight change in format
+ main.Mininet2.pingKill(
+ main.params[ 'TESTONUSER' ],
+ main.params[ 'TESTONIP' ] )
+ LossInPings = main.FALSE
+ # NOTE: checkForLoss returns main.FALSE with 0% packet loss
+ for i in range( 8, 18 ):
+ main.log.info(
+ "Checking for a loss in pings along flow from s" +
+ str( i ) )
+ LossInPings = main.Mininet2.checkForLoss(
+ "/tmp/ping.h" +
+ str( i ) ) or LossInPings
+ if LossInPings == main.TRUE:
+ main.log.info( "Loss in ping detected" )
+ elif LossInPings == main.ERROR:
+ main.log.info( "There are multiple mininet process running" )
+ elif LossInPings == main.FALSE:
+ main.log.info( "No Loss in the pings" )
+ main.log.report( "No loss of dataplane connectivity" )
+ utilities.assert_equals(
+ expect=main.FALSE,
+ actual=LossInPings,
+ onpass="No Loss of connectivity",
+ onfail="Loss of dataplane connectivity detected" )
+
+ # Test of LeadershipElection
+ # FIXME Update this for network partition case
+ # NOTE: this only works for the sanity test. In case of failures,
+ # leader will likely change
+ leader = ONOS1Ip
+ leaderResult = main.TRUE
+ for controller in range( 1, numControllers + 1 ):
+ # loop through ONOScli handlers
+ node = getattr( main, ( 'ONOScli' + str( controller ) ) )
+ leaderN = node.electionTestLeader()
+ # verify leader is ONOS1
+ if leaderN == leader:
+ # all is well
+ # NOTE: In failure scenario, this could be a new node, maybe
+ # check != ONOS1
+ pass
+ elif leaderN == main.FALSE:
+ # error in response
+ main.log.report( "Something is wrong with " +
+ "electionTestLeader function," +
+ " check the error logs" )
+ leaderResult = main.FALSE
+ elif leader != leaderN:
+ leaderResult = main.FALSE
+ main.log.report( "ONOS" + str( controller ) + " sees " +
+ str( leaderN ) +
+ " as the leader of the election app. " +
+ "Leader should be " + str( leader ) )
+ if leaderResult:
+ main.log.report( "Leadership election tests passed( consistent " +
+ "view of leader across listeners and a new " +
+ "leader was re-elected if applicable )" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=leaderResult,
+ onpass="Leadership election passed",
+ onfail="Something went wrong with Leadership election" )
+
+ result = mastershipCheck and intentCheck and FlowTables and\
+ ( not LossInPings ) and rolesNotNull and leaderResult
+ result = int( result )
+ if result == main.TRUE:
+ main.log.report( "Constant State Tests Passed" )
+ utilities.assert_equals( expect=main.TRUE, actual=result,
+ onpass="Constant State Tests Passed",
+ onfail="Constant state tests failed" )
+
+ def CASE8( self, main ):
+ """
+ Compare topo
+ """
+ import sys
+ # FIXME add this path to params
+ sys.path.append( "/home/admin/sts" )
+ # assumes that sts is already in you PYTHONPATH
+ from sts.topology.teston_topology import TestONTopology
+ import json
+ import time
+
+ description = "Compare ONOS Topology view to Mininet topology"
+ main.case( description )
+ main.log.report( description )
+ 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
+
+ main.step( "Comparing ONOS topology to MN" )
+ devicesResults = main.TRUE
+ portsResults = main.TRUE
+ linksResults = main.TRUE
+ topoResult = main.FALSE
+ elapsed = 0
+ count = 0
+ main.step( "Collecting topology information from ONOS" )
+ startTime = time.time()
+ # Give time for Gossip to work
+ while topoResult == main.FALSE and elapsed < 60:
+ count = count + 1
+ if count > 1:
+ # TODO: Depricate STS usage
+ MNTopo = TestONTopology(
+ main.Mininet1,
+ ctrls )
+ cliStart = time.time()
+ devices = []
+ devices.append( main.ONOScli1.devices() )
+ devices.append( main.ONOScli2.devices() )
+ devices.append( main.ONOScli3.devices() )
+ devices.append( main.ONOScli4.devices() )
+ devices.append( main.ONOScli5.devices() )
+ devices.append( main.ONOScli6.devices() )
+ devices.append( main.ONOScli7.devices() )
+ hosts = []
+ hosts.append( json.loads( main.ONOScli1.hosts() ) )
+ hosts.append( json.loads( main.ONOScli2.hosts() ) )
+ hosts.append( json.loads( main.ONOScli3.hosts() ) )
+ hosts.append( json.loads( main.ONOScli4.hosts() ) )
+ hosts.append( json.loads( main.ONOScli5.hosts() ) )
+ hosts.append( json.loads( main.ONOScli6.hosts() ) )
+ hosts.append( json.loads( main.ONOScli7.hosts() ) )
+ for controller in range( 0, len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ for host in hosts[ controller ]:
+ if host[ 'ipAddresses' ] == []:
+ main.log.error(
+ "DEBUG:Error with host ips on controller" +
+ controllerStr + ": " + str( host ) )
+ ports = []
+ ports.append( main.ONOScli1.ports() )
+ ports.append( main.ONOScli2.ports() )
+ ports.append( main.ONOScli3.ports() )
+ ports.append( main.ONOScli4.ports() )
+ ports.append( main.ONOScli5.ports() )
+ ports.append( main.ONOScli6.ports() )
+ ports.append( main.ONOScli7.ports() )
+ links = []
+ links.append( main.ONOScli1.links() )
+ links.append( main.ONOScli2.links() )
+ links.append( main.ONOScli3.links() )
+ links.append( main.ONOScli4.links() )
+ links.append( main.ONOScli5.links() )
+ links.append( main.ONOScli6.links() )
+ links.append( main.ONOScli7.links() )
+ clusters = []
+ clusters.append( main.ONOScli1.clusters() )
+ clusters.append( main.ONOScli2.clusters() )
+ clusters.append( main.ONOScli3.clusters() )
+ clusters.append( main.ONOScli4.clusters() )
+ clusters.append( main.ONOScli5.clusters() )
+ clusters.append( main.ONOScli6.clusters() )
+ clusters.append( main.ONOScli7.clusters() )
+
+ elapsed = time.time() - startTime
+ cliTime = time.time() - cliStart
+ print "CLI time: " + str( cliTime )
+
+ for controller in range( numControllers ):
+ controllerStr = str( controller + 1 )
+ if devices[ controller ] or "Error" not in devices[
+ controller ]:
+ currentDevicesResult = main.Mininet1.compareSwitches(
+ MNTopo,
+ json.loads(
+ devices[ controller ] ) )
+ else:
+ currentDevicesResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
+
+ if ports[ controller ] or "Error" not in ports[ controller ]:
+ currentPortsResult = main.Mininet1.comparePorts(
+ MNTopo,
+ json.loads(
+ ports[ controller ] ) )
+ else:
+ currentPortsResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentPortsResult,
+ onpass="ONOS" + controllerStr +
+ " ports view is correct",
+ onfail="ONOS" + controllerStr +
+ " ports view is incorrect" )
+
+ if links[ controller ] or "Error" not in links[ controller ]:
+ currentLinksResult = main.Mininet1.compareLinks(
+ MNTopo,
+ json.loads(
+ links[ controller ] ) )
+ else:
+ currentLinksResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
+ devicesResults = devicesResults and currentDevicesResult
+ portsResults = portsResults and currentPortsResult
+ linksResults = linksResults and currentLinksResult
+
+ # Compare json objects for hosts and dataplane clusters
+
+ # hosts
+ consistentHostsResult = main.TRUE
+ for controller in range( len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in hosts[ controller ]:
+ if hosts[ controller ] == hosts[ 0 ]:
+ continue
+ else: # hosts not consistent
+ main.log.report( "hosts from ONOS" + controllerStr +
+ " is inconsistent with ONOS1" )
+ main.log.warn( repr( hosts[ controller ] ) )
+ consistentHostsResult = main.FALSE
+
+ else:
+ main.log.report( "Error in getting ONOS hosts from ONOS" +
+ controllerStr )
+ consistentHostsResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " hosts response: " +
+ repr( hosts[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentHostsResult,
+ onpass="Hosts view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of hosts" )
+
+ # Strongly connected clusters of devices
+ consistentClustersResult = main.TRUE
+ for controller in range( len( clusters ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in clusters[ controller ]:
+ if clusters[ controller ] == clusters[ 0 ]:
+ continue
+ else: # clusters not consistent
+ main.log.report( "clusters from ONOS" +
+ controllerStr +
+ " is inconsistent with ONOS1" )
+ consistentClustersResult = main.FALSE
+
+ else:
+ main.log.report( "Error in getting dataplane clusters " +
+ "from ONOS" + controllerStr )
+ consistentClustersResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " clusters response: " +
+ repr( clusters[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentClustersResult,
+ onpass="Clusters view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of clusters" )
+ # there should always only be one cluster
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ utilities.assert_equals(
+ expect=1,
+ actual=numClusters,
+ onpass="ONOS shows 1 SCC",
+ onfail="ONOS shows " +
+ str( numClusters ) +
+ " SCCs" )
+
+ topoResult = ( devicesResults and portsResults and linksResults
+ and consistentHostsResult
+ and consistentClustersResult )
+
+ topoResult = topoResult and int( count <= 2 )
+ note = "note it takes about " + str( int( cliTime ) ) + \
+ " seconds for the test to make all the cli calls to fetch " +\
+ "the topology from each ONOS instance"
+ main.log.info(
+ "Very crass estimate for topology discovery/convergence( " +
+ str( note ) + " ): " + str( elapsed ) + " seconds, " +
+ str( count ) + " tries" )
+ utilities.assert_equals( expect=main.TRUE, actual=topoResult,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
+ if topoResult == main.TRUE:
+ main.log.report( "ONOS topology view matches Mininet topology" )
+
+ def CASE9( self, main ):
+ """
+ Link s3-s28 down
+ """
+ import time
+ # NOTE: You should probably run a topology check after this
+
+ linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+ description = "Turn off a link to ensure that Link Discovery " +\
+ "is working properly"
+ main.log.report( description )
+ main.case( description )
+
+ main.step( "Kill Link between s3 and s28" )
+ LinkDown = main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
+ main.log.info(
+ "Waiting " +
+ str( linkSleep ) +
+ " seconds for link down to be discovered" )
+ time.sleep( linkSleep )
+ utilities.assert_equals( expect=main.TRUE, actual=LinkDown,
+ onpass="Link down succesful",
+ onfail="Failed to bring link down" )
+ # TODO do some sort of check here
+
+ def CASE10( self, main ):
+ """
+ Link s3-s28 up
+ """
+ import time
+ # NOTE: You should probably run a topology check after this
+
+ linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+ description = "Restore a link to ensure that Link Discovery is " + \
+ "working properly"
+ main.log.report( description )
+ main.case( description )
+
+ main.step( "Bring link between s3 and s28 back up" )
+ LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+ main.log.info(
+ "Waiting " +
+ str( linkSleep ) +
+ " seconds for link up to be discovered" )
+ time.sleep( linkSleep )
+ utilities.assert_equals( expect=main.TRUE, actual=LinkUp,
+ onpass="Link up succesful",
+ onfail="Failed to bring link up" )
+ # TODO do some sort of check here
+
+ def CASE11( self, main ):
+ """
+ Switch Down
+ """
+ # NOTE: You should probably run a topology check after this
+ import time
+
+ switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
+
+ description = "Killing a switch to ensure it is discovered correctly"
+ main.log.report( description )
+ main.case( description )
+ switch = main.params[ 'kill' ][ 'switch' ]
+ switchDPID = main.params[ 'kill' ][ 'dpid' ]
+
+ # TODO: Make this switch parameterizable
+ main.step( "Kill " + switch )
+ main.log.report( "Deleting " + switch )
+ main.Mininet1.delSwitch( switch )
+ main.log.info( "Waiting " + str( switchSleep ) +
+ " seconds for switch down to be discovered" )
+ time.sleep( switchSleep )
+ device = main.ONOScli1.getDevice( dpid=switchDPID )
+ # Peek at the deleted switch
+ main.log.warn( str( device ) )
+ result = main.FALSE
+ if device and device[ 'available' ] is False:
+ result = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=result,
+ onpass="Kill switch succesful",
+ onfail="Failed to kill switch?" )
+
+ def CASE12( self, main ):
+ """
+ Switch Up
+ """
+ # NOTE: You should probably run a topology check after this
+ import time
+
+ switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
+ switch = main.params[ 'kill' ][ 'switch' ]
+ switchDPID = main.params[ 'kill' ][ 'dpid' ]
+ links = main.params[ 'kill' ][ 'links' ].split()
+ description = "Adding a switch to ensure it is discovered correctly"
+ main.log.report( description )
+ main.case( description )
+
+ main.step( "Add back " + switch )
+ main.log.report( "Adding back " + switch )
+ main.Mininet1.addSwitch( switch, dpid=switchDPID )
+ for peer in links:
+ main.Mininet1.addLink( switch, peer )
+ main.Mininet1.assignSwController(
+ sw=switch.split( 's' )[ 1 ],
+ count=numControllers,
+ ip1=ONOS1Ip,
+ port1=ONOS1Port,
+ ip2=ONOS2Ip,
+ port2=ONOS2Port,
+ ip3=ONOS3Ip,
+ port3=ONOS3Port,
+ ip4=ONOS4Ip,
+ port4=ONOS4Port,
+ ip5=ONOS5Ip,
+ port5=ONOS5Port,
+ ip6=ONOS6Ip,
+ port6=ONOS6Port,
+ ip7=ONOS7Ip,
+ port7=ONOS7Port )
+ main.log.info(
+ "Waiting " +
+ str( switchSleep ) +
+ " seconds for switch up to be discovered" )
+ time.sleep( switchSleep )
+ device = main.ONOScli1.getDevice( dpid=switchDPID )
+ # Peek at the deleted switch
+ main.log.warn( str( device ) )
+ result = main.FALSE
+ if device and device[ 'available' ]:
+ result = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=result,
+ onpass="add switch succesful",
+ onfail="Failed to add switch?" )
+
+ def CASE13( self, main ):
+ """
+ Clean up
+ """
+ import os
+ import time
+ # TODO: make use of this elsewhere
+ ips = []
+ ips.append( ONOS1Ip )
+ ips.append( ONOS2Ip )
+ ips.append( ONOS3Ip )
+ ips.append( ONOS4Ip )
+ ips.append( ONOS5Ip )
+ ips.append( ONOS6Ip )
+ ips.append( ONOS7Ip )
+
+ # printing colors to terminal
+ colors = {}
+ colors[ 'cyan' ] = '\033[96m'
+ colors[ 'purple' ] = '\033[95m'
+ colors[ 'blue' ] = '\033[94m'
+ colors[ 'green' ] = '\033[92m'
+ colors[ 'yellow' ] = '\033[93m'
+ colors[ 'red' ] = '\033[91m'
+ colors[ 'end' ] = '\033[0m'
+ description = "Test Cleanup"
+ main.log.report( description )
+ main.case( description )
+ main.step( "Killing tcpdumps" )
+ main.Mininet2.stopTcpdump()
+
+ main.step( "Checking ONOS Logs for errors" )
+ for i in range( 7 ):
+ print colors[ 'purple' ] + "Checking logs for errors on " + \
+ "ONOS" + str( i + 1 ) + ":" + colors[ 'end' ]
+ print main.ONOSbench.checkLogs( ips[ i ] )
+
+ main.step( "Copying MN pcap and ONOS log files to test station" )
+ testname = main.TEST
+ teststationUser = main.params[ 'TESTONUSER' ]
+ teststationIP = main.params[ 'TESTONIP' ]
+ # NOTE: MN Pcap file is being saved to ~/packet_captures
+ # scp this file as MN and TestON aren't necessarily the same vm
+ # FIXME: scp
+ # mn files
+ # TODO: Load these from params
+ # NOTE: must end in /
+ logFolder = "/opt/onos/log/"
+ logFiles = [ "karaf.log", "karaf.log.1" ]
+ # NOTE: must end in /
+ dstDir = "~/packet_captures/"
+ for f in logFiles:
+ for i in range( 7 ):
+ main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" +
+ logFolder + f + " " +
+ teststationUser + "@" +
+ teststationIP + ":" +
+ dstDir + str( testname ) +
+ "-ONOS" + str( i + 1 ) + "-" +
+ f )
+ # std*.log's
+ # NOTE: must end in /
+ logFolder = "/opt/onos/var/"
+ logFiles = [ "stderr.log", "stdout.log" ]
+ # NOTE: must end in /
+ dstDir = "~/packet_captures/"
+ for f in logFiles:
+ for i in range( 7 ):
+ main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" +
+ logFolder + f + " " +
+ teststationUser + "@" +
+ teststationIP + ":" +
+ dstDir + str( testname ) +
+ "-ONOS" + str( i + 1 ) + "-" +
+ f )
+ # sleep so scp can finish
+ time.sleep( 10 )
+ main.step( "Packing and rotating pcap archives" )
+ os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
+
+ # TODO: actually check something here
+ utilities.assert_equals( expect=main.TRUE, actual=main.TRUE,
+ onpass="Test cleanup successful",
+ onfail="Test cleanup NOT successful" )
+
+ def CASE14( self, main ):
+ """
+ start election app on all onos nodes
+ """
+ leaderResult = main.TRUE
+ # install app on onos 1
+ main.log.info( "Install leadership election app" )
+ main.ONOScli1.featureInstall( "onos-app-election" )
+ # wait for election
+ # check for leader
+ leader = main.ONOScli1.electionTestLeader()
+ # verify leader is ONOS1
+ if leader == ONOS1Ip:
+ # all is well
+ pass
+ elif leader is None:
+ # No leader elected
+ main.log.report( "No leader was elected" )
+ leaderResult = main.FALSE
+ elif leader == main.FALSE:
+ # error in response
+ # TODO: add check for "Command not found:" in the driver, this
+ # means the app isn't loaded
+ main.log.report( "Something is wrong with electionTestLeader" +
+ " function, check the error logs" )
+ leaderResult = main.FALSE
+ else:
+ # error in response
+ main.log.report(
+ "Unexpected response from electionTestLeader function:'" +
+ str( leader ) +
+ "'" )
+ leaderResult = main.FALSE
+
+ # install on other nodes and check for leader.
+ # Should be onos1 and each app should show the same leader
+ for controller in range( 2, numControllers + 1 ):
+ # loop through ONOScli handlers
+ node = getattr( main, ( 'ONOScli' + str( controller ) ) )
+ node.featureInstall( "onos-app-election" )
+ leaderN = node.electionTestLeader()
+ # verify leader is ONOS1
+ if leaderN == ONOS1Ip:
+ # all is well
+ pass
+ elif leaderN == main.FALSE:
+ # error in response
+ # TODO: add check for "Command not found:" in the driver, this
+ # means the app isn't loaded
+ main.log.report( "Something is wrong with " +
+ "electionTestLeader function, check the" +
+ " error logs" )
+ leaderResult = main.FALSE
+ elif leader != leaderN:
+ leaderResult = main.FALSE
+ main.log.report( "ONOS" + str( controller ) + " sees " +
+ str( leaderN ) +
+ " as the leader of the election app. Leader" +
+ " should be " +
+ str( leader ) )
+ if leaderResult:
+ main.log.report( "Leadership election tests passed( consistent " +
+ "view of leader across listeners and a leader " +
+ "was elected )" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=leaderResult,
+ onpass="Leadership election passed",
+ onfail="Something went wrong with Leadership election" )
+
+ def CASE15( self, main ):
+ """
+ Check that Leadership Election is still functional
+ """
+ leaderResult = main.TRUE
+ description = "Check that Leadership Election is still functional"
+ main.log.report( description )
+ main.case( description )
+ main.step( "Find current leader and withdraw" )
+ leader = main.ONOScli1.electionTestLeader()
+ withdrawResult = main.FALSE
+ if leader == ONOS1Ip:
+ oldLeader = getattr( main, "ONOScli1" )
+ elif leader == ONOS2Ip:
+ oldLeader = getattr( main, "ONOScli2" )
+ elif leader == ONOS3Ip:
+ oldLeader = getattr( main, "ONOScli3" )
+ elif leader == ONOS4Ip:
+ oldLeader = getattr( main, "ONOScli4" )
+ elif leader == ONOS5Ip:
+ oldLeader = getattr( main, "ONOScli5" )
+ elif leader == ONOS6Ip:
+ oldLeader = getattr( main, "ONOScli6" )
+ elif leader == ONOS7Ip:
+ oldLeader = getattr( main, "ONOScli7" )
+ elif leader is None or leader == main.FALSE:
+ main.log.report(
+ "Leader for the election app should be an ONOS node," +
+ "instead got '" +
+ str( leader ) +
+ "'" )
+ leaderResult = main.FALSE
+ withdrawResult = oldLeader.electionTestWithdraw()
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=withdrawResult,
+ onpass="App was withdrawn from election",
+ onfail="App was not withdrawn from election" )
+
+ main.step( "Make sure new leader is elected" )
+ leaderList = []
+ for controller in range( 1, numControllers + 1 ):
+ # loop through ONOScli handlers
+ node = getattr( main, ( 'ONOScli' + str( controller ) ) )
+ leaderList.append( node.electionTestLeader() )
+ for leaderN in leaderList:
+ if leaderN == leader:
+ main.log.report(
+ "ONOS" +
+ str( controller ) +
+ " still sees " +
+ str( leader ) +
+ " as leader after they withdrew" )
+ leaderResult = main.FALSE
+ elif leaderN == main.FALSE:
+ # error in response
+ # TODO: add check for "Command not found:" in the driver, this
+ # means the app isn't loaded
+ main.log.report( "Something is wrong with " +
+ "electionTestLeader function, " +
+ "check the error logs" )
+ leaderResult = main.FALSE
+ consistentLeader = main.FALSE
+ if len( set( leaderList ) ) == 1:
+ main.log.info( "Each Election-app sees '" +
+ str( leaderList[ 0 ] ) +
+ "' as the leader" )
+ consistentLeader = main.TRUE
+ else:
+ main.log.report(
+ "Inconsistent responses for leader of Election-app:" )
+ for n in range( len( leaderList ) ):
+ main.log.report( "ONOS" + str( n + 1 ) + " response: " +
+ str( leaderList[ n ] ) )
+ if leaderResult:
+ main.log.report( "Leadership election tests passed( consistent " +
+ "view of leader across listeners and a new " +
+ "leader was elected when the old leader " +
+ "resigned )" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=leaderResult,
+ onpass="Leadership election passed",
+ onfail="Something went wrong with Leadership election" )
+
+ main.step( "Run for election on old leader( just so everyone "
+ "is in the hat )" )
+ runResult = oldLeader.electionTestRun()
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=runResult,
+ onpass="App re-ran for election",
+ onfail="App failed to run for election" )
+ if consistentLeader == main.TRUE:
+ afterRun = main.ONOScli1.electionTestLeader()
+ # verify leader didn't just change
+ if afterRun == leaderList[ 0 ]:
+ leaderResult = main.TRUE
+ else:
+ leaderResult = main.FALSE
+ # TODO: assert on run and withdraw results?
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=leaderResult,
+ onpass="Leadership election passed",
+ onfail="Something went wrong with Leadership election after " +
+ "the old leader re-ran for election" )
+ def CASE16( self ):
+ """
+ """
+ main.ONOScli1.handle.sendline( "sudo iptables -F" )
+ main.ONOScli1.handle.expect( "\$" )
+ main.ONOScli2.handle.sendline( "sudo iptables -F" )
+ main.ONOScli2.handle.expect( "\$" )
+ main.ONOScli3.handle.sendline( "sudo iptables -F" )
+ main.ONOScli3.handle.expect( "\$" )
+ main.ONOScli4.handle.sendline( "sudo iptables -F" )
+ main.ONOScli4.handle.expect( "\$" )
+ main.ONOScli5.handle.sendline( "sudo iptables -F" )
+ main.ONOScli5.handle.expect( "\$" )
+ main.ONOScli6.handle.sendline( "sudo iptables -F" )
+ main.ONOScli6.handle.expect( "\$" )
+ main.ONOScli7.handle.sendline( "sudo iptables -F" )
+ main.ONOScli7.handle.expect( "\$" )
+
diff --git a/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.topo b/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.topo
new file mode 100644
index 0000000..7b32cc2
--- /dev/null
+++ b/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.topo
@@ -0,0 +1,170 @@
+<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>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli3>
+
+
+ <ONOScli4>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli4>
+
+
+ <ONOScli5>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli5>
+
+
+ <ONOScli6>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli6>
+
+
+ <ONOScli7>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli7>
+
+ <ONOS1>
+ <host>10.128.30.11</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.30.12</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.30.13</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.128.30.14</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4>
+
+ <ONOS5>
+ <host>10.128.30.15</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOS5>
+
+ <ONOS6>
+ <host>10.128.30.16</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>14</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6>
+
+ <ONOS7>
+ <host>10.128.30.17</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>15</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7>
+
+ <Mininet1>
+ <host>10.128.30.9</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>16</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> </arg3>
+ <controller> none </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.128.30.9</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>17</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </Mininet2>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/HATestNetworkPartition/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/HATestNetworkPartition/__init__.py
diff --git a/TestON/tests/HATestSanity/HATestSanity.params b/TestON/tests/HATestSanity/HATestSanity.params
index ee4374d..2440ec6 100644
--- a/TestON/tests/HATestSanity/HATestSanity.params
+++ b/TestON/tests/HATestSanity/HATestSanity.params
@@ -1,5 +1,24 @@
<PARAMS>
- <testcases>1,2,8,3,4,5,14,[6],8,7,4,15,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ #List of test cases:
+ #CASE1: Compile ONOS and push it to the test machines
+ #CASE2: Assign mastership to controllers
+ #CASE3: Assign intents
+ #CASE4: Ping across added host intents
+ #CASE5: Reading state of ONOS
+ #CASE6: The Failure case. Since this is the Sanity test, we do nothing.
+ #CASE7: Check state after control plane failure
+ #CASE8: Compare topo
+ #CASE9: Link s3-s28 down
+ #CASE10: Link s3-s28 up
+ #CASE11: Switch down
+ #CASE12: Switch up
+ #CASE13: Clean up
+ #CASE14: start election app on all onos nodes
+ #CASE15: Check that Leadership Election is still functional
+ #CASE16: Install Distributed Primitives app
+ #CASE17: Check for basic functionality with distributed primitives
+ #1,2,8,3,4,5,14,16,17,[6],8,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13
+ <testcases>1,2,8,3,4,5,14,16,17,[6],8,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
<ENV>
<cellName>HA</cellName>
</ENV>
diff --git a/TestON/tests/HATestSanity/HATestSanity.py b/TestON/tests/HATestSanity/HATestSanity.py
index 9a95e78..fe513ac 100644
--- a/TestON/tests/HATestSanity/HATestSanity.py
+++ b/TestON/tests/HATestSanity/HATestSanity.py
@@ -19,6 +19,8 @@
CASE13: Clean up
CASE14: start election app on all onos nodes
CASE15: Check that Leadership Election is still functional
+CASE16: Install Distributed Primitives app
+CASE17: Check for basic functionality with distributed primitives
"""
@@ -32,20 +34,27 @@
CASE1 is to compile ONOS and push it to the test machines
Startup sequence:
- git pull
- mvn clean install
- onos-package
cell <name>
onos-verify-cell
NOTE: temporary - onos-remove-raft-logs
+ onos-uninstall
+ start mininet
+ git pull
+ mvn clean install
+ onos-package
onos-install -f
onos-wait-for-start
+ start cli sessions
+ start tcpdump
"""
main.log.report( "ONOS HA Sanity test - initialization" )
main.case( "Setting up test environment" )
+ main.caseExplaination = "Setup the test environment including " +\
+ "installing ONOS, starting Mininet and ONOS" +\
+ "cli sessions."
# TODO: save all the timers and output them for plotting
- # load some vairables from the params file
+ # load some variables from the params file
PULLCODE = False
if main.params[ 'Git' ] == 'True':
PULLCODE = True
@@ -53,38 +62,34 @@
cellName = main.params[ 'ENV' ][ 'cellName' ]
# set global variables
- global ONOS1Ip
global ONOS1Port
- global ONOS2Ip
global ONOS2Port
- global ONOS3Ip
global ONOS3Port
- global ONOS4Ip
global ONOS4Port
- global ONOS5Ip
global ONOS5Port
- global ONOS6Ip
global ONOS6Port
- global ONOS7Ip
global ONOS7Port
global numControllers
-
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
- ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
- ONOS4Port = main.params[ 'CTRL' ][ 'port4' ]
- ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
- ONOS5Port = main.params[ 'CTRL' ][ 'port5' ]
- ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
- ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
- ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
- ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
numControllers = int( main.params[ 'num_controllers' ] )
+ # FIXME: just get controller port from params?
+ # TODO: do we really need all these?
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+ ONOS4Port = main.params[ 'CTRL' ][ 'port4' ]
+ ONOS5Port = main.params[ 'CTRL' ][ 'port5' ]
+ ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
+ ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
+
+ global CLIs
+ CLIs = []
+ global nodes
+ nodes = []
+ for i in range( 1, numControllers + 1 ):
+ CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+ nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+
main.step( "Applying cell variable to environment" )
cellResult = main.ONOSbench.setCell( cellName )
verifyResult = main.ONOSbench.verifyCell()
@@ -92,93 +97,114 @@
# FIXME:this is short term fix
main.log.report( "Removing raft logs" )
main.ONOSbench.onosRemoveRaftLogs()
+
main.log.report( "Uninstalling ONOS" )
- main.ONOSbench.onosUninstall( ONOS1Ip )
- main.ONOSbench.onosUninstall( ONOS2Ip )
- main.ONOSbench.onosUninstall( ONOS3Ip )
- main.ONOSbench.onosUninstall( ONOS4Ip )
- main.ONOSbench.onosUninstall( ONOS5Ip )
- main.ONOSbench.onosUninstall( ONOS6Ip )
- main.ONOSbench.onosUninstall( ONOS7Ip )
+ for node in nodes:
+ main.ONOSbench.onosUninstall( node.ip_address )
+
+ # Make sure ONOS is DEAD
+ main.log.report( "Killing any ONOS processes" )
+ killResults = main.TRUE
+ for node in nodes:
+ killed = main.ONOSbench.onosKill( node.ip_address )
+ killResults = killResults and killed
cleanInstallResult = main.TRUE
gitPullResult = main.TRUE
- main.step( "Compiling the latest version of ONOS" )
+ main.step( "Starting Mininet" )
+ mnResult = main.Mininet1.startNet( )
+ utilities.assert_equals( expect=main.TRUE, actual=mnResult,
+ onpass="Mininet Started",
+ onfail="Error starting Mininet" )
+
+ main.step( "Git checkout and pull " + gitBranch )
if PULLCODE:
- # TODO Configure branch in params
- main.step( "Git checkout and pull master" )
main.ONOSbench.gitCheckout( gitBranch )
gitPullResult = main.ONOSbench.gitPull()
-
- main.step( "Using mvn clean & install" )
- cleanInstallResult = main.ONOSbench.cleanInstall()
+ # values of 1 or 3 are good
+ utilities.assert_lesser( expect=0, actual=gitPullResult,
+ onpass="Git pull successful",
+ onfail="Git pull failed" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
main.ONOSbench.getVersion( report=True )
+ main.step( "Using mvn clean install" )
+ cleanInstallResult = main.TRUE
+ if gitPullResult == main.TRUE:
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cleanInstallResult,
+ onpass="MCI successful",
+ onfail="MCI failed" )
+ # GRAPHS
+ # NOTE: important params here:
+ # job = name of Jenkins job
+ # Plot Name = Plot-HA, only can be used if multiple plots
+ # index = The number of the graph under plot name
+ job = "HASanity"
+ plotName = "Plot-HA"
+ graphs = '<ac:structured-macro ac:name="html">\n'
+ graphs += '<ac:plain-text-body><![CDATA[\n'
+ graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
+ '/plot/' + plotName + '/getPlot?index=0' +\
+ '&width=500&height=300"' +\
+ 'noborder="0" width="500" height="300" scrolling="yes" ' +\
+ 'seamless="seamless"></iframe>\n'
+ graphs += ']]></ac:plain-text-body>\n'
+ graphs += '</ac:structured-macro>\n'
+ main.log.wiki(graphs)
+
main.step( "Creating ONOS package" )
packageResult = main.ONOSbench.onosPackage()
+ utilities.assert_equals( expect=main.TRUE, actual=packageResult,
+ onpass="ONOS package successful",
+ onfail="ONOS package failed" )
main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS1Ip )
- onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS2Ip )
- onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS3Ip )
- onos4InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS4Ip )
- onos5InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS5Ip )
- onos6InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS6Ip )
- onos7InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS7Ip )
- onosInstallResult = onos1InstallResult and onos2InstallResult\
- and onos3InstallResult and onos4InstallResult\
- and onos5InstallResult and onos6InstallResult\
- and onos7InstallResult
+ onosInstallResult = main.TRUE
+ for node in nodes:
+ tmpResult = main.ONOSbench.onosInstall( options="-f",
+ node=node.ip_address )
+ onosInstallResult = onosInstallResult and tmpResult
+ utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
+ onpass="ONOS install successful",
+ onfail="ONOS install failed" )
main.step( "Checking if ONOS is up yet" )
- # TODO check bundle:list?
for i in range( 2 ):
- onos1Isup = main.ONOSbench.isup( ONOS1Ip )
- if not onos1Isup:
- main.log.report( "ONOS1 didn't start!" )
- onos2Isup = main.ONOSbench.isup( ONOS2Ip )
- if not onos2Isup:
- main.log.report( "ONOS2 didn't start!" )
- onos3Isup = main.ONOSbench.isup( ONOS3Ip )
- if not onos3Isup:
- main.log.report( "ONOS3 didn't start!" )
- onos4Isup = main.ONOSbench.isup( ONOS4Ip )
- if not onos4Isup:
- main.log.report( "ONOS4 didn't start!" )
- onos5Isup = main.ONOSbench.isup( ONOS5Ip )
- if not onos5Isup:
- main.log.report( "ONOS5 didn't start!" )
- onos6Isup = main.ONOSbench.isup( ONOS6Ip )
- if not onos6Isup:
- main.log.report( "ONOS6 didn't start!" )
- onos7Isup = main.ONOSbench.isup( ONOS7Ip )
- if not onos7Isup:
- main.log.report( "ONOS7 didn't start!" )
- onosIsupResult = onos1Isup and onos2Isup and onos3Isup\
- and onos4Isup and onos5Isup and onos6Isup and onos7Isup
+ onosIsupResult = main.TRUE
+ for node in nodes:
+ started = main.ONOSbench.isup( node.ip_address )
+ if not started:
+ main.log.report( node.name + " didn't start!" )
+ main.ONOSbench.onosStop( node.ip_address )
+ main.ONOSbench.onosStart( node.ip_address )
+ onosIsupResult = onosIsupResult and started
if onosIsupResult == main.TRUE:
break
+ utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult,
+ onpass="ONOS startup successful",
+ onfail="ONOS startup failed" )
- cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip )
- cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip )
- cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip )
- cliResult4 = main.ONOScli4.startOnosCli( ONOS4Ip )
- cliResult5 = main.ONOScli5.startOnosCli( ONOS5Ip )
- cliResult6 = main.ONOScli6.startOnosCli( ONOS6Ip )
- cliResult7 = main.ONOScli7.startOnosCli( ONOS7Ip )
- cliResults = cliResult1 and cliResult2 and cliResult3 and\
- cliResult4 and cliResult5 and cliResult6 and cliResult7
+ main.log.step( "Starting ONOS CLI sessions" )
+ cliResults = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].startOnosCli,
+ name="startOnosCli-" + str( i ),
+ args=[nodes[i].ip_address] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ cliResults = cliResults and t.result
+ utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+ onpass="ONOS cli startup successful",
+ onfail="ONOS cli startup failed" )
main.step( "Start Packet Capture MN" )
main.Mininet2.startTcpdump(
@@ -187,15 +213,28 @@
intf=main.params[ 'MNtcpdump' ][ 'intf' ],
port=main.params[ 'MNtcpdump' ][ 'port' ] )
- case1Result = ( cleanInstallResult and packageResult and
- cellResult and verifyResult and onosInstallResult
- and onosIsupResult and cliResults )
+ main.step( "App Ids check" )
+ appCheck = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
- utilities.assert_equals( expect=main.TRUE, actual=case1Result,
- onpass="Test startup successful",
- onfail="Test startup NOT successful" )
+ for t in threads:
+ t.join()
+ appCheck = appCheck and t.result
+ if appCheck != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
- if case1Result == main.FALSE:
+ if cliResults == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -204,40 +243,57 @@
Assign mastership to controllers
"""
import re
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
- main.log.report( "Assigning switches to controllers" )
main.case( "Assigning Controllers" )
+ main.caseExplaination = "Assign switches to ONOS using 'ovs-vsctl' " +\
+ "and check that an ONOS node becomes the " +\
+ "master of the device. Then manually assign" +\
+ " mastership to specific ONOS nodes using" +\
+ " 'device-role'"
main.step( "Assign switches to controllers" )
+ # TODO: rewrite this function to take lists of ips and ports?
+ # or list of tuples?
for i in range( 1, 29 ):
main.Mininet1.assignSwController(
sw=str( i ),
count=numControllers,
- ip1=ONOS1Ip, port1=ONOS1Port,
- ip2=ONOS2Ip, port2=ONOS2Port,
- ip3=ONOS3Ip, port3=ONOS3Port,
- ip4=ONOS4Ip, port4=ONOS4Port,
- ip5=ONOS5Ip, port5=ONOS5Port,
- ip6=ONOS6Ip, port6=ONOS6Port,
- ip7=ONOS7Ip, port7=ONOS7Port )
+ ip1=nodes[ 0 ].ip_address, port1=ONOS1Port,
+ ip2=nodes[ 1 ].ip_address, port2=ONOS2Port,
+ ip3=nodes[ 2 ].ip_address, port3=ONOS3Port,
+ ip4=nodes[ 3 ].ip_address, port4=ONOS4Port,
+ ip5=nodes[ 4 ].ip_address, port5=ONOS5Port,
+ ip6=nodes[ 5 ].ip_address, port6=ONOS6Port,
+ ip7=nodes[ 6 ].ip_address, port7=ONOS7Port )
mastershipCheck = main.TRUE
for i in range( 1, 29 ):
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
- if re.search( "tcp:" + ONOS1Ip, response )\
- and re.search( "tcp:" + ONOS2Ip, response )\
- and re.search( "tcp:" + ONOS3Ip, response )\
- and re.search( "tcp:" + ONOS4Ip, response )\
- and re.search( "tcp:" + ONOS5Ip, response )\
- and re.search( "tcp:" + ONOS6Ip, response )\
- and re.search( "tcp:" + ONOS7Ip, response ):
- mastershipCheck = mastershipCheck and main.TRUE
- else:
- mastershipCheck = main.FALSE
+ for node in nodes:
+ if re.search( "tcp:" + node.ip_address, response ):
+ mastershipCheck = mastershipCheck and main.TRUE
+ else:
+ main.log.error( "Error, node " + node.ip_address + " is " +
+ "not in the list of controllers s" +
+ str( i ) + " is connecting to." )
+ mastershipCheck = main.FALSE
if mastershipCheck == main.TRUE:
main.log.report( "Switch mastership assigned correctly" )
utilities.assert_equals(
@@ -246,127 +302,84 @@
onpass="Switch mastership assigned correctly",
onfail="Switches not assigned correctly to controllers" )
+ main.step( "Assign mastership of switches to specific controllers" )
# Manually assign mastership to the controller we want
roleCall = main.TRUE
- roleCheck = main.TRUE
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS1Ip )
- # Check assignment
- if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS1Ip )
- # Check assignment
- if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS2Ip )
- # Check assignment
- if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS2Ip )
- # Check assignment
- if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS3Ip )
- # Check assignment
- if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS3Ip )
- # Check assignment
- if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- # Assign switch
- deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS4Ip )
- # Check assignment
- if ONOS4Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- for i in range( 8, 18 ):
- dpid = '3' + str( i ).zfill( 3 )
- deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS5Ip )
- # Check assignment
- if ONOS5Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS6Ip )
- # Check assignment
- if ONOS6Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
- for i in range( 18, 28 ):
- dpid = '6' + str( i ).zfill( 3 )
- deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
- roleCall = roleCall and main.ONOScli1.deviceRole(
- deviceId,
- ONOS7Ip )
- # Check assignment
- if ONOS7Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
- roleCheck = roleCheck and main.TRUE
- else:
- roleCheck = roleCheck and main.FALSE
-
+ ipList = [ ]
+ deviceList = []
+ try:
+ for i in range( 1, 29 ): # switches 1 through 28
+ # set up correct variables:
+ if i == 1:
+ ip = nodes[ 0 ].ip_address # ONOS1
+ deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
+ elif i == 2:
+ ip = nodes[ 1 ].ip_address # ONOS2
+ deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' )
+ elif i == 3:
+ ip = nodes[ 1 ].ip_address # ONOS2
+ deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' )
+ elif i == 4:
+ ip = nodes[ 3 ].ip_address # ONOS4
+ deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' )
+ elif i == 5:
+ ip = nodes[ 2 ].ip_address # ONOS3
+ deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' )
+ elif i == 6:
+ ip = nodes[ 2 ].ip_address # ONOS3
+ deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' )
+ elif i == 7:
+ ip = nodes[ 5 ].ip_address # ONOS6
+ deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' )
+ elif i >= 8 and i <= 17:
+ ip = nodes[ 4 ].ip_address # ONOS5
+ dpid = '3' + str( i ).zfill( 3 )
+ deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
+ elif i >= 18 and i <= 27:
+ ip = nodes[ 6 ].ip_address # ONOS7
+ dpid = '6' + str( i ).zfill( 3 )
+ deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
+ elif i == 28:
+ ip = nodes[ 0 ].ip_address # ONOS1
+ deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' )
+ else:
+ main.log.error( "You didn't write an else statement for " +
+ "switch s" + str( i ) )
+ # Assign switch
+ assert deviceId, "No device id for s" + str( i ) + " in ONOS"
+ # TODO: make this controller dynamic
+ roleCall = roleCall and main.ONOScli1.deviceRole( deviceId,
+ ip )
+ ipList.append( ip )
+ deviceList.append( deviceId )
+ except ( AttributeError, AssertionError ):
+ main.log.exception( "Something is wrong with ONOS device view" )
+ main.log.info( main.ONOScli1.devices() )
utilities.assert_equals(
expect=main.TRUE,
actual=roleCall,
onpass="Re-assigned switch mastership to designated controller",
onfail="Something wrong with deviceRole calls" )
+ main.step( "Check mastership was correctly assigned" )
+ roleCheck = main.TRUE
+ # NOTE: This is due to the fact that device mastership change is not
+ # atomic and is actually a multi step process
+ time.sleep( 5 )
+ for i in range( len( ipList ) ):
+ ip = ipList[i]
+ deviceId = deviceList[i]
+ # Check assignment
+ master = main.ONOScli1.getRole( deviceId ).get( 'master' )
+ if ip in master:
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+ main.log.error( "Error, controller " + ip + " is not" +
+ " master " + "of device " +
+ str( deviceId ) + ". Master is " +
+ repr( master ) + "." )
utilities.assert_equals(
expect=main.TRUE,
actual=roleCheck,
@@ -384,49 +397,102 @@
Assign intents
"""
import time
- main.log.report( "Adding host intents" )
+ import json
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
main.case( "Adding host Intents" )
-
- main.step( "Discovering Hosts( Via pingall for now )" )
- # FIXME: Once we have a host discovery mechanism, use that instead
+ main.caseExplaination = "Discover hosts by using pingall then " +\
+ "assign predetermined host-to-host intents." +\
+ " After installation, check that the intent" +\
+ " is distributed to all nodes and the state" +\
+ " is INSTALLED"
# install onos-app-fwd
- main.log.info( "Install reactive forwarding app" )
- main.ONOScli1.featureInstall( "onos-app-fwd" )
- main.ONOScli2.featureInstall( "onos-app-fwd" )
- main.ONOScli3.featureInstall( "onos-app-fwd" )
- main.ONOScli4.featureInstall( "onos-app-fwd" )
- main.ONOScli5.featureInstall( "onos-app-fwd" )
- main.ONOScli6.featureInstall( "onos-app-fwd" )
- main.ONOScli7.featureInstall( "onos-app-fwd" )
+ main.step( "Install reactive forwarding app" )
+ installResults = CLIs[0].activateApp( "org.onosproject.fwd" )
+ utilities.assert_equals( expect=main.TRUE, actual=installResults,
+ onpass="Install fwd successful",
+ onfail="Install fwd failed" )
+ main.step( "Check app ids" )
+ appCheck = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ appCheck = appCheck and t.result
+ if appCheck != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+
+ main.step( "Discovering Hosts( Via pingall for now )" )
+ # FIXME: Once we have a host discovery mechanism, use that instead
# REACTIVE FWD test
pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall()
- utilities.assert_equals(
- expect=main.TRUE,
- actual=pingResult,
- onpass="Reactive Pingall test passed",
- onfail="Reactive Pingall failed, one or more ping pairs failed" )
- time2 = time.time()
- main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) )
-
- # uninstall onos-app-fwd
- main.log.info( "Uninstall reactive forwarding app" )
- main.ONOScli1.featureUninstall( "onos-app-fwd" )
- main.ONOScli2.featureUninstall( "onos-app-fwd" )
- main.ONOScli3.featureUninstall( "onos-app-fwd" )
- main.ONOScli4.featureUninstall( "onos-app-fwd" )
- main.ONOScli5.featureUninstall( "onos-app-fwd" )
- main.ONOScli6.featureUninstall( "onos-app-fwd" )
- main.ONOScli7.featureUninstall( "onos-app-fwd" )
+ for i in range(2): # Retry if pingall fails first time
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=pingResult,
+ onpass="Reactive Pingall test passed",
+ onfail="Reactive Pingall failed, " +
+ "one or more ping pairs failed" )
+ time2 = time.time()
+ main.log.info( "Time for pingall: %2f seconds" %
+ ( time2 - time1 ) )
# timeout for fwd flows
- time.sleep( 10 )
+ time.sleep( 11 )
+ # uninstall onos-app-fwd
+ main.step( "Uninstall reactive forwarding app" )
+ uninstallResult = CLIs[0].deactivateApp( "org.onosproject.fwd" )
+ utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
+ onpass="Uninstall fwd successful",
+ onfail="Uninstall fwd failed" )
+ '''
+ main.Mininet1.handle.sendline( "py [ h.cmd( \"arping -c 1 10.1.1.1 \" ) for h in net.hosts ] ")
+ import time
+ time.sleep(60)
+ '''
- main.step( "Add host intents" )
+ main.step( "Check app ids" )
+ threads = []
+ appCheck2 = main.TRUE
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ appCheck2 = appCheck2 and t.result
+ if appCheck2 != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck2,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+
+ main.step( "Add host intents via cli" )
+ intentIds = []
# TODO: move the host numbers to params
+ # Maybe look at all the paths we ping?
intentAddResult = True
+ hostResult = main.TRUE
for i in range( 8, 18 ):
main.log.info( "Adding host intent between h" + str( i ) +
" and h" + str( i + 10 ) )
@@ -434,53 +500,300 @@
str( hex( i )[ 2: ] ).zfill( 2 ).upper()
host2 = "00:00:00:00:00:" + \
str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
- host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
- # NOTE: get host can return None
+ # NOTE: getHost can return None
+ host1Dict = main.ONOScli1.getHost( host1 )
+ host2Dict = main.ONOScli1.getHost( host2 )
+ host1Id = None
+ host2Id = None
+ if host1Dict and host2Dict:
+ host1Id = host1Dict.get( 'id', None )
+ host2Id = host2Dict.get( 'id', None )
if host1Id and host2Id:
- tmpResult = main.ONOScli1.addHostIntent(
- host1Id,
- host2Id )
+ nodeNum = ( i % 7 )
+ tmpId = CLIs[ nodeNum ].addHostIntent( host1Id, host2Id )
+ if tmpId:
+ main.log.info( "Added intent with id: " + tmpId )
+ intentIds.append( tmpId )
+ else:
+ main.log.error( "addHostIntent returned: " +
+ repr( tmpId ) )
else:
- main.log.error( "Error, getHost() failed" )
- tmpResult = main.FALSE
- intentAddResult = bool( pingResult and intentAddResult
- and tmpResult )
- # TODO Check that intents were added?
- utilities.assert_equals(
- expect=True,
- actual=intentAddResult,
- onpass="Pushed host intents to ONOS",
- onfail="Error in pushing host intents to ONOS" )
- # TODO Check if intents all exist in datastore
+ main.log.error( "Error, getHost() failed for h" + str( i ) +
+ " and/or h" + str( i + 10 ) )
+ hosts = CLIs[ 0 ].hosts()
+ main.log.warn( "Hosts output: " )
+ try:
+ main.log.warn( json.dumps( json.loads( hosts ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( hosts ) )
+ hostResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE, actual=hostResult,
+ onpass="Found a host id for each host",
+ onfail="Error looking up host ids" )
+
+ intentStart = time.time()
+ onosIds = main.ONOScli1.getAllIntentsId()
+ main.log.info( "Submitted intents: " + str( intentIds ) )
+ main.log.info( "Intents in ONOS: " + str( onosIds ) )
+ for intent in intentIds:
+ if intent in onosIds:
+ pass # intent submitted is in onos
+ else:
+ intentAddResult = False
+ # FIXME: DEBUG
+ if intentAddResult:
+ intentStop = time.time()
+ else:
+ intentStop = None
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ installedCheck = True
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents" )
+ # add submitted intents not in the store
+ tmplist = [ i for i, s in intentStates ]
+ missingIntents = False
+ for i in intentIds:
+ if i not in tmplist:
+ intentStates.append( ( i, " - " ) )
+ missingIntents = True
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+
+ intentAddResult = bool( intentAddResult and not missingIntents and
+ installedCheck )
+ if not intentAddResult:
+ main.log.error( "Error in pushing host intents to ONOS" )
+
+ main.step( "Intent Anti-Entropy dispersion" )
+ for i in range(100):
+ correct = True
+ main.log.info( "Submitted intents: " + str( sorted( intentIds ) ) )
+ for cli in CLIs:
+ onosIds = []
+ ids = cli.getAllIntentsId()
+ onosIds.append( ids )
+ main.log.debug( "Intents in " + cli.name + ": " +
+ str( sorted( onosIds ) ) )
+ if sorted( ids ) != sorted( intentIds ):
+ correct = False
+ if correct:
+ break
+ else:
+ time.sleep(1)
+ if not intentStop:
+ intentStop = time.time()
+ global gossipTime
+ gossipTime = intentStop - intentStart
+ main.log.info( "It took about " + str( gossipTime ) +
+ " seconds for all intents to appear in each node" )
+ # FIXME: make this time configurable/calculate based off of number of
+ # nodes and gossip rounds
+ utilities.assert_greater_equals(
+ expect=40, actual=gossipTime,
+ onpass="ECM anti-entropy for intents worked within " +
+ "expected time",
+ onfail="Intent ECM anti-entropy took too long" )
+ if gossipTime <= 40:
+ intentAddResult = True
+
+ if not intentAddResult or "key" in pendingMap:
+ import time
+ installedCheck = True
+ main.log.info( "Sleeping 60 seconds to see if intents are found" )
+ time.sleep( 60 )
+ onosIds = main.ONOScli1.getAllIntentsId()
+ main.log.info( "Submitted intents: " + str( intentIds ) )
+ main.log.info( "Intents in ONOS: " + str( onosIds ) )
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ try:
+ for intent in json.loads( intents ):
+ # Iter through intents of a node
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents" )
+ # add submitted intents not in the store
+ tmplist = [ i for i, s in intentStates ]
+ for i in intentIds:
+ if i not in tmplist:
+ intentStates.append( ( i, " - " ) )
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ topics.append( "org.onosproject.election" )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
def CASE4( self, main ):
"""
Ping across added host intents
"""
- description = " Ping across added host intents"
- main.log.report( description )
- main.case( description )
+ import json
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ main.case( "Verify connectivity by sendind traffic across Intents" )
+ main.caseExplaination = "Ping across added host intents to check " +\
+ "functionality and check the state of " +\
+ "the intent"
+ main.step( "Ping across added host intents" )
PingResult = main.TRUE
for i in range( 8, 18 ):
- ping = main.Mininet1.pingHost(
- src="h" + str( i ), target="h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
PingResult = PingResult and ping
if ping == main.FALSE:
main.log.warn( "Ping failed between h" + str( i ) +
" and h" + str( i + 10 ) )
elif ping == main.TRUE:
main.log.info( "Ping test passed!" )
- PingResult = main.TRUE
+ # Don't set PingResult or you'd override failures
if PingResult == main.FALSE:
main.log.report(
"Intents have not been installed correctly, pings failed." )
- #TODO: pretty print
- main.log.warn( "ONSO1 intents: " )
- main.log.warn( json.dumps( json.loads( main.ONOScli1.intents() ),
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
if PingResult == main.TRUE:
main.log.report(
"Intents have been installed correctly and verified by pings" )
@@ -490,344 +803,504 @@
onpass="Intents have been installed correctly and pings work",
onfail="Intents have not been installed correctly, pings failed." )
+ main.step( "Check Intent state" )
+ installedCheck = True
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents." )
+ # Print states
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ utilities.assert_equals( expect=True, actual=installedCheck,
+ onpass="Intents are all INSTALLED",
+ onfail="Intents are not all in " +\
+ "INSTALLED state" )
+
+ main.step( "Check leadership of topics" )
+ leaders = main.ONOScli1.leaders()
+ topicCheck = main.TRUE
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ # TODO: Look at Devices as topics now that it uses this system
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ # FIXME: topics.append( "org.onosproject.election" )
+ # Print leaders output
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ topicCheck = main.FALSE
+ else:
+ main.log.error( "leaders() returned None" )
+ topicCheck = main.FALSE
+ except ( ValueError, TypeError ):
+ topicCheck = main.FALSE
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ # TODO: Check for a leader of these topics
+ utilities.assert_equals( expect=main.TRUE, actual=topicCheck,
+ onpass="intent Partitions is in leaders",
+ onfail="Some topics were lost " )
+ # Print partitions
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ # Print Pending Map
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+
+ if not installedCheck:
+ main.log.info( "Waiting 60 seconds to see if the state of " +
+ "intents change" )
+ time.sleep( 60 )
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents." )
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ topics.append( "org.onosproject.election" )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+ main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+
+ main.step( "Wait a minute then ping again" )
+ PingResult = main.TRUE
+ for i in range( 8, 18 ):
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
+ PingResult = PingResult and ping
+ if ping == main.FALSE:
+ main.log.warn( "Ping failed between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ elif ping == main.TRUE:
+ main.log.info( "Ping test passed!" )
+ # Don't set PingResult or you'd override failures
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Intents have not been installed correctly, pings failed." )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=PingResult,
+ onpass="Intents have been installed correctly and pings work",
+ onfail="Intents have not been installed correctly, pings failed." )
+
+
+
+ '''
+ #DEBUG
+ if PingResult == main.FALSE:
+ import time
+ time.sleep( 100000 )
+ '''
+
def CASE5( self, main ):
"""
Reading state of ONOS
"""
import json
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
- main.log.report( "Setting up and gathering data for current state" )
main.case( "Setting up and gathering data for current state" )
# The general idea for this test case is to pull the state of
# ( intents,flows, topology,... ) from each ONOS node
- # We can then compare them with eachother and also with past states
+ # We can then compare them with each other and also with past states
- main.step( "Get the Mastership of each switch from each controller" )
+ main.step( "Check that each switch has a master" )
global mastershipState
- mastershipState = []
+ mastershipState = '[]'
# Assert that each device has a master
- ONOS1MasterNotNull = main.ONOScli1.rolesNotNull()
- ONOS2MasterNotNull = main.ONOScli2.rolesNotNull()
- ONOS3MasterNotNull = main.ONOScli3.rolesNotNull()
- ONOS4MasterNotNull = main.ONOScli4.rolesNotNull()
- ONOS5MasterNotNull = main.ONOScli5.rolesNotNull()
- ONOS6MasterNotNull = main.ONOScli6.rolesNotNull()
- ONOS7MasterNotNull = main.ONOScli7.rolesNotNull()
- rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\
- ONOS3MasterNotNull and ONOS4MasterNotNull and\
- ONOS5MasterNotNull and ONOS6MasterNotNull and\
- ONOS7MasterNotNull
+ rolesNotNull = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].rolesNotNull,
+ name="rolesNotNull-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ rolesNotNull = rolesNotNull and t.result
utilities.assert_equals(
expect=main.TRUE,
actual=rolesNotNull,
onpass="Each device has a master",
onfail="Some devices don't have a master assigned" )
- ONOS1Mastership = main.ONOScli1.roles()
- ONOS2Mastership = main.ONOScli2.roles()
- ONOS3Mastership = main.ONOScli3.roles()
- ONOS4Mastership = main.ONOScli4.roles()
- ONOS5Mastership = main.ONOScli5.roles()
- ONOS6Mastership = main.ONOScli6.roles()
- ONOS7Mastership = main.ONOScli7.roles()
- # print json.dumps( json.loads( ONOS1Mastership ), sort_keys=True,
- # indent=4, separators=( ',', ': ' ) )
- if "Error" in ONOS1Mastership or not ONOS1Mastership\
- or "Error" in ONOS2Mastership or not ONOS2Mastership\
- or "Error" in ONOS3Mastership or not ONOS3Mastership\
- or "Error" in ONOS4Mastership or not ONOS4Mastership\
- or "Error" in ONOS5Mastership or not ONOS5Mastership\
- or "Error" in ONOS6Mastership or not ONOS6Mastership\
- or "Error" in ONOS7Mastership or not ONOS7Mastership:
- main.log.report( "Error in getting ONOS roles" )
- main.log.warn(
- "ONOS1 mastership response: " +
- repr( ONOS1Mastership ) )
- main.log.warn(
- "ONOS2 mastership response: " +
- repr( ONOS2Mastership ) )
- main.log.warn(
- "ONOS3 mastership response: " +
- repr( ONOS3Mastership ) )
- main.log.warn(
- "ONOS4 mastership response: " +
- repr( ONOS4Mastership ) )
- main.log.warn(
- "ONOS5 mastership response: " +
- repr( ONOS5Mastership ) )
- main.log.warn(
- "ONOS6 mastership response: " +
- repr( ONOS6Mastership ) )
- main.log.warn(
- "ONOS7 mastership response: " +
- repr( ONOS7Mastership ) )
- consistentMastership = main.FALSE
- elif ONOS1Mastership == ONOS2Mastership\
- and ONOS1Mastership == ONOS3Mastership\
- and ONOS1Mastership == ONOS4Mastership\
- and ONOS1Mastership == ONOS5Mastership\
- and ONOS1Mastership == ONOS6Mastership\
- and ONOS1Mastership == ONOS7Mastership:
- mastershipState = ONOS1Mastership
- consistentMastership = main.TRUE
+ main.step( "Get the Mastership of each switch from each controller" )
+ ONOSMastership = []
+ mastershipCheck = main.FALSE
+ consistentMastership = True
+ rolesResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].roles,
+ name="roles-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSMastership.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " roles" )
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " mastership response: " +
+ repr( ONOSMastership[i] ) )
+ rolesResults = False
+ utilities.assert_equals(
+ expect=True,
+ actual=rolesResults,
+ onpass="No error in reading roles output",
+ onfail="Error in reading roles from ONOS" )
+
+ main.step( "Check for consistency in roles from each controller" )
+ if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
main.log.report(
"Switch roles are consistent across all ONOS nodes" )
else:
- main.log.warn(
- "ONOS1 roles: ",
- json.dumps(
- json.loads( ONOS1Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS2 roles: ",
- json.dumps(
- json.loads( ONOS2Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS3 roles: ",
- json.dumps(
- json.loads( ONOS3Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS4 roles: ",
- json.dumps(
- json.loads( ONOS4Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS5 roles: ",
- json.dumps(
- json.loads( ONOS5Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS6 roles: ",
- json.dumps(
- json.loads( ONOS6Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS7 roles: ",
- json.dumps(
- json.loads( ONOS7Mastership ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- consistentMastership = main.FALSE
+ consistentMastership = False
utilities.assert_equals(
- expect=main.TRUE,
+ expect=True,
actual=consistentMastership,
onpass="Switch roles are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of switch roles" )
+ if rolesResults and not consistentMastership:
+ for i in range( numControllers ):
+ try:
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " roles: ",
+ json.dumps(
+ json.loads( ONOSMastership[ i ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( ONOSMastership[ i ] ) )
+ elif rolesResults and consistentMastership:
+ mastershipCheck = main.TRUE
+ mastershipState = ONOSMastership[ 0 ]
+
main.step( "Get the intents from each controller" )
global intentState
intentState = []
- ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
- ONOS2Intents = main.ONOScli2.intents( jsonFormat=True )
- ONOS3Intents = main.ONOScli3.intents( jsonFormat=True )
- ONOS4Intents = main.ONOScli4.intents( jsonFormat=True )
- ONOS5Intents = main.ONOScli5.intents( jsonFormat=True )
- ONOS6Intents = main.ONOScli6.intents( jsonFormat=True )
- ONOS7Intents = main.ONOScli7.intents( jsonFormat=True )
+ ONOSIntents = []
intentCheck = main.FALSE
- if "Error" in ONOS1Intents or not ONOS1Intents\
- or "Error" in ONOS2Intents or not ONOS2Intents\
- or "Error" in ONOS3Intents or not ONOS3Intents\
- or "Error" in ONOS4Intents or not ONOS4Intents\
- or "Error" in ONOS5Intents or not ONOS5Intents\
- or "Error" in ONOS6Intents or not ONOS6Intents\
- or "Error" in ONOS7Intents or not ONOS7Intents:
- main.log.report( "Error in getting ONOS intents" )
- main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
- main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) )
- main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) )
- main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) )
- main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) )
- main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) )
- main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) )
- elif ONOS1Intents == ONOS2Intents\
- and ONOS1Intents == ONOS3Intents\
- and ONOS1Intents == ONOS4Intents\
- and ONOS1Intents == ONOS5Intents\
- and ONOS1Intents == ONOS6Intents\
- and ONOS1Intents == ONOS7Intents:
- intentState = ONOS1Intents
- intentCheck = main.TRUE
- main.log.report( "Intents are consistent across all ONOS nodes" )
- else:
- main.log.warn(
- "ONOS1 intents: ",
- json.dumps(
- json.loads( ONOS1Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS2 intents: ",
- json.dumps(
- json.loads( ONOS2Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS3 intents: ",
- json.dumps(
- json.loads( ONOS3Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS4 intents: ",
- json.dumps(
- json.loads( ONOS4Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS5 intents: ",
- json.dumps(
- json.loads( ONOS5Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS6 intents: ",
- json.dumps(
- json.loads( ONOS6Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
- main.log.warn(
- "ONOS7 intents: ",
- json.dumps(
- json.loads( ONOS7Intents ),
- sort_keys=True,
- indent=4,
- separators=(
- ',',
- ': ' ) ) )
+ consistentIntents = True
+ intentsResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].intents,
+ name="intents-" + str( i ),
+ args=[],
+ kwargs={ 'jsonFormat': True } )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSIntents.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " intents" )
+ main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
+ repr( ONOSIntents[ i ] ) )
+ intentsResults = False
utilities.assert_equals(
- expect=main.TRUE,
- actual=intentCheck,
+ expect=True,
+ actual=intentsResults,
+ onpass="No error in reading intents output",
+ onfail="Error in reading intents from ONOS" )
+
+ main.step( "Check for consistency in Intents from each controller" )
+ if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
+ main.log.report( "Intents are consistent across all ONOS " +
+ "nodes" )
+ else:
+ consistentIntents = False
+ main.log.report( "Intents not consistent" )
+ utilities.assert_equals(
+ expect=True,
+ actual=consistentIntents,
onpass="Intents are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of intents" )
+ if intentsResults:
+ # Try to make it easy to figure out what is happening
+ #
+ # Intent ONOS1 ONOS2 ...
+ # 0x01 INSTALLED INSTALLING
+ # ... ... ...
+ # ... ... ...
+ title = " Id"
+ for n in range( numControllers ):
+ title += " " * 10 + "ONOS" + str( n + 1 )
+ main.log.warn( title )
+ # get all intent keys in the cluster
+ keys = []
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ keys.append( intent.get( 'id' ) )
+ keys = set( keys )
+ for key in keys:
+ row = "%-13s" % key
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ if intent.get( 'id', "Error" ) == key:
+ row += "%-15s" % intent.get( 'state' )
+ main.log.warn( row )
+ # End table view
+
+ if intentsResults and not consistentIntents:
+ # print the json objects
+ n = len(ONOSIntents)
+ main.log.debug( "ONOS" + str( n ) + " intents: " )
+ main.log.debug( json.dumps( json.loads( ONOSIntents[ -1 ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ for i in range( numControllers ):
+ if ONOSIntents[ i ] != ONOSIntents[ -1 ]:
+ main.log.debug( "ONOS" + str( i + 1 ) + " intents: " )
+ main.log.debug( json.dumps( json.loads( ONOSIntents[i] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ else:
+ main.log.debug( nodes[ i ].name + " intents match ONOS" +
+ str( n ) + " intents" )
+ elif intentsResults and consistentIntents:
+ intentCheck = main.TRUE
+ intentState = ONOSIntents[ 0 ]
+
main.step( "Get the flows from each controller" )
global flowState
flowState = []
- ONOS1Flows = main.ONOScli1.flows( jsonFormat=True )
- ONOS2Flows = main.ONOScli2.flows( jsonFormat=True )
- ONOS3Flows = main.ONOScli3.flows( jsonFormat=True )
- ONOS4Flows = main.ONOScli4.flows( jsonFormat=True )
- ONOS5Flows = main.ONOScli5.flows( jsonFormat=True )
- ONOS6Flows = main.ONOScli6.flows( jsonFormat=True )
- ONOS7Flows = main.ONOScli7.flows( jsonFormat=True )
- ONOS1FlowsJson = json.loads( ONOS1Flows )
- ONOS2FlowsJson = json.loads( ONOS2Flows )
- ONOS3FlowsJson = json.loads( ONOS3Flows )
- ONOS4FlowsJson = json.loads( ONOS4Flows )
- ONOS5FlowsJson = json.loads( ONOS5Flows )
- ONOS6FlowsJson = json.loads( ONOS6Flows )
- ONOS7FlowsJson = json.loads( ONOS7Flows )
+ ONOSFlows = []
+ ONOSFlowsJson = []
flowCheck = main.FALSE
- if "Error" in ONOS1Flows or not ONOS1Flows\
- or "Error" in ONOS2Flows or not ONOS2Flows\
- or "Error" in ONOS3Flows or not ONOS3Flows\
- or "Error" in ONOS4Flows or not ONOS4Flows\
- or "Error" in ONOS5Flows or not ONOS5Flows\
- or "Error" in ONOS6Flows or not ONOS6Flows\
- or "Error" in ONOS7Flows or not ONOS7Flows:
- main.log.report( "Error in getting ONOS intents" )
- main.log.warn( "ONOS1 flows repsponse: " + ONOS1Flows )
- main.log.warn( "ONOS2 flows repsponse: " + ONOS2Flows )
- main.log.warn( "ONOS3 flows repsponse: " + ONOS3Flows )
- main.log.warn( "ONOS4 flows repsponse: " + ONOS4Flows )
- main.log.warn( "ONOS5 flows repsponse: " + ONOS5Flows )
- main.log.warn( "ONOS6 flows repsponse: " + ONOS6Flows )
- main.log.warn( "ONOS7 flows repsponse: " + ONOS7Flows )
- elif len( ONOS1FlowsJson ) == len( ONOS2FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS3FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS4FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS5FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS6FlowsJson )\
- and len( ONOS1FlowsJson ) == len( ONOS7FlowsJson ):
- # TODO: Do a better check, maybe compare flows on switches?
- flowState = ONOS1Flows
- flowCheck = main.TRUE
+ consistentFlows = True
+ flowsResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].flows,
+ name="flows-" + str( i ),
+ args=[],
+ kwargs={ 'jsonFormat': True } )
+ threads.append( t )
+ t.start()
+
+ # NOTE: Flows command can take some time to run
+ time.sleep(30)
+ for t in threads:
+ t.join()
+ result = t.result
+ ONOSFlows.append( result )
+
+ for i in range( numControllers ):
+ num = str( i + 1 )
+ if not ONOSFlows[ i ] or "Error" in ONOSFlows[ i ]:
+ main.log.report( "Error in getting ONOS" + num + " flows" )
+ main.log.warn( "ONOS" + num + " flows response: " +
+ repr( ONOSFlows[ i ] ) )
+ flowsResults = False
+ ONOSFlowsJson.append( None )
+ else:
+ try:
+ ONOSFlowsJson.append( json.loads( ONOSFlows[ i ] ) )
+ except ( ValueError, TypeError ):
+ # FIXME: change this to log.error?
+ main.log.exception( "Error in parsing ONOS" + num +
+ " response as json." )
+ main.log.error( repr( ONOSFlows[ i ] ) )
+ ONOSFlowsJson.append( None )
+ flowsResults = False
+ utilities.assert_equals(
+ expect=True,
+ actual=flowsResults,
+ onpass="No error in reading flows output",
+ onfail="Error in reading flows from ONOS" )
+
+ main.step( "Check for consistency in Flows from each controller" )
+ tmp = [ len( i ) == len( ONOSFlowsJson[ 0 ] ) for i in ONOSFlowsJson ]
+ if all( tmp ):
main.log.report( "Flow count is consistent across all ONOS nodes" )
else:
- main.log.warn( "ONOS1 flows: " +
- json.dumps( ONOS1FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS2 flows: " +
- json.dumps( ONOS2FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS3 flows: " +
- json.dumps( ONOS3FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS4 flows: " +
- json.dumps( ONOS4FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS5 flows: " +
- json.dumps( ONOS5FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS6 flows: " +
- json.dumps( ONOS6FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS7 flows: " +
- json.dumps( ONOS7FlowsJson, sort_keys=True,
- indent=4, separators=( ',', ': ' ) ) )
+ consistentFlows = False
utilities.assert_equals(
- expect=main.TRUE,
- actual=flowCheck,
+ expect=True,
+ actual=consistentFlows,
onpass="The flow count is consistent across all ONOS nodes",
onfail="ONOS nodes have different flow counts" )
+ if flowsResults and not consistentFlows:
+ for i in range( numControllers ):
+ try:
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " flows: " +
+ json.dumps( json.loads( ONOSFlows[i] ), sort_keys=True,
+ indent=4, separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " flows: " +
+ repr( ONOSFlows[ i ] ) )
+ elif flowsResults and consistentFlows:
+ flowCheck = main.TRUE
+ flowState = ONOSFlows[ 0 ]
+
main.step( "Get the OF Table entries" )
global flows
flows = []
for i in range( 1, 29 ):
flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) )
-
+ if flowCheck == main.FALSE:
+ for table in flows:
+ main.log.warn( table )
# TODO: Compare switch flow tables with ONOS flow tables
main.step( "Start continuous pings" )
@@ -874,67 +1347,84 @@
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
+ for node in nodes:
+ temp = ( node, node.name, node.ip_address, 6633 )
+ ctrls.append( temp )
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
main.step( "Collecting topology information from ONOS" )
devices = []
- devices.append( main.ONOScli1.devices() )
- devices.append( main.ONOScli2.devices() )
- devices.append( main.ONOScli3.devices() )
- devices.append( main.ONOScli4.devices() )
- devices.append( main.ONOScli5.devices() )
- devices.append( main.ONOScli6.devices() )
- devices.append( main.ONOScli7.devices() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].devices,
+ name="devices-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ devices.append( t.result )
hosts = []
- hosts.append( main.ONOScli1.hosts() )
- hosts.append( main.ONOScli2.hosts() )
- hosts.append( main.ONOScli3.hosts() )
- hosts.append( main.ONOScli4.hosts() )
- hosts.append( main.ONOScli5.hosts() )
- hosts.append( main.ONOScli6.hosts() )
- hosts.append( main.ONOScli7.hosts() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].hosts,
+ name="hosts-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ try:
+ hosts.append( json.loads( t.result ) )
+ except ( ValueError, TypeError ):
+ # FIXME: better handling of this, print which node
+ # Maybe use thread name?
+ main.log.exception( "Error parsing json output of hosts" )
+ # FIXME: should this be an empty json object instead?
+ hosts.append( None )
+
ports = []
- ports.append( main.ONOScli1.ports() )
- ports.append( main.ONOScli2.ports() )
- ports.append( main.ONOScli3.ports() )
- ports.append( main.ONOScli4.ports() )
- ports.append( main.ONOScli5.ports() )
- ports.append( main.ONOScli6.ports() )
- ports.append( main.ONOScli7.ports() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].ports,
+ name="ports-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ports.append( t.result )
links = []
- links.append( main.ONOScli1.links() )
- links.append( main.ONOScli2.links() )
- links.append( main.ONOScli3.links() )
- links.append( main.ONOScli4.links() )
- links.append( main.ONOScli5.links() )
- links.append( main.ONOScli6.links() )
- links.append( main.ONOScli7.links() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].links,
+ name="links-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ links.append( t.result )
clusters = []
- clusters.append( main.ONOScli1.clusters() )
- clusters.append( main.ONOScli2.clusters() )
- clusters.append( main.ONOScli3.clusters() )
- clusters.append( main.ONOScli4.clusters() )
- clusters.append( main.ONOScli5.clusters() )
- clusters.append( main.ONOScli6.clusters() )
- clusters.append( main.ONOScli7.clusters() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].clusters,
+ name="clusters-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ clusters.append( t.result )
# Compare json objects for hosts and dataplane clusters
# hosts
+ main.step( "Host view is consistent across ONOS nodes" )
consistentHostsResult = main.TRUE
for controller in range( len( hosts ) ):
controllerStr = str( controller + 1 )
@@ -961,15 +1451,31 @@
onpass="Hosts view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of hosts" )
+ main.step( "Each host has an IP address" )
+ ipResult = main.TRUE
+ for controller in range( 0, len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ for host in hosts[ controller ]:
+ if not host.get( 'ipAddresses', [ ] ):
+ main.log.error( "DEBUG:Error with host ips on controller" +
+ controllerStr + ": " + str( host ) )
+ ipResult = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=ipResult,
+ onpass="The ips of the hosts aren't empty",
+ onfail="The ip of at least one host is missing" )
+
# Strongly connected clusters of devices
+ main.step( "Cluster view is consistent across ONOS nodes" )
consistentClustersResult = main.TRUE
for controller in range( len( clusters ) ):
+ controllerStr = str( controller + 1 )
if "Error" not in clusters[ controller ]:
if clusters[ controller ] == clusters[ 0 ]:
continue
else: # clusters not consistent
- main.log.report( "clusters from ONOS" +
- controllerStr +
+ main.log.report( "clusters from ONOS" + controllerStr +
" is inconsistent with ONOS1" )
consistentClustersResult = main.FALSE
@@ -986,14 +1492,20 @@
onpass="Clusters view is consistent across all ONOS nodes",
onfail="ONOS nodes have different views of clusters" )
# there should always only be one cluster
- numClusters = len( json.loads( clusters[ 0 ] ) )
+ main.step( "Cluster view correct across ONOS nodes" )
+ try:
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing clusters[0]: " +
+ repr( clusters[ 0 ] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
utilities.assert_equals(
expect=1,
actual=numClusters,
onpass="ONOS shows 1 SCC",
- onfail="ONOS shows " +
- str( numClusters ) +
- " SCCs" )
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
@@ -1004,68 +1516,64 @@
if devices[ controller ] or "Error" not in devices[ controller ]:
currentDevicesResult = main.Mininet1.compareSwitches(
MNTopo,
- json.loads(
- devices[ controller ] ) )
+ json.loads( devices[ controller ] ) )
else:
currentDevicesResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentDevicesResult,
- onpass="ONOS" + controllerStr +
- " Switches view is correct",
- onfail="ONOS" + controllerStr +
- " Switches view is incorrect" )
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
if ports[ controller ] or "Error" not in ports[ controller ]:
currentPortsResult = main.Mininet1.comparePorts(
MNTopo,
- json.loads(
- ports[ controller ] ) )
+ json.loads( ports[ controller ] ) )
else:
currentPortsResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentPortsResult,
- onpass="ONOS" + controllerStr +
- " ports view is correct",
- onfail="ONOS" + controllerStr +
- " ports view is incorrect" )
+ actual=currentPortsResult,
+ onpass="ONOS" + controllerStr +
+ " ports view is correct",
+ onfail="ONOS" + controllerStr +
+ " ports view is incorrect" )
if links[ controller ] or "Error" not in links[ controller ]:
currentLinksResult = main.Mininet1.compareLinks(
MNTopo,
- json.loads(
- links[ controller ] ) )
+ json.loads( links[ controller ] ) )
else:
currentLinksResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentLinksResult,
- onpass="ONOS" + controllerStr +
- " links view is correct",
- onfail="ONOS" + controllerStr +
- " links view is incorrect" )
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
devicesResults = devicesResults and currentDevicesResult
portsResults = portsResults and currentPortsResult
linksResults = linksResults and currentLinksResult
- topoResult = devicesResults and portsResults and linksResults\
- and consistentHostsResult and consistentClustersResult
+ topoResult = ( devicesResults and portsResults and linksResults
+ and consistentHostsResult and consistentClustersResult
+ and clusterResults and ipResult )
utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
-
- finalAssert = main.TRUE
- finalAssert = finalAssert and topoResult and flowCheck \
- and intentCheck and consistentMastership and rolesNotNull
- utilities.assert_equals( expect=main.TRUE, actual=finalAssert,
- onpass="State check successful",
- onfail="State check NOT successful" )
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
def CASE6( self, main ):
"""
The Failure case. Since this is the Sanity test, we do nothing.
"""
import time
- main.log.report( "Wait 60 seconds instead of inducing a failure" )
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ main.case( "Wait 60 seconds instead of inducing a failure" )
time.sleep( 60 )
utilities.assert_equals(
expect=main.TRUE,
@@ -1078,109 +1586,104 @@
Check state after ONOS failure
"""
import json
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
main.case( "Running ONOS Constant State Tests" )
+ main.step( "Check that each switch has a master" )
# Assert that each device has a master
- ONOS1MasterNotNull = main.ONOScli1.rolesNotNull()
- ONOS2MasterNotNull = main.ONOScli2.rolesNotNull()
- ONOS3MasterNotNull = main.ONOScli3.rolesNotNull()
- ONOS4MasterNotNull = main.ONOScli4.rolesNotNull()
- ONOS5MasterNotNull = main.ONOScli5.rolesNotNull()
- ONOS6MasterNotNull = main.ONOScli6.rolesNotNull()
- ONOS7MasterNotNull = main.ONOScli7.rolesNotNull()
- rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\
- ONOS3MasterNotNull and ONOS4MasterNotNull and\
- ONOS5MasterNotNull and ONOS6MasterNotNull and\
- ONOS7MasterNotNull
+ rolesNotNull = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].rolesNotNull,
+ name="rolesNotNull-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ rolesNotNull = rolesNotNull and t.result
utilities.assert_equals(
expect=main.TRUE,
actual=rolesNotNull,
onpass="Each device has a master",
onfail="Some devices don't have a master assigned" )
- main.step( "Check if switch roles are consistent across all nodes" )
- ONOS1Mastership = main.ONOScli1.roles()
- ONOS2Mastership = main.ONOScli2.roles()
- ONOS3Mastership = main.ONOScli3.roles()
- ONOS4Mastership = main.ONOScli4.roles()
- ONOS5Mastership = main.ONOScli5.roles()
- ONOS6Mastership = main.ONOScli6.roles()
- ONOS7Mastership = main.ONOScli7.roles()
- # print json.dumps( json.loads( ONOS1Mastership ), sort_keys=True,
- # indent=4, separators=( ',', ': ' ) )
- if "Error" in ONOS1Mastership or not ONOS1Mastership\
- or "Error" in ONOS2Mastership or not ONOS2Mastership\
- or "Error" in ONOS3Mastership or not ONOS3Mastership\
- or "Error" in ONOS4Mastership or not ONOS4Mastership\
- or "Error" in ONOS5Mastership or not ONOS5Mastership\
- or "Error" in ONOS6Mastership or not ONOS6Mastership\
- or "Error" in ONOS7Mastership or not ONOS7Mastership:
- main.log.error( "Error in getting ONOS mastership" )
- main.log.warn( "ONOS1 mastership response: " +
- repr( ONOS1Mastership ) )
- main.log.warn( "ONOS2 mastership response: " +
- repr( ONOS2Mastership ) )
- main.log.warn( "ONOS3 mastership response: " +
- repr( ONOS3Mastership ) )
- main.log.warn( "ONOS4 mastership response: " +
- repr( ONOS4Mastership ) )
- main.log.warn( "ONOS5 mastership response: " +
- repr( ONOS5Mastership ) )
- main.log.warn( "ONOS6 mastership response: " +
- repr( ONOS6Mastership ) )
- main.log.warn( "ONOS7 mastership response: " +
- repr( ONOS7Mastership ) )
- consistentMastership = main.FALSE
- elif ONOS1Mastership == ONOS2Mastership\
- and ONOS1Mastership == ONOS3Mastership\
- and ONOS1Mastership == ONOS4Mastership\
- and ONOS1Mastership == ONOS5Mastership\
- and ONOS1Mastership == ONOS6Mastership\
- and ONOS1Mastership == ONOS7Mastership:
- consistentMastership = main.TRUE
+ main.step( "Read device roles from ONOS" )
+ ONOSMastership = []
+ mastershipCheck = main.FALSE
+ consistentMastership = True
+ rolesResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].roles,
+ name="roles-" + str( i ),
+ args=[] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSMastership.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " roles" )
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " mastership response: " +
+ repr( ONOSMastership[i] ) )
+ rolesResults = False
+ utilities.assert_equals(
+ expect=True,
+ actual=rolesResults,
+ onpass="No error in reading roles output",
+ onfail="Error in reading roles from ONOS" )
+
+ main.step( "Check for consistency in roles from each controller" )
+ if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
main.log.report(
"Switch roles are consistent across all ONOS nodes" )
else:
- main.log.warn( "ONOS1 roles: ", json.dumps(
- json.loads( ONOS1Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS2 roles: ", json.dumps(
- json.loads( ONOS2Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS3 roles: ", json.dumps(
- json.loads( ONOS3Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS4 roles: ", json.dumps(
- json.loads( ONOS4Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS5 roles: ", json.dumps(
- json.loads( ONOS5Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS6 roles: ", json.dumps(
- json.loads( ONOS6Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- main.log.warn( "ONOS7 roles: ", json.dumps(
- json.loads( ONOS7Mastership ), sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
- consistentMastership = main.FALSE
+ consistentMastership = False
utilities.assert_equals(
- expect=main.TRUE,
+ expect=True,
actual=consistentMastership,
onpass="Switch roles are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of switch roles" )
+ if rolesResults and not consistentMastership:
+ for i in range( numControllers ):
+ main.log.warn(
+ "ONOS" + str( i + 1 ) + " roles: ",
+ json.dumps(
+ json.loads( ONOSMastership[ i ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ elif rolesResults and not consistentMastership:
+ mastershipCheck = main.TRUE
+
description2 = "Compare switch roles from before failure"
main.step( description2 )
-
- currentJson = json.loads( ONOS1Mastership )
- oldJson = json.loads( mastershipState )
+ try:
+ currentJson = json.loads( ONOSMastership[0] )
+ oldJson = json.loads( mastershipState )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Something is wrong with parsing " +
+ "ONOSMastership[0] or mastershipState" )
+ main.log.error( "ONOSMastership[0]: " + repr( ONOSMastership[0] ) )
+ main.log.error( "mastershipState" + repr( mastershipState ) )
+ main.cleanup()
+ main.exit()
mastershipCheck = main.TRUE
for i in range( 1, 29 ):
switchDPID = str(
- main.Mininet1.getSwitchDPID(
- switch="s" +
- str( i ) ) )
-
+ main.Mininet1.getSwitchDPID( switch="s" + str( i ) ) )
current = [ switch[ 'master' ] for switch in currentJson
if switchDPID in switch[ 'id' ] ]
old = [ switch[ 'master' ] for switch in oldJson
@@ -1190,8 +1693,6 @@
else:
main.log.warn( "Mastership of switch %s changed" % switchDPID )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Mastership of Switches was not changed" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
@@ -1200,83 +1701,120 @@
mastershipCheck = mastershipCheck and consistentMastership
main.step( "Get the intents and compare across all nodes" )
- ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
- ONOS2Intents = main.ONOScli2.intents( jsonFormat=True )
- ONOS3Intents = main.ONOScli3.intents( jsonFormat=True )
- ONOS4Intents = main.ONOScli4.intents( jsonFormat=True )
- ONOS5Intents = main.ONOScli5.intents( jsonFormat=True )
- ONOS6Intents = main.ONOScli6.intents( jsonFormat=True )
- ONOS7Intents = main.ONOScli7.intents( jsonFormat=True )
+ ONOSIntents = []
intentCheck = main.FALSE
- if "Error" in ONOS1Intents or not ONOS1Intents\
- or "Error" in ONOS2Intents or not ONOS2Intents\
- or "Error" in ONOS3Intents or not ONOS3Intents\
- or "Error" in ONOS4Intents or not ONOS4Intents\
- or "Error" in ONOS5Intents or not ONOS5Intents\
- or "Error" in ONOS6Intents or not ONOS6Intents\
- or "Error" in ONOS7Intents or not ONOS7Intents:
- main.log.report( "Error in getting ONOS intents" )
- main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
- main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) )
- main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) )
- main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) )
- main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) )
- main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) )
- main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) )
- elif ONOS1Intents == ONOS2Intents\
- and ONOS1Intents == ONOS3Intents\
- and ONOS1Intents == ONOS4Intents\
- and ONOS1Intents == ONOS5Intents\
- and ONOS1Intents == ONOS6Intents\
- and ONOS1Intents == ONOS7Intents:
- intentCheck = main.TRUE
- main.log.report( "Intents are consistent across all ONOS nodes" )
- else:
- main.log.warn( "ONOS1 intents: " )
- print json.dumps( json.loads( ONOS1Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS2 intents: " )
- print json.dumps( json.loads( ONOS2Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS3 intents: " )
- print json.dumps( json.loads( ONOS3Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS4 intents: " )
- print json.dumps( json.loads( ONOS4Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS5 intents: " )
- print json.dumps( json.loads( ONOS5Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS6 intents: " )
- print json.dumps( json.loads( ONOS6Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
- main.log.warn( "ONOS7 intents: " )
- print json.dumps( json.loads( ONOS7Intents ), sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
+ consistentIntents = True
+ intentsResults = True
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].intents,
+ name="intents-" + str( i ),
+ args=[],
+ kwargs={ 'jsonFormat': True } )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ONOSIntents.append( t.result )
+
+ for i in range( numControllers ):
+ if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
+ main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ " intents" )
+ main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
+ repr( ONOSIntents[ i ] ) )
+ intentsResults = False
utilities.assert_equals(
- expect=main.TRUE,
- actual=intentCheck,
+ expect=True,
+ actual=intentsResults,
+ onpass="No error in reading intents output",
+ onfail="Error in reading intents from ONOS" )
+
+ main.step( "Check for consistency in Intents from each controller" )
+ if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
+ main.log.report( "Intents are consistent across all ONOS " +
+ "nodes" )
+ else:
+ consistentIntents = False
+
+ # Try to make it easy to figure out what is happening
+ #
+ # Intent ONOS1 ONOS2 ...
+ # 0x01 INSTALLED INSTALLING
+ # ... ... ...
+ # ... ... ...
+ title = " ID"
+ for n in range( numControllers ):
+ title += " " * 10 + "ONOS" + str( n + 1 )
+ main.log.warn( title )
+ # get all intent keys in the cluster
+ keys = []
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ keys.append( intent.get( 'id' ) )
+ keys = set( keys )
+ for key in keys:
+ row = "%-13s" % key
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ if intent.get( 'id' ) == key:
+ row += "%-15s" % intent.get( 'state' )
+ main.log.warn( row )
+ # End table view
+
+ utilities.assert_equals(
+ expect=True,
+ actual=consistentIntents,
onpass="Intents are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of intents" )
+ intentStates = []
+ for node in ONOSIntents: # Iter through ONOS nodes
+ nodeStates = []
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( node ):
+ nodeStates.append( intent[ 'state' ] )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error in parsing intents" )
+ main.log.error( repr( node ) )
+ intentStates.append( nodeStates )
+ out = [ (i, nodeStates.count( i ) ) for i in set( nodeStates ) ]
+ main.log.info( dict( out ) )
- # NOTE: Hazelcast has no durability, so intents are lost across system
- # restarts
+ if intentsResults and not consistentIntents:
+ for i in range( numControllers ):
+ main.log.warn( "ONOS" + str( i + 1 ) + " intents: " )
+ main.log.warn( json.dumps(
+ json.loads( ONOSIntents[ i ] ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ elif intentsResults and consistentIntents:
+ intentCheck = main.TRUE
+
+ # NOTE: Store has no durability, so intents are lost across system
+ # restarts
main.step( "Compare current intents with intents before the failure" )
# NOTE: this requires case 5 to pass for intentState to be set.
# maybe we should stop the test if that fails?
- if intentState == ONOS1Intents:
+ sameIntents = main.TRUE
+ if intentState and intentState == ONOSIntents[ 0 ]:
sameIntents = main.TRUE
- main.log.report( "Intents are consistent with before failure" )
+ main.log.info( "Intents are consistent with before failure" )
# TODO: possibly the states have changed? we may need to figure out
- # what the aceptable states are
+ # what the acceptable states are
else:
try:
- main.log.warn( "ONOS1 intents: " )
- print json.dumps( json.loads( ONOS1Intents ),
- sort_keys=True, indent=4,
- separators=( ',', ': ' ) )
- except:
- pass
+ main.log.warn( "ONOS intents: " )
+ main.log.warn( json.dumps( json.loads( ONOSIntents[ 0 ] ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Exception printing intents" )
+ main.log.warn( repr( ONOSIntents[0] ) )
sameIntents = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
@@ -1300,8 +1838,6 @@
if FlowTables == main.FALSE:
main.log.info( "Differences in flow table for switch: s" +
str( i + 1 ) )
- if FlowTables == main.TRUE:
- main.log.report( "No changes were found in the flow tables" )
utilities.assert_equals(
expect=main.TRUE,
actual=FlowTables,
@@ -1310,12 +1846,8 @@
main.step( "Check the continuous pings to ensure that no packets " +
"were dropped during component failure" )
- # FIXME: This check is always failing. Investigate cause
- # NOTE: this may be something to do with file permsissions
- # or slight change in format
- main.Mininet2.pingKill(
- main.params[ 'TESTONUSER' ],
- main.params[ 'TESTONIP' ] )
+ main.Mininet2.pingKill( main.params[ 'TESTONUSER' ],
+ main.params[ 'TESTONIP' ] )
LossInPings = main.FALSE
# NOTE: checkForLoss returns main.FALSE with 0% packet loss
for i in range( 8, 18 ):
@@ -1338,15 +1870,14 @@
onpass="No Loss of connectivity",
onfail="Loss of dataplane connectivity detected" )
+ main.step( "Leadership Election is still functional" )
# Test of LeadershipElection
# NOTE: this only works for the sanity test. In case of failures,
- # leader will likely change
- leader = ONOS1Ip
+ # leader will likely change
+ leader = nodes[ 0 ].ip_address
leaderResult = main.TRUE
- for controller in range( 1, numControllers + 1 ):
- # loop through ONOScli handlers
- node = getattr( main, ( 'ONOScli' + str( controller ) ) )
- leaderN = node.electionTestLeader()
+ for cli in CLIs:
+ leaderN = cli.electionTestLeader()
# verify leader is ONOS1
if leaderN == leader:
# all is well
@@ -1354,36 +1885,22 @@
# check != ONOS1
pass
elif leaderN == main.FALSE:
- # error in response
+ # error in response
main.log.report( "Something is wrong with " +
- "electionTestLeader function," +
- " check the error logs" )
+ "electionTestLeader function, check the" +
+ " error logs" )
leaderResult = main.FALSE
elif leader != leaderN:
leaderResult = main.FALSE
- main.log.report( "ONOS" + str( controller ) + " sees " +
- str( leaderN ) +
+ main.log.report( cli.name + " sees " + str( leaderN ) +
" as the leader of the election app. " +
"Leader should be " + str( leader ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was re-elected if applicable )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
onpass="Leadership election passed",
onfail="Something went wrong with Leadership election" )
- result = mastershipCheck and intentCheck and FlowTables and\
- ( not LossInPings ) and rolesNotNull and leaderResult
- result = int( result )
- if result == main.TRUE:
- main.log.report( "Constant State Tests Passed" )
- utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Constant State Tests Passed",
- onfail="Constant state tests failed" )
-
def CASE8( self, main ):
"""
Compare topo
@@ -1395,258 +1912,341 @@
from sts.topology.teston_topology import TestONTopology
import json
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
- description = "Compare ONOS Topology view to Mininet topology"
- main.case( description )
- main.log.report( description )
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplaination = "Compare topology objects between Mininet" +\
+ " and ONOS"
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 ) ] ), )
+ try:
+ ctrls = []
+ for node in nodes:
+ temp = ( node, node.name, node.ip_address, 6633 )
ctrls.append( temp )
- count = count + 1
- else:
- break
- MNTopo = TestONTopology(
- main.Mininet1,
- ctrls ) # can also add Intent API info for intent operations
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
+ except Exception:
+ objResult = main.FALSE
+ else:
+ objResult = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=objResult,
+ onpass="Created TestONTopology object",
+ onfail="Exception while creating " +
+ "TestONTopology object" )
main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
portsResults = main.TRUE
linksResults = main.TRUE
+ hostsResults = main.TRUE
topoResult = main.FALSE
elapsed = 0
count = 0
main.step( "Collecting topology information from ONOS" )
startTime = time.time()
+ # Give time for Gossip to work
while topoResult == main.FALSE and elapsed < 60:
- count = count + 1
+ count += 1
if count > 1:
- # TODO: Depricate STS usage
- MNTopo = TestONTopology(
- main.Mininet1,
- ctrls )
+ # TODO: Deprecate STS usage
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
cliStart = time.time()
devices = []
- devices.append( main.ONOScli1.devices() )
- devices.append( main.ONOScli2.devices() )
- devices.append( main.ONOScli3.devices() )
- devices.append( main.ONOScli4.devices() )
- devices.append( main.ONOScli5.devices() )
- devices.append( main.ONOScli6.devices() )
- devices.append( main.ONOScli7.devices() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].devices,
+ name="devices-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ devices.append( t.result )
hosts = []
- hosts.append( json.loads( main.ONOScli1.hosts() ) )
- hosts.append( json.loads( main.ONOScli2.hosts() ) )
- hosts.append( json.loads( main.ONOScli3.hosts() ) )
- hosts.append( json.loads( main.ONOScli4.hosts() ) )
- hosts.append( json.loads( main.ONOScli5.hosts() ) )
- hosts.append( json.loads( main.ONOScli6.hosts() ) )
- hosts.append( json.loads( main.ONOScli7.hosts() ) )
+ ipResult = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].hosts,
+ name="hosts-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ try:
+ hosts.append( json.loads( t.result ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing hosts results" )
+ main.log.error( repr( t.result ) )
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- host
- if host[ 'ips' ] == []:
+ if host is None or host.get( 'ipAddresses', [] ) == []:
main.log.error(
"DEBUG:Error with host ips on controller" +
controllerStr + ": " + str( host ) )
+ ipResult = main.FALSE
ports = []
- ports.append( main.ONOScli1.ports() )
- ports.append( main.ONOScli2.ports() )
- ports.append( main.ONOScli3.ports() )
- ports.append( main.ONOScli4.ports() )
- ports.append( main.ONOScli5.ports() )
- ports.append( main.ONOScli6.ports() )
- ports.append( main.ONOScli7.ports() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].ports,
+ name="ports-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ports.append( t.result )
links = []
- links.append( main.ONOScli1.links() )
- links.append( main.ONOScli2.links() )
- links.append( main.ONOScli3.links() )
- links.append( main.ONOScli4.links() )
- links.append( main.ONOScli5.links() )
- links.append( main.ONOScli6.links() )
- links.append( main.ONOScli7.links() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].links,
+ name="links-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ links.append( t.result )
clusters = []
- clusters.append( main.ONOScli1.clusters() )
- clusters.append( main.ONOScli2.clusters() )
- clusters.append( main.ONOScli3.clusters() )
- clusters.append( main.ONOScli4.clusters() )
- clusters.append( main.ONOScli5.clusters() )
- clusters.append( main.ONOScli6.clusters() )
- clusters.append( main.ONOScli7.clusters() )
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].clusters,
+ name="clusters-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ clusters.append( t.result )
elapsed = time.time() - startTime
cliTime = time.time() - cliStart
print "CLI time: " + str( cliTime )
- try:
- for controller in range( numControllers ):
- controllerStr = str( controller + 1 )
- if devices[ controller ] or "Error" not in devices[
- controller ]:
- currentDevicesResult = main.Mininet1.compareSwitches(
- MNTopo,
- json.loads(
- devices[ controller ] ) )
- else:
- currentDevicesResult = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=currentDevicesResult,
- onpass="ONOS" + controllerStr +
- " Switches view is correct",
- onfail="ONOS" + controllerStr +
- " Switches view is incorrect" )
+ for controller in range( numControllers ):
+ controllerStr = str( controller + 1 )
+ if devices[ controller ] or "Error" not in devices[
+ controller ]:
+ currentDevicesResult = main.Mininet1.compareSwitches(
+ MNTopo,
+ json.loads( devices[ controller ] ) )
+ else:
+ currentDevicesResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
- if ports[ controller ] or "Error" not in ports[ controller ]:
- currentPortsResult = main.Mininet1.comparePorts(
- MNTopo,
- json.loads(
- ports[ controller ] ) )
- else:
- currentPortsResult = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=currentPortsResult,
- onpass="ONOS" + controllerStr +
- " ports view is correct",
- onfail="ONOS" + controllerStr +
- " ports view is incorrect" )
+ if ports[ controller ] or "Error" not in ports[ controller ]:
+ currentPortsResult = main.Mininet1.comparePorts(
+ MNTopo,
+ json.loads( ports[ controller ] ) )
+ else:
+ currentPortsResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentPortsResult,
+ onpass="ONOS" + controllerStr +
+ " ports view is correct",
+ onfail="ONOS" + controllerStr +
+ " ports view is incorrect" )
- if links[ controller ] or "Error" not in links[ controller ]:
- currentLinksResult = main.Mininet1.compareLinks(
- MNTopo,
- json.loads(
- links[ controller ] ) )
- else:
- currentLinksResult = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=currentLinksResult,
- onpass="ONOS" + controllerStr +
- " links view is correct",
- onfail="ONOS" + controllerStr +
- " links view is incorrect" )
+ if links[ controller ] or "Error" not in links[ controller ]:
+ currentLinksResult = main.Mininet1.compareLinks(
+ MNTopo,
+ json.loads( links[ controller ] ) )
+ else:
+ currentLinksResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
+
+ if hosts[ controller ] or "Error" not in hosts[ controller ]:
+ currentHostsResult = main.Mininet1.compareHosts(
+ MNTopo, hosts[ controller ] )
+ else:
+ currentHostsResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentHostsResult,
+ onpass="ONOS" + controllerStr +
+ " hosts exist in Mininet",
+ onfail="ONOS" + controllerStr +
+ " hosts don't match Mininet" )
+
devicesResults = devicesResults and currentDevicesResult
portsResults = portsResults and currentPortsResult
linksResults = linksResults and currentLinksResult
+ hostsResults = hostsResults and currentHostsResult
- # Compare json objects for hosts and dataplane clusters
+ # Compare json objects for hosts and dataplane clusters
- # hosts
- consistentHostsResult = main.TRUE
- for controller in range( len( hosts ) ):
- controllerStr = str( controller + 1 )
- if "Error" not in hosts[ controller ]:
- if hosts[ controller ] == hosts[ 0 ]:
- continue
- else: # hosts not consistent
- main.log.report( "hosts from ONOS" + controllerStr +
- " is inconsistent with ONOS1" )
- main.log.warn( repr( hosts[ controller ] ) )
- consistentHostsResult = main.FALSE
-
- else:
- main.log.report( "Error in getting ONOS hosts from ONOS" +
- controllerStr )
+ # hosts
+ main.step( "Hosts view is consistent across all ONOS nodes" )
+ consistentHostsResult = main.TRUE
+ for controller in range( len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in hosts[ controller ]:
+ if hosts[ controller ] == hosts[ 0 ]:
+ continue
+ else: # hosts not consistent
+ main.log.report( "hosts from ONOS" + controllerStr +
+ " is inconsistent with ONOS1" )
+ main.log.warn( repr( hosts[ controller ] ) )
consistentHostsResult = main.FALSE
- main.log.warn( "ONOS" + controllerStr +
- " hosts response: " +
- repr( hosts[ controller ] ) )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=consistentHostsResult,
- onpass="Hosts view is consistent across all ONOS nodes",
- onfail="ONOS nodes have different views of hosts" )
- # Strongly connected clusters of devices
- consistentClustersResult = main.TRUE
- for controller in range( len( clusters ) ):
- controllerStr = str( controller + 1 )
- if "Error" not in clusters[ controller ]:
- if clusters[ controller ] == clusters[ 0 ]:
- continue
- else: # clusters not consistent
- main.log.report( "clusters from ONOS" +
- controllerStr +
- " is inconsistent with ONOS1" )
- consistentClustersResult = main.FALSE
+ else:
+ main.log.report( "Error in getting ONOS hosts from ONOS" +
+ controllerStr )
+ consistentHostsResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " hosts response: " +
+ repr( hosts[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentHostsResult,
+ onpass="Hosts view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of hosts" )
- else:
- main.log.report( "Error in getting dataplane clusters " +
- "from ONOS" + controllerStr )
+ # Strongly connected clusters of devices
+ main.step( "Clusters view is consistent across all ONOS nodes" )
+ consistentClustersResult = main.TRUE
+ for controller in range( len( clusters ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in clusters[ controller ]:
+ if clusters[ controller ] == clusters[ 0 ]:
+ continue
+ else: # clusters not consistent
+ main.log.report( "clusters from ONOS" +
+ controllerStr +
+ " is inconsistent with ONOS1" )
consistentClustersResult = main.FALSE
- main.log.warn( "ONOS" + controllerStr +
- " clusters response: " +
- repr( clusters[ controller ] ) )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=consistentClustersResult,
- onpass="Clusters view is consistent across all ONOS nodes",
- onfail="ONOS nodes have different views of clusters" )
- # there should always only be one cluster
+
+ else:
+ main.log.report( "Error in getting dataplane clusters " +
+ "from ONOS" + controllerStr )
+ consistentClustersResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " clusters response: " +
+ repr( clusters[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentClustersResult,
+ onpass="Clusters view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of clusters" )
+ # there should always only be one cluster
+ main.step( "Topology view is correct and consistent across all " +
+ "ONOS nodes" )
+ try:
numClusters = len( json.loads( clusters[ 0 ] ) )
- utilities.assert_equals(
- expect=1,
- actual=numClusters,
- onpass="ONOS shows 1 SCC",
- onfail="ONOS shows " +
- str( numClusters ) +
- " SCCs" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing clusters[0]: " +
+ repr( clusters[0] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
+ utilities.assert_equals(
+ expect=1,
+ actual=numClusters,
+ onpass="ONOS shows 1 SCC",
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
- topoResult = ( devicesResults and portsResults and linksResults
- and consistentHostsResult
- and consistentClustersResult )
+ topoResult = ( devicesResults and portsResults and linksResults
+ and hostsResults and consistentHostsResult
+ and consistentClustersResult and clusterResults
+ and ipResult )
- topoResult = topoResult and int( count <= 2 )
- note = "note it takes about " + str( int( cliTime ) ) + \
- " seconds for the test to make all the cli calls to fetch " +\
- "the topology from each ONOS instance"
- main.log.report(
- "Very crass estimate for topology discovery/convergence( " +
- str( note ) + " ): " + str( elapsed ) + " seconds, " +
- str( count ) + " tries" )
- utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
- if topoResult == main.TRUE:
- main.log.report( "ONOS topology view matches Mininet topology" )
- except:
- main.log.info( self.name + " ::::::" )
- main.log.error( traceback.print_exc() )
- main.log.info( self.name + " ::::::" )
+ topoResult = topoResult and int( count <= 2 )
+ note = "note it takes about " + str( int( cliTime ) ) + \
+ " seconds for the test to make all the cli calls to fetch " +\
+ "the topology from each ONOS instance"
+ main.log.info(
+ "Very crass estimate for topology discovery/convergence( " +
+ str( note ) + " ): " + str( elapsed ) + " seconds, " +
+ str( count ) + " tries" )
+ utilities.assert_equals( expect=main.TRUE, actual=topoResult,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
+ # FIXME: move this to an ONOS state case
+ main.step( "Checking ONOS nodes" )
+ nodesOutput = []
+ nodeResults = main.TRUE
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].nodes,
+ name="nodes-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ nodesOutput.append( t.result )
+ ips = [ node.ip_address for node in nodes ]
+ for i in nodesOutput:
+ try:
+ current = json.loads( i )
+ for node in current:
+ currentResult = main.FALSE
+ if node['ip'] in ips: # node in nodes() output is in cell
+ if node['state'] == 'ACTIVE':
+ currentResult = main.TRUE
+ else:
+ main.log.error( "Error in ONOS node availability" )
+ main.log.error(
+ json.dumps( current,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ break
+ nodeResults = nodeResults and currentResult
+ except ( ValueError, TypeError ):
+ main.log.error( "Error parsing nodes output" )
+ main.log.warn( repr( i ) )
+ utilities.assert_equals( expect=main.TRUE, actual=nodeResults,
+ onpass="Nodes check successful",
+ onfail="Nodes check NOT successful" )
def CASE9( self, main ):
"""
Link s3-s28 down
"""
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# NOTE: You should probably run a topology check after this
linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
description = "Turn off a link to ensure that Link Discovery " +\
- "is working properly"
+ "is working properly"
main.log.report( description )
main.case( description )
main.step( "Kill Link between s3 and s28" )
LinkDown = main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
- main.log.info(
- "Waiting " +
- str( linkSleep ) +
- " seconds for link down to be discovered" )
+ main.log.info( "Waiting " + str( linkSleep ) +
+ " seconds for link down to be discovered" )
time.sleep( linkSleep )
utilities.assert_equals( expect=main.TRUE, actual=LinkDown,
- onpass="Link down succesful",
- onfail="Failed to bring link down" )
+ onpass="Link down successful",
+ onfail="Failed to bring link down" )
# TODO do some sort of check here
def CASE10( self, main ):
@@ -1654,25 +2254,28 @@
Link s3-s28 up
"""
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# NOTE: You should probably run a topology check after this
linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
description = "Restore a link to ensure that Link Discovery is " + \
- "working properly"
+ "working properly"
main.log.report( description )
main.case( description )
main.step( "Bring link between s3 and s28 back up" )
LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
- main.log.info(
- "Waiting " +
- str( linkSleep ) +
- " seconds for link up to be discovered" )
+ main.log.info( "Waiting " + str( linkSleep ) +
+ " seconds for link up to be discovered" )
time.sleep( linkSleep )
utilities.assert_equals( expect=main.TRUE, actual=LinkUp,
- onpass="Link up succesful",
- onfail="Failed to bring link up" )
+ onpass="Link up successful",
+ onfail="Failed to bring link up" )
# TODO do some sort of check here
def CASE11( self, main ):
@@ -1681,6 +2284,11 @@
"""
# NOTE: You should probably run a topology check after this
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
@@ -1704,8 +2312,8 @@
if device and device[ 'available' ] is False:
result = main.TRUE
utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Kill switch succesful",
- onfail="Failed to kill switch?" )
+ onpass="Kill switch successful",
+ onfail="Failed to kill switch?" )
def CASE12( self, main ):
"""
@@ -1713,6 +2321,18 @@
"""
# NOTE: You should probably run a topology check after this
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
switch = main.params[ 'kill' ][ 'switch' ]
@@ -1725,30 +2345,26 @@
main.step( "Add back " + switch )
main.log.report( "Adding back " + switch )
main.Mininet1.addSwitch( switch, dpid=switchDPID )
- # TODO: New dpid or same? Ask Thomas?
for peer in links:
main.Mininet1.addLink( switch, peer )
- main.Mininet1.assignSwController(
- sw=switch.split( 's' )[ 1 ],
- count=numControllers,
- ip1=ONOS1Ip,
- port1=ONOS1Port,
- ip2=ONOS2Ip,
- port2=ONOS2Port,
- ip3=ONOS3Ip,
- port3=ONOS3Port,
- ip4=ONOS4Ip,
- port4=ONOS4Port,
- ip5=ONOS5Ip,
- port5=ONOS5Port,
- ip6=ONOS6Ip,
- port6=ONOS6Port,
- ip7=ONOS7Ip,
- port7=ONOS7Port )
- main.log.info(
- "Waiting " +
- str( switchSleep ) +
- " seconds for switch up to be discovered" )
+ main.Mininet1.assignSwController( sw=switch.split( 's' )[ 1 ],
+ count=numControllers,
+ ip1=nodes[ 0 ].ip_address,
+ port1=ONOS1Port,
+ ip2=nodes[ 1 ].ip_address,
+ port2=ONOS2Port,
+ ip3=nodes[ 2 ].ip_address,
+ port3=ONOS3Port,
+ ip4=nodes[ 3 ].ip_address,
+ port4=ONOS4Port,
+ ip5=nodes[ 4 ].ip_address,
+ port5=ONOS5Port,
+ ip6=nodes[ 5 ].ip_address,
+ port6=ONOS6Port,
+ ip7=nodes[ 6 ].ip_address,
+ port7=ONOS7Port )
+ main.log.info( "Waiting " + str( switchSleep ) +
+ " seconds for switch up to be discovered" )
time.sleep( switchSleep )
device = main.ONOScli1.getDevice( dpid=switchDPID )
# Peek at the deleted switch
@@ -1757,8 +2373,8 @@
if device and device[ 'available' ]:
result = main.TRUE
utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="add switch succesful",
- onfail="Failed to add switch?" )
+ onpass="add switch successful",
+ onfail="Failed to add switch?" )
def CASE13( self, main ):
"""
@@ -1766,37 +2382,22 @@
"""
import os
import time
- # TODO: make use of this elsewhere
- ips = []
- ips.append( ONOS1Ip )
- ips.append( ONOS2Ip )
- ips.append( ONOS3Ip )
- ips.append( ONOS4Ip )
- ips.append( ONOS5Ip )
- ips.append( ONOS6Ip )
- ips.append( ONOS7Ip )
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
# printing colors to terminal
- colors = {}
- colors[ 'cyan' ] = '\033[96m'
- colors[ 'purple' ] = '\033[95m'
- colors[ 'blue' ] = '\033[94m'
- colors[ 'green' ] = '\033[92m'
- colors[ 'yellow' ] = '\033[93m'
- colors[ 'red' ] = '\033[91m'
- colors[ 'end' ] = '\033[0m'
+ colors = { 'cyan': '\033[96m', 'purple': '\033[95m',
+ 'blue': '\033[94m', 'green': '\033[92m',
+ 'yellow': '\033[93m', 'red': '\033[91m', 'end': '\033[0m' }
description = "Test Cleanup"
main.log.report( description )
main.case( description )
main.step( "Killing tcpdumps" )
main.Mininet2.stopTcpdump()
- main.step( "Checking ONOS Logs for errors" )
- for i in range( 7 ):
- print colors[ 'purple' ] + "Checking logs for errors on " + \
- "ONOS" + str( i + 1 ) + ":" + colors[ 'end' ]
- print main.ONOSbench.checkLogs( ips[ i ] )
-
main.step( "Copying MN pcap and ONOS log files to test station" )
testname = main.TEST
teststationUser = main.params[ 'TESTONUSER' ]
@@ -1812,14 +2413,15 @@
# NOTE: must end in /
dstDir = "~/packet_captures/"
for f in logFiles:
- for i in range( 7 ):
- main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" +
- logFolder + f + " " +
+ for node in nodes:
+ main.ONOSbench.handle.sendline( "scp sdn@" + node.ip_address +
+ ":" + logFolder + f + " " +
teststationUser + "@" +
teststationIP + ":" +
dstDir + str( testname ) +
- "-ONOS" + str( i + 1 ) + "-" +
- f )
+ "-" + node.name + "-" + f )
+ main.ONOSbench.handle.expect( "\$" )
+
# std*.log's
# NOTE: must end in /
logFolder = "/opt/onos/var/"
@@ -1827,157 +2429,171 @@
# NOTE: must end in /
dstDir = "~/packet_captures/"
for f in logFiles:
- for i in range( 7 ):
- main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" +
- logFolder + f + " " +
+ for node in nodes:
+ main.ONOSbench.handle.sendline( "scp sdn@" + node.ip_address +
+ ":" + logFolder + f + " " +
teststationUser + "@" +
teststationIP + ":" +
dstDir + str( testname ) +
- "-ONOS" + str( i + 1 ) + "-" +
- f )
+ "-" + node.name + "-" + f )
+ main.ONOSbench.handle.expect( "\$" )
# sleep so scp can finish
time.sleep( 10 )
+
+ main.step( "Stopping Mininet" )
+ mnResult = main.Mininet1.stopNet()
+ utilities.assert_equals( expect=main.TRUE, actual=mnResult,
+ onpass="Mininet stopped",
+ onfail="MN cleanup NOT successful" )
+
+ main.step( "Checking ONOS Logs for errors" )
+ for node in nodes:
+ print colors[ 'purple' ] + "Checking logs for errors on " + \
+ node.name + ":" + colors[ 'end' ]
+ print main.ONOSbench.checkLogs( node.ip_address )
+
main.step( "Packing and rotating pcap archives" )
os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
- # TODO: actually check something here
- utilities.assert_equals( expect=main.TRUE, actual=main.TRUE,
- onpass="Test cleanup successful",
- onfail="Test cleanup NOT successful" )
+ try:
+ timerLog = open( main.logdir + "/Timers.csv", 'w')
+ # Overwrite with empty line and close
+ timerLog.write( "Gossip Intents\n" )
+ timerLog.write( str( gossipTime ) )
+ timerLog.close()
+ except NameError, e:
+ main.log.exception(e)
def CASE14( self, main ):
"""
start election app on all onos nodes
"""
- leaderResult = main.TRUE
- # install app on onos 1
- main.log.info( "Install leadership election app" )
- main.ONOScli1.featureInstall( "onos-app-election" )
- # wait for election
- # check for leader
- leader = main.ONOScli1.electionTestLeader()
- # verify leader is ONOS1
- if leader == ONOS1Ip:
- # all is well
- pass
- elif leader is None:
- # No leader elected
- main.log.report( "No leader was elected" )
- leaderResult = main.FALSE
- elif leader == main.FALSE:
- # error in response
- # TODO: add check for "Command not found:" in the driver, this
- # means the app isn't loaded
- main.log.report( "Something is wrong with electionTestLeader" +
- " function, check the error logs" )
- leaderResult = main.FALSE
- else:
- # error in response
- main.log.report(
- "Unexpected response from electionTestLeader function:'" +
- str( leader ) +
- "'" )
- leaderResult = main.FALSE
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
- # install on other nodes and check for leader.
- # Should be onos1 and each app should show the same leader
- for controller in range( 2, numControllers + 1 ):
- # loop through ONOScli handlers
- node = getattr( main, ( 'ONOScli' + str( controller ) ) )
- node.featureInstall( "onos-app-election" )
- leaderN = node.electionTestLeader()
- # verify leader is ONOS1
- if leaderN == ONOS1Ip:
- # all is well
- pass
- elif leaderN == main.FALSE:
- # error in response
- # TODO: add check for "Command not found:" in the driver, this
- # means the app isn't loaded
- main.log.report( "Something is wrong with " +
- "electionTestLeader function, check the" +
- " error logs" )
+ main.case("Start Leadership Election app")
+ main.step( "Install leadership election app" )
+ appResult = main.ONOScli1.activateApp( "org.onosproject.election" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=appResult,
+ onpass="Election app installed",
+ onfail="Something went wrong with installing Leadership election" )
+
+ main.step( "Run for election on each node" )
+ leaderResult = main.TRUE
+ leaders = []
+ for cli in CLIs:
+ cli.electionTestRun()
+ for cli in CLIs:
+ leader = cli.electionTestLeader()
+ if leader is None or leader == main.FALSE:
+ main.log.report( cli.name + ": Leader for the election app " +
+ "should be an ONOS node, instead got '" +
+ str( leader ) + "'" )
leaderResult = main.FALSE
- elif leader != leaderN:
- leaderResult = main.FALSE
- main.log.report( "ONOS" + str( controller ) + " sees " +
- str( leaderN ) +
- " as the leader of the election app. Leader" +
- " should be " +
- str( leader ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a leader " +
- "was elected )" )
+ leaders.append( leader )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
- onpass="Leadership election passed",
- onfail="Something went wrong with Leadership election" )
+ onpass="Successfully ran for leadership",
+ onfail="Failed to run for leadership" )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
def CASE15( self, main ):
"""
Check that Leadership Election is still functional
"""
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+
leaderResult = main.TRUE
description = "Check that Leadership Election is still functional"
main.log.report( description )
main.case( description )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ leaders = []
+ for cli in CLIs:
+ leader = cli.electionTestLeader()
+ leaders.append( leader )
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
+
main.step( "Find current leader and withdraw" )
leader = main.ONOScli1.electionTestLeader()
- # TODO: do some sanity checking on leader before using it
+ # do some sanity checking on leader before using it
withdrawResult = main.FALSE
- if leader == ONOS1Ip:
- oldLeader = getattr( main, "ONOScli1" )
- elif leader == ONOS2Ip:
- oldLeader = getattr( main, "ONOScli2" )
- elif leader == ONOS3Ip:
- oldLeader = getattr( main, "ONOScli3" )
- elif leader == ONOS4Ip:
- oldLeader = getattr( main, "ONOScli4" )
- elif leader == ONOS5Ip:
- oldLeader = getattr( main, "ONOScli5" )
- elif leader == ONOS6Ip:
- oldLeader = getattr( main, "ONOScli6" )
- elif leader == ONOS7Ip:
- oldLeader = getattr( main, "ONOScli7" )
- elif leader is None or leader == main.FALSE:
- main.log.report(
+ if leader is None or leader == main.FALSE:
+ main.log.error(
"Leader for the election app should be an ONOS node," +
- "instead got '" +
- str( leader ) +
- "'" )
+ "instead got '" + str( leader ) + "'" )
leaderResult = main.FALSE
- withdrawResult = oldLeader.electionTestWithdraw()
+ oldLeader = None
+ for i in range( len( CLIs ) ):
+ if leader == nodes[ i ].ip_address:
+ oldLeader = CLIs[ i ]
+ break
+ else: # FOR/ELSE statement
+ main.log.error( "Leader election, could not find current leader" )
+ if oldLeader:
+ withdrawResult = oldLeader.electionTestWithdraw()
utilities.assert_equals(
expect=main.TRUE,
actual=withdrawResult,
- onpass="App was withdrawn from election",
- onfail="App was not withdrawn from election" )
+ onpass="Node was withdrawn from election",
+ onfail="Node was not withdrawn from election" )
main.step( "Make sure new leader is elected" )
+ # FIXME: use threads
leaderList = []
- for controller in range( 1, numControllers + 1 ):
- # loop through ONOScli handlers
- node = getattr( main, ( 'ONOScli' + str( controller ) ) )
- leaderList.append( node.electionTestLeader() )
- for leaderN in leaderList:
+ for cli in CLIs:
+ leaderN = cli.electionTestLeader()
+ leaderList.append( leaderN )
if leaderN == leader:
- main.log.report(
- "ONOS" +
- str( controller ) +
- " still sees " +
- str( leader ) +
- " as leader after they withdrew" )
+ main.log.report( cli.name + " still sees " + str( leader ) +
+ " as leader after they withdrew" )
leaderResult = main.FALSE
elif leaderN == main.FALSE:
# error in response
# TODO: add check for "Command not found:" in the driver, this
- # means the app isn't loaded
+ # means the app isn't loaded
main.log.report( "Something is wrong with " +
"electionTestLeader function, " +
"check the error logs" )
leaderResult = main.FALSE
+ elif leaderN is None:
+ # node may not have recieved the event yet
+ time.sleep(7)
+ leaderN = cli.electionTestLeader()
+ leaderList.pop()
+ leaderList.append( leaderN )
consistentLeader = main.FALSE
if len( set( leaderList ) ) == 1:
main.log.info( "Each Election-app sees '" +
@@ -1990,37 +2606,1114 @@
for n in range( len( leaderList ) ):
main.log.report( "ONOS" + str( n + 1 ) + " response: " +
str( leaderList[ n ] ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was elected when the old leader " +
- "resigned )" )
+ leaderResult = leaderResult and consistentLeader
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
onpass="Leadership election passed",
onfail="Something went wrong with Leadership election" )
- main.step(
- "Run for election on old leader( just so everyone is in the hat )" )
- runResult = oldLeader.electionTestRun()
+ main.step( "Run for election on old leader( just so everyone " +
+ "is in the hat )" )
+ if oldLeader:
+ runResult = oldLeader.electionTestRun()
+ else:
+ runResult = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
actual=runResult,
onpass="App re-ran for election",
onfail="App failed to run for election" )
- if consistentLeader == main.TRUE:
- afterRun = main.ONOScli1.electionTestLeader()
- # verify leader didn't just change
- if afterRun == leaderList[ 0 ]:
- leaderResult = main.TRUE
- else:
- leaderResult = main.FALSE
- # TODO: assert on run and withdraw results?
+
+ main.step( "Leader did not change when old leader re-ran" )
+ afterRun = main.ONOScli1.electionTestLeader()
+ # verify leader didn't just change
+ if afterRun == leaderList[ 0 ]:
+ afterResult = main.TRUE
+ else:
+ afterResult = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
- actual=leaderResult,
- onpass="Leadership election passed",
+ actual=afterResult,
+ onpass="Old leader successfully re-ran for election",
onfail="Something went wrong with Leadership election after " +
"the old leader re-ran for election" )
+
+ def CASE16( self, main ):
+ """
+ Install Distributed Primitives app
+ """
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+
+ # Variables for the distributed primitives tests
+ global pCounterName
+ global iCounterName
+ global pCounterValue
+ global iCounterValue
+ global onosSet
+ global onosSetName
+ pCounterName = "TestON-Partitions"
+ iCounterName = "TestON-inMemory"
+ pCounterValue = 0
+ iCounterValue = 0
+ onosSet = set([])
+ onosSetName = "TestON-set"
+
+ description = "Install Primitives app"
+ main.case( description )
+ main.step( "Install Primitives app" )
+ appName = "org.onosproject.distributedprimitives"
+ appResults = CLIs[0].activateApp( appName )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=appResults,
+ onpass="Primitives app activated",
+ onfail="Primitives app not activated" )
+ time.sleep (5 ) # To allow all nodes to activate
+
+ def CASE17( self, main ):
+ """
+ Check for basic functionality with distributed primitives
+ """
+ # Make sure variables are defined/set
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert pCounterName, "pCounterName not defined"
+ assert iCounterName, "iCounterName not defined"
+ assert onosSetName, "onosSetName not defined"
+ # NOTE: assert fails if value is 0/None/Empty/False
+ try:
+ pCounterValue
+ except NameError:
+ main.log.error( "pCounterValue not defined, setting to 0" )
+ pCounterValue = 0
+ try:
+ iCounterValue
+ except NameError:
+ main.log.error( "iCounterValue not defined, setting to 0" )
+ iCounterValue = 0
+ try:
+ onosSet
+ except NameError:
+ main.log.error( "onosSet not defined, setting to empty Set" )
+ onosSet = set([])
+ # Variables for the distributed primitives tests. These are local only
+ addValue = "a"
+ addAllValue = "a b c d e f"
+ retainValue = "c d e f"
+
+ description = "Check for basic functionality with distributed " +\
+ "primitives"
+ main.case( description )
+ main.caseExplaination = "Test the methods of the distributed primitives (counters and sets) throught the cli"
+ # DISTRIBUTED ATOMIC COUNTERS
+ main.step( "Increment and get a default counter on each node" )
+ pCounters = []
+ threads = []
+ addedPValues = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counterTestIncrement,
+ name="counterIncrement-" + str( i ),
+ args=[ pCounterName ] )
+ pCounterValue += 1
+ addedPValues.append( pCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ pCounters.append( t.result )
+ # Check that counter incremented numController times
+ pCounterResults = True
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=pCounterResults,
+ onpass="Default counter incremented",
+ onfail="Error incrementing default" +
+ " counter" )
+
+ main.step( "Increment and get an in memory counter on each node" )
+ iCounters = []
+ addedIValues = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counterTestIncrement,
+ name="icounterIncrement-" + str( i ),
+ args=[ iCounterName ],
+ kwargs={ "inMemory": True } )
+ iCounterValue += 1
+ addedIValues.append( iCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ iCounters.append( t.result )
+ # Check that counter incremented numController times
+ iCounterResults = True
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in the in-memory "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=iCounterResults,
+ onpass="In memory counter incremented",
+ onfail="Error incrementing in memory" +
+ " counter" )
+
+ main.step( "Check counters are consistant across nodes" )
+ onosCounters = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counters,
+ name="counters-" + str( i ) )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ onosCounters.append( t.result )
+ tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
+ if all( tmp ):
+ main.log.info( "Counters are consistent across all nodes" )
+ consistentCounterResults = main.TRUE
+ else:
+ main.log.error( "Counters are not consistent across all nodes" )
+ consistentCounterResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=consistentCounterResults,
+ onpass="ONOS counters are consistent " +
+ "across nodes",
+ onfail="ONOS Counters are inconsistent " +
+ "across nodes" )
+
+ main.step( "Counters we added have the correct values" )
+ correctResults = main.TRUE
+ for i in range( numControllers ):
+ current = onosCounters[i]
+ try:
+ pValue = current.get( pCounterName )
+ iValue = current.get( iCounterName )
+ if pValue == pCounterValue:
+ main.log.info( "Partitioned counter value is correct" )
+ else:
+ main.log.error( "Partitioned counter value is incorrect," +
+ " expected value: " + str( pCounterValue )
+ + " current value: " + str( pValue ) )
+ correctResults = main.FALSE
+ if iValue == iCounterValue:
+ main.log.info( "In memory counter value is correct" )
+ else:
+ main.log.error( "In memory counter value is incorrect, " +
+ "expected value: " + str( iCounterValue ) +
+ " current value: " + str( iValue ) )
+ correctResults = main.FALSE
+ except AttributeError, e:
+ main.log.error( "ONOS" + str( i + 1 ) + " counters result " +
+ "is not as expected" )
+ correctResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=correctResults,
+ onpass="Added counters are correct",
+ onfail="Added counters are incorrect" )
+ # DISTRIBUTED SETS
+ main.step( "Distributed Set get" )
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=getResults,
+ onpass="Set elements are correct",
+ onfail="Set elements are incorrect" )
+
+ main.step( "Distributed Set size" )
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=sizeResults,
+ onpass="Set sizes are correct",
+ onfail="Set sizes are incorrect" )
+
+ main.step( "Distributed Set add()" )
+ onosSet.add( addValue )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAdd-" + str( i ),
+ args=[ onosSetName, addValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addResults = main.FALSE
+ else:
+ # unexpected result
+ addResults = main.FALSE
+ if addResults != main.TRUE:
+ main.log.error( "Error executing set add" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addResults = addResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addResults,
+ onpass="Set add correct",
+ onfail="Set add was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set contains()" )
+ containsResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setContains-" + str( i ),
+ args=[ onosSetName ],
+ kwargs={ "values": addValue } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ # NOTE: This is the tuple
+ containsResponses.append( t.result )
+
+ containsResults = main.TRUE
+ for i in range( numControllers ):
+ if containsResponses[ i ] == main.ERROR:
+ containsResults = main.FALSE
+ else:
+ containsResults = containsResults and\
+ containsResponses[ i ][ 1 ]
+ utilities.assert_equals( expect=main.TRUE,
+ actual=containsResults,
+ onpass="Set contains is functional",
+ onfail="Set contains failed" )
+
+ main.step( "Distributed Set containsAll()" )
+ containsAllResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setContainsAll-" + str( i ),
+ args=[ onosSetName ],
+ kwargs={ "values": addAllValue } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ # NOTE: This is the tuple
+ containsAllResponses.append( t.result )
+
+ containsAllResults = main.TRUE
+ for i in range( numControllers ):
+ if containsResponses[ i ] == main.ERROR:
+ containsResults = main.FALSE
+ else:
+ containsResults = containsResults and\
+ containsResponses[ i ][ 1 ]
+ utilities.assert_equals( expect=main.TRUE,
+ actual=containsAllResults,
+ onpass="Set containsAll is functional",
+ onfail="Set containsAll failed" )
+
+ main.step( "Distributed Set remove()" )
+ onosSet.remove( addValue )
+ removeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRemove-" + str( i ),
+ args=[ onosSetName, addValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ removeResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ removeResults = main.TRUE
+ for i in range( numControllers ):
+ if removeResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif removeResponses[ i ] == main.FALSE:
+ # not in set, probably fine
+ pass
+ elif removeResponses[ i ] == main.ERROR:
+ # Error in execution
+ removeResults = main.FALSE
+ else:
+ # unexpected result
+ removeResults = main.FALSE
+ if removeResults != main.TRUE:
+ main.log.error( "Error executing set remove" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ removeResults = removeResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=removeResults,
+ onpass="Set remove correct",
+ onfail="Set remove was incorrect" )
+
+ main.step( "Distributed Set removeAll()" )
+ onosSet.difference_update( addAllValue.split() )
+ removeAllResponses = []
+ threads = []
+ try:
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRemoveAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ removeAllResponses.append( t.result )
+ except Exception, e:
+ main.log.exception(e)
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ removeAllResults = main.TRUE
+ for i in range( numControllers ):
+ if removeAllResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif removeAllResponses[ i ] == main.FALSE:
+ # not in set, probably fine
+ pass
+ elif removeAllResponses[ i ] == main.ERROR:
+ # Error in execution
+ removeAllResults = main.FALSE
+ else:
+ # unexpected result
+ removeAllResults = main.FALSE
+ if removeAllResults != main.TRUE:
+ main.log.error( "Error executing set removeAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ removeAllResults = removeAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=removeAllResults,
+ onpass="Set removeAll correct",
+ onfail="Set removeAll was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set clear()" )
+ onosSet.clear()
+ clearResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestClear-" + str( i ),
+ args=[ onosSetName, " "], # Values doesn't matter
+ kwargs={ "clear": True } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ clearResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ clearResults = main.TRUE
+ for i in range( numControllers ):
+ if clearResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif clearResponses[ i ] == main.FALSE:
+ # Nothing set, probably fine
+ pass
+ elif clearResponses[ i ] == main.ERROR:
+ # Error in execution
+ clearResults = main.FALSE
+ else:
+ # unexpected result
+ clearResults = main.FALSE
+ if clearResults != main.TRUE:
+ main.log.error( "Error executing set clear" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ clearResults = clearResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=clearResults,
+ onpass="Set clear correct",
+ onfail="Set clear was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set retain()" )
+ onosSet.intersection_update( retainValue.split() )
+ retainResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRetain-" + str( i ),
+ args=[ onosSetName, retainValue ],
+ kwargs={ "retain": True } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ retainResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ retainResults = main.TRUE
+ for i in range( numControllers ):
+ if retainResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif retainResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif retainResponses[ i ] == main.ERROR:
+ # Error in execution
+ retainResults = main.FALSE
+ else:
+ # unexpected result
+ retainResults = main.FALSE
+ if retainResults != main.TRUE:
+ main.log.error( "Error executing set retain" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " +
+ str( size ) + " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ retainResults = retainResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=retainResults,
+ onpass="Set retain correct",
+ onfail="Set retain was incorrect" )
+
diff --git a/TestON/tests/HATestSanity/HATestSanity.topo b/TestON/tests/HATestSanity/HATestSanity.topo
index c24d546..0855d4e 100644
--- a/TestON/tests/HATestSanity/HATestSanity.topo
+++ b/TestON/tests/HATestSanity/HATestSanity.topo
@@ -7,7 +7,8 @@
<password>onos_test</password>
<type>OnosDriver</type>
<connect_order>1</connect_order>
- <COMPONENTS> </COMPONENTS>
+ <COMPONENTS>
+ </COMPONENTS>
</ONOSbench>
<ONOScli1>
@@ -151,7 +152,7 @@
<arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
<arg2> --topo mytopo </arg2>
<arg3> </arg3>
- <controller> remote </controller>
+ <controller> none </controller>
</COMPONENTS>
</Mininet1>
@@ -162,7 +163,7 @@
<type>RemoteMininetDriver</type>
<connect_order>17</connect_order>
<COMPONENTS>
- </COMPONENTS>
+ </COMPONENTS>
</Mininet2>
</COMPONENT>
diff --git a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.params b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.params
index 7f5cf4e..f057592 100644
--- a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.params
+++ b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.params
@@ -1,7 +1,24 @@
<PARAMS>
- <testcases>1,2,8,3,4,5,14,[6],8,3,7,4,15,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ #CASE1: Compile ONOS and push it to the test machines
+ #CASE2: Assign mastership to controllers
+ #CASE3: Assign intents
+ #CASE4: Ping across added host intents
+ #CASE5: Reading state of ONOS
+ #CASE6: The Failure case. Since this is the Sanity test, we do nothing.
+ #CASE7: Check state after control plane failure
+ #CASE8: Compare topo
+ #CASE9: Link s3-s28 down
+ #CASE10: Link s3-s28 up
+ #CASE11: Switch down
+ #CASE12: Switch up
+ #CASE13: Clean up
+ #CASE14: start election app on all onos nodes
+ #CASE15: Check that Leadership Election is still functional
+ #1,2,8,3,4,5,14,[6],8,3,7,4,15,9,8,4,10,8,4,11,8,4,12,8,4,13
+ #extra hosts test 1,2,8,11,8,12,8
+ <testcases>1,2,8,3,4,5,14,15,16,17,[6],8,3,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
<ENV>
- <cellName>HA</cellName>
+ <cellName>HA</cellName>
</ENV>
<Git>False</Git>
<branch> master </branch>
diff --git a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
index 39ce920..7194a3b 100644
--- a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
+++ b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
@@ -18,6 +18,8 @@
CASE13: Clean up
CASE14: start election app on all onos nodes
CASE15: Check that Leadership Election is still functional
+CASE16: Install Distributed Primitives app
+CASE17: Check for basic functionality with distributed primitives
"""
@@ -31,21 +33,28 @@
CASE1 is to compile ONOS and push it to the test machines
Startup sequence:
- git pull
- mvn clean install
- onos-package
cell <name>
onos-verify-cell
NOTE: temporary - onos-remove-raft-logs
+ onos-uninstall
+ start mininet
+ git pull
+ mvn clean install
+ onos-package
onos-install -f
onos-wait-for-start
+ start cli sessions
+ start tcpdump
"""
main.log.report( "ONOS Single node cluster restart " +
"HA test - initialization" )
main.case( "Setting up test environment" )
+ main.caseExplaination = "Setup the test environment including " +\
+ "installing ONOS, starting Mininet and ONOS" +\
+ "cli sessions."
# TODO: save all the timers and output them for plotting
- # load some vairables from the params file
+ # load some variables from the params file
PULLCODE = False
if main.params[ 'Git' ] == 'True':
PULLCODE = True
@@ -55,88 +64,126 @@
# set global variables
global ONOS1Ip
global ONOS1Port
- global ONOS2Ip
global ONOS2Port
- global ONOS3Ip
global ONOS3Port
- global ONOS4Ip
global ONOS4Port
- global ONOS5Ip
global ONOS5Port
- global ONOS6Ip
global ONOS6Port
- global ONOS7Ip
global ONOS7Port
global numControllers
+ numControllers = int( main.params[ 'num_controllers' ] )
ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
- ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
ONOS4Port = main.params[ 'CTRL' ][ 'port4' ]
- ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
ONOS5Port = main.params[ 'CTRL' ][ 'port5' ]
- ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
- ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
- numControllers = int( main.params[ 'num_controllers' ] )
+
+ global CLIs
+ CLIs = []
+ global nodes
+ nodes = []
+ for i in range( 1, numControllers + 1 ):
+ CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+ nodes.append( getattr( main, 'ONOS' + str( i ) ) )
main.step( "Applying cell variable to environment" )
cellResult = main.ONOSbench.setCell( cellName )
verifyResult = main.ONOSbench.verifyCell()
# FIXME:this is short term fix
- main.log.report( "Removing raft logs" )
+ main.log.info( "Removing raft logs" )
main.ONOSbench.onosRemoveRaftLogs()
- main.log.report( "Uninstalling ONOS" )
- main.ONOSbench.onosUninstall( ONOS1Ip )
- main.ONOSbench.onosUninstall( ONOS2Ip )
- main.ONOSbench.onosUninstall( ONOS3Ip )
- main.ONOSbench.onosUninstall( ONOS4Ip )
- main.ONOSbench.onosUninstall( ONOS5Ip )
- main.ONOSbench.onosUninstall( ONOS6Ip )
- main.ONOSbench.onosUninstall( ONOS7Ip )
+
+ main.log.info( "Uninstalling ONOS" )
+ for node in nodes:
+ main.ONOSbench.onosUninstall( node.ip_address )
+
+ # Make sure ONOS is DEAD
+ main.log.info( "Killing any ONOS processes" )
+ killResults = main.TRUE
+ for node in nodes:
+ killed = main.ONOSbench.onosKill( node.ip_address )
+ killResults = killResults and killed
cleanInstallResult = main.TRUE
gitPullResult = main.TRUE
- main.step( "Compiling the latest version of ONOS" )
+ main.step( "Starting Mininet" )
+ mnResult = main.Mininet1.startNet( )
+ utilities.assert_equals( expect=main.TRUE, actual=mnResult,
+ onpass="Mininet Started",
+ onfail="Error starting Mininet" )
+
+ main.step( "Git checkout and pull " + gitBranch )
if PULLCODE:
- # TODO Configure branch in params
- main.step( "Git checkout and pull master" )
main.ONOSbench.gitCheckout( gitBranch )
gitPullResult = main.ONOSbench.gitPull()
-
- main.step( "Using mvn clean & install" )
- cleanInstallResult = main.ONOSbench.cleanInstall()
+ # values of 1 or 3 are good
+ utilities.assert_lesser( expect=0, actual=gitPullResult,
+ onpass="Git pull successful",
+ onfail="Git pull failed" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
main.ONOSbench.getVersion( report=True )
+ main.step( "Using mvn clean install" )
+ cleanInstallResult = main.TRUE
+ if gitPullResult == main.TRUE:
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cleanInstallResult,
+ onpass="MCI successful",
+ onfail="MCI failed" )
+ # GRAPHS
+ # NOTE: important params here:
+ # job = name of Jenkins job
+ # Plot Name = Plot-HA, only can be used if multiple plots
+ # index = The number of the graph under plot name
+ job = "HASingleInstanceRestart"
+ graphs = '<ac:structured-macro ac:name="html">\n'
+ graphs += '<ac:plain-text-body><![CDATA[\n'
+ graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
+ '/plot/getPlot?index=0&width=500&height=300"' +\
+ 'noborder="0" width="500" height="300" scrolling="yes" ' +\
+ 'seamless="seamless"></iframe>\n'
+ graphs += ']]></ac:plain-text-body>\n'
+ graphs += '</ac:structured-macro>\n'
+ main.log.wiki(graphs)
+
cellResult = main.ONOSbench.setCell( "SingleHA" )
verifyResult = main.ONOSbench.verifyCell()
main.step( "Creating ONOS package" )
packageResult = main.ONOSbench.onosPackage()
+ utilities.assert_equals( expect=main.TRUE, actual=packageResult,
+ onpass="ONOS package successful",
+ onfail="ONOS package failed" )
main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
+ onosInstallResult = main.ONOSbench.onosInstall( options="-f",
node=ONOS1Ip )
+ utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
+ onpass="ONOS install successful",
+ onfail="ONOS install failed" )
main.step( "Checking if ONOS is up yet" )
- # TODO check bundle:list?
for i in range( 2 ):
onos1Isup = main.ONOSbench.isup( ONOS1Ip )
if onos1Isup:
break
- if not onos1Isup:
- main.log.report( "ONOS1 didn't start!" )
+ utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
+ onpass="ONOS startup successful",
+ onfail="ONOS startup failed" )
- cliResult = main.ONOScli1.startOnosCli( ONOS1Ip )
+ main.log.step( "Starting ONOS CLI sessions" )
+ cliResults = main.ONOScli1.startOnosCli( ONOS1Ip )
+ utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+ onpass="ONOS cli startup successful",
+ onfail="ONOS cli startup failed" )
main.step( "Start Packet Capture MN" )
main.Mininet2.startTcpdump(
@@ -145,15 +192,17 @@
intf=main.params[ 'MNtcpdump' ][ 'intf' ],
port=main.params[ 'MNtcpdump' ][ 'port' ] )
- case1Result = ( cleanInstallResult and packageResult and
- cellResult and verifyResult and onos1InstallResult
- and onos1Isup and cliResult )
+ main.step( "App Ids check" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
- utilities.assert_equals( expect=main.TRUE, actual=case1Result,
- onpass="Test startup successful",
- onfail="Test startup NOT successful" )
-
- if case1Result == main.FALSE:
+ if cliResults == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -162,9 +211,21 @@
Assign mastership to controllers
"""
import re
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
- main.log.report( "Assigning switches to controllers" )
main.case( "Assigning Controllers" )
+ main.caseExplaination = "Assign switches to ONOS using 'ovs-vsctl' " +\
+ "and check that an ONOS node becomes the " +\
+ "master of the device."
main.step( "Assign switches to controllers" )
for i in range( 1, 29 ):
@@ -177,58 +238,163 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response ):
mastershipCheck = mastershipCheck and main.TRUE
else:
mastershipCheck = main.FALSE
if mastershipCheck == main.TRUE:
- main.log.report( "Switch mastership assigned correctly" )
+ main.log.info( "Switch mastership assigned correctly" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
onpass="Switch mastership assigned correctly",
onfail="Switches not assigned correctly to controllers" )
+ main.step( "Assign mastership of switches to specific controllers" )
+ roleCall = main.TRUE
+ roleCheck = main.TRUE
+ try:
+ for i in range( 1, 29 ): # switches 1 through 28
+ ip = nodes[ 0 ].ip_address # ONOS1
+ # set up correct variables:
+ if i == 1:
+ deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
+ elif i == 2:
+ deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' )
+ elif i == 3:
+ deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' )
+ elif i == 4:
+ deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' )
+ elif i == 5:
+ deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' )
+ elif i == 6:
+ deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' )
+ elif i == 7:
+ deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' )
+ elif i >= 8 and i <= 17:
+ dpid = '3' + str( i ).zfill( 3 )
+ deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
+ elif i >= 18 and i <= 27:
+ dpid = '6' + str( i ).zfill( 3 )
+ deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
+ elif i == 28:
+ deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' )
+ else:
+ main.log.error( "You didn't write an else statement for " +
+ "switch s" + str( i ) )
+ # Assign switch
+ assert deviceId, "No device id for s" + str( i ) + " in ONOS"
+ # TODO: make this controller dynamic
+ roleCall = roleCall and main.ONOScli1.deviceRole( deviceId,
+ ip )
+ # Check assignment
+ master = main.ONOScli1.getRole( deviceId ).get( 'master' )
+ if ip in master:
+ roleCheck = roleCheck and main.TRUE
+ else:
+ roleCheck = roleCheck and main.FALSE
+ main.log.error( "Error, controller " + ip + " is not" +
+ " master " + "of device " +
+ str( deviceId ) + ". Master is " +
+ repr( master ) + "." )
+ except ( AttributeError, AssertionError ):
+ main.log.exception( "Something is wrong with ONOS device view" )
+ main.log.info( main.ONOScli1.devices() )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=roleCall,
+ onpass="Re-assigned switch mastership to designated controller",
+ onfail="Something wrong with deviceRole calls" )
+
+ main.step( "Check mastership was correctly assigned" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=roleCheck,
+ onpass="Switches were successfully reassigned to designated " +
+ "controller",
+ onfail="Switches were not successfully reassigned" )
+ mastershipCheck = mastershipCheck and roleCall and roleCheck
+ utilities.assert_equals( expect=main.TRUE, actual=mastershipCheck,
+ onpass="Switch mastership correctly assigned",
+ onfail="Error in (re)assigning switch" +
+ " mastership" )
+
def CASE3( self, main ):
"""
Assign intents
"""
- # FIXME: we must reinstall intents until we have a persistant
- # datastore!
import time
- main.log.report( "Adding host intents" )
+ import json
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ # NOTE: we must reinstall intents until we have a persistant intent
+ # datastore!
main.case( "Adding host Intents" )
-
- main.step( "Discovering Hosts( Via pingall for now )" )
- # FIXME: Once we have a host discovery mechanism, use that instead
+ main.caseExplaination = "Discover hosts by using pingall then " +\
+ "assign predetermined host-to-host intents." +\
+ " After installation, check that the intent" +\
+ " is distributed to all nodes and the state" +\
+ " is INSTALLED"
# install onos-app-fwd
- main.log.info( "Install reactive forwarding app" )
- main.ONOScli1.featureInstall( "onos-app-fwd" )
+ main.step( "Install reactive forwarding app" )
+ installResults = CLIs[0].activateApp( "org.onosproject.fwd" )
+ utilities.assert_equals( expect=main.TRUE, actual=installResults,
+ onpass="Install fwd successful",
+ onfail="Install fwd failed" )
+ main.step( "Check app ids" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+
+ main.step( "Discovering Hosts( Via pingall for now )" )
+ # FIXME: Once we have a host discovery mechanism, use that instead
# REACTIVE FWD test
pingResult = main.FALSE
- time1 = time.time()
- pingResult = main.Mininet1.pingall()
- utilities.assert_equals(
- expect=main.TRUE,
- actual=pingResult,
- onpass="Reactive Pingall test passed",
- onfail="Reactive Pingall failed, one or more ping pairs failed" )
- time2 = time.time()
- main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) )
-
- # uninstall onos-app-fwd
- main.log.info( "Uninstall reactive forwarding app" )
- main.ONOScli1.featureUninstall( "onos-app-fwd" )
+ for i in range(2): # Retry if pingall fails first time
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=pingResult,
+ onpass="Reactive Pingall test passed",
+ onfail="Reactive Pingall failed, " +
+ "one or more ping pairs failed" )
+ time2 = time.time()
+ main.log.info( "Time for pingall: %2f seconds" %
+ ( time2 - time1 ) )
# timeout for fwd flows
- time.sleep( 10 )
+ time.sleep( 11 )
+ # uninstall onos-app-fwd
+ main.step( "Uninstall reactive forwarding app" )
+ uninstallResult = CLIs[0].deactivateApp( "org.onosproject.fwd" )
+ utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
+ onpass="Uninstall fwd successful",
+ onfail="Uninstall fwd failed" )
- main.step( "Add host intents" )
+ main.step( "Check app ids" )
+ appCheck2 = main.ONOScli1.appToIDCheck()
+ if appCheck2 != main.TRUE:
+ main.log.warn( CLIs[0].apps() )
+ main.log.warn( CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck2,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+
+ main.step( "Add host intents via cli" )
+ intentIds = []
# TODO: move the host numbers to params
+ # Maybe look at all the paths we ping?
intentAddResult = True
+ hostResult = main.TRUE
for i in range( 8, 18 ):
main.log.info( "Adding host intent between h" + str( i ) +
" and h" + str( i + 10 ) )
@@ -236,55 +402,299 @@
str( hex( i )[ 2: ] ).zfill( 2 ).upper()
host2 = "00:00:00:00:00:" + \
str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
- host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
- # NOTE: get host can return None
+ # NOTE: getHost can return None
+ host1Dict = main.ONOScli1.getHost( host1 )
+ host2Dict = main.ONOScli1.getHost( host2 )
+ host1Id = None
+ host2Id = None
+ if host1Dict and host2Dict:
+ host1Id = host1Dict.get( 'id', None )
+ host2Id = host2Dict.get( 'id', None )
if host1Id and host2Id:
- tmpResult = main.ONOScli1.addHostIntent(
- host1Id,
- host2Id )
+ tmpId = main.ONOScli1.addHostIntent( host1Id, host2Id )
+ if tmpId:
+ main.log.info( "Added intent with id: " + tmpId )
+ intentIds.append( tmpId )
+ else:
+ main.log.error( "addHostIntent returned: " +
+ repr( tmpId ) )
else:
- main.log.error( "Error, getHost() failed" )
- tmpResult = main.FALSE
- intentAddResult = bool( pingResult and intentAddResult
- and tmpResult )
- # TODO Check that intents were added?
- utilities.assert_equals(
- expect=True,
- actual=intentAddResult,
- onpass="Pushed host intents to ONOS",
- onfail="Error in pushing host intents to ONOS" )
- # TODO Check if intents all exist in datastore
+ main.log.error( "Error, getHost() failed for h" + str( i ) +
+ " and/or h" + str( i + 10 ) )
+ hosts = main.ONOScli1.hosts()
+ main.log.warn( "Hosts output: " )
+ try:
+ main.log.warn( json.dumps( json.loads( hosts ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( hosts ) )
+ hostResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE, actual=hostResult,
+ onpass="Found a host id for each host",
+ onfail="Error looking up host ids" )
+
+ intentStart = time.time()
+ onosIds = main.ONOScli1.getAllIntentsId()
+ main.log.info( "Submitted intents: " + str( intentIds ) )
+ main.log.info( "Intents in ONOS: " + str( onosIds ) )
+ for intent in intentIds:
+ if intent in onosIds:
+ pass # intent submitted is in onos
+ else:
+ intentAddResult = False
+ # FIXME: DEBUG
+ if intentAddResult:
+ intentStop = time.time()
+ else:
+ intentStop = None
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ installedCheck = True
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents" )
+ # add submitted intents not in the store
+ tmplist = [ i for i, s in intentStates ]
+ missingIntents = False
+ for i in intentIds:
+ if i not in tmplist:
+ intentStates.append( ( i, " - " ) )
+ missingIntents = True
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+
+ intentAddResult = bool( intentAddResult and not missingIntents and
+ installedCheck )
+ if not intentAddResult:
+ main.log.error( "Error in pushing host intents to ONOS" )
+
+ main.step( "Intent Anti-Entropy dispersion" )
+ for i in range(100):
+ correct = True
+ main.log.info( "Submitted intents: " + str( sorted( intentIds ) ) )
+ for cli in CLIs:
+ onosIds = []
+ ids = cli.getAllIntentsId()
+ onosIds.append( ids )
+ main.log.debug( "Intents in " + cli.name + ": " +
+ str( sorted( onosIds ) ) )
+ if sorted( ids ) != sorted( intentIds ):
+ correct = False
+ if correct:
+ break
+ else:
+ time.sleep(1)
+ if not intentStop:
+ intentStop = time.time()
+ global gossipTime
+ gossipTime = intentStop - intentStart
+ main.log.info( "It took about " + str( gossipTime ) +
+ " seconds for all intents to appear in each node" )
+ # FIXME: make this time configurable/calculate based off of number of
+ # nodes and gossip rounds
+ utilities.assert_greater_equals(
+ expect=40, actual=gossipTime,
+ onpass="ECM anti-entropy for intents worked within " +
+ "expected time",
+ onfail="Intent ECM anti-entropy took too long" )
+ if gossipTime <= 40:
+ intentAddResult = True
+
+ if not intentAddResult or "key" in pendingMap:
+ import time
+ installedCheck = True
+ main.log.info( "Sleeping 60 seconds to see if intents are found" )
+ time.sleep( 60 )
+ onosIds = main.ONOScli1.getAllIntentsId()
+ main.log.info( "Submitted intents: " + str( intentIds ) )
+ main.log.info( "Intents in ONOS: " + str( onosIds ) )
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ try:
+ for intent in json.loads( intents ):
+ # Iter through intents of a node
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents" )
+ # add submitted intents not in the store
+ tmplist = [ i for i, s in intentStates ]
+ for i in intentIds:
+ if i not in tmplist:
+ intentStates.append( ( i, " - " ) )
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ topics.append( "org.onosproject.election" )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
def CASE4( self, main ):
"""
Ping across added host intents
"""
- description = " Ping across added host intents"
- main.log.report( description )
- main.case( description )
+ import json
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ main.case( "Verify connectivity by sendind traffic across Intents" )
+ main.caseExplaination = "Ping across added host intents to check " +\
+ "functionality and check the state of " +\
+ "the intent"
+ main.step( "Ping across added host intents" )
PingResult = main.TRUE
for i in range( 8, 18 ):
- ping = main.Mininet1.pingHost(
- src="h" + str( i ), target="h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
PingResult = PingResult and ping
if ping == main.FALSE:
main.log.warn( "Ping failed between h" + str( i ) +
" and h" + str( i + 10 ) )
elif ping == main.TRUE:
main.log.info( "Ping test passed!" )
- PingResult = main.TRUE
+ # Don't set PingResult or you'd override failures
if PingResult == main.FALSE:
main.log.report(
"Intents have not been installed correctly, pings failed." )
- #TODO: pretty print
- main.log.warn( "ONSO1 intents: " )
- main.log.warn( json.dumps( json.loads( main.ONOScli1.intents() ),
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
if PingResult == main.TRUE:
- main.log.report(
+ main.log.info(
"Intents have been installed correctly and verified by pings" )
utilities.assert_equals(
expect=main.TRUE,
@@ -292,23 +702,234 @@
onpass="Intents have been installed correctly and pings work",
onfail="Intents have not been installed correctly, pings failed." )
+ main.step( "Check Intent state" )
+ installedCheck = True
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents." )
+ # Print states
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ utilities.assert_equals( expect=True, actual=installedCheck,
+ onpass="Intents are all INSTALLED",
+ onfail="Intents are not all in " +\
+ "INSTALLED state" )
+
+ main.step( "Check leadership of topics" )
+ leaders = main.ONOScli1.leaders()
+ topicCheck = main.TRUE
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ # TODO: Look at Devices as topics now that it uses this system
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ # FIXME: topics.append( "org.onosproject.election" )
+ # Print leaders output
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ topicCheck = main.FALSE
+ else:
+ main.log.error( "leaders() returned None" )
+ topicCheck = main.FALSE
+ except ( ValueError, TypeError ):
+ topicCheck = main.FALSE
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ # TODO: Check for a leader of these topics
+ utilities.assert_equals( expect=main.TRUE, actual=topicCheck,
+ onpass="intent Partitions is in leaders",
+ onfail="Some topics were lost " )
+ # Print partitions
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ # Print Pending Map
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+
+ if not installedCheck:
+ main.log.info( "Waiting 60 seconds to see if the state of " +
+ "intents change" )
+ time.sleep( 60 )
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents." )
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ leaders = main.ONOScli1.leaders()
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ topics.append( "org.onosproject.election" )
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ else:
+ main.log.error( "leaders() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
+ main.log.debug( main.ONOScli1.flows( jsonFormat=False ) )
+
+ main.step( "Wait a minute then ping again" )
+ PingResult = main.TRUE
+ for i in range( 8, 18 ):
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
+ PingResult = PingResult and ping
+ if ping == main.FALSE:
+ main.log.warn( "Ping failed between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ elif ping == main.TRUE:
+ main.log.info( "Ping test passed!" )
+ # Don't set PingResult or you'd override failures
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Intents have not been installed correctly, pings failed." )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=PingResult,
+ onpass="Intents have been installed correctly and pings work",
+ onfail="Intents have not been installed correctly, pings failed." )
+
def CASE5( self, main ):
"""
Reading state of ONOS
"""
import json
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
- main.log.report( "Setting up and gathering data for current state" )
main.case( "Setting up and gathering data for current state" )
# The general idea for this test case is to pull the state of
# ( intents,flows, topology,... ) from each ONOS node
- # We can then compare them with eachother and also with past states
+ # We can then compare them with each other and also with past states
- main.step( "Get the Mastership of each switch from each controller" )
+ main.step( "Check that each switch has a master" )
global mastershipState
- mastershipState = []
+ mastershipState = '[]'
# Assert that each device has a master
rolesNotNull = main.ONOScli1.rolesNotNull()
@@ -318,6 +939,7 @@
onpass="Each device has a master",
onfail="Some devices don't have a master assigned" )
+ main.step( "Get the Mastership of each switch" )
ONOS1Mastership = main.ONOScli1.roles()
# TODO: Make this a meaningful check
if "Error" in ONOS1Mastership or not ONOS1Mastership:
@@ -344,10 +966,10 @@
main.step( "Get the flows from each controller" )
global flowState
flowState = []
- ONOS1Flows = main.ONOScli1.flows( jsonFormat=True )
flowCheck = main.FALSE
+ ONOS1Flows = main.ONOScli1.flows( jsonFormat=True )
if "Error" in ONOS1Flows or not ONOS1Flows:
- main.log.report( "Error in getting ONOS intents" )
+ main.log.report( "Error in getting ONOS flows" )
main.log.warn( "ONOS1 flows repsponse: " + ONOS1Flows )
else:
# TODO: Do a better check, maybe compare flows on switches?
@@ -359,109 +981,156 @@
flows = []
for i in range( 1, 29 ):
flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) )
-
+ if flowCheck == main.FALSE:
+ for table in flows:
+ main.log.warn( table )
# TODO: Compare switch flow tables with ONOS flow tables
main.step( "Create TestONTopology object" )
ctrls = []
- count = 1
- temp = ()
- 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 ) ] ), )
+ temp = ( nodes[0], nodes[0].name, nodes[0].ip_address, 6633 )
ctrls.append( temp )
- MNTopo = TestONTopology(
- main.Mininet1,
- ctrls ) # can also add Intent API info for intent operations
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
main.step( "Collecting topology information from ONOS" )
devices = []
devices.append( main.ONOScli1.devices() )
- """
hosts = []
- hosts.append( main.ONOScli1.hosts() )
- """
+ hosts.append( json.loads( main.ONOScli1.hosts() ) )
ports = []
ports.append( main.ONOScli1.ports() )
links = []
links.append( main.ONOScli1.links() )
+ clusters = []
+ clusters.append( main.ONOScli1.clusters() )
+
+ main.step( "Each host has an IP address" )
+ ipResult = main.TRUE
+ for controller in range( 0, len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ for host in hosts[ controller ]:
+ if host is None or host.get( 'ipAddresses', [] ) == []:
+ main.log.error(
+ "DEBUG:Error with host ips on controller" +
+ controllerStr + ": " + str( host ) )
+ ipResult = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=ipResult,
+ onpass="The ips of the hosts aren't empty",
+ onfail="The ip of at least one host is missing" )
+
+ # there should always only be one cluster
+ main.step( "There is only one dataplane cluster" )
+ try:
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing clusters[0]: " +
+ repr( clusters[ 0 ] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
+ utilities.assert_equals(
+ expect=1,
+ actual=numClusters,
+ onpass="ONOS shows 1 SCC",
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
portsResults = main.TRUE
linksResults = main.TRUE
+ hostsResults = main.TRUE
for controller in range( numControllers ):
controllerStr = str( controller + 1 )
if devices[ controller ] or "Error" not in devices[ controller ]:
currentDevicesResult = main.Mininet1.compareSwitches(
MNTopo,
- json.loads(
- devices[ controller ] ) )
+ json.loads( devices[ controller ] ) )
else:
currentDevicesResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentDevicesResult,
- onpass="ONOS" + controllerStr +
- " Switches view is correct",
- onfail="ONOS" + controllerStr +
- " Switches view is incorrect" )
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
if ports[ controller ] or "Error" not in ports[ controller ]:
currentPortsResult = main.Mininet1.comparePorts(
MNTopo,
- json.loads(
- ports[ controller ] ) )
+ json.loads( ports[ controller ] ) )
else:
currentPortsResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentPortsResult,
- onpass="ONOS" + controllerStr +
- " ports view is correct",
- onfail="ONOS" + controllerStr +
- " ports view is incorrect" )
+ actual=currentPortsResult,
+ onpass="ONOS" + controllerStr +
+ " ports view is correct",
+ onfail="ONOS" + controllerStr +
+ " ports view is incorrect" )
if links[ controller ] or "Error" not in links[ controller ]:
currentLinksResult = main.Mininet1.compareLinks(
MNTopo,
- json.loads(
- links[ controller ] ) )
+ json.loads( links[ controller ] ) )
else:
currentLinksResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentLinksResult,
- onpass="ONOS" + controllerStr +
- " links view is correct",
- onfail="ONOS" + controllerStr +
- " links view is incorrect" )
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
+
+ if hosts[ controller ] or "Error" not in hosts[ controller ]:
+ currentHostsResult = main.Mininet1.compareHosts(
+ MNTopo, hosts[ controller ] )
+ else:
+ currentHostsResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentHostsResult,
+ onpass="ONOS" + controllerStr +
+ " hosts exist in Mininet",
+ onfail="ONOS" + controllerStr +
+ " hosts don't match Mininet" )
devicesResults = devicesResults and currentDevicesResult
portsResults = portsResults and currentPortsResult
linksResults = linksResults and currentLinksResult
+ hostsResults = hostsResults and currentHostsResult
- topoResult = devicesResults and portsResults and linksResults
+ topoResult = devicesResults and portsResults and linksResults\
+ and clusterResults and ipResult and hostsResults
utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
-
- finalAssert = main.TRUE
- finalAssert = finalAssert and topoResult and flowCheck \
- and intentCheck and consistentMastership and rolesNotNull
- utilities.assert_equals( expect=main.TRUE, actual=finalAssert,
- onpass="State check successful",
- onfail="State check NOT successful" )
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
def CASE6( self, main ):
"""
The Failure case.
"""
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+
+ # Reset non-persistent variables
+ try:
+ iCounterValue = 0
+ except NameError:
+ main.log.error( "iCounterValue not defined, setting to 0" )
+ iCounterValue = 0
main.log.report( "Restart ONOS node" )
- main.log.case( "Restart ONOS node" )
- main.ONOSbench.onosKill( ONOS1Ip )
+ main.case( "Restart ONOS node" )
+ main.caseExplaination = "Killing ONOS process and restart cli " +\
+ "sessions once onos is up."
+ main.step( "Killing ONOS processes" )
+ killResult = main.ONOSbench.onosKill( ONOS1Ip )
start = time.time()
+ utilities.assert_equals( expect=main.TRUE, actual=killResult,
+ onpass="ONOS Killed",
+ onfail="Error killing ONOS" )
main.step( "Checking if ONOS is up yet" )
count = 0
@@ -472,25 +1141,33 @@
break
else:
count = count + 1
+ utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
+ onpass="ONOS is back up",
+ onfail="ONOS failed to start" )
- cliResult = main.ONOScli1.startOnosCli( ONOS1Ip )
+ main.log.step( "Starting ONOS CLI sessions" )
+ cliResults = main.ONOScli1.startOnosCli( ONOS1Ip )
+ utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+ onpass="ONOS cli startup successful",
+ onfail="ONOS cli startup failed" )
- caseResults = main.TRUE and onos1Isup and cliResult
- utilities.assert_equals( expect=main.TRUE, actual=caseResults,
- onpass="ONOS restart successful",
- onfail="ONOS restart NOT successful" )
- main.log.info(
- "ESTIMATE: ONOS took %s seconds to restart" %
- str( elapsed ) )
+ if elapsed:
+ main.log.info( "ESTIMATE: ONOS took %s seconds to restart" %
+ str( elapsed ) )
time.sleep( 5 )
+ # rerun on election apps
+ main.ONOScli1.electionTestRun()
def CASE7( self, main ):
"""
Check state after ONOS failure
"""
import json
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
main.case( "Running ONOS Constant State Tests" )
-
+ main.step( "Check that each switch has a master" )
# Assert that each device has a master
rolesNotNull = main.ONOScli1.rolesNotNull()
utilities.assert_equals(
@@ -504,9 +1181,8 @@
# FIXME: Refactor this whole case for single instance
if "Error" in ONOS1Mastership or not ONOS1Mastership:
main.log.report( "Error in getting ONOS mastership" )
- main.log.warn(
- "ONOS1 mastership response: " +
- repr( ONOS1Mastership ) )
+ main.log.warn( "ONOS1 mastership response: " +
+ repr( ONOS1Mastership ) )
consistentMastership = main.FALSE
else:
consistentMastership = main.TRUE
@@ -526,9 +1202,7 @@
mastershipCheck = main.TRUE
for i in range( 1, 29 ):
switchDPID = str(
- main.Mininet1.getSwitchDPID(
- switch="s" +
- str( i ) ) )
+ main.Mininet1.getSwitchDPID( switch="s" + str( i ) ) )
current = [ switch[ 'master' ] for switch in currentJson
if switchDPID in switch[ 'id' ] ]
@@ -539,8 +1213,6 @@
else:
main.log.warn( "Mastership of switch %s changed" % switchDPID )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Mastership of Switches was not changed" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
@@ -562,25 +1234,38 @@
actual=intentCheck,
onpass="Intents are consistent across all ONOS nodes",
onfail="ONOS nodes have different views of intents" )
+ # Print the intent states
+ intents = []
+ intents.append( ONOS1Intents )
+ intentStates = []
+ for node in intents: # Iter through ONOS nodes
+ nodeStates = []
+ # Iter through intents of a node
+ for intent in json.loads( node ):
+ nodeStates.append( intent[ 'state' ] )
+ intentStates.append( nodeStates )
+ out = [ (i, nodeStates.count( i ) ) for i in set( nodeStates ) ]
+ main.log.info( dict( out ) )
- # NOTE: Hazelcast has no durability, so intents are lost across system
- # restarts
+ # NOTE: Store has no durability, so intents are lost across system
+ # restarts
"""
main.step( "Compare current intents with intents before the failure" )
# NOTE: this requires case 5 to pass for intentState to be set.
# maybe we should stop the test if that fails?
- if intentState == ONOS1Intents:
+ sameIntents = main.TRUE
+ if intentState and intentState == ONOS1Intents:
sameIntents = main.TRUE
- main.log.report( "Intents are consistent with before failure" )
+ main.log.info( "Intents are consistent with before failure" )
# TODO: possibly the states have changed? we may need to figure out
- # what the aceptable states are
+ # what the acceptable states are
else:
try:
main.log.warn( "ONOS1 intents: " )
print json.dumps( json.loads( ONOS1Intents ),
sort_keys=True, indent=4,
separators=( ',', ': ' ) )
- except:
+ except Exception:
pass
sameIntents = main.FALSE
utilities.assert_equals(
@@ -605,14 +1290,13 @@
if FlowTables == main.FALSE:
main.log.info( "Differences in flow table for switch: s" +
str( i + 1 ) )
- if FlowTables == main.TRUE:
- main.log.report( "No changes were found in the flow tables" )
utilities.assert_equals(
expect=main.TRUE,
actual=FlowTables,
onpass="No changes were found in the flow tables",
onfail="Changes were found in the flow tables" )
+ main.step( "Leadership Election is still functional" )
# Test of LeadershipElection
leader = ONOS1Ip
@@ -628,36 +1312,23 @@
# all is well
pass
elif leaderN == main.FALSE:
- # error in response
+ # error in response
main.log.report( "Something is wrong with " +
"electionTestLeader function, check the" +
" error logs" )
leaderResult = main.FALSE
elif leader != leaderN:
leaderResult = main.FALSE
- main.log.report( "ONOS" + str( controller ) +
- " sees " + str( leaderN ) +
- " as the leader of the election app." +
- " Leader should be " + str( leader ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was re-elected if applicable )" )
+ main.log.report( "ONOS" + str( controller ) + " sees " +
+ str( leaderN ) +
+ " as the leader of the election app. " +
+ "Leader should be " + str( leader ) )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
onpass="Leadership election passed",
onfail="Something went wrong with Leadership election" )
- result = ( mastershipCheck and intentCheck and FlowTables and
- rolesNotNull and leaderResult )
- result = int( result )
- if result == main.TRUE:
- main.log.report( "Constant State Tests Passed" )
- utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Constant State Tests Passed",
- onfail="Constant state tests failed" )
-
def CASE8( self, main ):
"""
Compare topo
@@ -669,50 +1340,66 @@
from sts.topology.teston_topology import TestONTopology
import json
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
- description = "Compare ONOS Topology view to Mininet topology"
- main.case( description )
- main.log.report( description )
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplaination = "Compare topology objects between Mininet" +\
+ " and ONOS"
main.step( "Create TestONTopology object" )
- ctrls = []
- count = 1
- temp = ()
- 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 )
- MNTopo = TestONTopology(
- main.Mininet1,
- ctrls ) # can also add Intent API info for intent operations
+ try:
+ ctrls = []
+ node = main.ONOS1
+ temp = ( node, node.name, node.ip_address, 6633 )
+ ctrls.append( temp )
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
+ except Exception:
+ objResult = main.FALSE
+ else:
+ objResult = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=objResult,
+ onpass="Created TestONTopology object",
+ onfail="Exception while creating " +
+ "TestONTopology object" )
main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
portsResults = main.TRUE
linksResults = main.TRUE
+ hostsResults = main.TRUE
topoResult = main.FALSE
elapsed = 0
count = 0
main.step( "Collecting topology information from ONOS" )
startTime = time.time()
+ # Give time for Gossip to work
while topoResult == main.FALSE and elapsed < 60:
- count = count + 1
+ count += 1
if count > 1:
- MNTopo = TestONTopology(
- main.Mininet1,
- ctrls )
+ # TODO: Deprecate STS usage
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
cliStart = time.time()
devices = []
devices.append( main.ONOScli1.devices() )
- """
hosts = []
- hosts.append( main.ONOScli1.hosts() )
- """
+ hosts.append( json.loads( main.ONOScli1.hosts() ) )
+ ipResult = main.TRUE
+ for controller in range( 0, len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ for host in hosts[ controller ]:
+ if host is None or host.get( 'ipAddresses', [] ) == []:
+ main.log.error(
+ "DEBUG:Error with host ips on controller" +
+ controllerStr + ": " + str( host ) )
+ ipResult = main.FALSE
ports = []
ports.append( main.ONOScli1.ports() )
links = []
links.append( main.ONOScli1.links() )
+ clusters = []
+ clusters.append( main.ONOScli1.clusters() )
+
elapsed = time.time() - startTime
cliTime = time.time() - cliStart
print "CLI time: " + str( cliTime )
@@ -723,89 +1410,111 @@
controller ]:
currentDevicesResult = main.Mininet1.compareSwitches(
MNTopo,
- json.loads(
- devices[ controller ] ) )
+ json.loads( devices[ controller ] ) )
else:
currentDevicesResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentDevicesResult,
- onpass="ONOS" + controllerStr +
- " Switches view is correct",
- onfail="ONOS" + controllerStr +
- " Switches view is incorrect" )
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
if ports[ controller ] or "Error" not in ports[ controller ]:
currentPortsResult = main.Mininet1.comparePorts(
MNTopo,
- json.loads(
- ports[ controller ] ) )
+ json.loads( ports[ controller ] ) )
else:
currentPortsResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentPortsResult,
- onpass="ONOS" + controllerStr +
- " ports view is correct",
- onfail="ONOS" + controllerStr +
- " ports view is incorrect" )
+ actual=currentPortsResult,
+ onpass="ONOS" + controllerStr +
+ " ports view is correct",
+ onfail="ONOS" + controllerStr +
+ " ports view is incorrect" )
if links[ controller ] or "Error" not in links[ controller ]:
currentLinksResult = main.Mininet1.compareLinks(
MNTopo,
- json.loads(
- links[ controller ] ) )
+ json.loads( links[ controller ] ) )
else:
currentLinksResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
- actual=currentLinksResult,
- onpass="ONOS" + controllerStr +
- " links view is correct",
- onfail="ONOS" + controllerStr +
- " links view is incorrect" )
- devicesResults = devicesResults and currentDevicesResult
- portsResults = portsResults and currentPortsResult
- linksResults = linksResults and currentLinksResult
- topoResult = devicesResults and portsResults and linksResults
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
+
+ if hosts[ controller ] or "Error" not in hosts[ controller ]:
+ currentHostsResult = main.Mininet1.compareHosts(
+ MNTopo, hosts[ controller ] )
+ else:
+ currentHostsResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentHostsResult,
+ onpass="ONOS" + controllerStr +
+ " hosts exist in Mininet",
+ onfail="ONOS" + controllerStr +
+ " hosts don't match Mininet" )
+
+ devicesResults = devicesResults and currentDevicesResult
+ portsResults = portsResults and currentPortsResult
+ linksResults = linksResults and currentLinksResult
+ hostsResults = hostsResults and currentHostsResult
+
+ # "consistent" results don't make sense for single instance
+ # there should always only be one cluster
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
+ utilities.assert_equals(
+ expect=1,
+ actual=numClusters,
+ onpass="ONOS shows 1 SCC",
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
+
+ topoResult = ( devicesResults and portsResults and linksResults
+ and hostsResults and ipResult and clusterResults )
topoResult = topoResult and int( count <= 2 )
note = "note it takes about " + str( int( cliTime ) ) + \
" seconds for the test to make all the cli calls to fetch " +\
"the topology from each ONOS instance"
- main.log.report(
+ main.log.info(
"Very crass estimate for topology discovery/convergence( " +
str( note ) + " ): " + str( elapsed ) + " seconds, " +
str( count ) + " tries" )
- if elapsed > 60:
- main.log.report( "Giving up on topology convergence" )
utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
- if topoResult == main.TRUE:
- main.log.report( "ONOS topology view matches Mininet topology" )
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful" )
def CASE9( self, main ):
"""
Link s3-s28 down
"""
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
# NOTE: You should probably run a topology check after this
linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
description = "Turn off a link to ensure that Link Discovery " +\
- "is working properly"
+ "is working properly"
main.log.report( description )
main.case( description )
main.step( "Kill Link between s3 and s28" )
LinkDown = main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
- main.log.info(
- "Waiting " +
- str( linkSleep ) +
- " seconds for link down to be discovered" )
+ main.log.info( "Waiting " + str( linkSleep ) +
+ " seconds for link down to be discovered" )
time.sleep( linkSleep )
utilities.assert_equals( expect=main.TRUE, actual=LinkDown,
- onpass="Link down succesful",
- onfail="Failed to bring link down" )
+ onpass="Link down successful",
+ onfail="Failed to bring link down" )
# TODO do some sort of check here
def CASE10( self, main ):
@@ -813,25 +1522,26 @@
Link s3-s28 up
"""
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
# NOTE: You should probably run a topology check after this
linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
description = "Restore a link to ensure that Link Discovery is " + \
- "working properly"
+ "working properly"
main.log.report( description )
main.case( description )
main.step( "Bring link between s3 and s28 back up" )
LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
- main.log.info(
- "Waiting " +
- str( linkSleep ) +
- " seconds for link up to be discovered" )
+ main.log.info( "Waiting " + str( linkSleep ) +
+ " seconds for link up to be discovered" )
time.sleep( linkSleep )
utilities.assert_equals( expect=main.TRUE, actual=LinkUp,
- onpass="Link up succesful",
- onfail="Failed to bring link up" )
+ onpass="Link up successful",
+ onfail="Failed to bring link up" )
# TODO do some sort of check here
def CASE11( self, main ):
@@ -840,6 +1550,9 @@
"""
# NOTE: You should probably run a topology check after this
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
@@ -863,8 +1576,8 @@
if device and device[ 'available' ] is False:
result = main.TRUE
utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Kill switch succesful",
- onfail="Failed to kill switch?" )
+ onpass="Kill switch successful",
+ onfail="Failed to kill switch?" )
def CASE12( self, main ):
"""
@@ -872,6 +1585,16 @@
"""
# NOTE: You should probably run a topology check after this
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
switch = main.params[ 'kill' ][ 'switch' ]
@@ -884,15 +1607,13 @@
main.step( "Add back " + switch )
main.log.report( "Adding back " + switch )
main.Mininet1.addSwitch( switch, dpid=switchDPID )
- # TODO: New dpid or same? Ask Thomas?
for peer in links:
main.Mininet1.addLink( switch, peer )
main.Mininet1.assignSwController( sw=switch.split( 's' )[ 1 ],
- ip1=ONOS1Ip, port1=ONOS1Port )
- main.log.info(
- "Waiting " +
- str( switchSleep ) +
- " seconds for switch up to be discovered" )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ main.log.info( "Waiting " + str( switchSleep ) +
+ " seconds for switch up to be discovered" )
time.sleep( switchSleep )
device = main.ONOScli1.getDevice( dpid=switchDPID )
# Peek at the deleted switch
@@ -901,8 +1622,8 @@
if device and device[ 'available' ]:
result = main.TRUE
utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="add switch succesful",
- onfail="Failed to add switch?" )
+ onpass="add switch successful",
+ onfail="Failed to add switch?" )
def CASE13( self, main ):
"""
@@ -910,25 +1631,19 @@
"""
import os
import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
# printing colors to terminal
- colors = {}
- colors[ 'cyan' ] = '\033[96m'
- colors[ 'purple' ] = '\033[95m'
- colors[ 'blue' ] = '\033[94m'
- colors[ 'green' ] = '\033[92m'
- colors[ 'yellow' ] = '\033[93m'
- colors[ 'red' ] = '\033[91m'
- colors[ 'end' ] = '\033[0m'
+ colors = { 'cyan': '\033[96m', 'purple': '\033[95m',
+ 'blue': '\033[94m', 'green': '\033[92m',
+ 'yellow': '\033[93m', 'red': '\033[91m', 'end': '\033[0m' }
description = "Test Cleanup"
main.log.report( description )
main.case( description )
main.step( "Killing tcpdumps" )
main.Mininet2.stopTcpdump()
- main.step( "Checking ONOS Logs for errors" )
- print colors[ 'purple' ] + "Checking logs for errors on ONOS1:" + \
- colors[ 'end' ]
- print main.ONOSbench.checkLogs( ONOS1Ip )
main.step( "Copying MN pcap and ONOS log files to test station" )
testname = main.TEST
teststationUser = main.params[ 'TESTONUSER' ]
@@ -950,7 +1665,6 @@
teststationIP + ":" + dstDir +
str( testname ) + "-ONOS1-" + f )
main.ONOSbench.handle.expect( "\$" )
- print main.ONOSbench.handle.before
# std*.log's
# NOTE: must end in /
@@ -964,25 +1678,43 @@
teststationUser + "@" +
teststationIP + ":" + dstDir +
str( testname ) + "-ONOS1-" + f )
+ main.ONOSbench.handle.expect( "\$" )
# sleep so scp can finish
time.sleep( 10 )
+
+ main.step( "Stopping Mininet" )
+ mnResult = main.Mininet1.stopNet()
+ utilities.assert_equals( expect=main.TRUE, actual=mnResult,
+ onpass="Mininet stopped",
+ onfail="MN cleanup NOT successful" )
+
+ main.step( "Checking ONOS Logs for errors" )
+ print colors[ 'purple' ] + "Checking logs for errors on ONOS1:" + \
+ colors[ 'end' ]
+ print main.ONOSbench.checkLogs( ONOS1Ip )
+
main.step( "Packing and rotating pcap archives" )
os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
- # TODO: actually check something here
- utilities.assert_equals( expect=main.TRUE, actual=main.TRUE,
- onpass="Test cleanup successful",
- onfail="Test cleanup NOT successful" )
-
def CASE14( self, main ):
"""
start election app on all onos nodes
"""
- leaderResult = main.TRUE
- # install app on onos 1
- main.log.info( "Install leadership election app" )
- main.ONOScli1.featureInstall( "onos-app-election" )
- # wait for election
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+
+ main.case("Start Leadership Election app")
+ main.step( "Install leadership election app" )
+ appResult = main.ONOScli1.activateApp( "org.onosproject.election" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=appResult,
+ onpass="Election app installed",
+ onfail="Something went wrong with installing Leadership election" )
+
+ main.step( "Run for election on each node" )
+ leaderResult = main.ONOScli1.electionTestRun()
# check for leader
leader = main.ONOScli1.electionTestLeader()
# verify leader is ONOS1
@@ -991,89 +1723,64 @@
pass
elif leader is None:
# No leader elected
- main.log.report( "No leader was elected" )
+ main.log.error( "No leader was elected" )
leaderResult = main.FALSE
elif leader == main.FALSE:
# error in response
# TODO: add check for "Command not found:" in the driver, this
# means the app isn't loaded
- main.log.report( "Something is wrong with electionTestLeader" +
+ main.log.error( "Something is wrong with electionTestLeader" +
" function, check the error logs" )
leaderResult = main.FALSE
else:
# error in response
- main.log.report(
+ main.log.error(
"Unexpected response from electionTestLeader function:'" +
str( leader ) +
"'" )
leaderResult = main.FALSE
-
- # install on other nodes and check for leader.
- # Should be onos1 and each app should show the same leader
- for controller in range( 2, numControllers + 1 ):
- # loop through ONOScli handlers
- node = getattr( main, ( 'ONOScli' + str( controller ) ) )
- node.featureInstall( "onos-app-election" )
- leaderN = node.electionTestLeader()
- # verify leader is ONOS1
- if leaderN == ONOS1Ip:
- # all is well
- pass
- elif leaderN == main.FALSE:
- # error in response
- # TODO: add check for "Command not found:" in the driver, this
- # means the app isn't loaded
- main.log.report( "Something is wrong with " +
- "electionTestLeader function, check the" +
- " error logs" )
- leaderResult = main.FALSE
- elif leader != leaderN:
- leaderResult = main.FALSE
- main.log.report( "ONOS" + str( controller ) + " sees " +
- str( leaderN ) +
- " as the leader of the election app. Leader" +
- " should be " +
- str( leader ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a leader " +
- "was elected )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
- onpass="Leadership election passed",
- onfail="Something went wrong with Leadership election" )
+ onpass="Successfully ran for leadership",
+ onfail="Failed to run for leadership" )
def CASE15( self, main ):
"""
Check that Leadership Election is still functional
"""
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
leaderResult = main.TRUE
description = "Check that Leadership Election is still functional"
main.log.report( description )
main.case( description )
main.step( "Find current leader and withdraw" )
leader = main.ONOScli1.electionTestLeader()
- # TODO: do some sanity checking on leader before using it
+ # do some sanity checking on leader before using it
withdrawResult = main.FALSE
if leader == ONOS1Ip:
oldLeader = getattr( main, "ONOScli1" )
elif leader is None or leader == main.FALSE:
main.log.report(
"Leader for the election app should be an ONOS node," +
- "instead got '" +
- str( leader ) +
- "'" )
+ "instead got '" + str( leader ) + "'" )
leaderResult = main.FALSE
- withdrawResult = oldLeader.electionTestWithdraw()
+ oldLeader = None
+ else:
+ main.log.error( "Leader election --- why am I HERE?!?")
+ leaderResult = main.FALSE
+ oldLeader = None
+ if oldLeader:
+ withdrawResult = oldLeader.electionTestWithdraw()
utilities.assert_equals(
expect=main.TRUE,
actual=withdrawResult,
- onpass="App was withdrawn from election",
- onfail="App was not withdrawn from election" )
+ onpass="Node was withdrawn from election",
+ onfail="Node was not withdrawn from election" )
main.step( "Make sure new leader is elected" )
- leaderList = []
leaderN = main.ONOScli1.electionTestLeader()
if leaderN == leader:
main.log.report( "ONOS still sees " + str( leaderN ) +
@@ -1089,34 +1796,1113 @@
elif leaderN is None:
main.log.info(
"There is no leader after the app withdrew from election" )
- if leaderResult:
- main.log.report( "Leadership election tests passed( There is no " +
- "leader after the old leader resigned )" )
+ leaderResult = main.TRUE
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
onpass="Leadership election passed",
onfail="Something went wrong with Leadership election" )
- main.step(
- "Run for election on old leader( just so everyone is in the hat )" )
- runResult = oldLeader.electionTestRun()
+ main.step( "Run for election on old leader( just so everyone " +
+ "is in the hat )" )
+ if oldLeader:
+ runResult = oldLeader.electionTestRun()
+ else:
+ runResult = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
actual=runResult,
onpass="App re-ran for election",
onfail="App failed to run for election" )
- leader = main.ONOScli1.electionTestLeader()
+
+ main.step( "Node became leader when it ran for election" )
+ afterRun = main.ONOScli1.electionTestLeader()
# verify leader is ONOS1
- if leader == ONOS1Ip:
- leaderResult = main.TRUE
+ if afterRun == ONOS1Ip:
+ afterResult = main.TRUE
else:
- leaderResult = main.FALSE
- # TODO: assert on run and withdraw results?
+ afterResult = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
- actual=leaderResult,
- onpass="Leadership election passed",
- onfail="ONOS1's election app was not leader after it re-ran " +
- "for election" )
+ actual=afterResult,
+ onpass="Old leader successfully re-ran for election",
+ onfail="Something went wrong with Leadership election after " +
+ "the old leader re-ran for election" )
+
+ def CASE16( self, main ):
+ """
+ Install Distributed Primitives app
+ """
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+
+ # Variables for the distributed primitives tests
+ global pCounterName
+ global iCounterName
+ global pCounterValue
+ global iCounterValue
+ global onosSet
+ global onosSetName
+ pCounterName = "TestON-Partitions"
+ iCounterName = "TestON-inMemory"
+ pCounterValue = 0
+ iCounterValue = 0
+ onosSet = set([])
+ onosSetName = "TestON-set"
+
+ description = "Install Primitives app"
+ main.case( description )
+ main.step( "Install Primitives app" )
+ appName = "org.onosproject.distributedprimitives"
+ appResults = CLIs[0].activateApp( appName )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=appResults,
+ onpass="Primitives app activated",
+ onfail="Primitives app not activated" )
+
+ def CASE17( self, main ):
+ """
+ Check for basic functionality with distributed primitives
+ """
+ # Make sure variables are defined/set
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert pCounterName, "pCounterName not defined"
+ assert iCounterName, "iCounterName not defined"
+ assert onosSetName, "onosSetName not defined"
+ # NOTE: assert fails if value is 0/None/Empty/False
+ try:
+ pCounterValue
+ except NameError:
+ main.log.error( "pCounterValue not defined, setting to 0" )
+ pCounterValue = 0
+ try:
+ iCounterValue
+ except NameError:
+ main.log.error( "iCounterValue not defined, setting to 0" )
+ iCounterValue = 0
+ try:
+ onosSet
+ except NameError:
+ main.log.error( "onosSet not defined, setting to empty Set" )
+ onosSet = set([])
+ # Variables for the distributed primitives tests. These are local only
+ addValue = "a"
+ addAllValue = "a b c d e f"
+ retainValue = "c d e f"
+
+ description = "Check for basic functionality with distributed " +\
+ "primitives"
+ main.case( description )
+ main.caseExplaination = "Test the methods of the distributed primitives (counters and sets) throught the cli"
+ # DISTRIBUTED ATOMIC COUNTERS
+ main.step( "Increment and get a default counter on each node" )
+ pCounters = []
+ threads = []
+ addedPValues = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counterTestIncrement,
+ name="counterIncrement-" + str( i ),
+ args=[ pCounterName ] )
+ pCounterValue += 1
+ addedPValues.append( pCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ pCounters.append( t.result )
+ # Check that counter incremented numController times
+ pCounterResults = True
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=pCounterResults,
+ onpass="Default counter incremented",
+ onfail="Error incrementing default" +
+ " counter" )
+
+ main.step( "Increment and get an in memory counter on each node" )
+ iCounters = []
+ addedIValues = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counterTestIncrement,
+ name="icounterIncrement-" + str( i ),
+ args=[ iCounterName ],
+ kwargs={ "inMemory": True } )
+ iCounterValue += 1
+ addedIValues.append( iCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ iCounters.append( t.result )
+ # Check that counter incremented numController times
+ iCounterResults = True
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in the in-memory "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=iCounterResults,
+ onpass="In memory counter incremented",
+ onfail="Error incrementing in memory" +
+ " counter" )
+
+ main.step( "Check counters are consistant across nodes" )
+ onosCounters = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].counters,
+ name="counters-" + str( i ) )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ onosCounters.append( t.result )
+ tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
+ if all( tmp ):
+ main.log.info( "Counters are consistent across all nodes" )
+ consistentCounterResults = main.TRUE
+ else:
+ main.log.error( "Counters are not consistent across all nodes" )
+ consistentCounterResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=consistentCounterResults,
+ onpass="ONOS counters are consistent " +
+ "across nodes",
+ onfail="ONOS Counters are inconsistent " +
+ "across nodes" )
+
+ main.step( "Counters we added have the correct values" )
+ correctResults = main.TRUE
+ for i in range( numControllers ):
+ current = onosCounters[i]
+ try:
+ pValue = current.get( pCounterName )
+ iValue = current.get( iCounterName )
+ if pValue == pCounterValue:
+ main.log.info( "Partitioned counter value is correct" )
+ else:
+ main.log.error( "Partitioned counter value is incorrect," +
+ " expected value: " + str( pCounterValue )
+ + " current value: " + str( pValue ) )
+ correctResults = main.FALSE
+ if iValue == iCounterValue:
+ main.log.info( "In memory counter value is correct" )
+ else:
+ main.log.error( "In memory counter value is incorrect, " +
+ "expected value: " + str( iCounterValue ) +
+ " current value: " + str( iValue ) )
+ correctResults = main.FALSE
+ except AttributeError, e:
+ main.log.error( "ONOS" + str( i + 1 ) + " counters result " +
+ "is not as expected" )
+ correctResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=correctResults,
+ onpass="Added counters are correct",
+ onfail="Added counters are incorrect" )
+ # DISTRIBUTED SETS
+ main.step( "Distributed Set get" )
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=getResults,
+ onpass="Set elements are correct",
+ onfail="Set elements are incorrect" )
+
+ main.step( "Distributed Set size" )
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=sizeResults,
+ onpass="Set sizes are correct",
+ onfail="Set sizes are incorrect" )
+
+ main.step( "Distributed Set add()" )
+ onosSet.add( addValue )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAdd-" + str( i ),
+ args=[ onosSetName, addValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addResults = main.FALSE
+ else:
+ # unexpected result
+ addResults = main.FALSE
+ if addResults != main.TRUE:
+ main.log.error( "Error executing set add" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addResults = addResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addResults,
+ onpass="Set add correct",
+ onfail="Set add was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set contains()" )
+ containsResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setContains-" + str( i ),
+ args=[ onosSetName ],
+ kwargs={ "values": addValue } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ # NOTE: This is the tuple
+ containsResponses.append( t.result )
+
+ containsResults = main.TRUE
+ for i in range( numControllers ):
+ if containsResponses[ i ] == main.ERROR:
+ containsResults = main.FALSE
+ else:
+ containsResults = containsResults and\
+ containsResponses[ i ][ 1 ]
+ utilities.assert_equals( expect=main.TRUE,
+ actual=containsResults,
+ onpass="Set contains is functional",
+ onfail="Set contains failed" )
+
+ main.step( "Distributed Set containsAll()" )
+ containsAllResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setContainsAll-" + str( i ),
+ args=[ onosSetName ],
+ kwargs={ "values": addAllValue } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ # NOTE: This is the tuple
+ containsAllResponses.append( t.result )
+
+ containsAllResults = main.TRUE
+ for i in range( numControllers ):
+ if containsResponses[ i ] == main.ERROR:
+ containsResults = main.FALSE
+ else:
+ containsResults = containsResults and\
+ containsResponses[ i ][ 1 ]
+ utilities.assert_equals( expect=main.TRUE,
+ actual=containsAllResults,
+ onpass="Set containsAll is functional",
+ onfail="Set containsAll failed" )
+
+ main.step( "Distributed Set remove()" )
+ onosSet.remove( addValue )
+ removeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRemove-" + str( i ),
+ args=[ onosSetName, addValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ removeResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ removeResults = main.TRUE
+ for i in range( numControllers ):
+ if removeResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif removeResponses[ i ] == main.FALSE:
+ # not in set, probably fine
+ pass
+ elif removeResponses[ i ] == main.ERROR:
+ # Error in execution
+ removeResults = main.FALSE
+ else:
+ # unexpected result
+ removeResults = main.FALSE
+ if removeResults != main.TRUE:
+ main.log.error( "Error executing set remove" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ removeResults = removeResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=removeResults,
+ onpass="Set remove correct",
+ onfail="Set remove was incorrect" )
+
+ main.step( "Distributed Set removeAll()" )
+ onosSet.difference_update( addAllValue.split() )
+ removeAllResponses = []
+ threads = []
+ try:
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRemoveAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ removeAllResponses.append( t.result )
+ except Exception, e:
+ main.log.exception(e)
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ removeAllResults = main.TRUE
+ for i in range( numControllers ):
+ if removeAllResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif removeAllResponses[ i ] == main.FALSE:
+ # not in set, probably fine
+ pass
+ elif removeAllResponses[ i ] == main.ERROR:
+ # Error in execution
+ removeAllResults = main.FALSE
+ else:
+ # unexpected result
+ removeAllResults = main.FALSE
+ if removeAllResults != main.TRUE:
+ main.log.error( "Error executing set removeAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ removeAllResults = removeAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=removeAllResults,
+ onpass="Set removeAll correct",
+ onfail="Set removeAll was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set clear()" )
+ onosSet.clear()
+ clearResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestClear-" + str( i ),
+ args=[ onosSetName, " "], # Values doesn't matter
+ kwargs={ "clear": True } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ clearResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ clearResults = main.TRUE
+ for i in range( numControllers ):
+ if clearResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif clearResponses[ i ] == main.FALSE:
+ # Nothing set, probably fine
+ pass
+ elif clearResponses[ i ] == main.ERROR:
+ # Error in execution
+ clearResults = main.FALSE
+ else:
+ # unexpected result
+ clearResults = main.FALSE
+ if clearResults != main.TRUE:
+ main.log.error( "Error executing set clear" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ clearResults = clearResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=clearResults,
+ onpass="Set clear correct",
+ onfail="Set clear was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( numControllers ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " + str( size ) +
+ " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set retain()" )
+ onosSet.intersection_update( retainValue.split() )
+ retainResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestRemove,
+ name="setTestRetain-" + str( i ),
+ args=[ onosSetName, retainValue ],
+ kwargs={ "retain": True } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ retainResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ retainResults = main.TRUE
+ for i in range( numControllers ):
+ if retainResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif retainResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif retainResponses[ i ] == main.ERROR:
+ # Error in execution
+ retainResults = main.FALSE
+ else:
+ # unexpected result
+ retainResults = main.FALSE
+ if retainResults != main.TRUE:
+ main.log.error( "Error executing set retain" )
+
+ # Check if set is still correct
+ size = len( onosSet )
+ getResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( numControllers ):
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if onosSet != current:
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has incorrect view" +
+ " of set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " has repeat elements in" +
+ " set " + onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in range( numControllers ):
+ t = main.Thread( target=CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( numControllers ):
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + str( i + 1 ) +
+ " expected a size of " +
+ str( size ) + " for set " + onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ retainResults = retainResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=retainResults,
+ onpass="Set retain correct",
+ onfail="Set retain was incorrect" )
+
diff --git a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.topo b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.topo
index 4d4156c..9305025 100644
--- a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.topo
+++ b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.topo
@@ -151,7 +151,7 @@
<arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
<arg2> --topo mytopo </arg2>
<arg3> </arg3>
- <controller> remote </controller>
+ <controller> none </controller>
</COMPONENTS>
</Mininet1>
@@ -162,11 +162,7 @@
<type>RemoteMininetDriver</type>
<connect_order>17</connect_order>
<COMPONENTS>
- # Specify the Option for mininet
- <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
- <arg2> --topo mytopo --arp</arg2>
- <controller> remote </controller>
- </COMPONENTS>
+ </COMPONENTS>
</Mininet2>
</COMPONENT>
diff --git a/TestON/tests/IntentEventTP/IntentEventTP.params b/TestON/tests/IntentEventTP/IntentEventTP.params
new file mode 100644
index 0000000..ddda23e
--- /dev/null
+++ b/TestON/tests/IntentEventTP/IntentEventTP.params
@@ -0,0 +1,71 @@
+<PARAMS>
+
+ <testcases>1,2,1,2,1,2,1,2,1,2,1,2,1,2</testcases>
+
+ <isOnBaremetal>True</isOnBaremetal>
+ <debugMode></debugMode> #nothing means false
+
+ <ENV>
+ <cellName>intentTP</cellName>
+ <cellApps>drivers,null,intentperf</cellApps>
+ </ENV>
+
+ <SCALE>1,3,3,5,5,7,7</SCALE>
+ <availableNodes>7</availableNodes>
+
+ <GIT>
+ <autopull>on</autopull>
+ <checkout>master</checkout>
+ </GIT>
+
+ <CTRL>
+ <USER>admin</USER>
+
+ <ip1>10.128.5.51</ip1>
+ <port1>6633</port1>
+
+ <ip2>10.128.5.52</ip2>
+ <port2>6633</port2>
+
+ <ip3>10.128.5.53</ip3>
+ <port3>6633</port3>
+
+ <ip4>10.128.5.54</ip4>
+ <port4>6633</port4>
+
+ <ip5>10.128.5.55</ip5>
+ <port5>6633</port5>
+
+ <ip6>10.128.5.56</ip6>
+ <port6>6633</port6>
+
+ <ip7>10.128.5.57</ip7>
+ <port7>6633</port7>
+ </CTRL>
+
+ <MN><ip1>10.128.5.50</ip1></MN>
+
+ <BENCH>
+ <user>admin</user>
+ <ip1>10.128.5.50</ip1>
+ </BENCH>
+
+ <TEST>
+ <loadFrom>1,1,1,1,1,1,1</loadFrom> #generate load on server, 1 = generator on
+ <numSwitches>10,10,10,10,10,10,10</numSwitches>
+ <skipCleanInstall>yes</skipCleanInstall>
+ <duration>400</duration>
+ <log_interval>20</log_interval>
+ <numKeys>40000</numKeys>
+ <cyclePeriod>1000</cyclePeriod>
+ <neighbors>0,a</neighbors> #a == all nodes (-1)
+ <flowRuleBUEnabled>false</flowRuleBUEnabled>
+ </TEST>
+
+ <METRICS>
+ <intents_rate>intents-events-metrics|grep "Intent Installed Events"|cut -d ' ' -f7</intents_rate>
+ <intents_withdrawn>intents-events-metrics|grep "Intent Withdrawn Events"|cut -d ' ' -f7</intents_withdrawn>
+ <intents_failed>intents-events-metrics|grep "Intent Failed Events"|cut -d ' ' -f7</intents_failed>
+ </METRICS>
+
+</PARAMS>
diff --git a/TestON/tests/IntentEventTP/IntentEventTP.py b/TestON/tests/IntentEventTP/IntentEventTP.py
new file mode 100644
index 0000000..99332f7
--- /dev/null
+++ b/TestON/tests/IntentEventTP/IntentEventTP.py
@@ -0,0 +1,358 @@
+# ScaleOutTemplate
+#
+# CASE1 starts number of nodes specified in param file
+#
+# cameron@onlab.us
+
+import sys
+import os.path
+
+
+class IntentEventTP:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+
+ import time
+ import os.path
+
+ global init
+ try:
+ if type(init) is not bool:
+ init = False
+ except NameError:
+ init = False
+
+ #Load values from params file
+ checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
+ gitPull = main.params[ 'GIT' ][ 'autopull' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ Apps = main.params[ 'ENV' ][ 'cellApps' ]
+ BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+ BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+ MN1Ip = main.params[ 'MN' ][ 'ip1' ]
+ maxNodes = int(main.params[ 'availableNodes' ])
+ skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",")
+ flowRuleBU = main.params[ 'TEST' ][ 'flowRuleBUEnabled' ]
+ onBaremetal = main.params['isOnBaremetal']
+ homeDir = os.path.expanduser('~')
+
+ main.exceptions = [0]*11
+ main.warnings = [0]*11
+ main.errors = [0]*11
+
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
+ if init == False:
+ init = True
+ global clusterCount #number of nodes running
+ global ONOSIp #list of ONOS IP addresses
+ global scale
+ global commit
+
+ clusterCount = 0
+ ONOSIp = [ 0 ]
+ scale = (main.params[ 'SCALE' ]).split(",")
+ clusterCount = int(scale[0])
+
+ #Populate ONOSIp with ips from params
+ for i in range(1, maxNodes + 1):
+ ipString = 'ip' + str(i)
+ ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
+
+ #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
+ if skipMvn != "yes":
+ mvnResult = main.ONOSbench.cleanInstall()
+
+ #git
+ main.step( "Git checkout and pull " + checkoutBranch )
+ if gitPull == 'on':
+ checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
+ pullResult = main.ONOSbench.gitPull()
+
+ else:
+ checkoutResult = main.TRUE
+ pullResult = main.TRUE
+ main.log.info( "Skipped git checkout and pull" )
+
+ commit = main.ONOSbench.getVersion()
+ commit = (commit.split(" "))[1]
+
+ resultsDB = open("IntentEventTPDB", "w+")
+ resultsDB.close()
+
+ # -- END OF INIT SECTION --#
+
+ clusterCount = int(scale[0])
+ scale.remove(scale[0])
+
+ #kill off all onos processes
+ main.log.step("Safety check, killing all ONOS processes")
+ main.log.step("before initiating enviornment setup")
+ for node in range(1, maxNodes + 1):
+ main.ONOSbench.onosDie(ONOSIp[node])
+
+ #Uninstall everywhere
+ main.log.step( "Cleaning Enviornment..." )
+ for i in range(1, maxNodes + 1):
+ main.log.info(" Uninstalling ONOS " + str(i) )
+ main.ONOSbench.onosUninstall( ONOSIp[i] )
+
+ #construct the cell file
+ main.log.info("Creating cell file")
+ cellIp = []
+ for node in range (1, clusterCount + 1):
+ cellIp.append(ONOSIp[node])
+
+ main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
+
+ main.step( "Set Cell" )
+ main.ONOSbench.setCell(cellName)
+
+ myDistribution = []
+ for node in range (1, clusterCount + 1):
+ myDistribution.append(numSwitches[node-1])
+
+ #main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
+
+ if onBaremetal == "True":
+ filename = "/onos/tools/package/bin/onos-service"
+ serviceConfig = open(homeDir + filename, 'w+')
+ serviceConfig.write("#!/bin/bash\n ")
+ serviceConfig.write("#------------------------------------- \n ")
+ serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
+ serviceConfig.write("#------------------------------------- \n ")
+ serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
+ serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
+ serviceConfig.write("")
+ serviceConfig.write("ONOS_HOME=/opt/onos \n ")
+ serviceConfig.write("")
+ serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
+ serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
+ serviceConfig.close()
+ main.log.info("Set /onos/tools/package/bin/onos-service with 8G Xms/Xmx Options.")
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "verify cells" )
+ verifyCellResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
+ for node in range(1, clusterCount + 1):
+ main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
+ main.ONOSbench.onosInstall( ONOSIp[node])
+
+ for node in range(1, clusterCount + 1):
+ for i in range( 2 ):
+ isup = main.ONOSbench.isup( ONOSIp[node] )
+ if isup:
+ main.log.info("ONOS " + str(node) + " is up\n")
+ break
+ if not isup:
+ main.log.report( "ONOS " + str(node) + " didn't start!" )
+ main.log.info("Startup sequence complete")
+
+ time.sleep(20)
+
+
+ while True:
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(clusterCount*10) + """ " """)
+ main.ONOSbench.handle.expect(":~")
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
+ main.ONOSbench.handle.expect(":~")
+ if ("value=" + str(clusterCount*10)) in main.ONOSbench.handle.before:
+ main.log.info("Device count set")
+ main.log.info("before" + main.ONOSbench.handle.before)
+ break
+ time.sleep(10)
+ main.log.info("cfg set failure, retrying")
+ main.log.info("before" + main.ONOSbench.handle.before)
+
+ while True:
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
+ main.ONOSbench.handle.expect(":~")
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
+ main.ONOSbench.handle.expect(":~")
+ if ("value=linear") in main.ONOSbench.handle.before:
+ main.log.info("Device count set")
+ main.log.info("before" + main.ONOSbench.handle.before)
+ break
+ time.sleep(10)
+ main.log.info("cfg set failure, retrying")
+ main.log.info("before" + main.ONOSbench.handle.before)
+
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBU + """" """)
+ main.ONOSbench.handle.expect(":~")
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg get" """)
+ main.ONOSbench.handle.expect(":~")
+ main.log.info(main.ONOSbench.handle.before)
+
+ time.sleep(10)
+ main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
+ main.ONOSbench.handle.expect(":~")
+ print main.ONOSbench.handle.before
+ time.sleep(10)
+ main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
+ main.ONOSbench.handle.expect(":~")
+ print main.ONOSbench.handle.before
+
+ lastOutput = "--"
+ origin = time.time()
+ clockStarted = False
+ while True:
+ main.ONOSbench.handle.sendline("onos $OC1 summary")
+ main.ONOSbench.handle.expect(":~")
+ main.log.info("before" + main.ONOSbench.handle.before)
+ clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
+ print("\nBefore: " + str(clusterCheck))
+ if ("SCC(s)=1,") in clusterCheck:
+ break
+ if clusterCheck != lastOutput:
+ sameOutput = False
+ elif clusterCheck == lastOutput:
+ if clockStarted == False:
+ start = time.time()
+ clockStarted = True
+ if time.time() > (start + 10):
+ main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
+ break
+ lastOutput = clusterCheck
+ time.sleep(5)
+ main.ONOSbench.onosErrorLog(ONOSIp[1])
+
+ def CASE2( self, main ):
+ import time
+ import json
+ import string
+ import csv
+ import numpy
+ import os.path
+
+ global currentNeighbors
+ neighbors = []
+
+ try:
+ currentNeighbors
+ except:
+ currentNeighbors = "0"
+ neighbors = ['0']
+ else:
+ if currentNeighbors == "r": #reset
+ currentNeighbors = "a"
+ neighbors = ['0']
+ else:
+ currentNeighbors = "r"
+ neighbors = ['a']
+
+ if clusterCount == 1:
+ currentNeighbors = "r"
+
+ main.log.info("Cluster Count = " + str(clusterCount))
+
+ intentsRate = main.params['METRICS']['intents_rate']
+ intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
+ intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
+ testDuration = main.params[ 'TEST' ][ 'duration' ]
+ logInterval = main.params[ 'TEST' ][ 'log_interval' ]
+ debug = main.params[ 'debugMode' ]
+ numKeys = main.params[ 'TEST' ][ 'numKeys' ]
+ cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
+ #neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
+ metricList = [intentsRate, intentsWithdrawn, intentsFailed]
+
+ for n in range(0, len(neighbors)):
+ if neighbors[n] == 'a':
+ neighbors[n] = str(clusterCount -1)
+ if int(clusterCount) == 1:
+ neighbors = neighbors.pop()
+
+ for n in neighbors:
+ main.log.info("Run with " + n + " neighbors")
+ time.sleep(5)
+ main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
+ main.ONOSbench.handle.expect(":~")
+ main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
+ main.ONOSbench.handle.expect(":~")
+ main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
+ main.ONOSbench.handle.expect(":~")
+
+ cmd = "onos $OC1 intent-perf-start"
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
+
+ main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
+ stop = time.time() + float( testDuration )
+
+ while time.time() < stop:
+ time.sleep( float( logInterval ) )
+ groupResult = []
+ for node in range (1, clusterCount + 1):
+ groupResult.append(0)
+
+ cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
+ main.log.info("COMMAND: " + str(cmd))
+
+ x = 0
+ while True:
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ raw = main.ONOSbench.handle.before
+ if "OVERALL=" in raw:
+ break
+ x += 1
+ if x > 10:
+ main.log.error("Expected output not being recieved... continuing")
+ break
+ time.sleep(2)
+
+ raw = raw.splitlines()
+ splitResults = []
+ for line in raw:
+ splitResults.extend(line.split(" "))
+
+ myResult = "--"
+ for field in splitResults:
+ if "OVERALL" in field:
+ myResult = field
+
+ if myResult == "--":
+ main.log.error("Parsing/Pexpect error\n" + str(splitResults))
+
+ myResult = myResult.replace(";", "")
+ myResult = myResult.replace("OVERALL=","")
+ myResult = float(myResult)
+ groupResult[len(groupResult) -1] = myResult
+
+ main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
+
+ clusterTotal = str(numpy.sum(groupResult))
+ main.log.report("Results from this round of polling: " + str(groupResult))
+ main.log.report("Cluster Total: " + clusterTotal + "\n")
+
+ cmd = "onos $OC1 intent-perf-stop"
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ main.log.info("Stopping intentperf" )
+
+ resultsDB = open("IntentEventTPDB", "a")
+ for node in groupResult:
+
+ resultString = "'" + commit + "',"
+ resultString += "'1gig',"
+ resultString += str(clusterCount) + ","
+ resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
+ resultString += n + ","
+ resultString += str(node) + ","
+ resultString += str(0) + "\n" #no stddev
+ resultsDB.write(resultString)
+
+ resultsDB.close()
+
+ main.ONOSbench.onosErrorLog(ONOSIp[1])
+
+
diff --git a/TestON/tests/IntentEventTP/IntentEventTP.topo b/TestON/tests/IntentEventTP/IntentEventTP.topo
new file mode 100644
index 0000000..763a4d6
--- /dev/null
+++ b/TestON/tests/IntentEventTP/IntentEventTP.topo
@@ -0,0 +1,144 @@
+<TOPOLOGY>
+
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS><home>~/onos</home></COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1cli>
+
+ <ONOS2cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2cli>
+
+ <ONOS3cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3cli>
+
+ <ONOS4cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4cli>
+
+ <ONOS5cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5cli>
+
+ <ONOS6cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6cli>
+
+ <ONOS7cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7cli>
+
+ <ONOS1>
+ <host>10.128.5.51</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.5.52</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.5.53</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.128.5.54</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4>
+
+
+ <ONOS5>
+ <host>10.128.5.55</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5>
+
+ <ONOS6>
+ <host>10.128.5.56</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>14</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6>
+
+ <ONOS7>
+ <host>10.128.5.57</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>15</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7>
+
+ </COMPONENT>
+
+</TOPOLOGY>
+
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/IntentEventTP/__init__.py
similarity index 100%
rename from TestON/tests/IntentsLoad/__init__.py
rename to TestON/tests/IntentEventTP/__init__.py
diff --git a/TestON/tests/IntentInstallWithdrawLat/IntentInstallWithdrawLat.params b/TestON/tests/IntentInstallWithdrawLat/IntentInstallWithdrawLat.params
new file mode 100644
index 0000000..2b76662
--- /dev/null
+++ b/TestON/tests/IntentInstallWithdrawLat/IntentInstallWithdrawLat.params
@@ -0,0 +1,66 @@
+<PARAMS>
+
+ <testcases>1,2,1,2,1,2,1,2</testcases>
+
+ <SCALE>1,3,5,7</SCALE>
+ <availableNodes>7</availableNodes>
+
+ <ENV>
+ <cellName>IntentInstallWithdrawCell</cellName>
+ <cellApps>drivers,null</cellApps>
+ </ENV>
+
+ <TEST>
+ <skipCleanInstall>yes</skipCleanInstall>
+ <switchCount>7</switchCount>
+ <warmUp>10</warmUp>
+ <sampleSize>20</sampleSize>
+ <wait></wait>
+ <intents>1,100,1000</intents> #list format, will be split on ','
+ <debug>True</debug> #"True" for true
+ </TEST>
+
+ <GIT>
+ <autopull>on</autopull>
+ <checkout>master</checkout>
+ </GIT>
+
+ <CTRL>
+ <USER>admin</USER>
+
+ <ip1>10.254.1.201</ip1>
+ <port1>6633</port1>
+
+ <ip2>10.254.1.202</ip2>
+ <port2>6633</port2>
+
+ <ip3>10.254.1.203</ip3>
+ <port3>6633</port3>
+
+ <ip4>10.254.1.204</ip4>
+ <port4>6633</port4>
+
+ <ip5>10.254.1.205</ip5>
+ <port5>6633</port5>
+
+ <ip6>10.254.1.206</ip6>
+ <port6>6633</port6>
+
+ <ip7>10.254.1.207</ip7>
+ <port7>6633</port7>
+
+ </CTRL>
+
+ <MN>
+ <ip1>10.254.1.200</ip1>
+ </MN>
+
+ <BENCH>
+ <user>admin</user>
+ <ip1>10.254.1.200</ip1>
+ </BENCH>
+
+ <JSON>
+ </JSON>
+
+</PARAMS>
diff --git a/TestON/tests/IntentInstallWithdrawLat/IntentInstallWithdrawLat.py b/TestON/tests/IntentInstallWithdrawLat/IntentInstallWithdrawLat.py
new file mode 100644
index 0000000..83dac2a
--- /dev/null
+++ b/TestON/tests/IntentInstallWithdrawLat/IntentInstallWithdrawLat.py
@@ -0,0 +1,257 @@
+# ScaleOutTemplate
+#
+# CASE1 starts number of nodes specified in param file
+#
+# cameron@onlab.us
+
+import sys
+import os.path
+
+
+class IntentInstallWithdrawLat:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+
+ import time
+ global init
+ try:
+ if type(init) is not bool:
+ init = False
+ except NameError:
+ init = False
+
+ #Load values from params file
+ checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
+ gitPull = main.params[ 'GIT' ][ 'autopull' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ Apps = main.params[ 'ENV' ][ 'cellApps' ]
+ BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+ BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+ MN1Ip = main.params[ 'MN' ][ 'ip1' ]
+ maxNodes = int(main.params[ 'availableNodes' ])
+ skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ switchCount = main.params[ 'TEST' ][ 'switchCount' ]
+
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
+ if init == False:
+ init = True
+ global clusterCount #number of nodes running
+ global ONOSIp #list of ONOS IP addresses
+ global scale
+ global commit
+
+ clusterCount = 0
+ ONOSIp = [ 0 ]
+ scale = (main.params[ 'SCALE' ]).split(",")
+ clusterCount = int(scale[0])
+
+ #Populate ONOSIp with ips from params
+ for i in range(1, maxNodes + 1):
+ ipString = 'ip' + str(i)
+ ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
+
+ #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
+ if skipMvn != "yes":
+ mvnResult = main.ONOSbench.cleanInstall()
+
+ #git
+ main.step( "Git checkout and pull " + checkoutBranch )
+ if gitPull == 'on':
+ checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
+ pullResult = main.ONOSbench.gitPull()
+
+ else:
+ checkoutResult = main.TRUE
+ pullResult = main.TRUE
+ main.log.info( "Skipped git checkout and pull" )
+
+ commit = main.ONOSbench.getVersion()
+ commit = (commit.split(" "))[1]
+
+ resultsDB = open("IntentInstallWithdrawLatDB", "w+")
+ resultsDB.close()
+
+ # -- END OF INIT SECTION --#
+
+ clusterCount = int(scale[0])
+ scale.remove(scale[0])
+
+ #kill off all onos processes
+ main.log.step("Safety check, killing all ONOS processes")
+ main.log.step("before initiating enviornment setup")
+ for node in range(1, maxNodes + 1):
+ main.ONOSbench.onosDie(ONOSIp[node])
+
+ #Uninstall everywhere
+ main.log.step( "Cleaning Enviornment..." )
+ for i in range(1, maxNodes + 1):
+ main.log.info(" Uninstalling ONOS " + str(i) )
+ main.ONOSbench.onosUninstall( ONOSIp[i] )
+
+ #construct the cell file
+ main.log.info("Creating cell file")
+ cellIp = []
+ for node in range (1, clusterCount + 1):
+ cellIp.append(ONOSIp[node])
+
+ main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
+
+ main.step( "Set Cell" )
+ main.ONOSbench.setCell(cellName)
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "verify cells" )
+ verifyCellResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
+ for node in range(1, clusterCount + 1):
+ main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
+ main.ONOSbench.onosInstall( ONOSIp[node])
+
+ for node in range(1, clusterCount + 1):
+ for i in range( 2 ):
+ isup = main.ONOSbench.isup( ONOSIp[node] )
+ if isup:
+ main.log.info("ONOS " + str(node) + " is up\n")
+ break
+ if not isup:
+ main.log.report( "ONOS " + str(node) + " didn't start!" )
+
+ main.ONOS1cli.startOnosCli( ONOSIp[1] )
+ main.log.info("Startup sequence complete")
+
+ time.sleep(30)
+
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg setorg.onosproject.provider.nil.NullProviders enabled true" """)
+ main.ONOSbench.handle.expect(":~")
+ print main.ONOSbench.handle.before
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(switchCount) + """ " """)
+ main.ONOSbench.handle.expect(":~")
+ print main.ONOSbench.handle.before
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
+ main.ONOSbench.handle.expect(":~")
+ print main.ONOSbench.handle.before
+ main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
+ main.ONOSbench.handle.expect(":~")
+ print main.ONOSbench.handle.before
+ main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
+ main.ONOSbench.handle.expect(":~")
+ print main.ONOSbench.handle.before
+
+ def CASE2( self, main ):
+
+ import time
+ import numpy
+
+ sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
+ warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
+ intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
+ switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
+ debug = main.params[ 'TEST' ][ 'switchCount' ]
+ for i in range(0,len(intentsList)):
+ intentsList[i] = int(intentsList[i])
+
+ if debug == "True":
+ debug = True
+ else:
+ debug = False
+
+ linkCount = 0
+ for i in range(0,10):
+ main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
+ main.ONOSbench.handle.expect(":~")
+ linkCount = main.ONOSbench.handle.before
+ if debug: main.log.info("Link Count check: " + linkCount)
+ if str((switchCount*2)-2) in linkCount:
+ break
+ time.sleep(2)
+
+ links = "--"
+ while "=null:" not in links:
+ if debug: main.log.info("top of loop")
+ main.ONOSbench.handle.sendline("onos $OC1 links")
+ main.ONOSbench.handle.expect(":~")
+ links = main.ONOSbench.handle.before
+ if debug: main.log.info(str(links))
+ time.sleep(1)
+ links = links.splitlines()
+ templinks = links
+
+ tempDevices = []
+ for line in links:
+ temp = line.split(" ")
+ temp[0].replace("src=","")
+ temp[0] = (temp[0].split("/"))[0]
+ tempDevices.append(temp[0])
+
+ tempDevices.sort()
+ devices = []
+ for i in tempDevices:
+ if "src=null" in i:
+ devices.append(i.replace("src=", ""))
+ if debug: main.log.info(str(devices))
+
+ ingress = devices[0]
+ egress = devices.pop()
+ if debug: main.log.info(ingress)
+ if debug: main.log.info(egress)
+
+ for intentSize in intentsList:
+ cmd = "onos $OC1 push-test-intents "
+ cmd += ingress + "/6 "
+ cmd += egress + "/5 "
+ cmd += str(intentSize) + " 1"
+ installed = []
+ withdrawn = []
+
+ for run in range(0, (warmUp + sampleSize)):
+ if run > warmUp:
+ time.sleep(5)
+
+ myRawResult = "--"
+ while "ms" not in myRawResult:
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ myRawResult = main.ONOSbench.handle.before
+ if debug: main.log.info(myRawResult)
+
+ if debug: main.log.info(myRawResult)
+
+ if run >= warmUp:
+ myRawResult = myRawResult.splitlines()
+ for line in myRawResult:
+ if "install" in line:
+ installed.append(int(line.split(" ")[5]))
+
+ for line in myRawResult:
+ if "withdraw" in line:
+ withdrawn.append(int(line.split(" ")[5]))
+
+ print("installed: " + str(installed))
+ print("withraw: " + str(withdrawn) + "\n")
+
+ main.log.report("----------------------------------------------------")
+ main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
+ main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
+ main.log.report("Installed average: " + str(numpy.mean(installed)))
+ main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
+ main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
+ main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
+ main.log.report(" ")
+
+ resultString = "'" + commit + "',"
+ resultString += str(clusterCount) + ","
+ resultString += str(intentSize) + ","
+ resultString += str(numpy.mean(installed)) + ","
+ resultString += str(numpy.std(installed)) + ","
+ resultString += str(numpy.mean(withdrawn)) + ","
+ resultString += str(numpy.std(withdrawn)) + "\n"
+ resultsDB = open("IntentInstallWithdrawLatDB", "a")
+ resultsDB.write(resultString)
+ resultsDB.close()
diff --git a/TestON/tests/IntentInstallWithdrawLat/IntentInstallWithdrawLat.topo b/TestON/tests/IntentInstallWithdrawLat/IntentInstallWithdrawLat.topo
new file mode 100644
index 0000000..0e45e0f
--- /dev/null
+++ b/TestON/tests/IntentInstallWithdrawLat/IntentInstallWithdrawLat.topo
@@ -0,0 +1,146 @@
+<TOPOLOGY>
+
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS><home>~/onos</home></COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1cli>
+
+ <ONOS2cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2cli>
+
+ <ONOS3cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3cli>
+
+ <ONOS4cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4cli>
+
+ <ONOS5cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5cli>
+
+ <ONOS6cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6cli>
+
+ <ONOS7cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7cli>
+
+ <ONOS1>
+ <host>10.254.1.201</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.254.1.202</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.254.1.203</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.254.1.204</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4>
+
+
+ <ONOS5>
+ <host>10.254.1.205</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5>
+
+ <ONOS6>
+ <host>10.254.1.206</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>14</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6>
+
+ <ONOS7>
+ <host>10.254.1.207</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>15</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7>
+
+ </COMPONENT>
+
+</TOPOLOGY>
+
+
+
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/IntentInstallWithdrawLat/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/IntentInstallWithdrawLat/__init__.py
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.params b/TestON/tests/IntentPerfNext/IntentPerfNext.params
index 8909059..90ef160 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.params
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.params
@@ -1,5 +1,5 @@
<PARAMS>
- <testcases>1,4,5,2,3,4,5,2,3,4,5,2,3,4</testcases>
+ <testcases>1,4,5,4,5,4,5,4</testcases>
<ENV>
<cellName>intent_perf_test</cellName>
@@ -36,7 +36,7 @@
<TEST>
#Number of times to iterate each case
- <numIter>3</numIter>
+ <numIter>8</numIter>
<numIgnore>2</numIgnore>
<numSwitch>8</numSwitch>
<batchThresholdMin>0</batchThresholdMin>
@@ -47,6 +47,12 @@
<intfs>s3-eth2</intfs>
</TEST>
+ <DB>
+ <intentFilePath>
+ /home/admin/ONLabTest/TestON/tests/IntentPerfNext/intentLatencyResultDb.log
+ </intentFilePath>
+ </DB>
+
<JSON>
<submittedTime>intentSubmittedTimestamp</submittedTime>
<installedTime>intentInstalledTimestamp</installedTime>
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.py b/TestON/tests/IntentPerfNext/IntentPerfNext.py
index 40a1276..cb226e7 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.py
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.py
@@ -16,39 +16,44 @@
"""
import time
global clusterCount
+ global timeToPost
+ global runNum
+
clusterCount = 1
+ timeToPost = time.strftime("%Y-%m-%d %H:%M:%S")
+ runNum = time.strftime("%d%H%M%S")
cellName = main.params[ 'ENV' ][ 'cellName' ]
gitPull = main.params[ 'GIT' ][ 'autoPull' ]
checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
+ intentFilePath = main.params[ 'DB' ][ 'intentFilePath' ]
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
- ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
- ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
- ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
-
- main.ONOSbench.onosUninstall( nodeIp=ONOS1Ip )
- main.ONOSbench.onosUninstall( nodeIp=ONOS2Ip )
- main.ONOSbench.onosUninstall( nodeIp=ONOS3Ip )
- main.ONOSbench.onosUninstall( nodeIp=ONOS4Ip )
- main.ONOSbench.onosUninstall( nodeIp=ONOS5Ip )
- main.ONOSbench.onosUninstall( nodeIp=ONOS6Ip )
- main.ONOSbench.onosUninstall( nodeIp=ONOS7Ip )
+ ONOSIp = []
+ for i in range(1, 8):
+ ONOSIp.append(main.params[ 'CTRL' ][ 'ip'+str(i) ])
+ main.ONOSbench.onosUninstall( nodeIp = ONOSIp[i-1] )
MN1Ip = main.params[ 'MN' ][ 'ip1' ]
BENCHIp = main.params[ 'BENCH' ][ 'ip' ]
main.case( "Setting up test environment" )
+ main.step( "Clearing previous DB log file" )
+ fIntentLog = open(intentFilePath, 'w')
+ # Overwrite with empty line and close
+ fIntentLog.write('')
+ fIntentLog.close()
+
+ main.step( "Starting mininet topology" )
+ main.Mininet1.startNet()
+
main.step( "Creating cell file" )
cellFileResult = main.ONOSbench.createCellFile(
BENCHIp, cellName, MN1Ip,
- "onos-core,onos-app-metrics,onos-gui",
- ONOS1Ip )
+ ("onos-core,webconsole,onos-api,onos-app-metrics,onos-gui,"
+ "onos-cli,onos-openflow"),
+ ONOSIp[0] )
main.step( "Applying cell file to environment" )
cellApplyResult = main.ONOSbench.setCell( cellName )
@@ -79,21 +84,15 @@
packageResult = main.ONOSbench.onosPackage()
main.step( "Installing ONOS package" )
- install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip )
- #install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
- #install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
+ install1Result = main.ONOSbench.onosInstall( node=ONOSIp[0] )
main.step( "Set cell for ONOScli env" )
main.ONOS1cli.setCell( cellName )
- # main.ONOS2cli.setCell( cellName )
- # main.ONOS3cli.setCell( cellName )
time.sleep( 5 )
main.step( "Start onos cli" )
- cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip )
- #cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip )
- #cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip )
+ cli1 = main.ONOS1cli.startOnosCli( ONOSIp[0] )
utilities.assert_equals( expect=main.TRUE,
actual=cellFileResult and cellApplyResult and
@@ -376,6 +375,10 @@
ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
ONOSUser = main.params[ 'CTRL' ][ 'user' ]
+
+ ONOSIpList = []
+ for i in range( 1, 8 ):
+ ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
@@ -392,6 +395,51 @@
# NOTE: May need to configure interface depending on topology
intfs = main.params[ 'TEST' ][ 'intfs' ]
+
+ # Distribute switches according to cluster count
+ for i in range( 1, 9 ):
+ if clusterCount == 1:
+ main.Mininet1.assignSwController(
+ sw=str( i ), ip1=ONOSIpList[ 0 ],
+ port1=defaultSwPort
+ )
+ elif clusterCount == 3:
+ if i < 3:
+ index = 0
+ elif i < 6 and i >= 3:
+ index = 1
+ else:
+ index = 2
+ main.Mininet1.assignSwController(
+ sw=str( i ), ip1=ONOSIpList[ index ],
+ port1=defaultSwPort
+ )
+ elif clusterCount == 5:
+ if i < 3:
+ index = 0
+ elif i < 5 and i >= 3:
+ index = 1
+ elif i < 7 and i >= 5:
+ index = 2
+ elif i == 7:
+ index = 3
+ else:
+ index = 4
+ main.Mininet1.assignSwController(
+ sw=str( i ), ip1=ONOSIpList[ index ],
+ port1=defaultSwPort
+ )
+ elif clusterCount == 7:
+ if i < 6:
+ index = i
+ else:
+ index = 6
+ main.Mininet1.assignSwController(
+ sw=str( i ), ip1=ONOSIpList[ index ],
+ port1=defaultSwPort
+ )
+
+ time.sleep(10)
devicesJsonStr = main.ONOS1cli.devices()
devicesJsonObj = json.loads( devicesJsonStr )
@@ -419,14 +467,15 @@
intentsStr = main.ONOS1cli.intents( jsonFormat=True )
intentsObj = json.loads( intentsStr )
for intent in intentsObj:
+ main.log.info(intent)
if intent[ 'state' ] == "INSTALLED":
main.log.info( "Intent installed successfully" )
intentId = intent[ 'id' ]
main.log.info( "Intent id: " + str( intentId ) )
- else:
- # TODO: Add error handling
- main.log.info( "Intent installation failed" )
- intentId = ""
+ #else:
+ #TODO: Add error handling
+ #main.log.info( "Intent installation failed" )
+ #intentId = ""
main.log.info( "Disabling interface " + intfs )
t0System = time.time() * 1000
@@ -510,7 +559,7 @@
intentRerouteLat7 ) / clusterCount
main.log.info( "Intent reroute latency avg for iteration " +
- str( i ) + ": " + str( intentRerouteLatAvg ) )
+ str( i ) + ": " + str( intentRerouteLatAvg )+ " ms")
if intentRerouteLatAvg > 0.0 and \
intentRerouteLatAvg < 1000 and i > numIgnore:
@@ -556,6 +605,9 @@
def CASE4( self, main ):
"""
Batch intent install
+
+ Supports scale-out scenarios and increasing
+ number of intents within each iteration
"""
import time
import json
@@ -563,6 +615,7 @@
import os
import numpy
global clusterCount
+ global timeToPost
ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
@@ -593,6 +646,9 @@
nThread = main.params[ 'TEST' ][ 'numMult' ]
#nThread = 105
+ # DB operation variables
+ intentFilePath = main.params[ 'DB' ][ 'intentFilePath' ]
+
# Switch assignment NOTE: hardcoded
if clusterCount == 1:
for i in range( 1, numSwitch + 1 ):
@@ -670,17 +726,26 @@
for device in jsonObj:
deviceIdList.append( device[ 'id' ] )
+ # List of install / witdhraw latencies for each batch
batchInstallLat = []
batchWithdrawLat = []
- # Max intent install measurement of all nodes
- maxInstallLat = []
- maxWithdrawLat = []
sleepTime = 10
baseDir = "/tmp/"
+ # Batch size increase loop
for batch in range( 0, 5 ):
+ # Max intent install measurement of all nodes
+ # Resets after each batch calculation
+ maxInstallLat = []
+ maxWithdrawLat = []
+ # Max single intent install measurement of all nodes
+ # For example, if batch size is 1000, result latency
+ # will be divided by 1000
+ maxSingleInstallLat = []
+ maxSingleWithdrawLat = []
+ # Statistical gathering loop over number of iterations
for i in range( 0, int( numIter ) ):
main.log.info( "Pushing " +
str( int( batchIntentSize ) * int( nThread ) ) +
@@ -693,7 +758,7 @@
deviceIdList[ 7 ] + "/2",
batchIntentSize,
saveDir, ONOSIpList[ node - 1 ],
- numMult=nThread, appId=node )
+ numMult=nThread )
# Wait sufficient time for intents to start
# installing
@@ -721,17 +786,38 @@
with open( saveDir ) as fOnos:
lineCount = 0
for line in fOnos:
- line = line[ 1: ]
- line = line.split( ": " )
+ line_temp = ""
main.log.info( "Line read: " + str( line ) )
- result = line[ 1 ].split( " " )[ 0 ]
+ line_temp = line[ 1: ]
+ line_temp = line_temp.split( ": " )
+ #Prevent split method if line doesn't have
+ #space
+ if " " in str(line_temp):
+ result = line_temp[ 1 ].split( " " )[ 0 ]
+ else:
+ main.log.warn( "Empty line read" )
+ result = 0
# TODO: add parameters before appending latency
if lineCount == 0:
- batchInstallLat.append( int( result ) )
+ if "Failure" in str(line):
+ main.log.warn("Intent installation failed")
+ result = 'NA'
+ else:
+ main.log.info("Install result: "+result)
+ batchInstallLat.append( int( result ) )
installResult = result
elif lineCount == 1:
- batchWithdrawLat.append( int( result ) )
+ if "Failure" in str(line):
+ main.log.warn("Intent withdraw failed")
+ result = 'NA'
+ else:
+ main.log.info("Withdraw result: "+result)
+ batchWithdrawLat.append( int( result ) )
withdrawResult = result
+ else:
+ main.log.warn("Invalid results: excess lines")
+ installResult = 'NA'
+ withdrawResult = 'NA'
lineCount += 1
main.log.info( "Batch install latency for ONOS" +
str( node ) + " with " +
@@ -742,33 +828,72 @@
str( batchIntentSize ) + "intents: " +
str( withdrawResult ) + " ms" )
+ main.log.info( "Single intent install latency ONOS" +
+ str( node ) + " with " +
+ str( batchIntentSize ) + "intents: " +
+ str( float(installResult) /\
+ int(batchIntentSize) ) + " ms" )
+ main.log.info( "Single intent withdraw latency ONOS" +
+ str( node ) + " with " +
+ str( batchIntentSize ) + "intents: " +
+ str( float(withdrawResult) /\
+ int(batchIntentSize) ) + " ms" )
+
+ #NOTE: END node loop
+
if len( batchInstallLat ) > 0 and int( i ) > numIgnore:
maxInstallLat.append( max( batchInstallLat ) )
+ maxSingleInstallLat.append(
+ max( batchInstallLat ) / int( batchIntentSize )
+ )
elif len( batchInstallLat ) == 0:
# If I failed to read anything from the file,
# increase the wait time before checking intents
sleepTime += 30
if len( batchWithdrawLat ) > 0 and int( i ) > numIgnore:
maxWithdrawLat.append( max( batchWithdrawLat ) )
+ maxSingleWithdrawLat.append(
+ max( batchWithdrawLat ) / int( batchIntentSize )
+ )
batchInstallLat = []
batchWithdrawLat = []
# Sleep in between iterations
time.sleep( 5 )
+ #NOTE: END iteration loop
+
if maxInstallLat:
- avgInstallLat = str( sum( maxInstallLat ) /
- len( maxInstallLat ) )
+ avgInstallLat = str( round( numpy.average(maxInstallLat)
+ , 2 ))
+ stdInstallLat = str( round(
+ numpy.std(maxInstallLat), 2))
+ avgSingleInstallLat = str( round(
+ numpy.average(maxSingleInstallLat)
+ , 3 ))
+ stdSingleInstallLat = str( round(
+ numpy.std(maxSingleInstallLat),
+ 3 ))
else:
avgInstallLat = "NA"
+ stdInstallLat = "NA"
main.log.report( "Batch installation failed" )
assertion = main.FALSE
if maxWithdrawLat:
- avgWithdrawLat = str( sum( maxWithdrawLat ) /
- len( maxWithdrawLat ) )
+ avgWithdrawLat = str( round( numpy.average(maxWithdrawLat)
+ , 2 ))
+ stdWithdrawLat = str( round(
+ numpy.std(maxWithdrawLat), 2))
+ avgSingleWithdrawLat = str( round(
+ numpy.average(maxSingleWithdrawLat)
+ , 3 ))
+ stdSingleWithdrawLat = str( round(
+ numpy.std(maxSingleWithdrawLat),
+ 3 ))
else:
avgWithdrawLat = "NA"
+ stdWithdrawLat = "NA"
main.log.report( "Batch withdraw failed" )
assertion = main.FALSE
@@ -776,20 +901,56 @@
"of size " + str( batchIntentSize ) + ": " +
str( avgInstallLat ) + " ms" )
main.log.report( "Std Deviation of batch installation latency " +
- ": " + str( numpy.std( maxInstallLat ) ) + " ms" )
+ ": " +
+ str( stdInstallLat ) + " ms" )
+ main.log.report( "Avg of single installation latency " +
+ "of size " + str( batchIntentSize ) + ": " +
+ str( avgSingleInstallLat ) + " ms" )
+ main.log.report( "Std Deviation of single installation latency " +
+ ": " +
+ str( stdSingleInstallLat ) + " ms" )
main.log.report( "Avg of batch withdraw latency " +
"of size " + str( batchIntentSize ) + ": " +
str( avgWithdrawLat ) + " ms" )
main.log.report( "Std Deviation of batch withdraw latency " +
": " +
- str( numpy.std( maxWithdrawLat ) ) +
- " ms" )
+ str( stdWithdrawLat ) + " ms" )
+ main.log.report( "Avg of single withdraw latency " +
+ "of size " + str( batchIntentSize ) + ": " +
+ str( avgSingleWithdrawLat ) + " ms" )
+ main.log.report( "Std Deviation of single withdraw latency " +
+ ": " +
+ str( stdSingleWithdrawLat ) + " ms" )
- batchIntentSize = batchIntentSize + 1000
- main.log.report( "Increasing batch intent size to " +
+ dbCmd = (
+ "INSERT INTO intents_latency_tests VALUES("
+ "'"+timeToPost+"','intents_latency_results',"
+ ""+runNum+","+str(clusterCount)+","+str(batchIntentSize)+","
+ ""+str(avgInstallLat)+","+str(stdInstallLat)+","
+ ""+str(avgWithdrawLat)+","+str(stdWithdrawLat)+");"
+ )
+
+ # Write result to file (which is posted to DB by jenkins)
+ fResult = open(intentFilePath, 'a')
+ if dbCmd:
+ fResult.write(dbCmd+"\n")
+ fResult.close()
+
+ if batch == 0:
+ batchIntentSize = 10
+ elif batch == 1:
+ batchIntentSize = 100
+ elif batch == 2:
+ batchIntentSize = 1000
+ elif batch == 3:
+ batchIntentSize = 2000
+ if batch < 4:
+ main.log.report( "Increasing batch intent size to " +
str(batchIntentSize) )
+ #NOTE: END batch loop
+
#main.log.info( "Removing all intents for next test case" )
#jsonTemp = main.ONOS1cli.intents( jsonFormat=True )
#jsonObjIntents = json.loads( jsonTemp )
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.topo b/TestON/tests/IntentPerfNext/IntentPerfNext.topo
index 9de0291..5575237 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.topo
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.topo
@@ -24,7 +24,7 @@
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>3</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS2cli>
@@ -33,7 +33,7 @@
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>4</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS3cli>
@@ -42,7 +42,7 @@
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>5</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS4cli>
@@ -51,7 +51,7 @@
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>6</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS5cli>
@@ -60,7 +60,7 @@
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>7</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS6cli>
@@ -69,7 +69,7 @@
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>8</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS7cli>
@@ -78,7 +78,7 @@
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
- <connect_order>3</connect_order>
+ <connect_order>9</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS1>
@@ -87,7 +87,7 @@
<user>admin</user>
<password>onos_test</password>
<type>MininetCliDriver</type>
- <connect_order>4</connect_order>
+ <connect_order>10</connect_order>
<COMPONENTS>
<arg1> --custom topo-intent-8sw.py </arg1>
<arg2> --arp --mac --topo mytopo </arg2>
@@ -101,7 +101,7 @@
<user>admin</user>
<password>onos_test</password>
<type>RemoteMininetDriver</type>
- <connect_order>5</connect_order>
+ <connect_order>11</connect_order>
<COMPONENTS> </COMPONENTS>
</Mininet2>
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/IntentPerfNext/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/IntentPerfNext/__init__.py
diff --git a/TestON/tests/IntentPerfNextBM/IntentPerfNextBM.params b/TestON/tests/IntentPerfNextBM/IntentPerfNextBM.params
new file mode 100644
index 0000000..f01f017
--- /dev/null
+++ b/TestON/tests/IntentPerfNextBM/IntentPerfNextBM.params
@@ -0,0 +1,67 @@
+<PARAMS>
+ <testcases>1,2,4,2,4,2,4,2</testcases>
+
+ <ENV>
+ <cellName>intent_perf_test</cellName>
+ </ENV>
+
+ <GIT>
+ #autoPull 'on' or 'off'
+ <autoPull>off</autoPull>
+ <checkout>master</checkout>
+ </GIT>
+
+ <CTRL>
+ <user>sdn</user>
+ <ip1>10.254.1.201</ip1>
+ <port1>6633</port1>
+ <ip2>10.254.1.202</ip2>
+ <port2>6633</port2>
+ <ip3>10.254.1.203</ip3>
+ <port3>6633</port3>
+ <ip4>10.254.1.204</ip4>
+ <ip5>10.254.1.205</ip5>
+ <ip6>10.254.1.206</ip6>
+ <ip7>10.254.1.207</ip7>
+ </CTRL>
+
+ <TSHARK>
+ <ofpPortStatus>OF 1.3 146</ofpPortStatus>
+ </TSHARK>
+
+ <MN>
+ <ip1>10.254.1.200</ip1>
+ <ip2>10.254.1.200</ip2>
+ </MN>
+
+ <BENCH>
+ <ip>10.254.1.200</ip>
+ </BENCH>
+
+ <TEST>
+ #Number of times to iterate each case
+ <numIter>8</numIter>
+ <numIgnore>2</numIgnore>
+ <numSwitch>8</numSwitch>
+ <batchThresholdMin>0</batchThresholdMin>
+ <batchThresholdMax>1000</batchThresholdMax>
+ <batchIntentSize>1</batchIntentSize>
+ <numMult>1</numMult>
+ #Interface to bring down for intent reroute case
+ <intfs>s3-eth2</intfs>
+ <cellStr>webconsole,onos-core,onos-api,onos-app-metrics,onos-app-gui,onos-cli,onos-openflow</cellStr>
+ </TEST>
+
+ <DB>
+ <intentFilePath>
+ /home/admin/ONLabTest/TestON/tests/IntentPerfNextBM/intentLatencyResultDb.log
+ </intentFilePath>
+ </DB>
+
+ <JSON>
+ <submittedTime>intentSubmittedTimestamp</submittedTime>
+ <installedTime>intentInstalledTimestamp</installedTime>
+ <wdRequestTime>intentWithdrawRequestedTimestamp</wdRequestTime>
+ <withdrawnTime>intentWithdrawnTimestamp</withdrawnTime>
+ </JSON>
+</PARAMS>
diff --git a/TestON/tests/IntentPerfNextBM/IntentPerfNextBM.py b/TestON/tests/IntentPerfNextBM/IntentPerfNextBM.py
new file mode 100644
index 0000000..32477a6
--- /dev/null
+++ b/TestON/tests/IntentPerfNextBM/IntentPerfNextBM.py
@@ -0,0 +1,746 @@
+# 2015.03.12 10:28:21 PDT
+#Embedded file name: ../tests/IntentPerfNextBM/IntentPerfNextBM.py
+
+
+class IntentPerfNextBM:
+
+ def __init__(self):
+ self.default = ''
+
+ def CASE1(self, main):
+ """
+ ONOS startup sequence
+ """
+ global clusterCount
+ global timeToPost
+ global runNum
+ import time
+
+ clusterCount = 1
+ timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
+ runNum = time.strftime('%d%H%M%S')
+ cellName = main.params['ENV']['cellName']
+ gitPull = main.params['GIT']['autoPull']
+ checkoutBranch = main.params['GIT']['checkout']
+ intentFilePath = main.params['DB']['intentFilePath']
+ cellStr = main.params[ 'TEST' ][ 'cellStr' ]
+ ONOSIp = []
+
+ for i in range(1, 8):
+ ONOSIp.append(main.params['CTRL']['ip' + str(i)])
+ main.ONOSbench.onosUninstall(nodeIp=ONOSIp[i - 1])
+
+ MN1Ip = main.params['MN']['ip1']
+ BENCHIp = main.params['BENCH']['ip']
+ main.case('Setting up test environment')
+ main.step('Clearing previous DB log file')
+ fIntentLog = open(intentFilePath, 'w')
+ fIntentLog.write('')
+ fIntentLog.close()
+ main.step('Starting mininet topology')
+ main.Mininet1.startNet()
+ main.step('Creating cell file')
+ cellFileResult = main.ONOSbench.createCellFile(
+ BENCHIp, cellName, MN1Ip, cellStr, ONOSIp[0])
+ main.step('Applying cell file to environment')
+ cellApplyResult = main.ONOSbench.setCell(cellName)
+ verifyCellResult = main.ONOSbench.verifyCell()
+ main.step('Removing raft logs')
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.step('Git checkout and pull ' + checkoutBranch)
+
+ if gitPull == 'on':
+ checkoutResult = main.ONOSbench.gitCheckout(checkoutBranch)
+ pullResult = main.ONOSbench.gitPull()
+ main.step('Using onos-build to compile ONOS')
+ buildResult = main.ONOSbench.onosBuild()
+ else:
+ checkoutResult = main.TRUE
+ pullResult = main.TRUE
+ buildResult = main.TRUE
+ main.log.info('Git pull skipped by configuration')
+
+ main.log.report('Commit information - ')
+ main.ONOSbench.getVersion(report=True)
+ main.step('Creating ONOS package')
+ packageResult = main.ONOSbench.onosPackage()
+ main.step('Installing ONOS package')
+ install1Result = main.ONOSbench.onosInstall(node=ONOSIp[0])
+ main.step('Set cell for ONOScli env')
+ main.ONOS1cli.setCell(cellName)
+ time.sleep(5)
+ main.step('Start onos cli')
+ cli1 = main.ONOS1cli.startOnosCli(ONOSIp[0])
+ utilities.assert_equals(expect=main.TRUE,
+ actual=cellFileResult and cellApplyResult and\
+ verifyCellResult and checkoutResult and\
+ pullResult and buildResult and install1Result,
+ onpass='ONOS started successfully',
+ onfail='Failed to start ONOS')
+
+ def CASE2(self, main):
+ """
+ Batch intent install
+
+ Supports scale-out scenarios and increasing
+ number of intents within each iteration
+ """
+ import time
+ import json
+ import requests
+ import os
+ import numpy
+ ONOS1Ip = main.params['CTRL']['ip1']
+ ONOS2Ip = main.params['CTRL']['ip2']
+ ONOS3Ip = main.params['CTRL']['ip3']
+ ONOS4Ip = main.params['CTRL']['ip4']
+ ONOS5Ip = main.params['CTRL']['ip5']
+ ONOS6Ip = main.params['CTRL']['ip6']
+ ONOS7Ip = main.params['CTRL']['ip7']
+ assertion = main.TRUE
+ ONOSIpList = []
+
+ for i in range(1, 8):
+ ONOSIpList.append(main.params['CTRL']['ip' + str(i)])
+
+ ONOSUser = main.params['CTRL']['user']
+ defaultSwPort = main.params['CTRL']['port1']
+ batchIntentSize = int(main.params['TEST']['batchIntentSize'])
+ batchThreshMin = int(main.params['TEST']['batchThresholdMin'])
+ batchThreshMax = int(main.params['TEST']['batchThresholdMax'])
+ numIter = main.params['TEST']['numIter']
+ numIgnore = int(main.params['TEST']['numIgnore'])
+ numSwitch = int(main.params['TEST']['numSwitch'])
+ nThread = main.params['TEST']['numMult']
+ intentFilePath = main.params['DB']['intentFilePath']
+
+ if clusterCount == 1:
+ for i in range(1, numSwitch + 1):
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOS1Ip, port1=defaultSwPort)
+ if clusterCount == 3:
+ for i in range(1, 3):
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOS1Ip, port1=defaultSwPort)
+ for i in range(3, 6):
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOS2Ip, port1=defaultSwPort)
+ for i in range(6, 9):
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOS3Ip, port1=defaultSwPort)
+ if clusterCount == 5:
+ main.Mininet1.assignSwController(sw='1',
+ ip1=ONOS1Ip, port1=defaultSwPort)
+ main.Mininet1.assignSwController(sw='2',
+ ip1=ONOS2Ip, port1=defaultSwPort)
+ for i in range(3, 6):
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOS3Ip, port1=defaultSwPort)
+ main.Mininet1.assignSwController(sw='6',
+ ip1=ONOS4Ip, port1=defaultSwPort)
+ main.Mininet1.assignSwController(sw='7',
+ ip1=ONOS5Ip, port1=defaultSwPort)
+ main.Mininet1.assignSwController(sw='8',
+ ip1=ONOS5Ip, port1=defaultSwPort)
+ if clusterCount == 7:
+ for i in range(1, 9):
+ if i < 8:
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOSIpList[i - 1], port1=defaultSwPort)
+ elif i >= 8:
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOSIpList[6], port1=defaultSwPort)
+
+ time.sleep(20)
+
+ deviceIdList = []
+ batchInstallLat = []
+ batchWithdrawLat = []
+
+ main.log.report('Batch intent installation test of ' +
+ str(batchIntentSize) + ' intent(s)')
+ main.log.info('Getting list of available devices')
+
+ jsonStr = main.ONOS1cli.devices()
+ jsonObj = json.loads(jsonStr)
+ for device in jsonObj:
+ deviceIdList.append(device['id'])
+
+ if not jsonObj:
+ main.log.warn( "Devices not found, check topology" )
+
+ sleepTime = 10
+ baseDir = '/tmp/'
+ for batch in range(0, 5):
+ maxInstallLat = []
+ maxWithdrawLat = []
+ maxSingleInstallLat = []
+ maxSingleWithdrawLat = []
+ for i in range(0, int(numIter)):
+ main.log.info('Pushing ' + str(
+ int(batchIntentSize) * int(nThread)) +
+ ' intents. Iteration ' + str(i))
+ saveDir = baseDir + 'batch_intent_1.txt'
+ main.ONOSbench.pushTestIntentsShell(deviceIdList[0] +
+ '/2', deviceIdList[7] + '/2', batchIntentSize,
+ saveDir, ONOSIpList[0], numMult=nThread)
+ time.sleep(sleepTime)
+ intent = ''
+ counter = 300
+ while len(intent) > 0 and counter > 0:
+ main.ONOS1cli.handle.sendline('intents | wc -l')
+ main.ONOS1cli.handle.expect('intents | wc -l')
+ main.ONOS1cli.handle.expect('onos>')
+ intentTemp = main.ONOS1cli.handle.before()
+ intent = main.ONOS1cli.intents()
+ intent = json.loads(intent)
+ counter = counter - 1
+ time.sleep(1)
+
+ time.sleep(5)
+ saveDir = baseDir + 'batch_intent_1.txt'
+ with open(saveDir) as fOnos:
+ lineCount = 0
+ for line in fOnos:
+ line_temp = ''
+ main.log.info('Line read: ' + str(line))
+ line_temp = line[1:]
+ line_temp = line_temp.split(': ')
+ if ' ' in str(line_temp):
+ result = line_temp[1].split(' ')[0]
+ else:
+ main.log.warn('Empty line read')
+ result = 0
+ if lineCount == 0:
+ if 'Failure' in str(line):
+ main.log.warn('Intent installation failed')
+ result = 'NA'
+ else:
+ main.log.info('Install result: ' + result)
+ batchInstallLat.append(int(result))
+ installResult = result
+ elif lineCount == 1:
+ if 'Failure' in str(line):
+ main.log.warn('Intent withdraw failed')
+ result = 'NA'
+ else:
+ main.log.info('Withdraw result: ' + result)
+ batchWithdrawLat.append(int(result))
+ withdrawResult = result
+ else:
+ main.log.warn('Invalid results')
+ installResult = 'NA'
+ withdrawResult = 'NA'
+ lineCount += 1
+
+ main.log.info('Batch install latency with' +
+ str(batchIntentSize) + 'intents: ' +
+ str(installResult) + ' ms')
+ main.log.info('Batch withdraw latency with' +
+ str(batchIntentSize) + 'intents: ' +
+ str(withdrawResult) + ' ms')
+ main.log.info('Single intent install latency with' +
+ str(batchIntentSize) + 'intents: ' +
+ str(float(installResult) / int(batchIntentSize))+' ms')
+ main.log.info('Single intent withdraw latency with' +
+ str(batchIntentSize) + 'intents: ' +
+ str(float(withdrawResult)/ int(batchIntentSize))+' ms')
+ if len(batchInstallLat) > 0 and int(i) > numIgnore:
+ maxInstallLat.append(max(batchInstallLat))
+ maxSingleInstallLat.append(
+ max(batchInstallLat) / int(batchIntentSize))
+ elif len(batchInstallLat) == 0:
+ sleepTime += 30
+ if len(batchWithdrawLat) > 0 and int(i) > numIgnore:
+ maxWithdrawLat.append(max(batchWithdrawLat))
+ maxSingleWithdrawLat.append(
+ max(batchWithdrawLat) / int(batchIntentSize))
+ batchInstallLat = []
+ batchWithdrawLat = []
+ time.sleep(5)
+
+ if maxInstallLat:
+ avgInstallLat = str(round(
+ numpy.average(maxInstallLat), 2))
+ stdInstallLat = str(round(
+ numpy.std(maxInstallLat), 2))
+ avgSingleInstallLat = str(round(
+ numpy.average(maxSingleInstallLat), 3))
+ stdSingleInstallLat = str(round(
+ numpy.std(maxSingleInstallLat), 3))
+ else:
+ avgInstallLat = 'NA'
+ stdInstallLat = 'NA'
+ main.log.report('Batch installation failed')
+ assertion = main.FALSE
+ if maxWithdrawLat:
+ avgWithdrawLat = str(round(
+ numpy.average(maxWithdrawLat), 2))
+ stdWithdrawLat = str(round(
+ numpy.std(maxWithdrawLat), 2))
+ avgSingleWithdrawLat = str(round(
+ numpy.average(maxSingleWithdrawLat), 3))
+ stdSingleWithdrawLat = str(round(
+ numpy.std(maxSingleWithdrawLat), 3))
+ else:
+ avgWithdrawLat = 'NA'
+ stdWithdrawLat = 'NA'
+ main.log.report('Batch withdraw failed')
+ assertion = main.FALSE
+
+ main.log.report('Avg of batch installation latency ' +
+ 'of size ' + str(batchIntentSize) + ': ' +
+ str(avgInstallLat) + ' ms')
+ main.log.report('Std Deviation of batch installation latency ' +
+ ': ' + str(round(numpy.std(maxInstallLat), 2)) + ' ms')
+ main.log.report('Avg of batch withdraw latency ' +
+ 'of size ' + str(batchIntentSize) + ': ' +
+ str(avgWithdrawLat) + ' ms')
+ main.log.report('Std Deviation of batch withdraw latency ' +
+ ': ' + str(round(numpy.std(maxWithdrawLat), 2)) + ' ms')
+
+ main.log.report('Avg of batch withdraw latency ' + 'of size ' +
+ str(batchIntentSize) + ': ' + str(avgWithdrawLat) + ' ms')
+ main.log.report('Std Deviation of batch withdraw latency ' +
+ ': ' + str(stdWithdrawLat) + ' ms')
+ main.log.report('Avg of single withdraw latency ' + 'of size ' +
+ str(batchIntentSize) + ': ' +
+ str(avgSingleWithdrawLat) + ' ms')
+ main.log.report('Std Deviation of single withdraw latency ' +
+ ': ' + str(stdSingleWithdrawLat) + ' ms')
+
+ dbCmd = "INSERT INTO intents_latency_tests VALUES('" +\
+ timeToPost + "','intents_latency_results'," +\
+ runNum + ',' + str(clusterCount) + ',' +\
+ str(batchIntentSize) + ',' + str(avgInstallLat) +\
+ ',' + str(stdInstallLat) + ',' + str(avgWithdrawLat) +\
+ ',' + str(stdWithdrawLat) + ');'
+
+ fResult = open(intentFilePath, 'a')
+ if dbCmd:
+ fResult.write(dbCmd + '\n')
+ fResult.close()
+ if batch == 0:
+ batchIntentSize = 10
+ elif batch == 1:
+ batchIntentSize = 100
+ elif batch == 2:
+ batchIntentSize = 1000
+ elif batch == 3:
+ batchIntentSize = 1500
+ if batch < 4:
+ main.log.report('Increasing batch intent size to ' +
+ str(batchIntentSize))
+
+ utilities.assert_equals(expect=main.TRUE, actual=assertion,
+ onpass='Batch intent install/withdraw test successful',
+ onfail='Batch intent install/withdraw test failed')
+
+ def CASE3(self, main):
+ """
+ Batch intent reroute latency
+ """
+ import time
+ import json
+ import requests
+ import os
+ import numpy
+
+ ONOS1Ip = main.params['CTRL']['ip1']
+ ONOS2Ip = main.params['CTRL']['ip2']
+ ONOS3Ip = main.params['CTRL']['ip3']
+ ONOS4Ip = main.params['CTRL']['ip4']
+ ONOS5Ip = main.params['CTRL']['ip5']
+ ONOS6Ip = main.params['CTRL']['ip6']
+ ONOS7Ip = main.params['CTRL']['ip7']
+
+ ONOSIpList = []
+ for i in range(1, 8):
+ ONOSIpList.append(main.params['CTRL']['ip' + str(i)])
+
+ ONOSUser = main.params['CTRL']['user']
+ defaultSwPort = main.params['CTRL']['port1']
+ batchIntentSize = main.params['TEST']['batchIntentSize']
+ thresholdMin = int(main.params['TEST']['batchThresholdMin'])
+ thresholdMax = int(main.params['TEST']['batchThresholdMax'])
+
+ intfs = main.params['TEST']['intfs']
+ installTime = main.params['JSON']['installedTime']
+ numIter = main.params['TEST']['numIter']
+ numIgnore = int(main.params['TEST']['numIgnore'])
+ numSwitch = int(main.params['TEST']['numSwitch'])
+ nThread = main.params['TEST']['numMult']
+
+ tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
+ tsharkPortDown = '/tmp/tshark_port_down_reroute.txt'
+
+ if clusterCount == 1:
+ for i in range(1, numSwitch + 1):
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOS1Ip, port1=defaultSwPort)
+ if clusterCount == 3:
+ for i in range(1, 3):
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOS1Ip, port1=defaultSwPort)
+ for i in range(3, 6):
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOS2Ip, port1=defaultSwPort)
+ for i in range(6, 9):
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOS3Ip, port1=defaultSwPort)
+ if clusterCount == 5:
+ main.Mininet1.assignSwController(sw='1',
+ ip1=ONOS1Ip, port1=defaultSwPort)
+ main.Mininet1.assignSwController(sw='2',
+ ip1=ONOS2Ip, port1=defaultSwPort)
+ for i in range(3, 6):
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOS3Ip, port1=defaultSwPort)
+ main.Mininet1.assignSwController(sw='6',
+ ip1=ONOS4Ip, port1=defaultSwPort)
+ main.Mininet1.assignSwController(sw='7',
+ ip1=ONOS5Ip, port1=defaultSwPort)
+ main.Mininet1.assignSwController(sw='8',
+ ip1=ONOS5Ip, port1=defaultSwPort)
+ if clusterCount == 7:
+ for i in range(1, 9):
+ if i < 8:
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOSIpList[i - 1], port1=defaultSwPort)
+ elif i >= 8:
+ main.Mininet1.assignSwController(sw=str(i),
+ ip1=ONOSIpList[6], port1=defaultSwPort)
+
+ main.log.report('Batch intent reroute test ')
+
+ batchIntentRerouteAvgSystem = numpy.zeros((
+ clusterCount, int(numIter)))
+ batchIntentRerouteStdSystem = numpy.zeros((
+ clusterCount, int(numIter)))
+ batchIntentRerouteAvgPort = numpy.zeros((
+ clusterCount, int(numIter)))
+ batchIntentRerouteStdSystem = numpy.zeros((
+ clusterCount, int(numIter)))
+
+ time.sleep(10)
+
+ main.log.info('Getting list of available devices')
+
+ deviceIdList = []
+ jsonStr = main.ONOS1cli.devices()
+ jsonObj = json.loads(jsonStr)
+ for device in jsonObj:
+ deviceIdList.append(device['id'])
+ if not jsonObj:
+ main.log.warn('No devices have been discovered')
+ assertion = main.FALSE
+
+ sleepTime = 10
+
+ baseDir = '/tmp/'
+ for batch in range(0, 5):
+ maxRerouteLatSystem = []
+ maxRerouteLatPort = []
+ for i in range(0, int(numIter)):
+ rerouteLatSystem = []
+ rerouteLatPort = []
+ main.log.info('Pushing ' + str(
+ int(batchIntentSize) * int(nThread)) +
+ ' intents. Iteration ' + str(i))
+ main.ONOSbench.pushTestIntentsShell(
+ deviceIdList[0] + '/2', deviceIdList[7] +
+ '/2', batchIntentSize, '/tmp/batch_install.txt',
+ ONOSIpList[0], numMult='1', report=False,
+ options='-i')
+
+ time.sleep(10)
+
+ main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown)
+ main.log.info('Disabling interface ' + intfs)
+ main.Mininet1.handle.sendline(
+ 'sh ifconfig ' + intfs + ' down')
+ t0System = time.time() * 1000
+
+ time.sleep(3)
+
+ main.ONOS1.tsharkStop()
+
+ time.sleep(2)
+
+ os.system('scp ' + ONOSUser + '@' + ONOSIpList[0] +
+ ':' + tsharkPortDown + ' /tmp/')
+ time.sleep(5)
+
+ fPortDown = open(tsharkPortDown, 'r')
+ fLine = fPortDown.readline()
+ objDown = fLine.split(' ')
+ if len(fLine) > 0:
+ timestampBeginPtDown = int(float(objDown[1]) * 1000)
+ if timestampBeginPtDown < 1400000000000:
+ timestampBeginPtDown = int(float(objDown[2]) * 1000)
+ main.log.info('Port down begin timestamp: ' +
+ str(timestampBeginPtDown))
+ else:
+ main.log.info('Tshark output file returned unexpected' +
+ ' results: ' + str(fLine))
+ fPortDown.close()
+
+ intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
+ intentsJsonObj1 = json.loads(intentsJsonStr1)
+ intentInstall1 = intentsJsonObj1[installTime]['value']
+ intentRerouteLat1 = int(intentInstall1) - int(t0System)
+ intentRerouteLatPort1 =\
+ int(intentInstall1) - int(timestampBeginPtDown)
+
+ if intentRerouteLat1 > thresholdMin and \
+ intentRerouteLat1 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatSystem.append(intentRerouteLat1)
+ main.log.info('ONOS1 Intent Reroute Lat ' +
+ ' size: ' + str(batchIntentSize) +
+ ' system-to-install: ' +
+ str(intentRerouteLat1) + ' ms')
+ if intentRerouteLatPort1 > thresholdMin and\
+ intentRerouteLatPort1 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatPort.append(intentRerouteLatPort1)
+
+ main.log.info('ONOS1 Intent Reroute Lat ' +
+ ' size: ' + str(batchIntentSize) +
+ ' system-to-install: ' +
+ str(intentRerouteLatPort1) + ' ms')
+
+ if clusterCount == 3:
+ intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
+ intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
+ intentsJsonObj2 = json.loads(intentsJsonStr2)
+ intentsJsonObj3 = json.loads(intentsJsonStr3)
+ intentInstall2 = intentsJsonObj2[installTime]['value']
+ intentInstall3 = intentsJsonObj3[installTime]['value']
+ intentRerouteLat2 = int(intentInstall2) - int(t0System)
+ intentRerouteLat3 = int(intentInstall3) - int(t0System)
+ intentRerouteLatPort2 = int(intentInstall2) - int(timestampBeginPtDown)
+ intentRerouteLatPort3 = int(intentInstall3) - int(timestampBeginPtDown)
+
+ if intentRerouteLat2 > thresholdMin and\
+ intentRerouteLat2 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatSystem.append(intentRerouteLat2)
+ main.log.info('ONOS2 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' system-to-install: ' + str(intentRerouteLat2) + ' ms')
+ if intentRerouteLat3 > thresholdMin and\
+ intentRerouteLat3 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatSystem.append(intentRerouteLat3)
+ main.log.info('ONOS3 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' system-to-install: ' + str(intentRerouteLat3) +
+ ' ms')
+ if intentRerouteLatPort2 > thresholdMin and\
+ intentRerouteLatPort2 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatPort.append(intentRerouteLatPort2)
+ main.log.info('ONOS2 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' port-to-install: ' +
+ str(intentRerouteLatPort2) + ' ms')
+ if intentRerouteLatPort3 > thresholdMin and\
+ intentRerouteLatPort3 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatPort.append(intentRerouteLatPort3)
+ main.log.info('ONOS3 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' port-to-install: ' +
+ str(intentRerouteLatPort2) + ' ms')
+
+ if clusterCount == 5:
+ intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
+ intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
+ intentsJsonObj4 = json.loads(intentsJsonStr4)
+ intentsJsonObj5 = json.loads(intentsJsonStr5)
+ intentInstall4 = intentsJsonObj4[installTime]['value']
+ intentInstall5 = intentsJsonObj5[installTime]['value']
+ intentRerouteLat4 = int(intentInstall4) - int(t0System)
+ intentRerouteLat5 = int(intentInstall5) - int(t0System)
+ intentRerouteLatPort4 =\
+ int(intentInstall4) - int(timestampBeginPtDown)
+ intentRerouteLatPort5 =\
+ int(intentInstall5) - int(timestampBeginPtDown)
+ if intentRerouteLat4 > thresholdMin and\
+ intentRerouteLat4 < thresholdMax and \
+ i > numIgnore:
+ rerouteLatSystem.append(intentRerouteLat4)
+ main.log.info('ONOS4 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' system-to-install: ' + str(intentRerouteLat4) +
+ ' ms')
+ if intentRerouteLat5 > thresholdMin and\
+ intentRerouteLat5 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatSystem.append(intentRerouteLat5)
+ main.log.info('ONOS5 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' system-to-install: ' +
+ str(intentRerouteLat5) + ' ms')
+ if intentRerouteLatPort4 > thresholdMin and\
+ intentRerouteLatPort4 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatPort.append(intentRerouteLatPort4)
+ main.log.info('ONOS4 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' port-to-install: ' +
+ str(intentRerouteLatPort4) + ' ms')
+ if intentRerouteLatPort5 > thresholdMin and\
+ intentRerouteLatPort5 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatPort.append(intentRerouteLatPort5)
+ main.log.info('ONOS5 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' port-to-install: ' +
+ str(intentRerouteLatPort5) + ' ms')
+
+ if clusterCount == 7:
+ intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
+ intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
+ intentsJsonObj6 = json.loads(intentsJsonStr6)
+ intentsJsonObj7 = json.loads(intentsJsonStr7)
+ intentInstall6 = intentsJsonObj6[installTime]['value']
+ intentInstall7 = intentsJsonObj7[installTime]['value']
+ intentRerouteLat6 = int(intentInstall6) - int(t0System)
+ intentRerouteLat7 = int(intentInstall7) - int(t0System)
+ intentRerouteLatPort4 =\
+ int(intentInstall4) - int(timestampBeginPtDown)
+ intentRerouteLatPort5 =\
+ int(intentInstall5) - int(timestampBeginPtDown)
+ if intentRerouteLat6 > thresholdMin and\
+ intentRerouteLat6 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatSystem.append(intentRerouteLat6)
+ main.log.info('ONOS6 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' system-to-install: ' +
+ str(intentRerouteLat6) + ' ms')
+ if intentRerouteLat7 > thresholdMin and\
+ intentRerouteLat7 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatSystem.append(intentRerouteLat7)
+ main.log.info('ONOS7 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' system-to-install: ' +
+ str(intentRerouteLat7) + ' ms')
+ if intentRerouteLatPort6 > thresholdMin and\
+ intentRerouteLatPort6 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatPort.append(intentRerouteLatPort6)
+ main.log.info('ONOS6 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' port-to-install: ' +
+ str(intentRerouteLatPort6) + ' ms')
+ if intentRerouteLatPort7 > thresholdMin and\
+ intentRerouteLatPort7 < thresholdMax and\
+ i > numIgnore:
+ rerouteLatPort.append(intentRerouteLatPort7)
+ main.log.info('ONOS7 Intent Reroute Lat' +
+ ' size: ' + str(batchIntentSize) +
+ ' port-to-install: ' +
+ str(intentRerouteLatPort7) + ' ms')
+
+ time.sleep(5)
+
+ main.log.info('System: ' + str(rerouteLatSystem))
+ main.log.info('Port: ' + str(rerouteLatPort))
+ if rerouteLatSystem:
+ maxRerouteLatSystem = max(rerouteLatSystem)
+ main.log.info('Max system: ' + str(maxRerouteLatSystem))
+ if rerouteLatPort:
+ maxRerouteLatPort = max(rerouteLatPort)
+ main.log.info('Max port: ' + str(maxRerouteLatPort))
+
+ # Bring port back up for next iteration
+ main.Mininet1.handle.sendline('sh ifconfig ' + intfs + ' up')
+ time.sleep(5)
+
+ # Use 'withdraw' option to withdraw batch intents
+ main.ONOSbench.pushTestIntentsShell(
+ deviceIdList[0] + '/2', deviceIdList[7] + '/2',
+ batchIntentSize, '/tmp/batch_install.txt',
+ ONOSIpList[0], numMult='1', report=False, options='-w')
+ main.log.info('Intents removed and port back up')
+
+ # NOTE: End iteration loop
+ if batch == 1:
+ batchIntentSize = 10
+ elif batch == 2:
+ batchIntentSize = 100
+ elif batch == 3:
+ batchIntentSize = 500
+ elif batch == 4:
+ batchIntentSize = 1000
+ main.log.info('Batch intent size increased to ' + str(batchIntentSize))
+
+ def CASE4(self, main):
+ """
+ Increase number of nodes and initiate CLI
+ """
+ global clusterCount
+ import time
+ import json
+
+ clusterCount += 2
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ features = main.params[ 'TEST' ][ 'cellStr' ]
+ benchIp = main.params[ 'BENCH' ][ 'ip' ]
+ mininetIp = main.params[ 'MN' ][ 'ip1' ]
+
+ main.log.report('Increasing cluster size to ' + str(clusterCount))
+
+ ONOSIp = []
+ for i in range( 1, 8 ):
+ ONOSIp.append( main.params[ 'CTRL' ][ 'ip'+str(i) ] )
+
+ main.step( "Cleaning environment" )
+ for i in range( 0, 7 ):
+ main.ONOSbench.onosDie( ONOSIp[i] )
+ main.log.info( "Uninstalling ONOS "+str(i+1) )
+ main.ONOSbench.onosUninstall( ONOSIp[i] )
+
+ main.step( "Creating new cell file" )
+ cellIp = []
+ for node in range( 1, clusterCount + 1 ):
+ cellIp.append( ONOSIp[node] )
+ main.ONOSbench.createCellFile( benchIp, cellName,
+ mininetIp, str(features), *cellIp )
+
+ main.step( "Setting cell definition" )
+ main.ONOSbench.setCell( cellName )
+
+ main.step( "Packaging cell definition" )
+ main.ONOSbench.onosPackage()
+
+ for node in range( 1, clusterCount + 1 ):
+ main.ONOSbench.onosInstall( node = ONOSIp[node] )
+
+ time.sleep( 20 )
+
+ for node in range( 1, clusterCount + 1 ):
+ for i in range( 2 ):
+ isup = main.ONOSbench.isup( ONOSIp[node] )
+ if isup:
+ main.log.info( "ONOS "+str(node) + " is up\n")
+ assertion = main.TRUE
+ break
+ if not isup:
+ main.log.info( "ONOS" + str(node) + " did not start")
+
+ for node in range( 1, clusterCount + 1 ):
+ exec "a = main.ONOS%scli.startOnosCli" %str(node)
+ a( ONOSIp[node] )
+
+ time.sleep(30)
+
+ utilities.assert_equals(expect=main.TRUE, actual=assertion,
+ onpass='Scale out to ' + str(clusterCount) + ' nodes successful',
+ onfail='Scale out to ' + str(clusterCount) + ' nodes failed')
+
diff --git a/TestON/tests/IntentPerfNextBM/IntentPerfNextBM.topo b/TestON/tests/IntentPerfNextBM/IntentPerfNextBM.topo
new file mode 100644
index 0000000..197acfa
--- /dev/null
+++ b/TestON/tests/IntentPerfNextBM/IntentPerfNextBM.topo
@@ -0,0 +1,109 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1cli>
+
+ <ONOS2cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2cli>
+
+ <ONOS3cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3cli>
+
+ <ONOS4cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4cli>
+
+ <ONOS5cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5cli>
+
+ <ONOS6cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6cli>
+
+ <ONOS7cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7cli>
+
+ <ONOS1>
+ <host>10.254.1.201</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <Mininet1>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS>
+ <arg1> --custom topo-intent-8sw.py </arg1>
+ <arg2> --arp --mac --topo mytopo </arg2>
+ <arg3> </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </Mininet2>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/IntentRerouteLat/IntentRerouteLat.params b/TestON/tests/IntentRerouteLat/IntentRerouteLat.params
new file mode 100644
index 0000000..8e7a6a4
--- /dev/null
+++ b/TestON/tests/IntentRerouteLat/IntentRerouteLat.params
@@ -0,0 +1,79 @@
+<PARAMS>
+
+ <testcases>1,2,1,2,1,2,1,2</testcases>
+
+ <SCALE>1,3,5,7</SCALE>
+ <availableNodes>7</availableNodes>
+
+ <ENV>
+ <cellName>intentRerouteCell</cellName>
+ <cellApps>drivers,null,intentperf,metrics</cellApps>
+ </ENV>
+
+ <TEST>
+ <skipCleanInstall>yes</skipCleanInstall>
+ <warmUp>5</warmUp>
+ <sampleSize>10</sampleSize>
+ <wait></wait>
+ <intents>1,100,1000</intents> #list format, will be split on ','
+ <debug>True</debug>
+
+ <s1>1,1,1,1,1,1,1,1</s1>
+ <s3>2,2,1,1,3,3,3,1</s3>
+ <s5>2,2,1,1,3,4,5,3</s5>
+ <s7>2,3,1,1,5,6,7,4</s7>
+
+ </TEST>
+
+ <METRICS>
+ <Submitted>0</Submitted>
+ <Installed>1</Installed>
+ <Failed>0</Failed>
+ <Withdraw>0</Withdraw>
+ <Withdrawn>0</Withdrawn>
+ </METRICS>
+
+ <GIT>
+ <autopull>on</autopull>
+ <checkout>master</checkout>
+ </GIT>
+
+ <CTRL>
+ <USER>admin</USER>
+
+ <ip1>10.254.1.201</ip1>
+ <port1>6633</port1>
+
+ <ip2>10.254.1.202</ip2>
+ <port2>6633</port2>
+
+ <ip3>10.254.1.203</ip3>
+ <port3>6633</port3>
+
+ <ip4>10.254.1.204</ip4>
+ <port4>6633</port4>
+
+ <ip5>10.254.1.205</ip5>
+ <port5>6633</port5>
+
+ <ip6>10.254.1.206</ip6>
+ <port6>6633</port6>
+
+ <ip7>10.254.1.207</ip7>
+ <port7>6633</port7>
+
+ </CTRL>
+
+ <MN>
+ <ip1>10.254.1.200</ip1>
+ </MN>
+
+ <BENCH>
+ <user>admin</user>
+ <ip1>10.254.1.200</ip1>
+ </BENCH>
+
+ <JSON>
+ </JSON>
+
+</PARAMS>
diff --git a/TestON/tests/IntentRerouteLat/IntentRerouteLat.py b/TestON/tests/IntentRerouteLat/IntentRerouteLat.py
new file mode 100644
index 0000000..f824a5c
--- /dev/null
+++ b/TestON/tests/IntentRerouteLat/IntentRerouteLat.py
@@ -0,0 +1,410 @@
+# ScaleOutTemplate
+#
+# CASE1 starts number of nodes specified in param file
+#
+# cameron@onlab.us
+
+import sys
+import os.path
+
+
+class IntentRerouteLat:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+
+ import time
+ global init
+ try:
+ if type(init) is not bool:
+ init = False
+ except NameError:
+ init = False
+
+ #Load values from params file
+ checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
+ gitPull = main.params[ 'GIT' ][ 'autopull' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ Apps = main.params[ 'ENV' ][ 'cellApps' ]
+ BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+ BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+ MN1Ip = main.params[ 'MN' ][ 'ip1' ]
+ maxNodes = int(main.params[ 'availableNodes' ])
+ skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
+ if init == False:
+ init = True
+ global clusterCount #number of nodes running
+ global ONOSIp #list of ONOS IP addresses
+ global scale
+ global commit
+
+ clusterCount = 0
+ ONOSIp = [ 0 ]
+ scale = (main.params[ 'SCALE' ]).split(",")
+ clusterCount = int(scale[0])
+
+ #Populate ONOSIp with ips from params
+ for i in range(1, maxNodes + 1):
+ ipString = 'ip' + str(i)
+ ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
+
+ #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
+ if skipMvn != "yes":
+ mvnResult = main.ONOSbench.cleanInstall()
+
+ #git
+ main.step( "Git checkout and pull " + checkoutBranch )
+ if gitPull == 'on':
+ checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
+ pullResult = main.ONOSbench.gitPull()
+
+ else:
+ checkoutResult = main.TRUE
+ pullResult = main.TRUE
+ main.log.info( "Skipped git checkout and pull" )
+
+ commit = main.ONOSbench.getVersion()
+ commit = (commit.split(" "))[1]
+
+ resultsDB = open("IntentRerouteLatDB", "w+")
+ resultsDB.close()
+
+ # -- END OF INIT SECTION --#
+
+ clusterCount = int(scale[0])
+ scale.remove(scale[0])
+
+ #kill off all onos processes
+ main.log.step("Safety check, killing all ONOS processes")
+ main.log.step("before initiating enviornment setup")
+ for node in range(1, maxNodes + 1):
+ main.ONOSbench.onosDie(ONOSIp[node])
+
+ #Uninstall everywhere
+ main.log.step( "Cleaning Enviornment..." )
+ for i in range(1, maxNodes + 1):
+ main.log.info(" Uninstalling ONOS " + str(i) )
+ main.ONOSbench.onosUninstall( ONOSIp[i] )
+
+ #construct the cell file
+ main.log.info("Creating cell file")
+ cellIp = []
+ for node in range (1, clusterCount + 1):
+ cellIp.append(ONOSIp[node])
+
+ main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
+
+ main.step( "Set Cell" )
+ main.ONOSbench.setCell(cellName)
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "verify cells" )
+ verifyCellResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Initializing " + str( clusterCount ) + " node cluster." )
+ for node in range(1, clusterCount + 1):
+ main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
+ main.ONOSbench.onosInstall( ONOSIp[node])
+
+ for node in range(1, clusterCount + 1):
+ for i in range( 2 ):
+ isup = main.ONOSbench.isup( ONOSIp[node] )
+ if isup:
+ main.log.info("ONOS " + str(node) + " is up\n")
+ break
+ if not isup:
+ main.log.report( "ONOS " + str(node) + " didn't start!" )
+ main.log.info("Startup sequence complete")
+
+ deviceMastership = (main.params[ 'TEST' ][ "s" + str(clusterCount) ]).split(",")
+ print("Device mastership list: " + str(deviceMastership))
+
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount 8 " """)
+ main.ONOSbench.handle.expect(":~")
+ print repr(main.ONOSbench.handle.before)
+ time.sleep(3)
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape reroute" """)
+ main.ONOSbench.handle.expect(":~")
+ print repr(main.ONOSbench.handle.before)
+ time.sleep(3)
+
+ time.sleep(10)
+
+ once = True
+ for attempt in range(0,10):
+ main.ONOSbench.handle.sendline("onos $OC1 summary")
+ main.ONOSbench.handle.expect(":~")
+ x = main.ONOSbench.handle.before
+ main.log.info("Initial setup. ONOS summary response: \n" + x + "\n")
+
+ if "devices=8" in x and "links=16," in x:
+ break
+ else:
+ if once == False:
+ main.log.error("Null provider start failed, retrying..")
+ once = False
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders enabled false" """)
+ main.ONOSbench.handle.expect(":~")
+ time.sleep(3)
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders enabled true" """)
+ main.ONOSbench.handle.expect(":~")
+ time.sleep(8)
+
+ index = 1
+ for node in deviceMastership:
+ for attempt in range(0,10):
+ cmd = ( "onos $OC" + node + """ "device-role null:000000000000000""" + str(index) + " " + ONOSIp[int(node)] + """ master" """)
+ main.log.info("assigning mastership of device " + str(index) + " to node " + node + ": \n " + cmd + "\n")
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ time.sleep(4)
+
+ cmd = ( "onos $OC" + node + " roles|grep 00000" + str(index))
+ main.log.info(cmd)
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ check = main.ONOSbench.handle.before
+ main.log.info("CHECK:\n" + check)
+ if ("master=" + ONOSIp[int(node)]) in check:
+ break
+ index += 1
+
+
+ def CASE2( self, main ):
+
+ import time
+ import numpy
+ import datetime
+ #from scipy import stats
+
+ ts = time.time()
+ date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d')
+
+ sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
+ warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
+ intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
+ debug = main.params[ 'TEST' ][ 'debug' ]
+ for i in range(0,len(intentsList)):
+ intentsList[i] = int(intentsList[i])
+
+ timestampMetrics = []
+ if main.params['METRICS']['Submitted'] == "1":
+ timestampMetrics.append("Submitted")
+ if main.params['METRICS']['Installed'] == "1":
+ timestampMetrics.append("Installed")
+ if main.params['METRICS']['Failed'] == "1":
+ timestampMetrics.append("Failed")
+ if main.params['METRICS']['Withdraw'] == "1":
+ timestampMetrics.append("Withdraw")
+ if main.params['METRICS']['Withdrawn'] == "1":
+ timestampMetrics.append("Withdrawn")
+ if debug: main.log.info(timestampMetrics)
+
+ if debug == "True":
+ debug = True
+ else:
+ debug = False
+
+ ingress = "null:0000000000000001"
+ egress = "null:0000000000000007"
+
+ for intents in intentsList:
+ main.log.report("Intent Batch size: " + str(intents) + "\n ")
+ myResult = [["latency", "lastNode"] for x in range(sampleSize)]
+
+ for run in range(0, (warmUp + sampleSize)):
+ if run > warmUp:
+ main.log.info("Starting test iteration " + str(run-warmUp))
+
+ cmd = """onos $OC1 "push-test-intents -i """
+ cmd += ingress + "/0 "
+ cmd += egress + "/0 "
+ cmd += str(intents) +""" 1" """
+ if debug: main.log.info(cmd)
+
+ withdrawCmd = cmd.replace("intents -i", "intents -w ")
+
+ #push-test-intents
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ myRawResult = main.ONOSbench.handle.before
+
+ for i in range(0, 40):
+ main.ONOSbench.handle.sendline("onos $OC1 summary")
+ main.ONOSbench.handle.expect(":~")
+ linkCheck = main.ONOSbench.handle.before
+ if ("links=16,") in linkCheck and ("flows=" + str(intents*7) + ","):
+ break
+ if i == 39:
+ main.log.error("Flow/link count incorrect, data invalid."+ linkCheck)
+
+
+ #collect timestamp from link cut
+ cmd = """onos $OC1 null-link "null:0000000000000004/1 null:0000000000000003/2 down" """
+ if debug: main.log.info("COMMAND: " + str(cmd))
+ main.ONOSbench.handle.sendline(cmd)
+
+ cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1"
+ for i in range(0,10):
+ main.ONOSbench.handle.sendline(cmd)
+ time.sleep(2)
+ main.ONOSbench.handle.expect(":~")
+ raw = main.ONOSbench.handle.before
+ #if "NullLinkProvider" in raw and "links=14" in raw:
+ if "links=14" in raw:
+ break
+ if i >= 9:
+ main.log.error("Expected output not being recieved... continuing")
+ main.log.info(raw)
+ break
+ time.sleep(2)
+
+ temp = raw.splitlines()
+ for line in temp:
+ if str(date) in line:
+ temp = line
+ break
+
+ cutTimestamp = (temp.split(" "))[0] + " " + (temp.split(" "))[1]
+ if debug: main.log.info("Cut timestamp: " + cutTimestamp)
+
+ #validate link count and flow count
+ for i in range(0, 40):
+ main.ONOSbench.handle.sendline("onos $OC1 summary")
+ main.ONOSbench.handle.expect(":~")
+ linkCheck = main.ONOSbench.handle.before
+ #if "links=" + str(7*intents)+ "," in linkCheck and ("flows=" + str(7*intents) + ",") in linkCheck:
+ if "links=14," in linkCheck and ("flows=" + str(8*intents) + ",") in linkCheck:
+ break
+ if i == 39:
+ main.log.error("Link or flow count incorrect, data invalid." + linkCheck)
+
+ time.sleep(5) #trying to avoid negative values
+
+ #intents events metrics installed timestamp
+ IEMtimestamps = [0]*(clusterCount + 1)
+ installedTemp = [0]*(clusterCount + 1)
+ for node in range(1, clusterCount +1):
+ cmd = "onos $OC" + str(node) + """ "intents-events-metrics"|grep Timestamp """
+ raw = ""
+ while "epoch)" not in raw:
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ raw = main.ONOSbench.handle.before
+
+ print(raw)
+
+ intentsTimestamps = {}
+ rawTimestamps = raw.splitlines()
+ for line in rawTimestamps:
+ if "Timestamp" in line and "grep" not in line:
+ metricKey = (line.split(" "))[1]
+ metricTimestamp = (line.split(" ")[len(line.split(" ")) -1]).replace("epoch)=","")
+ metricTimestamp = float(metricTimestamp)
+ metricTimestamp = numpy.divide(metricTimestamp, 1000)
+ if debug: main.log.info(repr(metricTimestamp))
+ intentsTimestamps[metricKey] = metricTimestamp
+ if metricKey == "Installed":
+ installedTemp[node] = metricTimestamp
+
+ main.log.info("Node: " + str(node) + " Timestamps: " + str(intentsTimestamps))
+ IEMtimestamps[node] = intentsTimestamps
+
+ myMax = max(installedTemp)
+ indexOfMax = installedTemp.index(myMax)
+
+ #number crunch
+ for metric in timestampMetrics: #this is where we sould add support for computing other timestamp metrics
+ if metric == "Installed":
+ if run >= warmUp:
+ main.log.report("link cut timestamp: " + cutTimestamp)
+ #readableInstalledTimestamp = str(intentsTimestamps["Installed"])
+ readableInstalledTimestamp = str(myMax)
+
+ #main.log.report("Intent Installed timestamp: " + str(intentsTimestamps["Installed"]))
+ main.log.report("Intent Installed timestamp: " + str(myMax))
+
+ cutEpoch = time.mktime(time.strptime(cutTimestamp, "%Y-%m-%d %H:%M:%S,%f"))
+ if debug: main.log.info("cutEpoch=" + str(cutEpoch))
+ #rerouteLatency = float(intentsTimestamps["Installed"] - cutEpoch)
+ rerouteLatency = float(myMax - cutEpoch)
+
+ rerouteLatency = numpy.divide(rerouteLatency, 1000)
+ main.log.report("Reroute latency:" + str(rerouteLatency) + " (seconds)\n ")
+ myResult[run-warmUp][0] = rerouteLatency
+ myResult[run-warmUp][1] = indexOfMax
+ if debug: main.log.info("Latency: " + str(myResult[run-warmUp][0]))
+ if debug: main.log.info("last node: " + str(myResult[run-warmUp][1]))
+
+ cmd = """ onos $OC1 null-link "null:0000000000000004/1 null:0000000000000003/2 up" """
+
+ #wait for intent withdraw
+ if debug: main.log.info(cmd)
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ main.ONOSbench.handle.sendline("onos $OC1 intents|grep WITHDRAWN|wc -l")
+ main.ONOSbench.handle.expect(":~")
+ intentWithdrawCheck = main.ONOSbench.handle.before
+ if (str(intents)) in intentWithdrawCheck:
+ main.log.info("intents withdrawn")
+ if debug: main.log.info(intentWithdrawCheck)
+
+ # wait for links to be reestablished
+ for i in range(0, 10):
+ main.ONOSbench.handle.sendline("onos $OC1 summary")
+ main.ONOSbench.handle.expect(":~")
+ linkCheck = main.ONOSbench.handle.before
+ if "links=16," in linkCheck:
+ break
+ time.sleep(1)
+ if i == 9:
+ main.log.info("Links Failed to reconnect, next iteration of data invalid." + linkCheck)
+
+ if run < warmUp:
+ main.log.info("Warm up run " + str(run+1) + " completed")
+
+ if debug: main.log.info(myResult)
+ latTemp = []
+ nodeTemp = []
+ for i in myResult:
+ latTemp.append(i[0])
+ nodeTemp.append(i[1])
+
+ mode = {}
+ for i in nodeTemp:
+ if i in mode:
+ mode[i] += 1
+ else:
+ mode[i] = 1
+
+ for i in mode.keys():
+ if mode[i] == max(mode.values()):
+ nodeMode = i
+
+ average = numpy.average(latTemp)
+ stdDev = numpy.std(latTemp)
+
+ average = numpy.multiply(average, 1000)
+ stdDev = numpy.multiply(stdDev, 1000)
+
+ main.log.report("Scale: " + str(clusterCount) + " \tIntent batch: " + str(intents))
+ main.log.report("Latency average:................" + str(average))
+ main.log.report("Latency standard deviation:....." + str(stdDev))
+ main.log.report("Mode of last node to respond:..." + str(nodeMode))
+ main.log.report("________________________________________________________")
+
+ resultsDB = open("IntentRerouteLatDB", "a")
+ resultsDB.write("'" + commit + "',")
+ resultsDB.write(str(clusterCount) + ",")
+ resultsDB.write(str(intents) + ",")
+ resultsDB.write(str(average) + ",")
+ resultsDB.write(str(stdDev) + "\n")
+ resultsDB.close()
+
diff --git a/TestON/tests/IntentRerouteLat/IntentRerouteLat.topo b/TestON/tests/IntentRerouteLat/IntentRerouteLat.topo
new file mode 100644
index 0000000..0e45e0f
--- /dev/null
+++ b/TestON/tests/IntentRerouteLat/IntentRerouteLat.topo
@@ -0,0 +1,146 @@
+<TOPOLOGY>
+
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS><home>~/onos</home></COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1cli>
+
+ <ONOS2cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2cli>
+
+ <ONOS3cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3cli>
+
+ <ONOS4cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4cli>
+
+ <ONOS5cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5cli>
+
+ <ONOS6cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6cli>
+
+ <ONOS7cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7cli>
+
+ <ONOS1>
+ <host>10.254.1.201</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.254.1.202</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.254.1.203</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.254.1.204</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4>
+
+
+ <ONOS5>
+ <host>10.254.1.205</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5>
+
+ <ONOS6>
+ <host>10.254.1.206</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>14</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6>
+
+ <ONOS7>
+ <host>10.254.1.207</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>15</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7>
+
+ </COMPONENT>
+
+</TOPOLOGY>
+
+
+
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/IntentRerouteLat/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/IntentRerouteLat/__init__.py
diff --git a/TestON/tests/IntentsLoad/IntentsLoad.params b/TestON/tests/IntentsLoad/IntentsLoad.params
deleted file mode 100644
index b60621c..0000000
--- a/TestON/tests/IntentsLoad/IntentsLoad.params
+++ /dev/null
@@ -1,49 +0,0 @@
-<PARAMS>
-
- <testcases>1,2,4</testcases>
-
- <ENV>
- <cellName>cam_cells</cellName>
- </ENV>
-
- <SCALE>1</SCALE>
-
- <GIT>
- <autopull>off</autopull>
- <checkout>master</checkout>
- </GIT>
-
- <CTRL>
- <USER>admin</USER>
- <ip1>10.128.5.51</ip1>
- <port1>6633</port1>
- <ip2>10.128.5.52</ip2>
- <port2>6633</port2>
- <ip3>10.128.5.53</ip3>
- <port3>6633</port3>
- </CTRL>
-
- <MN>
- <ip1>10.128.5.59</ip1>
- <ip2>10.128.5.59</ip2>
- </MN>
-
- <BENCH>
- <user>admin</user>
- <ip1>10.128.5.55</ip1>
- </BENCH>
-
- <TEST>
- <loadstart>curl --fail http://localhost:8181/onos/demo/intents/setup -H "Content-Type:application/json" -d '{"type" : "random"}'</loadstart>
- <loadstop>curl --fail http://localhost:8181/onos/demo/intents/teardown</loadstop>
- <arping>py [h.cmd("arping -c 1 -w 1 10.0.0.225") for h in net.hosts]</arping>
- <metric1>intents-events-metrics|grep "Intent Installed Events"</metric1>
- <duration>90</duration>
- <log_interval>5</log_interval>
- </TEST>
-
- <JSON>
- <intents_rate>intentInstalledRate</intents_rate>
- </JSON>
-
-</PARAMS>
diff --git a/TestON/tests/IntentsLoad/IntentsLoad.py b/TestON/tests/IntentsLoad/IntentsLoad.py
deleted file mode 100644
index f13e60d..0000000
--- a/TestON/tests/IntentsLoad/IntentsLoad.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# ScaleOutTemplate --> IntentsLoad
-#
-# CASE1 starts number of nodes specified in param file
-#
-# cameron@onlab.us
-
-import sys
-import os
-
-
-class IntentsLoad:
- def __init__(self):
- self.default = ''
-
- def CASE1(self, main):
-
- global cluster_count
- cluster_count = 1
-
- checkout_branch = main.params['GIT']['checkout']
- git_pull = main.params['GIT']['autopull']
- cell_name = main.params['ENV']['cellName']
- BENCH_ip = main.params['BENCH']['ip1']
- BENCH_user = main.params['BENCH']['user']
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- MN1_ip = main.params['MN']['ip1']
-
- main.log.step("Cleaning Enviornment...")
- main.ONOSbench.onos_uninstall(ONOS1_ip)
- main.ONOSbench.onos_uninstall(ONOS2_ip)
- main.ONOSbench.onos_uninstall(ONOS3_ip)
-
- main.step("Git checkout and pull "+checkout_branch)
- if git_pull == 'on':
- checkout_result = main.ONOSbench.git_checkout(checkout_branch)
- pull_result = main.ONOSbench.git_pull()
-
- else:
- checkout_result = main.TRUE
- pull_result = main.TRUE
- main.log.info("Skipped git checkout and pull")
-
- #mvn_result = main.ONOSbench.clean_install()
-
- main.step("Set cell for ONOS cli env")
- main.ONOS1cli.set_cell(cell_name)
- main.ONOS2cli.set_cell(cell_name)
- main.ONOS3cli.set_cell(cell_name)
-
- main.step("Creating ONOS package")
- package_result = main.ONOSbench.onos_package() #no file or directory
-
- main.step("Installing ONOS package")
- install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
-
- cell_name = main.params['ENV']['cellName']
- main.step("Applying cell file to environment")
- cell_apply_result = main.ONOSbench.set_cell(cell_name)
- main.step("verify cells")
- verify_cell_result = main.ONOSbench.verify_cell()
-
- main.step("Set cell for ONOS cli env")
- main.ONOS1cli.set_cell(cell_name)
-
- cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
-
- def CASE2(self, main):
-
- '''
- Increase number of nodes and initiate CLI
- '''
- import time
-
- global cluster_count
-
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- #ONOS4_ip = main.params['CTRL']['ip4']
- #ONOS5_ip = main.params['CTRL']['ip5']
- #ONOS6_ip = main.params['CTRL']['ip6']
- #ONOS7_ip = main.params['CTRL']['ip7']
- cell_name = main.params['ENV']['cellName']
- scale = int(main.params['SCALE'])
-
-
- #Cluster size increased everytime the case is defined
- cluster_count += scale
-
- main.log.report("Increasing cluster size to "+
- str(cluster_count))
- install_result = main.FALSE
-
- if scale == 2:
- if cluster_count == 3:
- main.log.info("Installing nodes 2 and 3")
- install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
- install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
- cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
- cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
- '''
- elif cluster_count == 5:
-
- main.log.info("Installing nodes 4 and 5")
- node4_result = main.ONOSbench.onos_install(node=ONOS4_ip)
- node5_result = main.ONOSbench.onos_install(node=ONOS5_ip)
- install_result = node4_result and node5_result
- time.sleep(5)
-
- main.ONOS4cli.start_onos_cli(ONOS4_ip)
- main.ONOS5cli.start_onos_cli(ONOS5_ip)
-
- elif cluster_count == 7:
-
- main.log.info("Installing nodes 4 and 5")
- node6_result = main.ONOSbench.onos_install(node=ONOS6_ip)
- node7_result = main.ONOSbench.onos_install(node=ONOS7_ip)
- install_result = node6_result and node7_result
- time.sleep(5)
-
- main.ONOS6cli.start_onos_cli(ONOS6_ip)
- main.ONOS7cli.start_onos_cli(ONOS7_ip)
- '''
- if scale == 1:
- if cluster_count == 2:
- main.log.info("Installing node 2")
- install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
- cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
-
- if cluster_count == 3:
- main.log.info("Installing node 3")
- install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
- cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
-
-
-
- def CASE3(self,main):
- import time
- import json
- import string
-
- intents_rate = main.params['JSON']['intents_rate']
-
- default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
-
- main.Mininet1.assign_sw_controller(sw="1", ip1=ONOS1_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="2", ip1=ONOS1_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="3", ip1=ONOS1_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="4", ip1=ONOS1_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="5", ip1=ONOS1_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="6", ip1=ONOS1_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="7", ip1=ONOS1_ip, port1=default_sw_port )
-
- mn_arp = main.params['TEST']['arping']
- main.Mininet1.handle.sendline(mn_arp)
-
- generate_load = main.params['TEST']['loadstart']
-
- main.ONOS1.handle.sendline(generate_load)
- main.ONOS1.handle.expect("sdn")
- print("before: ", main.ONOS1.handle.before)
- print("after: ",main.ONOS1.handle.after)
-
- load_confirm = main.ONOS1.handle.after
- if load_confirm == "{}":
- main.log.info("Load started")
-
- else:
- main.log.error("Load start failure")
- main.log.error("expected '{}', got: " + str(load_confirm))
-
- devices_json_str = main.ONOS1cli.devices()
- devices_json_obj = json.loads(devices_json_str)
-
- get_metric = main.params['TEST']['metric1']
- test_duration = main.params['TEST']['duration']
- stop = time.time() + float(test_duration)
-
-
- main.log.info("Starting test loop...")
- log_interval = main.params['TEST']['log_interval']
-
- while time.time() < stop:
- time.sleep(float(log_interval))
-
- intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
- intents_json_obj_1 = json.loads(intents_json_str_1)
- main.log.info("Node 1 rate: " + str(intents_json_obj_1[intents_rate]['m1_rate']))
- last_rate_1 = intents_json_obj_1[intents_rate]['m1_rate']
-
- stop_load = main.params['TEST']['loadstop']
- main.ONOS1.handle.sendline(stop_load)
-
-
- msg = ("Final rate on node 1: " + str(last_rate_1))
- main.log.report(msg)
-
- def CASE4(self, main): #2 node scale
- import time
- import json
- import string
-
- intents_rate = main.params['JSON']['intents_rate']
-
- default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
-
- main.Mininet1.assign_sw_controller(sw="1", ip1=ONOS1_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="2", ip1=ONOS2_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="3", ip1=ONOS1_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="4", ip1=ONOS2_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="5", ip1=ONOS1_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="6", ip1=ONOS2_ip, port1=default_sw_port )
- main.Mininet1.assign_sw_controller(sw="7", ip1=ONOS1_ip, port1=default_sw_port )
-
- mn_arp = main.params['TEST']['arping']
- main.Mininet1.handle.sendline(mn_arp)
-
- generate_load = main.params['TEST']['loadstart']
-
- main.ONOS1.handle.sendline(generate_load)
- main.ONOS2.handle.sendline(generate_load)
-
- devices_json_str_1 = main.ONOS1cli.devices()
- devices_json_obj_1 = json.loads(devices_json_str_1)
- devices_json_str_2 = main.ONOS2cli.devices()
- devices_json_obj_2 = json.loads(devices_json_str_2)
-
- get_metric = main.params['TEST']['metric1']
- test_duration = main.params['TEST']['duration']
- stop = time.time() + float(test_duration)
-
-
- main.log.info("Starting test loop...")
- log_interval = main.params['TEST']['log_interval']
-
- while time.time() < stop:
- time.sleep(float(log_interval))
-
- intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
- intents_json_obj_1 = json.loads(intents_json_str_1)
- main.log.info("Node 1 rate: " + str(intents_json_obj_1[intents_rate]['m1_rate']))
- last_rate_1 = intents_json_obj_1[intents_rate]['m1_rate']
-
- intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
- intents_json_obj_2 = json.loads(intents_json_str_2)
- main.log.info("Node 2 rate: " + str(intents_json_obj_2[intents_rate]['m1_rate']))
- last_rate_2 = intents_json_obj_2[intents_rate]['m1_rate']
-
- stop_load = main.params['TEST']['loadstop']
- main.ONOS1.handle.sendline(stop_load)
- main.ONOS2.handle.sendline(stop_load)
-
-
- msg = ("Final rate on node 1: " + str(last_rate_1))
- main.log.report(msg)
-
- msg = ("Final rate on node 2: " + str(last_rate_2))
- main.log.report(msg)
-
-
-
diff --git a/TestON/tests/IntentsLoad/IntentsLoad.topo b/TestON/tests/IntentsLoad/IntentsLoad.topo
deleted file mode 100644
index 985baf9..0000000
--- a/TestON/tests/IntentsLoad/IntentsLoad.topo
+++ /dev/null
@@ -1,94 +0,0 @@
-<TOPOLOGY>
-
- <COMPONENT>
-
- <ONOSbench>
- <host>10.128.5.55</host>
- <user>admin</user>
- <password>onos_test</password>
- <type>OnosDriver</type>
- <connect_order>1</connect_order>
- <COMPONENTS> </COMPONENTS>
- </ONOSbench>
-
- <ONOS1cli>
- <host>10.128.5.55</host>
- <user>admin</user>
- <password>onos_test</password>
- <type>OnosCliDriver</type>
- <connect_order>2</connect_order>
- <COMPONENTS> </COMPONENTS>
- </ONOS1cli>
-
- <ONOS2cli>
- <host>10.128.5.55</host>
- <user>admin</user>
- <password>onos_test</password>
- <type>OnosCliDriver</type>
- <connect_order>3</connect_order>
- <COMPONENTS> </COMPONENTS>
- </ONOS2cli>
-
- <ONOS3cli>
- <host>10.128.5.55</host>
- <user>admin</user>
- <password>onos_test</password>
- <type>OnosCliDriver</type>
- <connect_order>4</connect_order>
- <COMPONENTS> </COMPONENTS>
- </ONOS3cli>
-
- <ONOS1>
- <host>10.128.5.51</host>
- <user>sdn</user>
- <password>rocks</password>
- <type>OnosDriver</type>
- <connect_order>5</connect_order>
- <COMPONENTS> </COMPONENTS>
- </ONOS1>
-
- <ONOS2>
- <host>10.128.5.52</host>
- <user>sdn</user>
- <password>rocks</password>
- <type>OnosDriver</type>
- <connect_order>6</connect_order>
- <COMPONENTS> </COMPONENTS>
- </ONOS2>
-
- <ONOS3>
- <host>10.128.5.53</host>
- <user>sdn</user>
- <password>rocks</password>
- <type>OnosDriver</type>
- <connect_order>7</connect_order>
- <COMPONENTS> </COMPONENTS>
- </ONOS3>
-
- <Mininet1>
- <host>10.128.5.59</host>
- <user>admin</user>
- <password>onos_test</password>
- <type>MininetCliDriver</type>
- <connect_order>8</connect_order>
- <COMPONENTS>
- <arg1> --custom ~/topo-intentTPtest.py </arg1>
- <arg2> --mac --topo mytopo </arg2>
- <arg3> </arg3>
- <controller> remote </controller>
- </COMPONENTS>
- </Mininet1>
-
- <Mininet2>
- <host>10.128.5.59</host>
- <user>admin</user>
- <password>onos_test</password>
- <type>RemoteMininetDriver</type>
- <connect_order>9</connect_order>
- <COMPONENTS> </COMPONENTS>
- </Mininet2>
-
- </COMPONENT>
-
-</TOPOLOGY>
-
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/LincOETest/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/LincOETest/__init__.py
diff --git a/TestON/tests/LinkEventTP/LinkEventTP.params b/TestON/tests/LinkEventTP/LinkEventTP.params
new file mode 100644
index 0000000..7a47a51
--- /dev/null
+++ b/TestON/tests/LinkEventTP/LinkEventTP.params
@@ -0,0 +1,62 @@
+<PARAMS>
+ <testcases>1,2,3</testcases>
+
+ <ENV>
+ <cellName>network_tp_test</cellName>
+ <cellFeatures>"webconsole,onos-core,onos-api,onos-cli,onos-null,onos-rest,onos-app-metrics,onos-app-metrics-intent,onos-app-metrics-topology"</cellFeatures>
+ <onBaremetal>true</onBaremetal> "true"
+ </ENV>
+
+ <SCALE>6</SCALE>
+
+ <availableNodes>7</availableNodes>
+
+ <GIT>
+ <autopull>off</autopull>
+ <checkout>master</checkout>
+ </GIT>
+
+ <CTRL>
+ <USER>admin</USER>
+ <ip1>10.254.1.201</ip1>
+ <port1>6633</port1>
+ <ip2>10.254.1.202</ip2>
+ <port2>6633</port2>
+ <ip3>10.254.1.203</ip3>
+ <port3>6633</port3>
+ <ip4>10.254.1.204</ip4>
+ <port4>6633</port4>
+ <ip5>10.254.1.205</ip5>
+ <port5>6633</port5>
+ <ip6>10.254.1.206</ip6>
+ <port6>6633</port6>
+ <ip7>10.254.1.207</ip7>
+ <port7>6633</port7>
+ </CTRL>
+
+ <BENCH>
+ <user>admin</user>
+ <ip1>localhost</ip1>
+ </BENCH>
+
+ <TEST> # duration = time the test loop runs
+ # log_interval = how often the data is reported
+ # wait = time between tests, used to let the averages run down
+ <configFile>/onos/tools/package/etc/org.onosproject.net.topology.impl.DefaultTopologyProvider.cfg</configFile>
+ <flickerRates>20000,20000,20000,20000,20000,20000,20000</flickerRates>
+ <devicesPerNode>40,40,40,40,40,40,40</devicesPerNode>
+ <flickerRate>1000</flickerRate>
+ <linkgraphdif>.03</linkgraphdif> # 0-1 indicated link/graph rate dif tolerance
+ <duration>1800</duration>
+ <log_interval>15</log_interval>
+ <wait>60</wait>
+ <skipCleanInstall>yes</skipCleanInstall>
+ <MN>localhost</MN>
+ <logFile>link_event_tp_results_LOG</logFile>
+ </TEST>
+
+ <JSON>
+ <intents_rate>intentInstalledRate</intents_rate>
+ </JSON>
+
+</PARAMS>
diff --git a/TestON/tests/LinkEventTP/LinkEventTP.py b/TestON/tests/LinkEventTP/LinkEventTP.py
new file mode 100644
index 0000000..a4bc0aa
--- /dev/null
+++ b/TestON/tests/LinkEventTP/LinkEventTP.py
@@ -0,0 +1,336 @@
+# ScaleOutTemplate --> LinkEventTP
+#
+# CASE1 starts number of nodes specified in param file
+#
+# cameron@onlab.us
+
+import sys
+import os
+
+
+class LinkEventTP:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ): #This is the initialization case
+ import os.path #this case will clean up all nodes
+ #but only node 1 isnodestarted in this case
+
+ global clusterCount #number of nodes running
+ global ONOSIp #list of ONOS IP addresses
+
+ clusterCount = 1
+ ONOSIp = [ 0 ]
+
+ #Load values from params file
+ checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
+ gitPull = main.params[ 'GIT' ][ 'autopull' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ Features= main.params[ 'ENV' ][ 'cellFeatures' ]
+ BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+ BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+ maxNodes = int(main.params[ 'availableNodes' ])
+ Features = main.params[ 'ENV' ][ 'cellFeatures' ]
+ skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
+ flickerRate = main.params[ 'TEST' ][ 'flickerRate']
+ deviceDistribution = (main.params[ 'TEST' ][ 'devicesPerNode']).split(",")
+ MNip = main.params[ 'TEST' ][ 'MN' ]
+ logFileName = main.params[ 'TEST' ][ 'logFile' ]
+ onBaremetal = main.params[ 'ENV' ][ 'onBaremetal' ]
+
+ main.ONOSbench.handle.sendline("export TERM=vt100")
+ main.ONOSbench.handle.expect(":~")
+ homeDir = os.path.expanduser('~')
+
+ #Populate ONOSIp with ips from params
+ for i in range(1, maxNodes + 1):
+ ipString = 'ip' + str(i)
+ ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
+
+ #kill off all onos processes
+ main.log.step("Safety check, killing all ONOS processes")
+ main.log.step("before initiating enviornment setup")
+ for node in range(1, maxNodes + 1):
+ main.ONOSbench.onosDie(ONOSIp[node])
+
+ #construct the cell file
+ main.log.step("Creating cell file")
+ cellIp = []
+ for node in range (1, clusterCount + 1):
+ cellIp.append(ONOSIp[node])
+ main.ONOSbench.createCellFile(BENCHIp,cellName,MNip,str(Features), *cellIp)
+
+ main.step( "Set Cell" )
+ main.ONOSbench.setCell(cellName)
+
+ #Uninstall everywhere
+ main.log.step( "Cleaning Enviornment..." )
+ for i in range(1, maxNodes + 1):
+ main.log.info(" Uninstalling ONOS " + str(i) )
+ main.ONOSbench.onosUninstall( ONOSIp[i] )
+
+ myDistribution = []
+ for node in range (1, clusterCount + 1):
+ myDistribution.append(deviceDistribution[node-1])
+
+ main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
+ main.ONOSbench.createNullDevProviderFile( BENCHIp, cellIp, myDistribution)
+ main.ONOSbench.createNullLinkProviderFile(BENCHIp)
+
+ #git step - skipable
+ main.step( "Git checkout and pull " + checkoutBranch )
+ if gitPull == 'on':
+ checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
+ pullResult = main.ONOSbench.gitPull()
+
+ else:
+ checkoutResult = main.TRUE
+ pullResult = main.TRUE
+ main.log.info( "Skipped git checkout and pull" )
+
+ #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
+ if skipMvn != "yes":
+ mvnResult = main.ONOSbench.cleanInstall()
+
+ ### configure event rate file ###
+ main.log.step("Writing Default Topology Provider config file")
+ localPath = main.params[ 'TEST' ][ 'configFile' ]
+ filePath = homeDir + localPath
+ main.log.info(filePath)
+ configFile = open(filePath, 'w+')
+ main.log.info("File Opened")
+ configFile.write("maxEvents = 1\n")
+ configFile.write("maxIdleMs = 0\n")
+ configFile.write("maxBatchMs = 0\n")
+ main.log.info("File written and closed")
+ configFile.close()
+
+ logFile = open(logFileName, 'w+')
+ main.log.info("Created log File")
+ logFile.close()
+
+ if onBaremetal == "true":
+ filename = "/onos/tools/package/bin/onos-service"
+ serviceConfig = open(homeDir + filename, 'w+')
+ serviceConfig.write("#!/bin/bash\n ")
+ serviceConfig.write("#------------------------------------- \n ")
+ serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
+ serviceConfig.write("#------------------------------------- \n ")
+ serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
+ serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms256m -Xmx8G}" \n """)
+ serviceConfig.write("")
+ serviceConfig.write("ONOS_HOME=/opt/onos \n ")
+ serviceConfig.write("")
+ serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
+ serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
+ serviceConfig.close()
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
+
+ main.step( "Verify cells" )
+ verifyCellResult = main.ONOSbench.verifyCell()
+
+ main.step( "Enviornment setup and verification complete." )
+ main.ONOS1cli.startOnosCli( ONOSIp[1] )
+ main.step( "ONOS 1 is up and running." )
+ main.ONOSbench.handle.expect(":~") #there is a dangling sendline somewhere...
+
+ def CASE2( self, main ):
+ # This case increases the cluster size by whatever scale is
+ # Note: 'scale' is the size of the step
+ # if scaling is not a part of your test, simply run this case
+ # once after CASE1 to set up your enviornment for your desired
+ # cluster size. If scaling is a part of you test call this case each time
+ # you want to increase cluster size
+
+ ''
+ 'Increase number of nodes and initiate CLI'
+ ''
+ import time
+ global clusterCount
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ Features= main.params[ 'ENV' ][ 'cellFeatures' ]
+ BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+ MNip = main.params[ 'TEST' ][ 'MN' ]
+ deviceDistribution = (main.params[ 'TEST' ][ 'devicesPerNode']).split(",")
+
+ scale = int( main.params[ 'SCALE' ] )
+ clusterCount += scale
+
+ main.log.step( "Cleaning Enviornment..." )
+ for i in range(1, maxNodes + 1):
+ main.ONOSbench.onosDie(ONOSIp[i])
+ main.log.info(" Uninstalling ONOS " + str(i) )
+ main.ONOSbench.onosUninstall( ONOSIp[i] )
+
+ myDistribution = []
+ for node in range (1, clusterCount + 1):
+ myDistribution.append(deviceDistribution[node-1])
+
+ main.log.step("Creating cell file")
+ cellIp = []
+ for node in range (1, clusterCount + 1):
+ cellIp.append(ONOSIp[node])
+ main.ONOSbench.createCellFile(BENCHIp,cellName,MNip,str(Features), *cellIp)
+
+ main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
+ main.ONOSbench.createNullDevProviderFile( BENCHIp, cellIp, myDistribution)
+ main.ONOSbench.createNullLinkProviderFile(BENCHIp)
+
+ main.step( "Set Cell" )
+ main.ONOSbench.setCell(cellName)
+
+ main.step( "Packaging" )
+ main.ONOSbench.onosPackage()
+
+ main.log.report( "Increasing cluster size to " + str( clusterCount ) )
+ for node in range(1, clusterCount + 1):
+ time.sleep(10)
+ main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
+ main.ONOSbench.onosInstall( node=ONOSIp[node] )
+ exec "a = main.ONOS%scli.startOnosCli" %str(node)
+ a(ONOSIp[node])
+
+ for node in range(1, clusterCount + 1):
+ for i in range( 2 ):
+ isup = main.ONOSbench.isup( ONOSIp[node] )
+ if isup:
+ main.log.info("ONOS " + str(node) + " is up\n")
+ break
+ if not isup:
+ main.log.report( "ONOS " + str(node) + " didn't start!" )
+
+ def CASE3( self, main ):
+ import time
+ import json
+ import string
+ import csv
+ import os.path
+ import requests
+ import numpy
+
+ sustainability = float(main.params[ 'TEST' ][ 'linkgraphdif' ])
+ flickerRates = (main.params[ 'TEST' ][ 'flickerRates']).split(",")
+ homeDir = os.path.expanduser('~')
+
+ linkResult = main.FALSE
+ scale = int( main.params[ 'SCALE' ] )
+
+ testDelay = main.params[ 'TEST' ][ 'wait' ]
+
+ for node in range(1, clusterCount + 1):
+ main.log.info("Writing flicker file to node " + str(node))
+ main.ONOSbench.createNullLinkProviderFile( ONOSIp[node], eventRate=flickerRates[node-1], onNode=True )
+
+ testDuration = main.params[ 'TEST' ][ 'duration' ]
+ stop = time.time() + float( testDuration )
+
+ msg = ( "Starting test loop for " + str(testDuration) + " seconds on a " + str(clusterCount) + " node cluster" )
+ main.log.info( msg )
+ logInterval = main.params[ 'TEST' ][ 'log_interval' ]
+
+ linkResults = [0,0,0,0,0,0,0,0]
+ graphResults = [0,0,0,0,0,0,0,0]
+ JsonStr = [ 0,0,0,0,0,0,0,0 ]
+ JsonObj = [ 0,0,0,0,0,0,0,0 ]
+
+ while time.time() < stop:
+ time.sleep( float( logInterval ) )
+ for node in range(1, clusterCount+1):
+ main.ONOSbench.handle.sendline("""onos $OC1 topology-events-metrics|grep "Topology Link Events"|cut -d ' ' -f7 """)
+ main.ONOSbench.handle.expect(":~")
+ raw = (main.ONOSbench.handle.before).splitlines()
+ myresult = "--"
+ for word in raw:
+ if "m1" in word:
+ myresult = word
+ myresult = myresult.replace("m1=","")
+ break
+ if myresult == "--":
+ main.log.error("Parse error or no data error")
+ msg = ( "Node " + str(node) + " Link Event TP: " + str(myresult) )
+ main.log.info( msg )
+ linkResults[node] = round(float(myresult),2)
+ myLinkRate = round(float(myresult),2)
+
+ main.ONOSbench.handle.sendline("""onos $OC1 topology-events-metrics|grep "Topology Graph Events"|cut -d ' ' -f7 """)
+ main.ONOSbench.handle.expect(":~")
+ raw = (main.ONOSbench.handle.before).splitlines()
+ myresult = "--"
+ for word in raw:
+ if "m1" in word:
+ myresult = word
+ myresult = myresult.replace("m1=","")
+ break
+ if myresult == "--":
+ main.log.error("Parse error or no data error")
+ msg = ( "Node " + str(node) + " Graph Event TP: " + str(myresult) )
+ main.log.info( msg )
+ graphResults[node] = round(float(myresult),2)
+ myGraphRate = round(float(myresult),2)
+
+ difLinkGraph = float(myLinkRate - myGraphRate)
+ difLinkGraph = numpy.absolute(difLinkGraph)
+ main.log.info("Node " + str(node) + " abs(Link event - Graph event) = " + str(difLinkGraph))
+ tempx = numpy.divide(difLinkGraph,float(myLinkRate))
+ if tempx > sustainability:
+ main.log.error("Difference in link event rate and graph event rate above " + str(sustainability) + " tolerance")
+ print("")
+
+ print("")
+ print("")
+
+ main.log.report("Final Link Event TP Results on " + str(clusterCount) + " node cluster")
+ main.log.report("_______________________________________________")
+ for node in range(1, clusterCount+1):
+ main.log.report("Node " + str(node) + ": " + str(linkResults[node]))
+
+ print("")
+ print("")
+
+ main.log.report("Final Graph Event TP Results on " + str(clusterCount) + " node cluster")
+ main.log.report("_______________________________________________")
+ for node in range(1, clusterCount+1):
+ main.log.report("Node " + str(node) + ": " + str(graphResults[node]))
+
+ #################################################################################
+ # Data Logging
+
+ logFileName = main.params[ 'TEST' ][ 'logFile' ]
+ logFile = open(logFileName, 'a')
+ main.log.info("Log file opened")
+ flickerRate = main.params[ 'TEST' ][ 'flickerRate']
+
+ for node in range (1, clusterCount + 1):
+ # replare -> logFile.write( str(clusterCount) + "," + flickerNodes + "," )
+ logFile.write("'" + "baremetal" + str(node) + "'," )
+ logFile.write( testDuration + "," )
+ logFile.write( flickerRate + "," )
+ logFile.write( str(linkResults[node]) + "," )
+ logFile.write( str(graphResults[node]) + "\n" )
+
+ logFile.close()
+ main.log.info("Log file closed")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TestON/tests/LinkEventTP/LinkEventTP.pyc b/TestON/tests/LinkEventTP/LinkEventTP.pyc
new file mode 100644
index 0000000..644df6d
--- /dev/null
+++ b/TestON/tests/LinkEventTP/LinkEventTP.pyc
Binary files differ
diff --git a/TestON/tests/LinkEventTP/LinkEventTP.topo b/TestON/tests/LinkEventTP/LinkEventTP.topo
new file mode 100644
index 0000000..3c24161
--- /dev/null
+++ b/TestON/tests/LinkEventTP/LinkEventTP.topo
@@ -0,0 +1,146 @@
+<TOPOLOGY>
+
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ <home>~/onos</home>
+ </COMPONENTS>
+
+ </ONOSbench>
+
+ <ONOS1cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1cli>
+
+ <ONOS2cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2cli>
+
+ <ONOS3cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3cli>
+
+ <ONOS4cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4cli>
+
+ <ONOS5cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5cli>
+
+ <ONOS6cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6cli>
+
+ <ONOS7cli>
+ <host>10.254.1.200</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7cli>
+
+ <ONOS1>
+ <host>10.254.1.201</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.254.1.202</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.254.1.203</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.254.1.204</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4>
+
+
+ <ONOS5>
+ <host>10.254.1.205</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5>
+
+ <ONOS6>
+ <host>10.254.1.206</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>14</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6>
+
+ <ONOS7>
+ <host>10.254.1.207</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>15</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7>
+
+ </COMPONENT>
+
+</TOPOLOGY>
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/LinkEventTP/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/LinkEventTP/__init__.py
diff --git a/TestON/tests/LinkEventTP/__init__.pyc b/TestON/tests/LinkEventTP/__init__.pyc
new file mode 100644
index 0000000..62abfab
--- /dev/null
+++ b/TestON/tests/LinkEventTP/__init__.pyc
Binary files differ
diff --git a/TestON/tests/MultiProd/MultiProd.bak b/TestON/tests/MultiProd/MultiProd.bak
deleted file mode 100755
index 11af10b..0000000
--- a/TestON/tests/MultiProd/MultiProd.bak
+++ /dev/null
@@ -1,1156 +0,0 @@
-
-#Testing the basic functionality of ONOS Next
-#For sanity and driver functionality excercises only.
-
-import time
-import time
-import json
-
-time.sleep(1)
-class MultiProd:
- def __init__(self):
- self.default = ''
-
- def CASE1(self, main):
- '''
- Startup sequence:
- cell <name>
- onos-verify-cell
- onos-remove-raft-logs
- git pull
- mvn clean install
- onos-package
- onos-install -f
- onos-wait-for-start
- '''
-
- cell_name = main.params['ENV']['cellName']
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
-
- main.case("Setting up test environment")
- main.log.report("This testcase is testing setting up test environment")
- main.log.report("__________________________________")
-
- main.step("Applying cell variable to environment")
- cell_result1 = main.ONOSbench.set_cell(cell_name)
- #cell_result2 = main.ONOScli1.set_cell(cell_name)
- #cell_result3 = main.ONOScli2.set_cell(cell_name)
- #cell_result4 = main.ONOScli3.set_cell(cell_name)
- verify_result = main.ONOSbench.verify_cell()
- cell_result = cell_result1
-
- main.step("Removing raft logs before a clen installation of ONOS")
- remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
-
- 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
- main.ONOSbench.get_version(report=True)
-
- if git_pull_result == 1:
- main.step("Using mvn clean & install")
- main.ONOSbench.clean_install()
-
- 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")
- onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
- onos2_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS2_ip)
- onos3_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS3_ip)
- onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result
- if onos_install_result == main.TRUE:
- main.log.report("Installing ONOS package successful")
- else:
- main.log.report("Installing ONOS package failed")
-
- onos1_isup = main.ONOSbench.isup(ONOS1_ip)
- onos2_isup = main.ONOSbench.isup(ONOS2_ip)
- onos3_isup = main.ONOSbench.isup(ONOS3_ip)
- onos_isup = onos1_isup and onos2_isup and onos3_isup
- if onos_isup == main.TRUE:
- main.log.report("ONOS instances are up and ready")
- else:
- main.log.report("ONOS instances may not be up")
-
- main.step("Starting ONOS service")
- start_result = main.TRUE
- #start_result = main.ONOSbench.onos_start(ONOS1_ip)
- startcli1 = main.ONOScli1.start_onos_cli(ONOS_ip = ONOS1_ip)
- startcli2 = main.ONOScli2.start_onos_cli(ONOS_ip = ONOS2_ip)
- startcli3 = main.ONOScli3.start_onos_cli(ONOS_ip = ONOS3_ip)
- print startcli1
- print startcli2
- print startcli3
-
- case1_result = (package_result and\
- cell_result and verify_result and onos_install_result and\
- onos_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']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
-
- main.case("Cleaning up test environment")
-
- main.step("Testing ONOS kill function")
- kill_result1 = main.ONOSbench.onos_kill(ONOS1_ip)
- kill_result2 = main.ONOSbench.onos_kill(ONOS2_ip)
- kill_result3 = main.ONOSbench.onos_kill(ONOS3_ip)
-
- main.step("Stopping ONOS service")
- stop_result1 = main.ONOSbench.onos_stop(ONOS1_ip)
- stop_result2 = main.ONOSbench.onos_stop(ONOS2_ip)
- stop_result3 = main.ONOSbench.onos_stop(ONOS3_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']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
-
- 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)
- cmd_result2 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr1)
- main.log.info("onos command returned: "+cmd_result2)
- cmd_result3 = main.ONOSbench.onos_cli(ONOS3_ip, cmdstr1)
- main.log.info("onos command returned: "+cmd_result3)
-
- main.step("Sending command 'onos -w <onos-ip> onos:topology'")
- cmdstr2 = "onos:topology"
- cmd_result4 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result4)
- cmd_result5 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result5)
- cmd_result6 = main.ONOSbench.onos_cli(ONOS6_ip, cmdstr2)
- main.log.info("onos command returned: "+cmd_result6)
-
-
- def CASE4(self, main):
- import re
- import time
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS1_port = main.params['CTRL']['port1']
- ONOS2_port = main.params['CTRL']['port2']
- ONOS3_port = main.params['CTRL']['port3']
-
- main.log.report("This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode")
- main.log.report("__________________________________")
- main.case("Pingall Test(No intents are added)")
- main.step("Assigning switches to controllers")
- for i in range(1,29): #1 to (num of switches +1)
- main.Mininet1.assign_sw_controller(sw=str(i),count=3,
- ip1=ONOS1_ip, port1=ONOS1_port,
- ip2=ONOS2_ip, port2=ONOS2_port,
- ip3=ONOS3_ip, port3=ONOS3_port)
-
- switch_mastership = main.TRUE
- for i in range (1,29):
- 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("Controller assignment successfull")
- else:
- main.log.report("Controller assignment failed")
- #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
- if ping_result == main.TRUE:
- main.log.report("Pingall Test in reactive mode to discover the hosts successful")
- else:
- main.log.report("Pingall Test in reactive mode to discover the hosts failed")
-
- utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and 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
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
-
- main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes")
- main.log.report("__________________________________")
- main.case ("Testing Mininet topology with the topology of multi instances ONOS")
- main.step("Collecting topology information from ONOS")
- devices1 = main.ONOScli1.devices()
- devices2 = main.ONOScli2.devices()
- devices3 = main.ONOScli3.devices()
- #print "devices1 = ", devices1
- #print "devices2 = ", devices2
- #print "devices3 = ", devices3
- hosts1 = main.ONOScli1.hosts()
- hosts2 = main.ONOScli2.hosts()
- hosts3 = main.ONOScli3.hosts()
- #print "hosts1 = ", hosts1
- #print "hosts2 = ", hosts2
- #print "hosts3 = ", hosts3
- ports1 = main.ONOScli1.ports()
- ports2 = main.ONOScli2.ports()
- ports3 = main.ONOScli3.ports()
- #print "ports1 = ", ports1
- #print "ports2 = ", ports2
- #print "ports3 = ", ports3
- links1 = main.ONOScli1.links()
- links2 = main.ONOScli2.links()
- links3 = main.ONOScli3.links()
- #print "links1 = ", links1
- #print "links2 = ", links2
- #print "links3 = ", links3
-
- 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")
-
- switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
- print "switches_Result1 = ", switches_results1
- 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")
-
- switches_results3 = main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
- utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
- onpass="ONOS3 Switches view is correct",
- onfail="ONOS3 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")
-
- ports_results3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
- onpass="ONOS3 Ports view is correct",
- onfail="ONOS3 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")
-
- links_results3 = main.Mininet1.compare_links(MNTopo, json.loads(links3))
- utilities.assert_equals(expect=main.TRUE, actual=links_results3,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect")
-
- #topo_result = switches_results1 and switches_results2 and switches_results3\
- #and ports_results1 and ports_results2 and ports_results3\
- #and links_results1 and links_results2 and links_results3
-
- topo_result = switches_results1 and switches_results2 and switches_results3\
- and links_results1 and links_results2 and links_results3
-
- if topo_result == main.TRUE:
- main.log.report("Topology Check Test with mininet and ONOS instances successful")
- else:
- main.log.report("Topology Check Test with mininet and ONOS instances failed")
-
- utilities.assert_equals(expect=main.TRUE, actual=topo_result,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful")
-
-
-
-
- def CASE10(self):
- main.log.report("This testcase uninstalls the reactive forwarding app")
- main.log.report("__________________________________")
- main.case("Uninstalling reactive forwarding app")
- #Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-fwd")
- appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-fwd")
- appUninstall_result3 = main.ONOScli3.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)
-
- hosts = main.ONOScli1.hosts()
- main.log.info(hosts)
-
- case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
- utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
-
-
- def CASE6(self):
- main.log.report("This testcase is testing the addition of host intents and then doing pingall")
- main.log.report("__________________________________")
- main.case("Obtaining hostsfor adding host intents")
- main.step("Get hosts")
- hosts = main.ONOScli1.hosts()
- main.log.info(hosts)
-
- main.step("Get all devices id")
- devices_id_list = main.ONOScli1.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 intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
- hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
- '''
-
- for i in range(8,18):
- main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- #NOTE: get host can return None
- #TODO: handle this
- host1_id = main.ONOScli1.get_host(host1)['id']
- host2_id = main.ONOScli1.get_host(host2)['id']
- tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
-
- flowHandle = main.ONOScli1.flows()
- #print "flowHandle = ", flowHandle
- main.log.info("flows:" +flowHandle)
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
- 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 between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
- Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "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("Host intents have not ben installed correctly. Cleaning up")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Host intents have been installed correctly")
-
- case6_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case6_result,
- onpass="Host intent addition and Pingall Test successful",
- onfail="Host intent addition and Pingall Test NOT successful")
-
-
- def CASE7 (self,main):
-
- ONOS1_ip = main.params['CTRL']['ip1']
-
- link_sleep = int(main.params['timers']['LinkDiscovery'])
-
- main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
- main.log.report("__________________________________")
- 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.ONOScli1.topology()
- topology_result = main.ONOSbench.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.ONOScli2.topology()
- Link_Down = main.ONOSbench.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.ONOScli2.topology()
- Link_Up = main.ONOSbench.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")
- main.case ("Testing Mininet topology with the topology of multi instances ONOS")
- main.step("Collecting topology information from ONOS")
- devices1 = main.ONOScli1.devices()
- devices2 = main.ONOScli2.devices()
- devices3 = main.ONOScli3.devices()
- print "devices1 = ", devices1
- print "devices2 = ", devices2
- print "devices3 = ", devices3
- hosts1 = main.ONOScli1.hosts()
- hosts2 = main.ONOScli2.hosts()
- hosts3 = main.ONOScli3.hosts()
- #print "hosts1 = ", hosts1
- #print "hosts2 = ", hosts2
- #print "hosts3 = ", hosts3
- ports1 = main.ONOScli1.ports()
- ports2 = main.ONOScli2.ports()
- ports3 = main.ONOScli3.ports()
- #print "ports1 = ", ports1
- #print "ports2 = ", ports2
- #print "ports3 = ", ports3
- links1 = main.ONOScli1.links()
- links2 = main.ONOScli2.links()
- links3 = main.ONOScli3.links()
- #print "links1 = ", links1
- #print "links2 = ", links2
- #print "links3 = ", links3
-
- 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")
-
- switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
- print "switches_Result1 = ", switches_results1
- 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")
-
- switches_results3 = main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
- utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
- onpass="ONOS3 Switches view is correct",
- onfail="ONOS3 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")
-
- ports_results3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
- utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
- onpass="ONOS3 Ports view is correct",
- onfail="ONOS3 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")
-
- links_results3 = main.Mininet1.compare_links(MNTopo, json.loads(links3))
- utilities.assert_equals(expect=main.TRUE, actual=links_results3,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect")
-
- #topo_result = switches_results1 and switches_results2 and switches_results3\
- #and ports_results1 and ports_results2 and ports_results3\
- #and links_results1 and links_results2 and links_results3
-
- topo_result = switches_results1 and switches_results2 and switches_results3\
- and links_results1 and links_results2 and links_results3
-
- utilities.assert_equals(expect=main.TRUE, actual=topo_result and Link_Up and Link_Down,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful")
-
-
- def CASE8(self):
- '''
- Intent removal
- '''
- main.log.report("This testcase removes host any previously added intents")
- main.log.report("__________________________________")
- main.log.info("Removing any previously installed intents")
- main.case("Removing intents")
- main.step("Obtain the intent id's")
- intent_result = main.ONOScli1.intents(json_format = False)
-
- intent_linewise = intent_result.split("\n")
- intentList = []
- for line in intent_linewise:
- if line.startswith("id="):
- intentList.append(line)
-
- intentids = []
- for line in intentList:
- intentids.append(line.split(",")[0].split("=")[1])
- for id in intentids:
- main.log.info("id = " +id)
-
- main.step("Iterate through the intentids list and remove each intent")
- for id in intentids:
- main.ONOScli1.remove_intent(intent_id = id)
-
- intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info("intent_result = " +intent_result)
- case8_result = main.TRUE
-
- i = 8
- Ping_Result = main.TRUE
- 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.TRUE:
- i = 19
- Ping_Result = main.TRUE
- elif ping==main.FALSE:
- i+=1
- Ping_Result = main.FALSE
- else:
- main.log.info("Unknown error")
- Ping_Result = main.ERROR
-
- #Note: If the ping result failed, that means the intents have been withdrawn correctly.
- if Ping_Result==main.TRUE:
- main.log.report("Host intents have not been withdrawn correctly")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.FALSE:
- main.log.report("Host intents have been withdrawn correctly")
-
- case8_result = case8_result and Ping_Result
-
- if case8_result == main.FALSE:
- main.log.report("Intent removal successful")
- else:
- main.log.report("Intent removal failed")
-
- utilities.assert_equals(expect=main.FALSE, actual=case8_result,
- onpass="Intent removal test failed",
- onfail="Intent removal test successful")
-
-
- def CASE9(self):
- '''
- This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case.
- Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows
- '''
- main.log.report("This testcase adds point intents and then does pingall")
- main.log.report("__________________________________")
- main.log.info("Adding point intents")
- main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
- main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info("Point to point intent install successful")
- #main.log.info(get_intent_result)
-
- print("_______________________________________________________________________________________")
-
- flowHandle = main.ONOScli1.flows()
- #print "flowHandle = ", flowHandle
- main.log.info("flows :" + flowHandle)
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
- 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 between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
- Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "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("Ping all test after Point intents addition failed. Cleaning up")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all test after Point intents addition successful")
-
- case8_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case8_result,
- onpass="Ping all test after Point intents addition successful",
- onfail="Ping all test after Point intents addition failed")
-
- def CASE31(self):
- '''
- This test case adds point intent related to SDN-IP matching on ICMP (ethertype=IPV4, ipProto=1)
- '''
- import json
-
- main.log.report("This test case adds point intent related to SDN-IP matching on ICMP")
- main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP")
- main.step("Adding bidirectional point intent")
- #add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1 of:0000000000003008/1 of:0000000000006018/1
-
- hosts_json = json.loads(main.ONOScli1.hosts())
- for i in range(8,11):
- main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- host1_id = main.ONOScli1.get_host(host1)['id']
- host2_id = main.ONOScli1.get_host(host2)['id']
- for host in hosts_json:
- if host['id'] == host1_id:
- ip1 = host['ips'][0]
- ip1 = str(ip1+"/32")
- device1 = host['location']['device']
- device1 = str(device1+"/1")
- elif host['id'] == host2_id:
- ip2 = str(host['ips'][0])+"/32"
- device2 = host['location']["device"]
- device2 = str(device2+"/1")
-
- p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
-
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info(get_intent_result)
-
- p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
-
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info(get_intent_result)
- if (p_intent_result1 and p_intent_result2) == main.TRUE:
- #get_intent_result = main.ONOScli1.intents()
- #main.log.info(get_intent_result)
- main.log.info("Point intent related to SDN-IP matching on ICMP install successful")
-
- time.sleep(15)
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info("intents = "+ get_intent_result)
- get_flows_result = main.ONOScli1.flows()
- main.log.info("flows = " + get_flows_result)
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
- while i <11 :
- 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 <3:
- 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 between h" + str(i) + " and h" + str(i+10) +"have failed")
- i=19
- Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "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("Ping test after Point intents related to SDN-IP matching on ICMP failed.")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful")
-
- case31_result = Ping_Result and p_intent_result1 and p_intent_result2
- utilities.assert_equals(expect=main.TRUE, actual=case31_result,
- onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
- onfail="Point intent related to SDN-IP matching on ICMP and ping test failed")
-
- def CASE32(self):
- '''
- This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001)
- Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
- '''
- import json
-
- main.log.report("This test case adds point intent related to SDN-IP matching on TCP")
- main.case("Adding bidirectional point intent related to SDN-IP matching on TCP")
- main.step("Adding bidirectional point intent")
- """
- add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1
-
- add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1
-
- add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1
-
- add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1
-
- """
-
- hosts_json = json.loads(main.ONOScli1.hosts())
- for i in range(8,9):
- main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
- host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
- host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
- host1_id = main.ONOScli1.get_host(host1)['id']
- host2_id = main.ONOScli1.get_host(host2)['id']
- for host in hosts_json:
- if host['id'] == host1_id:
- ip1 = host['ips'][0]
- ip1 = str(ip1+"/32")
- device1 = host['location']['device']
- device1 = str(device1+"/1")
- elif host['id'] == host2_id:
- ip2 = str(host['ips'][0])+"/32"
- device2 = host['location']["device"]
- device2 = str(device2+"/1")
-
- p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
- p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
-
- p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
- p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
- ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
-
- p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
- if p_intent_result ==main.TRUE:
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info(get_intent_result)
- main.log.info("Point intent related to SDN-IP matching on TCP install successful")
-
- iperf_result = main.Mininet1.iperf('h8', 'h18')
- if iperf_result == main.TRUE:
- main.log.report("iperf test successful")
- else:
- main.log.report("iperf test failed")
-
-
- case32_result = p_intent_result and iperf_result
- utilities.assert_equals(expect=main.TRUE, actual=case32_result,
- onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
- onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed")
-
-
- def CASE33(self):
- '''
- This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
- Here the mac address to be rewritten is the mac address of the egress device
- '''
- import json
- import time
-
- main.log.report("This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action")
- main.case("Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip")
- main.step("Adding bidirectional multipoint to singlepoint intent")
- """
- add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
-
- add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
- """
-
- main.case("Installing multipoint to single point intent with rewrite mac address")
- main.step("Uninstalling proxy arp app")
- #Unistall onos-app-proxyarp app to disable reactive forwarding
- appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-proxyarp")
- appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-proxyarp")
- appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-proxyarp")
- main.log.info("onos-app-proxyarp uninstalled")
-
- main.step("Changing ipaddress of hosts h8,h9 and h18")
- main.Mininet1.changeIP(host='h8', intf='h8-eth0', newIP='10.0.1.1', newNetmask='255.255.255.0')
- main.Mininet1.changeIP(host='h9', intf='h9-eth0', newIP='10.0.2.1', newNetmask='255.255.255.0')
- main.Mininet1.changeIP(host='h10', intf='h10-eth0', newIP='10.0.3.1', newNetmask='255.255.255.0')
-
- main.step("Changing default gateway of hosts h8,h9 and h18")
- main.Mininet1.changeDefaultGateway(host='h8', newGW='10.0.1.254')
- main.Mininet1.changeDefaultGateway(host='h9', newGW='10.0.2.254')
- main.Mininet1.changeDefaultGateway(host='h10', newGW='10.0.3.254')
-
- main.step("Assigning random mac address to the default gateways since proxyarp app is uninstalled")
- main.Mininet1.addStaticMACAddress(host='h8', GW='10.0.1.254', macaddr='00:00:00:00:11:11')
- main.Mininet1.addStaticMACAddress(host='h9', GW='10.0.2.254', macaddr='00:00:00:00:22:22')
- main.Mininet1.addStaticMACAddress(host='h10', GW='10.0.3.254', macaddr='00:00:00:00:33:33')
-
- main.step("Verify static gateway and MAC address assignment")
- main.Mininet1.verifyStaticGWandMAC(host='h8')
- main.Mininet1.verifyStaticGWandMAC(host='h9')
- main.Mininet1.verifyStaticGWandMAC(host='h10')
-
- main.step("Adding multipoint to singlepoint intent")
- p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device1'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],
- egress_device=main.params['MULTIPOINT_INTENT']['device3'], ipDst=main.params['MULTIPOINT_INTENT']['ip1'], setEthDst=main.params['MULTIPOINT_INTENT']['mac1'])
-
- p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device3'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],
- egress_device=main.params['MULTIPOINT_INTENT']['device1'], ipDst=main.params['MULTIPOINT_INTENT']['ip2'], setEthDst=main.params['MULTIPOINT_INTENT']['mac2'])
-
-
- get_intent_result = main.ONOScli1.intents(json_format = False)
- main.log.info("intents = "+ get_intent_result)
-
- time.sleep(10)
- get_flows_result = main.ONOScli1.flows(json_format = False)
- main.log.info("flows = " + get_flows_result)
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
-
- main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+2))
- ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+2))
- if ping == main.FALSE and count <3:
- count+=1
- Ping_Result = main.FALSE
- main.log.report("Ping between h" + str(i) + " and h" + str(i+2) + " failed. Making attempt number "+str(count) + " in 2 seconds")
- time.sleep(2)
- elif ping==main.FALSE:
- main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
- Ping_Result = main.FALSE
- elif ping==main.TRUE:
- main.log.info("Ping test between h" + str(i) + " and h" + str(i+2) + "passed!")
- Ping_Result = main.TRUE
- else:
- main.log.info("Unknown error")
- Ping_Result = main.ERROR
-
- if Ping_Result==main.FALSE:
- main.log.report("Ping test failed.")
- #main.cleanup()
- #main.exit()
- if Ping_Result==main.TRUE:
- main.log.report("Ping all successful")
-
-
- p_intent_result = p_intent_result1 and p_intent_result2
- if p_intent_result ==main.TRUE:
- main.log.info("Multi point intent with rewrite mac address installation successful")
- else:
- main.log.info("Multi point intent with rewrite mac address installation failed")
-
- case33_result = p_intent_result and Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case33_result,
- onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
- onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed")
diff --git a/TestON/tests/MultiProd/MultiProd.bak1 b/TestON/tests/MultiProd/MultiProd.bak1
deleted file mode 100644
index 6b67f63..0000000
--- a/TestON/tests/MultiProd/MultiProd.bak1
+++ /dev/null
@@ -1,1523 +0,0 @@
-
-# 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 MultiProd:
-
- def __init__( self ):
- self.default = ''
-
- def CASE1( self, main ):
- """
- Startup sequence:
- cell <name>
- onos-verify-cell
- onos-remove-raft-logs
- git pull
- mvn clean install
- onos-package
- onos-install -f
- onos-wait-for-start
- """
- cell_name = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
- ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
- ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
-
- main.case( "Setting up test environment" )
- main.log.report(
- "This testcase is testing setting up test environment" )
- main.log.report( "__________________________________" )
-
- main.step( "Applying cell variable to environment" )
- cell_result1 = main.ONOSbench.set_cell( cell_name )
- #cell_result2 = main.ONOScli1.set_cell( cell_name )
- #cell_result3 = main.ONOScli2.set_cell( cell_name )
- #cell_result4 = main.ONOScli3.set_cell( cell_name )
- verify_result = main.ONOSbench.verify_cell()
- cell_result = cell_result1
-
- main.step( "Removing raft logs before a clen installation of ONOS" )
- remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
-
- 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( report=True )
-
- if git_pull_result == 1:
- 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 a cell" )
- # cell_create_result = main.ONOSbench.create_cell_file( **************
- # )
-
- 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 )
- onos3_install_result = main.ONOSbench.onos_install(
- options="-f",
- node=ONOS3_ip )
- onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result
- if onos_install_result == main.TRUE:
- main.log.report( "Installing ONOS package successful" )
- else:
- main.log.report( "Installing ONOS package failed" )
-
- onos1_isup = main.ONOSbench.isup( ONOS1_ip )
- onos2_isup = main.ONOSbench.isup( ONOS2_ip )
- onos3_isup = main.ONOSbench.isup( ONOS3_ip )
- onos_isup = onos1_isup and onos2_isup and onos3_isup
- if onos_isup == main.TRUE:
- main.log.report( "ONOS instances are up and ready" )
- else:
- main.log.report( "ONOS instances may not be up" )
-
- main.step( "Starting ONOS service" )
- start_result = main.TRUE
- #start_result = main.ONOSbench.onos_start( ONOS1_ip )
- startcli1 = main.ONOScli1.start_onos_cli( ONOS_ip=ONOS1_ip )
- startcli2 = main.ONOScli2.start_onos_cli( ONOS_ip=ONOS2_ip )
- startcli3 = main.ONOScli3.start_onos_cli( ONOS_ip=ONOS3_ip )
- print startcli1
- print startcli2
- print startcli3
-
- case1_result = ( package_result and
- cell_result and verify_result and onos_install_result and
- onos_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' ]
- ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
-
- main.case( "Cleaning up test environment" )
-
- main.step( "Testing ONOS kill function" )
- kill_result1 = main.ONOSbench.onos_kill( ONOS1_ip )
- kill_result2 = main.ONOSbench.onos_kill( ONOS2_ip )
- kill_result3 = main.ONOSbench.onos_kill( ONOS3_ip )
-
- main.step( "Stopping ONOS service" )
- stop_result1 = main.ONOSbench.onos_stop( ONOS1_ip )
- stop_result2 = main.ONOSbench.onos_stop( ONOS2_ip )
- stop_result3 = main.ONOSbench.onos_stop( ONOS3_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' ]
- ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
-
- 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 )
- cmd_result2 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr1 )
- main.log.info( "onos command returned: " + cmd_result2 )
- cmd_result3 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr1 )
- main.log.info( "onos command returned: " + cmd_result3 )
-
- main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
- cmdstr2 = "onos:topology"
- cmd_result4 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
- main.log.info( "onos command returned: " + cmd_result4 )
- cmd_result5 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr2 )
- main.log.info( "onos command returned: " + cmd_result5 )
- cmd_result6 = main.ONOSbench.onos_cli( ONOS6_ip, cmdstr2 )
- main.log.info( "onos command returned: " + cmd_result6 )
-
- def CASE4( self, main ):
- import re
- import time
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
- ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
- ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
-
- main.log.report(
- "This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode" )
- main.log.report( "__________________________________" )
- main.case( "Pingall Test(No intents are added)" )
- main.step( "Assigning switches to controllers" )
- for i in range( 1, 29 ): # 1 to ( num of switches +1 )
- main.Mininet1.assign_sw_controller(
- sw=str( i ),
- count=3,
- ip1=ONOS1_ip,
- port1=ONOS1_port,
- ip2=ONOS2_ip,
- port2=ONOS2_port,
- ip3=ONOS3_ip,
- port3=ONOS3_port )
-
- switch_mastership = main.TRUE
- for i in range( 1, 29 ):
- 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( "Controller assignment successfull" )
- else:
- main.log.report( "Controller assignment failed" )
- # 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
- if ping_result == main.TRUE:
- main.log.report(
- "Pingall Test in reactive mode to discover the hosts successful" )
- else:
- main.log.report(
- "Pingall Test in reactive mode to discover the hosts failed" )
-
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case4_result,
- onpass="Controller assignment and Pingall Test successful",
- onfail="Controller assignment and Pingall Test NOT successful" )
-
- def CASE5( self, main ):
- import json
- from subprocess import Popen, PIPE
- # assumes that sts is already in you PYTHONPATH
- from sts.topology.teston_topology import TestONTopology
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
-
- main.log.report(
- "This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes" )
- main.log.report( "__________________________________" )
- main.case(
- "Testing Mininet topology with the topology of multi instances ONOS" )
- main.step( "Collecting topology information from ONOS" )
- devices1 = main.ONOScli1.devices()
- devices2 = main.ONOScli2.devices()
- devices3 = main.ONOScli3.devices()
- # print "devices1 = ", devices1
- # print "devices2 = ", devices2
- # print "devices3 = ", devices3
- hosts1 = main.ONOScli1.hosts()
- hosts2 = main.ONOScli2.hosts()
- hosts3 = main.ONOScli3.hosts()
- # print "hosts1 = ", hosts1
- # print "hosts2 = ", hosts2
- # print "hosts3 = ", hosts3
- ports1 = main.ONOScli1.ports()
- ports2 = main.ONOScli2.ports()
- ports3 = main.ONOScli3.ports()
- # print "ports1 = ", ports1
- # print "ports2 = ", ports2
- # print "ports3 = ", ports3
- links1 = main.ONOScli1.links()
- links2 = main.ONOScli2.links()
- links3 = main.ONOScli3.links()
- # print "links1 = ", links1
- # print "links2 = ", links2
- # print "links3 = ", links3
-
- 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" )
-
- switches_results1 = main.Mininet1.compare_switches(
- MNTopo,
- json.loads( devices1 ) )
- print "switches_Result1 = ", switches_results1
- 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" )
-
- switches_results3 = main.Mininet1.compare_switches(
- MNTopo,
- json.loads( devices3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
- onpass="ONOS3 Switches view is correct",
- onfail="ONOS3 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" )
-
- ports_results3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
- onpass="ONOS3 Ports view is correct",
- onfail="ONOS3 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" )
-
- links_results3 = main.Mininet1.compare_links(
- MNTopo,
- json.loads( links3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=links_results3,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect" )
-
- #topo_result = switches_results1 and switches_results2 and switches_results3\
- # and ports_results1 and ports_results2 and ports_results3\
- # and links_results1 and links_results2 and links_results3
-
- topo_result = switches_results1 and switches_results2 and switches_results3\
- and links_results1 and links_results2 and links_results3
-
- if topo_result == main.TRUE:
- main.log.report(
- "Topology Check Test with mininet and ONOS instances successful" )
- else:
- main.log.report(
- "Topology Check Test with mininet and ONOS instances failed" )
-
- utilities.assert_equals( expect=main.TRUE, actual=topo_result,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
-
- def CASE10( self ):
- main.log.report(
- "This testcase uninstalls the reactive forwarding app" )
- main.log.report( "__________________________________" )
- main.case( "Uninstalling reactive forwarding app" )
- # Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result1 = main.ONOScli1.feature_uninstall(
- "onos-app-fwd" )
- appUninstall_result2 = main.ONOScli2.feature_uninstall(
- "onos-app-fwd" )
- appUninstall_result3 = main.ONOScli3.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 )
-
- hosts = main.ONOScli1.hosts()
- main.log.info( hosts )
-
- case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case10_result,
- onpass="Reactive forwarding app uninstallation successful",
- onfail="Reactive forwarding app uninstallation failed" )
-
- def CASE6( self ):
- main.log.report(
- "This testcase is testing the addition of host intents and then doing pingall" )
- main.log.report( "__________________________________" )
- main.case( "Obtaining hostsfor adding host intents" )
- main.step( "Get hosts" )
- hosts = main.ONOScli1.hosts()
- main.log.info( hosts )
-
- main.step( "Get all devices id" )
- devices_id_list = main.ONOScli1.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 intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
- hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
- """
- for i in range( 8, 18 ):
- main.log.info(
- "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
- host1 = "00:00:00:00:00:" + \
- str( hex( i )[ 2: ] ).zfill( 2 ).upper()
- host2 = "00:00:00:00:00:" + \
- str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- # NOTE: get host can return None
- # TODO: handle this
- host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
- host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
- tmp_result = main.ONOScli1.add_host_intent( host1_id, host2_id )
-
- flowHandle = main.ONOScli1.flows()
- # print "flowHandle = ", flowHandle
- main.log.info( "flows:" + flowHandle )
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
- 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 between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "have failed" )
- i = 19
- Ping_Result = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "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(
- "Host intents have not ben installed correctly. Cleaning up" )
- # main.cleanup()
- # main.exit()
- if Ping_Result == main.TRUE:
- main.log.report( "Host intents have been installed correctly" )
-
- case6_result = Ping_Result
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case6_result,
- onpass="Host intent addition and Pingall Test successful",
- onfail="Host intent addition and Pingall Test NOT successful" )
-
- def CASE7( self, main ):
-
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
-
- link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
-
- main.log.report(
- "This testscase is killing a link to ensure that link discovery is consistent" )
- main.log.report( "__________________________________" )
- 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.ONOScli1.topology()
- topology_result = main.ONOSbench.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.ONOScli2.topology()
- Link_Down = main.ONOSbench.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.ONOScli2.topology()
- Link_Up = main.ONOSbench.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" )
- main.case(
- "Testing Mininet topology with the topology of multi instances ONOS" )
- main.step( "Collecting topology information from ONOS" )
- devices1 = main.ONOScli1.devices()
- devices2 = main.ONOScli2.devices()
- devices3 = main.ONOScli3.devices()
- print "devices1 = ", devices1
- print "devices2 = ", devices2
- print "devices3 = ", devices3
- hosts1 = main.ONOScli1.hosts()
- hosts2 = main.ONOScli2.hosts()
- hosts3 = main.ONOScli3.hosts()
- # print "hosts1 = ", hosts1
- # print "hosts2 = ", hosts2
- # print "hosts3 = ", hosts3
- ports1 = main.ONOScli1.ports()
- ports2 = main.ONOScli2.ports()
- ports3 = main.ONOScli3.ports()
- # print "ports1 = ", ports1
- # print "ports2 = ", ports2
- # print "ports3 = ", ports3
- links1 = main.ONOScli1.links()
- links2 = main.ONOScli2.links()
- links3 = main.ONOScli3.links()
- # print "links1 = ", links1
- # print "links2 = ", links2
- # print "links3 = ", links3
-
- 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" )
-
- switches_results1 = main.Mininet1.compare_switches(
- MNTopo,
- json.loads( devices1 ) )
- print "switches_Result1 = ", switches_results1
- 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" )
-
- switches_results3 = main.Mininet1.compare_switches(
- MNTopo,
- json.loads( devices3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
- onpass="ONOS3 Switches view is correct",
- onfail="ONOS3 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" )
-
- ports_results3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
- onpass="ONOS3 Ports view is correct",
- onfail="ONOS3 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" )
-
- links_results3 = main.Mininet1.compare_links(
- MNTopo,
- json.loads( links3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=links_results3,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect" )
-
- #topo_result = switches_results1 and switches_results2 and switches_results3\
- # and ports_results1 and ports_results2 and ports_results3\
- # and links_results1 and links_results2 and links_results3
-
- topo_result = switches_results1 and switches_results2 and switches_results3\
- and links_results1 and links_results2 and links_results3
-
- utilities.assert_equals(
- expect=main.TRUE,
- actual=topo_result and Link_Up and Link_Down,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
-
- def CASE8( self ):
- """
- Intent removal
- """
- main.log.report(
- "This testcase removes host any previously added intents" )
- main.log.report( "__________________________________" )
- main.log.info( "Removing any previously installed intents" )
- main.case( "Removing intents" )
- main.step( "Obtain the intent id's" )
- intent_result = main.ONOScli1.intents( json_format=False )
-
- intent_linewise = intent_result.split( "\n" )
- intentList = []
- for line in intent_linewise:
- if line.startswith( "id=" ):
- intentList.append( line )
-
- intentids = []
- for line in intentList:
- intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
- for id in intentids:
- main.log.info( "id = " + id )
-
- main.step(
- "Iterate through the intentids list and remove each intent" )
- for id in intentids:
- main.ONOScli1.remove_intent( intent_id=id )
-
- intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( "intent_result = " + intent_result )
- case8_result = main.TRUE
-
- i = 8
- Ping_Result = main.TRUE
- 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.TRUE:
- i = 19
- Ping_Result = main.TRUE
- elif ping == main.FALSE:
- i += 1
- Ping_Result = main.FALSE
- else:
- main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
-
- # Note: If the ping result failed, that means the intents have been
- # withdrawn correctly.
- if Ping_Result == main.TRUE:
- main.log.report( "Host intents have not been withdrawn correctly" )
- # main.cleanup()
- # main.exit()
- if Ping_Result == main.FALSE:
- main.log.report( "Host intents have been withdrawn correctly" )
-
- case8_result = case8_result and Ping_Result
-
- if case8_result == main.FALSE:
- main.log.report( "Intent removal successful" )
- else:
- main.log.report( "Intent removal failed" )
-
- utilities.assert_equals( expect=main.FALSE, actual=case8_result,
- onpass="Intent removal test failed",
- onfail="Intent removal test successful" )
-
- def CASE9( self ):
- """
- This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case.
- Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows
- """
- main.log.report(
- "This testcase adds point intents and then does pingall" )
- main.log.report( "__________________________________" )
- main.log.info( "Adding point intents" )
- main.case(
- "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
- main.step(
- "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000003008/1",
- "of:0000000000006018/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006018/1",
- "of:0000000000003008/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003009/1",
- "of:0000000000006019/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006019/1",
- "of:0000000000003009/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003010/1",
- "of:0000000000006020/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006020/1",
- "of:0000000000003010/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003011/1",
- "of:0000000000006021/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006021/1",
- "of:0000000000003011/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003012/1",
- "of:0000000000006022/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006022/1",
- "of:0000000000003012/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003013/1",
- "of:0000000000006023/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006023/1",
- "of:0000000000003013/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003014/1",
- "of:0000000000006024/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006024/1",
- "of:0000000000003014/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003015/1",
- "of:0000000000006025/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006025/1",
- "of:0000000000003015/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003016/1",
- "of:0000000000006026/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006026/1",
- "of:0000000000003016/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003017/1",
- "of:0000000000006027/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006027/1",
- "of:0000000000003017/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- print(
- "_______________________________________________________________________________________" )
-
- flowHandle = main.ONOScli1.flows()
- # print "flowHandle = ", flowHandle
- main.log.info( "flows :" + flowHandle )
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
- 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 between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "have failed" )
- i = 19
- Ping_Result = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "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(
- "Ping all test after Point intents addition failed. Cleaning up" )
- # main.cleanup()
- # main.exit()
- if Ping_Result == main.TRUE:
- main.log.report(
- "Ping all test after Point intents addition successful" )
-
- case8_result = Ping_Result
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case8_result,
- onpass="Ping all test after Point intents addition successful",
- onfail="Ping all test after Point intents addition failed" )
-
- def CASE31( self ):
- """
- This test case adds point intent related to SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
- """
- import json
-
- main.log.report(
- "This test case adds point intent related to SDN-IP matching on ICMP" )
- main.case(
- "Adding bidirectional point intent related to SDN-IP matching on ICMP" )
- main.step( "Adding bidirectional point intent" )
- # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
- # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
- # of:0000000000006018/1
-
- hosts_json = json.loads( main.ONOScli1.hosts() )
- for i in range( 8, 11 ):
- main.log.info(
- "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
- host1 = "00:00:00:00:00:" + \
- str( hex( i )[ 2: ] ).zfill( 2 ).upper()
- host2 = "00:00:00:00:00:" + \
- str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
- host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
- for host in hosts_json:
- if host[ 'id' ] == host1_id:
- ip1 = host[ 'ips' ][ 0 ]
- ip1 = str( ip1 + "/32" )
- device1 = host[ 'location' ][ 'device' ]
- device1 = str( device1 + "/1" )
- elif host[ 'id' ] == host2_id:
- ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
- device2 = host[ 'location' ][ "device" ]
- device2 = str( device2 + "/1" )
-
- p_intent_result1 = main.ONOScli1.add_point_intent(
- ingress_device=device1,
- egress_device=device2,
- ipSrc=ip1,
- ipDst=ip2,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
-
- get_intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( get_intent_result )
-
- p_intent_result2 = main.ONOScli1.add_point_intent(
- ingress_device=device2,
- egress_device=device1,
- ipSrc=ip2,
- ipDst=ip1,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
-
- get_intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( get_intent_result )
- if ( p_intent_result1 and p_intent_result2 ) == main.TRUE:
- #get_intent_result = main.ONOScli1.intents()
- # main.log.info( get_intent_result )
- main.log.info(
- "Point intent related to SDN-IP matching on ICMP install successful" )
-
- time.sleep( 15 )
- get_intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( "intents = " + get_intent_result )
- get_flows_result = main.ONOScli1.flows()
- main.log.info( "flows = " + get_flows_result )
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
- while i < 11:
- 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 < 3:
- 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 between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "have failed" )
- i = 19
- Ping_Result = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "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(
- "Ping test after Point intents related to SDN-IP matching on ICMP failed." )
- # main.cleanup()
- # main.exit()
- if Ping_Result == main.TRUE:
- main.log.report(
- "Ping all test after Point intents related to SDN-IP matching on ICMP successful" )
-
- case31_result = Ping_Result and p_intent_result1 and p_intent_result2
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case31_result,
- onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
- onfail="Point intent related to SDN-IP matching on ICMP and ping test failed" )
-
- def CASE32( self ):
- """
- This test case adds point intent related to SDN-IP matching on TCP ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
- Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
- """
- import json
-
- main.log.report(
- "This test case adds point intent related to SDN-IP matching on TCP" )
- main.case(
- "Adding bidirectional point intent related to SDN-IP matching on TCP" )
- main.step( "Adding bidirectional point intent" )
- """
- add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1
-
- add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1
-
- add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1
-
- add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1
-
- """
- hosts_json = json.loads( main.ONOScli1.hosts() )
- for i in range( 8, 9 ):
- main.log.info(
- "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
- host1 = "00:00:00:00:00:" + \
- str( hex( i )[ 2: ] ).zfill( 2 ).upper()
- host2 = "00:00:00:00:00:" + \
- str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
- host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
- for host in hosts_json:
- if host[ 'id' ] == host1_id:
- ip1 = host[ 'ips' ][ 0 ]
- ip1 = str( ip1 + "/32" )
- device1 = host[ 'location' ][ 'device' ]
- device1 = str( device1 + "/1" )
- elif host[ 'id' ] == host2_id:
- ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
- device2 = host[ 'location' ][ "device" ]
- device2 = str( device2 + "/1" )
-
- p_intent_result1 = main.ONOScli1.add_point_intent(
- ingress_device=device1,
- egress_device=device2,
- ipSrc=ip1,
- ipDst=ip2,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
- tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
- p_intent_result2 = main.ONOScli1.add_point_intent(
- ingress_device=device2,
- egress_device=device1,
- ipSrc=ip2,
- ipDst=ip1,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
- tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
-
- p_intent_result3 = main.ONOScli1.add_point_intent(
- ingress_device=device1,
- egress_device=device2,
- ipSrc=ip1,
- ipDst=ip2,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
- tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
- p_intent_result4 = main.ONOScli1.add_point_intent(
- ingress_device=device2,
- egress_device=device1,
- ipSrc=ip2,
- ipDst=ip1,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
- tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
-
- p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
- if p_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( get_intent_result )
- main.log.info(
- "Point intent related to SDN-IP matching on TCP install successful" )
-
- iperf_result = main.Mininet1.iperf( 'h8', 'h18' )
- if iperf_result == main.TRUE:
- main.log.report( "iperf test successful" )
- else:
- main.log.report( "iperf test failed" )
-
- case32_result = p_intent_result and iperf_result
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case32_result,
- onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
- onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed" )
-
- def CASE33( self ):
- """
- This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
- Here the mac address to be rewritten is the mac address of the egress device
- """
- import json
- import time
-
- main.log.report(
- "This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action" )
- main.case(
- "Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip" )
- main.step( "Adding bidirectional multipoint to singlepoint intent" )
- """
- add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
-
- add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
- """
- main.case(
- "Installing multipoint to single point intent with rewrite mac address" )
- main.step( "Uninstalling proxy arp app" )
- # Unistall onos-app-proxyarp app to disable reactive forwarding
- appUninstall_result1 = main.ONOScli1.feature_uninstall(
- "onos-app-proxyarp" )
- appUninstall_result2 = main.ONOScli2.feature_uninstall(
- "onos-app-proxyarp" )
- appUninstall_result3 = main.ONOScli3.feature_uninstall(
- "onos-app-proxyarp" )
- main.log.info( "onos-app-proxyarp uninstalled" )
-
- main.step( "Changing ipaddress of hosts h8,h9 and h18" )
- main.Mininet1.changeIP(
- host='h8',
- intf='h8-eth0',
- newIP='10.0.1.1',
- newNetmask='255.255.255.0' )
- main.Mininet1.changeIP(
- host='h9',
- intf='h9-eth0',
- newIP='10.0.2.1',
- newNetmask='255.255.255.0' )
- main.Mininet1.changeIP(
- host='h10',
- intf='h10-eth0',
- newIP='10.0.3.1',
- newNetmask='255.255.255.0' )
-
- main.step( "Changing default gateway of hosts h8,h9 and h18" )
- main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
- main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
- main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
-
- main.step(
- "Assigning random mac address to the default gateways since proxyarp app is uninstalled" )
- main.Mininet1.addStaticMACAddress(
- host='h8',
- GW='10.0.1.254',
- macaddr='00:00:00:00:11:11' )
- main.Mininet1.addStaticMACAddress(
- host='h9',
- GW='10.0.2.254',
- macaddr='00:00:00:00:22:22' )
- main.Mininet1.addStaticMACAddress(
- host='h10',
- GW='10.0.3.254',
- macaddr='00:00:00:00:33:33' )
-
- main.step( "Verify static gateway and MAC address assignment" )
- main.Mininet1.verifyStaticGWandMAC( host='h8' )
- main.Mininet1.verifyStaticGWandMAC( host='h9' )
- main.Mininet1.verifyStaticGWandMAC( host='h10' )
-
- main.step( "Adding multipoint to singlepoint intent" )
- p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
- ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
- ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
- egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
- ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
- setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
-
- p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
- ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
- ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
- egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
- ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
- setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
-
- get_intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( "intents = " + get_intent_result )
-
- time.sleep( 10 )
- get_flows_result = main.ONOScli1.flows( json_format=False )
- main.log.info( "flows = " + get_flows_result )
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
-
- main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
- ping = main.Mininet1.pingHost(
- src="h" + str( i ), target="h" + str( i + 2 ) )
- if ping == main.FALSE and count < 3:
- count += 1
- Ping_Result = main.FALSE
- main.log.report( "Ping between h" +
- str( i ) +
- " and h" +
- str( i +
- 2 ) +
- " failed. Making attempt number " +
- str( count ) +
- " in 2 seconds" )
- time.sleep( 2 )
- elif ping == main.FALSE:
- main.log.report( "All ping attempts between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "have failed" )
- Ping_Result = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
- str( i ) +
- " and h" +
- str( i +
- 2 ) +
- "passed!" )
- Ping_Result = main.TRUE
- else:
- main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
-
- if Ping_Result == main.FALSE:
- main.log.report( "Ping test failed." )
- # main.cleanup()
- # main.exit()
- if Ping_Result == main.TRUE:
- main.log.report( "Ping all successful" )
-
- p_intent_result = p_intent_result1 and p_intent_result2
- if p_intent_result == main.TRUE:
- main.log.info(
- "Multi point intent with rewrite mac address installation successful" )
- else:
- main.log.info(
- "Multi point intent with rewrite mac address installation failed" )
-
- case33_result = p_intent_result and Ping_Result
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case33_result,
- onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
- onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed" )
diff --git a/TestON/tests/MultiProd/MultiProd.params b/TestON/tests/MultiProd/MultiProd.params
index 6e5c85e..4818d09 100755
--- a/TestON/tests/MultiProd/MultiProd.params
+++ b/TestON/tests/MultiProd/MultiProd.params
@@ -1,7 +1,6 @@
<PARAMS>
- <testcases>1,4,10,5,6,7,8,6,8,9,8,31,32,8,33,8</testcases>
-
+ <testcases>1,4,10,5,6,7,8,6,8,9,8,31,32,8,33,8</testcases>
#Environment variables
<ENV>
<cellName>multi_test</cellName>
diff --git a/TestON/tests/MultiProd/MultiProd.py b/TestON/tests/MultiProd/MultiProd.py
index d3ed757..aac631f 100644
--- a/TestON/tests/MultiProd/MultiProd.py
+++ b/TestON/tests/MultiProd/MultiProd.py
@@ -55,7 +55,7 @@
main.step( "Git checkout, pull and get version" )
#main.ONOSbench.gitCheckout( "master" )
gitPullResult = main.ONOSbench.gitPull()
- print "git_pull_result = ", gitPullResult
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
versionResult = main.ONOSbench.getVersion( report=True )
if gitPullResult == 1:
@@ -106,6 +106,12 @@
print startcli2
print startcli3
+ # Starting the mininet using the old way
+ main.step( "Starting Mininet ..." )
+ netIsUp = main.Mininet1.startNet()
+ if netIsUp:
+ main.log.info("Mininet CLI is up")
+
case1Result = ( packageResult and
cellResult and verifyResult and onosInstallResult and
onosIsup and startResult )
@@ -242,7 +248,7 @@
ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
main.log.report(
- "This testcase is testing if all ONOS nodes are in topologyi" +
+ "This testcase is testing if all ONOS nodes are in topology" +
" sync with mininet and its peer ONOS nodes" )
main.log.report( "__________________________________" )
main.case(
@@ -631,10 +637,8 @@
main.step( "Determine the current number of switches and links" )
topologyOutput = main.ONOScli1.topology()
topologyResult = main.ONOSbench.getTopology( topologyOutput )
- activeSwitches = topologyResult[ 'devices' ]
- links = topologyResult[ 'links' ]
- print "activeSwitches = ", type( activeSwitches )
- print "links = ", type( links )
+ activeSwitches = topologyResult[ 'deviceCount' ]
+ links = topologyResult[ 'linkCount' ]
main.log.info(
"Currently there are %s switches and %s links" %
( str( activeSwitches ), str( links ) ) )
@@ -1529,39 +1533,54 @@
main.Mininet1.verifyStaticGWandMAC( host='h9' )
main.Mininet1.verifyStaticGWandMAC( host='h10' )
+ ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ]
+ ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
+ ingressDeviceList = []
+ ingressDeviceList.append( ingressDevice1 )
+ ingressDeviceList.append( ingressDevice2 )
+
main.step( "Adding multipoint to singlepoint intent" )
pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
- ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
- ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+ ingressDeviceList,
egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
+ ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ]
+ ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
+ ingressDeviceList = [ingressDevice1, ingressDevice2]
+
pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
- ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
- ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+ ingressDeviceList,
egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
- getIntentResult = main.ONOScli1.intents( jsonFormat=False )
- main.log.info( "intents = " + getIntentResult )
+ pIntentResult = pIntentResult1 and pIntentResult2
+ if pIntentResult == main.FALSE:
+ main.log.info(
+ "Multi point to single point intent " +
+ "installation failed" )
+ else:
+ pIntentResult = main.TRUE
+ getIntentResult = main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "intents = " + getIntentResult )
- time.sleep( 10 )
- getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
- main.log.info( "flows = " + getFlowsResult )
+ time.sleep( 10 )
+ getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
+ main.log.info( "flows = " + getFlowsResult )
- count = 1
- i = 8
- PingResult = main.TRUE
+ count = 1
+ i = 8
+ PingResult = main.TRUE
- main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
- ping = main.Mininet1.pingHost(
+ main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
+ ping = main.Mininet1.pingHost(
src="h" + str( i ), target="h" + str( i + 2 ) )
- if ping == main.FALSE and count < 3:
- count += 1
- PingResult = main.FALSE
- main.log.report( "Ping between h" +
+ if ping == main.FALSE and count < 3:
+ count += 1
+ PingResult = main.FALSE
+ main.log.report( "Ping between h" +
str( i ) +
" and h" +
str( i +
@@ -1569,43 +1588,38 @@
" failed. Making attempt number " +
str( count ) +
" in 2 seconds" )
- time.sleep( 2 )
- elif ping == main.FALSE:
- main.log.report( "All ping attempts between h" +
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
str( i ) +
" and h" +
str( i +
10 ) +
"have failed" )
- PingResult = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
str( i ) +
" and h" +
str( i +
2 ) +
"passed!" )
- PingResult = main.TRUE
- else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
- if PingResult == main.FALSE:
- main.log.report( "Ping test failed." )
- # main.cleanup()
- # main.exit()
- if PingResult == main.TRUE:
- main.log.report( "Ping all successful" )
+ if PingResult == main.FALSE:
+ main.log.report( "Ping test failed." )
+ # main.cleanup()
+ # main.exit()
+ if PingResult == main.TRUE:
+ main.log.report( "Ping all successful" )
- pIntentResult = pIntentResult1 and pIntentResult2
if pIntentResult == main.TRUE:
main.log.info(
"Multi point intent with rewrite mac " +
- "address installation successful" )
- else:
- main.log.info(
- "Multi point intent with rewrite mac" +
- " address installation failed" )
+ "address installation and ping successful" )
case33Result = pIntentResult and PingResult
utilities.assertEquals(
diff --git a/TestON/tests/MultiProd/MultiProd.py.fixed b/TestON/tests/MultiProd/MultiProd.py.fixed
deleted file mode 100644
index e0e772a..0000000
--- a/TestON/tests/MultiProd/MultiProd.py.fixed
+++ /dev/null
@@ -1,1566 +0,0 @@
-
-# Testing the basic functionality of ONOS Next
-# For sanity and driver functionality excercises only.
-
-import time
-import json
-
-time.sleep( 1 )
-
-
-class MultiProd:
-
- def __init__( self ):
- self.default = ''
-
- def CASE1( self, main ):
- """
- Startup sequence:
- cell <name>
- onos-verify-cell
- onos-remove-raft-logs
- git pull
- mvn clean install
- onos-package
- onos-install -f
- onos-wait-for-start
- """
- cell_name = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
-
- main.case( "Setting up test environment" )
- main.log.report(
- "This testcase is testing setting up test environment" )
- main.log.report( "__________________________________" )
-
- main.step( "Applying cell variable to environment" )
- cell_result1 = main.ONOSbench.set_cell( cell_name )
- # cell_result2 = main.ONOScli1.set_cell( cell_name )
- # cell_result3 = main.ONOScli2.set_cell( cell_name )
- # cell_result4 = main.ONOScli3.set_cell( cell_name )
- verify_result = main.ONOSbench.verify_cell()
- cell_result = cell_result1
-
- main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onos_remove_raft_logs()
-
- 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
- main.ONOSbench.get_version( report=True )
-
- if git_pull_result == 1:
- main.step( "Using mvn clean & install" )
- main.ONOSbench.clean_install()
-
- 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" )
- onos1_install_result = main.ONOSbench.onos_install(
- options="-f",
- node=ONOS1_ip )
- onos2_install_result = main.ONOSbench.onos_install(
- options="-f",
- node=ONOS2_ip )
- onos3_install_result = main.ONOSbench.onos_install(
- options="-f",
- node=ONOS3_ip )
- onos_install_result = onos1_install_result and onos2_install_result \
- and onos3_install_result
- if onos_install_result == main.TRUE:
- main.log.report( "Installing ONOS package successful" )
- else:
- main.log.report( "Installing ONOS package failed" )
-
- onos1_isup = main.ONOSbench.isup( ONOS1_ip )
- onos2_isup = main.ONOSbench.isup( ONOS2_ip )
- onos3_isup = main.ONOSbench.isup( ONOS3_ip )
- onos_isup = onos1_isup and onos2_isup and onos3_isup
- if onos_isup == main.TRUE:
- main.log.report( "ONOS instances are up and ready" )
- else:
- main.log.report( "ONOS instances may not be up" )
-
- main.step( "Starting ONOS service" )
- start_result = main.TRUE
- # start_result = main.ONOSbench.onos_start( ONOS1_ip )
- startcli1 = main.ONOScli1.start_onos_cli( ONOS_ip=ONOS1_ip )
- startcli2 = main.ONOScli2.start_onos_cli( ONOS_ip=ONOS2_ip )
- startcli3 = main.ONOScli3.start_onos_cli( ONOS_ip=ONOS3_ip )
- print startcli1
- print startcli2
- print startcli3
-
- case1_result = ( package_result and cell_result and
- verify_result and onos_install_result
- and onos_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' ]
- ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
-
- main.case( "Cleaning up test environment" )
-
- main.step( "Testing ONOS kill function" )
- kill_result1 = main.ONOSbench.onos_kill( ONOS1_ip )
- kill_result2 = main.ONOSbench.onos_kill( ONOS2_ip )
- kill_result3 = main.ONOSbench.onos_kill( ONOS3_ip )
- kill_result = kill_result1 and kill_result2 and kill_result3
-
- main.step( "Stopping ONOS service" )
- stop_result1 = main.ONOSbench.onos_stop( ONOS1_ip )
- stop_result2 = main.ONOSbench.onos_stop( ONOS2_ip )
- stop_result3 = main.ONOSbench.onos_stop( ONOS3_ip )
- stop_result = stop_result1 and stop_result2 and stop_result3
-
- main.step( "Uninstalling ONOS service" )
- uninstall_result = main.ONOSbench.onos_uninstall()
-
- case11_result = kill_result and stop_result and uninstall_result
- utilities.assert_equals( expect=main.TRUE, actual=case11_result,
- onpass="Cleanup successful",
- onfail="Cleanup failed" )
-
- def CASE3( self, main ):
- """
- Test 'onos' command and its functionality in driver
- """
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
-
- 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 )
- cmd_result2 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr1 )
- main.log.info( "onos command returned: " + cmd_result2 )
- cmd_result3 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr1 )
- main.log.info( "onos command returned: " + cmd_result3 )
-
- main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
- cmdstr2 = "onos:topology"
- cmd_result4 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
- main.log.info( "onos command returned: " + cmd_result4 )
- cmd_result5 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr2 )
- main.log.info( "onos command returned: " + cmd_result5 )
- cmd_result6 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr2 )
- main.log.info( "onos command returned: " + cmd_result6 )
-
- def CASE4( self, main ):
- import re
- import time
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
- ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
- ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
-
- main.log.report(
- "This testcase is testing the assignment of all the switches to \
- all controllers and discovering the hosts in reactive mode" )
- main.log.report( "__________________________________" )
- main.case( "Pingall Test(No intents are added)" )
- main.step( "Assigning switches to controllers" )
- for i in range( 1, 29 ): # 1 to ( num of switches +1 )
- main.Mininet1.assign_sw_controller(
- sw=str( i ),
- count=3,
- ip1=ONOS1_ip,
- port1=ONOS1_port,
- ip2=ONOS2_ip,
- port2=ONOS2_port,
- ip3=ONOS3_ip,
- port3=ONOS3_port )
-
- switch_mastership = main.TRUE
- for i in range( 1, 29 ):
- 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( "Controller assignment successfull" )
- else:
- main.log.report( "Controller assignment failed" )
- # 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
- if ping_result == main.TRUE:
- main.log.report( "Pingall Test in reactive mode to discover \
- the hosts successful" )
- else:
- main.log.report( "Pingall Test in reactive mode to discover \
- the hosts failed" )
-
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case4_result,
- onpass="Controller assignment and Pingall Test successful",
- onfail="Controller assignment and Pingall Test NOT successful" )
-
- def CASE5( self, main ):
- import json
- from subprocess import Popen, PIPE
- # assumes that sts is already in you PYTHONPATH
- from sts.topology.teston_topology import TestONTopology
-
- main.log.report( "This testcase is testing if all ONOS nodes are in \
- topology sync with mininet and its peer ONOS nodes" )
- main.log.report( "__________________________________" )
- main.case(
- "Testing Mininet topology with the topology \
- of multi instances ONOS" )
- main.step( "Collecting topology information from ONOS" )
- devices1 = main.ONOScli1.devices()
- devices2 = main.ONOScli2.devices()
- devices3 = main.ONOScli3.devices()
- hosts1 = main.ONOScli1.hosts()
- hosts2 = main.ONOScli2.hosts()
- hosts3 = main.ONOScli3.hosts()
- ports1 = main.ONOScli1.ports()
- ports2 = main.ONOScli2.ports()
- ports3 = main.ONOScli3.ports()
- links1 = main.ONOScli1.links()
- links2 = main.ONOScli2.links()
- links3 = main.ONOScli3.links()
-
- 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" )
-
- switches_results1 = main.Mininet1.compare_switches(
- MNTopo,
- json.loads( devices1 ) )
- print "switches_Result1 = ", switches_results1
- 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" )
-
- switches_results3 = main.Mininet1.compare_switches(
- MNTopo,
- json.loads( devices3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
- onpass="ONOS3 Switches view is correct",
- onfail="ONOS3 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" )
-
- ports_results3 = main.Mininet1.compare_ports(
- MNTopo, json.loads( ports3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
- onpass="ONOS3 Ports view is correct",
- onfail="ONOS3 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" )
-
- links_results3 = main.Mininet1.compare_links(
- MNTopo,
- json.loads( links3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=links_results3,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect" )
-
- topo_result = switches_results1 and switches_results2 and \
- switches_results3\
- and ports_results1 and ports_results2 and ports_results3\
- and links_results1 and links_results2 and links_results3
-
- '''
- topo_result = switches_results1 and switches_results2 and \
- switches_results3 and links_results1 and \
- links_results2 and links_results3
- '''
-
- if topo_result == main.TRUE:
- main.log.report(
- "Topology Check Test with mininet and \
- ONOS instances successful" )
- else:
- main.log.report(
- "Topology Check Test with mininet and \
- ONOS instances failed" )
-
- utilities.assert_equals( expect=main.TRUE, actual=topo_result,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
-
- def CASE10( self ):
- main.log.report(
- "This testcase uninstalls the reactive forwarding app" )
- main.log.report( "__________________________________" )
- main.case( "Uninstalling reactive forwarding app" )
- # Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result1 = main.ONOScli1.feature_uninstall(
- "onos-app-fwd" )
- appUninstall_result2 = main.ONOScli2.feature_uninstall(
- "onos-app-fwd" )
- appUninstall_result3 = main.ONOScli3.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 )
-
- hosts = main.ONOScli1.hosts()
- main.log.info( hosts )
-
- case10_result = appUninstall_result1 and appUninstall_result2 and \
- appUninstall_result3
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case10_result,
- onpass="Reactive forwarding app uninstallation successful",
- onfail="Reactive forwarding app uninstallation failed" )
-
- def CASE6( self ):
- main.log.report(
- "This testcase is testing the addition of host intents and \
- then doing pingall" )
- main.log.report( "__________________________________" )
- main.case( "Obtaining hostsfor adding host intents" )
- main.step( "Get hosts" )
- hosts = main.ONOScli1.hosts()
- main.log.info( hosts )
-
- main.step( "Get all devices id" )
- devices_id_list = main.ONOScli1.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 intents for mn hosts
- (h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,
- h15-h25,h16-h26,h17-h27)" )
- hth_intent_result = main.ONOScli1.add_host_intent(
- "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent(
- "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent(
- "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent(
- "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent(
- "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent(
- "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent(
- "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent(
- "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent(
- "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
- hth_intent_result = main.ONOScli1.add_host_intent(
- "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
- """
- for i in range( 8, 18 ):
- main.log.info(
- "Adding host intent between h" + str( i ) +
- " and h" + str( i + 10 ) )
- host1 = "00:00:00:00:00:" + \
- str( hex( i )[ 2: ] ).zfill( 2 ).upper()
- host2 = "00:00:00:00:00:" + \
- str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- # NOTE: get host can return None
- # TODO: handle this
- host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
- host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
- tmp_result = main.ONOScli1.add_host_intent( host1_id, host2_id )
-
- flowHandle = main.ONOScli1.flows()
- main.log.info( "flows:" + flowHandle )
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
- 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 between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "have failed" )
- i = 19
- Ping_Result = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "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(
- "Host intents have not ben installed correctly. Cleaning up" )
- # main.cleanup()
- # main.exit()
- if Ping_Result == main.TRUE:
- main.log.report( "Host intents have been installed correctly" )
-
- case6_result = Ping_Result
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case6_result,
- onpass="Host intent addition and Pingall Test successful",
- onfail="Host intent addition and Pingall Test NOT successful" )
-
- def CASE7( self, main ):
-
- from sts.topology.teston_topology import TestONTopology
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
-
- link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
-
- main.log.report(
- "This testscase is killing a link to ensure that \
- link discovery is consistent" )
- main.log.report( "__________________________________" )
- 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.ONOScli1.topology()
- topology_result = main.ONOSbench.get_topology( topology_output )
- activeSwitches = topology_result[ 'devices' ]
- links = topology_result[ '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.ONOScli2.topology()
- Link_Down = main.ONOSbench.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.ONOScli2.topology()
- Link_Up = main.ONOSbench.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" )
- main.case(
- "Testing Mininet topology with the topology of \
- multi instances ONOS" )
- main.step( "Collecting topology information from ONOS" )
- devices1 = main.ONOScli1.devices()
- devices2 = main.ONOScli2.devices()
- devices3 = main.ONOScli3.devices()
- hosts1 = main.ONOScli1.hosts()
- hosts2 = main.ONOScli2.hosts()
- hosts3 = main.ONOScli3.hosts()
- ports1 = main.ONOScli1.ports()
- ports2 = main.ONOScli2.ports()
- ports3 = main.ONOScli3.ports()
- links1 = main.ONOScli1.links()
- links2 = main.ONOScli2.links()
- links3 = main.ONOScli3.links()
-
- 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" )
-
- switches_results1 = main.Mininet1.compare_switches(
- MNTopo,
- json.loads( devices1 ) )
- print "switches_Result1 = ", switches_results1
- 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" )
-
- switches_results3 = main.Mininet1.compare_switches(
- MNTopo,
- json.loads( devices3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
- onpass="ONOS3 Switches view is correct",
- onfail="ONOS3 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" )
-
- ports_results3 = main.Mininet1.compare_ports(
- MNTopo, json.loads( ports3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
- onpass="ONOS3 Ports view is correct",
- onfail="ONOS3 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" )
-
- links_results3 = main.Mininet1.compare_links(
- MNTopo,
- json.loads( links3 ) )
- utilities.assert_equals( expect=main.TRUE, actual=links_results3,
- onpass="ONOS2 Links view is correct",
- onfail="ONOS2 Links view is incorrect" )
-
- # topo_result = switches_results1 and switches_results2 and \
- # switches_results3 and ports_results1 and ports_results2 and \
- # ports_results3 and links_results1 and links_results2 and \
- # links_results3
-
- topo_result = switches_results1 and switches_results2 \
- and switches_results3 and links_results1 and \
- links_results2 and links_results3
-
- utilities.assert_equals(
- expect=main.TRUE,
- actual=topo_result and Link_Up and Link_Down,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
-
- def CASE8( self ):
- """
- Intent removal
- """
- main.log.report(
- "This testcase removes host any previously added intents" )
- main.log.report( "__________________________________" )
- main.log.info( "Removing any previously installed intents" )
- main.case( "Removing intents" )
- main.step( "Obtain the intent id's" )
- intent_result = main.ONOScli1.intents( json_format=False )
-
- intent_linewise = intent_result.split( "\n" )
- intentList = []
- for line in intent_linewise:
- if line.startswith( "id=" ):
- intentList.append( line )
-
- intentids = []
- for line in intentList:
- intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
- for id in intentids:
- main.log.info( "id = " + id )
-
- main.step(
- "Iterate through the intentids list and remove each intent" )
- for id in intentids:
- main.ONOScli1.remove_intent( intent_id=id )
-
- intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( "intent_result = " + intent_result )
- case8_result = main.TRUE
-
- i = 8
- Ping_Result = main.TRUE
- 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.TRUE:
- i = 19
- Ping_Result = main.TRUE
- elif ping == main.FALSE:
- i += 1
- Ping_Result = main.FALSE
- else:
- main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
-
- # Note: If the ping result failed, that means the intents have been
- # withdrawn correctly.
- if Ping_Result == main.TRUE:
- main.log.report( "Host intents have not been withdrawn correctly" )
- # main.cleanup()
- # main.exit()
- if Ping_Result == main.FALSE:
- main.log.report( "Host intents have been withdrawn correctly" )
-
- case8_result = case8_result and Ping_Result
-
- if case8_result == main.FALSE:
- main.log.report( "Intent removal successful" )
- else:
- main.log.report( "Intent removal failed" )
-
- utilities.assert_equals( expect=main.FALSE, actual=case8_result,
- onpass="Intent removal test failed",
- onfail="Intent removal test successful" )
-
- def CASE9( self ):
- """
- This test case adds point intents. Make sure you run test case 8
- which is host intent removal before executing this test case.
- Else the host intents flows will persist on switches and the ping
- would work even if there is some issue with the point intent's flows
- """
- main.log.report(
- "This testcase adds point intents and then does pingall" )
- main.log.report( "__________________________________" )
- main.log.info( "Adding point intents" )
- main.case(
- "Adding bidirectional point for mn hosts \
- h8-h18 h9-h19 h10-h20 h11-h21 h12-h22 h13-h23 \
- h14-h24 h15-h25 h16-h26 h17-h27" )
-
- main.step( "Add point-to-point intents for mininet hosts \
- h8 and h18 or ONOS hosts h8 and h12" )
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000003008/1",
- "of:0000000000006018/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006018/1",
- "of:0000000000003008/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003009/1",
- "of:0000000000006019/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006019/1",
- "of:0000000000003009/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003010/1",
- "of:0000000000006020/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006020/1",
- "of:0000000000003010/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003011/1",
- "of:0000000000006021/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006021/1",
- "of:0000000000003011/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003012/1",
- "of:0000000000006022/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006022/1",
- "of:0000000000003012/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003013/1",
- "of:0000000000006023/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006023/1",
- "of:0000000000003013/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003014/1",
- "of:0000000000006024/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006024/1",
- "of:0000000000003014/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003015/1",
- "of:0000000000006025/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006025/1",
- "of:0000000000003015/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003016/1",
- "of:0000000000006026/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006026/1",
- "of:0000000000003016/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.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.ONOScli1.add_point_intent(
- "of:0000000000003017/1",
- "of:0000000000006027/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- ptp_intent_result = main.ONOScli1.add_point_intent(
- "of:0000000000006027/1",
- "of:0000000000003017/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
-
- print("___________________________________________________________" )
-
- flowHandle = main.ONOScli1.flows()
- main.log.info( "flows :" + flowHandle )
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
- 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 between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "have failed" )
- i = 19
- Ping_Result = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "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(
- "Ping all test after Point intents addition failed. \
- Cleaning up" )
- # main.cleanup()
- # main.exit()
- if Ping_Result == main.TRUE:
- main.log.report(
- "Ping all test after Point intents addition successful" )
-
- case8_result = Ping_Result
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case8_result,
- onpass="Ping all test after Point intents addition successful",
- onfail="Ping all test after Point intents addition failed" )
-
- def CASE31( self ):
- """
- This test case adds point intent related to SDN-IP
- matching on ICMP ( ethertype=IPV4, ipProto=1 )
- """
- import json
-
- main.log.report(
- '''This test case adds point intent related to SDN-IP
- matching on ICMP''' )
- main.case(
- '''Adding bidirectional point intent related to SDN-IP
- matching on ICMP''' )
- main.step( "Adding bidirectional point intent" )
- # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
- # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
- # of:0000000000006018/1
-
- hosts_json = json.loads( main.ONOScli1.hosts() )
- for i in range( 8, 11 ):
- main.log.info(
- "Adding point intent between h" + str( i ) +
- " and h" + str( i + 10 ) )
- host1 = "00:00:00:00:00:" + \
- str( hex( i )[ 2: ] ).zfill( 2 ).upper()
- host2 = "00:00:00:00:00:" + \
- str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
- host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
- for host in hosts_json:
- if host[ 'id' ] == host1_id:
- ip1 = host[ 'ips' ][ 0 ]
- ip1 = str( ip1 + "/32" )
- device1 = host[ 'location' ][ 'device' ]
- device1 = str( device1 + "/1" )
- elif host[ 'id' ] == host2_id:
- ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
- device2 = host[ 'location' ][ "device" ]
- device2 = str( device2 + "/1" )
-
- p_intent_result1 = main.ONOScli1.add_point_intent(
- ingress_device=device1,
- egress_device=device2,
- ipSrc=ip1,
- ipDst=ip2,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
-
- get_intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( get_intent_result )
-
- p_intent_result2 = main.ONOScli1.add_point_intent(
- ingress_device=device2,
- egress_device=device1,
- ipSrc=ip2,
- ipDst=ip1,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
-
- get_intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( get_intent_result )
- if ( p_intent_result1 and p_intent_result2 ) == main.TRUE:
- # get_intent_result = main.ONOScli1.intents()
- # main.log.info( get_intent_result )
- main.log.info(
- '''Point intent related to SDN-IP matching on ICMP install
- successful''' )
-
- time.sleep( 15 )
- get_intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( "intents = " + get_intent_result )
- get_flows_result = main.ONOScli1.flows()
- main.log.info( "flows = " + get_flows_result )
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
- while i < 11:
- 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 < 3:
- 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 between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "have failed" )
- i = 19
- Ping_Result = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "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(
- "Ping test after Point intents related to SDN-IP \
- matching on ICMP failed." )
- # main.cleanup()
- # main.exit()
- if Ping_Result == main.TRUE:
- main.log.report(
- "Ping all test after Point intents related to SDN-IP \
- matching on ICMP successful" )
-
- case31_result = Ping_Result and p_intent_result1 and p_intent_result2
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case31_result,
- onpass="Point intent related to SDN-IP matching on ICMP and \
- ping test successful",
- onfail="Point intent related to SDN-IP matching on ICMP and \
- ping test failed" )
-
- def CASE32( self ):
- '''
- This test case adds point intent related to SDN-IP matching on TCP
- ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
- Note: Although BGP port is 179, we are using 5001 because iperf is
- used for verifying and iperf's default port is 5001
- '''
- import json
-
- main.log.report( '''This test case adds point intent related
- to SDN-IP matching on TCP''' )
- main.case( '''Adding bidirectional point intent related to SDN-IP
- matching on TCP''' )
- main.step( "Adding bidirectional point intent" )
-
- """
- add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
- --ethType=IPV4 --ipProto=6 --tcpDst=5001
- of:0000000000003008/1 of:0000000000006018/1
-
- add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
- --ethType=IPV4 --ipProto=6 --tcpDst=5001
- of:0000000000006018/1 of:0000000000003008/1
-
- add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
- --ethType=IPV4 --ipProto=6 --tcpSrc=5001
- of:0000000000003008/1 of:0000000000006018/1
-
- add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
- --ethType=IPV4 --ipProto=6 --tcpSrc=5001
- of:0000000000006018/1 of:0000000000003008/1
-
- """
- hosts_json = json.loads( main.ONOScli1.hosts() )
- for i in range( 8, 9 ):
- main.log.info(
- "Adding point intent between h" + str( i ) +
- " and h" + str( i + 10 ) )
- host1 = "00:00:00:00:00:" + \
- str( hex( i )[ 2: ] ).zfill( 2 ).upper()
- host2 = "00:00:00:00:00:" + \
- str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
- host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
- for host in hosts_json:
- if host[ 'id' ] == host1_id:
- ip1 = host[ 'ips' ][ 0 ]
- ip1 = str( ip1 + "/32" )
- device1 = host[ 'location' ][ 'device' ]
- device1 = str( device1 + "/1" )
- elif host[ 'id' ] == host2_id:
- ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
- device2 = host[ 'location' ][ "device" ]
- device2 = str( device2 + "/1" )
-
- p_intent_result1 = main.ONOScli1.add_point_intent(
- ingress_device=device1,
- egress_device=device2,
- ipSrc=ip1,
- ipDst=ip2,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
- tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
- p_intent_result2 = main.ONOScli1.add_point_intent(
- ingress_device=device2,
- egress_device=device1,
- ipSrc=ip2,
- ipDst=ip1,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
- tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
-
- p_intent_result3 = main.ONOScli1.add_point_intent(
- ingress_device=device1,
- egress_device=device2,
- ipSrc=ip1,
- ipDst=ip2,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
- tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
- p_intent_result4 = main.ONOScli1.add_point_intent(
- ingress_device=device2,
- egress_device=device1,
- ipSrc=ip2,
- ipDst=ip1,
- ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
- tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
-
- p_intent_result = p_intent_result1 and p_intent_result2 and \
- p_intent_result3 and p_intent_result4
- if p_intent_result == main.TRUE:
- get_intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( get_intent_result )
- main.log.info( '''Point intent related to SDN-IP matching
- on TCP install successful''' )
-
- iperf_result = main.Mininet1.iperf( 'h8', 'h18' )
- if iperf_result == main.TRUE:
- main.log.report( "iperf test successful" )
- else:
- main.log.report( "iperf test failed" )
-
- case32_result = p_intent_result and iperf_result
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case32_result,
- onpass="Ping all test after Point intents addition related to \
- SDN-IP on TCP match successful",
- onfail="Ping all test after Point intents addition related to \
- SDN-IP on TCP match failed" )
-
- def CASE33( self ):
- """
- This test case adds multipoint to singlepoint intent related
- to SDN-IP matching on destination ip and the action is to
- rewrite the mac address.
- Here the mac address to be rewritten is the mac address
- of the egress device
- """
- import json
- import time
-
- main.log.report( "This test case adds multipoint to singlepoint intent\
- related to SDN-IP matching on destination ip and\
- rewrite mac address action" )
- main.case( "Adding multipoint to singlepoint intent related to SDN-IP\
- matching on destination ip" )
- main.step( "Adding bidirectional multipoint to singlepoint intent" )
- """
- add-multi-to-single-intent --ipDst=10.0.3.0/24
- --setEthDst=00:00:00:00:00:12
- of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
-
- add-multi-to-single-intent --ipDst=10.0.1.0/24
- --setEthDst=00:00:00:00:00:08
- of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
- """
- main.case( "Installing multipoint to single point intent with\
- rewrite mac address" )
- main.step( "Uninstalling proxy arp app" )
- # Unistall onos-app-proxyarp app to disable reactive forwarding
- appUninstall_result1 = main.ONOScli1.feature_uninstall(
- "onos-app-proxyarp" )
- appUninstall_result2 = main.ONOScli2.feature_uninstall(
- "onos-app-proxyarp" )
- appUninstall_result3 = main.ONOScli3.feature_uninstall(
- "onos-app-proxyarp" )
- main.log.info( "onos-app-proxyarp uninstalled" )
-
- main.step( "Changing ipaddress of hosts h8,h9 and h18" )
- main.Mininet1.changeIP(
- host='h8',
- intf='h8-eth0',
- newIP='10.0.1.1',
- newNetmask='255.255.255.0' )
- main.Mininet1.changeIP(
- host='h9',
- intf='h9-eth0',
- newIP='10.0.2.1',
- newNetmask='255.255.255.0' )
- main.Mininet1.changeIP(
- host='h10',
- intf='h10-eth0',
- newIP='10.0.3.1',
- newNetmask='255.255.255.0' )
-
- main.step( "Changing default gateway of hosts h8,h9 and h18" )
- main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
- main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
- main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
-
- main.step( "Assigning random mac address to the default gateways\
- since proxyarp app is uninstalled" )
- main.Mininet1.addStaticMACAddress(
- host='h8',
- GW='10.0.1.254',
- macaddr='00:00:00:00:11:11' )
- main.Mininet1.addStaticMACAddress(
- host='h9',
- GW='10.0.2.254',
- macaddr='00:00:00:00:22:22' )
- main.Mininet1.addStaticMACAddress(
- host='h10',
- GW='10.0.3.254',
- macaddr='00:00:00:00:33:33' )
-
- main.step( "Verify static gateway and MAC address assignment" )
- main.Mininet1.verifyStaticGWandMAC( host='h8' )
- main.Mininet1.verifyStaticGWandMAC( host='h9' )
- main.Mininet1.verifyStaticGWandMAC( host='h10' )
-
- main.step( "Adding multipoint to singlepoint intent" )
- p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
- ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
- ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
- egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
- ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
- setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
-
- p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
- ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
- ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
- egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
- ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
- setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
-
- get_intent_result = main.ONOScli1.intents( json_format=False )
- main.log.info( "intents = " + get_intent_result )
-
- time.sleep( 10 )
- get_flows_result = main.ONOScli1.flows( json_format=False )
- main.log.info( "flows = " + get_flows_result )
-
- count = 1
- i = 8
- Ping_Result = main.TRUE
-
- main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
- ping = main.Mininet1.pingHost(
- src="h" + str( i ), target="h" + str( i + 2 ) )
- if ping == main.FALSE and count < 3:
- count += 1
- Ping_Result = main.FALSE
- main.log.report( "Ping between h" +
- str( i ) +
- " and h" +
- str( i +
- 2 ) +
- " failed. Making attempt number " +
- str( count ) +
- " in 2 seconds" )
- time.sleep( 2 )
- elif ping == main.FALSE:
- main.log.report( "All ping attempts between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "have failed" )
- Ping_Result = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
- str( i ) +
- " and h" +
- str( i +
- 2 ) +
- "passed!" )
- Ping_Result = main.TRUE
- else:
- main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
-
- if Ping_Result == main.FALSE:
- main.log.report( "Ping test failed." )
- # main.cleanup()
- # main.exit()
- if Ping_Result == main.TRUE:
- main.log.report( "Ping all successful" )
-
- p_intent_result = p_intent_result1 and p_intent_result2
- if p_intent_result == main.TRUE:
- main.log.info( "Multi point intent with rewrite mac address\
- installation successful" )
- else:
- main.log.info( "Multi point intent with rewrite mac address\
- installation failed" )
-
- case33_result = p_intent_result and Ping_Result
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case33_result,
- onpass="Ping all test after multipoint to single point intent \
- addition with rewrite mac address successful",
- onfail="Ping all test after multipoint to single point intent \
- addition with rewrite mac address failed" )
-
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/MultiProd/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/MultiProd/__init__.py
diff --git a/TestON/tests/MultiProd13/MultiProd13.py b/TestON/tests/MultiProd13/MultiProd13.py
index d3ed757..6c0b8d7 100644
--- a/TestON/tests/MultiProd13/MultiProd13.py
+++ b/TestON/tests/MultiProd13/MultiProd13.py
@@ -11,7 +11,7 @@
time.sleep( 1 )
-class MultiProd:
+class MultiProd13:
def __init__( self ):
self.default = ''
@@ -55,7 +55,7 @@
main.step( "Git checkout, pull and get version" )
#main.ONOSbench.gitCheckout( "master" )
gitPullResult = main.ONOSbench.gitPull()
- print "git_pull_result = ", gitPullResult
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
versionResult = main.ONOSbench.getVersion( report=True )
if gitPullResult == 1:
@@ -106,6 +106,12 @@
print startcli2
print startcli3
+ # Starting the mininet using the old way
+ main.step( "Starting Mininet ..." )
+ netIsUp = main.Mininet1.startNet()
+ if netIsUp:
+ main.log.info("Mininet CLI is up")
+
case1Result = ( packageResult and
cellResult and verifyResult and onosInstallResult and
onosIsup and startResult )
@@ -631,10 +637,8 @@
main.step( "Determine the current number of switches and links" )
topologyOutput = main.ONOScli1.topology()
topologyResult = main.ONOSbench.getTopology( topologyOutput )
- activeSwitches = topologyResult[ 'devices' ]
- links = topologyResult[ 'links' ]
- print "activeSwitches = ", type( activeSwitches )
- print "links = ", type( links )
+ activeSwitches = topologyResult[ 'deviceCount' ]
+ links = topologyResult[ 'linkCount' ]
main.log.info(
"Currently there are %s switches and %s links" %
( str( activeSwitches ), str( links ) ) )
@@ -1529,39 +1533,54 @@
main.Mininet1.verifyStaticGWandMAC( host='h9' )
main.Mininet1.verifyStaticGWandMAC( host='h10' )
+ ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ]
+ ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
+ ingressDeviceList = []
+ ingressDeviceList.append( ingressDevice1 )
+ ingressDeviceList.append( ingressDevice2 )
+
main.step( "Adding multipoint to singlepoint intent" )
pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
- ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
- ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+ ingressDeviceList,
egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
+ ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ]
+ ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
+ ingressDeviceList = [ingressDevice1, ingressDevice2]
+
pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
- ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
- ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+ ingressDeviceList,
egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
- getIntentResult = main.ONOScli1.intents( jsonFormat=False )
- main.log.info( "intents = " + getIntentResult )
+ pIntentResult = pIntentResult1 and pIntentResult2
+ if pIntentResult == main.FALSE:
+ main.log.info(
+ "Multi point to single point intent " +
+ "installation failed" )
+ else:
+ pIntentResult = main.TRUE
+ getIntentResult = main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "intents = " + getIntentResult )
- time.sleep( 10 )
- getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
- main.log.info( "flows = " + getFlowsResult )
+ time.sleep( 10 )
+ getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
+ main.log.info( "flows = " + getFlowsResult )
- count = 1
- i = 8
- PingResult = main.TRUE
+ count = 1
+ i = 8
+ PingResult = main.TRUE
- main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
- ping = main.Mininet1.pingHost(
+ main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
+ ping = main.Mininet1.pingHost(
src="h" + str( i ), target="h" + str( i + 2 ) )
- if ping == main.FALSE and count < 3:
- count += 1
- PingResult = main.FALSE
- main.log.report( "Ping between h" +
+ if ping == main.FALSE and count < 3:
+ count += 1
+ PingResult = main.FALSE
+ main.log.report( "Ping between h" +
str( i ) +
" and h" +
str( i +
@@ -1569,43 +1588,38 @@
" failed. Making attempt number " +
str( count ) +
" in 2 seconds" )
- time.sleep( 2 )
- elif ping == main.FALSE:
- main.log.report( "All ping attempts between h" +
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
str( i ) +
" and h" +
str( i +
10 ) +
"have failed" )
- PingResult = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
str( i ) +
" and h" +
str( i +
2 ) +
"passed!" )
- PingResult = main.TRUE
- else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
- if PingResult == main.FALSE:
- main.log.report( "Ping test failed." )
- # main.cleanup()
- # main.exit()
- if PingResult == main.TRUE:
- main.log.report( "Ping all successful" )
+ if PingResult == main.FALSE:
+ main.log.report( "Ping test failed." )
+ # main.cleanup()
+ # main.exit()
+ if PingResult == main.TRUE:
+ main.log.report( "Ping all successful" )
- pIntentResult = pIntentResult1 and pIntentResult2
if pIntentResult == main.TRUE:
main.log.info(
"Multi point intent with rewrite mac " +
- "address installation successful" )
- else:
- main.log.info(
- "Multi point intent with rewrite mac" +
- " address installation failed" )
+ "address installation and ping successful" )
case33Result = pIntentResult and PingResult
utilities.assertEquals(
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/MultiProd13/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/MultiProd13/__init__.py
diff --git a/TestON/tests/OnosCHO/OnosCHO.params b/TestON/tests/OnosCHO/OnosCHO.params
index c0325a9..a91e17c 100644
--- a/TestON/tests/OnosCHO/OnosCHO.params
+++ b/TestON/tests/OnosCHO/OnosCHO.params
@@ -1,5 +1,5 @@
<PARAMS>
- #CHO sequence : 1,2,3,[4,5,6,5,7,8,5,10,5,9,5,7,8,5,10,5]*2
+ # 1,20,3,[40,5,60,70,80,10,90,71,81,10,93,10]*50,22,3,[41,5,61,72,82,10,91,73,83,10,94,10]*50,22,3,[42,5,62,10,92,10]*50
# 1. ONOS brinup Test case
# 2. Assign and Balance all Mininet switches across controllers
# 3. Collect reference toplogy for topo compare
@@ -8,44 +8,57 @@
# 6. Install 300 host intents and verify ping all
# 7. Randomly bring some core links down and verify pingall
# 8. Bring core links Up that were down and verify pingall
- # 9. Install 114 point intents and verify ping all
+ # 9. Install 300 point intents and verify ping all
# 10. Remove all intents on ONOS
- # 1,2,3,[4,5,6,5,7,8,5,10,5,9,5,7,8,5,10,5]*2
- <testcases>1,2,3,[4,5,6,5,70,80,5,10,5,9,5,71,81,5,10,5]*100</testcases>
+ <testcases>1,20,3,[40,5,60,70,80,10,90,71,81,10,93,10]*50,22,3,[41,5,61,72,82,10,91,73,83,10,94,10]*50,22,3,[42,5,62,10,92,10]*50</testcases>
<ENV>
<cellName>choTest5</cellName>
</ENV>
<GIT>
#autoPull 'on' or 'off'
- <autoPull>on</autoPull>
+ <autoPull>off</autoPull>
<branch>master</branch>
- </GIT>
+ </GIT>-t
+ <TOPO1>
+ <topo>~/mininet/custom/topoAtt.py</topo>
+ <numSwitches>25</numSwitches>
+ <numHosts>25</numHosts>
+ <numLinks>114</numLinks>
+ <numPaths>1</numPaths>
+ </TOPO1>
+ <TOPO2>
+ <topo>~/mininet/custom/topoChordal.py</topo>
+ <numSwitches>25</numSwitches>
+ <numHosts>25</numHosts>
+ <numLinks>600</numLinks>
+ <numPaths>1</numPaths>
+ </TOPO2>
+ <TOPO3>
+ <topo>~/mininet/custom/topoSpine.py</topo>
+ <numSwitches>78</numSwitches>
+ <numHosts>68</numHosts>
+ <numLinks>284</numLinks>
+ <numPaths>1</numPaths>
+ </TOPO3>
<CTRL>
<numCtrl>5</numCtrl>
- <ip1>10.128.40.41</ip1>
+ <ip1>10.128.10.21</ip1>
<port1>6633</port1>
- <ip2>10.128.40.42</ip2>
+ <ip2>10.128.10.22</ip2>
<port2>6633</port2>
- <ip3>10.128.40.43</ip3>
+ <ip3>10.128.10.23</ip3>
<port3>6633</port3>
- <ip4>10.128.40.44</ip4>
+ <ip4>10.128.10.24</ip4>
<port4>6633</port4>
- <ip5>10.128.40.45</ip5>
+ <ip5>10.128.10.25</ip5>
<port5>6633</port5>
</CTRL>
<HOSTS>
<startMAC>00:00:00:00:00:01</startMAC>
<endMAC>00:00:00:00:00:19</endMAC>
</HOSTS>
- <ONOSTOPO>
- <numDevices>25</numDevices>
- <numLinks>114</numLinks>
- <numHosts>25</numHosts>
- <numIntents>300</numIntents>
- <numPaths>1360</numPaths>
- </ONOSTOPO>
- <CORELINKS>
+ <ATTCORELINKS>
<toggleLinks>3</toggleLinks>
<linkS3a>s3</linkS3a>
@@ -59,11 +72,20 @@
<linkS18a>s18</linkS18a>
<linkS18b>s14,s16,s17,s19,s20,s21,s22,s23</linkS18b>
#######s3,s14,s16,s17,s19,s20,s21,s22,s23########
- </CORELINKS>
+ </ATTCORELINKS>
+
+ <SPINECORELINKS>
+ <linkS9>s9</linkS9>
+ <linkS9top>s1,s3,s5,s7</linkS9top>
+ <linkS9bot>s11,s12</linkS9bot>
+ <linkS10>s10</linkS10>
+ <linkS10top>s2,s4,s6,s8</linkS10top>
+ <linkS10bot>s13,s14</linkS10bot>
+ </SPINECORELINKS>
<timers>
- <LinkDiscovery>5</LinkDiscovery>
- <SwitchDiscovery>31</SwitchDiscovery>
+ <LinkDiscovery>1</LinkDiscovery>
+ <SwitchDiscovery>1</SwitchDiscovery>
</timers>
</PARAMS>
diff --git a/TestON/tests/OnosCHO/OnosCHO.py b/TestON/tests/OnosCHO/OnosCHO.py
index 3be5cbb..d5b9400 100644
--- a/TestON/tests/OnosCHO/OnosCHO.py
+++ b/TestON/tests/OnosCHO/OnosCHO.py
@@ -1,4 +1,4 @@
-import time
+
import sys
import os
import re
@@ -11,13 +11,6 @@
def __init__( self ):
self.default = ''
- global deviceDPIDs
- global hostMACs
- global deviceLinks
- global deviceActiveLinksCount
- global devicePortsEnabledCount
- global installedIntents
- global randomLink1, randomLink2, randomLink3, numSwitches, numLinks
def CASE1( self, main ):
"""
@@ -31,19 +24,39 @@
onos-wait-for-start
"""
import time
+
+ global intentState
+ main.threadID = 0
+ main.pingTimeout = 300
+ main.numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+ main.ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+ main.ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+ main.ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+ main.ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+ main.ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ main.ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+ main.ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+ main.ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
+ main.ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
cell_name = main.params[ 'ENV' ][ 'cellName' ]
git_pull = main.params[ 'GIT' ][ 'autoPull' ]
- numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
git_branch = main.params[ 'GIT' ][ 'branch' ]
-
+ main.newTopo = ""
+ main.CLIs = []
+ main.nodes = []
+ for i in range( 1, int(main.numCtrls) + 1 ):
+ main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+ main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+
main.case( "Set up test environment" )
main.log.report( "Set up test environment" )
main.log.report( "_______________________" )
main.step( "Git checkout and pull " + git_branch )
if git_pull == 'on':
- checkout_result = main.ONOSbench.git_checkout( git_branch )
- pull_result = main.ONOSbench.git_pull()
+ checkout_result = main.ONOSbench.gitCheckout( git_branch )
+ pull_result = main.ONOSbench.gitPull()
cp_result = ( checkout_result and pull_result )
else:
checkout_result = main.TRUE
@@ -55,45 +68,49 @@
onfail="Test step FAIL" )
main.step( "mvn clean & install" )
- mvn_result = main.ONOSbench.clean_install()
- utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
+ if git_pull == 'on':
+ mvn_result = main.ONOSbench.cleanInstall()
+ utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
onpass="Test step PASS",
onfail="Test step FAIL" )
+ else:
+ mvn_result = main.TRUE
+ main.log.info("Skipped mvn clean install as git pull is disabled in params file")
- main.ONOSbench.get_version( report=True )
+ main.ONOSbench.getVersion( report=True )
main.step( "Apply Cell environment for ONOS" )
- cell_result = main.ONOSbench.set_cell( cell_name )
+ cell_result = main.ONOSbench.setCell( cell_name )
utilities.assert_equals( expect=main.TRUE, actual=cell_result,
onpass="Test step PASS",
onfail="Test step FAIL" )
main.step( "Create ONOS package" )
- packageResult = main.ONOSbench.onos_package()
+ packageResult = main.ONOSbench.onosPackage()
utilities.assert_equals( expect=main.TRUE, actual=packageResult,
onpass="Test step PASS",
onfail="Test step FAIL" )
main.step( "Uninstall ONOS package on all Nodes" )
uninstallResult = main.TRUE
- for i in range( 1, int( numCtrls ) + 1 ):
+ for i in range( 1, int( main.numCtrls ) + 1 ):
ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
- main.log.info( "Unintsalling package on ONOS Node IP: " + ONOS_ip )
- u_result = main.ONOSbench.onos_uninstall( ONOS_ip )
+ main.log.info( "Uninstalling package on ONOS Node IP: " + ONOS_ip )
+ u_result = main.ONOSbench.onosUninstall( ONOS_ip )
utilities.assert_equals( expect=main.TRUE, actual=u_result,
onpass="Test step PASS",
onfail="Test step FAIL" )
uninstallResult = ( uninstallResult and u_result )
- main.step( "Removing copy-cat logs from ONOS nodes" )
- main.ONOSbench.onos_remove_raft_logs()
+ #main.step( "Removing copy-cat logs from ONOS nodes" )
+ #main.ONOSbench.onosRemoveRaftLogs()
main.step( "Install ONOS package on all Nodes" )
installResult = main.TRUE
- for i in range( 1, int( numCtrls ) + 1 ):
+ for i in range( 1, int( main.numCtrls ) + 1 ):
ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip )
- i_result = main.ONOSbench.onos_install( node=ONOS_ip )
+ i_result = main.ONOSbench.onosInstall( node=ONOS_ip )
utilities.assert_equals( expect=main.TRUE, actual=i_result,
onpass="Test step PASS",
onfail="Test step FAIL" )
@@ -101,88 +118,191 @@
main.step( "Verify ONOS nodes UP status" )
statusResult = main.TRUE
- for i in range( 1, int( numCtrls ) + 1 ):
+ for i in range( 1, int( main.numCtrls ) + 1 ):
ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
main.log.info( "ONOS Node " + ONOS_ip + " status:" )
- onos_status = main.ONOSbench.onos_status( node=ONOS_ip )
+ onos_status = main.ONOSbench.onosStatus( node=ONOS_ip )
utilities.assert_equals( expect=main.TRUE, actual=onos_status,
onpass="Test step PASS",
onfail="Test step FAIL" )
statusResult = ( statusResult and onos_status )
-
+
main.step( "Start ONOS CLI on all nodes" )
cliResult = main.TRUE
karafTimeout = "3600000"
# need to wait here for sometime. This will be removed once ONOS is
# stable enough
- time.sleep( 15 )
- for i in range( 1, int( numCtrls ) + 1 ):
- ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
- ONOScli = 'ONOScli' + str( i )
- main.log.info( "ONOS Node " + ONOS_ip + " cli start:" )
- exec "startcli=main." + ONOScli + \
- ".start_onos_cli(ONOS_ip, karafTimeout=karafTimeout)"
- utilities.assert_equals( expect=main.TRUE, actual=startcli,
- onpass="Test step PASS",
- onfail="Test step FAIL" )
- cliResult = ( cliResult and startcli )
-
- case1Result = ( cp_result and cell_result
- and packageResult and installResult and statusResult and cliResult )
+ time.sleep( 25 )
+ main.log.step(" Start ONOS cli using thread ")
+ startCliResult = main.TRUE
+ pool = []
+ time1 = time.time()
+ for i in range( int( main.numCtrls) ):
+ t = main.Thread( target=main.CLIs[i].startOnosCli,
+ threadID=main.threadID,
+ name="startOnosCli",
+ args=[ main.nodes[i].ip_address, karafTimeout ] )
+ pool.append(t)
+ t.start()
+ main.threadID = main.threadID + 1
+ for t in pool:
+ t.join()
+ startCliResult = startCliResult and t.result
+ time2 = time.time()
+
+ if not startCliResult:
+ main.log.info("ONOS CLI did not start up properly")
+ #main.cleanup()
+ #main.exit()
+ else:
+ main.log.info("Successful CLI startup")
+ startCliResult = main.TRUE
+ case1Result = installResult and uninstallResult and statusResult and startCliResult
+
+ main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
utilities.assert_equals( expect=main.TRUE, actual=case1Result,
onpass="Set up test environment PASS",
onfail="Set up test environment FAIL" )
- def CASE2( self, main ):
+ def CASE20( self, main ):
"""
- This test script still needs more refactoring
+ This test script Loads a new Topology (Att) on CHO setup and balances all switches
"""
import re
import time
import copy
- numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
- ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
- ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
- ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
- ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
- ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
- ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
- numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+ main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] )
+ main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] )
+ main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] )
+ main.pingTimeout = 60
main.log.report(
- "Assign and Balance all Mininet switches across controllers" )
+ "Load Att topology and Balance all Mininet switches across controllers" )
main.log.report(
- "_________________________________________________________" )
- # need to wait here for sometime. This will be removed once ONOS is
- # stable enough
- time.sleep( 15 )
+ "________________________________________________________________________" )
main.case(
"Assign and Balance all Mininet switches across controllers" )
+ main.step( "Stop any previous Mininet network topology" )
+ cliResult = main.TRUE
+ if main.newTopo == main.params['TOPO3']['topo']:
+ stopStatus = main.Mininet1.stopNet( fileName = "topoSpine" )
+
+ main.step( "Start Mininet with Att topology" )
+ main.newTopo = main.params['TOPO1']['topo']
+ startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
+
main.step( "Assign switches to controllers" )
- for i in range( 1, 26 ): # 1 to ( num of switches +1 )
- main.Mininet1.assign_sw_controller(
+ for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
+ main.Mininet1.assignSwController(
sw=str( i ),
- count=int( numCtrls ),
- 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 )
+ count= 1 ,
+ ip1=main.ONOS1_ip,
+ port1=main.ONOS1_port,
+ ip2=main.ONOS2_ip,
+ port2=main.ONOS2_port,
+ ip3=main.ONOS3_ip,
+ port3=main.ONOS3_port,
+ ip4=main.ONOS4_ip,
+ port4=main.ONOS4_port,
+ ip5=main.ONOS5_ip,
+ port5=main.ONOS5_port )
+ time.sleep(2)
+ switch_mastership = main.TRUE
+ for i in range( 1, ( main.numMNswitches + 1 ) ):
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + main.ONOS1_ip, response ):
+ switch_mastership = switch_mastership and main.TRUE
+ else:
+ switch_mastership = main.FALSE
+
+ if switch_mastership == main.TRUE:
+ main.log.report( "Controller assignment successfull" )
+ else:
+ main.log.report( "Controller assignment failed" )
+
+ """topoFailed = main.FALSE
+ checkCount = 0
+ while(topoFailed == main.FALSE):
+ topology_output = main.ONOScli1.topology()
+ topology_result = main.ONOSbench.getTopology( topology_output )
+ numOnosDevices = topology_result[ 'deviceCount' ]
+ numOnosLinks = topology_result[ 'linkCount' ]
+ if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
+ main.log.info("Att topology is now ready!")
+ break
+ else:
+ main.log.info("Att topology is not ready yet!")
+ checkCount = checkCount + 1
+ time.sleep(2)
+ if checkCount == 10:
+ topoFailed = main.TRUE
+ if topoFailed:
+ main.log.info("Att topology failed to start correctly")
+ """
+ time.sleep(15)
+ #Don't balance master for now..
+ """main.step( "Balance devices across controllers" )
+ for i in range( int( main.numCtrls ) ):
+ balanceResult = main.ONOScli1.balanceMasters()
+ # giving some breathing time for ONOS to complete re-balance
+ time.sleep( 3 )
+ topology_output = main.ONOScli1.topology()
+ topology_result = main.ONOSbench.getTopology( topology_output )
+ """
+ case2Result = ( switch_mastership and startStatus )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case2Result,
+ onpass="Starting new Att topology test PASS",
+ onfail="Starting new Att topology test FAIL" )
+
+ def CASE21( self, main ):
+ """
+ This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
+ """
+ import re
+ import time
+ import copy
+
+ main.newTopo = main.params['TOPO2']['topo']
+ main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
+ main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
+ main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
+ main.pingTimeout = 120
+ main.log.report(
+ "Load Chordal topology and Balance all Mininet switches across controllers" )
+ main.log.report(
+ "________________________________________________________________________" )
+ main.case(
+ "Assign and Balance all Mininet switches across controllers" )
+ main.step( "Stop any previous Mininet network topology" )
+ stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
+ #time.sleep(10)
+ main.step( "Start Mininet with Chordal topology" )
+ startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
+ time.sleep(15)
+ main.step( "Assign switches to controllers" )
+ for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ count=int( main.numCtrls ),
+ ip1=main.ONOS1_ip,
+ port1=main.ONOS1_port,
+ ip2=main.ONOS2_ip,
+ port2=main.ONOS2_port,
+ ip3=main.ONOS3_ip,
+ port3=main.ONOS3_port,
+ ip4=main.ONOS4_ip,
+ port4=main.ONOS4_port,
+ ip5=main.ONOS5_ip,
+ port5=main.ONOS5_port )
switch_mastership = main.TRUE
- for i in range( 1, 26 ):
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ for i in range( 1, ( main.numMNswitches + 1 ) ):
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
+ if re.search( "tcp:" + main.ONOS1_ip, response ):
switch_mastership = switch_mastership and main.TRUE
else:
switch_mastership = main.FALSE
@@ -192,18 +312,100 @@
else:
main.log.report( "Controller assignment failed" )
time.sleep( 5 )
-
+
+ #Don't balance master for now..
+ """
main.step( "Balance devices across controllers" )
- for i in range( int( numCtrls ) ):
- balanceResult = main.ONOScli1.balance_masters()
+ for i in range( int( main.numCtrls ) ):
+ balanceResult = main.ONOScli1.balanceMasters()
+ # giving some breathing time for ONOS to complete re-balance
+ time.sleep( 3 )
+ """
+ case21Result = switch_mastership
+ time.sleep(30)
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case21Result,
+ onpass="Starting new Chordal topology test PASS",
+ onfail="Starting new Chordal topology test FAIL" )
+
+ def CASE22( self, main ):
+ """
+ This test script Loads a new Topology (Spine) on CHO setup and balances all switches
+ """
+ import re
+ import time
+ import copy
+
+ main.newTopo = main.params['TOPO3']['topo']
+ main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
+ main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
+ main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
+ main.pingTimeout = 400
+
+ main.log.report(
+ "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
+ main.log.report(
+ "________________________________________________________________________" )
+ # need to wait here for sometime until ONOS bootup
+ main.case(
+ "Assign and Balance all Mininet switches across controllers" )
+ main.step( "Stop any previous Mininet network topology" )
+ #stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" )
+ main.step( "Start Mininet with Spine topology" )
+ startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
+ time.sleep(20)
+ main.step( "Assign switches to controllers" )
+ for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ count= 1,
+ ip1=main.ONOS1_ip,
+ port1=main.ONOS1_port,
+ ip2=main.ONOS2_ip,
+ port2=main.ONOS2_port,
+ ip3=main.ONOS3_ip,
+ port3=main.ONOS3_port,
+ ip4=main.ONOS4_ip,
+ port4=main.ONOS4_port,
+ ip5=main.ONOS5_ip,
+ port5=main.ONOS5_port )
+
+ switch_mastership = main.TRUE
+ for i in range( 1, ( main.numMNswitches + 1 ) ):
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + main.ONOS1_ip, response ):
+ switch_mastership = switch_mastership and main.TRUE
+ else:
+ switch_mastership = main.FALSE
+
+ if switch_mastership == main.TRUE:
+ main.log.report( "Controller assignment successfull" )
+ else:
+ main.log.report( "Controller assignment failed" )
+ time.sleep( 5 )
+ """
+ main.step( "Balance devices across controllers" )
+
+ for i in range( int( main.numCtrls ) ):
+ balanceResult = main.ONOScli1.balanceMasters()
# giving some breathing time for ONOS to complete re-balance
time.sleep( 3 )
+ main.step( "Balance devices across controllers" )
+ for i in range( int( main.numCtrls ) ):
+ balanceResult = main.ONOScli1.balanceMasters()
+ # giving some breathing time for ONOS to complete re-balance
+ time.sleep( 3 )
+ """
+ case22Result = switch_mastership
+ time.sleep(30)
utilities.assert_equals(
expect=main.TRUE,
- actual=balanceResult,
- onpass="Assign and Balance devices test PASS",
- onfail="Assign and Balance devices test FAIL" )
+ actual=case22Result,
+ onpass="Starting new Spine topology test PASS",
+ onfail="Starting new Spine topology test FAIL" )
def CASE3( self, main ):
"""
@@ -212,108 +414,158 @@
"""
import re
import copy
- deviceDPIDs = []
- hostMACs = []
- deviceLinks = []
- deviceActiveLinksCount = []
- devicePortsEnabledCount = []
-
+ main.deviceDPIDs = []
+ main.hostMACs = []
+ main.deviceLinks = []
+ main.deviceActiveLinksCount = []
+ main.devicePortsEnabledCount = []
+
main.log.report(
"Collect and Store topology details from ONOS before running any Tests" )
main.log.report(
"____________________________________________________________________" )
- main.case( "Collect and Store Topology Deatils from ONOS" )
-
+ main.case( "Collect and Store Topology Details from ONOS" )
main.step( "Collect and store current number of switches and links" )
topology_output = main.ONOScli1.topology()
- topology_result = main.ONOSbench.get_topology( topology_output )
- numSwitches = topology_result[ 'devices' ]
- numLinks = topology_result[ 'links' ]
- main.log.info(
- "Currently there are %s switches and %s links" %
- ( str( numSwitches ), str( numLinks ) ) )
+ topology_result = main.ONOSbench.getTopology( topology_output )
+ numOnosDevices = topology_result[ 'deviceCount' ]
+ numOnosLinks = topology_result[ 'linkCount' ]
+ topoResult = main.TRUE
- main.step( "Store Device DPIDs" )
- for i in range( 1, 26 ):
- deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
- print "Device DPIDs in Store: \n", str( deviceDPIDs )
+ if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
+ main.step( "Store Device DPIDs" )
+ for i in range( 1, (main.numMNswitches+1) ):
+ main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
+ print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
- main.step( "Store Host MACs" )
- for i in range( 1, 26 ):
- hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
- print "Host MACs in Store: \n", str( hostMACs )
+ main.step( "Store Host MACs" )
+ for i in range( 1, ( main.numMNhosts + 1 ) ):
+ main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
+ print "Host MACs in Store: \n", str( main.hostMACs )
+ main.MACsDict = {}
+ print "Creating dictionary of DPID and HostMacs"
+ for i in range(len(main.hostMACs)):
+ main.MACsDict[main.deviceDPIDs[i]] = main.hostMACs[i].split('/')[0]
+ print main.MACsDict
+ main.step( "Collect and store all Devices Links" )
+ linksResult = main.ONOScli1.links( jsonFormat=False )
+ ansi_escape = re.compile( r'\x1b[^m]*m' )
+ linksResult = ansi_escape.sub( '', linksResult )
+ linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
+ linksResult = linksResult.splitlines()
+ linksResult = linksResult[ 1: ]
+ main.deviceLinks = copy.copy( linksResult )
+ print "Device Links Stored: \n", str( main.deviceLinks )
+ # this will be asserted to check with the params provided count of
+ # links
+ print "Length of Links Store", len( main.deviceLinks )
- main.step( "Collect and store all Devices Links" )
- linksResult = main.ONOScli1.links( json_format=False )
- ansi_escape = re.compile( r'\x1b[^m]*m' )
- linksResult = ansi_escape.sub( '', linksResult )
- linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
- linksResult = linksResult.splitlines()
- linksResult = linksResult[ 1: ]
- deviceLinks = copy.copy( linksResult )
- print "Device Links Stored: \n", str( deviceLinks )
- # this will be asserted to check with the params provided count of
- # links
- print "Length of Links Store", len( deviceLinks )
+ main.step( "Collect and store each Device ports enabled Count" )
+ time1 = time.time()
+ for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
+ pool = []
+ for cli in main.CLIs:
+ if i >= main.numMNswitches + 1:
+ break
+ dpid = "of:00000000000000" + format( i,'02x' )
+ t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
+ t.start()
+ pool.append(t)
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ portResult = thread.result
+ portTemp = re.split( r'\t+', portResult )
+ portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+ main.devicePortsEnabledCount.append( portCount )
+ print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
+ time2 = time.time()
+ main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
- main.step( "Collect and store each Device ports enabled Count" )
- for i in range( 1, 26 ):
- portResult = main.ONOScli1.getDevicePortsEnabledCount(
- "of:00000000000000" +
- format(
- i,
- '02x' ) )
- portTemp = re.split( r'\t+', portResult )
- portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
- devicePortsEnabledCount.append( portCount )
- print "Device Enabled Port Counts Stored: \n", str( devicePortsEnabledCount )
+ main.step( "Collect and store each Device active links Count" )
+ time1 = time.time()
+
+ for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
+ pool = []
+ for cli in main.CLIs:
+ if i >= main.numMNswitches + 1:
+ break
+ dpid = "of:00000000000000" + format( i,'02x' )
+ t = main.Thread( target = cli.getDeviceLinksActiveCount,
+ threadID = main.threadID,
+ name = "getDevicePortsEnabledCount",
+ args = [dpid])
+ t.start()
+ pool.append(t)
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ linkCountResult = thread.result
+ linkCountTemp = re.split( r'\t+', linkCountResult )
+ linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+ main.deviceActiveLinksCount.append( linkCount )
+ print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
+ time2 = time.time()
+ main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
- main.step( "Collect and store each Device active links Count" )
- for i in range( 1, 26 ):
- linkCountResult = main.ONOScli1.getDeviceLinksActiveCount(
- "of:00000000000000" +
- format(
- i,
- '02x' ) )
- linkCountTemp = re.split( r'\t+', linkCountResult )
- linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
- deviceActiveLinksCount.append( linkCount )
- print "Device Active Links Count Stored: \n", str( deviceActiveLinksCount )
+ else:
+ main.log.info("Devices (expected): %s, Links (expected): %s" %
+ ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
+ main.log.info("Devices (actual): %s, Links (actual): %s" %
+ ( numOnosDevices , numOnosLinks ) )
+ main.log.info("Topology does not match, exiting CHO test...")
+ topoResult = main.FALSE
+
+ #time.sleep(300)
+ #main.cleanup()
+ #main.exit()
# just returning TRUE for now as this one just collects data
- caseResult = main.TRUE
- utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ case3Result = topoResult
+ utilities.assert_equals( expect=main.TRUE, actual=case3Result,
onpass="Saving ONOS topology data test PASS",
onfail="Saving ONOS topology data test FAIL" )
- def CASE4( self, main ):
+ def CASE40( self, main ):
"""
- Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it
+ Verify Reactive forwarding (Att Topology)
"""
import re
import copy
import time
- numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
- main.log.report( "Enable Reactive forwarding and Verify ping all" )
+ main.log.report( "Verify Reactive forwarding (Att Topology)" )
main.log.report( "______________________________________________" )
main.case( "Enable Reactive forwarding and Verify ping all" )
main.step( "Enable Reactive forwarding" )
installResult = main.TRUE
- for i in range( 1, int( numCtrls ) + 1 ):
- onosFeature = 'onos-app-fwd'
- ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
- ONOScli = 'ONOScli' + str( i )
- main.log.info( "Enabling Reactive mode on ONOS Node " + ONOS_ip )
- exec "inResult=main." + ONOScli + ".feature_install(onosFeature)"
- time.sleep( 3 )
- installResult = inResult and installResult
-
- time.sleep( 5 )
+ # Activate fwd app
+ appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
+ appCheck = main.TRUE
+ pool = []
+ for cli in main.CLIs:
+ t = main.Thread( target=cli.appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ pool.append( t )
+ t.start()
+ for t in pool:
+ t.join()
+ appCheck = appCheck and t.result
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[0].apps() )
+ main.log.warn( main.CLIs[0].appIDs() )
+
+ time.sleep( 10 )
main.step( "Verify Pingall" )
ping_result = main.FALSE
time1 = time.time()
- ping_result = main.Mininet1.pingall()
+ ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -327,20 +579,191 @@
main.log.report( "Pingall Test in Reactive mode failed" )
main.step( "Disable Reactive forwarding" )
- uninstallResult = main.TRUE
- for i in range( 1, int( numCtrls ) + 1 ):
- onosFeature = 'onos-app-fwd'
- ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
- ONOScli = 'ONOScli' + str( i )
- main.log.info( "Disabling Reactive mode on ONOS Node " + ONOS_ip )
- exec "unResult=main." + ONOScli + ".feature_uninstall(onosFeature)"
- uninstallResult = unResult and uninstallResult
+
+ main.log.info( "Uninstall reactive forwarding app" )
+ appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
+ pool = []
+ for cli in main.CLIs:
+ t = main.Thread( target=cli.appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ pool.append( t )
+ t.start()
+
+ for t in pool:
+ t.join()
+ appCheck = appCheck and t.result
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[0].apps() )
+ main.log.warn( main.CLIs[0].appIDs() )
# Waiting for reative flows to be cleared.
time.sleep( 10 )
+ case40Result = installResult and uninstallResult and ping_result
+ utilities.assert_equals( expect=main.TRUE, actual=case40Result,
+ onpass="Reactive Mode Pingall test PASS",
+ onfail="Reactive Mode Pingall test FAIL" )
- case3Result = installResult and ping_result and uninstallResult
- utilities.assert_equals( expect=main.TRUE, actual=case3Result,
+ def CASE41( self, main ):
+ """
+ Verify Reactive forwarding (Chordal Topology)
+ """
+ import re
+ import copy
+ import time
+ main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
+ main.log.report( "______________________________________________" )
+ main.case( "Enable Reactive forwarding and Verify ping all" )
+ main.step( "Enable Reactive forwarding" )
+ installResult = main.TRUE
+ # Activate fwd app
+ appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
+
+ appCheck = main.TRUE
+ pool = []
+ for cli in main.CLIs:
+ t = main.Thread( target=cli.appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ pool.append( t )
+ t.start()
+ for t in pool:
+ t.join()
+ appCheck = appCheck and t.result
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[0].apps() )
+ main.log.warn( main.CLIs[0].appIDs() )
+
+ time.sleep( 10 )
+
+ main.step( "Verify Pingall" )
+ ping_result = main.FALSE
+ time1 = time.time()
+ ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+
+ if ping_result == main.TRUE:
+ main.log.report( "Pingall Test in Reactive mode successful" )
+ else:
+ main.log.report( "Pingall Test in Reactive mode failed" )
+
+ main.step( "Disable Reactive forwarding" )
+
+ main.log.info( "Uninstall reactive forwarding app" )
+ appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
+ pool = []
+ for cli in main.CLIs:
+ t = main.Thread( target=cli.appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ pool.append( t )
+ t.start()
+
+ for t in pool:
+ t.join()
+ appCheck = appCheck and t.result
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[0].apps() )
+ main.log.warn( main.CLIs[0].appIDs() )
+
+ # Waiting for reative flows to be cleared.
+ time.sleep( 10 )
+ case41Result = installResult and uninstallResult and ping_result
+ utilities.assert_equals( expect=main.TRUE, actual=case41Result,
+ onpass="Reactive Mode Pingall test PASS",
+ onfail="Reactive Mode Pingall test FAIL" )
+
+ def CASE42( self, main ):
+ """
+ Verify Reactive forwarding (Spine Topology)
+ """
+ import re
+ import copy
+ import time
+ main.log.report( "Verify Reactive forwarding (Spine Topology)" )
+ main.log.report( "______________________________________________" )
+ main.case( "Enable Reactive forwarding and Verify ping all" )
+ main.step( "Enable Reactive forwarding" )
+ installResult = main.TRUE
+ # Activate fwd app
+ appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
+
+ appCheck = main.TRUE
+ pool = []
+ for cli in main.CLIs:
+ t = main.Thread( target=cli.appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ pool.append( t )
+ t.start()
+ for t in pool:
+ t.join()
+ appCheck = appCheck and t.result
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[0].apps() )
+ main.log.warn( main.CLIs[0].appIDs() )
+
+ time.sleep( 10 )
+
+ main.step( "Verify Pingall" )
+ ping_result = main.FALSE
+ time1 = time.time()
+ ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+
+ if ping_result == main.TRUE:
+ main.log.report( "Pingall Test in Reactive mode successful" )
+ else:
+ main.log.report( "Pingall Test in Reactive mode failed" )
+
+ main.step( "Disable Reactive forwarding" )
+
+ main.log.info( "Uninstall reactive forwarding app" )
+ appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
+ pool = []
+ for cli in main.CLIs:
+ t = main.Thread( target=cli.appToIDCheck,
+ name="appToIDCheck-" + str( i ),
+ args=[] )
+ pool.append( t )
+ t.start()
+
+ for t in pool:
+ t.join()
+ appCheck = appCheck and t.result
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[0].apps() )
+ main.log.warn( main.CLIs[0].appIDs() )
+
+ # Waiting for reative flows to be cleared.
+ time.sleep( 10 )
+ case42Result = installResult and uninstallResult and ping_result
+ utilities.assert_equals( expect=main.TRUE, actual=case42Result,
onpass="Reactive Mode Pingall test PASS",
onfail="Reactive Mode Pingall test FAIL" )
@@ -349,11 +772,12 @@
Compare current ONOS topology with reference data
"""
import re
- devicesDPID_tmp = []
- hostMACs_tmp = []
- deviceLinks_tmp = []
- deviceActiveLinksCount_tmp = []
- devicePortsEnabledCount_tmp = []
+
+ devicesDPIDTemp = []
+ hostMACsTemp = []
+ deviceLinksTemp = []
+ deviceActiveLinksCountTemp = []
+ devicePortsEnabledCountTemp = []
main.log.report(
"Compare ONOS topology with reference data in Stores" )
@@ -361,82 +785,138 @@
main.case( "Compare ONOS topology with reference data" )
main.step( "Compare current Device ports enabled with reference" )
- for i in range( 1, 26 ):
- portResult = main.ONOScli1.getDevicePortsEnabledCount(
- "of:00000000000000" +
- format(
- i,
- '02x' ) )
- portTemp = re.split( r'\t+', portResult )
- portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
- devicePortsEnabledCount_tmp.append( portCount )
- time.sleep( 2 )
- print (
- "Device Enabled ports EXPECTED: \n" +
- str( devicePortsEnabledCount ) )
- print (
- "Device Enabled ports ACTUAL: \n" +
- str( devicePortsEnabledCount_tmp ) )
- if ( cmp( devicePortsEnabledCount,
- devicePortsEnabledCount_tmp ) == 0 ):
+ time1 = time.time()
+ for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
+ pool = []
+ for cli in main.CLIs:
+ if i >= main.numMNswitches + 1:
+ break
+ dpid = "of:00000000000000" + format( i,'02x' )
+ t = main.Thread(target = cli.getDevicePortsEnabledCount,
+ threadID = main.threadID,
+ name = "getDevicePortsEnabledCount",
+ args = [dpid])
+ t.start()
+ pool.append(t)
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ portResult = thread.result
+ portTemp = re.split( r'\t+', portResult )
+ portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+ devicePortsEnabledCountTemp.append( portCount )
+ print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
+ time2 = time.time()
+ main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
+ main.log.info (
+ "Device Enabled ports EXPECTED: %s" %
+ str( main.devicePortsEnabledCount ) )
+ main.log.info (
+ "Device Enabled ports ACTUAL: %s" %
+ str( devicePortsEnabledCountTemp ) )
+
+ if ( cmp( main.devicePortsEnabledCount,
+ devicePortsEnabledCountTemp ) == 0 ):
stepResult1 = main.TRUE
else:
stepResult1 = main.FALSE
main.step( "Compare Device active links with reference" )
- for i in range( 1, 26 ):
- linkResult = main.ONOScli1.getDeviceLinksActiveCount(
- "of:00000000000000" +
- format(
- i,
- '02x' ) )
- linkTemp = re.split( r'\t+', linkResult )
- linkCount = linkTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
- deviceActiveLinksCount_tmp.append( linkCount )
- time.sleep( 3 )
- print (
- "Device Active links EXPECTED: \n" +
- str( deviceActiveLinksCount ) )
- print (
- "Device Active links ACTUAL: \n" +
- str( deviceActiveLinksCount_tmp ) )
- if ( cmp( deviceActiveLinksCount, deviceActiveLinksCount_tmp ) == 0 ):
+ time1 = time.time()
+ for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
+ pool = []
+ for cli in main.CLIs:
+ dpid = "of:00000000000000" + format( i,'02x' )
+ t = main.Thread(target = cli.getDeviceLinksActiveCount,
+ threadID = main.threadID,
+ name = "getDevicePortsEnabledCount",
+ args = [dpid])
+ t.start()
+ pool.append(t)
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ linkCountResult = thread.result
+ linkCountTemp = re.split( r'\t+', linkCountResult )
+ linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+ deviceActiveLinksCountTemp.append( linkCount )
+ print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
+ time2 = time.time()
+ main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
+ main.log.info (
+ "Device Active links EXPECTED: %s" %
+ str( main.deviceActiveLinksCount ) )
+ main.log.info (
+ "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
+ if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
stepResult2 = main.TRUE
else:
stepResult2 = main.FALSE
"""
- place holder for comparing devices, hosts and paths if required.
+ place holder for comparing devices, hosts, paths and intents if required.
Links and ports data would be incorrect with out devices anyways.
"""
- caseResult = ( stepResult1 and stepResult2 )
- utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ case5Result = ( stepResult1 and stepResult2 )
+ utilities.assert_equals( expect=main.TRUE, actual=case5Result,
onpass="Compare Topology test PASS",
onfail="Compare Topology test FAIL" )
- if caseResult == main.TRUE:
- main.log.report( "Compare Topology test Pass" )
- def CASE6( self ):
+ def CASE60( self ):
"""
- Install 300 host intents and verify ping all
+ Install 300 host intents and verify ping all (Att Topology)
"""
- main.log.report( "Add 300 host intents and verify pingall" )
+ main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
main.log.report( "_______________________________________" )
import itertools
+ import time
main.case( "Install 300 host intents" )
main.step( "Add host Intents" )
intentResult = main.TRUE
- hostCombos = list( itertools.combinations( hostMACs, 2 ) )
- for i in range( len( hostCombos ) ):
- iResult = main.ONOScli1.add_host_intent(
- hostCombos[ i ][ 0 ],
- hostCombos[ i ][ 1 ] )
- intentResult = ( intentResult and iResult )
+ hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
+
+ intentIdList = []
+ time1 = time.time()
+ for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
+ pool = []
+ for cli in main.CLIs:
+ if i >= len( hostCombos ):
+ break
+ t = main.Thread( target=cli.addHostIntent,
+ threadID=main.threadID,
+ name="addHostIntent",
+ args=[hostCombos[i][0],hostCombos[i][1]])
+ pool.append(t)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
+
+ intentResult = main.TRUE
+ intentsJson = main.ONOScli2.intents()
+ getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
+ intentsJson = intentsJson)
+ print "len of intent ID", str(len(intentIdList))
+ print "len of intent state results", str(len(getIntentStateResult))
+ print getIntentStateResult
+ # Takes awhile for all the onos to get the intents
+ time.sleep( 15 )
+ """intentState = main.TRUE
+ for i in getIntentStateResult:
+ if getIntentStateResult.get( 'state' ) != 'INSTALLED':
+ """
+
main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingall()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -447,69 +927,189 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case4Result = ( intentResult and pingResult )
+ case60Result = ( intentResult and pingResult )
+
utilities.assert_equals(
expect=main.TRUE,
- actual=case4Result,
+ actual=case60Result,
onpass="Install 300 Host Intents and Ping All test PASS",
onfail="Install 300 Host Intents and Ping All test FAIL" )
+ def CASE61( self ):
+ """
+ Install 600 host intents and verify ping all for Chordal Topology
+ """
+ main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
+ main.log.report( "_______________________________________" )
+ import itertools
+
+ main.case( "Install 600 host intents" )
+ main.step( "Add host Intents" )
+ intentResult = main.TRUE
+ hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
+
+ intentIdList = []
+ time1 = time.time()
+
+ for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
+ pool = []
+ for cli in main.CLIs:
+ if i >= len( hostCombos ):
+ break
+ t = main.Thread( target=cli.addHostIntent,
+ threadID=main.threadID,
+ name="addHostIntent",
+ args=[hostCombos[i][0],hostCombos[i][1]])
+ pool.append(t)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
+ intentResult = main.TRUE
+ intentsJson = main.ONOScli2.intents()
+ getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
+ intentsJson = intentsJson)
+ print getIntentStateResult
+
+ main.step( "Verify Ping across all hosts" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ case14Result = ( intentResult and pingResult )
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case14Result,
+ onpass="Install 300 Host Intents and Ping All test PASS",
+ onfail="Install 300 Host Intents and Ping All test FAIL" )
+
+ def CASE62( self ):
+ """
+ Install 2278 host intents and verify ping all for Spine Topology
+ """
+ main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
+ main.log.report( "_______________________________________" )
+ import itertools
+
+ main.case( "Install 2278 host intents" )
+ main.step( "Add host Intents" )
+ intentResult = main.TRUE
+ hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
+ main.pingTimeout = 300
+ intentIdList = []
+ time1 = time.time()
+ for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
+ pool = []
+ for cli in main.CLIs:
+ if i >= len( hostCombos ):
+ break
+ t = main.Thread( target=cli.addHostIntent,
+ threadID=main.threadID,
+ name="addHostIntent",
+ args=[hostCombos[i][0],hostCombos[i][1]])
+ pool.append(t)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
+ intentResult = main.TRUE
+ intentsJson = main.ONOScli2.intents()
+ getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
+ intentsJson = intentsJson)
+ print getIntentStateResult
+
+ main.step( "Verify Ping across all hosts" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ case15Result = ( intentResult and pingResult )
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case15Result,
+ onpass="Install 2278 Host Intents and Ping All test PASS",
+ onfail="Install 2278 Host Intents and Ping All test FAIL" )
+
def CASE70( self, main ):
"""
- Randomly bring some core links down and verify ping all ( Host Intents Scenario )
+ Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
"""
import random
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
- link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
- link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
- link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
- link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
- link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
- switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
+ main.randomLink1 = []
+ main.randomLink2 = []
+ main.randomLink3 = []
+ link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
+ link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
+ link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
+ link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
+ link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
+ link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
+ switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- main.log.report(
- "Host intents - Randomly bring some core links down and verify ping all" )
- main.log.report(
- "_________________________________________________________________" )
- main.case(
- "Host intents - Randomly bring some core links down and verify ping all" )
- main.step(
- "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
+ main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
+ main.log.report( "___________________________________________________________________________" )
+ main.case( "Host intents - Randomly bring some core links down and verify ping all" )
+ main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
if ( int( switchLinksToToggle ) ==
0 or int( switchLinksToToggle ) > 5 ):
- main.log.info(
- "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
- main.cleanup()
- main.exit()
+ main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
+ #main.cleanup()
+ #main.exit()
else:
- main.log.info(
- "User provided Core switch links range to toggle is correct, proceeding to run the test" )
+ main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
main.step( "Cut links on Core devices using user provided range" )
- randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
- randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
- randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
+ main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
+ main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
+ main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
for i in range( int( switchLinksToToggle ) ):
main.Mininet1.link(
END1=link1End1,
- END2=randomLink1[ i ],
+ END2=main.randomLink1[ i ],
OPTION="down" )
main.Mininet1.link(
END1=link2End1,
- END2=randomLink2[ i ],
+ END2=main.randomLink2[ i ],
OPTION="down" )
main.Mininet1.link(
END1=link3End1,
- END2=randomLink3[ i ],
+ END2=main.randomLink3[ i ],
OPTION="down" )
time.sleep( link_sleep )
topology_output = main.ONOScli2.topology()
- linkDown = main.ONOSbench.check_status(
- topology_output, numSwitches, str(
- int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
+ linkDown = main.ONOSbench.checkStatus(
+ topology_output, main.numMNswitches, str(
+ int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
utilities.assert_equals(
expect=main.TRUE,
actual=linkDown,
@@ -521,7 +1121,7 @@
main.step( "Verify Ping across all hosts" )
pingResultLinkDown = main.FALSE
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall()
+ pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -532,25 +1132,24 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult7 = linkDown and pingResultLinkDown
- utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
+ caseResult70 = linkDown and pingResultLinkDown
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
onpass="Random Link cut Test PASS",
onfail="Random Link cut Test FAIL" )
def CASE80( self, main ):
"""
- Bring the core links up that are down and verify ping all ( Host Intents Scenario )
+ Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
"""
import random
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
- link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
- link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
+ link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
+ link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
+ link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
+ switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
main.log.report(
- "Host intents - Bring the core links up that are down and verify ping all" )
+ "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
main.log.report(
"__________________________________________________________________" )
main.case(
@@ -559,23 +1158,23 @@
for i in range( int( switchLinksToToggle ) ):
main.Mininet1.link(
END1=link1End1,
- END2=randomLink1[ i ],
+ END2=main.randomLink1[ i ],
OPTION="up" )
main.Mininet1.link(
END1=link2End1,
- END2=randomLink2[ i ],
+ END2=main.randomLink2[ i ],
OPTION="up" )
main.Mininet1.link(
END1=link3End1,
- END2=randomLink3[ i ],
+ END2=main.randomLink3[ i ],
OPTION="up" )
time.sleep( link_sleep )
topology_output = main.ONOScli2.topology()
- linkUp = main.ONOSbench.check_status(
+ linkUp = main.ONOSbench.checkStatus(
topology_output,
- numSwitches,
- str( numLinks ) )
+ main.numMNswitches,
+ str( main.numMNlinks ) )
utilities.assert_equals(
expect=main.TRUE,
actual=linkUp,
@@ -587,7 +1186,7 @@
main.step( "Verify Ping across all hosts" )
pingResultLinkUp = main.FALSE
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall()
+ pingResultLinkUp = main.Mininet1.pingall( timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -598,67 +1197,63 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult8 = linkUp and pingResultLinkUp
- utilities.assert_equals( expect=main.TRUE, actual=caseResult8,
+ caseResult80 = linkUp and pingResultLinkUp
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
onpass="Link Up Test PASS",
onfail="Link Up Test FAIL" )
def CASE71( self, main ):
"""
- Randomly bring some core links down and verify ping all ( Point Intents Scenario )
+ Randomly bring some core links down and verify ping all ( Point Intents-Att Topo)
"""
import random
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
- link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
- link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
- link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
- link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
- link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
- switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
+ main.randomLink1 = []
+ main.randomLink2 = []
+ main.randomLink3 = []
+ link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
+ link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
+ link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
+ link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
+ link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
+ link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
+ switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- main.log.report(
- "Point Intents - Randomly bring some core links down and verify ping all" )
- main.log.report(
- "__________________________________________________________________" )
- main.case(
- "Point Intents - Randomly bring some core links down and verify ping all" )
- main.step(
- "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
+ main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo)" )
+ main.log.report( "___________________________________________________________________________" )
+ main.case( "Point intents - Randomly bring some core links down and verify ping all" )
+ main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
if ( int( switchLinksToToggle ) ==
0 or int( switchLinksToToggle ) > 5 ):
- main.log.info(
- "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
- main.cleanup()
- main.exit()
+ main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
+ #main.cleanup()
+ #main.exit()
else:
- main.log.info(
- "User provided Core switch links range to toggle is correct, proceeding to run the test" )
+ main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
main.step( "Cut links on Core devices using user provided range" )
- randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
- randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
- randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
+ main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
+ main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
+ main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
for i in range( int( switchLinksToToggle ) ):
main.Mininet1.link(
END1=link1End1,
- END2=randomLink1[ i ],
+ END2=main.randomLink1[ i ],
OPTION="down" )
main.Mininet1.link(
END1=link2End1,
- END2=randomLink2[ i ],
+ END2=main.randomLink2[ i ],
OPTION="down" )
main.Mininet1.link(
END1=link3End1,
- END2=randomLink3[ i ],
+ END2=main.randomLink3[ i ],
OPTION="down" )
time.sleep( link_sleep )
topology_output = main.ONOScli2.topology()
- linkDown = main.ONOSbench.check_status(
- topology_output, numSwitches, str(
- int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
+ linkDown = main.ONOSbench.checkStatus(
+ topology_output, main.numMNswitches, str(
+ int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
utilities.assert_equals(
expect=main.TRUE,
actual=linkDown,
@@ -670,7 +1265,7 @@
main.step( "Verify Ping across all hosts" )
pingResultLinkDown = main.FALSE
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall()
+ pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -681,50 +1276,49 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult7 = linkDown and pingResultLinkDown
- utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
+ caseResult71 = linkDown and pingResultLinkDown
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
onpass="Random Link cut Test PASS",
onfail="Random Link cut Test FAIL" )
def CASE81( self, main ):
"""
- Bring the core links up that are down and verify ping all ( Point Intents Scenario )
+ Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
"""
import random
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
- link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
- link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
+ link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
+ link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
+ link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
+ switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
main.log.report(
- "Point intents - Bring the core links up that are down and verify ping all" )
+ "Bring the core links up that are down and verify ping all ( Point Intents-Att Topo" )
main.log.report(
- "___________________________________________________________________" )
+ "__________________________________________________________________" )
main.case(
"Point intents - Bring the core links up that are down and verify ping all" )
main.step( "Bring randomly cut links on Core devices up" )
for i in range( int( switchLinksToToggle ) ):
main.Mininet1.link(
END1=link1End1,
- END2=randomLink1[ i ],
+ END2=main.randomLink1[ i ],
OPTION="up" )
main.Mininet1.link(
END1=link2End1,
- END2=randomLink2[ i ],
+ END2=main.randomLink2[ i ],
OPTION="up" )
main.Mininet1.link(
END1=link3End1,
- END2=randomLink3[ i ],
+ END2=main.randomLink3[ i ],
OPTION="up" )
time.sleep( link_sleep )
topology_output = main.ONOScli2.topology()
- linkUp = main.ONOSbench.check_status(
+ linkUp = main.ONOSbench.checkStatus(
topology_output,
- numSwitches,
- str( numLinks ) )
+ main.numMNswitches,
+ str( main.numMNlinks ) )
utilities.assert_equals(
expect=main.TRUE,
actual=linkUp,
@@ -736,7 +1330,7 @@
main.step( "Verify Ping across all hosts" )
pingResultLinkUp = main.FALSE
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall()
+ pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -747,61 +1341,402 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult8 = linkUp and pingResultLinkUp
- utilities.assert_equals( expect=main.TRUE, actual=caseResult8,
+ caseResult81 = linkUp and pingResultLinkUp
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
onpass="Link Up Test PASS",
onfail="Link Up Test FAIL" )
- def CASE9( self ):
+ def CASE72( self, main ):
"""
- Install 114 point intents and verify Ping all works
+ Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
"""
- import copy
- main.log.report( "Install 114 point intents and verify Ping all" )
- main.log.report( "___________________________________________" )
- main.case( "Install 114 point intents and Ping all" )
- deviceLinks_copy = copy.copy( deviceLinks )
- main.step( "Install 114 point intents" )
- for i in range( len( deviceLinks_copy ) ):
- pointLink = str(
- deviceLinks_copy[ i ] ).replace(
- "src=",
- "" ).replace(
- "dst=",
- "" ).split( ',' )
- point1 = pointLink[ 0 ].split( '/' )
- point2 = pointLink[ 1 ].split( '/' )
- installResult = main.ONOScli1.add_point_intent(
- point1[ 0 ], point2[ 0 ], int(
- point1[ 1 ] ), int(
- point2[ 1 ] ) )
- if installResult == main.TRUE:
- print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
+ import random
+ import itertools
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+ main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
+ main.log.report( "___________________________________________________________________________" )
+ main.case( "Host intents - Randomly bring some core links down and verify ping all" )
+ switches = []
+ switchesComb = []
+ for i in range( main.numMNswitches ):
+ switches.append('s%d'%(i+1))
+ switchesLinksComb = list(itertools.combinations(switches,2))
+ main.randomLinks = random.sample(switchesLinksComb, 5 )
+ print main.randomLinks
+ main.step( "Cut links on random devices" )
+
+ for switch in main.randomLinks:
+ main.Mininet1.link(
+ END1=switch[0],
+ END2=switch[1],
+ OPTION="down")
+ time.sleep( link_sleep )
- main.step( "Obtain the intent id's" )
- intentsList = main.ONOScli1.getAllIntentIds()
- ansi_escape = re.compile( r'\x1b[^m]*m' )
- intentsList = ansi_escape.sub( '', intentsList )
- intentsList = intentsList.replace(
- " onos:intents | grep id=",
- "" ).replace(
- "id=",
- "" ).replace(
- "\r\r",
- "" )
- intentsList = intentsList.splitlines()
- intentsList = intentsList[ 1: ]
+ topology_output = main.ONOScli2.topology()
+ linkDown = main.ONOSbench.checkStatus(
+ topology_output, main.numMNswitches, str(
+ int( main.numMNlinks ) - 5 * 2 ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linkDown,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ main.step( "Verify Ping across all hosts" )
+ pingResultLinkDown = main.FALSE
+ time1 = time.time()
+ pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ caseResult71 = pingResultLinkDown
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
+ onpass="Random Link cut Test PASS",
+ onfail="Random Link cut Test FAIL" )
+
+ def CASE82( self, main ):
+ """
+ Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
+ """
+ import random
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+ main.log.report(
+ "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
+ main.log.report(
+ "__________________________________________________________________" )
+ main.case(
+ "Host intents - Bring the core links up that are down and verify ping all" )
+ main.step( "Bring randomly cut links on devices up" )
+
+ for switch in main.randomLinks:
+ main.Mininet1.link(
+ END1=switch[0],
+ END2=switch[1],
+ OPTION="up")
+
+ time.sleep( link_sleep )
+
+ topology_output = main.ONOScli2.topology()
+ linkUp = main.ONOSbench.checkStatus(
+ topology_output,
+ main.numMNswitches,
+ str( main.numMNlinks ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linkUp,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ main.step( "Verify Ping across all hosts" )
+ pingResultLinkUp = main.FALSE
+ time1 = time.time()
+ pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ caseResult82 = linkUp and pingResultLinkUp
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
+ onpass="Link Up Test PASS",
+ onfail="Link Up Test FAIL" )
+
+ def CASE73( self, main ):
+ """
+ Randomly bring some links down and verify ping all ( Point Intents-Chordal Topo)
+ """
+ import random
+ import itertools
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+ main.log.report( "Randomly bring some core links down and verify ping all ( Point Intents-Chordal Topo)" )
+ main.log.report( "___________________________________________________________________________" )
+ main.case( "Point intents - Randomly bring some core links down and verify ping all" )
+ switches = []
+ switchesComb = []
+ for i in range( main.numMNswitches ):
+ switches.append('s%d'%(i+1))
+ switchesLinksComb = list(itertools.combinations(switches,2))
+ main.randomLinks = random.sample(switchesLinksComb, 5 )
+ print main.randomLinks
+ main.step( "Cut links on random devices" )
+
+ for switch in main.randomLinks:
+ main.Mininet1.link(
+ END1=switch[0],
+ END2=switch[1],
+ OPTION="down")
+ time.sleep( link_sleep )
+
+ topology_output = main.ONOScli2.topology()
+ linkDown = main.ONOSbench.checkStatus(
+ topology_output, main.numMNswitches, str(
+ int( main.numMNlinks ) - 5 * 2 ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linkDown,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ main.step( "Verify Ping across all hosts" )
+ pingResultLinkDown = main.FALSE
+ time1 = time.time()
+ pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ caseResult73 = pingResultLinkDown
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
+ onpass="Random Link cut Test PASS",
+ onfail="Random Link cut Test FAIL" )
+
+ def CASE83( self, main ):
+ """
+ Bring the core links up that are down and verify ping all ( Point Intents Chordal Topo )
+ """
+ import random
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+ main.log.report(
+ "Bring the core links up that are down and verify ping all ( Point Intents-Chordal Topo" )
+ main.log.report(
+ "__________________________________________________________________" )
+ main.case(
+ "Point intents - Bring the core links up that are down and verify ping all" )
+ main.step( "Bring randomly cut links on devices up" )
+
+ for switch in main.randomLinks:
+ main.Mininet1.link(
+ END1=switch[0],
+ END2=switch[1],
+ OPTION="up")
+
+ time.sleep( link_sleep )
+
+ topology_output = main.ONOScli2.topology()
+ linkUp = main.ONOSbench.checkStatus(
+ topology_output,
+ main.numMNswitches,
+ str( main.numMNlinks ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linkUp,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ main.step( "Verify Ping across all hosts" )
+ pingResultLinkUp = main.FALSE
+ time1 = time.time()
+ pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ caseResult83 = linkUp and pingResultLinkUp
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
+ onpass="Link Up Test PASS",
+ onfail="Link Up Test FAIL" )
+
+ def CASE74( self, main ):
+ """
+ Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
+ """
+ import random
+ main.randomLink1 = []
+ main.randomLink2 = []
+ main.randomLink3 = []
+ main.randomLink4 = []
+ link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
+ link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
+ link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
+ link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
+ link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
+ link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+ main.pingTimeout = 400
+
+ main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
+ main.log.report( "___________________________________________________________________________" )
+
+ linkIndex = range(4)
+ linkIndexS9 = random.sample(linkIndex,1)[0]
+ linkIndex.remove(linkIndexS9)
+ linkIndexS10 = random.sample(linkIndex,1)[0]
+ main.randomLink1 = link1End2top[linkIndexS9]
+ main.randomLink2 = link2End2top[linkIndexS10]
+ main.randomLink3 = random.sample(link1End2bot,1)[0]
+ main.randomLink4 = random.sample(link2End2bot,1)[0]
+ # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
+ # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
+ main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
+ main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
+
+ time.sleep( link_sleep )
+
+ topology_output = main.ONOScli2.topology()
+ linkDown = main.ONOSbench.checkStatus(
+ topology_output, main.numMNswitches, str(
+ int( main.numMNlinks ) - 8 ))
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linkDown,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ main.step( "Verify Ping across all hosts" )
+ pingResultLinkDown = main.FALSE
+ time1 = time.time()
+ pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ caseResult74 = linkDown and pingResultLinkDown
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
+ onpass="Random Link cut Test PASS",
+ onfail="Random Link cut Test FAIL" )
+
+ def CASE84( self, main ):
+ """
+ Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
+ """
+ import random
+ link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
+ link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
+ link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+ main.log.report(
+ "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
+ main.log.report(
+ "__________________________________________________________________" )
+ main.case(
+ "Host intents - Bring the core links up that are down and verify ping all" )
+
+ #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
+ #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
+ main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
+ main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
+
+ time.sleep( link_sleep )
+ topology_output = main.ONOScli2.topology()
+ linkUp = main.ONOSbench.checkStatus(
+ topology_output,
+ main.numMNswitches,
+ str( main.numMNlinks ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linkUp,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( link_sleep ) +
+ " seconds" )
+
+ main.step( "Verify Ping across all hosts" )
+ pingResultLinkUp = main.FALSE
+ time1 = time.time()
+ pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ caseResult84 = linkUp and pingResultLinkUp
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
+ onpass="Link Up Test PASS",
+ onfail="Link Up Test FAIL" )
+
+ def CASE90( self ):
+ """
+ Install 600 point intents and verify ping all (Att Topology)
+ """
+ main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
+ main.log.report( "_______________________________________" )
+ import itertools
+ import time
+ main.case( "Install 600 point intents" )
+ main.step( "Add point Intents" )
+ intentResult = main.TRUE
+ deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
+
intentIdList = []
- for i in range( len( intentsList ) ):
- intentsTemp = intentsList[ i ].split( ',' )
- intentIdList.append( intentsTemp[ 0 ] )
- print "Intent IDs: ", intentIdList
- print "Total Intents installed: ", len( intentIdList )
-
+ time1 = time.time()
+ for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
+ pool = []
+ for cli in main.CLIs:
+ if i >= len( deviceCombos ):
+ break
+ t = main.Thread( target=cli.addPointIntent,
+ threadID=main.threadID,
+ name="addPointIntent",
+ args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
+ pool.append(t)
+ #time.sleep(1)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
+ intentResult = main.TRUE
+ intentsJson = main.ONOScli2.intents()
+ getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
+ intentsJson = intentsJson)
+ print getIntentStateResult
+ # Takes awhile for all the onos to get the intents
+ time.sleep(30)
main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingall()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -812,14 +1747,450 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case8_result = installResult and pingResult
+ case90Result = ( intentResult and pingResult )
+
utilities.assert_equals(
expect=main.TRUE,
- actual=case8_result,
- onpass="Ping all test after Point intents addition successful",
- onfail="Ping all test after Point intents addition failed" )
+ actual=case90Result,
+ onpass="Install 600 point Intents and Ping All test PASS",
+ onfail="Install 600 point Intents and Ping All test FAIL" )
+
+ def CASE91( self ):
+ """
+ Install ###$$$ point intents and verify ping all (Chordal Topology)
+ """
+ main.log.report( "Add ###$$$ point intents and verify pingall (Chordal Topology)" )
+ main.log.report( "_______________________________________" )
+ import itertools
+ import time
+ main.case( "Install ###$$$ point intents" )
+ main.step( "Add point Intents" )
+ intentResult = main.TRUE
+ deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
+
+ intentIdList = []
+ time1 = time.time()
+ for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
+ pool = []
+ for cli in main.CLIs:
+ if i >= len( deviceCombos ):
+ break
+ t = main.Thread( target=cli.addPointIntent,
+ threadID=main.threadID,
+ name="addPointIntent",
+ args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
+ pool.append(t)
+ #time.sleep(1)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
+ intentResult = main.TRUE
+ intentsJson = main.ONOScli2.intents()
+ getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
+ intentsJson = intentsJson)
+ print getIntentStateResult
+ # Takes awhile for all the onos to get the intents
+ time.sleep(30)
+ main.step( "Verify Ping across all hosts" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ case91Result = ( intentResult and pingResult )
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case91Result,
+ onpass="Install ###$$$ point Intents and Ping All test PASS",
+ onfail="Install ###$$$ point Intents and Ping All test FAIL" )
+
+ def CASE92( self ):
+ """
+ Install 4556 point intents and verify ping all (Spine Topology)
+ """
+ main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
+ main.log.report( "_______________________________________" )
+ import itertools
+ import time
+ main.case( "Install 4556 point intents" )
+ main.step( "Add point Intents" )
+ intentResult = main.TRUE
+ main.pingTimeout = 600
+ for i in range(len(main.hostMACs)):
+ main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
+ print main.MACsDict
+ deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
+ intentIdList = []
+ time1 = time.time()
+ for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
+ pool = []
+ for cli in main.CLIs:
+ if i >= len( deviceCombos ):
+ break
+ t = main.Thread( target=cli.addPointIntent,
+ threadID=main.threadID,
+ name="addPointIntent",
+ args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
+ pool.append(t)
+ #time.sleep(1)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
+ intentResult = main.TRUE
+ intentsJson = main.ONOScli2.intents()
+ getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
+ intentsJson = intentsJson)
+ #print getIntentStateResult
+ # Takes awhile for all the onos to get the intents
+ time.sleep(60)
+ main.step( "Verify Ping across all hosts" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+ onpass="PING ALL PASS",
+ onfail="PING ALL FAIL" )
+
+ case92Result = ( intentResult and pingResult )
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case92Result,
+ onpass="Install 4556 point Intents and Ping All test PASS",
+ onfail="Install 4556 point Intents and Ping All test FAIL" )
+
+ def CASE93( self ):
+ """
+ Install multi-single point intents and verify Ping all works
+ for att topology
+ """
+ import copy
+ import time
+ main.log.report( "Install multi-single point intents and verify Ping all" )
+ main.log.report( "___________________________________________" )
+ main.case( "Install multi-single point intents and Ping all" )
+ deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
+ portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
+ intentIdList = []
+ print "MACsDict", main.MACsDict
+ time1 = time.time()
+ for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
+ pool = []
+ for cli in main.CLIs:
+ egressDevice = deviceDPIDsCopy[i]
+ ingressDeviceList = copy.copy(deviceDPIDsCopy)
+ ingressDeviceList.remove(egressDevice)
+ if i >= len( deviceDPIDsCopy ):
+ break
+ t = main.Thread( target=cli.addMultipointToSinglepointIntent,
+ threadID=main.threadID,
+ name="addMultipointToSinglepointIntent",
+ args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
+ pool.append(t)
+ #time.sleep(1)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
+ time.sleep(30)
+ print "getting all intents ID"
+ intentIdTemp = main.ONOScli1.getAllIntentsId()
+ print intentIdTemp
+ print len(intentIdList)
+ print intentIdList
+ checkIntentStateResult = main.TRUE
+ print "Checking intents state"
+ checkIntentStateResult = main.ONOScli1.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
+ checkIntentStateResult = main.ONOScli2.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
+ checkIntentStateResult = main.ONOScli3.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
+ checkIntentStateResult = main.ONOScli4.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
+ checkIntentStateResult = main.ONOScli5.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
+
+ if checkIntentStateResult:
+ main.log.info( "All intents are installed correctly " )
+
+ print "Checking flows state "
+ checkFlowsState = main.ONOScli1.checkFlowsState()
+ time.sleep(50)
+ main.step( "Verify Ping across all hosts" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+ checkFlowsState = main.ONOScli1.checkFlowsState()
+ case93Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case93Result,
+ onpass="Install 25 multi to single point Intents and Ping All test PASS",
+ onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
+
+ def CASE94( self ):
+ """
+ Install multi-single point intents and verify Ping all works
+ for Chordal topology
+ """
+ import copy
+ import time
+ main.log.report( "Install multi-single point intents and verify Ping all" )
+ main.log.report( "___________________________________________" )
+ main.case( "Install multi-single point intents and Ping all" )
+ deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
+ portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
+ intentIdList = []
+ print "MACsDict", main.MACsDict
+ time1 = time.time()
+ for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
+ pool = []
+ for cli in main.CLIs:
+ egressDevice = deviceDPIDsCopy[i]
+ ingressDeviceList = copy.copy(deviceDPIDsCopy)
+ ingressDeviceList.remove(egressDevice)
+ if i >= len( deviceDPIDsCopy ):
+ break
+ t = main.Thread( target=cli.addMultipointToSinglepointIntent,
+ threadID=main.threadID,
+ name="addMultipointToSinglepointIntent",
+ args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
+ pool.append(t)
+ #time.sleep(1)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
+ time.sleep(5)
+ main.step( "Verify Ping across all hosts" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+
+ case94Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case94Result,
+ onpass="Install 25 multi to single point Intents and Ping All test PASS",
+ onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
+
+ #def CASE95 multi-single point intent for Spine
+
+ def CASE96( self ):
+ """
+ Install single-multi point intents and verify Ping all works
+ for att topology
+ """
+ import copy
+ main.log.report( "Install single-multi point intents and verify Ping all" )
+ main.log.report( "___________________________________________" )
+ main.case( "Install single-multi point intents and Ping all" )
+ deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
+ portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
+ intentIdList = []
+ print "MACsDict", main.MACsDict
+ time1 = time.time()
+ for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
+ pool = []
+ for cli in main.CLIs:
+ ingressDevice = deviceDPIDsCopy[i]
+ egressDeviceList = copy.copy(deviceDPIDsCopy)
+ egressDeviceList.remove(ingressDevice)
+ if i >= len( deviceDPIDsCopy ):
+ break
+ t = main.Thread( target=cli.addSinglepointToMultipointIntent,
+ threadID=main.threadID,
+ name="addSinglepointToMultipointIntent",
+ args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
+ pool.append(t)
+ #time.sleep(1)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
+ time.sleep(5)
+ main.step( "Verify Ping across all hosts" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+
+ case96Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case96Result,
+ onpass="Install 25 single to multi point Intents and Ping All test PASS",
+ onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
+
+ def CASE97( self ):
+ """
+ Install single-multi point intents and verify Ping all works
+ for Chordal topology
+ """
+ import copy
+ main.log.report( "Install single-multi point intents and verify Ping all" )
+ main.log.report( "___________________________________________" )
+ main.case( "Install single-multi point intents and Ping all" )
+ deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
+ portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
+ intentIdList = []
+ print "MACsDict", main.MACsDict
+ time1 = time.time()
+ for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
+ pool = []
+ for cli in main.CLIs:
+ ingressDevice = deviceDPIDsCopy[i]
+ egressDeviceList = copy.copy(deviceDPIDsCopy)
+ egressDeviceList.remove(ingressDevice)
+ if i >= len( deviceDPIDsCopy ):
+ break
+ t = main.Thread( target=cli.addSinglepointToMultipointIntent,
+ threadID=main.threadID,
+ name="addSinglepointToMultipointIntent",
+ args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
+ pool.append(t)
+ #time.sleep(1)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
+ time.sleep(5)
+ main.step( "Verify Ping across all hosts" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+
+ case97Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case97Result,
+ onpass="Install 25 single to multi point Intents and Ping All test PASS",
+ onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
+
+ def CASE98( self ):
+ """
+ Install single-multi point intents and verify Ping all works
+ for Spine topology
+ """
+ import copy
+ main.log.report( "Install single-multi point intents and verify Ping all" )
+ main.log.report( "___________________________________________" )
+ main.case( "Install single-multi point intents and Ping all" )
+ deviceDPIDsCopy = copy.copy( main.deviceDPIDs )
+ deviceDPIDsCopy = deviceDPIDsCopy[ 10: ]
+ portEgressList = [ '1' ]*(len(deviceDPIDsCopy) - 1)
+ intentIdList = []
+ MACsDictCopy = {}
+ for i in range( len( deviceDPIDsCopy ) ):
+ MACsDictCopy[ deviceDPIDsCopy[ i ] ] = main.hostMACs[i].split( '/' )[ 0 ]
+
+ print "deviceDPIDsCopy", deviceDPIDsCopy
+ print ""
+ print "MACsDictCopy", MACsDictCopy
+ time1 = time.time()
+ for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
+ pool = []
+ for cli in main.CLIs:
+ if i >= len( deviceDPIDsCopy ):
+ break
+ ingressDevice = deviceDPIDsCopy[i]
+ egressDeviceList = copy.copy(deviceDPIDsCopy)
+ egressDeviceList.remove(ingressDevice)
+ t = main.Thread( target=cli.addSinglepointToMultipointIntent,
+ threadID=main.threadID,
+ name="addSinglepointToMultipointIntent",
+ args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',MACsDictCopy.get(ingressDevice),''])
+ pool.append(t)
+ #time.sleep(1)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
+ time.sleep(5)
+ main.step( "Verify Ping across all hosts" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True,acceptableFailed=5)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+
+ case98Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case98Result,
+ onpass="Install 25 single to multi point Intents and Ping All test PASS",
+ onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
def CASE10( self ):
+ import time
"""
Remove all Intents
"""
@@ -842,50 +2213,235 @@
intentsList = intentsList[ 1: ]
intentIdList = []
step1Result = main.TRUE
+ moreIntents = main.TRUE
+ removeIntentCount = 0
+ intentsCount = len(intentsList)
+ print "Current number of intents" , len(intentsList)
if ( len( intentsList ) > 1 ):
- for i in range( len( intentsList ) ):
- intentsTemp = intentsList[ i ].split( ',' )
- intentIdList.append( intentsTemp[ 0 ] )
- print "Intent IDs: ", intentIdList
- for id in range( len( intentIdList ) ):
- print "Removing intent id (round 1) :", intentIdList[ id ]
- main.ONOScli1.remove_intent( intent_id=intentIdList[ id ] )
- time.sleep( 1 )
+ results = main.TRUE
+ main.log.info("Removing intent...")
+ while moreIntents:
+ if removeIntentCount == 5:
+ break
+ removeIntentCount = removeIntentCount + 1
+ intentsList1 = main.ONOScli1.getAllIntentIds()
+ if len( intentsList1 ) == 0:
+ break
+ ansi_escape = re.compile( r'\x1b[^m]*m' )
+ intentsList1 = ansi_escape.sub( '', intentsList1 )
+ intentsList1 = intentsList1.replace(
+ " onos:intents | grep id=",
+ "" ).replace(
+ " state=",
+ "" ).replace(
+ "\r\r",
+ "" )
+ intentsList1 = intentsList1.splitlines()
+ intentsList1 = intentsList1[ 1: ]
+ print "Round %d intents to remove: " %(removeIntentCount)
+ print intentsList1
+ intentIdList1 = []
+ if ( len( intentsList1 ) > 0 ):
+ moreIntents = main.TRUE
+ for i in range( len( intentsList1 ) ):
+ intentsTemp1 = intentsList1[ i ].split( ',' )
+ intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
+ print "Leftover Intent IDs: ", intentIdList1
+ print len(intentIdList1)
+ time1 = time.time()
+ for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
+ pool = []
+ for cli in main.CLIs:
+ if i >= len( intentIdList1 ):
+ break
+ t = main.Thread( target=cli.removeIntent,
+ threadID=main.threadID,
+ name="removeIntent",
+ args=[intentIdList1[i],'org.onosproject.cli',True,False])
+ pool.append(t)
+ t.start()
+ i = i + 1
+ main.threadID = main.threadID + 1
+ for thread in pool:
+ thread.join()
+ intentIdList.append(thread.result)
+ time2 = time.time()
+ main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
+ time.sleep(10)
+ else:
+ time.sleep(15)
+ if len( main.ONOScli1.intents()):
+ continue
+ break
- main.log.info(
- "Verify all intents are removed and if any leftovers try remove one more time" )
- intentsList1 = main.ONOScli1.getAllIntentIds()
- ansi_escape = re.compile( r'\x1b[^m]*m' )
- intentsList1 = ansi_escape.sub( '', intentsList1 )
- intentsList1 = intentsList1.replace(
- " onos:intents | grep id=",
- "" ).replace(
- " state=",
- "" ).replace(
- "\r\r",
- "" )
- intentsList1 = intentsList1.splitlines()
- intentsList1 = intentsList1[ 1: ]
- print "Round 2 (leftover) intents to remove: ", intentsList1
- intentIdList1 = []
- if ( len( intentsList1 ) > 1 ):
- for i in range( len( intentsList1 ) ):
- intentsTemp1 = intentsList[ i ].split( ',' )
- intentIdList1.append( intentsTemp1[ 0 ] )
- print "Leftover Intent IDs: ", intentIdList1
- for id in range( len( intentIdList1 ) ):
- print "Removing intent id (round 2):", intentIdList1[ id ]
- main.ONOScli1.remove_intent(
- intent_id=intentIdList1[ id ] )
- time.sleep( 2 )
else:
- print "There are no more intents that need to be removed"
+ print "Removed %d intents" %(intentsCount)
step1Result = main.TRUE
else:
print "No Intent IDs found in Intents list: ", intentsList
step1Result = main.FALSE
- caseResult7 = step1Result
- utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
+ print main.ONOScli1.intents()
+ caseResult10 = step1Result
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
onpass="Intent removal test successful",
onfail="Intent removal test failed" )
+
+ def CASE12( self, main ):
+ """
+ Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
+ """
+ import re
+ import copy
+ import time
+
+ Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
+ threadID = 0
+
+ main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
+ main.log.report( "_____________________________________________________" )
+ main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
+ main.step( "Enable intent based Reactive forwarding" )
+ installResult = main.FALSE
+ feature = "onos-app-ifwd"
+
+ pool = []
+ time1 = time.time()
+ for cli,feature in main.CLIs:
+ t = main.Thread(target=cli,threadID=threadID,
+ name="featureInstall",args=[feature])
+ pool.append(t)
+ t.start()
+ threadID = threadID + 1
+
+ results = []
+ for thread in pool:
+ thread.join()
+ results.append(thread.result)
+ time2 = time.time()
+
+ if( all(result == main.TRUE for result in results) == False):
+ main.log.info("Did not install onos-app-ifwd feature properly")
+ #main.cleanup()
+ #main.exit()
+ else:
+ main.log.info("Successful feature:install onos-app-ifwd")
+ installResult = main.TRUE
+ main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
+
+ main.step( "Verify Pingall" )
+ ping_result = main.FALSE
+ time1 = time.time()
+ ping_result = main.Mininet1.pingall(timeout=600)
+ time2 = time.time()
+ timeDiff = round( ( time2 - time1 ), 2 )
+ main.log.report(
+ "Time taken for Ping All: " +
+ str( timeDiff ) +
+ " seconds" )
+
+ if ping_result == main.TRUE:
+ main.log.report( "Pingall Test in Reactive mode successful" )
+ else:
+ main.log.report( "Pingall Test in Reactive mode failed" )
+
+ main.step( "Disable Intent based Reactive forwarding" )
+ uninstallResult = main.FALSE
+
+ pool = []
+ time1 = time.time()
+ for cli,feature in main.CLIs:
+ t = main.Thread(target=cli,threadID=threadID,
+ name="featureUninstall",args=[feature])
+ pool.append(t)
+ t.start()
+ threadID = threadID + 1
+
+ results = []
+ for thread in pool:
+ thread.join()
+ results.append(thread.result)
+ time2 = time.time()
+
+ if( all(result == main.TRUE for result in results) == False):
+ main.log.info("Did not uninstall onos-app-ifwd feature properly")
+ uninstallResult = main.FALSE
+ #main.cleanup()
+ #main.exit()
+ else:
+ main.log.info("Successful feature:uninstall onos-app-ifwd")
+ uninstallResult = main.TRUE
+ main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
+
+ # Waiting for reative flows to be cleared.
+ time.sleep( 10 )
+
+ case11Result = installResult and ping_result and uninstallResult
+ utilities.assert_equals( expect=main.TRUE, actual=case11Result,
+ onpass="Intent based Reactive forwarding Pingall test PASS",
+ onfail="Intent based Reactive forwarding Pingall test FAIL" )
+
+ def CASE99(self):
+ import time
+ # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
+ main.step( "Stop ONOS on all Nodes" )
+ stopResult = main.TRUE
+ for i in range( 1, int( main.numCtrls ) + 1 ):
+ ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+ main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
+ sresult = main.ONOSbench.onosStop( ONOS_ip )
+ utilities.assert_equals( expect=main.TRUE, actual=sresult,
+ onpass="Test step PASS",
+ onfail="Test step FAIL" )
+ stopResult = ( stopResult and sresult )
+
+ main.step( "Start ONOS on all Nodes" )
+ startResult = main.TRUE
+ for i in range( 1, int( main.numCtrls ) + 1 ):
+ ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+ main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
+ sresult = main.ONOSbench.onosStart( ONOS_ip )
+ utilities.assert_equals( expect=main.TRUE, actual=sresult,
+ onpass="Test step PASS",
+ onfail="Test step FAIL" )
+ startResult = ( startResult and sresult )
+
+ main.step( "Start ONOS CLI on all nodes" )
+ cliResult = main.TRUE
+ time.sleep( 30 )
+ main.log.step(" Start ONOS cli using thread ")
+ pool = []
+ time1 = time.time()
+ for i in range( int( main.numCtrls ) ):
+ t = main.Thread(target=main.CLIs[i].startOnosCli,
+ threadID=main.threadID,
+ name="startOnosCli",
+ args=[main.nodes[i].ip_address])
+ pool.append(t)
+ t.start()
+ main.threadID = main.threadID + 1
+ for t in pool:
+ t.join()
+ cliResult = cliResult and t.result
+ time2 = time.time()
+
+ if not cliResult:
+ main.log.info("ONOS CLI did not start up properly")
+ #main.cleanup()
+ #main.exit()
+ else:
+ main.log.info("Successful CLI startup")
+ main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
+
+ case99Result = ( startResult and cliResult )
+ time.sleep(30)
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case99Result,
+ onpass="Starting new Chordal topology test PASS",
+ onfail="Starting new Chordal topology test FAIL" )
+
+
+
+
+
diff --git a/TestON/tests/OnosCHO/OnosCHO.topo b/TestON/tests/OnosCHO/OnosCHO.topo
index 2a79611..9b0c3e7 100644
--- a/TestON/tests/OnosCHO/OnosCHO.topo
+++ b/TestON/tests/OnosCHO/OnosCHO.topo
@@ -2,16 +2,18 @@
<COMPONENT>
<ONOSbench>
- <host>10.128.40.40</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
<connect_order>1</connect_order>
- <COMPONENTS> </COMPONENTS>
+ <COMPONENTS>
+ <home> ~/ONOS</home>
+ </COMPONENTS>
</ONOSbench>
<ONOScli1>
- <host>10.128.40.40</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -20,7 +22,7 @@
</ONOScli1>
<ONOScli2>
- <host>10.128.40.40</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -29,7 +31,7 @@
</ONOScli2>
<ONOScli3>
- <host>10.128.40.40</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -38,7 +40,7 @@
</ONOScli3>
<ONOScli4>
- <host>10.128.40.40</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -47,7 +49,7 @@
</ONOScli4>
<ONOScli5>
- <host>10.128.40.40</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -56,7 +58,7 @@
</ONOScli5>
<ONOS1>
- <host>10.128.40.40</host>
+ <host>10.128.10.21</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -65,7 +67,7 @@
</ONOS1>
<ONOS2>
- <host>10.128.40.40</host>
+ <host>10.128.10.22</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -74,7 +76,7 @@
</ONOS2>
<ONOS3>
- <host>10.128.40.40</host>
+ <host>10.128.10.23</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -83,7 +85,7 @@
</ONOS3>
<ONOS4>
- <host>10.128.40.40</host>
+ <host>10.128.10.24</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -92,7 +94,7 @@
</ONOS4>
<ONOS5>
- <host>10.128.40.40</host>
+ <host>10.128.10.25</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -101,7 +103,7 @@
</ONOS5>
<Mininet1>
- <host>10.128.40.40</host>
+ <host>10.128.40.50</host>
<user>admin</user>
<password>onos_test</password>
<type>MininetCliDriver</type>
@@ -114,20 +116,6 @@
<controller> remote </controller>
</COMPONENTS>
</Mininet1>
-
- <Mininet2>
- <host>10.128.40.40</host>
- <user>admin</user>
- <password>onos_test</password>
- <type>RemoteMininetDriver</type>
- <connect_order>13</connect_order>
- <COMPONENTS>
- #Specify the Option for mininet
- <arg1> --custom ~/mininet/custom/att-mpls-topo.py </arg1>
- <arg2> --topo att </arg2>
- <arg3> --link tc --switch ovs,protocols=OpenFlow13 </arg3>
- <controller> remote </controller>
- </COMPONENTS>
- </Mininet2>
</COMPONENT>
+
</TOPOLOGY>
diff --git a/TestON/tests/PeeringRouterTest/PeeringRouterTest.params b/TestON/tests/PeeringRouterTest/PeeringRouterTest.params
new file mode 100755
index 0000000..0c4af63
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/PeeringRouterTest.params
@@ -0,0 +1,26 @@
+<PARAMS>
+
+ <testcases>5,7,8,9,31,32</testcases>
+
+ #Environment variables
+ <ENV>
+ <cellName>sdnip_single_instance</cellName>
+ <home>/home/admin/ONLabTest/TestON/tests/PeeringRouterTest</home>
+ </ENV>
+
+ <CTRL>
+ <ip1>127.0.0.1</ip1>
+ <port1>6633</port1>
+ </CTRL>
+
+ <GIT>
+ <autoPull>off</autoPull>
+ <checkout>master</checkout>
+ </GIT>
+
+ <JSON>
+ <prefix>prefix</prefix>
+ <nextHop>nextHop</nextHop>
+ </JSON>
+
+</PARAMS>
diff --git a/TestON/tests/PeeringRouterTest/PeeringRouterTest.py b/TestON/tests/PeeringRouterTest/PeeringRouterTest.py
new file mode 100755
index 0000000..fec9365
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/PeeringRouterTest.py
@@ -0,0 +1,2537 @@
+# from cupshelpers.config import prefix
+
+# Testing the basic functionality of SDN-IP
+
+class PeeringRouterTest:
+
+ def __init__( self ):
+ self.default = ''
+
+
+ def CASE6 ( self, main):
+
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
+ TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet"
+ # Launch mininet topology for this case
+ MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py"
+ main.step( "Launch mininet" )
+ main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
+ main.step("waiting 20 secs for all switches and quagga instances to comeup")
+ time.sleep(20)
+ main.step( "Test whether Mininet is started" )
+
+ #============================= Ping Test ========================
+ main.log.info("Start ping test")
+
+ for m in range( 3, 6 ):
+ for n in range( 1, 11 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ pingTestResults = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+
+ def CASE4( self, main):
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
+ TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/mininet"
+ SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
+ main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
+
+ # Copy the json files to config dir
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
+
+ # Launch mininet topology for this case
+ MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininet.py"
+ main.step( "Launch mininet" )
+ main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
+ main.step("waiting 20 secs for all switches and quagga instances to comeup")
+ time.sleep(20)
+ main.step( "Test whether Mininet is started" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+
+ main.log.info( "Generate prefixes for host3" )
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+
+ main.ONOScli.startOnosCli( ONOS1Ip )
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing bgprouter feature" )
+ main.ONOScli.featureInstall( "onos-app-bgprouter" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ time.sleep( 30 )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+ main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
+
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report( "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="disconnect check PASS",
+ onfail="disconnect check FAIL")
+
+ main.ONOScli.logout()
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.Mininet.stopNet()
+ time.sleep(10)
+
+ def CASE5( self, main ):
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
+ TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet"
+ SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
+ main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
+
+ # Copy the json files to config dir
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
+
+ # Launch mininet topology for this case
+ MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py"
+ main.step( "Launch mininet" )
+ main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
+ main.step("waiting 20 secs for all switches and quagga instances to comeup")
+ time.sleep(20)
+ main.step( "Test whether Mininet is started" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+
+ main.log.info( "Generate prefixes for host3" )
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ # Copy the cfg files to config dir
+ main.log.info("Copying two cfg files to onos etc folder")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+
+ main.ONOScli.startOnosCli( ONOS1Ip )
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing bgprouter feature" )
+ main.ONOScli.featureInstall( "onos-app-bgprouter" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ time.sleep( 30 )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ time.sleep(20)
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ sources = ["as2host", "as3host", "as6host"]
+ targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"]
+ for source in sources:
+ for target in targets:
+ r = main.Mininet.pingHost(SRC=source, TARGET=target)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Router connectivity check PASS",
+ onfail="Router connectivity check FAIL")
+
+ pingTestResults = main.TRUE
+ for m in range( 3, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ time.sleep(20)
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+ main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
+
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report( "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
+
+ time.sleep(10)
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ for m in range( 4, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.TRUE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="disconnect check PASS",
+ onfail="disconnect check FAIL")
+
+
+ time.sleep(20);
+
+ main.ONOScli.logout()
+ main.log.info("ONOS cli logout")
+ time.sleep(20);
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.log.info("onos stop")
+ time.sleep(20);
+ main.Mininet.stopNet()
+ main.log.info("mininet stop")
+ time.sleep(20)
+
+
+ def CASE7( self, main ):
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
+ TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet"
+ SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
+ main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
+
+ # Copy the json files to config dir
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
+
+ # Launch mininet topology for this case
+ MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py"
+ main.step( "Launch mininet" )
+ main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
+ main.step("waiting 20 secs for all switches and quagga instances to comeup")
+ time.sleep(20)
+ main.step( "Test whether Mininet is started" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+
+ main.log.info( "Generate prefixes for host3" )
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 3500 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 3500 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 3500 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ # Copy the cfg files to config dir
+ main.log.info("Copying two cfg files to onos etc folder")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+
+ main.ONOScli.startOnosCli( ONOS1Ip )
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing bgprouter feature" )
+ main.ONOScli.featureInstall( "onos-app-bgprouter" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ time.sleep(20)
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ time.sleep(20)
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ time.sleep(60)
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ time.sleep(20)
+
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ for m in range( 3, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ time.sleep(10)
+
+ main.ONOScli.logout()
+ main.log.info("ONOS cli logout")
+ time.sleep(20);
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.log.info("onos stop")
+ time.sleep(20);
+ main.Mininet.stopNet()
+ main.log.info("mininet stop")
+ time.sleep(20)
+
+ # Route flap test (Add a route and detele it very fast 20 times) in VLAN configuration
+ def CASE8( self, main ):
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
+ TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet"
+ SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
+ main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
+
+ # Copy the json files to config dir
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
+
+ # Launch mininet topology for this case
+ MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py"
+ main.step( "Launch mininet" )
+ main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
+ main.step("waiting 20 secs for all switches and quagga instances to comeup")
+ time.sleep(20)
+ main.step( "Test whether Mininet is started" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+
+ main.log.info( "Generate prefixes for host3" )
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 1 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 1 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost5
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ # Copy the cfg files to config dir
+ main.log.info("Copying two cfg files to onos etc folder")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+
+ main.ONOScli.startOnosCli( ONOS1Ip )
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing bgprouter feature" )
+ main.ONOScli.featureInstall( "onos-app-bgprouter" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add and delete a route to Quagga on host3 20 times" )
+ for i in range(0, 20):
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+ main.log.info("Add a route %s times", i)
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.log.info("Delete the route")
+ time.sleep(0.1)
+
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+ main.log.info("Add the route finally and wait for 10 sec")
+
+ #============================= Ping Test ========================
+ for j in range(0, 30):
+ r = main.Mininet.pingHost(SRC="as6host", TARGET="3.0.0.1")
+
+ utilities.assert_equals(expect=main.TRUE,actual=r,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ #time.sleep(20)
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add and delete a route to Quagga on host3 20 times" )
+ for i in range(0, 20):
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+ main.log.info("Add a route %s times", i)
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.log.info("Delete the route")
+ time.sleep(0.1)
+
+ main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = []
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+
+ for j in range(0, 5):
+ r = main.Mininet.pingHost(SRC="as6host", TARGET="3.0.0.1")
+
+ utilities.assert_equals(expect=main.FALSE,actual=r,
+ onpass="disconnectivity check PASS",
+ onfail="disconnectivity check FAIL")
+
+ main.ONOScli.logout()
+ main.log.info("ONOS cli logout")
+ time.sleep(20);
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.log.info("onos stop")
+ time.sleep(20);
+ main.Mininet.stopNet()
+ main.log.info("mininet stop")
+ time.sleep(20)
+
+ # Route flap test (change the next-hop very fast 20 times) in VLAN configuration
+ def CASE9( self, main):
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
+ TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeconvergence/mininet"
+ SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
+ main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
+
+ # Copy the json files to config dir
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
+
+ # Launch mininet topology for this case
+ MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceVlanMininet.py"
+ main.step( "Launch mininet" )
+ main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
+ main.step("waiting 20 secs for all switches and quagga instances to comeup")
+ time.sleep(20)
+ main.step( "Test whether Mininet is started" )
+ main.log.info( "Login Quagga CLI on host3" )
+ result = main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ #if result is not main.TRUE:
+ # main.log.report("Mininet is not started...Aborting")
+ # main.Mininet.stopNet()
+ # main.cleanup()
+ # main.exit()
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+ main.log.info( "Generate prefixes for host3" )
+
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ utilities.assert_equals(expect=main.TRUE,actual=verifyResult,onpass="Verify cell pass!",onfail="Verify cell failed...")
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ # Copy the cfg files to config dir
+ main.log.info("Copying two cfg files to onos etc folder")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+ if onos1InstallResult is not main.TRUE:
+ main.log.report("ONOS is not installed...Aborting")
+ main.Mininet.stopNet()
+ main.cleanup()
+ main.exit()
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if onos1Isup is not main.TRUE:
+ main.log.report("ONOS1 didn't start!...Aborting" )
+ main.Mininet.stopNet()
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.cleanup()
+ main.exit()
+
+ main.step( "Start ONOS-cli" )
+
+ result = main.ONOScli.startOnosCli( ONOS1Ip )
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS CLI is up!",onfail="ONOS CLI is not up...")
+ if result is not main.TRUE:
+ main.log.report("ONOS1 didn't start!...Aborting" )
+ main.Mininet.stopNet()
+ main.ONOScli.logout()
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.cleanup()
+ main.exit()
+
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing bgprouter feature" )
+ main.ONOScli.featureInstall( "onos-app-bgprouter" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ time.sleep( 30 )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ #============= Flap the BGP session between QuaggaCliHost4 and ONOS ==================
+ main.log.info( "Disabling bgp session and enable it 20 times very fast between QuaggaCliHost4 and 192.168.30.101:" )
+ for i in range(0, 20):
+ main.log.info("Disable it %s times", i)
+ main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513")
+ main.log.info("Enable it again")
+ main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
+ time.sleep(0.1)
+ main.log.info("Disable it finally")
+ main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513")
+
+ main.log.info( "Sleeping for 30 seconds for network to converge" )
+ time.sleep(30)
+ # get routes inside SDN-IP
+ main.log.info( "Getting Routes from ONOS CLI" )
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ newAllRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
+
+ # Expected routes with changed next hop
+ newAllRoutesExpected = []
+ for prefix in prefixesHost3:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ for prefix in prefixesHost4:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ for prefix in prefixesHost5:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
+ main.step( "Check routes installed after convergence-1" )
+ main.log.info( "Routes expected:" )
+ main.log.info( newAllRoutesStrExpected )
+ main.log.info( "Routes got from ONOS CLI after convergence-1:" )
+ main.log.info( newAllRoutesStrActual )
+ utilities.assertEquals(
+ expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct after convergence!***",
+ onfail="***Routes in SDN-IP are wrong after convergence!***" )
+ if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after convergence are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after convergence are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ for m in range( 3, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ #============= Flap the BGP session between QuaggaCliHost4 and ONOS ==================
+ main.log.info( "Disabling bgp session and enable it 20 times very fast between QuaggaCliHost4 and 192.168.30.101:" )
+ for i in range(0, 20):
+ main.log.info("Disable it %s times", i)
+ main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513")
+ main.log.info("Enable it again")
+ main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
+ time.sleep(0.1)
+
+ main.log.info( "Sleeping for 30 seconds for network to converge" )
+ time.sleep(30)
+
+ # get routes inside SDN-IP
+ main.log.info( "Getting Routes from ONOS CLI" )
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ newAllRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
+
+ # Expected routes with changed next hop
+ newAllRoutesExpected = []
+ for prefix in prefixesHost3:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ for prefix in prefixesHost4:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ for prefix in prefixesHost5:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
+ main.step( "Check routes installed after convergence-2" )
+ main.log.info( "Routes expected:" )
+ main.log.info( newAllRoutesStrExpected )
+ main.log.info( "Routes got from ONOS CLI after convergence-2:" )
+ main.log.info( newAllRoutesStrActual )
+ utilities.assertEquals(
+ expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct after convergence!***",
+ onfail="***Routes in SDN-IP are wrong after convergence!***" )
+ if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after convergence are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after convergence are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ for m in range( 3, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ main.ONOScli.logout()
+ main.log.info("ONOS cli logout")
+ time.sleep(20);
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.log.info("onos stop")
+ time.sleep(20);
+ main.Mininet.stopNet()
+ main.log.info("mininet stop")
+ time.sleep(20)
+
+ # Route convergence and connectivity test
+ def CASE21( self, main):
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
+ TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeconvergence/mininet"
+ SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
+ main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
+
+ # Copy the json files to config dir
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
+
+ # Launch mininet topology for this case
+ MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceMininet.py"
+ main.step( "Launch mininet" )
+ main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
+ main.step("waiting 20 secs for all switches and quagga instances to comeup")
+ time.sleep(20)
+ main.step( "Test whether Mininet is started" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+ main.log.info( "Generate prefixes for host3" )
+
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ # Copy the cfg files to config dir
+ main.log.info("Copying two cfg files to onos etc folder")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+
+ main.ONOScli.startOnosCli( ONOS1Ip )
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing gbprouter feature" )
+ main.ONOScli.featureInstall( "onos-app-bgprouter" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ time.sleep( 30 )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
+ main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
+ main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
+ main.log.info( "Sleeping for 150 seconds for network to converge" )
+ time.sleep(150)
+ # get routes inside SDN-IP
+ main.log.info( "Getting Routes from ONOS CLI" )
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ newAllRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
+
+ # Expected routes with changed next hop
+ newAllRoutesExpected = []
+ for prefix in prefixesHost3:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ for prefix in prefixesHost4:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ for prefix in prefixesHost5:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
+ main.step( "Check routes installed after convergence-1" )
+ main.log.info( "Routes expected:" )
+ main.log.info( newAllRoutesStrExpected )
+ main.log.info( "Routes got from ONOS CLI after convergence-1:" )
+ main.log.info( newAllRoutesStrActual )
+ utilities.assertEquals(
+ expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct after convergence!***",
+ onfail="***Routes in SDN-IP are wrong after convergence!***" )
+ if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after convergence are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after convergence are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
+ main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
+ main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
+ main.log.info( "Sleeping for 150 seconds for network to converge" )
+ time.sleep(150)
+ # get routes inside SDN-IP
+ main.log.info( "Getting Routes from ONOS CLI" )
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ newAllRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
+
+ # Expected routes with changed next hop
+ newAllRoutesExpected = []
+ for prefix in prefixesHost3:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ for prefix in prefixesHost4:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ for prefix in prefixesHost5:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
+ main.step( "Check routes installed after convergence-2" )
+ main.log.info( "Routes expected:" )
+ main.log.info( newAllRoutesStrExpected )
+ main.log.info( "Routes got from ONOS CLI after convergence-2:" )
+ main.log.info( newAllRoutesStrActual )
+ utilities.assertEquals(
+ expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct after convergence!***",
+ onfail="***Routes in SDN-IP are wrong after convergence!***" )
+ if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after convergence are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after convergence are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+ main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
+
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report( "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="disconnect check PASS",
+ onfail="disconnect check FAIL")
+
+ main.ONOScli.logout()
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.Mininet.stopNet()
+ time.sleep(10)
+
+ # Route convergence and connectivity test with Route Server
+ def CASE22( self, main):
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
+ TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeserver/mininet"
+ SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/routeserver/sdnip.json"
+ main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
+
+ # Copy the json files to config dir
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/addresses.json ~/onos/tools/package/config/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/sdnip.json ~/onos/tools/package/config/")
+
+ # Launch mininet topology for this case
+ MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerMininet.py"
+ main.step( "Launch mininet" )
+ main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
+ main.step("waiting 20 secs for all switches and quagga instances to comeup")
+ time.sleep(20)
+ main.step( "Test whether Mininet is started" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+ main.log.info( "Generate prefixes for host3" )
+
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ # Copy the cfg files to config dir
+ main.log.info("Copying two cfg files to onos etc folder")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+
+ main.ONOScli.startOnosCli( ONOS1Ip )
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing gbprouter feature" )
+ main.ONOScli.featureInstall( "onos-app-bgprouter" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ time.sleep( 60 )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
+ main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
+ main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
+ main.log.info( "Sleeping for 150 seconds for network to converge" )
+ time.sleep(150)
+ # get routes inside SDN-IP
+ main.log.info( "Getting Routes from ONOS CLI" )
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ newAllRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
+
+ # Expected routes with changed next hop
+ newAllRoutesExpected = []
+ for prefix in prefixesHost3:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ for prefix in prefixesHost4:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ for prefix in prefixesHost5:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
+ main.step( "Check routes installed after convergence-1" )
+ main.log.info( "Routes expected:" )
+ main.log.info( newAllRoutesStrExpected )
+ main.log.info( "Routes got from ONOS CLI after convergence-1:" )
+ main.log.info( newAllRoutesStrActual )
+ utilities.assertEquals(
+ expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct after convergence!***",
+ onfail="***Routes in SDN-IP are wrong after convergence!***" )
+ if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after convergence are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after convergence are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
+ main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
+ main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
+ main.log.info( "Sleeping for 150 seconds for network to converge" )
+ time.sleep(150)
+ # get routes inside SDN-IP
+ main.log.info( "Getting Routes from ONOS CLI" )
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ newAllRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
+
+ # Expected routes with changed next hop
+ newAllRoutesExpected = []
+ for prefix in prefixesHost3:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ for prefix in prefixesHost4:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ for prefix in prefixesHost5:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
+ main.step( "Check routes installed after convergence-2" )
+ main.log.info( "Routes expected:" )
+ main.log.info( newAllRoutesStrExpected )
+ main.log.info( "Routes got from ONOS CLI after convergence-2:" )
+ main.log.info( newAllRoutesStrActual )
+ utilities.assertEquals(
+ expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct after convergence!***",
+ onfail="***Routes in SDN-IP are wrong after convergence!***" )
+ if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after convergence are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after convergence are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+ main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
+
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report( "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="disconnect check PASS",
+ onfail="disconnect check FAIL")
+
+ main.ONOScli.logout()
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.Mininet.stopNet()
+ time.sleep(10)
+
+ # Route convergence and connectivity test in VLAN configuration
+ def CASE31( self, main):
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
+ TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeconvergence/mininet"
+ SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
+ main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
+
+ # Copy the json files to config dir
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
+
+ # Launch mininet topology for this case
+ MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceVlanMininet.py"
+ main.step( "Launch mininet" )
+ main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
+ main.step("waiting 20 secs for all switches and quagga instances to comeup")
+ time.sleep(20)
+ main.step( "Test whether Mininet is started" )
+ main.log.info( "Login Quagga CLI on host3" )
+ result = main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ #if result is not main.TRUE:
+ # main.log.report("Mininet is not started...Aborting")
+ # main.Mininet.stopNet()
+ # main.cleanup()
+ # main.exit()
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+ main.log.info( "Generate prefixes for host3" )
+
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ utilities.assert_equals(expect=main.TRUE,actual=verifyResult,onpass="Verify cell pass!",onfail="Verify cell failed...")
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ # Copy the cfg files to config dir
+ main.log.info("Copying two cfg files to onos etc folder")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+ if onos1InstallResult is not main.TRUE:
+ main.log.report("ONOS is not installed...Aborting")
+ main.Mininet.stopNet()
+ main.cleanup()
+ main.exit()
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if onos1Isup is not main.TRUE:
+ main.log.report("ONOS1 didn't start!...Aborting" )
+ main.Mininet.stopNet()
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.cleanup()
+ main.exit()
+
+ main.step( "Start ONOS-cli" )
+
+ result = main.ONOScli.startOnosCli( ONOS1Ip )
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS CLI is up!",onfail="ONOS CLI is not up...")
+ if result is not main.TRUE:
+ main.log.report("ONOS1 didn't start!...Aborting" )
+ main.Mininet.stopNet()
+ main.ONOScli.logout()
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.cleanup()
+ main.exit()
+
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing bgprouter feature" )
+ main.ONOScli.featureInstall( "onos-app-bgprouter" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ time.sleep( 30 )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ sources = ["as2host", "as3host", "as6host"]
+ targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"]
+ for source in sources:
+ for target in targets:
+ r = main.Mininet.pingHost(SRC=source, TARGET=target)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Router connectivity check PASS",
+ onfail="Router connectivity check FAIL")
+
+ pingTestResults = main.TRUE
+ for m in range( 3, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ time.sleep(20)
+
+ #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
+ main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
+ main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
+ main.log.info( "Sleeping for 150 seconds for network to converge" )
+ time.sleep(150)
+ # get routes inside SDN-IP
+ main.log.info( "Getting Routes from ONOS CLI" )
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ newAllRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
+
+ # Expected routes with changed next hop
+ newAllRoutesExpected = []
+ for prefix in prefixesHost3:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ for prefix in prefixesHost4:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ for prefix in prefixesHost5:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
+ main.step( "Check routes installed after convergence-1" )
+ main.log.info( "Routes expected:" )
+ main.log.info( newAllRoutesStrExpected )
+ main.log.info( "Routes got from ONOS CLI after convergence-1:" )
+ main.log.info( newAllRoutesStrActual )
+ utilities.assertEquals(
+ expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct after convergence!***",
+ onfail="***Routes in SDN-IP are wrong after convergence!***" )
+ if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after convergence are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after convergence are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ sources = ["as2host", "as3host", "as6host"]
+ targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"]
+ for source in sources:
+ for target in targets:
+ r = main.Mininet.pingHost(SRC=source, TARGET=target)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Router connectivity check PASS",
+ onfail="Router connectivity check FAIL")
+
+ pingTestResults = main.TRUE
+ for m in range( 3, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ time.sleep(20)
+
+ #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
+ main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
+ main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
+ main.log.info( "Sleeping for 150 seconds for network to converge" )
+ time.sleep(150)
+ # get routes inside SDN-IP
+ main.log.info( "Getting Routes from ONOS CLI" )
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ newAllRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
+
+ # Expected routes with changed next hop
+ newAllRoutesExpected = []
+ for prefix in prefixesHost3:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ for prefix in prefixesHost4:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ for prefix in prefixesHost5:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
+ main.step( "Check routes installed after convergence-2" )
+ main.log.info( "Routes expected:" )
+ main.log.info( newAllRoutesStrExpected )
+ main.log.info( "Routes got from ONOS CLI after convergence-2:" )
+ main.log.info( newAllRoutesStrActual )
+ utilities.assertEquals(
+ expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct after convergence!***",
+ onfail="***Routes in SDN-IP are wrong after convergence!***" )
+ if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after convergence are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after convergence are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
+ main.log.info("Ping test result")
+ if pingTestResults:
+ main.log.info("Test succeeded")
+ else:
+ main.log.info("Test failed")
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+ main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
+
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report( "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ for m in range( 4, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.TRUE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="disconnect check PASS",
+ onfail="disconnect check FAIL")
+
+ time.sleep(20);
+
+ main.ONOScli.logout()
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.Mininet.stopNet()
+ time.sleep(10)
+
+ # Route convergence and connectivity test with Route Server in VLAN tagged network
+ def CASE32( self, main):
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
+ TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeserver/mininet"
+ SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/routeserver/sdnip.json"
+ main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
+
+ # Copy the json files to config dir
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/routeserver/addresses.json ~/onos/tools/package/config/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/routeserver/sdnip.json ~/onos/tools/package/config/")
+
+ # Launch mininet topology for this case
+ MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerVlanMininet.py"
+ main.step( "Launch mininet" )
+ main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
+ main.step("waiting 20 secs for all switches and quagga instances to comeup")
+ time.sleep(20)
+ main.step( "Test whether Mininet is started" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+ main.log.info( "Generate prefixes for host3" )
+
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ # Copy the cfg files to config dir
+ main.log.info("Copying two cfg files to onos etc folder")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/")
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+
+ main.ONOScli.startOnosCli( ONOS1Ip )
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing gbprouter feature" )
+ main.ONOScli.featureInstall( "onos-app-bgprouter" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ time.sleep( 60 )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ sources = ["as2host", "as3host", "as6host"]
+ targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"]
+ for source in sources:
+ for target in targets:
+ r = main.Mininet.pingHost(SRC=source, TARGET=target)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Router connectivity check PASS",
+ onfail="Router connectivity check FAIL")
+
+ pingTestResults = main.TRUE
+ for m in range( 3, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ time.sleep(20)
+
+ #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
+ main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
+ main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
+ main.log.info( "Sleeping for 150 seconds for network to converge" )
+ time.sleep(150)
+ # get routes inside SDN-IP
+ main.log.info( "Getting Routes from ONOS CLI" )
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ newAllRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
+
+ # Expected routes with changed next hop
+ newAllRoutesExpected = []
+ for prefix in prefixesHost3:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ for prefix in prefixesHost4:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ for prefix in prefixesHost5:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
+ main.step( "Check routes installed after convergence-1" )
+ main.log.info( "Routes expected:" )
+ main.log.info( newAllRoutesStrExpected )
+ main.log.info( "Routes got from ONOS CLI after convergence-1:" )
+ main.log.info( newAllRoutesStrActual )
+ utilities.assertEquals(
+ expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct after convergence!***",
+ onfail="***Routes in SDN-IP are wrong after convergence!***" )
+ if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after convergence are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after convergence are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ sources = ["as2host", "as3host", "as6host"]
+ targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"]
+ for source in sources:
+ for target in targets:
+ r = main.Mininet.pingHost(SRC=source, TARGET=target)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Router connectivity check PASS",
+ onfail="Router connectivity check FAIL")
+
+ pingTestResults = main.TRUE
+ for m in range( 3, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ time.sleep(20)
+
+ #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
+ main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
+ main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
+ main.log.info( "Sleeping for 150 seconds for network to converge" )
+ time.sleep(150)
+ # get routes inside SDN-IP
+ main.log.info( "Getting Routes from ONOS CLI" )
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ newAllRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
+
+ # Expected routes with changed next hop
+ newAllRoutesExpected = []
+ for prefix in prefixesHost3:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ for prefix in prefixesHost4:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ for prefix in prefixesHost5:
+ newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
+ main.step( "Check routes installed after convergence-2" )
+ main.log.info( "Routes expected:" )
+ main.log.info( newAllRoutesStrExpected )
+ main.log.info( "Routes got from ONOS CLI after convergence-2:" )
+ main.log.info( newAllRoutesStrActual )
+ utilities.assertEquals(
+ expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct after convergence!***",
+ onfail="***Routes in SDN-IP are wrong after convergence!***" )
+ if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after convergence are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after convergence are wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ sources = ["as2host", "as3host", "as6host"]
+ targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"]
+ for source in sources:
+ for target in targets:
+ r = main.Mininet.pingHost(SRC=source, TARGET=target)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Router connectivity check PASS",
+ onfail="Router connectivity check FAIL")
+
+ pingTestResults = main.TRUE
+ for m in range( 3, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.FALSE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="Default connectivity check PASS",
+ onfail="Default connectivity check FAIL")
+
+ time.sleep(20)
+
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+ main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
+
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report( "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
+
+ #============================= Ping Test ========================
+ pingTestResults = main.TRUE
+ for m in range( 4, 6 ):
+ for n in range( 1, 10 ):
+ hostIp = str( m ) + ".0." + str( n ) + ".1"
+ r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
+ if r == main.TRUE:
+ pingTestResults = main.FALSE
+
+ utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
+ onpass="disconnect check PASS",
+ onfail="disconnect check FAIL")
+ time.sleep(20)
+
+ main.ONOScli.logout()
+ main.ONOSbench.onosStop(ONOS1Ip);
+ main.Mininet.stopNet()
+ time.sleep(10)
+
diff --git a/TestON/tests/PeeringRouterTest/PeeringRouterTest.topo b/TestON/tests/PeeringRouterTest/PeeringRouterTest.topo
new file mode 100755
index 0000000..a1e2c45
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/PeeringRouterTest.topo
@@ -0,0 +1,82 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <Mininet>
+ <host>127.0.0.1</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </Mininet>
+
+ <ONOSbench>
+ <host>127.0.0.1</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS>
+ <home>~/onos</home>
+ </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli>
+ <host>127.0.0.1</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS>
+ <home>~/onos</home>
+ </COMPONENTS>
+ </ONOScli>
+
+ <ONOS1>
+ <host>127.0.0.1</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS>
+ <home>~/onos</home>
+ </COMPONENTS>
+ </ONOS1>
+
+ <QuaggaCliHost3>
+ <host>1.168.30.2</host>
+ <user>admin</user>
+ <password></password>
+ <type>QuaggaCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </QuaggaCliHost3>
+ <QuaggaCliHost4>
+ <host>1.168.30.3</host>
+ <user>admin</user>
+ <password></password>
+ <type>QuaggaCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </QuaggaCliHost4>
+ <QuaggaCliHost5>
+ <host>1.168.30.5</host>
+ <user>admin</user>
+ <password></password>
+ <type>QuaggaCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </QuaggaCliHost5>
+ <QuaggaCliHost>
+ <host>1.168.30.100</host>
+ <user>admin</user>
+ <password></password>
+ <type>QuaggaCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </QuaggaCliHost>
+
+
+ </COMPONENT>
+</TOPOLOGY>
+
diff --git a/TestON/tests/PeeringRouterTest/README.md b/TestON/tests/PeeringRouterTest/README.md
new file mode 100644
index 0000000..002a0f1
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/README.md
@@ -0,0 +1,44 @@
+
+
+1) Install TestON framework from https://github.com/srikanthvavila/ONLabTest (Follow README instructions. Until forked repo is mrged back, use URL https://github.com/srikanthvavila/ONLabTest for cloning this repo. You can ignore Linc-OE and STS installation steps as we may not need them for now)
+
+2) Peering router testcases are under ~/TestON/tests/PeeringRouterTest folder:
+a) CASE4 - Basic Route advertisement and connectivity in untagged network
+b) CASE5 - Basic Route advertisement and connectivity in tagged network
+c) CASE7 - Scale test with 25k routes
+d) CASE8 - Flap a route 20 times with 100 msec interval
+e) CASE9 - Flap a next-hop 20 times with 100 msec interval
+f) CASE21 - Route convergence due to bgp peering session flapping in untagged network
+g) CASE22 - Basic Route advertisement and connectivity in untagged network with Route server
+h) CASE31 - Route convergence due to bgp peering session flapping in tagged network
+i) CASE32 - Basic Route advertisement and connectivity in tagged network with Route server
+
+3) Before running the testcases, ensure quagga is installed on the machine:
+a) "sudo apt-get install quagga"
+b) "Create a folder for /usr/local/var/run/quagga"
+c) "chmod 777" to quagga folder
+
+4) Test environment assumes the TestON, ONOS and Mininet all are running in the same VM. These testcases are not verified with the components running in separate VMs.
+
+5) Before running testcases, edit the following files and make necessary changes:
+a) ~/TestON/tests/PeeringRouterTest/PeeringRouterTest.params --> Edit "cellname", "test home folder" and "controller IP" fields
+b) ~/TestON/tests/PeeringRouterTest/PeeringRouterTest.topo --> Edit "host", "user", "password", "home" fields under "ONOSbench", "ONOSCli" and "ONOS1". Similalry edit "user" field under "QuaggaCliHost<>" (You can use the same user name as your mininet VM)
+d) ~/TestON/drivers/common/cli/onosclidriver.py --> Change the line "self.handle.expect( "ONOS_CELL=" + str( cellname ) )" to "self.handle.expect( "ONOS_CELL" )"
+
+6) Ensure the ONOS cell file has the following lines populated:
+OCI=127.0.0.1
+OC1=127.0.0.1
+OC2=127.0.0.1
+OCN=127.0.0.1
+ONOS_FEATURES=webconsole,onos-api,onos-core-trivial,onos-cli,onos-openflow,onos-gui,onos-rest,onos-app-config,onos-app-proxyarp
+ONOS_USER=<user>
+ONOS_GROUP=<user>
+ONOS_NIC=127.0.0.*
+
+7) Ensure KARAF_ROOT is set to "/opt/onos/apache-karaf-3.0.2"
+
+8) Ensure JAVA_HOME is unset before sourcing ~/onos/tools/dev/bash_profile
+
+9) Ensure "onos-package" operation is done before executing the test cases
+
+10) Update the testcases to be run in ~/TestON/tests/PeeringRouterTest/PeeringRouterTest.params and execute "./cly.py run PeeringRouterTest" from ~/TestON/bin folder.
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/PeeringRouterTest/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/PeeringRouterTest/__init__.py
diff --git a/TestON/tests/PeeringRouterTest/addresses.json b/TestON/tests/PeeringRouterTest/addresses.json
new file mode 100644
index 0000000..8831f8d
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/addresses.json
@@ -0,0 +1,29 @@
+{
+ "addresses" : [
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "1",
+ "ips" : ["192.168.10.101/24"],
+ "mac" : "00:00:00:00:00:01"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "2",
+ "ips" : ["192.168.20.101/24"],
+ "mac" : "00:00:00:00:00:01"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "3",
+ "ips" : ["192.168.30.101/24"],
+ "mac" : "00:00:00:00:00:01"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "4",
+ "ips" : ["192.168.60.101/24"],
+ "mac" : "00:00:00:00:00:01"
+ }
+
+ ]
+}
diff --git a/TestON/tests/PeeringRouterTest/mininet/PeeringRouterMininet.py b/TestON/tests/PeeringRouterTest/mininet/PeeringRouterMininet.py
new file mode 100755
index 0000000..6991916
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/mininet/PeeringRouterMininet.py
@@ -0,0 +1,337 @@
+#!/usr/bin/python
+
+"""
+Start up the SDN-IP demo topology
+"""
+
+"""
+AS1 = 64513, (SDN AS)
+AS2 = 64514, reachable by 192.168.10.1, 192.168.20.1
+AS3 = 64516, reachable by 192.168.30.1
+AS4 = 64517, reachable by 192.168.40.1
+AS6 = 64520, reachable by 192.168.60.2, (route server 192.168.60.1)
+"""
+
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+
+import os.path
+import time
+import sys
+from subprocess import Popen, STDOUT, PIPE
+
+QUAGGA_DIR = '/usr/lib/quagga'
+#QUAGGA_DIR = '/usr/local/sbin'
+QUAGGA_RUN_DIR = '/usr/local/var/run/quagga'
+
+QUAGGA_CONFIG_FILE_DIR = '/home/tutorial1/ONLabTest/TestON/tests/PeeringRouterTest/mininet'
+
+class SDNIpModifiedTopo( Topo ):
+ "SDN Ip Modified Topology"
+
+ def __init__( self, *args, **kwargs ):
+ global numHost101
+ global numHost200
+ numHost101 = 101
+ numHost200 = 200
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='0000000000000001')
+ sw2 = self.addSwitch('sw2', dpid='0000000000000002')
+ #sw3 = self.addSwitch('sw3', dpid='00000000000000a3')
+ #sw4 = self.addSwitch('sw4', dpid='00000000000000a4')
+ #sw5 = self.addSwitch('sw5', dpid='00000000000000a5')
+ #sw6 = self.addSwitch('sw6', dpid='00000000000000a6')
+ #add a switch for 3 quagga hosts
+ swTestOn = self.addSwitch('swTestOn', dpid='0000000000000102')
+ #Note this switch isn't part of the SDN topology
+ #We'll use the ovs-controller to turn this into a learning switch
+ as6sw = self.addSwitch('as6sw', dpid='00000000000000a7')
+
+ host1 = self.addHost( 'host1' )
+ root1 = self.addHost( 'root1', inNamespace=False , ip='0')
+ rootTestOn = self.addHost( 'rootTestOn', inNamespace=False, ip='0' )
+
+ #AS2 host
+ host3 = self.addHost( 'host3' )
+ as2host = self.addHost( 'as2host' )
+ #AS3 host
+ host4 = self.addHost( 'host4' )
+ as3host = self.addHost( 'as3host' )
+ #AS6 host
+ host5 = self.addHost( 'host5' )
+ as6host = self.addHost( 'as6host' )
+
+ self.addLink( host1, sw2 )
+ #Links to the multihomed AS
+ self.addLink( host3, sw1 )
+ self.addLink( host3, sw1 )
+ self.addLink( as2host, host3 )
+ #Single links to the remaining two ASes
+ self.addLink( host4, sw1 )
+ self.addLink( as3host, host4 )
+
+ #AS3-AS4 link
+ #self.addLink( host4, host5)
+ #Add new AS6 to its bridge
+ self.addLink( host5, as6sw )
+ self.addLink( as6host, host5 )
+ #test the host behind the router(behind the router server)
+# for i in range(1, 10):
+ # host = self.addHost('as6host%d' % i)
+ # self.addLink(host, as6router)
+
+ ## Internal Connection To Hosts ##
+ self.addLink( root1, host1 )
+
+ # self.addLink( sw1, sw2 )
+ # self.addLink( sw1, sw3 )
+ # self.addLink( sw2, sw4 )
+ # self.addLink( sw3, sw4 )
+ # self.addLink( sw3, sw5 )
+ # self.addLink( sw4, sw6 )
+ # self.addLink( sw5, sw6 )
+ self.addLink( as6sw, sw1 )
+
+
+ self.addLink(swTestOn, rootTestOn)
+ #self.addLink(swTestOn, host1)
+ self.addLink(swTestOn, host3)
+ self.addLink(swTestOn, host4)
+ self.addLink(swTestOn, host5)
+ self.addLink(swTestOn, as2host)
+
+
+ #self.addLink(rootTestOn, host4)
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def startquagga( host, num, config_file ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f %s -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, config_file, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ print zebra_cmd
+ print quagga_cmd
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+def startquaggahost5( host, num ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f ./as4quaggas/quagga%s.conf -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, num, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+
+def stopquagga( ):
+ quietRun( 'sudo pkill -9 -f bgpd' )
+ quietRun( 'sudo pkill -9 -f zebra' )
+
+def sdn1net():
+ topo = SDNIpModifiedTopo()
+ info( '*** Creating network\n' )
+ net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=RemoteController )
+
+ host1, host3, host4, host5 = net.get( 'host1', 'host3', 'host4', 'host5' )
+
+ #host100.setIP('1.168.30.' + str(i), 24, str(host100) + "-eth2")
+
+ #host500.setMAC('00:00:00:00:04:%d' % (i-101), 'host%d-eth0' %(i))
+ #add IP prefixes
+ #for j in range(0,121):
+ #host100.cmd('sudo ip addr add %s.0.40.%s/24 dev host%s-eth0' %(i,j,i))
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ #sw1 = net.get('sw1')
+ host1.setMAC('00:00:00:00:00:01', 'host1-eth0')
+ host1.cmd('ip addr add 192.168.20.101/24 dev host1-eth0')
+ host1.cmd('ip addr add 192.168.30.101/24 dev host1-eth0')
+ #host1.cmd('ip addr add 192.168.40.101/24 dev host1-eth0')
+ host1.cmd('ip addr add 192.168.60.101/24 dev host1-eth0')
+
+ # Net has to be start after adding the above link
+ net.start()
+
+ # Set up as6sw as a learning switch as quickly as possible so it
+ # hopefully doesn't connect to the actual controller
+ # TODO figure out how to change controller before starting switch
+ as6sw = net.get('as6sw')
+ as6sw.cmd('ovs-vsctl set-controller as6sw none')
+ as6sw.cmd('ovs-vsctl set-fail-mode as6sw standalone')
+
+
+ sw1 = net.get('sw1')
+ sw1.cmd('ovs-vsctl set-controller sw1 tcp:127.0.0.1:6633')
+# sw2.cmd('ovs-vsctl set-controller sw2 tcp:127.0.0.1:6633')
+# sw3.cmd('ovs-vsctl set-controller sw3 tcp:127.0.0.1:6633')
+# sw4.cmd('ovs-vsctl set-controller sw4 tcp:127.0.0.1:6633')
+# sw5.cmd('ovs-vsctl set-controller sw5 tcp:127.0.0.1:6633')
+# sw6.cmd('ovs-vsctl set-controller sw6 tcp:127.0.0.1:6633')
+
+
+ swTestOn = net.get('swTestOn')
+ swTestOn.cmd('ovs-vsctl set-controller swTestOn none')
+ swTestOn.cmd('ovs-vsctl set-fail-mode swTestOn standalone')
+
+ host1.defaultIntf().setIP('192.168.10.101/24')
+ # Run BGPd
+ #host1.cmd('%s -d -f %s' % (BGPD, BGPD_CONF))
+ #host1.cmd('/sbin/route add default gw 192.168.10.254 dev %s-eth0' % (host1.name))
+
+ # Configure new host interfaces
+ #host2.defaultIntf().setIP('172.16.10.2/24')
+ #host2.defaultIntf().setMAC('00:00:00:00:01:02')
+ #host2.cmd('/sbin/route add default gw 172.16.10.254 dev %s-eth0' % (host2.name))
+
+ # Set up AS2
+ host3.setIP('192.168.10.1', 24, 'host3-eth0')
+ #host3.cmd('sudo ip addr add 172.16.20.1/24 dev host3-eth0')
+ host3.setIP('192.168.20.1', 24, 'host3-eth1')
+ host3.setMAC('00:00:00:00:02:01', 'host3-eth0')
+ host3.setMAC('00:00:00:00:02:02', 'host3-eth1')
+ #host3.setIP('172.16.20.254', 24, 'host3-eth2')
+ host3.setIP('3.0.0.254', 8, 'host3-eth2')
+ host3.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+
+ host3.setIP('1.168.30.2', 24, 'host3-eth3')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_ignore=1')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_announce=1')
+ as2host = net.get('as2host')
+ #as2host.defaultIntf().setIP('172.16.20.1/24')
+ for i in range(0, 20):
+ as2host.cmd('sudo ip addr add 3.0.%d.1/24 dev as2host-eth0' %i)
+ as2host.setIP('1.168.30.100', 24, 'as2host-eth1')
+
+ as2host.cmd('ip route add default via 3.0.0.254')
+
+ # Set up AS3
+ host4.setIP('192.168.30.1', 24, 'host4-eth0')
+ host4.setMAC('00:00:00:00:03:01', 'host4-eth0')
+ host4.setIP('4.0.0.254', 8, 'host4-eth1')
+ host4.setMAC('00:00:00:00:03:99', 'host4-eth1')
+ host4.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ as3host = net.get('as3host')
+ for i in range(0, 20):
+ as3host.cmd('sudo ip addr add 4.0.%d.1/24 dev as3host-eth0' %i)
+ as3host.cmd('ip route add default via 4.0.0.254')
+
+ #root space
+ host4.setIP('1.168.30.3', 24, 'host4-eth2')
+ host4.setMAC('00:00:00:00:03:03', 'host4-eth2')
+
+ # Set up AS4
+ #as4host = net.get('as4host')
+ #as4host.defaultIntf().setIP('172.16.40.1/24')
+ #as4host.cmd('ip route add default via 172.16.40.254')
+
+ # setup interface address for 100 quagga hosts
+ time.sleep(10)
+ #for i in range(numHost101, numHost200 + 1):
+ #host100 = net.get('host' + str(i))
+ #host100.cmd(str(i)+'.0.1.254', 24, 'host'+str(i)+'-eth1')
+ #as4host100 = net.get('as4host%s' %(i))
+ #as4host100.defaultIntf().setIP(str(i) + '.0.0.1/24')
+ #as4host100.cmd('ip route add default via ' + str(i) + '.0.0.254')
+ #for j in range(0, 100):
+ #as4host100.cmd('sudo ip addr add %d.0.%d.1/24 dev %s-eth0' %(i, j, as4host100))
+
+ # Set up AS6 - This has a router and a route server
+ #as6rs, host5 = net.get('as6rs', 'host5')
+ host5 = net.get('host5')
+ #as6rs.setIP('192.168.60.1', 24, 'as6rs-eth0')
+ #as6rs.setMAC('00:00:00:00:06:01', 'as6rs-eth0')
+ host5.setIP('192.168.60.2', 24, 'host5-eth0')
+ host5.setMAC('00:00:00:00:06:02', 'host5-eth0')
+ #as6router.setIP('172.16.60.254', 24, 'as6router-eth1')
+ host5.setIP('5.0.0.254', 8, 'host5-eth1')
+ host5.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ host5.setIP('1.168.30.5', 24, 'host5-eth2')
+ host5.setMAC('00:00:00:00:06:05', 'host5-eth2')
+
+ as6host = net.get('as6host')
+ #as6host.defaultIntf().setIP('5.0.0.1/24')
+ for i in range(0, 10):
+ as6host.cmd('sudo ip addr add 5.0.%d.1/24 dev as6host-eth0' %i)
+ as6host.cmd('ip route add default via 5.0.0.254')
+
+ # test the host in the as6
+ #for i in range(1, 10):
+ # baseip = (i-1)*4
+ # host = net.get('as6host%d' % i)
+ # host.defaultIntf().setIP('172.16.70.%d/24' % (baseip+1))
+ # host.cmd('ip route add default via 172.16.70.%d' % (baseip+2))
+ # as6router.setIP('172.16.70.%d' % (baseip+2), 30, 'as6router-eth%d' % (i+1))
+
+ # Start Quagga on border routers
+ startquagga(host3, 1, QUAGGA_CONFIG_FILE_DIR + '/quagga1.conf')
+ startquagga(host4, 2, QUAGGA_CONFIG_FILE_DIR + '/quagga2.conf')
+ #for i in range(numHost101, numHost200 + 1):
+ #host100=net.get('host%d' % (i))
+ #startquaggahost5(host100, i)
+
+ #startquagga(as6rs, 4, 'quagga-as6-rs.conf')
+ startquagga(host5, 5, QUAGGA_CONFIG_FILE_DIR + '/quagga-as6.conf')
+
+ #root1, root2, rootTestOn = net.get( 'root1', 'root2', 'rootTestOn' )
+ root1, rootTestOn = net.get( 'root1', 'rootTestOn' )
+ host1.intf('host1-eth1').setIP('1.1.1.1/24')
+ root1.intf('root1-eth0').setIP('1.1.1.2/24')
+ #host2.intf('host2-eth1').setIP('1.1.2.1/24')
+ #root2.intf('root2-eth0').setIP('1.1.2.2/24')
+
+ #rootTestOn.cmd('ip addr add 1.168.30.102/24 dev rootTestOn-eth0')
+ rootTestOn.cmd('ip addr add 1.168.30.99/24 dev rootTestOn-eth0')
+
+ stopsshd()
+
+ startquagga(host1, 100, QUAGGA_CONFIG_FILE_DIR + '/quagga-sdn-modified.conf')
+ hosts = [ host1, host3, host4, host5, as2host ];
+ #sshdHosts = sshdHosts + hosts
+ startsshds( hosts )
+ #
+ onos1 = '127.0.0.1'
+ forwarding1 = '%s:2000:%s:2000' % ('1.1.1.2', onos1)
+ root1.cmd( 'ssh -nNT -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % (forwarding1, onos1) )
+
+ # Forward 2605 to root namespace for easier access to SDN domain BGPd
+ # If root can ssh to itself without a password this should work
+ root1.cmd('ssh -N -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -L 2605:1.1.1.1:2605 1.1.1.1 &')
+ #time.sleep(3000000000)
+ CLI( net )
+
+ # Close the ssh port forwarding
+ #quietRun('sudo pkill -f 1.1.1.1')
+
+ stopsshd()
+ stopquagga()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'debug' )
+ if len(sys.argv) > 1:
+ QUAGGA_CONFIG_FILE_DIR = sys.argv[1]
+ sdn1net()
diff --git a/TestON/tests/PeeringRouterTest/mininet/quagga-as6-rs.conf b/TestON/tests/PeeringRouterTest/mininet/quagga-as6-rs.conf
new file mode 100644
index 0000000..1eac0dd
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/mininet/quagga-as6-rs.conf
@@ -0,0 +1,32 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64520
+ bgp router-id 192.168.60.1
+ neighbor 192.168.60.101 remote-as 64513
+ neighbor 192.168.60.101 route-server-client
+ neighbor 192.168.60.2 remote-as 64521
+ neighbor 192.168.60.2 route-server-client
+! network 172.16.60.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/mininet/quagga-as6.conf b/TestON/tests/PeeringRouterTest/mininet/quagga-as6.conf
new file mode 100644
index 0000000..434f983
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/mininet/quagga-as6.conf
@@ -0,0 +1,39 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64521
+ bgp router-id 192.168.60.2
+ neighbor 192.168.60.101 remote-as 64513
+! neighbor 192.168.60.1 remote-as 64520
+! neighbor 192.168.60.3 remote-as 64520
+! network 172.16.60.0/24
+! network 172.16.70.4/30
+ ! network 172.16.70.8/30
+ ! network 172.16.70.12/30
+ ! network 172.16.70.16/30
+ ! network 172.16.70.20/30
+ ! network 172.16.70.24/30
+ ! network 172.16.70.28/30
+ ! network 172.16.70.32/30
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/mininet/quagga-sdn-modified.conf b/TestON/tests/PeeringRouterTest/mininet/quagga-sdn-modified.conf
new file mode 100644
index 0000000..d334c2a
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/mininet/quagga-sdn-modified.conf
@@ -0,0 +1,49 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+route-map AS65000 permit 1
+ set as-path prepend 65000
+!
+router bgp 64513
+ bgp router-id 192.168.10.101
+ timers bgp 1 3
+ !timers bgp 3 9
+ neighbor 192.168.10.1 remote-as 64514
+ neighbor 192.168.10.1 ebgp-multihop
+ neighbor 192.168.10.1 timers connect 5
+ neighbor 192.168.20.1 remote-as 64514
+ neighbor 192.168.20.1 ebgp-multihop
+ neighbor 192.168.20.1 timers connect 5
+ neighbor 192.168.20.1 route-map AS65000 in
+ neighbor 192.168.30.1 remote-as 64516
+ neighbor 192.168.30.1 ebgp-multihop
+ neighbor 192.168.30.1 timers connect 5
+ neighbor 192.168.60.2 remote-as 64521
+ neighbor 192.168.60.2 ebgp-multihop
+ neighbor 192.168.60.2 timers connect 5
+ neighbor 1.1.1.2 remote-as 64513
+ neighbor 1.1.1.2 port 2000
+ neighbor 1.1.1.2 timers connect 5
+
+
+
+ network 172.16.10.0/24
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/mininet/quagga-sdn.conf b/TestON/tests/PeeringRouterTest/mininet/quagga-sdn.conf
new file mode 100644
index 0000000..77392a6
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/mininet/quagga-sdn.conf
@@ -0,0 +1,349 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+route-map AS65000 permit 1
+ set as-path prepend 65000
+!
+router bgp 64513
+ bgp router-id 192.168.10.101
+ timers bgp 1 3
+ !timers bgp 3 9
+ neighbor 192.168.10.1 remote-as 64514
+ neighbor 192.168.10.1 ebgp-multihop
+ neighbor 192.168.10.1 timers connect 5
+ neighbor 192.168.20.1 remote-as 64514
+ neighbor 192.168.20.1 ebgp-multihop
+ neighbor 192.168.20.1 timers connect 5
+ neighbor 192.168.20.1 route-map AS65000 in
+ neighbor 192.168.30.1 remote-as 64516
+ neighbor 192.168.30.1 ebgp-multihop
+ neighbor 192.168.30.1 timers connect 5
+ neighbor 192.168.60.1 remote-as 64520
+ neighbor 192.168.60.1 ebgp-multihop
+ neighbor 192.168.60.1 timers connect 5
+ neighbor 1.1.1.2 remote-as 64513
+ neighbor 1.1.1.2 port 2000
+ neighbor 1.1.1.2 timers connect 5
+
+
+neighbor 192.168.40.1 remote-as 65001
+neighbor 192.168.40.1 ebgp-multihop
+neighbor 192.168.40.1 timers connect 10
+neighbor 192.168.40.2 remote-as 65002
+neighbor 192.168.40.2 ebgp-multihop
+neighbor 192.168.40.2 timers connect 10
+neighbor 192.168.40.3 remote-as 65003
+neighbor 192.168.40.3 ebgp-multihop
+neighbor 192.168.40.3 timers connect 10
+neighbor 192.168.40.4 remote-as 65004
+neighbor 192.168.40.4 ebgp-multihop
+neighbor 192.168.40.4 timers connect 10
+neighbor 192.168.40.5 remote-as 65005
+neighbor 192.168.40.5 ebgp-multihop
+neighbor 192.168.40.5 timers connect 10
+neighbor 192.168.40.6 remote-as 65006
+neighbor 192.168.40.6 ebgp-multihop
+neighbor 192.168.40.6 timers connect 10
+neighbor 192.168.40.7 remote-as 65007
+neighbor 192.168.40.7 ebgp-multihop
+neighbor 192.168.40.7 timers connect 10
+neighbor 192.168.40.8 remote-as 65008
+neighbor 192.168.40.8 ebgp-multihop
+neighbor 192.168.40.8 timers connect 10
+neighbor 192.168.40.9 remote-as 65009
+neighbor 192.168.40.9 ebgp-multihop
+neighbor 192.168.40.9 timers connect 10
+neighbor 192.168.40.10 remote-as 65010
+neighbor 192.168.40.10 ebgp-multihop
+neighbor 192.168.40.10 timers connect 10
+neighbor 192.168.40.11 remote-as 65011
+neighbor 192.168.40.11 ebgp-multihop
+neighbor 192.168.40.11 timers connect 10
+neighbor 192.168.40.12 remote-as 65012
+neighbor 192.168.40.12 ebgp-multihop
+neighbor 192.168.40.12 timers connect 10
+neighbor 192.168.40.13 remote-as 65013
+neighbor 192.168.40.13 ebgp-multihop
+neighbor 192.168.40.13 timers connect 10
+neighbor 192.168.40.14 remote-as 65014
+neighbor 192.168.40.14 ebgp-multihop
+neighbor 192.168.40.14 timers connect 10
+neighbor 192.168.40.15 remote-as 65015
+neighbor 192.168.40.15 ebgp-multihop
+neighbor 192.168.40.15 timers connect 10
+neighbor 192.168.40.16 remote-as 65016
+neighbor 192.168.40.16 ebgp-multihop
+neighbor 192.168.40.16 timers connect 10
+neighbor 192.168.40.17 remote-as 65017
+neighbor 192.168.40.17 ebgp-multihop
+neighbor 192.168.40.17 timers connect 10
+neighbor 192.168.40.18 remote-as 65018
+neighbor 192.168.40.18 ebgp-multihop
+neighbor 192.168.40.18 timers connect 10
+neighbor 192.168.40.19 remote-as 65019
+neighbor 192.168.40.19 ebgp-multihop
+neighbor 192.168.40.19 timers connect 10
+neighbor 192.168.40.20 remote-as 65020
+neighbor 192.168.40.20 ebgp-multihop
+neighbor 192.168.40.20 timers connect 10
+neighbor 192.168.40.21 remote-as 65021
+neighbor 192.168.40.21 ebgp-multihop
+neighbor 192.168.40.21 timers connect 10
+neighbor 192.168.40.22 remote-as 65022
+neighbor 192.168.40.22 ebgp-multihop
+neighbor 192.168.40.22 timers connect 10
+neighbor 192.168.40.23 remote-as 65023
+neighbor 192.168.40.23 ebgp-multihop
+neighbor 192.168.40.23 timers connect 10
+neighbor 192.168.40.24 remote-as 65024
+neighbor 192.168.40.24 ebgp-multihop
+neighbor 192.168.40.24 timers connect 10
+neighbor 192.168.40.25 remote-as 65025
+neighbor 192.168.40.25 ebgp-multihop
+neighbor 192.168.40.25 timers connect 10
+neighbor 192.168.40.26 remote-as 65026
+neighbor 192.168.40.26 ebgp-multihop
+neighbor 192.168.40.26 timers connect 10
+neighbor 192.168.40.27 remote-as 65027
+neighbor 192.168.40.27 ebgp-multihop
+neighbor 192.168.40.27 timers connect 10
+neighbor 192.168.40.28 remote-as 65028
+neighbor 192.168.40.28 ebgp-multihop
+neighbor 192.168.40.28 timers connect 10
+neighbor 192.168.40.29 remote-as 65029
+neighbor 192.168.40.29 ebgp-multihop
+neighbor 192.168.40.29 timers connect 10
+neighbor 192.168.40.30 remote-as 65030
+neighbor 192.168.40.30 ebgp-multihop
+neighbor 192.168.40.30 timers connect 10
+neighbor 192.168.40.31 remote-as 65031
+neighbor 192.168.40.31 ebgp-multihop
+neighbor 192.168.40.31 timers connect 10
+neighbor 192.168.40.32 remote-as 65032
+neighbor 192.168.40.32 ebgp-multihop
+neighbor 192.168.40.32 timers connect 10
+neighbor 192.168.40.33 remote-as 65033
+neighbor 192.168.40.33 ebgp-multihop
+neighbor 192.168.40.33 timers connect 10
+neighbor 192.168.40.34 remote-as 65034
+neighbor 192.168.40.34 ebgp-multihop
+neighbor 192.168.40.34 timers connect 10
+neighbor 192.168.40.35 remote-as 65035
+neighbor 192.168.40.35 ebgp-multihop
+neighbor 192.168.40.35 timers connect 10
+neighbor 192.168.40.36 remote-as 65036
+neighbor 192.168.40.36 ebgp-multihop
+neighbor 192.168.40.36 timers connect 10
+neighbor 192.168.40.37 remote-as 65037
+neighbor 192.168.40.37 ebgp-multihop
+neighbor 192.168.40.37 timers connect 10
+neighbor 192.168.40.38 remote-as 65038
+neighbor 192.168.40.38 ebgp-multihop
+neighbor 192.168.40.38 timers connect 10
+neighbor 192.168.40.39 remote-as 65039
+neighbor 192.168.40.39 ebgp-multihop
+neighbor 192.168.40.39 timers connect 10
+neighbor 192.168.40.40 remote-as 65040
+neighbor 192.168.40.40 ebgp-multihop
+neighbor 192.168.40.40 timers connect 10
+neighbor 192.168.40.41 remote-as 65041
+neighbor 192.168.40.41 ebgp-multihop
+neighbor 192.168.40.41 timers connect 10
+neighbor 192.168.40.42 remote-as 65042
+neighbor 192.168.40.42 ebgp-multihop
+neighbor 192.168.40.42 timers connect 10
+neighbor 192.168.40.43 remote-as 65043
+neighbor 192.168.40.43 ebgp-multihop
+neighbor 192.168.40.43 timers connect 10
+neighbor 192.168.40.44 remote-as 65044
+neighbor 192.168.40.44 ebgp-multihop
+neighbor 192.168.40.44 timers connect 10
+neighbor 192.168.40.45 remote-as 65045
+neighbor 192.168.40.45 ebgp-multihop
+neighbor 192.168.40.45 timers connect 10
+neighbor 192.168.40.46 remote-as 65046
+neighbor 192.168.40.46 ebgp-multihop
+neighbor 192.168.40.46 timers connect 10
+neighbor 192.168.40.47 remote-as 65047
+neighbor 192.168.40.47 ebgp-multihop
+neighbor 192.168.40.47 timers connect 10
+neighbor 192.168.40.48 remote-as 65048
+neighbor 192.168.40.48 ebgp-multihop
+neighbor 192.168.40.48 timers connect 10
+neighbor 192.168.40.49 remote-as 65049
+neighbor 192.168.40.49 ebgp-multihop
+neighbor 192.168.40.49 timers connect 10
+neighbor 192.168.40.50 remote-as 65050
+neighbor 192.168.40.50 ebgp-multihop
+neighbor 192.168.40.50 timers connect 10
+neighbor 192.168.40.51 remote-as 65051
+neighbor 192.168.40.51 ebgp-multihop
+neighbor 192.168.40.51 timers connect 10
+neighbor 192.168.40.52 remote-as 65052
+neighbor 192.168.40.52 ebgp-multihop
+neighbor 192.168.40.52 timers connect 10
+neighbor 192.168.40.53 remote-as 65053
+neighbor 192.168.40.53 ebgp-multihop
+neighbor 192.168.40.53 timers connect 10
+neighbor 192.168.40.54 remote-as 65054
+neighbor 192.168.40.54 ebgp-multihop
+neighbor 192.168.40.54 timers connect 10
+neighbor 192.168.40.55 remote-as 65055
+neighbor 192.168.40.55 ebgp-multihop
+neighbor 192.168.40.55 timers connect 10
+neighbor 192.168.40.56 remote-as 65056
+neighbor 192.168.40.56 ebgp-multihop
+neighbor 192.168.40.56 timers connect 10
+neighbor 192.168.40.57 remote-as 65057
+neighbor 192.168.40.57 ebgp-multihop
+neighbor 192.168.40.57 timers connect 10
+neighbor 192.168.40.58 remote-as 65058
+neighbor 192.168.40.58 ebgp-multihop
+neighbor 192.168.40.58 timers connect 10
+neighbor 192.168.40.59 remote-as 65059
+neighbor 192.168.40.59 ebgp-multihop
+neighbor 192.168.40.59 timers connect 10
+neighbor 192.168.40.60 remote-as 65060
+neighbor 192.168.40.60 ebgp-multihop
+neighbor 192.168.40.60 timers connect 10
+neighbor 192.168.40.61 remote-as 65061
+neighbor 192.168.40.61 ebgp-multihop
+neighbor 192.168.40.61 timers connect 10
+neighbor 192.168.40.62 remote-as 65062
+neighbor 192.168.40.62 ebgp-multihop
+neighbor 192.168.40.62 timers connect 10
+neighbor 192.168.40.63 remote-as 65063
+neighbor 192.168.40.63 ebgp-multihop
+neighbor 192.168.40.63 timers connect 10
+neighbor 192.168.40.64 remote-as 65064
+neighbor 192.168.40.64 ebgp-multihop
+neighbor 192.168.40.64 timers connect 10
+neighbor 192.168.40.65 remote-as 65065
+neighbor 192.168.40.65 ebgp-multihop
+neighbor 192.168.40.65 timers connect 10
+neighbor 192.168.40.66 remote-as 65066
+neighbor 192.168.40.66 ebgp-multihop
+neighbor 192.168.40.66 timers connect 10
+neighbor 192.168.40.67 remote-as 65067
+neighbor 192.168.40.67 ebgp-multihop
+neighbor 192.168.40.67 timers connect 10
+neighbor 192.168.40.68 remote-as 65068
+neighbor 192.168.40.68 ebgp-multihop
+neighbor 192.168.40.68 timers connect 10
+neighbor 192.168.40.69 remote-as 65069
+neighbor 192.168.40.69 ebgp-multihop
+neighbor 192.168.40.69 timers connect 10
+neighbor 192.168.40.70 remote-as 65070
+neighbor 192.168.40.70 ebgp-multihop
+neighbor 192.168.40.70 timers connect 10
+neighbor 192.168.40.71 remote-as 65071
+neighbor 192.168.40.71 ebgp-multihop
+neighbor 192.168.40.71 timers connect 10
+neighbor 192.168.40.72 remote-as 65072
+neighbor 192.168.40.72 ebgp-multihop
+neighbor 192.168.40.72 timers connect 10
+neighbor 192.168.40.73 remote-as 65073
+neighbor 192.168.40.73 ebgp-multihop
+neighbor 192.168.40.73 timers connect 10
+neighbor 192.168.40.74 remote-as 65074
+neighbor 192.168.40.74 ebgp-multihop
+neighbor 192.168.40.74 timers connect 10
+neighbor 192.168.40.75 remote-as 65075
+neighbor 192.168.40.75 ebgp-multihop
+neighbor 192.168.40.75 timers connect 10
+neighbor 192.168.40.76 remote-as 65076
+neighbor 192.168.40.76 ebgp-multihop
+neighbor 192.168.40.76 timers connect 10
+neighbor 192.168.40.77 remote-as 65077
+neighbor 192.168.40.77 ebgp-multihop
+neighbor 192.168.40.77 timers connect 10
+neighbor 192.168.40.78 remote-as 65078
+neighbor 192.168.40.78 ebgp-multihop
+neighbor 192.168.40.78 timers connect 10
+neighbor 192.168.40.79 remote-as 65079
+neighbor 192.168.40.79 ebgp-multihop
+neighbor 192.168.40.79 timers connect 10
+neighbor 192.168.40.80 remote-as 65080
+neighbor 192.168.40.80 ebgp-multihop
+neighbor 192.168.40.80 timers connect 10
+neighbor 192.168.40.81 remote-as 65081
+neighbor 192.168.40.81 ebgp-multihop
+neighbor 192.168.40.81 timers connect 10
+neighbor 192.168.40.82 remote-as 65082
+neighbor 192.168.40.82 ebgp-multihop
+neighbor 192.168.40.82 timers connect 10
+neighbor 192.168.40.83 remote-as 65083
+neighbor 192.168.40.83 ebgp-multihop
+neighbor 192.168.40.83 timers connect 10
+neighbor 192.168.40.84 remote-as 65084
+neighbor 192.168.40.84 ebgp-multihop
+neighbor 192.168.40.84 timers connect 10
+neighbor 192.168.40.85 remote-as 65085
+neighbor 192.168.40.85 ebgp-multihop
+neighbor 192.168.40.85 timers connect 10
+neighbor 192.168.40.86 remote-as 65086
+neighbor 192.168.40.86 ebgp-multihop
+neighbor 192.168.40.86 timers connect 10
+neighbor 192.168.40.87 remote-as 65087
+neighbor 192.168.40.87 ebgp-multihop
+neighbor 192.168.40.87 timers connect 10
+neighbor 192.168.40.88 remote-as 65088
+neighbor 192.168.40.88 ebgp-multihop
+neighbor 192.168.40.88 timers connect 10
+neighbor 192.168.40.89 remote-as 65089
+neighbor 192.168.40.89 ebgp-multihop
+neighbor 192.168.40.89 timers connect 10
+neighbor 192.168.40.90 remote-as 65090
+neighbor 192.168.40.90 ebgp-multihop
+neighbor 192.168.40.90 timers connect 10
+neighbor 192.168.40.91 remote-as 65091
+neighbor 192.168.40.91 ebgp-multihop
+neighbor 192.168.40.91 timers connect 10
+neighbor 192.168.40.92 remote-as 65092
+neighbor 192.168.40.92 ebgp-multihop
+neighbor 192.168.40.92 timers connect 10
+neighbor 192.168.40.93 remote-as 65093
+neighbor 192.168.40.93 ebgp-multihop
+neighbor 192.168.40.93 timers connect 10
+neighbor 192.168.40.94 remote-as 65094
+neighbor 192.168.40.94 ebgp-multihop
+neighbor 192.168.40.94 timers connect 10
+neighbor 192.168.40.95 remote-as 65095
+neighbor 192.168.40.95 ebgp-multihop
+neighbor 192.168.40.95 timers connect 10
+neighbor 192.168.40.96 remote-as 65096
+neighbor 192.168.40.96 ebgp-multihop
+neighbor 192.168.40.96 timers connect 10
+neighbor 192.168.40.97 remote-as 65097
+neighbor 192.168.40.97 ebgp-multihop
+neighbor 192.168.40.97 timers connect 10
+neighbor 192.168.40.98 remote-as 65098
+neighbor 192.168.40.98 ebgp-multihop
+neighbor 192.168.40.98 timers connect 10
+neighbor 192.168.40.99 remote-as 65099
+neighbor 192.168.40.99 ebgp-multihop
+neighbor 192.168.40.99 timers connect 10
+neighbor 192.168.40.100 remote-as 65100
+neighbor 192.168.40.100 ebgp-multihop
+neighbor 192.168.40.100 timers connect 10
+
+ network 172.16.10.0/24
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/mininet/quagga1.conf b/TestON/tests/PeeringRouterTest/mininet/quagga1.conf
new file mode 100644
index 0000000..264f85e
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/mininet/quagga1.conf
@@ -0,0 +1,32 @@
+!
+! Zebra configuration saved from vty
+! 2014/11/25 11:22:24
+!
+hostname bgpd
+password hello
+log stdout
+!
+router bgp 64514
+ bgp router-id 192.168.10.1
+! network 3.0.0.0/24
+! network 3.0.1.0/24
+! network 3.0.2.0/24
+! network 3.0.3.0/24
+! network 3.0.4.0/24
+! network 3.0.5.0/24
+! network 3.0.6.0/24
+! network 3.0.7.0/24
+! network 3.0.8.0/24
+! network 3.0.9.0/24
+ neighbor 192.168.20.101 remote-as 64513
+ neighbor 192.168.20.101 route-map PREPEND2 in
+ neighbor 192.168.20.101 route-map PREPEND2 out
+!
+route-map PREPEND1 permit 1
+ set as-path prepend 64514
+!
+route-map PREPEND2 permit 2
+ set as-path prepend 64514 64514
+!
+line vty
+!
diff --git a/TestON/tests/PeeringRouterTest/mininet/quagga2.conf b/TestON/tests/PeeringRouterTest/mininet/quagga2.conf
new file mode 100644
index 0000000..20ca9e4
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/mininet/quagga2.conf
@@ -0,0 +1,31 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64516
+ bgp router-id 192.168.30.1
+! timers bgp 1 3
+ neighbor 192.168.30.101 remote-as 64513
+! neighbor 192.168.50.2 remote-as 65001
+! network 172.16.30.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/mininet/zebra.conf b/TestON/tests/PeeringRouterTest/mininet/zebra.conf
new file mode 100644
index 0000000..0f8e3a2
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/mininet/zebra.conf
@@ -0,0 +1,26 @@
+! -*- zebra -*-
+!
+! zebra sample configuration file
+!
+! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
+!
+hostname zebra
+password hello
+enable password 0fw0rk
+log stdout
+!
+! Interfaces description.
+!
+!interface lo
+! description test of desc.
+!
+!interface sit0
+! multicast
+
+!
+! Static default route sample.
+!
+!ip route 0.0.0.0/0 203.181.89.241
+!
+
+!log file /usr/local/var/log/quagga/zebra.log
diff --git a/TestON/tests/PeeringRouterTest/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg b/TestON/tests/PeeringRouterTest/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg
new file mode 100644
index 0000000..5feaf1d
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg
@@ -0,0 +1 @@
+corsaDpid = 00:00:00:00:00:00:00:01
diff --git a/TestON/tests/PeeringRouterTest/org.onosproject.provider.lldp.impl.LLDPLinkProvider.cfg b/TestON/tests/PeeringRouterTest/org.onosproject.provider.lldp.impl.LLDPLinkProvider.cfg
new file mode 100644
index 0000000..65c7bf3
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/org.onosproject.provider.lldp.impl.LLDPLinkProvider.cfg
@@ -0,0 +1,19 @@
+# Sample configuration for link discovery
+# Note that this file location is required for packaging onos and launching it in another localtion.
+# If you are launching onos locally, this configuration file would be placed at: $(KARAF_ROOT)/etc
+
+#
+# Disable Link Dicovery Permanently (Note: changing this property at runtime will have NO effect)
+#
+disableLinkDiscovery = true
+
+#
+# Enable Broadcast Discovery Protocol
+#
+#useBDDP = false
+
+#
+# Disable LLDP's recieved from specific devices
+# Details of the devices are in the file configured below
+#
+#lldpSuppression =
diff --git a/TestON/tests/PeeringRouterTest/routeconvergence/mininet/PeeringRouterConvergenceMininet.py b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/PeeringRouterConvergenceMininet.py
new file mode 100755
index 0000000..13c66ac
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/PeeringRouterConvergenceMininet.py
@@ -0,0 +1,346 @@
+#!/usr/bin/python
+
+"""
+Start up the SDN-IP demo topology
+"""
+
+"""
+AS1 = 64513, (SDN AS)
+AS2 = 64514, reachable by 192.168.10.1, 192.168.20.1
+AS3 = 64516, reachable by 192.168.30.1
+AS4 = 64517, reachable by 192.168.40.1
+AS6 = 64520, reachable by 192.168.60.2, (route server 192.168.60.1)
+"""
+
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+
+import os.path
+import time
+import sys
+from subprocess import Popen, STDOUT, PIPE
+
+QUAGGA_DIR = '/usr/lib/quagga'
+#QUAGGA_DIR = '/usr/local/sbin'
+QUAGGA_RUN_DIR = '/usr/local/var/run/quagga'
+
+QUAGGA_CONFIG_FILE_DIR = '/home/tutorial1/ONLabTest/TestON/tests/PeeringRouterTest/mininet'
+
+class SDNIpModifiedTopo( Topo ):
+ "SDN Ip Modified Topology"
+
+ def __init__( self, *args, **kwargs ):
+ global numHost101
+ global numHost200
+ numHost101 = 101
+ numHost200 = 200
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='0000000000000001')
+ sw2 = self.addSwitch('sw2', dpid='0000000000000002')
+ #sw3 = self.addSwitch('sw3', dpid='00000000000000a3')
+ #sw4 = self.addSwitch('sw4', dpid='00000000000000a4')
+ #sw5 = self.addSwitch('sw5', dpid='00000000000000a5')
+ #sw6 = self.addSwitch('sw6', dpid='00000000000000a6')
+ #add a switch for 3 quagga hosts
+ swTestOn = self.addSwitch('swTestOn', dpid='0000000000000102')
+ #Note this switch isn't part of the SDN topology
+ #We'll use the ovs-controller to turn this into a learning switch
+ as6sw = self.addSwitch('as6sw', dpid='00000000000000a7')
+
+ host1 = self.addHost( 'host1' )
+ root1 = self.addHost( 'root1', inNamespace=False , ip='0')
+ rootTestOn = self.addHost( 'rootTestOn', inNamespace=False, ip='0' )
+
+ #AS2 host
+ host3 = self.addHost( 'host3' )
+ as2host = self.addHost( 'as2host' )
+ #AS3 host
+ host4 = self.addHost( 'host4' )
+ as3host = self.addHost( 'as3host' )
+ #AS6 host
+ host5 = self.addHost( 'host5' )
+ as6host = self.addHost( 'as6host' )
+
+ self.addLink( host1, sw2 )
+ #Links to the multihomed AS
+ self.addLink( host3, sw1 )
+ self.addLink( host3, sw1 )
+ self.addLink( as2host, host3 )
+ #Single links to the remaining two ASes
+ self.addLink( host4, sw1 )
+ self.addLink( as3host, host4 )
+
+ #AS3-AS4 link
+ #self.addLink( host4, host5)
+ #Add new AS6 to its bridge
+ self.addLink( host5, as6sw )
+ self.addLink( as6host, host5 )
+
+ #Backup link from router5 to router4
+ self.addLink( host4, host5)
+
+ #test the host behind the router(behind the router server)
+# for i in range(1, 10):
+ # host = self.addHost('as6host%d' % i)
+ # self.addLink(host, as6router)
+
+ ## Internal Connection To Hosts ##
+ self.addLink( root1, host1 )
+
+ # self.addLink( sw1, sw2 )
+ # self.addLink( sw1, sw3 )
+ # self.addLink( sw2, sw4 )
+ # self.addLink( sw3, sw4 )
+ # self.addLink( sw3, sw5 )
+ # self.addLink( sw4, sw6 )
+ # self.addLink( sw5, sw6 )
+ self.addLink( as6sw, sw1 )
+
+
+ self.addLink(swTestOn, rootTestOn)
+ #self.addLink(swTestOn, host1)
+ self.addLink(swTestOn, host3)
+ self.addLink(swTestOn, host4)
+ self.addLink(swTestOn, host5)
+ self.addLink(swTestOn, as2host)
+
+
+ #self.addLink(rootTestOn, host4)
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def startquagga( host, num, config_file ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f %s -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, config_file, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ print zebra_cmd
+ print quagga_cmd
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+def startquaggahost5( host, num ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f ./as4quaggas/quagga%s.conf -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, num, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+
+def stopquagga( ):
+ quietRun( 'sudo pkill -9 -f bgpd' )
+ quietRun( 'sudo pkill -9 -f zebra' )
+
+def sdn1net():
+ topo = SDNIpModifiedTopo()
+ info( '*** Creating network\n' )
+ net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=RemoteController )
+
+ host1, host3, host4, host5 = net.get( 'host1', 'host3', 'host4', 'host5' )
+
+ #host100.setIP('1.168.30.' + str(i), 24, str(host100) + "-eth2")
+
+ #host500.setMAC('00:00:00:00:04:%d' % (i-101), 'host%d-eth0' %(i))
+ #add IP prefixes
+ #for j in range(0,121):
+ #host100.cmd('sudo ip addr add %s.0.40.%s/24 dev host%s-eth0' %(i,j,i))
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ #sw1 = net.get('sw1')
+ host1.setMAC('00:00:00:00:00:01', 'host1-eth0')
+ host1.cmd('ip addr add 192.168.20.101/24 dev host1-eth0')
+ host1.cmd('ip addr add 192.168.30.101/24 dev host1-eth0')
+ #host1.cmd('ip addr add 192.168.40.101/24 dev host1-eth0')
+ host1.cmd('ip addr add 192.168.60.101/24 dev host1-eth0')
+
+ # Net has to be start after adding the above link
+ net.start()
+
+ # Set up as6sw as a learning switch as quickly as possible so it
+ # hopefully doesn't connect to the actual controller
+ # TODO figure out how to change controller before starting switch
+ as6sw = net.get('as6sw')
+ as6sw.cmd('ovs-vsctl set-controller as6sw none')
+ as6sw.cmd('ovs-vsctl set-fail-mode as6sw standalone')
+
+
+ sw1 = net.get('sw1')
+ sw1.cmd('ovs-vsctl set-controller sw1 tcp:127.0.0.1:6633')
+# sw2.cmd('ovs-vsctl set-controller sw2 tcp:127.0.0.1:6633')
+# sw3.cmd('ovs-vsctl set-controller sw3 tcp:127.0.0.1:6633')
+# sw4.cmd('ovs-vsctl set-controller sw4 tcp:127.0.0.1:6633')
+# sw5.cmd('ovs-vsctl set-controller sw5 tcp:127.0.0.1:6633')
+# sw6.cmd('ovs-vsctl set-controller sw6 tcp:127.0.0.1:6633')
+
+
+ swTestOn = net.get('swTestOn')
+ swTestOn.cmd('ovs-vsctl set-controller swTestOn none')
+ swTestOn.cmd('ovs-vsctl set-fail-mode swTestOn standalone')
+
+ host1.defaultIntf().setIP('192.168.10.101/24')
+ # Run BGPd
+ #host1.cmd('%s -d -f %s' % (BGPD, BGPD_CONF))
+ #host1.cmd('/sbin/route add default gw 192.168.10.254 dev %s-eth0' % (host1.name))
+
+ # Configure new host interfaces
+ #host2.defaultIntf().setIP('172.16.10.2/24')
+ #host2.defaultIntf().setMAC('00:00:00:00:01:02')
+ #host2.cmd('/sbin/route add default gw 172.16.10.254 dev %s-eth0' % (host2.name))
+
+ # Set up AS2
+ host3.setIP('192.168.10.1', 24, 'host3-eth0')
+ #host3.cmd('sudo ip addr add 172.16.20.1/24 dev host3-eth0')
+ host3.setIP('192.168.20.1', 24, 'host3-eth1')
+ host3.setMAC('00:00:00:00:02:01', 'host3-eth0')
+ host3.setMAC('00:00:00:00:02:02', 'host3-eth1')
+ #host3.setIP('172.16.20.254', 24, 'host3-eth2')
+ host3.setIP('3.0.0.254', 8, 'host3-eth2')
+ host3.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+
+ host3.setIP('1.168.30.2', 24, 'host3-eth3')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_ignore=1')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_announce=1')
+ as2host = net.get('as2host')
+ #as2host.defaultIntf().setIP('172.16.20.1/24')
+ for i in range(0, 20):
+ as2host.cmd('sudo ip addr add 3.0.%d.1/24 dev as2host-eth0' %i)
+ as2host.setIP('1.168.30.100', 24, 'as2host-eth1')
+
+ as2host.cmd('ip route add default via 3.0.0.254')
+
+ # Set up AS3
+ host4.setIP('192.168.30.1', 24, 'host4-eth0')
+ host4.setMAC('00:00:00:00:03:01', 'host4-eth0')
+ host4.setIP('4.0.0.254', 8, 'host4-eth1')
+ host4.setMAC('00:00:00:00:03:99', 'host4-eth1')
+ host4.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ as3host = net.get('as3host')
+ for i in range(0, 20):
+ as3host.cmd('sudo ip addr add 4.0.%d.1/24 dev as3host-eth0' %i)
+ as3host.cmd('ip route add default via 4.0.0.254')
+
+ host4.setIP('10.0.0.4', 24, 'host4-eth2')
+ host4.setMAC('00:00:00:00:03:33', 'host4-eth2')
+
+ #root space
+ host4.setIP('1.168.30.3', 24, 'host4-eth3')
+ host4.setMAC('00:00:00:00:03:03', 'host4-eth3')
+
+ # Set up AS4
+ #as4host = net.get('as4host')
+ #as4host.defaultIntf().setIP('172.16.40.1/24')
+ #as4host.cmd('ip route add default via 172.16.40.254')
+
+ # setup interface address for 100 quagga hosts
+ time.sleep(10)
+ #for i in range(numHost101, numHost200 + 1):
+ #host100 = net.get('host' + str(i))
+ #host100.cmd(str(i)+'.0.1.254', 24, 'host'+str(i)+'-eth1')
+ #as4host100 = net.get('as4host%s' %(i))
+ #as4host100.defaultIntf().setIP(str(i) + '.0.0.1/24')
+ #as4host100.cmd('ip route add default via ' + str(i) + '.0.0.254')
+ #for j in range(0, 100):
+ #as4host100.cmd('sudo ip addr add %d.0.%d.1/24 dev %s-eth0' %(i, j, as4host100))
+
+ # Set up AS6 - This has a router and a route server
+ #as6rs, host5 = net.get('as6rs', 'host5')
+ host5 = net.get('host5')
+ #as6rs.setIP('192.168.60.1', 24, 'as6rs-eth0')
+ #as6rs.setMAC('00:00:00:00:06:01', 'as6rs-eth0')
+ host5.setIP('192.168.60.2', 24, 'host5-eth0')
+ host5.setMAC('00:00:00:00:06:02', 'host5-eth0')
+ #as6router.setIP('172.16.60.254', 24, 'as6router-eth1')
+ host5.setIP('5.0.0.254', 8, 'host5-eth1')
+ host5.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ host5.setIP('10.0.0.5', 24, 'host5-eth2')
+ host5.setMAC('00:00:00:00:06:66', 'host5-eth2')
+ host5.setIP('1.168.30.5', 24, 'host5-eth3')
+ host5.setMAC('00:00:00:00:06:05', 'host5-eth3')
+
+ as6host = net.get('as6host')
+ #as6host.defaultIntf().setIP('5.0.0.1/24')
+ for i in range(0, 10):
+ as6host.cmd('sudo ip addr add 5.0.%d.1/24 dev as6host-eth0' %i)
+ as6host.cmd('ip route add default via 5.0.0.254')
+
+ # test the host in the as6
+ #for i in range(1, 10):
+ # baseip = (i-1)*4
+ # host = net.get('as6host%d' % i)
+ # host.defaultIntf().setIP('172.16.70.%d/24' % (baseip+1))
+ # host.cmd('ip route add default via 172.16.70.%d' % (baseip+2))
+ # as6router.setIP('172.16.70.%d' % (baseip+2), 30, 'as6router-eth%d' % (i+1))
+
+ # Start Quagga on border routers
+ startquagga(host3, 1, QUAGGA_CONFIG_FILE_DIR + '/quagga1.conf')
+ startquagga(host4, 2, QUAGGA_CONFIG_FILE_DIR + '/quagga2.conf')
+ #for i in range(numHost101, numHost200 + 1):
+ #host100=net.get('host%d' % (i))
+ #startquaggahost5(host100, i)
+
+ #startquagga(as6rs, 4, 'quagga-as6-rs.conf')
+ startquagga(host5, 5, QUAGGA_CONFIG_FILE_DIR + '/quagga-as6.conf')
+
+ #root1, root2, rootTestOn = net.get( 'root1', 'root2', 'rootTestOn' )
+ root1, rootTestOn = net.get( 'root1', 'rootTestOn' )
+ host1.intf('host1-eth1').setIP('1.1.1.1/24')
+ root1.intf('root1-eth0').setIP('1.1.1.2/24')
+ #host2.intf('host2-eth1').setIP('1.1.2.1/24')
+ #root2.intf('root2-eth0').setIP('1.1.2.2/24')
+
+ #rootTestOn.cmd('ip addr add 1.168.30.102/24 dev rootTestOn-eth0')
+ rootTestOn.cmd('ip addr add 1.168.30.99/24 dev rootTestOn-eth0')
+
+ stopsshd()
+
+ startquagga(host1, 100, QUAGGA_CONFIG_FILE_DIR + '/quagga-sdn-modified.conf')
+ hosts = [ host1, host3, host4, host5, as2host ];
+ #sshdHosts = sshdHosts + hosts
+ startsshds( hosts )
+ #
+ onos1 = '127.0.0.1'
+ forwarding1 = '%s:2000:%s:2000' % ('1.1.1.2', onos1)
+ root1.cmd( 'ssh -nNT -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % (forwarding1, onos1) )
+
+ # Forward 2605 to root namespace for easier access to SDN domain BGPd
+ # If root can ssh to itself without a password this should work
+ root1.cmd('ssh -N -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -L 2605:1.1.1.1:2605 1.1.1.1 &')
+ #time.sleep(3000000000)
+ CLI( net )
+
+ # Close the ssh port forwarding
+ #quietRun('sudo pkill -f 1.1.1.1')
+
+ stopsshd()
+ stopquagga()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'debug' )
+ if len(sys.argv) > 1:
+ QUAGGA_CONFIG_FILE_DIR = sys.argv[1]
+ sdn1net()
diff --git a/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga-as6.conf b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga-as6.conf
new file mode 100644
index 0000000..5e7028d
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga-as6.conf
@@ -0,0 +1,39 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64521
+ bgp router-id 192.168.60.2
+ neighbor 192.168.60.101 remote-as 64513
+ neighbor 10.0.0.4 remote-as 64516
+! neighbor 192.168.60.3 remote-as 64520
+! network 172.16.60.0/24
+! network 172.16.70.4/30
+ ! network 172.16.70.8/30
+ ! network 172.16.70.12/30
+ ! network 172.16.70.16/30
+ ! network 172.16.70.20/30
+ ! network 172.16.70.24/30
+ ! network 172.16.70.28/30
+ ! network 172.16.70.32/30
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga-sdn-modified.conf b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga-sdn-modified.conf
new file mode 100644
index 0000000..d334c2a
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga-sdn-modified.conf
@@ -0,0 +1,49 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+route-map AS65000 permit 1
+ set as-path prepend 65000
+!
+router bgp 64513
+ bgp router-id 192.168.10.101
+ timers bgp 1 3
+ !timers bgp 3 9
+ neighbor 192.168.10.1 remote-as 64514
+ neighbor 192.168.10.1 ebgp-multihop
+ neighbor 192.168.10.1 timers connect 5
+ neighbor 192.168.20.1 remote-as 64514
+ neighbor 192.168.20.1 ebgp-multihop
+ neighbor 192.168.20.1 timers connect 5
+ neighbor 192.168.20.1 route-map AS65000 in
+ neighbor 192.168.30.1 remote-as 64516
+ neighbor 192.168.30.1 ebgp-multihop
+ neighbor 192.168.30.1 timers connect 5
+ neighbor 192.168.60.2 remote-as 64521
+ neighbor 192.168.60.2 ebgp-multihop
+ neighbor 192.168.60.2 timers connect 5
+ neighbor 1.1.1.2 remote-as 64513
+ neighbor 1.1.1.2 port 2000
+ neighbor 1.1.1.2 timers connect 5
+
+
+
+ network 172.16.10.0/24
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga1.conf b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga1.conf
new file mode 100644
index 0000000..264f85e
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga1.conf
@@ -0,0 +1,32 @@
+!
+! Zebra configuration saved from vty
+! 2014/11/25 11:22:24
+!
+hostname bgpd
+password hello
+log stdout
+!
+router bgp 64514
+ bgp router-id 192.168.10.1
+! network 3.0.0.0/24
+! network 3.0.1.0/24
+! network 3.0.2.0/24
+! network 3.0.3.0/24
+! network 3.0.4.0/24
+! network 3.0.5.0/24
+! network 3.0.6.0/24
+! network 3.0.7.0/24
+! network 3.0.8.0/24
+! network 3.0.9.0/24
+ neighbor 192.168.20.101 remote-as 64513
+ neighbor 192.168.20.101 route-map PREPEND2 in
+ neighbor 192.168.20.101 route-map PREPEND2 out
+!
+route-map PREPEND1 permit 1
+ set as-path prepend 64514
+!
+route-map PREPEND2 permit 2
+ set as-path prepend 64514 64514
+!
+line vty
+!
diff --git a/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga2.conf b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga2.conf
new file mode 100644
index 0000000..14c7d67
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/quagga2.conf
@@ -0,0 +1,32 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64516
+ bgp router-id 192.168.30.1
+! timers bgp 1 3
+ neighbor 192.168.30.101 remote-as 64513
+ neighbor 10.0.0.5 remote-as 64521
+! neighbor 192.168.50.2 remote-as 65001
+! network 172.16.30.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/routeconvergence/mininet/zebra.conf b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/zebra.conf
new file mode 100644
index 0000000..0f8e3a2
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeconvergence/mininet/zebra.conf
@@ -0,0 +1,26 @@
+! -*- zebra -*-
+!
+! zebra sample configuration file
+!
+! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
+!
+hostname zebra
+password hello
+enable password 0fw0rk
+log stdout
+!
+! Interfaces description.
+!
+!interface lo
+! description test of desc.
+!
+!interface sit0
+! multicast
+
+!
+! Static default route sample.
+!
+!ip route 0.0.0.0/0 203.181.89.241
+!
+
+!log file /usr/local/var/log/quagga/zebra.log
diff --git a/TestON/tests/PeeringRouterTest/routeserver/addresses.json b/TestON/tests/PeeringRouterTest/routeserver/addresses.json
new file mode 100644
index 0000000..ee83480
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeserver/addresses.json
@@ -0,0 +1,30 @@
+{
+ "addresses" : [
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "1",
+ "ips" : ["192.168.10.101/24"],
+ "mac" : "00:00:00:00:00:01"
+
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "2",
+ "ips" : ["192.168.20.101/24"],
+ "mac" : "00:00:00:00:00:01"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "3",
+ "ips" : ["192.168.30.101/24"],
+ "mac" : "00:00:00:00:00:01"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "4",
+ "ips" : ["192.168.60.101/24"],
+ "mac" : "00:00:00:00:00:01"
+ }
+
+ ]
+}
diff --git a/TestON/tests/PeeringRouterTest/routeserver/mininet/PeeringRouteServerMininet.py b/TestON/tests/PeeringRouterTest/routeserver/mininet/PeeringRouteServerMininet.py
new file mode 100755
index 0000000..0c8cb08
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeserver/mininet/PeeringRouteServerMininet.py
@@ -0,0 +1,352 @@
+#!/usr/bin/python
+
+"""
+Start up the SDN-IP demo topology
+"""
+
+"""
+AS1 = 64513, (SDN AS)
+AS2 = 64514, reachable by 192.168.10.1, 192.168.20.1
+AS3 = 64516, reachable by 192.168.30.1
+AS4 = 64517, reachable by 192.168.40.1
+AS6 = 64520, reachable by 192.168.60.2, (route server 192.168.60.1)
+"""
+
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+
+import os.path
+import time
+import sys
+from subprocess import Popen, STDOUT, PIPE
+
+QUAGGA_DIR = '/usr/lib/quagga'
+#QUAGGA_DIR = '/usr/local/sbin'
+QUAGGA_RUN_DIR = '/usr/local/var/run/quagga'
+
+QUAGGA_CONFIG_FILE_DIR = '/home/tutorial1/ONLabTest/TestON/tests/PeeringRouterTest/mininet'
+
+class SDNIpModifiedTopo( Topo ):
+ "SDN Ip Modified Topology"
+
+ def __init__( self, *args, **kwargs ):
+ global numHost101
+ global numHost200
+ numHost101 = 101
+ numHost200 = 200
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='0000000000000001')
+ sw2 = self.addSwitch('sw2', dpid='0000000000000002')
+ #sw3 = self.addSwitch('sw3', dpid='00000000000000a3')
+ #sw4 = self.addSwitch('sw4', dpid='00000000000000a4')
+ #sw5 = self.addSwitch('sw5', dpid='00000000000000a5')
+ #sw6 = self.addSwitch('sw6', dpid='00000000000000a6')
+ #add a switch for 3 quagga hosts
+ swTestOn = self.addSwitch('swTestOn', dpid='0000000000000102')
+ #Note this switch isn't part of the SDN topology
+ #We'll use the ovs-controller to turn this into a learning switch
+ as6sw = self.addSwitch('as6sw', dpid='00000000000000a7')
+
+ host1 = self.addHost( 'host1' )
+ root1 = self.addHost( 'root1', inNamespace=False , ip='0')
+ rootTestOn = self.addHost( 'rootTestOn', inNamespace=False, ip='0' )
+
+ #AS2 host
+ host3 = self.addHost( 'host3' )
+ as2host = self.addHost( 'as2host' )
+ #AS3 host
+ host4 = self.addHost( 'host4' )
+ as3host = self.addHost( 'as3host' )
+ #AS6 host
+ as6rs = self.addHost( 'as6rs' )
+ host5 = self.addHost( 'host5' )
+ as6host = self.addHost( 'as6host' )
+
+ self.addLink( host1, sw2 )
+ #Links to the multihomed AS
+ self.addLink( host3, sw1 )
+ self.addLink( host3, sw1 )
+ self.addLink( as2host, host3 )
+ #Single links to the remaining two ASes
+ self.addLink( host4, sw1 )
+ self.addLink( as3host, host4 )
+
+ #AS3-AS4 link
+ #self.addLink( host4, host5)
+ #Add new AS6 to its bridge
+ self.addLink( as6rs, as6sw )
+ self.addLink( host5, as6sw )
+ self.addLink( as6host, host5 )
+
+ #Backup link from router5 to router4
+ self.addLink( host4, host5)
+
+ #test the host behind the router(behind the router server)
+# for i in range(1, 10):
+ # host = self.addHost('as6host%d' % i)
+ # self.addLink(host, as6router)
+
+ ## Internal Connection To Hosts ##
+ self.addLink( root1, host1 )
+
+ # self.addLink( sw1, sw2 )
+ # self.addLink( sw1, sw3 )
+ # self.addLink( sw2, sw4 )
+ # self.addLink( sw3, sw4 )
+ # self.addLink( sw3, sw5 )
+ # self.addLink( sw4, sw6 )
+ # self.addLink( sw5, sw6 )
+ self.addLink( as6sw, sw1 )
+
+
+ self.addLink(swTestOn, rootTestOn)
+ #self.addLink(swTestOn, host1)
+ self.addLink(swTestOn, host3)
+ self.addLink(swTestOn, host4)
+ self.addLink(swTestOn, host5)
+ self.addLink(swTestOn, as2host)
+ self.addLink(swTestOn, as6rs)
+
+
+ #self.addLink(rootTestOn, host4)
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def startquagga( host, num, config_file ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f %s -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, config_file, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ print zebra_cmd
+ print quagga_cmd
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+def startquaggahost5( host, num ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f ./as4quaggas/quagga%s.conf -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, num, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+
+def stopquagga( ):
+ quietRun( 'sudo pkill -9 -f bgpd' )
+ quietRun( 'sudo pkill -9 -f zebra' )
+
+def sdn1net():
+ topo = SDNIpModifiedTopo()
+ info( '*** Creating network\n' )
+ net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=RemoteController )
+
+ host1, host3, host4, host5 = net.get( 'host1', 'host3', 'host4', 'host5' )
+
+ #host100.setIP('1.168.30.' + str(i), 24, str(host100) + "-eth2")
+
+ #host500.setMAC('00:00:00:00:04:%d' % (i-101), 'host%d-eth0' %(i))
+ #add IP prefixes
+ #for j in range(0,121):
+ #host100.cmd('sudo ip addr add %s.0.40.%s/24 dev host%s-eth0' %(i,j,i))
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ #sw1 = net.get('sw1')
+ host1.setMAC('00:00:00:00:00:01', 'host1-eth0')
+ host1.cmd('ip addr add 192.168.20.101/24 dev host1-eth0')
+ host1.cmd('ip addr add 192.168.30.101/24 dev host1-eth0')
+ #host1.cmd('ip addr add 192.168.40.101/24 dev host1-eth0')
+ host1.cmd('ip addr add 192.168.60.101/24 dev host1-eth0')
+
+ # Net has to be start after adding the above link
+ net.start()
+
+ # Set up as6sw as a learning switch as quickly as possible so it
+ # hopefully doesn't connect to the actual controller
+ # TODO figure out how to change controller before starting switch
+ as6sw = net.get('as6sw')
+ as6sw.cmd('ovs-vsctl set-controller as6sw none')
+ as6sw.cmd('ovs-vsctl set-fail-mode as6sw standalone')
+
+
+ sw1 = net.get('sw1')
+ sw1.cmd('ovs-vsctl set-controller sw1 tcp:127.0.0.1:6633')
+# sw2.cmd('ovs-vsctl set-controller sw2 tcp:127.0.0.1:6633')
+# sw3.cmd('ovs-vsctl set-controller sw3 tcp:127.0.0.1:6633')
+# sw4.cmd('ovs-vsctl set-controller sw4 tcp:127.0.0.1:6633')
+# sw5.cmd('ovs-vsctl set-controller sw5 tcp:127.0.0.1:6633')
+# sw6.cmd('ovs-vsctl set-controller sw6 tcp:127.0.0.1:6633')
+
+
+ swTestOn = net.get('swTestOn')
+ swTestOn.cmd('ovs-vsctl set-controller swTestOn none')
+ swTestOn.cmd('ovs-vsctl set-fail-mode swTestOn standalone')
+
+ host1.defaultIntf().setIP('192.168.10.101/24')
+ # Run BGPd
+ #host1.cmd('%s -d -f %s' % (BGPD, BGPD_CONF))
+ #host1.cmd('/sbin/route add default gw 192.168.10.254 dev %s-eth0' % (host1.name))
+
+ # Configure new host interfaces
+ #host2.defaultIntf().setIP('172.16.10.2/24')
+ #host2.defaultIntf().setMAC('00:00:00:00:01:02')
+ #host2.cmd('/sbin/route add default gw 172.16.10.254 dev %s-eth0' % (host2.name))
+
+ # Set up AS2
+ host3.setIP('192.168.10.1', 24, 'host3-eth0')
+ #host3.cmd('sudo ip addr add 172.16.20.1/24 dev host3-eth0')
+ host3.setIP('192.168.20.1', 24, 'host3-eth1')
+ host3.setMAC('00:00:00:00:02:01', 'host3-eth0')
+ host3.setMAC('00:00:00:00:02:02', 'host3-eth1')
+ #host3.setIP('172.16.20.254', 24, 'host3-eth2')
+ host3.setIP('3.0.0.254', 8, 'host3-eth2')
+ host3.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+
+ host3.setIP('1.168.30.2', 24, 'host3-eth3')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_ignore=1')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_announce=1')
+ as2host = net.get('as2host')
+ #as2host.defaultIntf().setIP('172.16.20.1/24')
+ for i in range(0, 20):
+ as2host.cmd('sudo ip addr add 3.0.%d.1/24 dev as2host-eth0' %i)
+ as2host.setIP('1.168.30.100', 24, 'as2host-eth1')
+
+ as2host.cmd('ip route add default via 3.0.0.254')
+
+ # Set up AS3
+ host4.setIP('192.168.30.1', 24, 'host4-eth0')
+ host4.setMAC('00:00:00:00:03:01', 'host4-eth0')
+ host4.setIP('4.0.0.254', 8, 'host4-eth1')
+ host4.setMAC('00:00:00:00:03:99', 'host4-eth1')
+ host4.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ as3host = net.get('as3host')
+ for i in range(0, 20):
+ as3host.cmd('sudo ip addr add 4.0.%d.1/24 dev as3host-eth0' %i)
+ as3host.cmd('ip route add default via 4.0.0.254')
+
+ host4.setIP('10.0.0.4', 24, 'host4-eth2')
+ host4.setMAC('00:00:00:00:03:33', 'host4-eth2')
+
+ #root space
+ host4.setIP('1.168.30.3', 24, 'host4-eth3')
+ host4.setMAC('00:00:00:00:03:03', 'host4-eth3')
+
+ # Set up AS4
+ #as4host = net.get('as4host')
+ #as4host.defaultIntf().setIP('172.16.40.1/24')
+ #as4host.cmd('ip route add default via 172.16.40.254')
+
+ # setup interface address for 100 quagga hosts
+ #time.sleep(10)
+ #for i in range(numHost101, numHost200 + 1):
+ #host100 = net.get('host' + str(i))
+ #host100.cmd(str(i)+'.0.1.254', 24, 'host'+str(i)+'-eth1')
+ #as4host100 = net.get('as4host%s' %(i))
+ #as4host100.defaultIntf().setIP(str(i) + '.0.0.1/24')
+ #as4host100.cmd('ip route add default via ' + str(i) + '.0.0.254')
+ #for j in range(0, 100):
+ #as4host100.cmd('sudo ip addr add %d.0.%d.1/24 dev %s-eth0' %(i, j, as4host100))
+
+ # Set up AS6 - This has a router and a route server
+ as6rs, host5 = net.get('as6rs', 'host5')
+
+ as6rs.setIP('192.168.60.1', 24, 'as6rs-eth0')
+ as6rs.setMAC('00:00:00:06:06:01', 'as6rs-eth0')
+ as6rs.setIP('1.168.30.6', 24, 'as6rs-eth1')
+ as6rs.setMAC('00:00:00:06:06:06', 'as6rs-eth1')
+
+ host5.setIP('192.168.60.2', 24, 'host5-eth0')
+ host5.setMAC('00:00:00:00:06:02', 'host5-eth0')
+ #as6router.setIP('172.16.60.254', 24, 'as6router-eth1')
+ host5.setIP('5.0.0.254', 8, 'host5-eth1')
+ host5.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ host5.setIP('10.0.0.5', 24, 'host5-eth2')
+ host5.setMAC('00:00:00:00:06:66', 'host5-eth2')
+ host5.setIP('1.168.30.5', 24, 'host5-eth3')
+ host5.setMAC('00:00:00:00:06:05', 'host5-eth3')
+
+ as6host = net.get('as6host')
+ #as6host.defaultIntf().setIP('5.0.0.1/24')
+ for i in range(0, 10):
+ as6host.cmd('sudo ip addr add 5.0.%d.1/24 dev as6host-eth0' %i)
+ as6host.cmd('ip route add default via 5.0.0.254')
+
+ # test the host in the as6
+ #for i in range(1, 10):
+ # baseip = (i-1)*4
+ # host = net.get('as6host%d' % i)
+ # host.defaultIntf().setIP('172.16.70.%d/24' % (baseip+1))
+ # host.cmd('ip route add default via 172.16.70.%d' % (baseip+2))
+ # as6router.setIP('172.16.70.%d' % (baseip+2), 30, 'as6router-eth%d' % (i+1))
+
+ # Start Quagga on border routers
+ startquagga(host3, 1, QUAGGA_CONFIG_FILE_DIR + '/quagga1.conf')
+ startquagga(host4, 2, QUAGGA_CONFIG_FILE_DIR + '/quagga2.conf')
+ #for i in range(numHost101, numHost200 + 1):
+ #host100=net.get('host%d' % (i))
+ #startquaggahost5(host100, i)
+
+ startquagga(as6rs, 4, QUAGGA_CONFIG_FILE_DIR + '/quagga-as6-rs.conf')
+ startquagga(host5, 5, QUAGGA_CONFIG_FILE_DIR + '/quagga-as6.conf')
+
+ #root1, root2, rootTestOn = net.get( 'root1', 'root2', 'rootTestOn' )
+ root1, rootTestOn = net.get( 'root1', 'rootTestOn' )
+ host1.intf('host1-eth1').setIP('1.1.1.1/24')
+ root1.intf('root1-eth0').setIP('1.1.1.2/24')
+ #host2.intf('host2-eth1').setIP('1.1.2.1/24')
+ #root2.intf('root2-eth0').setIP('1.1.2.2/24')
+
+ #rootTestOn.cmd('ip addr add 1.168.30.102/24 dev rootTestOn-eth0')
+ rootTestOn.cmd('ip addr add 1.168.30.99/24 dev rootTestOn-eth0')
+
+ stopsshd()
+
+ startquagga(host1, 100, QUAGGA_CONFIG_FILE_DIR + '/quagga-sdn-modified.conf')
+ hosts = [ host1, host3, host4, host5, as2host, as6rs ];
+ #sshdHosts = sshdHosts + hosts
+ startsshds( hosts )
+ #
+ onos1 = '127.0.0.1'
+ forwarding1 = '%s:2000:%s:2000' % ('1.1.1.2', onos1)
+ root1.cmd( 'ssh -nNT -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % (forwarding1, onos1) )
+
+ # Forward 2605 to root namespace for easier access to SDN domain BGPd
+ # If root can ssh to itself without a password this should work
+ root1.cmd('ssh -N -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -L 2605:1.1.1.1:2605 1.1.1.1 &')
+ #time.sleep(3000000000)
+ CLI( net )
+
+ # Close the ssh port forwarding
+ #quietRun('sudo pkill -f 1.1.1.1')
+
+ stopsshd()
+ stopquagga()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'debug' )
+ if len(sys.argv) > 1:
+ QUAGGA_CONFIG_FILE_DIR = sys.argv[1]
+ sdn1net()
diff --git a/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga-as6-rs.conf b/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga-as6-rs.conf
new file mode 100644
index 0000000..1eac0dd
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga-as6-rs.conf
@@ -0,0 +1,32 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64520
+ bgp router-id 192.168.60.1
+ neighbor 192.168.60.101 remote-as 64513
+ neighbor 192.168.60.101 route-server-client
+ neighbor 192.168.60.2 remote-as 64521
+ neighbor 192.168.60.2 route-server-client
+! network 172.16.60.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga-as6.conf b/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga-as6.conf
new file mode 100644
index 0000000..19cc140
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga-as6.conf
@@ -0,0 +1,39 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64521
+ bgp router-id 192.168.60.2
+ neighbor 192.168.60.1 remote-as 64520
+ neighbor 10.0.0.4 remote-as 64516
+! neighbor 192.168.60.3 remote-as 64520
+! network 172.16.60.0/24
+! network 172.16.70.4/30
+ ! network 172.16.70.8/30
+ ! network 172.16.70.12/30
+ ! network 172.16.70.16/30
+ ! network 172.16.70.20/30
+ ! network 172.16.70.24/30
+ ! network 172.16.70.28/30
+ ! network 172.16.70.32/30
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga-sdn-modified.conf b/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga-sdn-modified.conf
new file mode 100644
index 0000000..bf37a60
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga-sdn-modified.conf
@@ -0,0 +1,49 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+route-map AS65000 permit 1
+ set as-path prepend 65000
+!
+router bgp 64513
+ bgp router-id 192.168.10.101
+ timers bgp 1 3
+ !timers bgp 3 9
+ neighbor 192.168.10.1 remote-as 64514
+ neighbor 192.168.10.1 ebgp-multihop
+ neighbor 192.168.10.1 timers connect 5
+ neighbor 192.168.20.1 remote-as 64514
+ neighbor 192.168.20.1 ebgp-multihop
+ neighbor 192.168.20.1 timers connect 5
+ neighbor 192.168.20.1 route-map AS65000 in
+ neighbor 192.168.30.1 remote-as 64516
+ neighbor 192.168.30.1 ebgp-multihop
+ neighbor 192.168.30.1 timers connect 5
+ neighbor 192.168.60.1 remote-as 64520
+ neighbor 192.168.60.1 ebgp-multihop
+ neighbor 192.168.60.1 timers connect 5
+ neighbor 1.1.1.2 remote-as 64513
+ neighbor 1.1.1.2 port 2000
+ neighbor 1.1.1.2 timers connect 5
+
+
+
+ network 172.16.10.0/24
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga1.conf b/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga1.conf
new file mode 100644
index 0000000..264f85e
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga1.conf
@@ -0,0 +1,32 @@
+!
+! Zebra configuration saved from vty
+! 2014/11/25 11:22:24
+!
+hostname bgpd
+password hello
+log stdout
+!
+router bgp 64514
+ bgp router-id 192.168.10.1
+! network 3.0.0.0/24
+! network 3.0.1.0/24
+! network 3.0.2.0/24
+! network 3.0.3.0/24
+! network 3.0.4.0/24
+! network 3.0.5.0/24
+! network 3.0.6.0/24
+! network 3.0.7.0/24
+! network 3.0.8.0/24
+! network 3.0.9.0/24
+ neighbor 192.168.20.101 remote-as 64513
+ neighbor 192.168.20.101 route-map PREPEND2 in
+ neighbor 192.168.20.101 route-map PREPEND2 out
+!
+route-map PREPEND1 permit 1
+ set as-path prepend 64514
+!
+route-map PREPEND2 permit 2
+ set as-path prepend 64514 64514
+!
+line vty
+!
diff --git a/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga2.conf b/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga2.conf
new file mode 100644
index 0000000..14c7d67
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeserver/mininet/quagga2.conf
@@ -0,0 +1,32 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64516
+ bgp router-id 192.168.30.1
+! timers bgp 1 3
+ neighbor 192.168.30.101 remote-as 64513
+ neighbor 10.0.0.5 remote-as 64521
+! neighbor 192.168.50.2 remote-as 65001
+! network 172.16.30.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/routeserver/mininet/zebra.conf b/TestON/tests/PeeringRouterTest/routeserver/mininet/zebra.conf
new file mode 100644
index 0000000..0f8e3a2
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeserver/mininet/zebra.conf
@@ -0,0 +1,26 @@
+! -*- zebra -*-
+!
+! zebra sample configuration file
+!
+! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
+!
+hostname zebra
+password hello
+enable password 0fw0rk
+log stdout
+!
+! Interfaces description.
+!
+!interface lo
+! description test of desc.
+!
+!interface sit0
+! multicast
+
+!
+! Static default route sample.
+!
+!ip route 0.0.0.0/0 203.181.89.241
+!
+
+!log file /usr/local/var/log/quagga/zebra.log
diff --git a/TestON/tests/PeeringRouterTest/routeserver/sdnip.json b/TestON/tests/PeeringRouterTest/routeserver/sdnip.json
new file mode 100644
index 0000000..1f0a80a
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/routeserver/sdnip.json
@@ -0,0 +1,59 @@
+{
+
+ "bgpPeers" : [
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "1",
+ "ipAddress" : "192.168.10.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "2",
+ "ipAddress" : "192.168.20.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "3",
+ "ipAddress" : "192.168.30.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "4",
+ "ipAddress" : "192.168.60.1"
+ }
+
+ ],
+ "bgpSpeakers" : [
+ {
+ "name" : "bgpSpeaker1",
+ "attachmentDpid" : "00:00:00:00:00:00:00:02",
+ "attachmentPort" : "1",
+ "macAddress" : "00:00:00:00:00:01",
+ "interfaceAddresses" : [
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "1",
+ "ipAddress" : "192.168.10.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "2",
+ "ipAddress" : "192.168.20.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "3",
+ "ipAddress" : "192.168.30.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "4",
+ "ipAddress" : "192.168.60.101"
+ }
+
+ ]
+
+ }
+
+ ]
+}
diff --git a/TestON/tests/PeeringRouterTest/sdnip.json b/TestON/tests/PeeringRouterTest/sdnip.json
new file mode 100644
index 0000000..5b61d05
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/sdnip.json
@@ -0,0 +1,59 @@
+{
+
+ "bgpPeers" : [
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "1",
+ "ipAddress" : "192.168.10.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "2",
+ "ipAddress" : "192.168.20.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "3",
+ "ipAddress" : "192.168.30.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "4",
+ "ipAddress" : "192.168.60.2"
+ }
+
+ ],
+ "bgpSpeakers" : [
+ {
+ "name" : "bgpSpeaker1",
+ "attachmentDpid" : "00:00:00:00:00:00:00:02",
+ "attachmentPort" : "1",
+ "macAddress" : "00:00:00:00:00:02",
+ "interfaceAddresses" : [
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "1",
+ "ipAddress" : "192.168.10.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "2",
+ "ipAddress" : "192.168.20.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "3",
+ "ipAddress" : "192.168.30.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "4",
+ "ipAddress" : "192.168.60.101"
+ }
+
+ ]
+
+ }
+
+ ]
+}
diff --git a/TestON/tests/PeeringRouterTest/vlan/addresses.json b/TestON/tests/PeeringRouterTest/vlan/addresses.json
new file mode 100644
index 0000000..f800c1f
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/addresses.json
@@ -0,0 +1,33 @@
+{
+ "addresses" : [
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "1",
+ "ips" : ["192.168.10.101/24"],
+ "mac" : "00:00:00:00:00:01",
+ "vlan" : "10"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "2",
+ "ips" : ["192.168.20.101/24"],
+ "mac" : "00:00:00:00:00:01",
+ "vlan" : "20"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "3",
+ "ips" : ["192.168.30.101/24"],
+ "mac" : "00:00:00:00:00:01",
+ "vlan" : "30"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "4",
+ "ips" : ["192.168.60.101/24"],
+ "mac" : "00:00:00:00:00:01",
+ "vlan" : "60"
+ }
+
+ ]
+}
diff --git a/TestON/tests/PeeringRouterTest/vlan/mininet/PeeringRouterMininetVlan.py b/TestON/tests/PeeringRouterTest/vlan/mininet/PeeringRouterMininetVlan.py
new file mode 100755
index 0000000..9cbfc6d
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/mininet/PeeringRouterMininetVlan.py
@@ -0,0 +1,376 @@
+#!/usr/bin/python
+
+"""
+Start up the SDN-IP demo topology
+"""
+
+"""
+AS1 = 64513, (SDN AS)
+AS2 = 64514, reachable by 192.168.10.1, 192.168.20.1
+AS3 = 64516, reachable by 192.168.30.1
+AS4 = 64517, reachable by 192.168.40.1
+AS6 = 64520, reachable by 192.168.60.2, (route server 192.168.60.1)
+"""
+
+from mininet.node import Host
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+
+import os.path
+import time
+import sys
+from subprocess import Popen, STDOUT, PIPE
+
+QUAGGA_DIR = '/usr/lib/quagga'
+#QUAGGA_DIR = '/usr/local/sbin'
+QUAGGA_RUN_DIR = '/usr/local/var/run/quagga'
+
+QUAGGA_CONFIG_FILE_DIR = '/home/admin/ONLabTest/TestON/tests/PeeringRouterTest/mininet'
+
+class VLANHost( Host ):
+ "Host connected to VLAN interface"
+
+ def config( self, vlan=10, intf2 = '', ip2 = 0, vlan2 = 0, **params):
+ """Configure VLANHost according to (optional) parameters:
+ vlan: VLAN ID for default interface"""
+
+ r = super( VLANHost, self ).config( **params )
+
+ intf = params['inf']
+ # remove IP from default, "physical" interface
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ # create VLAN interface
+ self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
+ # assign the host's IP to the VLAN interface
+ self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+ # update the intf name and host's intf map
+ newName = '%s.%d' % ( intf, vlan )
+ # update the (Mininet) interface to refer to VLAN interface name
+ defaultIntf = self.defaultIntf()
+ defaultIntf.name = newName
+ # add VLAN interface to host's name to intf map
+ self.nameToIntf[ newName ] = defaultIntf
+
+ return r
+
+class SDNIpModifiedTopo( Topo ):
+ "SDN Ip Modified Topology"
+
+ def __init__( self, *args, **kwargs ):
+ global numHost101
+ global numHost200
+ numHost101 = 101
+ numHost200 = 200
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='0000000000000001')
+ sw2 = self.addSwitch('sw2', dpid='0000000000000002')
+ #add a switch for 3 quagga hosts
+ swTestOn = self.addSwitch('swTestOn', dpid='0000000000000102')
+ #Note this switch isn't part of the SDN topology
+ #We'll use the ovs-controller to turn this into a learning switch
+ as6sw = self.addSwitch('as6sw', dpid='00000000000000a7')
+
+ host1 = self.addHost( 'host1' )
+ root1 = self.addHost( 'root1', inNamespace=False , ip='0')
+ rootTestOn = self.addHost( 'rootTestOn', inNamespace=False, ip='0' )
+
+ #AS2 host
+ host3 = self.addHost( 'host3', cls=VLANHost, vlan=10, inf="host3-eth0", ip="192.168.10.1")
+
+ as2host = self.addHost( 'as2host' )
+ #AS3 host
+ host4 = self.addHost( 'host4', cls=VLANHost, vlan=30, inf="host4-eth0", ip="192.168.30.1" )
+ as3host = self.addHost( 'as3host' )
+ #AS6 host
+ host5 = self.addHost( 'host5', cls=VLANHost, vlan=60, inf="host5-eth0", ip="192.168.60.2" )
+ as6host = self.addHost( 'as6host' )
+
+ self.addLink( host1, sw2 )
+ #Links to the multihomed AS
+ self.addLink( host3, sw1 )
+ self.addLink( host3, sw1 )
+ self.addLink( as2host, host3 )
+ #Single links to the remaining two ASes
+ self.addLink( host4, sw1 )
+ self.addLink( as3host, host4 )
+
+ #AS3-AS4 link
+ #self.addLink( host4, host5)
+ #Add new AS6 to its bridge
+ self.addLink( host5, as6sw )
+ self.addLink( as6host, host5 )
+ #test the host behind the router(behind the router server)
+# for i in range(1, 10):
+ # host = self.addHost('as6host%d' % i)
+ # self.addLink(host, as6router)
+
+ ## Internal Connection To Hosts ##
+ self.addLink( root1, host1 )
+
+ # self.addLink( sw1, sw2 )
+ # self.addLink( sw1, sw3 )
+ # self.addLink( sw2, sw4 )
+ # self.addLink( sw3, sw4 )
+ # self.addLink( sw3, sw5 )
+ # self.addLink( sw4, sw6 )
+ # self.addLink( sw5, sw6 )
+ self.addLink( as6sw, sw1 )
+
+
+ self.addLink(swTestOn, rootTestOn)
+ #self.addLink(swTestOn, host1)
+ self.addLink(swTestOn, host3)
+ self.addLink(swTestOn, host4)
+ self.addLink(swTestOn, host5)
+ self.addLink(swTestOn, as2host)
+
+
+ #self.addLink(rootTestOn, host4)
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def startquagga( host, num, config_file ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f %s -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, config_file, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ print zebra_cmd
+ print quagga_cmd
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+def startquaggahost5( host, num ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f ./as4quaggas/quagga%s.conf -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, num, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+
+def stopquagga( ):
+ quietRun( 'sudo pkill -9 -f bgpd' )
+ quietRun( 'sudo pkill -9 -f zebra' )
+
+def sdn1net():
+ topo = SDNIpModifiedTopo()
+ info( '*** Creating network\n' )
+ net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=RemoteController )
+
+ host1, host3, host4, host5 = net.get( 'host1', 'host3', 'host4', 'host5' )
+
+ #host100.setIP('1.168.30.' + str(i), 24, str(host100) + "-eth2")
+
+ #host500.setMAC('00:00:00:00:04:%d' % (i-101), 'host%d-eth0' %(i))
+ #add IP prefixes
+ #for j in range(0,121):
+ #host100.cmd('sudo ip addr add %s.0.40.%s/24 dev host%s-eth0' %(i,j,i))
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ #sw1 = net.get('sw1')
+ host1.setMAC('00:00:00:00:00:01', 'host1-eth0')
+ #host1.cmd('ip addr add 192.168.20.101/24 dev host1-eth0')
+ #host1.cmd('ip addr add 192.168.30.101/24 dev host1-eth0')
+ #host1.cmd('ip addr add 192.168.60.101/24 dev host1-eth0')
+
+ # Net has to be start after adding the above link
+ net.start()
+
+ # Set up as6sw as a learning switch as quickly as possible so it
+ # hopefully doesn't connect to the actual controller
+ # TODO figure out how to change controller before starting switch
+ as6sw = net.get('as6sw')
+ as6sw.cmd('ovs-vsctl set-controller as6sw none')
+ as6sw.cmd('ovs-vsctl set-fail-mode as6sw standalone')
+
+ as6sw.cmd( 'sudo ovs-vsctl set port as6sw-eth1 trunk=60')
+ as6sw.cmd( 'sudo ovs-vsctl set port as6sw-eth2 trunk=60')
+
+
+ sw1 = net.get('sw1')
+ sw1.cmd('ovs-vsctl set-controller sw1 tcp:127.0.0.1:6633')
+
+ swTestOn = net.get('swTestOn')
+ swTestOn.cmd('ovs-vsctl set-controller swTestOn none')
+ swTestOn.cmd('ovs-vsctl set-fail-mode swTestOn standalone')
+
+ #host1.defaultIntf().setIP('192.168.10.101/24')
+
+ host1.cmd( 'ifconfig host1-eth0 inet 0')
+ host1.cmd( 'vconfig add host1-eth0 10')
+ host1.cmd( 'ifconfig host1-eth0.10 inet 192.168.10.101')
+
+ host1.cmd( 'vconfig add host1-eth0 20')
+ host1.cmd( 'ifconfig host1-eth0.20 inet 192.168.20.101')
+
+ host1.cmd( 'vconfig add host1-eth0 30')
+ host1.cmd( 'ifconfig host1-eth0.30 inet 192.168.30.101')
+
+ host1.cmd( 'vconfig add host1-eth0 60')
+ host1.cmd( 'ifconfig host1-eth0.60 inet 192.168.60.101')
+
+ # Run BGPd
+ #host1.cmd('%s -d -f %s' % (BGPD, BGPD_CONF))
+ #host1.cmd('/sbin/route add default gw 192.168.10.254 dev %s-eth0' % (host1.name))
+
+ # Configure new host interfaces
+ #host2.defaultIntf().setIP('172.16.10.2/24')
+ #host2.defaultIntf().setMAC('00:00:00:00:01:02')
+ #host2.cmd('/sbin/route add default gw 172.16.10.254 dev %s-eth0' % (host2.name))
+
+ # Set up AS2
+ # add additional VLAN interface
+ host3.cmd( 'ifconfig host3-eth1 inet 0')
+ host3.cmd( 'vconfig add host3-eth1 20')
+ host3.cmd( 'ifconfig host3-eth1.20 inet 192.168.20.1')
+ # change the interface for the sencond connection to sw1 to vlan interface
+ newName = "host3-eth1.20"
+ secondIntf = host3.intf("host3-eth1")
+ secondIntf.name = newName
+ host3.nameToIntf[ newName ] = secondIntf
+
+ host3.setMAC('00:00:00:00:02:01', 'host3-eth0.10')
+ host3.setMAC('00:00:00:00:02:02', 'host3-eth1.20')
+
+ #host3.setIP('172.16.20.254', 24, 'host3-eth2')
+ host3.setIP('3.0.0.254', 8, 'host3-eth2')
+ host3.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+
+ host3.setIP('1.168.30.2', 24, 'host3-eth3')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_ignore=1')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_announce=1')
+ host3.cmd('ip route add default via 192.168.10.101')
+ as2host = net.get('as2host')
+ #as2host.defaultIntf().setIP('172.16.20.1/24')
+ for i in range(0, 20):
+ as2host.cmd('sudo ip addr add 3.0.%d.1/24 dev as2host-eth0' %i)
+ as2host.setIP('1.168.30.100', 24, 'as2host-eth1')
+
+ as2host.cmd('ip route add default via 3.0.0.254')
+
+ # Set up AS3
+ host4.setMAC('00:00:00:00:03:01', 'host4-eth0.30')
+ host4.setIP('4.0.0.254', 8, 'host4-eth1')
+ host4.setMAC('00:00:00:00:03:99', 'host4-eth1')
+ host4.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ host4.cmd('ip route add default via 192.168.30.101')
+ as3host = net.get('as3host')
+ for i in range(0, 20):
+ as3host.cmd('sudo ip addr add 4.0.%d.1/24 dev as3host-eth0' %i)
+ as3host.cmd('ip route add default via 4.0.0.254')
+
+ #root space
+ host4.setIP('1.168.30.3', 24, 'host4-eth2')
+ host4.setMAC('00:00:00:00:03:03', 'host4-eth2')
+
+ # Set up AS4
+ #as4host = net.get('as4host')
+ #as4host.defaultIntf().setIP('172.16.40.1/24')
+ #as4host.cmd('ip route add default via 172.16.40.254')
+
+ # setup interface address for 100 quagga hosts
+ time.sleep(10)
+ #for i in range(numHost101, numHost200 + 1):
+ #host100 = net.get('host' + str(i))
+ #host100.cmd(str(i)+'.0.1.254', 24, 'host'+str(i)+'-eth1')
+ #as4host100 = net.get('as4host%s' %(i))
+ #as4host100.defaultIntf().setIP(str(i) + '.0.0.1/24')
+ #as4host100.cmd('ip route add default via ' + str(i) + '.0.0.254')
+ #for j in range(0, 100):
+ #as4host100.cmd('sudo ip addr add %d.0.%d.1/24 dev %s-eth0' %(i, j, as4host100))
+
+ # Set up AS6 - This has a router and a route server
+ host5 = net.get('host5')
+ host5.setMAC('00:00:00:00:06:02', 'host5-eth0.60')
+ #as6router.setIP('172.16.60.254', 24, 'as6router-eth1')
+ host5.setIP('5.0.0.254', 8, 'host5-eth1')
+ host5.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ host5.setIP('1.168.30.5', 24, 'host5-eth2')
+ host5.setMAC('00:00:00:00:06:05', 'host5-eth2')
+ host5.cmd('ip route add default via 192.168.60.101')
+ as6host = net.get('as6host')
+ #as6host.defaultIntf().setIP('5.0.0.1/24')
+ for i in range(0, 10):
+ as6host.cmd('sudo ip addr add 5.0.%d.1/24 dev as6host-eth0' %i)
+ as6host.cmd('ip route add default via 5.0.0.254')
+
+ # test the host in the as6
+ #for i in range(1, 10):
+ # baseip = (i-1)*4
+ # host = net.get('as6host%d' % i)
+ # host.defaultIntf().setIP('172.16.70.%d/24' % (baseip+1))
+ # host.cmd('ip route add default via 172.16.70.%d' % (baseip+2))
+ # as6router.setIP('172.16.70.%d' % (baseip+2), 30, 'as6router-eth%d' % (i+1))
+
+ # Start Quagga on border routers
+ startquagga(host3, 1, QUAGGA_CONFIG_FILE_DIR + '/quagga1.conf')
+ startquagga(host4, 2, QUAGGA_CONFIG_FILE_DIR + '/quagga2.conf')
+ #for i in range(numHost101, numHost200 + 1):
+ #host100=net.get('host%d' % (i))
+ #startquaggahost5(host100, i)
+
+ #startquagga(as6rs, 4, 'quagga-as6-rs.conf')
+ startquagga(host5, 5, QUAGGA_CONFIG_FILE_DIR + '/quagga-as6.conf')
+
+ #root1, root2, rootTestOn = net.get( 'root1', 'root2', 'rootTestOn' )
+ root1, rootTestOn = net.get( 'root1', 'rootTestOn' )
+ host1.intf('host1-eth1').setIP('1.1.1.1/24')
+ root1.intf('root1-eth0').setIP('1.1.1.2/24')
+ #host2.intf('host2-eth1').setIP('1.1.2.1/24')
+ #root2.intf('root2-eth0').setIP('1.1.2.2/24')
+
+ #rootTestOn.cmd('ip addr add 1.168.30.102/24 dev rootTestOn-eth0')
+ rootTestOn.cmd('ip addr add 1.168.30.99/24 dev rootTestOn-eth0')
+
+ stopsshd()
+
+ startquagga(host1, 100, QUAGGA_CONFIG_FILE_DIR + '/quagga-sdn-modified.conf')
+ hosts = [ host1, host3, host4, host5, as2host ];
+ #sshdHosts = sshdHosts + hosts
+ startsshds( hosts )
+ #
+ onos1 = '127.0.0.1'
+ forwarding1 = '%s:2000:%s:2000' % ('1.1.1.2', onos1)
+ root1.cmd( 'ssh -nNT -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % (forwarding1, onos1) )
+
+ # Forward 2605 to root namespace for easier access to SDN domain BGPd
+ # If root can ssh to itself without a password this should work
+ root1.cmd('ssh -N -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -L 2605:1.1.1.1:2605 1.1.1.1 &')
+ #time.sleep(3000000000)
+ CLI( net )
+
+ # Close the ssh port forwarding
+ #quietRun('sudo pkill -f 1.1.1.1')
+
+ stopsshd()
+ stopquagga()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'debug' )
+ if len(sys.argv) > 1:
+ QUAGGA_CONFIG_FILE_DIR = sys.argv[1]
+ sdn1net()
diff --git a/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-as6-rs.conf b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-as6-rs.conf
new file mode 100644
index 0000000..1eac0dd
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-as6-rs.conf
@@ -0,0 +1,32 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64520
+ bgp router-id 192.168.60.1
+ neighbor 192.168.60.101 remote-as 64513
+ neighbor 192.168.60.101 route-server-client
+ neighbor 192.168.60.2 remote-as 64521
+ neighbor 192.168.60.2 route-server-client
+! network 172.16.60.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-as6.conf b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-as6.conf
new file mode 100644
index 0000000..434f983
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-as6.conf
@@ -0,0 +1,39 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64521
+ bgp router-id 192.168.60.2
+ neighbor 192.168.60.101 remote-as 64513
+! neighbor 192.168.60.1 remote-as 64520
+! neighbor 192.168.60.3 remote-as 64520
+! network 172.16.60.0/24
+! network 172.16.70.4/30
+ ! network 172.16.70.8/30
+ ! network 172.16.70.12/30
+ ! network 172.16.70.16/30
+ ! network 172.16.70.20/30
+ ! network 172.16.70.24/30
+ ! network 172.16.70.28/30
+ ! network 172.16.70.32/30
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-sdn-modified.conf b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-sdn-modified.conf
new file mode 100644
index 0000000..d334c2a
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-sdn-modified.conf
@@ -0,0 +1,49 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+route-map AS65000 permit 1
+ set as-path prepend 65000
+!
+router bgp 64513
+ bgp router-id 192.168.10.101
+ timers bgp 1 3
+ !timers bgp 3 9
+ neighbor 192.168.10.1 remote-as 64514
+ neighbor 192.168.10.1 ebgp-multihop
+ neighbor 192.168.10.1 timers connect 5
+ neighbor 192.168.20.1 remote-as 64514
+ neighbor 192.168.20.1 ebgp-multihop
+ neighbor 192.168.20.1 timers connect 5
+ neighbor 192.168.20.1 route-map AS65000 in
+ neighbor 192.168.30.1 remote-as 64516
+ neighbor 192.168.30.1 ebgp-multihop
+ neighbor 192.168.30.1 timers connect 5
+ neighbor 192.168.60.2 remote-as 64521
+ neighbor 192.168.60.2 ebgp-multihop
+ neighbor 192.168.60.2 timers connect 5
+ neighbor 1.1.1.2 remote-as 64513
+ neighbor 1.1.1.2 port 2000
+ neighbor 1.1.1.2 timers connect 5
+
+
+
+ network 172.16.10.0/24
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-sdn.conf b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-sdn.conf
new file mode 100644
index 0000000..77392a6
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga-sdn.conf
@@ -0,0 +1,349 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+route-map AS65000 permit 1
+ set as-path prepend 65000
+!
+router bgp 64513
+ bgp router-id 192.168.10.101
+ timers bgp 1 3
+ !timers bgp 3 9
+ neighbor 192.168.10.1 remote-as 64514
+ neighbor 192.168.10.1 ebgp-multihop
+ neighbor 192.168.10.1 timers connect 5
+ neighbor 192.168.20.1 remote-as 64514
+ neighbor 192.168.20.1 ebgp-multihop
+ neighbor 192.168.20.1 timers connect 5
+ neighbor 192.168.20.1 route-map AS65000 in
+ neighbor 192.168.30.1 remote-as 64516
+ neighbor 192.168.30.1 ebgp-multihop
+ neighbor 192.168.30.1 timers connect 5
+ neighbor 192.168.60.1 remote-as 64520
+ neighbor 192.168.60.1 ebgp-multihop
+ neighbor 192.168.60.1 timers connect 5
+ neighbor 1.1.1.2 remote-as 64513
+ neighbor 1.1.1.2 port 2000
+ neighbor 1.1.1.2 timers connect 5
+
+
+neighbor 192.168.40.1 remote-as 65001
+neighbor 192.168.40.1 ebgp-multihop
+neighbor 192.168.40.1 timers connect 10
+neighbor 192.168.40.2 remote-as 65002
+neighbor 192.168.40.2 ebgp-multihop
+neighbor 192.168.40.2 timers connect 10
+neighbor 192.168.40.3 remote-as 65003
+neighbor 192.168.40.3 ebgp-multihop
+neighbor 192.168.40.3 timers connect 10
+neighbor 192.168.40.4 remote-as 65004
+neighbor 192.168.40.4 ebgp-multihop
+neighbor 192.168.40.4 timers connect 10
+neighbor 192.168.40.5 remote-as 65005
+neighbor 192.168.40.5 ebgp-multihop
+neighbor 192.168.40.5 timers connect 10
+neighbor 192.168.40.6 remote-as 65006
+neighbor 192.168.40.6 ebgp-multihop
+neighbor 192.168.40.6 timers connect 10
+neighbor 192.168.40.7 remote-as 65007
+neighbor 192.168.40.7 ebgp-multihop
+neighbor 192.168.40.7 timers connect 10
+neighbor 192.168.40.8 remote-as 65008
+neighbor 192.168.40.8 ebgp-multihop
+neighbor 192.168.40.8 timers connect 10
+neighbor 192.168.40.9 remote-as 65009
+neighbor 192.168.40.9 ebgp-multihop
+neighbor 192.168.40.9 timers connect 10
+neighbor 192.168.40.10 remote-as 65010
+neighbor 192.168.40.10 ebgp-multihop
+neighbor 192.168.40.10 timers connect 10
+neighbor 192.168.40.11 remote-as 65011
+neighbor 192.168.40.11 ebgp-multihop
+neighbor 192.168.40.11 timers connect 10
+neighbor 192.168.40.12 remote-as 65012
+neighbor 192.168.40.12 ebgp-multihop
+neighbor 192.168.40.12 timers connect 10
+neighbor 192.168.40.13 remote-as 65013
+neighbor 192.168.40.13 ebgp-multihop
+neighbor 192.168.40.13 timers connect 10
+neighbor 192.168.40.14 remote-as 65014
+neighbor 192.168.40.14 ebgp-multihop
+neighbor 192.168.40.14 timers connect 10
+neighbor 192.168.40.15 remote-as 65015
+neighbor 192.168.40.15 ebgp-multihop
+neighbor 192.168.40.15 timers connect 10
+neighbor 192.168.40.16 remote-as 65016
+neighbor 192.168.40.16 ebgp-multihop
+neighbor 192.168.40.16 timers connect 10
+neighbor 192.168.40.17 remote-as 65017
+neighbor 192.168.40.17 ebgp-multihop
+neighbor 192.168.40.17 timers connect 10
+neighbor 192.168.40.18 remote-as 65018
+neighbor 192.168.40.18 ebgp-multihop
+neighbor 192.168.40.18 timers connect 10
+neighbor 192.168.40.19 remote-as 65019
+neighbor 192.168.40.19 ebgp-multihop
+neighbor 192.168.40.19 timers connect 10
+neighbor 192.168.40.20 remote-as 65020
+neighbor 192.168.40.20 ebgp-multihop
+neighbor 192.168.40.20 timers connect 10
+neighbor 192.168.40.21 remote-as 65021
+neighbor 192.168.40.21 ebgp-multihop
+neighbor 192.168.40.21 timers connect 10
+neighbor 192.168.40.22 remote-as 65022
+neighbor 192.168.40.22 ebgp-multihop
+neighbor 192.168.40.22 timers connect 10
+neighbor 192.168.40.23 remote-as 65023
+neighbor 192.168.40.23 ebgp-multihop
+neighbor 192.168.40.23 timers connect 10
+neighbor 192.168.40.24 remote-as 65024
+neighbor 192.168.40.24 ebgp-multihop
+neighbor 192.168.40.24 timers connect 10
+neighbor 192.168.40.25 remote-as 65025
+neighbor 192.168.40.25 ebgp-multihop
+neighbor 192.168.40.25 timers connect 10
+neighbor 192.168.40.26 remote-as 65026
+neighbor 192.168.40.26 ebgp-multihop
+neighbor 192.168.40.26 timers connect 10
+neighbor 192.168.40.27 remote-as 65027
+neighbor 192.168.40.27 ebgp-multihop
+neighbor 192.168.40.27 timers connect 10
+neighbor 192.168.40.28 remote-as 65028
+neighbor 192.168.40.28 ebgp-multihop
+neighbor 192.168.40.28 timers connect 10
+neighbor 192.168.40.29 remote-as 65029
+neighbor 192.168.40.29 ebgp-multihop
+neighbor 192.168.40.29 timers connect 10
+neighbor 192.168.40.30 remote-as 65030
+neighbor 192.168.40.30 ebgp-multihop
+neighbor 192.168.40.30 timers connect 10
+neighbor 192.168.40.31 remote-as 65031
+neighbor 192.168.40.31 ebgp-multihop
+neighbor 192.168.40.31 timers connect 10
+neighbor 192.168.40.32 remote-as 65032
+neighbor 192.168.40.32 ebgp-multihop
+neighbor 192.168.40.32 timers connect 10
+neighbor 192.168.40.33 remote-as 65033
+neighbor 192.168.40.33 ebgp-multihop
+neighbor 192.168.40.33 timers connect 10
+neighbor 192.168.40.34 remote-as 65034
+neighbor 192.168.40.34 ebgp-multihop
+neighbor 192.168.40.34 timers connect 10
+neighbor 192.168.40.35 remote-as 65035
+neighbor 192.168.40.35 ebgp-multihop
+neighbor 192.168.40.35 timers connect 10
+neighbor 192.168.40.36 remote-as 65036
+neighbor 192.168.40.36 ebgp-multihop
+neighbor 192.168.40.36 timers connect 10
+neighbor 192.168.40.37 remote-as 65037
+neighbor 192.168.40.37 ebgp-multihop
+neighbor 192.168.40.37 timers connect 10
+neighbor 192.168.40.38 remote-as 65038
+neighbor 192.168.40.38 ebgp-multihop
+neighbor 192.168.40.38 timers connect 10
+neighbor 192.168.40.39 remote-as 65039
+neighbor 192.168.40.39 ebgp-multihop
+neighbor 192.168.40.39 timers connect 10
+neighbor 192.168.40.40 remote-as 65040
+neighbor 192.168.40.40 ebgp-multihop
+neighbor 192.168.40.40 timers connect 10
+neighbor 192.168.40.41 remote-as 65041
+neighbor 192.168.40.41 ebgp-multihop
+neighbor 192.168.40.41 timers connect 10
+neighbor 192.168.40.42 remote-as 65042
+neighbor 192.168.40.42 ebgp-multihop
+neighbor 192.168.40.42 timers connect 10
+neighbor 192.168.40.43 remote-as 65043
+neighbor 192.168.40.43 ebgp-multihop
+neighbor 192.168.40.43 timers connect 10
+neighbor 192.168.40.44 remote-as 65044
+neighbor 192.168.40.44 ebgp-multihop
+neighbor 192.168.40.44 timers connect 10
+neighbor 192.168.40.45 remote-as 65045
+neighbor 192.168.40.45 ebgp-multihop
+neighbor 192.168.40.45 timers connect 10
+neighbor 192.168.40.46 remote-as 65046
+neighbor 192.168.40.46 ebgp-multihop
+neighbor 192.168.40.46 timers connect 10
+neighbor 192.168.40.47 remote-as 65047
+neighbor 192.168.40.47 ebgp-multihop
+neighbor 192.168.40.47 timers connect 10
+neighbor 192.168.40.48 remote-as 65048
+neighbor 192.168.40.48 ebgp-multihop
+neighbor 192.168.40.48 timers connect 10
+neighbor 192.168.40.49 remote-as 65049
+neighbor 192.168.40.49 ebgp-multihop
+neighbor 192.168.40.49 timers connect 10
+neighbor 192.168.40.50 remote-as 65050
+neighbor 192.168.40.50 ebgp-multihop
+neighbor 192.168.40.50 timers connect 10
+neighbor 192.168.40.51 remote-as 65051
+neighbor 192.168.40.51 ebgp-multihop
+neighbor 192.168.40.51 timers connect 10
+neighbor 192.168.40.52 remote-as 65052
+neighbor 192.168.40.52 ebgp-multihop
+neighbor 192.168.40.52 timers connect 10
+neighbor 192.168.40.53 remote-as 65053
+neighbor 192.168.40.53 ebgp-multihop
+neighbor 192.168.40.53 timers connect 10
+neighbor 192.168.40.54 remote-as 65054
+neighbor 192.168.40.54 ebgp-multihop
+neighbor 192.168.40.54 timers connect 10
+neighbor 192.168.40.55 remote-as 65055
+neighbor 192.168.40.55 ebgp-multihop
+neighbor 192.168.40.55 timers connect 10
+neighbor 192.168.40.56 remote-as 65056
+neighbor 192.168.40.56 ebgp-multihop
+neighbor 192.168.40.56 timers connect 10
+neighbor 192.168.40.57 remote-as 65057
+neighbor 192.168.40.57 ebgp-multihop
+neighbor 192.168.40.57 timers connect 10
+neighbor 192.168.40.58 remote-as 65058
+neighbor 192.168.40.58 ebgp-multihop
+neighbor 192.168.40.58 timers connect 10
+neighbor 192.168.40.59 remote-as 65059
+neighbor 192.168.40.59 ebgp-multihop
+neighbor 192.168.40.59 timers connect 10
+neighbor 192.168.40.60 remote-as 65060
+neighbor 192.168.40.60 ebgp-multihop
+neighbor 192.168.40.60 timers connect 10
+neighbor 192.168.40.61 remote-as 65061
+neighbor 192.168.40.61 ebgp-multihop
+neighbor 192.168.40.61 timers connect 10
+neighbor 192.168.40.62 remote-as 65062
+neighbor 192.168.40.62 ebgp-multihop
+neighbor 192.168.40.62 timers connect 10
+neighbor 192.168.40.63 remote-as 65063
+neighbor 192.168.40.63 ebgp-multihop
+neighbor 192.168.40.63 timers connect 10
+neighbor 192.168.40.64 remote-as 65064
+neighbor 192.168.40.64 ebgp-multihop
+neighbor 192.168.40.64 timers connect 10
+neighbor 192.168.40.65 remote-as 65065
+neighbor 192.168.40.65 ebgp-multihop
+neighbor 192.168.40.65 timers connect 10
+neighbor 192.168.40.66 remote-as 65066
+neighbor 192.168.40.66 ebgp-multihop
+neighbor 192.168.40.66 timers connect 10
+neighbor 192.168.40.67 remote-as 65067
+neighbor 192.168.40.67 ebgp-multihop
+neighbor 192.168.40.67 timers connect 10
+neighbor 192.168.40.68 remote-as 65068
+neighbor 192.168.40.68 ebgp-multihop
+neighbor 192.168.40.68 timers connect 10
+neighbor 192.168.40.69 remote-as 65069
+neighbor 192.168.40.69 ebgp-multihop
+neighbor 192.168.40.69 timers connect 10
+neighbor 192.168.40.70 remote-as 65070
+neighbor 192.168.40.70 ebgp-multihop
+neighbor 192.168.40.70 timers connect 10
+neighbor 192.168.40.71 remote-as 65071
+neighbor 192.168.40.71 ebgp-multihop
+neighbor 192.168.40.71 timers connect 10
+neighbor 192.168.40.72 remote-as 65072
+neighbor 192.168.40.72 ebgp-multihop
+neighbor 192.168.40.72 timers connect 10
+neighbor 192.168.40.73 remote-as 65073
+neighbor 192.168.40.73 ebgp-multihop
+neighbor 192.168.40.73 timers connect 10
+neighbor 192.168.40.74 remote-as 65074
+neighbor 192.168.40.74 ebgp-multihop
+neighbor 192.168.40.74 timers connect 10
+neighbor 192.168.40.75 remote-as 65075
+neighbor 192.168.40.75 ebgp-multihop
+neighbor 192.168.40.75 timers connect 10
+neighbor 192.168.40.76 remote-as 65076
+neighbor 192.168.40.76 ebgp-multihop
+neighbor 192.168.40.76 timers connect 10
+neighbor 192.168.40.77 remote-as 65077
+neighbor 192.168.40.77 ebgp-multihop
+neighbor 192.168.40.77 timers connect 10
+neighbor 192.168.40.78 remote-as 65078
+neighbor 192.168.40.78 ebgp-multihop
+neighbor 192.168.40.78 timers connect 10
+neighbor 192.168.40.79 remote-as 65079
+neighbor 192.168.40.79 ebgp-multihop
+neighbor 192.168.40.79 timers connect 10
+neighbor 192.168.40.80 remote-as 65080
+neighbor 192.168.40.80 ebgp-multihop
+neighbor 192.168.40.80 timers connect 10
+neighbor 192.168.40.81 remote-as 65081
+neighbor 192.168.40.81 ebgp-multihop
+neighbor 192.168.40.81 timers connect 10
+neighbor 192.168.40.82 remote-as 65082
+neighbor 192.168.40.82 ebgp-multihop
+neighbor 192.168.40.82 timers connect 10
+neighbor 192.168.40.83 remote-as 65083
+neighbor 192.168.40.83 ebgp-multihop
+neighbor 192.168.40.83 timers connect 10
+neighbor 192.168.40.84 remote-as 65084
+neighbor 192.168.40.84 ebgp-multihop
+neighbor 192.168.40.84 timers connect 10
+neighbor 192.168.40.85 remote-as 65085
+neighbor 192.168.40.85 ebgp-multihop
+neighbor 192.168.40.85 timers connect 10
+neighbor 192.168.40.86 remote-as 65086
+neighbor 192.168.40.86 ebgp-multihop
+neighbor 192.168.40.86 timers connect 10
+neighbor 192.168.40.87 remote-as 65087
+neighbor 192.168.40.87 ebgp-multihop
+neighbor 192.168.40.87 timers connect 10
+neighbor 192.168.40.88 remote-as 65088
+neighbor 192.168.40.88 ebgp-multihop
+neighbor 192.168.40.88 timers connect 10
+neighbor 192.168.40.89 remote-as 65089
+neighbor 192.168.40.89 ebgp-multihop
+neighbor 192.168.40.89 timers connect 10
+neighbor 192.168.40.90 remote-as 65090
+neighbor 192.168.40.90 ebgp-multihop
+neighbor 192.168.40.90 timers connect 10
+neighbor 192.168.40.91 remote-as 65091
+neighbor 192.168.40.91 ebgp-multihop
+neighbor 192.168.40.91 timers connect 10
+neighbor 192.168.40.92 remote-as 65092
+neighbor 192.168.40.92 ebgp-multihop
+neighbor 192.168.40.92 timers connect 10
+neighbor 192.168.40.93 remote-as 65093
+neighbor 192.168.40.93 ebgp-multihop
+neighbor 192.168.40.93 timers connect 10
+neighbor 192.168.40.94 remote-as 65094
+neighbor 192.168.40.94 ebgp-multihop
+neighbor 192.168.40.94 timers connect 10
+neighbor 192.168.40.95 remote-as 65095
+neighbor 192.168.40.95 ebgp-multihop
+neighbor 192.168.40.95 timers connect 10
+neighbor 192.168.40.96 remote-as 65096
+neighbor 192.168.40.96 ebgp-multihop
+neighbor 192.168.40.96 timers connect 10
+neighbor 192.168.40.97 remote-as 65097
+neighbor 192.168.40.97 ebgp-multihop
+neighbor 192.168.40.97 timers connect 10
+neighbor 192.168.40.98 remote-as 65098
+neighbor 192.168.40.98 ebgp-multihop
+neighbor 192.168.40.98 timers connect 10
+neighbor 192.168.40.99 remote-as 65099
+neighbor 192.168.40.99 ebgp-multihop
+neighbor 192.168.40.99 timers connect 10
+neighbor 192.168.40.100 remote-as 65100
+neighbor 192.168.40.100 ebgp-multihop
+neighbor 192.168.40.100 timers connect 10
+
+ network 172.16.10.0/24
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/mininet/quagga1.conf b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga1.conf
new file mode 100644
index 0000000..264f85e
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga1.conf
@@ -0,0 +1,32 @@
+!
+! Zebra configuration saved from vty
+! 2014/11/25 11:22:24
+!
+hostname bgpd
+password hello
+log stdout
+!
+router bgp 64514
+ bgp router-id 192.168.10.1
+! network 3.0.0.0/24
+! network 3.0.1.0/24
+! network 3.0.2.0/24
+! network 3.0.3.0/24
+! network 3.0.4.0/24
+! network 3.0.5.0/24
+! network 3.0.6.0/24
+! network 3.0.7.0/24
+! network 3.0.8.0/24
+! network 3.0.9.0/24
+ neighbor 192.168.20.101 remote-as 64513
+ neighbor 192.168.20.101 route-map PREPEND2 in
+ neighbor 192.168.20.101 route-map PREPEND2 out
+!
+route-map PREPEND1 permit 1
+ set as-path prepend 64514
+!
+route-map PREPEND2 permit 2
+ set as-path prepend 64514 64514
+!
+line vty
+!
diff --git a/TestON/tests/PeeringRouterTest/vlan/mininet/quagga2.conf b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga2.conf
new file mode 100644
index 0000000..20ca9e4
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/mininet/quagga2.conf
@@ -0,0 +1,31 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64516
+ bgp router-id 192.168.30.1
+! timers bgp 1 3
+ neighbor 192.168.30.101 remote-as 64513
+! neighbor 192.168.50.2 remote-as 65001
+! network 172.16.30.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/mininet/zebra.conf b/TestON/tests/PeeringRouterTest/vlan/mininet/zebra.conf
new file mode 100644
index 0000000..0f8e3a2
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/mininet/zebra.conf
@@ -0,0 +1,26 @@
+! -*- zebra -*-
+!
+! zebra sample configuration file
+!
+! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
+!
+hostname zebra
+password hello
+enable password 0fw0rk
+log stdout
+!
+! Interfaces description.
+!
+!interface lo
+! description test of desc.
+!
+!interface sit0
+! multicast
+
+!
+! Static default route sample.
+!
+!ip route 0.0.0.0/0 203.181.89.241
+!
+
+!log file /usr/local/var/log/quagga/zebra.log
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/PeeringRouterConvergenceVlanMininet.py b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/PeeringRouterConvergenceVlanMininet.py
new file mode 100755
index 0000000..983d666
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/PeeringRouterConvergenceVlanMininet.py
@@ -0,0 +1,381 @@
+#!/usr/bin/python
+
+"""
+Start up the SDN-IP demo topology
+"""
+
+"""
+AS1 = 64513, (SDN AS)
+AS2 = 64514, reachable by 192.168.10.1, 192.168.20.1
+AS3 = 64516, reachable by 192.168.30.1
+AS4 = 64517, reachable by 192.168.40.1
+AS6 = 64520, reachable by 192.168.60.2, (route server 192.168.60.1)
+"""
+
+from mininet.node import Host
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+
+import os.path
+import time
+import sys
+from subprocess import Popen, STDOUT, PIPE
+
+QUAGGA_DIR = '/usr/lib/quagga'
+#QUAGGA_DIR = '/usr/local/sbin'
+QUAGGA_RUN_DIR = '/usr/local/var/run/quagga'
+
+QUAGGA_CONFIG_FILE_DIR = '/home/tutorial1/ONLabTest/TestON/tests/PeeringRouterTest/mininet'
+
+class VLANHost( Host ):
+ "Host connected to VLAN interface"
+
+ def config( self, vlan=10, intf2 = '', ip2 = 0, vlan2 = 0, **params):
+ """Configure VLANHost according to (optional) parameters:
+ vlan: VLAN ID for default interface"""
+
+ r = super( VLANHost, self ).config( **params )
+
+ intf = params['inf']
+ # remove IP from default, "physical" interface
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ # create VLAN interface
+ self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
+ # assign the host's IP to the VLAN interface
+ self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+ # update the intf name and host's intf map
+ newName = '%s.%d' % ( intf, vlan )
+ # update the (Mininet) interface to refer to VLAN interface name
+ defaultIntf = self.defaultIntf()
+ defaultIntf.name = newName
+ # add VLAN interface to host's name to intf map
+ self.nameToIntf[ newName ] = defaultIntf
+
+ return r
+
+class SDNIpModifiedTopo( Topo ):
+ "SDN Ip Modified Topology"
+
+ def __init__( self, *args, **kwargs ):
+ global numHost101
+ global numHost200
+ numHost101 = 101
+ numHost200 = 200
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='0000000000000001')
+ sw2 = self.addSwitch('sw2', dpid='0000000000000002')
+ #add a switch for 3 quagga hosts
+ swTestOn = self.addSwitch('swTestOn', dpid='0000000000000102')
+ #Note this switch isn't part of the SDN topology
+ #We'll use the ovs-controller to turn this into a learning switch
+ as6sw = self.addSwitch('as6sw', dpid='00000000000000a7')
+
+ host1 = self.addHost( 'host1' )
+ root1 = self.addHost( 'root1', inNamespace=False , ip='0')
+ rootTestOn = self.addHost( 'rootTestOn', inNamespace=False, ip='0' )
+
+ #AS2 host
+ host3 = self.addHost( 'host3', cls=VLANHost, vlan=10, inf="host3-eth0", ip="192.168.10.1")
+
+ as2host = self.addHost( 'as2host' )
+ #AS3 host
+ host4 = self.addHost( 'host4', cls=VLANHost, vlan=30, inf="host4-eth0", ip="192.168.30.1" )
+ as3host = self.addHost( 'as3host' )
+ #AS6 host
+ host5 = self.addHost( 'host5', cls=VLANHost, vlan=60, inf="host5-eth0", ip="192.168.60.2" )
+ as6host = self.addHost( 'as6host' )
+
+ self.addLink( host1, sw2 )
+ #Links to the multihomed AS
+ self.addLink( host3, sw1 )
+ self.addLink( host3, sw1 )
+ self.addLink( as2host, host3 )
+ #Single links to the remaining two ASes
+ self.addLink( host4, sw1 )
+ self.addLink( as3host, host4 )
+
+ #AS3-AS4 link
+ #self.addLink( host4, host5)
+ #Add new AS6 to its bridge
+ self.addLink( host5, as6sw )
+ self.addLink( as6host, host5 )
+ #Backup link from router5 to router4
+ self.addLink( host4, host5)
+ #test the host behind the router(behind the router server)
+# for i in range(1, 10):
+ # host = self.addHost('as6host%d' % i)
+ # self.addLink(host, as6router)
+
+ ## Internal Connection To Hosts ##
+ self.addLink( root1, host1 )
+
+ # self.addLink( sw1, sw2 )
+ # self.addLink( sw1, sw3 )
+ # self.addLink( sw2, sw4 )
+ # self.addLink( sw3, sw4 )
+ # self.addLink( sw3, sw5 )
+ # self.addLink( sw4, sw6 )
+ # self.addLink( sw5, sw6 )
+ self.addLink( as6sw, sw1 )
+
+
+ self.addLink(swTestOn, rootTestOn)
+ #self.addLink(swTestOn, host1)
+ self.addLink(swTestOn, host3)
+ self.addLink(swTestOn, host4)
+ self.addLink(swTestOn, host5)
+ self.addLink(swTestOn, as2host)
+
+
+ #self.addLink(rootTestOn, host4)
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def startquagga( host, num, config_file ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f %s -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, config_file, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ print zebra_cmd
+ print quagga_cmd
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+def startquaggahost5( host, num ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f ./as4quaggas/quagga%s.conf -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, num, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+
+def stopquagga( ):
+ quietRun( 'sudo pkill -9 -f bgpd' )
+ quietRun( 'sudo pkill -9 -f zebra' )
+
+def sdn1net():
+ topo = SDNIpModifiedTopo()
+ info( '*** Creating network\n' )
+ net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=RemoteController )
+
+ host1, host3, host4, host5 = net.get( 'host1', 'host3', 'host4', 'host5' )
+
+ #host100.setIP('1.168.30.' + str(i), 24, str(host100) + "-eth2")
+
+ #host500.setMAC('00:00:00:00:04:%d' % (i-101), 'host%d-eth0' %(i))
+ #add IP prefixes
+ #for j in range(0,121):
+ #host100.cmd('sudo ip addr add %s.0.40.%s/24 dev host%s-eth0' %(i,j,i))
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ #sw1 = net.get('sw1')
+ host1.setMAC('00:00:00:00:00:01', 'host1-eth0')
+ #host1.cmd('ip addr add 192.168.20.101/24 dev host1-eth0')
+ #host1.cmd('ip addr add 192.168.30.101/24 dev host1-eth0')
+ #host1.cmd('ip addr add 192.168.60.101/24 dev host1-eth0')
+
+ # Net has to be start after adding the above link
+ net.start()
+
+ # Set up as6sw as a learning switch as quickly as possible so it
+ # hopefully doesn't connect to the actual controller
+ # TODO figure out how to change controller before starting switch
+ as6sw = net.get('as6sw')
+ as6sw.cmd('ovs-vsctl set-controller as6sw none')
+ as6sw.cmd('ovs-vsctl set-fail-mode as6sw standalone')
+
+ as6sw.cmd( 'sudo ovs-vsctl set port as6sw-eth1 trunk=60')
+ as6sw.cmd( 'sudo ovs-vsctl set port as6sw-eth2 trunk=60')
+
+
+ sw1 = net.get('sw1')
+ sw1.cmd('ovs-vsctl set-controller sw1 tcp:127.0.0.1:6633')
+
+ swTestOn = net.get('swTestOn')
+ swTestOn.cmd('ovs-vsctl set-controller swTestOn none')
+ swTestOn.cmd('ovs-vsctl set-fail-mode swTestOn standalone')
+
+ #host1.defaultIntf().setIP('192.168.10.101/24')
+
+ host1.cmd( 'ifconfig host1-eth0 inet 0')
+ host1.cmd( 'vconfig add host1-eth0 10')
+ host1.cmd( 'ifconfig host1-eth0.10 inet 192.168.10.101')
+
+ host1.cmd( 'vconfig add host1-eth0 20')
+ host1.cmd( 'ifconfig host1-eth0.20 inet 192.168.20.101')
+
+ host1.cmd( 'vconfig add host1-eth0 30')
+ host1.cmd( 'ifconfig host1-eth0.30 inet 192.168.30.101')
+
+ host1.cmd( 'vconfig add host1-eth0 60')
+ host1.cmd( 'ifconfig host1-eth0.60 inet 192.168.60.101')
+
+ # Run BGPd
+ #host1.cmd('%s -d -f %s' % (BGPD, BGPD_CONF))
+ #host1.cmd('/sbin/route add default gw 192.168.10.254 dev %s-eth0' % (host1.name))
+
+ # Configure new host interfaces
+ #host2.defaultIntf().setIP('172.16.10.2/24')
+ #host2.defaultIntf().setMAC('00:00:00:00:01:02')
+ #host2.cmd('/sbin/route add default gw 172.16.10.254 dev %s-eth0' % (host2.name))
+
+ # Set up AS2
+ # add additional VLAN interface
+ host3.cmd( 'ifconfig host3-eth1 inet 0')
+ host3.cmd( 'vconfig add host3-eth1 20')
+ host3.cmd( 'ifconfig host3-eth1.20 inet 192.168.20.1')
+ # change the interface for the sencond connection to sw1 to vlan interface
+ newName = "host3-eth1.20"
+ secondIntf = host3.intf("host3-eth1")
+ secondIntf.name = newName
+ host3.nameToIntf[ newName ] = secondIntf
+
+ host3.setMAC('00:00:00:00:02:01', 'host3-eth0.10')
+ host3.setMAC('00:00:00:00:02:02', 'host3-eth1.20')
+
+ #host3.setIP('172.16.20.254', 24, 'host3-eth2')
+ host3.setIP('3.0.0.254', 8, 'host3-eth2')
+ host3.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+
+ host3.setIP('1.168.30.2', 24, 'host3-eth3')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_ignore=1')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_announce=1')
+ as2host = net.get('as2host')
+ #as2host.defaultIntf().setIP('172.16.20.1/24')
+ for i in range(0, 20):
+ as2host.cmd('sudo ip addr add 3.0.%d.1/24 dev as2host-eth0' %i)
+ as2host.setIP('1.168.30.100', 24, 'as2host-eth1')
+
+ as2host.cmd('ip route add default via 3.0.0.254')
+
+ # Set up AS3
+ host4.setMAC('00:00:00:00:03:01', 'host4-eth0.30')
+ host4.setIP('4.0.0.254', 8, 'host4-eth1')
+ host4.setMAC('00:00:00:00:03:99', 'host4-eth1')
+ host4.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ as3host = net.get('as3host')
+ for i in range(0, 20):
+ as3host.cmd('sudo ip addr add 4.0.%d.1/24 dev as3host-eth0' %i)
+ as3host.cmd('ip route add default via 4.0.0.254')
+
+ host4.setIP('10.0.0.4', 24, 'host4-eth2')
+ host4.setMAC('00:00:00:00:03:33', 'host4-eth2')
+
+ #root space
+ host4.setIP('1.168.30.3', 24, 'host4-eth3')
+ host4.setMAC('00:00:00:00:03:03', 'host4-eth3')
+
+ # Set up AS4
+ #as4host = net.get('as4host')
+ #as4host.defaultIntf().setIP('172.16.40.1/24')
+ #as4host.cmd('ip route add default via 172.16.40.254')
+
+ # setup interface address for 100 quagga hosts
+ time.sleep(10)
+ #for i in range(numHost101, numHost200 + 1):
+ #host100 = net.get('host' + str(i))
+ #host100.cmd(str(i)+'.0.1.254', 24, 'host'+str(i)+'-eth1')
+ #as4host100 = net.get('as4host%s' %(i))
+ #as4host100.defaultIntf().setIP(str(i) + '.0.0.1/24')
+ #as4host100.cmd('ip route add default via ' + str(i) + '.0.0.254')
+ #for j in range(0, 100):
+ #as4host100.cmd('sudo ip addr add %d.0.%d.1/24 dev %s-eth0' %(i, j, as4host100))
+
+ # Set up AS6 - This has a router and a route server
+ host5 = net.get('host5')
+ host5.setMAC('00:00:00:00:06:02', 'host5-eth0.60')
+ #as6router.setIP('172.16.60.254', 24, 'as6router-eth1')
+ host5.setIP('5.0.0.254', 8, 'host5-eth1')
+ host5.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ host5.setIP('10.0.0.5', 24, 'host5-eth2')
+ host5.setMAC('00:00:00:00:06:66', 'host5-eth2')
+ host5.setIP('1.168.30.5', 24, 'host5-eth3')
+ host5.setMAC('00:00:00:00:06:05', 'host5-eth3')
+
+ as6host = net.get('as6host')
+ #as6host.defaultIntf().setIP('5.0.0.1/24')
+ for i in range(0, 10):
+ as6host.cmd('sudo ip addr add 5.0.%d.1/24 dev as6host-eth0' %i)
+ as6host.cmd('ip route add default via 5.0.0.254')
+
+ # test the host in the as6
+ #for i in range(1, 10):
+ # baseip = (i-1)*4
+ # host = net.get('as6host%d' % i)
+ # host.defaultIntf().setIP('172.16.70.%d/24' % (baseip+1))
+ # host.cmd('ip route add default via 172.16.70.%d' % (baseip+2))
+ # as6router.setIP('172.16.70.%d' % (baseip+2), 30, 'as6router-eth%d' % (i+1))
+
+ # Start Quagga on border routers
+ startquagga(host3, 1, QUAGGA_CONFIG_FILE_DIR + '/quagga1.conf')
+ startquagga(host4, 2, QUAGGA_CONFIG_FILE_DIR + '/quagga2.conf')
+ #for i in range(numHost101, numHost200 + 1):
+ #host100=net.get('host%d' % (i))
+ #startquaggahost5(host100, i)
+
+ #startquagga(as6rs, 4, 'quagga-as6-rs.conf')
+ startquagga(host5, 5, QUAGGA_CONFIG_FILE_DIR + '/quagga-as6.conf')
+
+ #root1, root2, rootTestOn = net.get( 'root1', 'root2', 'rootTestOn' )
+ root1, rootTestOn = net.get( 'root1', 'rootTestOn' )
+ host1.intf('host1-eth1').setIP('1.1.1.1/24')
+ root1.intf('root1-eth0').setIP('1.1.1.2/24')
+ #host2.intf('host2-eth1').setIP('1.1.2.1/24')
+ #root2.intf('root2-eth0').setIP('1.1.2.2/24')
+
+ #rootTestOn.cmd('ip addr add 1.168.30.102/24 dev rootTestOn-eth0')
+ rootTestOn.cmd('ip addr add 1.168.30.99/24 dev rootTestOn-eth0')
+
+ stopsshd()
+
+ startquagga(host1, 100, QUAGGA_CONFIG_FILE_DIR + '/quagga-sdn-modified.conf')
+ hosts = [ host1, host3, host4, host5, as2host ];
+ #sshdHosts = sshdHosts + hosts
+ startsshds( hosts )
+ #
+ onos1 = '127.0.0.1'
+ forwarding1 = '%s:2000:%s:2000' % ('1.1.1.2', onos1)
+ root1.cmd( 'ssh -nNT -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % (forwarding1, onos1) )
+
+ # Forward 2605 to root namespace for easier access to SDN domain BGPd
+ # If root can ssh to itself without a password this should work
+ root1.cmd('ssh -N -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -L 2605:1.1.1.1:2605 1.1.1.1 &')
+ #time.sleep(3000000000)
+ CLI( net )
+
+ # Close the ssh port forwarding
+ #quietRun('sudo pkill -f 1.1.1.1')
+
+ stopsshd()
+ stopquagga()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'debug' )
+ if len(sys.argv) > 1:
+ QUAGGA_CONFIG_FILE_DIR = sys.argv[1]
+ sdn1net()
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga-as6.conf b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga-as6.conf
new file mode 100644
index 0000000..5e7028d
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga-as6.conf
@@ -0,0 +1,39 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64521
+ bgp router-id 192.168.60.2
+ neighbor 192.168.60.101 remote-as 64513
+ neighbor 10.0.0.4 remote-as 64516
+! neighbor 192.168.60.3 remote-as 64520
+! network 172.16.60.0/24
+! network 172.16.70.4/30
+ ! network 172.16.70.8/30
+ ! network 172.16.70.12/30
+ ! network 172.16.70.16/30
+ ! network 172.16.70.20/30
+ ! network 172.16.70.24/30
+ ! network 172.16.70.28/30
+ ! network 172.16.70.32/30
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga-sdn-modified.conf b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga-sdn-modified.conf
new file mode 100644
index 0000000..d334c2a
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga-sdn-modified.conf
@@ -0,0 +1,49 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+route-map AS65000 permit 1
+ set as-path prepend 65000
+!
+router bgp 64513
+ bgp router-id 192.168.10.101
+ timers bgp 1 3
+ !timers bgp 3 9
+ neighbor 192.168.10.1 remote-as 64514
+ neighbor 192.168.10.1 ebgp-multihop
+ neighbor 192.168.10.1 timers connect 5
+ neighbor 192.168.20.1 remote-as 64514
+ neighbor 192.168.20.1 ebgp-multihop
+ neighbor 192.168.20.1 timers connect 5
+ neighbor 192.168.20.1 route-map AS65000 in
+ neighbor 192.168.30.1 remote-as 64516
+ neighbor 192.168.30.1 ebgp-multihop
+ neighbor 192.168.30.1 timers connect 5
+ neighbor 192.168.60.2 remote-as 64521
+ neighbor 192.168.60.2 ebgp-multihop
+ neighbor 192.168.60.2 timers connect 5
+ neighbor 1.1.1.2 remote-as 64513
+ neighbor 1.1.1.2 port 2000
+ neighbor 1.1.1.2 timers connect 5
+
+
+
+ network 172.16.10.0/24
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga1.conf b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga1.conf
new file mode 100644
index 0000000..264f85e
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga1.conf
@@ -0,0 +1,32 @@
+!
+! Zebra configuration saved from vty
+! 2014/11/25 11:22:24
+!
+hostname bgpd
+password hello
+log stdout
+!
+router bgp 64514
+ bgp router-id 192.168.10.1
+! network 3.0.0.0/24
+! network 3.0.1.0/24
+! network 3.0.2.0/24
+! network 3.0.3.0/24
+! network 3.0.4.0/24
+! network 3.0.5.0/24
+! network 3.0.6.0/24
+! network 3.0.7.0/24
+! network 3.0.8.0/24
+! network 3.0.9.0/24
+ neighbor 192.168.20.101 remote-as 64513
+ neighbor 192.168.20.101 route-map PREPEND2 in
+ neighbor 192.168.20.101 route-map PREPEND2 out
+!
+route-map PREPEND1 permit 1
+ set as-path prepend 64514
+!
+route-map PREPEND2 permit 2
+ set as-path prepend 64514 64514
+!
+line vty
+!
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga2.conf b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga2.conf
new file mode 100644
index 0000000..14c7d67
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/quagga2.conf
@@ -0,0 +1,32 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64516
+ bgp router-id 192.168.30.1
+! timers bgp 1 3
+ neighbor 192.168.30.101 remote-as 64513
+ neighbor 10.0.0.5 remote-as 64521
+! neighbor 192.168.50.2 remote-as 65001
+! network 172.16.30.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/zebra.conf b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/zebra.conf
new file mode 100644
index 0000000..0f8e3a2
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeconvergence/mininet/zebra.conf
@@ -0,0 +1,26 @@
+! -*- zebra -*-
+!
+! zebra sample configuration file
+!
+! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
+!
+hostname zebra
+password hello
+enable password 0fw0rk
+log stdout
+!
+! Interfaces description.
+!
+!interface lo
+! description test of desc.
+!
+!interface sit0
+! multicast
+
+!
+! Static default route sample.
+!
+!ip route 0.0.0.0/0 203.181.89.241
+!
+
+!log file /usr/local/var/log/quagga/zebra.log
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeserver/addresses.json b/TestON/tests/PeeringRouterTest/vlan/routeserver/addresses.json
new file mode 100644
index 0000000..f800c1f
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeserver/addresses.json
@@ -0,0 +1,33 @@
+{
+ "addresses" : [
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "1",
+ "ips" : ["192.168.10.101/24"],
+ "mac" : "00:00:00:00:00:01",
+ "vlan" : "10"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "2",
+ "ips" : ["192.168.20.101/24"],
+ "mac" : "00:00:00:00:00:01",
+ "vlan" : "20"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "3",
+ "ips" : ["192.168.30.101/24"],
+ "mac" : "00:00:00:00:00:01",
+ "vlan" : "30"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:01",
+ "port" : "4",
+ "ips" : ["192.168.60.101/24"],
+ "mac" : "00:00:00:00:00:01",
+ "vlan" : "60"
+ }
+
+ ]
+}
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/PeeringRouteServerVlanMininet.py b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/PeeringRouteServerVlanMininet.py
new file mode 100755
index 0000000..3ba30cd
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/PeeringRouteServerVlanMininet.py
@@ -0,0 +1,389 @@
+#!/usr/bin/python
+
+"""
+Start up the SDN-IP demo topology
+"""
+
+"""
+AS1 = 64513, (SDN AS)
+AS2 = 64514, reachable by 192.168.10.1, 192.168.20.1
+AS3 = 64516, reachable by 192.168.30.1
+AS4 = 64517, reachable by 192.168.40.1
+AS6 = 64520, reachable by 192.168.60.2, (route server 192.168.60.1)
+"""
+
+from mininet.node import Host
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+
+import os.path
+import time
+import sys
+from subprocess import Popen, STDOUT, PIPE
+
+QUAGGA_DIR = '/usr/lib/quagga'
+#QUAGGA_DIR = '/usr/local/sbin'
+QUAGGA_RUN_DIR = '/usr/local/var/run/quagga'
+
+QUAGGA_CONFIG_FILE_DIR = '/home/tutorial1/ONLabTest/TestON/tests/PeeringRouterTest/mininet'
+
+class VLANHost( Host ):
+ "Host connected to VLAN interface"
+
+ def config( self, vlan=10, intf2 = '', ip2 = 0, vlan2 = 0, **params):
+ """Configure VLANHost according to (optional) parameters:
+ vlan: VLAN ID for default interface"""
+
+ r = super( VLANHost, self ).config( **params )
+
+ intf = params['inf']
+ # remove IP from default, "physical" interface
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ # create VLAN interface
+ self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
+ # assign the host's IP to the VLAN interface
+ self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+ # update the intf name and host's intf map
+ newName = '%s.%d' % ( intf, vlan )
+ # update the (Mininet) interface to refer to VLAN interface name
+ defaultIntf = self.defaultIntf()
+ defaultIntf.name = newName
+ # add VLAN interface to host's name to intf map
+ self.nameToIntf[ newName ] = defaultIntf
+
+ return r
+
+class SDNIpModifiedTopo( Topo ):
+ "SDN Ip Modified Topology"
+
+ def __init__( self, *args, **kwargs ):
+ global numHost101
+ global numHost200
+ numHost101 = 101
+ numHost200 = 200
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='0000000000000001')
+ sw2 = self.addSwitch('sw2', dpid='0000000000000002')
+ #add a switch for 3 quagga hosts
+ swTestOn = self.addSwitch('swTestOn', dpid='0000000000000102')
+ #Note this switch isn't part of the SDN topology
+ #We'll use the ovs-controller to turn this into a learning switch
+ as6sw = self.addSwitch('as6sw', dpid='00000000000000a7')
+
+ host1 = self.addHost( 'host1' )
+ root1 = self.addHost( 'root1', inNamespace=False , ip='0')
+ rootTestOn = self.addHost( 'rootTestOn', inNamespace=False, ip='0' )
+
+ #AS2 host
+ host3 = self.addHost( 'host3', cls=VLANHost, vlan=10, inf="host3-eth0", ip="192.168.10.1")
+
+ as2host = self.addHost( 'as2host' )
+ #AS3 host
+ host4 = self.addHost( 'host4', cls=VLANHost, vlan=30, inf="host4-eth0", ip="192.168.30.1" )
+ as3host = self.addHost( 'as3host' )
+ #AS6 host
+ as6rs = self.addHost( 'as6rs', cls=VLANHost, vlan=60, inf="as6rs-eth0", ip="192.168.60.1" )
+ host5 = self.addHost( 'host5', cls=VLANHost, vlan=60, inf="host5-eth0", ip="192.168.60.2" )
+ as6host = self.addHost( 'as6host' )
+
+ self.addLink( host1, sw2 )
+ #Links to the multihomed AS
+ self.addLink( host3, sw1 )
+ self.addLink( host3, sw1 )
+ self.addLink( as2host, host3 )
+ #Single links to the remaining two ASes
+ self.addLink( host4, sw1 )
+ self.addLink( as3host, host4 )
+
+ #AS3-AS4 link
+ #self.addLink( host4, host5)
+ #Add new AS6 to its bridge
+ self.addLink( as6rs, as6sw )
+ self.addLink( host5, as6sw )
+ self.addLink( as6host, host5 )
+ #Backup link from router5 to router4
+ self.addLink( host4, host5)
+ #test the host behind the router(behind the router server)
+# for i in range(1, 10):
+ # host = self.addHost('as6host%d' % i)
+ # self.addLink(host, as6router)
+
+ ## Internal Connection To Hosts ##
+ self.addLink( root1, host1 )
+
+ # self.addLink( sw1, sw2 )
+ # self.addLink( sw1, sw3 )
+ # self.addLink( sw2, sw4 )
+ # self.addLink( sw3, sw4 )
+ # self.addLink( sw3, sw5 )
+ # self.addLink( sw4, sw6 )
+ # self.addLink( sw5, sw6 )
+ self.addLink( as6sw, sw1 )
+
+
+ self.addLink(swTestOn, rootTestOn)
+ #self.addLink(swTestOn, host1)
+ self.addLink(swTestOn, host3)
+ self.addLink(swTestOn, host4)
+ self.addLink(swTestOn, host5)
+ self.addLink(swTestOn, as2host)
+ self.addLink(swTestOn, as6rs)
+
+
+ #self.addLink(rootTestOn, host4)
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def startquagga( host, num, config_file ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f %s -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, config_file, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ print zebra_cmd
+ print quagga_cmd
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+def startquaggahost5( host, num ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f %s/zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_CONFIG_FILE_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f ./as4quaggas/quagga%s.conf -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, num, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+
+def stopquagga( ):
+ quietRun( 'sudo pkill -9 -f bgpd' )
+ quietRun( 'sudo pkill -9 -f zebra' )
+
+def sdn1net():
+ topo = SDNIpModifiedTopo()
+ info( '*** Creating network\n' )
+ net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=RemoteController )
+
+ host1, host3, host4, host5 = net.get( 'host1', 'host3', 'host4', 'host5' )
+
+ #host100.setIP('1.168.30.' + str(i), 24, str(host100) + "-eth2")
+
+ #host500.setMAC('00:00:00:00:04:%d' % (i-101), 'host%d-eth0' %(i))
+ #add IP prefixes
+ #for j in range(0,121):
+ #host100.cmd('sudo ip addr add %s.0.40.%s/24 dev host%s-eth0' %(i,j,i))
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ #sw1 = net.get('sw1')
+ host1.setMAC('00:00:00:00:00:01', 'host1-eth0')
+ #host1.cmd('ip addr add 192.168.20.101/24 dev host1-eth0')
+ #host1.cmd('ip addr add 192.168.30.101/24 dev host1-eth0')
+ #host1.cmd('ip addr add 192.168.60.101/24 dev host1-eth0')
+
+ # Net has to be start after adding the above link
+ net.start()
+
+ # Set up as6sw as a learning switch as quickly as possible so it
+ # hopefully doesn't connect to the actual controller
+ # TODO figure out how to change controller before starting switch
+ as6sw = net.get('as6sw')
+ as6sw.cmd('ovs-vsctl set-controller as6sw none')
+ as6sw.cmd('ovs-vsctl set-fail-mode as6sw standalone')
+
+ as6sw.cmd( 'sudo ovs-vsctl set port as6sw-eth1 trunk=60')
+ as6sw.cmd( 'sudo ovs-vsctl set port as6sw-eth2 trunk=60')
+
+
+ sw1 = net.get('sw1')
+ sw1.cmd('ovs-vsctl set-controller sw1 tcp:127.0.0.1:6633')
+
+ swTestOn = net.get('swTestOn')
+ swTestOn.cmd('ovs-vsctl set-controller swTestOn none')
+ swTestOn.cmd('ovs-vsctl set-fail-mode swTestOn standalone')
+
+ #host1.defaultIntf().setIP('192.168.10.101/24')
+
+ host1.cmd( 'ifconfig host1-eth0 inet 0')
+ host1.cmd( 'vconfig add host1-eth0 10')
+ host1.cmd( 'ifconfig host1-eth0.10 inet 192.168.10.101')
+
+ host1.cmd( 'vconfig add host1-eth0 20')
+ host1.cmd( 'ifconfig host1-eth0.20 inet 192.168.20.101')
+
+ host1.cmd( 'vconfig add host1-eth0 30')
+ host1.cmd( 'ifconfig host1-eth0.30 inet 192.168.30.101')
+
+ host1.cmd( 'vconfig add host1-eth0 60')
+ host1.cmd( 'ifconfig host1-eth0.60 inet 192.168.60.101')
+
+ # Run BGPd
+ #host1.cmd('%s -d -f %s' % (BGPD, BGPD_CONF))
+ #host1.cmd('/sbin/route add default gw 192.168.10.254 dev %s-eth0' % (host1.name))
+
+ # Configure new host interfaces
+ #host2.defaultIntf().setIP('172.16.10.2/24')
+ #host2.defaultIntf().setMAC('00:00:00:00:01:02')
+ #host2.cmd('/sbin/route add default gw 172.16.10.254 dev %s-eth0' % (host2.name))
+
+ # Set up AS2
+ # add additional VLAN interface
+ host3.cmd( 'ifconfig host3-eth1 inet 0')
+ host3.cmd( 'vconfig add host3-eth1 20')
+ host3.cmd( 'ifconfig host3-eth1.20 inet 192.168.20.1')
+ # change the interface for the sencond connection to sw1 to vlan interface
+ newName = "host3-eth1.20"
+ secondIntf = host3.intf("host3-eth1")
+ secondIntf.name = newName
+ host3.nameToIntf[ newName ] = secondIntf
+
+ host3.setMAC('00:00:00:00:02:01', 'host3-eth0.10')
+ host3.setMAC('00:00:00:00:02:02', 'host3-eth1.20')
+
+ #host3.setIP('172.16.20.254', 24, 'host3-eth2')
+ host3.setIP('3.0.0.254', 8, 'host3-eth2')
+ host3.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+
+ host3.setIP('1.168.30.2', 24, 'host3-eth3')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_ignore=1')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_announce=1')
+ as2host = net.get('as2host')
+ #as2host.defaultIntf().setIP('172.16.20.1/24')
+ for i in range(0, 20):
+ as2host.cmd('sudo ip addr add 3.0.%d.1/24 dev as2host-eth0' %i)
+ as2host.setIP('1.168.30.100', 24, 'as2host-eth1')
+
+ as2host.cmd('ip route add default via 3.0.0.254')
+
+ # Set up AS3
+ host4.setMAC('00:00:00:00:03:01', 'host4-eth0.30')
+ host4.setIP('4.0.0.254', 8, 'host4-eth1')
+ host4.setMAC('00:00:00:00:03:99', 'host4-eth1')
+ host4.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ as3host = net.get('as3host')
+ for i in range(0, 20):
+ as3host.cmd('sudo ip addr add 4.0.%d.1/24 dev as3host-eth0' %i)
+ as3host.cmd('ip route add default via 4.0.0.254')
+
+ host4.setIP('10.0.0.4', 24, 'host4-eth2')
+ host4.setMAC('00:00:00:00:03:33', 'host4-eth2')
+
+ #root space
+ host4.setIP('1.168.30.3', 24, 'host4-eth3')
+ host4.setMAC('00:00:00:00:03:03', 'host4-eth3')
+
+ # Set up AS4
+ #as4host = net.get('as4host')
+ #as4host.defaultIntf().setIP('172.16.40.1/24')
+ #as4host.cmd('ip route add default via 172.16.40.254')
+
+ # setup interface address for 100 quagga hosts
+ time.sleep(10)
+ #for i in range(numHost101, numHost200 + 1):
+ #host100 = net.get('host' + str(i))
+ #host100.cmd(str(i)+'.0.1.254', 24, 'host'+str(i)+'-eth1')
+ #as4host100 = net.get('as4host%s' %(i))
+ #as4host100.defaultIntf().setIP(str(i) + '.0.0.1/24')
+ #as4host100.cmd('ip route add default via ' + str(i) + '.0.0.254')
+ #for j in range(0, 100):
+ #as4host100.cmd('sudo ip addr add %d.0.%d.1/24 dev %s-eth0' %(i, j, as4host100))
+
+ # Set up AS6 - This has a router and a route server
+ as6rs, host5 = net.get('as6rs', 'host5')
+
+ as6rs.setMAC('00:00:00:06:06:01', 'as6rs-eth0')
+ as6rs.setIP('1.168.30.6', 24, 'as6rs-eth1')
+ as6rs.setMAC('00:00:00:06:06:06', 'as6rs-eth1')
+
+ host5.setMAC('00:00:00:00:06:02', 'host5-eth0.60')
+ #as6router.setIP('172.16.60.254', 24, 'as6router-eth1')
+ host5.setIP('5.0.0.254', 8, 'host5-eth1')
+ host5.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ host5.setIP('10.0.0.5', 24, 'host5-eth2')
+ host5.setMAC('00:00:00:00:06:66', 'host5-eth2')
+ host5.setIP('1.168.30.5', 24, 'host5-eth3')
+ host5.setMAC('00:00:00:00:06:05', 'host5-eth3')
+
+ as6host = net.get('as6host')
+ #as6host.defaultIntf().setIP('5.0.0.1/24')
+ for i in range(0, 10):
+ as6host.cmd('sudo ip addr add 5.0.%d.1/24 dev as6host-eth0' %i)
+ as6host.cmd('ip route add default via 5.0.0.254')
+
+ # test the host in the as6
+ #for i in range(1, 10):
+ # baseip = (i-1)*4
+ # host = net.get('as6host%d' % i)
+ # host.defaultIntf().setIP('172.16.70.%d/24' % (baseip+1))
+ # host.cmd('ip route add default via 172.16.70.%d' % (baseip+2))
+ # as6router.setIP('172.16.70.%d' % (baseip+2), 30, 'as6router-eth%d' % (i+1))
+
+ # Start Quagga on border routers
+ startquagga(host3, 1, QUAGGA_CONFIG_FILE_DIR + '/quagga1.conf')
+ startquagga(host4, 2, QUAGGA_CONFIG_FILE_DIR + '/quagga2.conf')
+ #for i in range(numHost101, numHost200 + 1):
+ #host100=net.get('host%d' % (i))
+ #startquaggahost5(host100, i)
+
+ startquagga(as6rs, 4, QUAGGA_CONFIG_FILE_DIR + '/quagga-as6-rs.conf')
+ startquagga(host5, 5, QUAGGA_CONFIG_FILE_DIR + '/quagga-as6.conf')
+
+ #root1, root2, rootTestOn = net.get( 'root1', 'root2', 'rootTestOn' )
+ root1, rootTestOn = net.get( 'root1', 'rootTestOn' )
+ host1.intf('host1-eth1').setIP('1.1.1.1/24')
+ root1.intf('root1-eth0').setIP('1.1.1.2/24')
+ #host2.intf('host2-eth1').setIP('1.1.2.1/24')
+ #root2.intf('root2-eth0').setIP('1.1.2.2/24')
+
+ #rootTestOn.cmd('ip addr add 1.168.30.102/24 dev rootTestOn-eth0')
+ rootTestOn.cmd('ip addr add 1.168.30.99/24 dev rootTestOn-eth0')
+
+ stopsshd()
+
+ startquagga(host1, 100, QUAGGA_CONFIG_FILE_DIR + '/quagga-sdn-modified.conf')
+ hosts = [ host1, host3, host4, host5, as2host, as6rs ];
+ #sshdHosts = sshdHosts + hosts
+ startsshds( hosts )
+ #
+ onos1 = '127.0.0.1'
+ forwarding1 = '%s:2000:%s:2000' % ('1.1.1.2', onos1)
+ root1.cmd( 'ssh -nNT -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % (forwarding1, onos1) )
+
+ # Forward 2605 to root namespace for easier access to SDN domain BGPd
+ # If root can ssh to itself without a password this should work
+ root1.cmd('ssh -N -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -L 2605:1.1.1.1:2605 1.1.1.1 &')
+ #time.sleep(3000000000)
+ CLI( net )
+
+ # Close the ssh port forwarding
+ #quietRun('sudo pkill -f 1.1.1.1')
+
+ stopsshd()
+ stopquagga()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'debug' )
+ if len(sys.argv) > 1:
+ QUAGGA_CONFIG_FILE_DIR = sys.argv[1]
+ sdn1net()
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga-as6-rs.conf b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga-as6-rs.conf
new file mode 100644
index 0000000..1eac0dd
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga-as6-rs.conf
@@ -0,0 +1,32 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64520
+ bgp router-id 192.168.60.1
+ neighbor 192.168.60.101 remote-as 64513
+ neighbor 192.168.60.101 route-server-client
+ neighbor 192.168.60.2 remote-as 64521
+ neighbor 192.168.60.2 route-server-client
+! network 172.16.60.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga-as6.conf b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga-as6.conf
new file mode 100644
index 0000000..19cc140
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga-as6.conf
@@ -0,0 +1,39 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64521
+ bgp router-id 192.168.60.2
+ neighbor 192.168.60.1 remote-as 64520
+ neighbor 10.0.0.4 remote-as 64516
+! neighbor 192.168.60.3 remote-as 64520
+! network 172.16.60.0/24
+! network 172.16.70.4/30
+ ! network 172.16.70.8/30
+ ! network 172.16.70.12/30
+ ! network 172.16.70.16/30
+ ! network 172.16.70.20/30
+ ! network 172.16.70.24/30
+ ! network 172.16.70.28/30
+ ! network 172.16.70.32/30
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga-sdn-modified.conf b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga-sdn-modified.conf
new file mode 100644
index 0000000..bf37a60
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga-sdn-modified.conf
@@ -0,0 +1,49 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+route-map AS65000 permit 1
+ set as-path prepend 65000
+!
+router bgp 64513
+ bgp router-id 192.168.10.101
+ timers bgp 1 3
+ !timers bgp 3 9
+ neighbor 192.168.10.1 remote-as 64514
+ neighbor 192.168.10.1 ebgp-multihop
+ neighbor 192.168.10.1 timers connect 5
+ neighbor 192.168.20.1 remote-as 64514
+ neighbor 192.168.20.1 ebgp-multihop
+ neighbor 192.168.20.1 timers connect 5
+ neighbor 192.168.20.1 route-map AS65000 in
+ neighbor 192.168.30.1 remote-as 64516
+ neighbor 192.168.30.1 ebgp-multihop
+ neighbor 192.168.30.1 timers connect 5
+ neighbor 192.168.60.1 remote-as 64520
+ neighbor 192.168.60.1 ebgp-multihop
+ neighbor 192.168.60.1 timers connect 5
+ neighbor 1.1.1.2 remote-as 64513
+ neighbor 1.1.1.2 port 2000
+ neighbor 1.1.1.2 timers connect 5
+
+
+
+ network 172.16.10.0/24
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga1.conf b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga1.conf
new file mode 100644
index 0000000..264f85e
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga1.conf
@@ -0,0 +1,32 @@
+!
+! Zebra configuration saved from vty
+! 2014/11/25 11:22:24
+!
+hostname bgpd
+password hello
+log stdout
+!
+router bgp 64514
+ bgp router-id 192.168.10.1
+! network 3.0.0.0/24
+! network 3.0.1.0/24
+! network 3.0.2.0/24
+! network 3.0.3.0/24
+! network 3.0.4.0/24
+! network 3.0.5.0/24
+! network 3.0.6.0/24
+! network 3.0.7.0/24
+! network 3.0.8.0/24
+! network 3.0.9.0/24
+ neighbor 192.168.20.101 remote-as 64513
+ neighbor 192.168.20.101 route-map PREPEND2 in
+ neighbor 192.168.20.101 route-map PREPEND2 out
+!
+route-map PREPEND1 permit 1
+ set as-path prepend 64514
+!
+route-map PREPEND2 permit 2
+ set as-path prepend 64514 64514
+!
+line vty
+!
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga2.conf b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga2.conf
new file mode 100644
index 0000000..14c7d67
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/quagga2.conf
@@ -0,0 +1,32 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64516
+ bgp router-id 192.168.30.1
+! timers bgp 1 3
+ neighbor 192.168.30.101 remote-as 64513
+ neighbor 10.0.0.5 remote-as 64521
+! neighbor 192.168.50.2 remote-as 65001
+! network 172.16.30.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/zebra.conf b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/zebra.conf
new file mode 100644
index 0000000..0f8e3a2
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeserver/mininet/zebra.conf
@@ -0,0 +1,26 @@
+! -*- zebra -*-
+!
+! zebra sample configuration file
+!
+! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
+!
+hostname zebra
+password hello
+enable password 0fw0rk
+log stdout
+!
+! Interfaces description.
+!
+!interface lo
+! description test of desc.
+!
+!interface sit0
+! multicast
+
+!
+! Static default route sample.
+!
+!ip route 0.0.0.0/0 203.181.89.241
+!
+
+!log file /usr/local/var/log/quagga/zebra.log
diff --git a/TestON/tests/PeeringRouterTest/vlan/routeserver/sdnip.json b/TestON/tests/PeeringRouterTest/vlan/routeserver/sdnip.json
new file mode 100644
index 0000000..f3117c6
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/routeserver/sdnip.json
@@ -0,0 +1,59 @@
+{
+
+ "bgpPeers" : [
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "1",
+ "ipAddress" : "192.168.10.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "2",
+ "ipAddress" : "192.168.20.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "3",
+ "ipAddress" : "192.168.30.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "4",
+ "ipAddress" : "192.168.60.1"
+ }
+
+ ],
+ "bgpSpeakers" : [
+ {
+ "name" : "bgpSpeaker1",
+ "attachmentDpid" : "00:00:00:00:00:00:00:02",
+ "attachmentPort" : "1",
+ "macAddress" : "00:00:00:00:00:02",
+ "interfaceAddresses" : [
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "1",
+ "ipAddress" : "192.168.10.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "2",
+ "ipAddress" : "192.168.20.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "3",
+ "ipAddress" : "192.168.30.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "4",
+ "ipAddress" : "192.168.60.101"
+ }
+
+ ]
+
+ }
+
+ ]
+}
diff --git a/TestON/tests/PeeringRouterTest/vlan/sdnip.json b/TestON/tests/PeeringRouterTest/vlan/sdnip.json
new file mode 100644
index 0000000..5b61d05
--- /dev/null
+++ b/TestON/tests/PeeringRouterTest/vlan/sdnip.json
@@ -0,0 +1,59 @@
+{
+
+ "bgpPeers" : [
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "1",
+ "ipAddress" : "192.168.10.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "2",
+ "ipAddress" : "192.168.20.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "3",
+ "ipAddress" : "192.168.30.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:01",
+ "attachmentPort" : "4",
+ "ipAddress" : "192.168.60.2"
+ }
+
+ ],
+ "bgpSpeakers" : [
+ {
+ "name" : "bgpSpeaker1",
+ "attachmentDpid" : "00:00:00:00:00:00:00:02",
+ "attachmentPort" : "1",
+ "macAddress" : "00:00:00:00:00:02",
+ "interfaceAddresses" : [
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "1",
+ "ipAddress" : "192.168.10.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "2",
+ "ipAddress" : "192.168.20.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "3",
+ "ipAddress" : "192.168.30.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:01",
+ "interfacePort" : "4",
+ "ipAddress" : "192.168.60.101"
+ }
+
+ ]
+
+ }
+
+ ]
+}
diff --git a/TestON/tests/PingallExample/PingallExample.params b/TestON/tests/PingallExample/PingallExample.params
index aecaab6..1e4cfc1 100644
--- a/TestON/tests/PingallExample/PingallExample.params
+++ b/TestON/tests/PingallExample/PingallExample.params
@@ -1,9 +1,9 @@
<PARAMS>
<testcases>1,2,3</testcases>
<ENV>
- <cellName>HA</cellName>
+ <cellName>SingleHA</cellName>
</ENV>
- <Git>True</Git>
+ <Git>xe</Git>
<CTRL>
<ip1>10.128.30.11</ip1>
diff --git a/TestON/tests/PingallExample/PingallExample.py b/TestON/tests/PingallExample/PingallExample.py
index bb2b1cf..c03b0f1 100644
--- a/TestON/tests/PingallExample/PingallExample.py
+++ b/TestON/tests/PingallExample/PingallExample.py
@@ -95,6 +95,14 @@
main.cleanup()
main.exit()
+ # Starting the mininet using the old way
+ main.step( "Starting Mininet ..." )
+ netIsUp = main.Mininet1.startNet()
+ if netIsUp:
+ main.log.info("Mininet CLI is up")
+ else:
+ main.log.info("Mininet CLI is down")
+
def CASE2( self, main ):
"""
Assign mastership to controller
@@ -119,7 +127,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response ):
mastershipCheck = mastershipCheck and main.TRUE
@@ -135,7 +143,7 @@
def CASE3( self, main ):
"""
- Assign intents
+ Install forwarding app, Pingall and unistall the app
"""
import time
@@ -143,10 +151,11 @@
main.case( "Run Pingall" )
# install onos-app-fwd
- main.log.info( "Install reactive forwarding app" )
- main.ONOScli1.featureInstall( "onos-app-fwd" )
+ main.step( "Activate reactive forwarding app" )
+ main.ONOScli1.activateApp( "org.onosproject.fwd" )
# REACTIVE FWD test
+ main.step( "Run the pingall command in Mininet" )
pingResult = main.FALSE
time1 = time.time()
pingResult = main.Mininet1.pingall()
@@ -154,8 +163,8 @@
main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) )
# uninstall onos-app-fwd
- main.log.info( "Uninstall reactive forwarding app" )
- main.ONOScli1.featureUninstall( "onos-app-fwd" )
+ main.step( "Deactivate reactive forwarding app" )
+ main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="All hosts are reachable",
diff --git a/TestON/tests/PingallExample/PingallExample.topo b/TestON/tests/PingallExample/PingallExample.topo
index 1712756..3eda540 100644
--- a/TestON/tests/PingallExample/PingallExample.topo
+++ b/TestON/tests/PingallExample/PingallExample.topo
@@ -21,8 +21,8 @@
<ONOS1>
<host>10.128.30.11</host>
- <user>sdn</user>
- <password>rocks</password>
+ <user>admin</user>
+ <password></password>
<type>OnosDriver</type>
<connect_order>3</connect_order>
<COMPONENTS> </COMPONENTS>
diff --git a/TestON/tests/ProdFunc/ProdFunc.params b/TestON/tests/ProdFunc/ProdFunc.params
index 1189301..4367bf4 100755
--- a/TestON/tests/ProdFunc/ProdFunc.params
+++ b/TestON/tests/ProdFunc/ProdFunc.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>1,4,10,5,6,7,8,9,2,8,20,21,22,10,23,24</testcases>
+ <testcases>1,4,10,5,6,7,8,9,8,11,8,2,20,21,22,10,23,24</testcases>
#Environment variables
<ENV>
<cellName>driver_test</cellName>
@@ -38,11 +38,4 @@
<LinkDiscovery>5</LinkDiscovery>
<SwitchDiscovery>15</SwitchDiscovery>
</timers>
-
- <OPTICAL>
- <jsonfile> /home/admin/ONOS/tools/test/topos/oe-nonlinear-4.json </jsonfile>
- </OPTICAL>
-
-
-
</PARAMS>
diff --git a/TestON/tests/ProdFunc/ProdFunc.py b/TestON/tests/ProdFunc/ProdFunc.py
old mode 100755
new mode 100644
index 5e31df3..f779b6b
--- a/TestON/tests/ProdFunc/ProdFunc.py
+++ b/TestON/tests/ProdFunc/ProdFunc.py
@@ -17,6 +17,7 @@
self.default = ''
def CASE1( self, main ):
+ import time
"""
Startup sequence:
cell <name>
@@ -46,7 +47,7 @@
main.step( "Git checkout and get version" )
#main.ONOSbench.gitCheckout( "master" )
gitPullResult = main.ONOSbench.gitPull()
- main.log.info( "git_pull_result = " + gitPullResult )
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
main.ONOSbench.getVersion( report=True )
if gitPullResult == 1:
@@ -78,7 +79,14 @@
startResult = main.ONOSbench.onosStart( ONOS1Ip )
main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
-
+ main.step( "Starting Mininet CLI..." )
+
+ # Starting the mininet using the old way
+ main.step( "Starting Mininet ..." )
+ netIsUp = main.Mininet1.startNet()
+ if netIsUp:
+ main.log.info("Mininet CLI is up")
+
case1Result = ( packageResult and
cellResult and verifyResult
and onosInstallResult and
@@ -125,7 +133,7 @@
onpass="Switch down discovery successful",
onfail="Switch down discovery failed" )
- def CASE11( self, main ):
+ def CASE101( self, main ):
"""
Cleanup sequence:
onos-service <nodeIp> stop
@@ -184,6 +192,7 @@
main.case( "Disconnecting mininet and restarting ONOS" )
main.step( "Disconnecting mininet and restarting ONOS" )
mininetDisconnect = main.Mininet1.disconnect()
+ print "mininetDisconnect = ", mininetDisconnect
main.step( "Removing raft logs before a clen installation of ONOS" )
main.ONOSbench.onosRemoveRaftLogs()
@@ -222,8 +231,8 @@
def CASE21( self, main ):
"""
On ONOS bench, run this command:
- ./~/ONOS/tools/test/bin/onos-topo-cfg
- which starts the rest and copies the links
+ sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
+ which spawns packet optical topology and copies the links
json file to the onos instance.
Note that in case of Packet Optical, the links are not learnt
from the topology, instead the links are learnt
@@ -234,18 +243,10 @@
main.log.report( "_____________________________________________" )
main.case( "Starting LINC-OE and other components" )
main.step( "Starting LINC-OE and other components" )
- startConsoleResult = main.LincOE1.startConsole()
- opticalMnScript = main.LincOE2.runOpticalMnScript()
- onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
- instanceName=main.params[ 'CTRL' ][ 'ip1' ],
- jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
+ appInstallResult = main.ONOS2.featureInstall( "onos-app-optical" )
+ opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
- print "start_console_result =", startConsoleResult
- print "optical_mn_script = ", opticalMnScript
- print "onos_topo_cfg_result =", onosTopoCfgResult
-
- case21Result = startConsoleResult and opticalMnScript and \
- onosTopoCfgResult
+ case21Result = opticalMnScript and appInstallResult
utilities.assert_equals(
expect=main.TRUE,
actual=case21Result,
@@ -254,11 +255,12 @@
def CASE22( self, main ):
"""
- Curretly we use, 4 linear switch optical topology and
- 2 packet layer mininet switches each with one host.
- Therefore, the roadmCount variable = 4,
- packetLayerSWCount variable = 2 and hostCount = 2
- and this is hardcoded in the testcase. If the topology changes,
+ Curretly we use, 10 optical switches(ROADM's) and
+ 6 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 10,
+ packetLayerSWCount variable = 6, hostCount=6 and
+ links=42.
+ All this is hardcoded in the testcase. If the topology changes,
these hardcoded values need to be changed
"""
main.log.report(
@@ -271,7 +273,7 @@
print "devices_result = ", devicesResult
devicesLinewise = devicesResult.split( "\n" )
- devicesLinewise = devicesLinewise[ 1:-1 ]
+ devicesLinewise = devicesLinewise[ 1: ]
roadmCount = 0
packetLayerSWCount = 0
for line in devicesLinewise:
@@ -282,7 +284,7 @@
roadmCount += 1
elif availability == 'true' and type == 'SWITCH':
packetLayerSWCount += 1
- if roadmCount == 4:
+ if roadmCount == 10:
print "Number of Optical Switches = %d and is" % roadmCount +\
" correctly detected"
main.log.info(
@@ -298,7 +300,7 @@
" and is wrong" )
opticalSWResult = main.FALSE
- if packetLayerSWCount == 2:
+ if packetLayerSWCount == 6:
print "Number of Packet layer or mininet Switches = %d "\
% packetLayerSWCount + "and is correctly detected"
main.log.info(
@@ -319,6 +321,16 @@
linksResult = main.ONOS3.links( jsonFormat=False )
print "links_result = ", linksResult
print "_________________________________"
+ linkActiveCount = linksResult.count("state=ACTIVE")
+ main.log.info( "linkActiveCount = " + str( linkActiveCount ))
+ if linkActiveCount == 42:
+ linkActiveResult = main.TRUE
+ main.log.info(
+ "Number of links in ACTIVE state are correct")
+ else:
+ linkActiveResult = main.FALSE
+ main.log.info(
+ "Number of links in ACTIVE state are wrong")
# NOTE:Since only point intents are added, there is no
# requirement to discover the hosts
@@ -347,7 +359,8 @@
is wrong" )
hostDiscovery = main.FALSE
"""
- case22Result = opticalSWResult and packetSWResult
+ case22Result = opticalSWResult and packetSWResult and \
+ linkActiveResult
utilities.assert_equals(
expect=main.TRUE,
actual=case22Result,
@@ -368,45 +381,45 @@
main.step( "Adding point intents" )
ptpIntentResult = main.ONOS3.addPointIntent(
"of:0000ffffffff0001/1",
- "of:0000ffffffff0002/1" )
+ "of:0000ffffffff0005/1" )
if ptpIntentResult == main.TRUE:
main.ONOS3.intents( jsonFormat=False )
main.log.info( "Point to point intent install successful" )
ptpIntentResult = main.ONOS3.addPointIntent(
- "of:0000ffffffff0002/1",
+ "of:0000ffffffff0005/1",
"of:0000ffffffff0001/1" )
if ptpIntentResult == main.TRUE:
main.ONOS3.intents( jsonFormat=False )
main.log.info( "Point to point intent install successful" )
- time.sleep( 10 )
+ time.sleep( 30 )
flowHandle = main.ONOS3.flows()
main.log.info( "flows :" + flowHandle )
# Sleep for 30 seconds to provide time for the intent state to change
- time.sleep( 30 )
+ time.sleep( 60 )
intentHandle = main.ONOS3.intents( jsonFormat=False )
main.log.info( "intents :" + intentHandle )
PingResult = main.TRUE
count = 1
- main.log.info( "\n\nh1 is Pinging h2" )
- ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
# ping = main.LincOE2.pinghost()
if ping == main.FALSE and count < 5:
count += 1
PingResult = main.FALSE
main.log.info(
- "Ping between h1 and h2 failed. Making attempt number " +
+ "Ping between h1 and h5 failed. Making attempt number " +
str( count ) +
" in 2 seconds" )
time.sleep( 2 )
elif ping == main.FALSE:
- main.log.info( "All ping attempts between h1 and h2 have failed" )
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
PingResult = main.FALSE
elif ping == main.TRUE:
- main.log.info( "Ping test between h1 and h2 passed!" )
+ main.log.info( "Ping test between h1 and h5 passed!" )
PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
@@ -434,20 +447,39 @@
import time
import json
"""
+ LINC uses its own switch IDs. You can use the following
+ command on the LINC console to find the mapping between
+ DPIDs and LINC IDs.
+ rp(application:get_all_key(linc)).
+
Test Rerouting of Packet Optical by bringing a port down
- ( port 22 ) of a switch( switchID=1 ), so that link
- ( between switch1 port22 - switch4-port30 ) is inactive
+ ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
+ so that link
+ ( between switch1 port20 - switch5 port50 ) is inactive
and do a ping test. If rerouting is successful,
ping should pass. also check the flows
"""
main.log.report(
"This testcase tests rerouting and pings mininet hosts" )
main.case( "Test rerouting and pings mininet hosts" )
+ main.step( "Attach to the Linc-OE session" )
+ attachConsole = main.LincOE1.attachLincOESession()
+ print "attachConsole = ", attachConsole
+
main.step( "Bring a port down and verify the link state" )
- main.LincOE1.portDown( swId="1", ptId="22" )
+ main.LincOE1.portDown( swId="9", ptId="20" )
linksNonjson = main.ONOS3.links( jsonFormat=False )
main.log.info( "links = " + linksNonjson )
+ linkInactiveCount = linksNonjson.count("state=INACTIVE")
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 2:
+ main.log.info(
+ "Number of links in INACTIVE state are correct")
+ else:
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+
links = main.ONOS3.links()
main.log.info( "links = " + links )
@@ -455,9 +487,9 @@
linksStateResult = main.FALSE
for item in linksResult:
if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
- 'src' ][ 'port' ] == "22":
- if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
- 'dst' ][ 'port' ] == "30":
+ 'src' ][ 'port' ] == "20":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
+ 'dst' ][ 'port' ] == "50":
linksState = item[ 'state' ]
if linksState == "INACTIVE":
main.log.info(
@@ -483,22 +515,22 @@
main.step( "Verify Rerouting by a ping test" )
PingResult = main.TRUE
count = 1
- main.log.info( "\n\nh1 is Pinging h2" )
- ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
# ping = main.LincOE2.pinghost()
if ping == main.FALSE and count < 5:
count += 1
PingResult = main.FALSE
main.log.info(
- "Ping between h1 and h2 failed. Making attempt number " +
+ "Ping between h1 and h5 failed. Making attempt number " +
str( count ) +
" in 2 seconds" )
time.sleep( 2 )
elif ping == main.FALSE:
- main.log.info( "All ping attempts between h1 and h2 have failed" )
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
PingResult = main.FALSE
elif ping == main.TRUE:
- main.log.info( "Ping test between h1 and h2 passed!" )
+ main.log.info( "Ping test between h1 and h5 passed!" )
PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
@@ -519,7 +551,7 @@
import time
main.log.report( "This testcase is testing the assignment of" +
" all the switches to all the controllers and" +
- " discovering the hists in reactive mode" )
+ " discovering the hosts in reactive mode" )
main.log.report( "__________________________________" )
main.case( "Pingall Test" )
main.step( "Assigning switches to controllers" )
@@ -631,11 +663,10 @@
main.step( "Pingall" )
pingResult = main.FALSE
- while pingResult == main.FALSE:
- time1 = time.time()
- pingResult = main.Mininet1.pingall()
- time2 = time.time()
- print "Time for pingall: %2f seconds" % ( time2 - time1 )
+ time1 = time.time()
+ pingResult = 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
@@ -680,7 +711,110 @@
onpass="Reactive forwarding app uninstallation successful",
onfail="Reactive forwarding app uninstallation failed" )
+
+ def CASE11( self ):
+ # NOTE: This testcase require reactive forwarding mode enabled
+ # NOTE: in the beginning and then uninstall it before adding
+ # NOTE: point intents. Again the app is installed so that
+ # NOTE: testcase 10 can be ran successively
+ import time
+ main.log.report(
+ "This testcase moves a host from one switch to another to add" +
+ "point intents between them and then perform ping" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Moving host from one switch to another" )
+ main.case( "Moving host from a device and attach it to another device" )
+ main.step( "Moving host h9 from device s9 and attach it to s8" )
+ main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
+
+ time.sleep(15) #Time delay to have all the flows ready
+ main.step( "Pingall" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ time2 = time.time()
+ print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
+ hosts = main.ONOS2.hosts( jsonFormat = False )
+ main.log.info( hosts )
+
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd uninstalled" )
+
+ main.step( "Add point intents between hosts on the same device")
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003008/1",
+ "of:0000000000003008/3" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003008/3",
+ "of:0000000000003008/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ main.case( "Ping hosts on the same devices" )
+ ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
+
+ '''
+ main.case( "Installing reactive forwarding app" )
+ # Install onos-app-fwd app to enable reactive forwarding
+ appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd installed" )
+ '''
+
+ if ping == main.FALSE:
+ main.log.report(
+ "Point intents for hosts on same devices haven't" +
+ " been installed correctly. Cleaning up" )
+ if ping == main.TRUE:
+ main.log.report(
+ "Point intents for hosts on same devices" +
+ "installed correctly. Cleaning up" )
+
+ case11Result = ping and pingResult
+ utilities.assert_equals(
+ expect = main.TRUE,
+ actual = case11Result,
+ onpass = "Point intents for hosts on same devices" +
+ "Ping Test successful",
+ onfail = "Point intents for hosts on same devices" +
+ "Ping Test NOT successful" )
+
+
+ def CASE12( self ):
+ """
+ Verify the default flows on each switch in proactive mode
+ """
+ main.log.report( "This testcase is verifying num of default" +
+ " flows on each switch" )
+ main.log.report( "__________________________________" )
+ main.case( "Verify num of default flows on each switch" )
+ main.step( "Obtaining the device id's and flowrule count on them" )
+
+ case12Result = main.TRUE
+ idList = main.ONOS2.getAllDevicesId()
+ for id in idList:
+ count = main.ONOS2.FlowAddedCount( id )
+ main.log.info("count = " +count)
+ if int(count) != 3:
+ case12Result = main.FALSE
+ break
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case12Result,
+ onpass = "Expected default num of flows exist",
+ onfail = "Expected default num of flows do not exist")
+
def CASE6( self ):
+ import time
main.log.report( "This testcase is testing the addition of" +
" host intents and then does pingall" )
main.log.report( "__________________________________" )
@@ -730,15 +864,18 @@
host2 = "00:00:00:00:00:" + \
str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
# NOTE: get host can return None
- # TODO: handle this
- host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
- host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
- main.ONOS2.addHostIntent( host1Id, host2Id )
+ if host1:
+ host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
+ if host2:
+ host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
+ if host1Id and host2Id:
+ main.ONOS2.addHostIntent( host1Id, host2Id )
time.sleep( 10 )
hIntents = main.ONOS2.intents( jsonFormat=False )
main.log.info( "intents:" + hIntents )
- main.ONOS2.flows()
+ flows = main.ONOS2.flows()
+ main.log.info( "flows:" + flows )
count = 1
i = 8
@@ -800,6 +937,9 @@
onfail="Pingall Test after Host intents addition failed" )
def CASE5( self, main ):
+ """
+ Check ONOS topology matches with mininet
+ """
import json
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
@@ -912,6 +1052,11 @@
onfail="Topology checks failed" )
def CASE7( self, main ):
+ """
+ Link discovery test case. Checks if ONOS can discover a link
+ down or up properly.
+ """
+
from sts.topology.teston_topology import TestONTopology
linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
@@ -960,8 +1105,8 @@
main.step( "Determine the current number of switches and links" )
topologyOutput = main.ONOS2.topology()
topologyResult = main.ONOS1.getTopology( topologyOutput )
- activeSwitches = topologyResult[ 'devices' ]
- links = topologyResult[ 'links' ]
+ activeSwitches = topologyResult[ 'deviceCount' ]
+ links = topologyResult[ 'linkCount' ]
print "activeSwitches = ", type( activeSwitches )
print "links = ", type( links )
main.log.info(
@@ -1055,26 +1200,23 @@
def CASE8( self ):
"""
- Host intents removal
+ Intent removal
"""
+ import time
main.log.report( "This testcase removes any previously added intents" +
- " before adding the same intents or point intents" )
+ " before adding any new set of intents" )
main.log.report( "__________________________________" )
- main.log.info( "Host intents removal" )
- main.case( "Removing host intents" )
+ main.log.info( "intent removal" )
+ main.case( "Removing installed intents" )
main.step( "Obtain the intent id's" )
intentResult = main.ONOS2.intents( jsonFormat=False )
main.log.info( "intent_result = " + intentResult )
-
intentLinewise = intentResult.split( "\n" )
- intentList = []
- for line in intentLinewise:
- if line.startswith( "id=" ):
- intentList.append( line )
- intentids = []
- for line in intentList:
- intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
+ intentList = [line for line in intentLinewise \
+ if line.startswith( "id=")]
+ intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
+ intentList]
for id in intentids:
print "id = ", id
@@ -1085,8 +1227,20 @@
intentResult = main.ONOS2.intents( jsonFormat=False )
main.log.info( "intent_result = " + intentResult )
-
- case8Result = main.TRUE
+
+ intentList = [line for line in intentResult.split( "\n" ) \
+ if line.startswith( "id=")]
+ intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
+ intentList]
+ for state in intentState:
+ print state
+
+ case8Result = main.TRUE
+ for state in intentState:
+ if state != 'WITHDRAWN':
+ case8Result = main.FALSE
+ break
+
if case8Result == main.TRUE:
main.log.report( "Intent removal successful" )
else:
@@ -1113,11 +1267,11 @@
# Note: If the ping result failed, that means the intents have been
# withdrawn correctly.
if PingResult == main.TRUE:
- main.log.report( "Host intents have not been withdrawn correctly" )
+ main.log.report( "Installed intents have not been withdrawn correctly" )
# main.cleanup()
# main.exit()
if PingResult == main.FALSE:
- main.log.report( "Host intents have been withdrawn correctly" )
+ main.log.report( "Installed intents have been withdrawn correctly" )
case8Result = case8Result and PingResult
@@ -1131,8 +1285,11 @@
onfail="Intent removal test failed" )
def CASE9( self ):
+ """
+ Testing Point intents
+ """
main.log.report(
- "This testcase adds point intents and then does pingall" )
+ "This test case adds point intents and then does pingall" )
main.log.report( "__________________________________" )
main.log.info( "Adding point intents" )
main.case(
@@ -1318,7 +1475,7 @@
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- main.log.info( getIntentResult )
+ #main.log.info( getIntentResult )
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006027/1",
@@ -1326,14 +1483,13 @@
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- main.log.info( getIntentResult )
+ #main.log.info( getIntentResult )
print(
"___________________________________________________________" )
flowHandle = main.ONOS2.flows()
- # print "flowHandle = ", flowHandle
- main.log.info( "flows :" + flowHandle )
+ #main.log.info( "flows :" + flowHandle )
count = 1
i = 8
diff --git a/TestON/tests/ProdFunc/ProdFunc.py.fixed b/TestON/tests/ProdFunc/ProdFunc.py.fixed
deleted file mode 100644
index 6f4b72b..0000000
--- a/TestON/tests/ProdFunc/ProdFunc.py.fixed
+++ /dev/null
@@ -1,1395 +0,0 @@
-
-# Testing the basic functionality of ONOS Next
-# For sanity and driver functionality excercises only.
-
-import time
-# import sys
-# import os
-# import re
-import json
-
-time.sleep( 1 )
-
-
-class ProdFunc:
-
- def __init__( self ):
- self.default = ''
-
- def CASE1( self, main ):
- """
- Startup sequence:
- cell <name>
- onos-verify-cell
- onos-remove-raft-log
- git pull
- mvn clean install
- onos-package
- onos-install -f
- onos-wait-for-start
- """
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
-
- main.case( "Setting up test environment" )
- main.log.report(
- "This testcase is testing setting up test environment" )
- main.log.report( "__________________________________" )
-
- main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- verifyResult = main.ONOSbench.verifyCell()
-
- main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onosRemoveRaftLogs()
-
- main.step( "Git checkout and pull master and get version" )
- main.ONOSbench.gitCheckout( "master" )
- gitPullResult = main.ONOSbench.gitPull()
- main.log.info( "git_pull_result = " + gitPullResult )
- main.ONOSbench.getVersion( report=True )
-
- if gitPullResult == 1:
- main.step( "Using mvn clean & install" )
- main.ONOSbench.cleanInstall()
- elif gitPullResult == 0:
- main.log.report(
- "Git Pull Failed, look into logs for detailed reason" )
- main.cleanup()
- main.exit()
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.onosPackage()
-
- main.step( "Installing ONOS package" )
- onosInstallResult = main.ONOSbench.onosInstall()
- if onosInstallResult == main.TRUE:
- main.log.report( "Installing ONOS package successful" )
- else:
- main.log.report( "Installing ONOS package failed" )
-
- onos1Isup = main.ONOSbench.isup()
- if onos1Isup == main.TRUE:
- main.log.report( "ONOS instance is up and ready" )
- else:
- main.log.report( "ONOS instance may not be up" )
-
- main.step( "Starting ONOS service" )
- startResult = main.ONOSbench.onosStart( ONOS1Ip )
-
- main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
-
- case1Result = ( packageResult and
- cellResult and verifyResult
- and onosInstallResult and
- onos1Isup and startResult )
- utilities.assert_equals( expect=main.TRUE, actual=case1Result,
- onpass="Test startup successful",
- onfail="Test startup NOT successful" )
-
- def CASE2( self, main ):
- """
- Switch Down
- """
- # NOTE: You should probably run a topology check after this
- import time
-
- main.case( "Switch down discovery" )
- main.log.report( "This testcase is testing a switch down discovery" )
- main.log.report( "__________________________________" )
-
- switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
-
- description = "Killing a switch to ensure it is discovered correctly"
- main.log.report( description )
- main.case( description )
-
- # TODO: Make this switch parameterizable
- main.step( "Kill s28 " )
- main.log.report( "Deleting s28" )
- # FIXME: use new dynamic topo functions
- main.Mininet1.delSwitch( "s28" )
- main.log.info(
- "Waiting " +
- str( switchSleep ) +
- " seconds for switch down to be discovered" )
- time.sleep( switchSleep )
- # Peek at the deleted switch
- device = main.ONOS2.getDevice( dpid="0028" )
- print "device = ", device
- if device[ u'available' ] == 'False':
- case2Result = main.FALSE
- else:
- case2Result = main.TRUE
- utilities.assert_equals( expect=main.TRUE, actual=case2Result,
- onpass="Switch down discovery successful",
- onfail="Switch down discovery failed" )
-
- def CASE11( self, main ):
- """
- Cleanup sequence:
- onos-service <nodeIp> stop
- onos-uninstall
-
- TODO: Define rest of cleanup
-
- """
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
-
- main.case( "Cleaning up test environment" )
-
- main.step( "Testing ONOS kill function" )
- killResult = main.ONOSbench.onosKill( ONOS1Ip )
-
- main.step( "Stopping ONOS service" )
- stopResult = main.ONOSbench.onosStop( ONOS1Ip )
-
- main.step( "Uninstalling ONOS service" )
- uninstallResult = main.ONOSbench.onosUninstall()
-
- case11Result = killResult and stopResult and uninstallResult
- utilities.assert_equals( expect=main.TRUE, actual=case11Result,
- onpass="Cleanup successful",
- onfail="Cleanup failed" )
-
- def CASE3( self, main ):
- """
- Test 'onos' command and its functionality in driver
- """
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
-
- main.case( "Testing 'onos' command" )
-
- main.step( "Sending command 'onos -w <onos-ip> system:name'" )
- cmdstr1 = "system:name"
- cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
- main.log.info( "onos command returned: " + cmdResult1 )
-
- main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
- cmdstr2 = "onos:topology"
- cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
- main.log.info( "onos command returned: " + cmdResult2 )
-
- def CASE20( self ):
- """
- Exit from mininet cli
- reinstall ONOS
- """
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
-
- main.log.report( "This testcase exits the mininet cli and reinstalls\
- ONOS to switch over to Packet Optical topology" )
- main.log.report( "_____________________________________________" )
- main.case( "Disconnecting mininet and restarting ONOS" )
- main.step( "Disconnecting mininet and restarting ONOS" )
- mininetDisconnect = main.Mininet1.disconnect()
-
- main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onosRemoveRaftLogs()
-
- main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- verifyResult = main.ONOSbench.verifyCell()
-
- onosInstallResult = main.ONOSbench.onosInstall()
- if onosInstallResult == main.TRUE:
- main.log.report( "Installing ONOS package successful" )
- else:
- main.log.report( "Installing ONOS package failed" )
-
- onos1Isup = main.ONOSbench.isup()
- if onos1Isup == main.TRUE:
- main.log.report( "ONOS instance is up and ready" )
- else:
- main.log.report( "ONOS instance may not be up" )
-
- main.step( "Starting ONOS service" )
- startResult = main.ONOSbench.onosStart( ONOS1Ip )
-
- main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- case20Result = mininetDisconnect and cellResult and verifyResult \
- and onosInstallResult and onos1Isup and \
- startResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case20Result,
- onpass="Exiting functionality mininet topology and reinstalling \
- ONOS successful",
- onfail="Exiting functionality mininet topology and reinstalling \
- ONOS failed" )
-
- def CASE21( self, main ):
- """
- On ONOS bench, run this command:
- ./~/ONOS/tools/test/bin/onos-topo-cfg
- which starts the rest and copies the links
- json file to the onos instance.
- Note that in case of Packet Optical, the links are not learnt
- from the topology, instead the links are learnt
- from the json config file
- """
- main.log.report(
- "This testcase starts the packet layer topology and REST" )
- main.log.report( "_____________________________________________" )
- main.case( "Starting LINC-OE and other components" )
- main.step( "Starting LINC-OE and other components" )
- startConsoleResult = main.LincOE1.startConsole()
- opticalMnScript = main.LincOE2.runOpticalMnScript()
- onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
- instanceName=main.params[ 'CTRL' ][ 'ip1' ],
- jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
-
- print "start_console_result =", startConsoleResult
- print "optical_mn_script = ", opticalMnScript
- print "onos_topo_cfg_result =", onosTopoCfgResult
-
- case21Result = startConsoleResult and opticalMnScript and \
- onosTopoCfgResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case21Result,
- onpass="Packet optical topology spawned successsfully",
- onfail="Packet optical topology spawning failed" )
-
- def CASE22( self, main ):
- """
- Curretly we use, 4 linear switch optical topology and
- 2 packet layer mininet switches each with one host.
- Therefore, the roadmCount variable = 4,
- packetLayerSWCount variable = 2 and hostCount = 2
- and this is hardcoded in the testcase. If the topology changes,
- these hardcoded values need to be changed
- """
- main.log.report(
- "This testcase compares the optical+packet topology against what\
- is expected" )
- main.case( "Topology comparision" )
- main.step( "Topology comparision" )
- main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- devicesResult = main.ONOS3.devices( jsonFormat=False )
-
- print "devices_result = ", devicesResult
- devicesLinewise = devicesResult.split( "\n" )
- devicesLinewise = devicesLinewise[ 1:-1 ]
- roadmCount = 0
- packetLayerSWCount = 0
- for line in devicesLinewise:
- components = line.split( "," )
- availability = components[ 1 ].split( "=" )[ 1 ]
- type = components[ 3 ].split( "=" )[ 1 ]
- if availability == 'true' and type == 'ROADM':
- roadmCount += 1
- elif availability == 'true' and type == 'SWITCH':
- packetLayerSWCount += 1
- if roadmCount == 4:
- print "Number of Optical Switches = %d and is \
- correctly detected" % roadmCount
- main.log.info(
- "Number of Optical Switches = " +
- str( roadmCount ) +
- " and is correctly detected" )
- opticalSWResult = main.TRUE
- else:
- print "Number of Optical Switches = %d and is wrong" % roadmCount
- main.log.info(
- "Number of Optical Switches = " +
- str( roadmCount ) +
- " and is wrong" )
- opticalSWResult = main.FALSE
-
- if packetLayerSWCount == 2:
- print "Number of Packet layer or mininet Switches = %d and \
- is correctly detected" % packetLayerSWCount
- main.log.info(
- "Number of Packet layer or mininet Switches = " +
- str( packetLayerSWCount ) +
- " and is correctly detected" )
- packetSWResult = main.TRUE
- else:
- print "Number of Packet layer or mininet Switches = %d and \
- is wrong" % packetLayerSWCount
- main.log.info(
- "Number of Packet layer or mininet Switches = " +
- str( packetLayerSWCount ) +
- " and is wrong" )
- packetSWResult = main.FALSE
- print "_________________________________"
-
- linksResult = main.ONOS3.links( jsonFormat=False )
- print "links_result = ", linksResult
- print "_________________________________"
-
- # NOTE:Since only point intents are added, there is no
- # requirement to discover the hosts
- # Therfore, the below portion of the code is commented.
- """
- #Discover hosts using pingall
- pingallResult = main.LincOE2.pingall()
-
- hostsResult = main.ONOS3.hosts( jsonFormat=False )
- main.log.info( "hosts_result = "+hostsResult )
- main.log.info( "_________________________________" )
- hostsLinewise = hostsResult.split( "\n" )
- hostsLinewise = hostsLinewise[ 1:-1 ]
- hostCount = 0
- for line in hostsLinewise:
- hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
- hostCount +=1
- if hostCount ==2:
- print "Number of hosts = %d and is correctly detected" %hostCount
- main.log.info( "Number of hosts = " + str( hostCount ) +" and \
- is correctly detected" )
- hostDiscovery = main.TRUE
- else:
- print "Number of hosts = %d and is wrong" %hostCount
- main.log.info( "Number of hosts = " + str( hostCount ) +" and \
- is wrong" )
- hostDiscovery = main.FALSE
- """
- case22Result = opticalSWResult and packetSWResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case22Result,
- onpass="Packet optical topology discovery successful",
- onfail="Packet optical topology discovery failed" )
-
- def CASE23( self, main ):
- import time
- """
- Add bidirectional point intents between 2 packet layer( mininet )
- devices and
- ping mininet hosts
- """
- main.log.report(
- "This testcase adds bidirectional point intents between 2 \
- packet layer( mininet ) devices and ping mininet hosts" )
- main.case( "Topology comparision" )
- main.step( "Adding point intents" )
- ptpIntentResult = main.ONOS3.addPointIntent(
- "of:0000ffffffff0001/1",
- "of:0000ffffffff0002/1" )
- if ptpIntentResult == main.TRUE:
- main.ONOS3.intents( jsonFormat=False )
- main.log.info( "Point to point intent install successful" )
-
- ptpIntentResult = main.ONOS3.addPointIntent(
- "of:0000ffffffff0002/1",
- "of:0000ffffffff0001/1" )
- if ptpIntentResult == main.TRUE:
- main.ONOS3.intents( jsonFormat=False )
- main.log.info( "Point to point intent install successful" )
-
- time.sleep( 10 )
- flowHandle = main.ONOS3.flows()
- main.log.info( "flows :" + flowHandle )
-
- # Sleep for 30 seconds to provide time for the intent state to change
- time.sleep( 30 )
- intentHandle = main.ONOS3.intents( jsonFormat=False )
- main.log.info( "intents :" + intentHandle )
-
- PingResult = main.TRUE
- count = 1
- main.log.info( "\n\nh1 is Pinging h2" )
- ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
- # ping = main.LincOE2.pinghost()
- if ping == main.FALSE and count < 5:
- count += 1
- PingResult = main.FALSE
- main.log.info(
- "Ping between h1 and h2 failed. Making attempt number " +
- str( count ) +
- " in 2 seconds" )
- time.sleep( 2 )
- elif ping == main.FALSE:
- main.log.info( "All ping attempts between h1 and h2 have failed" )
- PingResult = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h1 and h2 passed!" )
- PingResult = main.TRUE
- else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
-
- if PingResult == main.FALSE:
- main.log.report(
- "Point intents for packet optical have not ben installed\
- correctly. Cleaning up" )
- if PingResult == main.TRUE:
- main.log.report(
- "Point Intents for packet optical have been\
- installed correctly" )
-
- case23Result = PingResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case23Result,
- onpass="Point intents addition for packet optical and\
- Pingall Test successful",
- onfail="Point intents addition for packet optical and\
- Pingall Test NOT successful" )
-
- def CASE24( self, main ):
- import time
- import json
- """
- Test Rerouting of Packet Optical by bringing a port down
- ( port 22 ) of a switch( switchID=1 ), so that link
- ( between switch1 port22 - switch4-port30 ) is inactive
- and do a ping test. If rerouting is successful,
- ping should pass. also check the flows
- """
- main.log.report(
- "This testcase tests rerouting and pings mininet hosts" )
- main.case( "Test rerouting and pings mininet hosts" )
- main.step( "Bring a port down and verify the link state" )
- main.LincOE1.portDown( swId="1", ptId="22" )
- linksNonjson = main.ONOS3.links( jsonFormat=False )
- main.log.info( "links = " + linksNonjson )
-
- links = main.ONOS3.links()
- main.log.info( "links = " + links )
-
- linksResult = json.loads( links )
- linksStateResult = main.FALSE
- for item in linksResult:
- if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
- 'src' ][ 'port' ] == "22":
- if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
- 'dst' ][ 'port' ] == "30":
- linksState = item[ 'state' ]
- if linksState == "INACTIVE":
- main.log.info(
- "Links state is inactive as expected due to one \
- of the ports being down" )
- main.log.report(
- "Links state is inactive as expected due to one \
- of the ports being down" )
- linksStateResult = main.TRUE
- break
- else:
- main.log.info(
- "Links state is not inactive as expected" )
- main.log.report(
- "Links state is not inactive as expected" )
- linksStateResult = main.FALSE
-
- print "links_state_result = ", linksStateResult
- time.sleep( 10 )
- flowHandle = main.ONOS3.flows()
- main.log.info( "flows :" + flowHandle )
-
- main.step( "Verify Rerouting by a ping test" )
- PingResult = main.TRUE
- count = 1
- main.log.info( "\n\nh1 is Pinging h2" )
- ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
- # ping = main.LincOE2.pinghost()
- if ping == main.FALSE and count < 5:
- count += 1
- PingResult = main.FALSE
- main.log.info(
- "Ping between h1 and h2 failed. Making attempt number " +
- str( count ) +
- " in 2 seconds" )
- time.sleep( 2 )
- elif ping == main.FALSE:
- main.log.info( "All ping attempts between h1 and h2 have failed" )
- PingResult = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h1 and h2 passed!" )
- PingResult = main.TRUE
- else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
-
- if PingResult == main.TRUE:
- main.log.report( "Ping test successful " )
- if PingResult == main.FALSE:
- main.log.report( "Ping test failed" )
-
- case24Result = PingResult and linksStateResult
- utilities.assert_equals( expect=main.TRUE, actual=case24Result,
- onpass="Packet optical rerouting successful",
- onfail="Packet optical rerouting failed" )
-
- def CASE4( self, main ):
- import re
- import time
- main.log.report( "This testcase is testing the assignment of \
- all the switches to all the controllers and \
- discovering the hists in reactive mode" )
- main.log.report( "__________________________________" )
- main.case( "Pingall Test" )
- main.step( "Assigning switches to controllers" )
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
- for i in range( 1, 29 ):
- if i == 1:
- main.Mininet1.assignSwController(
- sw=str( i ),
- ip1=ONOS1Ip,
- port1=ONOS1Port )
- elif i >= 2 and i < 5:
- main.Mininet1.assignSwController(
- sw=str( i ),
- ip1=ONOS1Ip,
- port1=ONOS1Port )
- elif i >= 5 and i < 8:
- main.Mininet1.assignSwController(
- sw=str( i ),
- ip1=ONOS1Ip,
- port1=ONOS1Port )
- elif i >= 8 and i < 18:
- main.Mininet1.assignSwController(
- sw=str( i ),
- ip1=ONOS1Ip,
- port1=ONOS1Port )
- elif i >= 18 and i < 28:
- main.Mininet1.assignSwController(
- sw=str( i ),
- ip1=ONOS1Ip,
- port1=ONOS1Port )
- else:
- main.Mininet1.assignSwController(
- sw=str( i ),
- ip1=ONOS1Ip,
- port1=ONOS1Port )
- SwitchMastership = main.TRUE
- for i in range( 1, 29 ):
- if i == 1:
- response = main.Mininet1.getSwController( "s" + str( i ) )
- print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1Ip, response ):
- SwitchMastership = SwitchMastership and main.TRUE
- else:
- SwitchMastership = main.FALSE
- elif i >= 2 and i < 5:
- response = main.Mininet1.getSwController( "s" + str( i ) )
- print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1Ip, response ):
- SwitchMastership = SwitchMastership and main.TRUE
- else:
- SwitchMastership = main.FALSE
- elif i >= 5 and i < 8:
- response = main.Mininet1.getSwController( "s" + str( i ) )
- print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1Ip, response ):
- SwitchMastership = SwitchMastership and main.TRUE
- else:
- SwitchMastership = main.FALSE
- elif i >= 8 and i < 18:
- response = main.Mininet1.getSwController( "s" + str( i ) )
- print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1Ip, response ):
- SwitchMastership = SwitchMastership and main.TRUE
- else:
- SwitchMastership = main.FALSE
- elif i >= 18 and i < 28:
- response = main.Mininet1.getSwController( "s" + str( i ) )
- print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1Ip, response ):
- SwitchMastership = SwitchMastership and main.TRUE
- else:
- SwitchMastership = main.FALSE
- else:
- response = main.Mininet1.getSwController( "s" + str( i ) )
- print( "Response is" + str( response ) )
- if re.search( "tcp:" + ONOS1Ip, response ):
- SwitchMastership = SwitchMastership and main.TRUE
- else:
- SwitchMastership = main.FALSE
-
- if SwitchMastership == main.TRUE:
- main.log.report( "Controller assignmnet successful" )
- else:
- main.log.report( "Controller assignmnet failed" )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=SwitchMastership,
- onpass="MasterControllers assigned correctly" )
- """
- for i in range ( 1,29 ):
- main.Mininet1.assignSwController( sw=str( i ),count=5,
- ip1=ONOS1Ip,port1=ONOS1Port,
- ip2=ONOS2Ip,port2=ONOS2Port,
- ip3=ONOS3Ip,port3=ONOS3Port,
- ip4=ONOS4Ip,port4=ONOS4Port,
- ip5=ONOS5Ip,port5=ONOS5Port )
- """
- # REACTIVE FWD test
-
- main.step( "Get list of hosts from Mininet" )
- hostList = main.Mininet1.getHosts()
- main.log.info( hostList )
-
- main.step( "Get host list in ONOS format" )
- hostOnosList = main.ONOS2.getHostsId( hostList )
- main.log.info( hostOnosList )
- # time.sleep( 5 )
-
- main.step( "Pingall" )
- pingResult = main.FALSE
- while pingResult == main.FALSE:
- time1 = time.time()
- pingResult = 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.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
-
- case4Result = SwitchMastership and pingResult
- if pingResult == main.TRUE:
- main.log.report( "Pingall Test in reactive mode to \
- discover the hosts successful" )
- else:
- main.log.report( "Pingall Test in reactive mode to \
- discover the hosts failed" )
-
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case4Result,
- onpass="Controller assignment and Pingall Test successful",
- onfail="Controller assignment and Pingall Test NOT successful" )
-
- def CASE10( self ):
- main.log.report(
- "This testcase uninstalls the reactive forwarding app" )
- main.log.report( "__________________________________" )
- main.case( "Uninstalling reactive forwarding app" )
- # Unistall onos-app-fwd app to disable reactive forwarding
- appUninstallResult = main.ONOS2.featureUninstall( "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 )
-
- flows = main.ONOS2.flows()
- main.log.info( flows )
-
- case10Result = appUninstallResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case10Result,
- onpass="Reactive forwarding app uninstallation successful",
- onfail="Reactive forwarding app uninstallation failed" )
-
- def CASE6( self ):
- main.log.report( "This testcase is testing the addition of \
- host intents and then does pingall" )
- main.log.report( "__________________________________" )
- main.case( "Obtaining host id's" )
- main.step( "Get hosts" )
- hosts = main.ONOS2.hosts()
- main.log.info( hosts )
-
- main.step( "Get all devices id" )
- devicesIdList = main.ONOS2.getAllDevicesId()
- main.log.info( devicesIdList )
-
- # 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" )
- hthIntentResult = main.ONOS2.addHostIntent(
- "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
- hthIntentResult = main.ONOS2.addHostIntent(
- "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
- hthIntentResult = main.ONOS2.addHostIntent(
- "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
- hthIntentResult = main.ONOS2.addHostIntent(
- "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
- hthIntentResult = main.ONOS2.addHostIntent(
- "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
- hthIntentResult = main.ONOS2.addHostIntent(
- "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
- hthIntentResult = main.ONOS2.addHostIntent(
- "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
- hthIntentResult = main.ONOS2.addHostIntent(
- "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
- hthIntentResult = main.ONOS2.addHostIntent(
- "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
- hthIntentResult = main.ONOS2.addHostIntent(
- "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
- print "______________________________________________________"
- """
- for i in range( 8, 18 ):
- main.log.info(
- "Adding host intent between h" + str( i ) +
- " and h" + str( i + 10 ) )
- host1 = "00:00:00:00:00:" + \
- str( hex( i )[ 2: ] ).zfill( 2 ).upper()
- host2 = "00:00:00:00:00:" + \
- str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
- # NOTE: get host can return None
- # TODO: handle this
- host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
- host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
- main.ONOS2.addHostIntent( host1Id, host2Id )
-
- time.sleep( 10 )
- hIntents = main.ONOS2.intents( jsonFormat=False )
- main.log.info( "intents:" + hIntents )
- main.ONOS2.flows()
-
- count = 1
- i = 8
- PingResult = 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
- PingResult = 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 between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "have failed" )
- i = 19
- PingResult = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "passed!" )
- i += 1
- PingResult = main.TRUE
- else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
- if PingResult == main.FALSE:
- main.log.report(
- "Ping all test after Host intent addition failed. Cleaning up" )
- # main.cleanup()
- # main.exit()
- if PingResult == main.TRUE:
- main.log.report(
- "Ping all test after Host intent addition successful" )
-
- case6Result = PingResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case6Result,
- onpass="Pingall Test after Host intents addition successful",
- onfail="Pingall Test after Host intents addition failed" )
-
- def CASE5( self, main ):
- import json
- # assumes that sts is already in you PYTHONPATH
- from sts.topology.testonTopology import TestONTopology
- # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- main.log.report( "This testcase is testing if all ONOS nodes \
- are in topology sync with mininet" )
- main.log.report( "__________________________________" )
- main.case( "Comparing Mininet topology with the topology of ONOS" )
- 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
-
- TopologyCheck = main.TRUE
- main.step( "Compare ONOS Topology to MN Topology" )
- devicesJson = main.ONOS2.devices()
- linksJson = main.ONOS2.links()
- # portsJson = main.ONOS2.ports()
-
- result1 = main.Mininet1.compareSwitches(
- MNTopo,
- json.loads( devicesJson ) )
- result2 = main.Mininet1.compareLinks(
- MNTopo,
- json.loads( linksJson ) )
- # result3 = main.Mininet1.comparePorts(
- # MNTopo, json.loads( portsJson ) )
-
- # result = result1 and result2 and result3
- result = result1 and result2
-
- print "***********************"
- if result == main.TRUE:
- main.log.report( "ONOS" + " Topology matches MN Topology" )
- else:
- main.log.report( "ONOS" + " Topology does not match MN Topology" )
-
- utilities.assert_equals(
- expect=main.TRUE,
- actual=result,
- onpass="ONOS" +
- " Topology matches MN Topology",
- onfail="ONOS" +
- " Topology does not match MN Topology" )
-
- TopologyCheck = TopologyCheck and result
- utilities.assert_equals(
- expect=main.TRUE,
- actual=TopologyCheck,
- onpass="Topology checks passed",
- onfail="Topology checks failed" )
-
- def CASE7( self, main ):
- from sts.topology.testonTopology import TestONTopology
-
- linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
-
- main.log.report( "This testscase is killing a link to ensure that \
- link discovery is consistent" )
- main.log.report( "__________________________________" )
- 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" )
- topologyOutput = main.ONOS2.topology()
- topologyResult = main.ONOS1.getTopology( topologyOutput )
- activeSwitches = topologyResult[ 'devices' ]
- links = topologyResult[ '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( linkSleep )
- topologyOutput = main.ONOS2.topology()
- LinkDown = main.ONOS1.checkStatus(
- topologyOutput, activeSwitches, str(
- int( links ) - 2 ) )
- if LinkDown == main.TRUE:
- main.log.report( "Link Down discovered properly" )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=LinkDown,
- onpass="Link Down discovered properly",
- onfail="Link down was not discovered in " +
- str( linkSleep ) +
- " seconds" )
-
- # Check ping result here..add code for it
-
- main.step( "Bring link between s3 and s28 back up" )
- LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
- time.sleep( linkSleep )
- topologyOutput = main.ONOS2.topology()
- LinkUp = main.ONOS1.checkStatus(
- topologyOutput,
- activeSwitches,
- str( links ) )
- if LinkUp == main.TRUE:
- main.log.report( "Link up discovered properly" )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=LinkUp,
- onpass="Link up discovered properly",
- onfail="Link up was not discovered in " +
- str( linkSleep ) +
- " seconds" )
-
- # NOTE Check ping result here..add code for it
-
- main.step( "Compare ONOS Topology to MN Topology" )
- Topo = TestONTopology(
- main.Mininet1,
- ctrls ) # can also add Intent API info for intent operations
- MNTopo = Topo
- TopologyCheck = main.TRUE
-
- devicesJson = main.ONOS2.devices()
- linksJson = main.ONOS2.links()
- portsJson = main.ONOS2.ports()
-
- result1 = main.Mininet1.compareSwitches(
- MNTopo,
- json.loads( devicesJson ) )
- result2 = main.Mininet1.compareLinks(
- MNTopo,
- json.loads( linksJson ) )
- # result3 = main.Mininet1.comparePorts(
- # MNTopo, json.loads( portsJson ) )
-
- # result = result1 and result2 and result3
- result = result1 and result2
- 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" )
-
- TopologyCheck = TopologyCheck and result
- utilities.assert_equals(
- expect=main.TRUE,
- actual=TopologyCheck,
- onpass="Topology checks passed",
- onfail="Topology checks failed" )
-
- result = LinkDown and LinkUp and TopologyCheck
- utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Link failure is discovered correctly",
- onfail="Link Discovery failed" )
-
- def CASE8( self ):
- """
- Host intents removal
- """
- main.log.report( "This testcase removes any previously added intents \
- before adding the same intents or point intents" )
- main.log.report( "__________________________________" )
- main.log.info( "Host intents removal" )
- main.case( "Removing host intents" )
- main.step( "Obtain the intent id's" )
- intentResult = main.ONOS2.intents( jsonFormat=False )
- main.log.info( "intent_result = " + intentResult )
-
- intentLinewise = intentResult.split( "\n" )
- intentList = []
- for line in intentLinewise:
- if line.startswith( "id=" ):
- intentList.append( line )
-
- intentids = []
- for line in intentList:
- intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
- for id in intentids:
- print "id = ", id
-
- main.step(
- "Iterate through the intentids list and remove each intent" )
- for id in intentids:
- main.ONOS2.removeIntent( intentId=id )
-
- intentResult = main.ONOS2.intents( jsonFormat=False )
- main.log.info( "intent_result = " + intentResult )
-
- case8Result = main.TRUE
- if case8Result == main.TRUE:
- main.log.report( "Intent removal successful" )
- else:
- main.log.report( "Intent removal failed" )
-
- PingResult = main.TRUE
- if case8Result == main.TRUE:
- i = 8
- 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.TRUE:
- i = 19
- PingResult = PingResult and main.TRUE
- elif ping == main.FALSE:
- i += 1
- PingResult = PingResult and main.FALSE
- else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
-
- # Note: If the ping result failed, that means the intents have been
- # withdrawn correctly.
- if PingResult == main.TRUE:
- main.log.report( "Host intents have not been withdrawn correctly" )
- # main.cleanup()
- # main.exit()
- if PingResult == main.FALSE:
- main.log.report( "Host intents have been withdrawn correctly" )
-
- case8Result = case8Result and PingResult
-
- if case8Result == main.FALSE:
- main.log.report( "Intent removal successful" )
- else:
- main.log.report( "Intent removal failed" )
-
- utilities.assert_equals( expect=main.FALSE, actual=case8Result,
- onpass="Intent removal test failed",
- onfail="Intent removal test passed" )
-
- def CASE9( self ):
- main.log.report(
- "This testcase adds point intents and then does pingall" )
- main.log.report( "__________________________________" )
- main.log.info( "Adding point intents" )
- main.case(
- "Adding bidirectional point for mn hosts \
- ( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22,\
- h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
- main.step(
- "Add point intents for mininet hosts h8 and h18 or \
- ONOS hosts h8 and h12" )
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003008/1",
- "of:0000000000006018/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006018/1",
- "of:0000000000003008/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- main.step(
- "Add point intents for mininet hosts h9 and h19 or \
- ONOS hosts h9 and h13" )
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003009/1",
- "of:0000000000006019/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006019/1",
- "of:0000000000003009/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- main.step(
- "Add point intents for mininet hosts h10 and h20 or \
- ONOS hosts hA and h14" )
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003010/1",
- "of:0000000000006020/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006020/1",
- "of:0000000000003010/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- main.step(
- "Add point intents for mininet hosts h11 and h21 or \
- ONOS hosts hB and h15" )
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003011/1",
- "of:0000000000006021/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006021/1",
- "of:0000000000003011/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- main.step(
- "Add point intents for mininet hosts h12 and h22 \
- ONOS hosts hC and h16" )
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003012/1",
- "of:0000000000006022/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006022/1",
- "of:0000000000003012/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- main.step(
- "Add point intents for mininet hosts h13 and h23 or \
- ONOS hosts hD and h17" )
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003013/1",
- "of:0000000000006023/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006023/1",
- "of:0000000000003013/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- main.step(
- "Add point intents for mininet hosts h14 and h24 or \
- ONOS hosts hE and h18" )
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003014/1",
- "of:0000000000006024/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006024/1",
- "of:0000000000003014/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- main.step(
- "Add point intents for mininet hosts h15 and h25 or \
- ONOS hosts hF and h19" )
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003015/1",
- "of:0000000000006025/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006025/1",
- "of:0000000000003015/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- main.step(
- "Add intents for mininet hosts h16 and h26 or \
- ONOS hosts h10 and h1A" )
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003016/1",
- "of:0000000000006026/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006026/1",
- "of:0000000000003016/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
-
- main.step(
- "Add point intents for mininet hosts h17 and h27 or \
- ONOS hosts h11 and h1B" )
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003017/1",
- "of:0000000000006027/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- main.log.info( getIntentResult )
-
- ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006027/1",
- "of:0000000000003017/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOS2.intents()
- main.log.info( "Point to point intent install successful" )
- main.log.info( getIntentResult )
-
- print(
- "___________________________________________________________" )
-
- flowHandle = main.ONOS2.flows()
- # print "flowHandle = ", flowHandle
- main.log.info( "flows :" + flowHandle )
-
- count = 1
- i = 8
- PingResult = main.TRUE
- 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
- PingResult = 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 between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "have failed" )
- i = 19
- PingResult = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h" +
- str( i ) +
- " and h" +
- str( i +
- 10 ) +
- "passed!" )
- i += 1
- PingResult = main.TRUE
- else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
-
- if PingResult == main.FALSE:
- main.log.report(
- "Point intents have not ben installed correctly. Cleaning up" )
- # main.cleanup()
- # main.exit()
- if PingResult == main.TRUE:
- main.log.report( "Point Intents have been installed correctly" )
-
- case9Result = PingResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case9Result,
- onpass="Point intents addition and Pingall Test successful",
- onfail="Point intents addition and Pingall Test NOT successful" )
diff --git a/TestON/tests/ProdFunc/ProdFunc.topo b/TestON/tests/ProdFunc/ProdFunc.topo
index 7dff686..3f3323e 100755
--- a/TestON/tests/ProdFunc/ProdFunc.topo
+++ b/TestON/tests/ProdFunc/ProdFunc.topo
@@ -63,41 +63,30 @@
#Specify the Option for mininet
<arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
<arg2> --topo mytopo </arg2>
- <arg3> --switch ovs,protocols=OpenFlow13 </arg3>
+ <arg3> --switch ovs,protocols=OpenFlow10 </arg3>
<controller> remote </controller>
</COMPONENTS>
</Mininet2>
<LincOE1>
- <host>10.128.20.30</host>
+ <host>10.128.10.11</host>
<user>admin</user>
<password>onos_test</password>
<type>LincOEDriver</type>
<connect_order>7</connect_order>
<COMPONENTS>
- <arg1> </arg1>
</COMPONENTS>
</LincOE1>
<LincOE2>
- <host>10.128.20.30</host>
+ <host>10.128.10.11</host>
<user>admin</user>
<password>onos_test</password>
<type>RemoteMininetDriver</type>
<connect_order>8</connect_order>
<COMPONENTS>
- <arg1> sudo python /home/admin/optical.py </arg1>
- <arg2> </arg2>
</COMPONENTS>
</LincOE2>
- <LincOE3>
- <host>10.128.20.30</host>
- <user>admin</user>
- <password>onos_test</password>
- <type>LincOEDriver</type>
- <connect_order>9</connect_order>
- </LincOE3>
-
</COMPONENT>
</TOPOLOGY>
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/ProdFunc/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/ProdFunc/__init__.py
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.params b/TestON/tests/ProdFunc13/ProdFunc13.params
index bb3c11c..4367bf4 100755
--- a/TestON/tests/ProdFunc13/ProdFunc13.params
+++ b/TestON/tests/ProdFunc13/ProdFunc13.params
@@ -1,7 +1,6 @@
<PARAMS>
- <testcases>1,4,10,5,6,7,8,9,2,20,21,22,10,23,24</testcases>
-
+ <testcases>1,4,10,5,6,7,8,9,8,11,8,2,20,21,22,10,23,24</testcases>
#Environment variables
<ENV>
<cellName>driver_test</cellName>
@@ -39,11 +38,4 @@
<LinkDiscovery>5</LinkDiscovery>
<SwitchDiscovery>15</SwitchDiscovery>
</timers>
-
- <OPTICAL>
- <jsonfile> /home/admin/ONOS/tools/test/topos/oe-nonlinear-4.json </jsonfile>
- </OPTICAL>
-
-
-
</PARAMS>
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.py b/TestON/tests/ProdFunc13/ProdFunc13.py
index b1246c2..a4d819c 100644
--- a/TestON/tests/ProdFunc13/ProdFunc13.py
+++ b/TestON/tests/ProdFunc13/ProdFunc13.py
@@ -17,6 +17,7 @@
self.default = ''
def CASE1( self, main ):
+ import time
"""
Startup sequence:
cell <name>
@@ -43,10 +44,10 @@
main.step( "Removing raft logs before a clen installation of ONOS" )
main.ONOSbench.onosRemoveRaftLogs()
- main.step( "Git checkout, pull and get version" )
+ main.step( "Git checkout and get version" )
#main.ONOSbench.gitCheckout( "master" )
gitPullResult = main.ONOSbench.gitPull()
- main.log.info( "git_pull_result = " + gitPullResult )
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
main.ONOSbench.getVersion( report=True )
if gitPullResult == 1:
@@ -78,7 +79,14 @@
startResult = main.ONOSbench.onosStart( ONOS1Ip )
main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
-
+ main.step( "Starting Mininet CLI..." )
+
+ # Starting the mininet using the old way
+ main.step( "Starting Mininet ..." )
+ netIsUp = main.Mininet1.startNet()
+ if netIsUp:
+ main.log.info("Mininet CLI is up")
+
case1Result = ( packageResult and
cellResult and verifyResult
and onosInstallResult and
@@ -125,7 +133,7 @@
onpass="Switch down discovery successful",
onfail="Switch down discovery failed" )
- def CASE11( self, main ):
+ def CASE101( self, main ):
"""
Cleanup sequence:
onos-service <nodeIp> stop
@@ -184,6 +192,7 @@
main.case( "Disconnecting mininet and restarting ONOS" )
main.step( "Disconnecting mininet and restarting ONOS" )
mininetDisconnect = main.Mininet1.disconnect()
+ print "mininetDisconnect = ", mininetDisconnect
main.step( "Removing raft logs before a clen installation of ONOS" )
main.ONOSbench.onosRemoveRaftLogs()
@@ -222,8 +231,8 @@
def CASE21( self, main ):
"""
On ONOS bench, run this command:
- ./~/ONOS/tools/test/bin/onos-topo-cfg
- which starts the rest and copies the links
+ sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
+ which spawns packet optical topology and copies the links
json file to the onos instance.
Note that in case of Packet Optical, the links are not learnt
from the topology, instead the links are learnt
@@ -234,18 +243,10 @@
main.log.report( "_____________________________________________" )
main.case( "Starting LINC-OE and other components" )
main.step( "Starting LINC-OE and other components" )
- startConsoleResult = main.LincOE1.startConsole()
- opticalMnScript = main.LincOE2.runOpticalMnScript()
- onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
- instanceName=main.params[ 'CTRL' ][ 'ip1' ],
- jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
+ appInstallResult = main.ONOS2.featureInstall( "onos-app-optical" )
+ opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
- print "start_console_result =", startConsoleResult
- print "optical_mn_script = ", opticalMnScript
- print "onos_topo_cfg_result =", onosTopoCfgResult
-
- case21Result = startConsoleResult and opticalMnScript and \
- onosTopoCfgResult
+ case21Result = opticalMnScript and appInstallResult
utilities.assert_equals(
expect=main.TRUE,
actual=case21Result,
@@ -254,11 +255,12 @@
def CASE22( self, main ):
"""
- Curretly we use, 4 linear switch optical topology and
- 2 packet layer mininet switches each with one host.
- Therefore, the roadmCount variable = 4,
- packetLayerSWCount variable = 2 and hostCount = 2
- and this is hardcoded in the testcase. If the topology changes,
+ Curretly we use, 10 optical switches(ROADM's) and
+ 6 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 10,
+ packetLayerSWCount variable = 6, hostCount=6 and
+ links=42.
+ All this is hardcoded in the testcase. If the topology changes,
these hardcoded values need to be changed
"""
main.log.report(
@@ -271,7 +273,7 @@
print "devices_result = ", devicesResult
devicesLinewise = devicesResult.split( "\n" )
- devicesLinewise = devicesLinewise[ 1:-1 ]
+ devicesLinewise = devicesLinewise[ 1: ]
roadmCount = 0
packetLayerSWCount = 0
for line in devicesLinewise:
@@ -282,7 +284,7 @@
roadmCount += 1
elif availability == 'true' and type == 'SWITCH':
packetLayerSWCount += 1
- if roadmCount == 4:
+ if roadmCount == 10:
print "Number of Optical Switches = %d and is" % roadmCount +\
" correctly detected"
main.log.info(
@@ -298,7 +300,7 @@
" and is wrong" )
opticalSWResult = main.FALSE
- if packetLayerSWCount == 2:
+ if packetLayerSWCount == 6:
print "Number of Packet layer or mininet Switches = %d "\
% packetLayerSWCount + "and is correctly detected"
main.log.info(
@@ -319,6 +321,16 @@
linksResult = main.ONOS3.links( jsonFormat=False )
print "links_result = ", linksResult
print "_________________________________"
+ linkActiveCount = linksResult.count("state=ACTIVE")
+ main.log.info( "linkActiveCount = " + str( linkActiveCount ))
+ if linkActiveCount == 42:
+ linkActiveResult = main.TRUE
+ main.log.info(
+ "Number of links in ACTIVE state are correct")
+ else:
+ linkActiveResult = main.FALSE
+ main.log.info(
+ "Number of links in ACTIVE state are wrong")
# NOTE:Since only point intents are added, there is no
# requirement to discover the hosts
@@ -347,7 +359,8 @@
is wrong" )
hostDiscovery = main.FALSE
"""
- case22Result = opticalSWResult and packetSWResult
+ case22Result = opticalSWResult and packetSWResult and \
+ linkActiveResult
utilities.assert_equals(
expect=main.TRUE,
actual=case22Result,
@@ -368,45 +381,45 @@
main.step( "Adding point intents" )
ptpIntentResult = main.ONOS3.addPointIntent(
"of:0000ffffffff0001/1",
- "of:0000ffffffff0002/1" )
+ "of:0000ffffffff0005/1" )
if ptpIntentResult == main.TRUE:
main.ONOS3.intents( jsonFormat=False )
main.log.info( "Point to point intent install successful" )
ptpIntentResult = main.ONOS3.addPointIntent(
- "of:0000ffffffff0002/1",
+ "of:0000ffffffff0005/1",
"of:0000ffffffff0001/1" )
if ptpIntentResult == main.TRUE:
main.ONOS3.intents( jsonFormat=False )
main.log.info( "Point to point intent install successful" )
- time.sleep( 10 )
+ time.sleep( 30 )
flowHandle = main.ONOS3.flows()
main.log.info( "flows :" + flowHandle )
# Sleep for 30 seconds to provide time for the intent state to change
- time.sleep( 30 )
+ time.sleep( 60 )
intentHandle = main.ONOS3.intents( jsonFormat=False )
main.log.info( "intents :" + intentHandle )
PingResult = main.TRUE
count = 1
- main.log.info( "\n\nh1 is Pinging h2" )
- ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
# ping = main.LincOE2.pinghost()
if ping == main.FALSE and count < 5:
count += 1
PingResult = main.FALSE
main.log.info(
- "Ping between h1 and h2 failed. Making attempt number " +
+ "Ping between h1 and h5 failed. Making attempt number " +
str( count ) +
" in 2 seconds" )
time.sleep( 2 )
elif ping == main.FALSE:
- main.log.info( "All ping attempts between h1 and h2 have failed" )
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
PingResult = main.FALSE
elif ping == main.TRUE:
- main.log.info( "Ping test between h1 and h2 passed!" )
+ main.log.info( "Ping test between h1 and h5 passed!" )
PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
@@ -434,20 +447,39 @@
import time
import json
"""
+ LINC uses its own switch IDs. You can use the following
+ command on the LINC console to find the mapping between
+ DPIDs and LINC IDs.
+ rp(application:get_all_key(linc)).
+
Test Rerouting of Packet Optical by bringing a port down
- ( port 22 ) of a switch( switchID=1 ), so that link
- ( between switch1 port22 - switch4-port30 ) is inactive
+ ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
+ so that link
+ ( between switch1 port20 - switch5 port50 ) is inactive
and do a ping test. If rerouting is successful,
ping should pass. also check the flows
"""
main.log.report(
"This testcase tests rerouting and pings mininet hosts" )
main.case( "Test rerouting and pings mininet hosts" )
+ main.step( "Attach to the Linc-OE session" )
+ attachConsole = main.LincOE1.attachLincOESession()
+ print "attachConsole = ", attachConsole
+
main.step( "Bring a port down and verify the link state" )
- main.LincOE1.portDown( swId="1", ptId="22" )
+ main.LincOE1.portDown( swId="9", ptId="20" )
linksNonjson = main.ONOS3.links( jsonFormat=False )
main.log.info( "links = " + linksNonjson )
+ linkInactiveCount = linksNonjson.count("state=INACTIVE")
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 2:
+ main.log.info(
+ "Number of links in INACTIVE state are correct")
+ else:
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+
links = main.ONOS3.links()
main.log.info( "links = " + links )
@@ -455,9 +487,9 @@
linksStateResult = main.FALSE
for item in linksResult:
if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
- 'src' ][ 'port' ] == "22":
- if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
- 'dst' ][ 'port' ] == "30":
+ 'src' ][ 'port' ] == "20":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
+ 'dst' ][ 'port' ] == "50":
linksState = item[ 'state' ]
if linksState == "INACTIVE":
main.log.info(
@@ -483,22 +515,22 @@
main.step( "Verify Rerouting by a ping test" )
PingResult = main.TRUE
count = 1
- main.log.info( "\n\nh1 is Pinging h2" )
- ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
# ping = main.LincOE2.pinghost()
if ping == main.FALSE and count < 5:
count += 1
PingResult = main.FALSE
main.log.info(
- "Ping between h1 and h2 failed. Making attempt number " +
+ "Ping between h1 and h5 failed. Making attempt number " +
str( count ) +
" in 2 seconds" )
time.sleep( 2 )
elif ping == main.FALSE:
- main.log.info( "All ping attempts between h1 and h2 have failed" )
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
PingResult = main.FALSE
elif ping == main.TRUE:
- main.log.info( "Ping test between h1 and h2 passed!" )
+ main.log.info( "Ping test between h1 and h5 passed!" )
PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
@@ -519,7 +551,7 @@
import time
main.log.report( "This testcase is testing the assignment of" +
" all the switches to all the controllers and" +
- " discovering the hists in reactive mode" )
+ " discovering the hosts in reactive mode" )
main.log.report( "__________________________________" )
main.case( "Pingall Test" )
main.step( "Assigning switches to controllers" )
@@ -631,11 +663,10 @@
main.step( "Pingall" )
pingResult = main.FALSE
- while pingResult == main.FALSE:
- time1 = time.time()
- pingResult = main.Mininet1.pingall()
- time2 = time.time()
- print "Time for pingall: %2f seconds" % ( time2 - time1 )
+ time1 = time.time()
+ pingResult = 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
@@ -680,7 +711,113 @@
onpass="Reactive forwarding app uninstallation successful",
onfail="Reactive forwarding app uninstallation failed" )
+
+ def CASE11( self ):
+ # NOTE: This testcase require reactive forwarding mode enabled
+ # NOTE: in the beginning and then uninstall it before adding
+ # NOTE: point intents. Again the app is installed so that
+ # NOTE: testcase 10 can be ran successively
+ import time
+ main.log.report(
+ "This testcase moves a host from one switch to another to add" +
+ "point intents between them and then perform ping" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Moving host from one switch to another" )
+ main.case( "Moving host from a device and attach it to another device" )
+ main.step( "Moving host h9 from device s9 and attach it to s8" )
+ main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
+
+ time.sleep(15) #Time delay to have all the flows ready
+ main.step( "Pingall" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ time2 = time.time()
+ print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
+ hosts = main.ONOS2.hosts( jsonFormat = False )
+ main.log.info( hosts )
+
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd uninstalled" )
+
+ main.step( "Add point intents between hosts on the same device")
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003008/1",
+ "of:0000000000003008/3" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003008/3",
+ "of:0000000000003008/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ main.case( "Ping hosts on the same devices" )
+ ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
+
+ '''
+ main.case( "Installing reactive forwarding app" )
+ # Install onos-app-fwd app to enable reactive forwarding
+ appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd installed" )
+ '''
+
+ if ping == main.FALSE:
+ main.log.report(
+ "Point intents for hosts on same devices haven't" +
+ " been installed correctly. Cleaning up" )
+ if ping == main.TRUE:
+ main.log.report(
+ "Point intents for hosts on same devices" +
+ "installed correctly. Cleaning up" )
+
+ case11Result = ping and pingResult
+ utilities.assert_equals(
+ expect = main.TRUE,
+ actual = case11Result,
+ onpass = "Point intents for hosts on same devices" +
+ "Ping Test successful",
+ onfail = "Point intents for hosts on same devices" +
+ "Ping Test NOT successful" )
+
+
+ def CASE12( self ):
+ """
+ Verify the default flows on each switch in proactive mode
+ """
+ main.log.report( "This testcase is verifying num of default" +
+ " flows on each switch" )
+ main.log.report( "__________________________________" )
+ main.case( "Verify num of default flows on each switch" )
+ main.step( "Obtaining the device id's and flowrule count on them" )
+
+ case12Result = main.TRUE
+ idList = main.ONOS2.getAllDevicesId()
+ for id in idList:
+ count = main.ONOS2.FlowAddedCount( id )
+ main.log.info("count = " +count)
+ if int(count) != 3:
+ case12Result = main.FALSE
+ break
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case12Result,
+ onpass = "Expected default num of flows exist",
+ onfail = "Expected default num of flows do not exist")
+
+
+
+
def CASE6( self ):
+ import time
main.log.report( "This testcase is testing the addition of" +
" host intents and then does pingall" )
main.log.report( "__________________________________" )
@@ -730,15 +867,18 @@
host2 = "00:00:00:00:00:" + \
str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
# NOTE: get host can return None
- # TODO: handle this
- host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
- host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
- main.ONOS2.addHostIntent( host1Id, host2Id )
+ if host1:
+ host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
+ if host2:
+ host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
+ if host1Id and host2Id:
+ main.ONOS2.addHostIntent( host1Id, host2Id )
time.sleep( 10 )
hIntents = main.ONOS2.intents( jsonFormat=False )
main.log.info( "intents:" + hIntents )
- main.ONOS2.flows()
+ flows = main.ONOS2.flows()
+ main.log.info( "flows:" + flows )
count = 1
i = 8
@@ -960,8 +1100,8 @@
main.step( "Determine the current number of switches and links" )
topologyOutput = main.ONOS2.topology()
topologyResult = main.ONOS1.getTopology( topologyOutput )
- activeSwitches = topologyResult[ 'devices' ]
- links = topologyResult[ 'links' ]
+ activeSwitches = topologyResult[ 'deviceCount' ]
+ links = topologyResult[ 'linkCount' ]
print "activeSwitches = ", type( activeSwitches )
print "links = ", type( links )
main.log.info(
@@ -1055,26 +1195,23 @@
def CASE8( self ):
"""
- Host intents removal
+ Intent removal
"""
+ import time
main.log.report( "This testcase removes any previously added intents" +
- " before adding the same intents or point intents" )
+ " before adding any new set of intents" )
main.log.report( "__________________________________" )
- main.log.info( "Host intents removal" )
- main.case( "Removing host intents" )
+ main.log.info( "intent removal" )
+ main.case( "Removing installed intents" )
main.step( "Obtain the intent id's" )
intentResult = main.ONOS2.intents( jsonFormat=False )
main.log.info( "intent_result = " + intentResult )
-
intentLinewise = intentResult.split( "\n" )
- intentList = []
- for line in intentLinewise:
- if line.startswith( "id=" ):
- intentList.append( line )
- intentids = []
- for line in intentList:
- intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
+ intentList = [line for line in intentLinewise \
+ if line.startswith( "id=")]
+ intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
+ intentList]
for id in intentids:
print "id = ", id
@@ -1085,8 +1222,20 @@
intentResult = main.ONOS2.intents( jsonFormat=False )
main.log.info( "intent_result = " + intentResult )
-
- case8Result = main.TRUE
+
+ intentList = [line for line in intentResult.split( "\n" ) \
+ if line.startswith( "id=")]
+ intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
+ intentList]
+ for state in intentState:
+ print state
+
+ case8Result = main.TRUE
+ for state in intentState:
+ if state != 'WITHDRAWN':
+ case8Result = main.FALSE
+ break
+
if case8Result == main.TRUE:
main.log.report( "Intent removal successful" )
else:
@@ -1113,11 +1262,11 @@
# Note: If the ping result failed, that means the intents have been
# withdrawn correctly.
if PingResult == main.TRUE:
- main.log.report( "Host intents have not been withdrawn correctly" )
+ main.log.report( "Installed intents have not been withdrawn correctly" )
# main.cleanup()
# main.exit()
if PingResult == main.FALSE:
- main.log.report( "Host intents have been withdrawn correctly" )
+ main.log.report( "Installed intents have been withdrawn correctly" )
case8Result = case8Result and PingResult
@@ -1136,9 +1285,9 @@
main.log.report( "__________________________________" )
main.log.info( "Adding point intents" )
main.case(
- '''Adding bidirectional point for mn hosts
- ( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22,
- h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )''' )
+ "Adding bidirectional point for mn hosts" +
+ "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
+ "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
main.step( "Add point intents for mn hosts h8 and h18 or" +
"ONOS hosts h8 and h12" )
@@ -1318,7 +1467,7 @@
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- main.log.info( getIntentResult )
+ #main.log.info( getIntentResult )
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006027/1",
@@ -1326,14 +1475,13 @@
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- main.log.info( getIntentResult )
+ #main.log.info( getIntentResult )
print(
"___________________________________________________________" )
flowHandle = main.ONOS2.flows()
- # print "flowHandle = ", flowHandle
- main.log.info( "flows :" + flowHandle )
+ #main.log.info( "flows :" + flowHandle )
count = 1
i = 8
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.topo b/TestON/tests/ProdFunc13/ProdFunc13.topo
index c592e18..9cef3f7 100755
--- a/TestON/tests/ProdFunc13/ProdFunc13.topo
+++ b/TestON/tests/ProdFunc13/ProdFunc13.topo
@@ -69,35 +69,24 @@
</Mininet2>
<LincOE1>
- <host>10.128.20.30</host>
+ <host>10.128.10.11</host>
<user>admin</user>
<password>onos_test</password>
<type>LincOEDriver</type>
<connect_order>7</connect_order>
<COMPONENTS>
- <arg1> </arg1>
</COMPONENTS>
</LincOE1>
<LincOE2>
- <host>10.128.20.30</host>
+ <host>10.128.10.11</host>
<user>admin</user>
<password>onos_test</password>
<type>RemoteMininetDriver</type>
<connect_order>8</connect_order>
<COMPONENTS>
- <arg1> sudo python /home/admin/optical.py </arg1>
- <arg2> </arg2>
</COMPONENTS>
</LincOE2>
- <LincOE3>
- <host>10.128.20.30</host>
- <user>admin</user>
- <password>onos_test</password>
- <type>LincOEDriver</type>
- <connect_order>9</connect_order>
- </LincOE3>
-
</COMPONENT>
</TOPOLOGY>
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/ProdFunc13/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/ProdFunc13/__init__.py
diff --git a/TestON/tests/ScaleOutTemplate/README b/TestON/tests/ScaleOutTemplate/README
new file mode 100644
index 0000000..2d5ae1c
--- /dev/null
+++ b/TestON/tests/ScaleOutTemplate/README
@@ -0,0 +1,22 @@
+-------------------
+----Setup Guide----
+-------------------
+
+CASE 1: init case; cleans and sets up enviornment, starts up node 1
+
+CASE 2: Increments scale case; starts up additional nodes, determined by 'SCALE' in params
+ Ex: cluster size = 1 and scale = 2 ==> call CASE2 ==> cluster size = 3
+
+Params file:
+ SCALE = cluster scale step size
+ availableNodes = number of nodes you have provided data for in .topo file
+
+ ENV:
+ cellName = desired name of cell file to be created at runtime
+ cellFeatures = list of features desired
+ NOTE: webconsole, onos-api, onos-cli and onos-openflow are loaded automatically.
+ adjust your test and feature list accordingly
+ TEST:
+ skipCleanInstall = set yes if you want to skip for the sake of test debugging, otherwise set no
+
+
diff --git a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.params b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.params
index 4dacc99..d4fa651 100644
--- a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.params
+++ b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.params
@@ -1,12 +1,18 @@
<PARAMS>
- <testcases>1,2</testcases>
+ <testcases>1,2,1,2,1,2,1,2</testcases>
+ <SCALE>1,3,5,7</SCALE>
+ <availableNodes>7</availableNodes>
+
<ENV>
- <cellName>cam_cells</cellName>
+ <cellName>defaultCell</cellName>
+ <cellApps></cellApps>
</ENV>
- <SCALE>2</SCALE>
+ <TEST>
+ <skipCleanInstall>yes</skipCleanInstall>
+ </TEST>
<GIT>
<autopull>on</autopull>
@@ -15,16 +21,32 @@
<CTRL>
<USER>admin</USER>
+
<ip1>10.128.5.51</ip1>
<port1>6633</port1>
+
<ip2>10.128.5.52</ip2>
<port2>6633</port2>
+
<ip3>10.128.5.53</ip3>
<port3>6633</port3>
+
+ <ip4>10.128.5.54</ip4>
+ <port4>6633</port4>
+
+ <ip5>10.128.5.65</ip5>
+ <port5>6633</port5>
+
+ <ip6>10.128.5.66</ip6>
+ <port6>6633</port6>
+
+ <ip7>10.128.5.67</ip7>
+ <port7>6633</port7>
+
</CTRL>
<MN>
- <ip1>10.128.5.59</ip1>
+ <ip1>10.128.5.55</ip1>
</MN>
<BENCH>
@@ -32,9 +54,6 @@
<ip1>10.128.5.55</ip1>
</BENCH>
- <TEST>
- </TEST>
-
<JSON>
</JSON>
diff --git a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.py b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.py
index a75d694..4400262 100644
--- a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.py
+++ b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.py
@@ -4,133 +4,122 @@
#
# cameron@onlab.us
-import sys
-import os
+import sys
+import os.path
class ScaleOutTemplate:
- def __init__(self):
+
+ def __init__( self ):
self.default = ''
-
- def CASE1(self, main):
-
- global cluster_count
- cluster_count = 1
- checkout_branch = main.params['GIT']['checkout']
- git_pull = main.params['GIT']['autopull']
- cell_name = main.params['ENV']['cellName']
- BENCH_ip = main.params['BENCH']['ip1']
- BENCH_user = main.params['BENCH']['user']
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- MN1_ip = main.params['MN']['ip1']
+ def CASE1( self, main ):
+
+ import time
+ global init
+ try:
+ if type(init) is not bool:
+ init = False
+ except NameError:
+ init = False
+
+ #Load values from params file
+ checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
+ gitPull = main.params[ 'GIT' ][ 'autopull' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ Apps = main.params[ 'ENV' ][ 'cellApps' ]
+ BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+ BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+ MN1Ip = main.params[ 'MN' ][ 'ip1' ]
+ maxNodes = int(main.params[ 'availableNodes' ])
+ skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
- main.log.step("Cleaning Enviornment...")
- main.ONOSbench.onos_uninstall(ONOS1_ip)
- main.ONOSbench.onos_uninstall(ONOS2_ip)
- main.ONOSbench.onos_uninstall(ONOS3_ip)
-
- main.step("Git checkout and pull "+checkout_branch)
- if git_pull == 'on':
- checkout_result = main.ONOSbench.git_checkout(checkout_branch)
- pull_result = main.ONOSbench.git_pull()
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
+ if init == False:
+ init = True
+ global clusterCount #number of nodes running
+ global ONOSIp #list of ONOS IP addresses
+ global scale
- else:
- checkout_result = main.TRUE
- pull_result = main.TRUE
- main.log.info("Skipped git checkout and pull")
+ clusterCount = 0
+ ONOSIp = [ 0 ]
+ scale = (main.params[ 'SCALE' ]).split(",")
+ clusterCount = int(scale[0])
- mvn_result = main.ONOSbench.clean_install()
-
- main.step("Set cell for ONOS cli env")
- main.ONOS1cli.set_cell(cell_name)
- main.ONOS2cli.set_cell(cell_name)
- main.ONOS3cli.set_cell(cell_name)
+ #Populate ONOSIp with ips from params
+ for i in range(1, maxNodes + 1):
+ ipString = 'ip' + str(i)
+ ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
+
+ #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
+ if skipMvn != "yes":
+ mvnResult = main.ONOSbench.cleanInstall()
- main.step("Creating ONOS package")
- package_result = main.ONOSbench.onos_package() #no file or directory
+ #git
+ main.step( "Git checkout and pull " + checkoutBranch )
+ if gitPull == 'on':
+ checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
+ pullResult = main.ONOSbench.gitPull()
- main.step("Installing ONOS package")
- install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
-
- cell_name = main.params['ENV']['cellName']
- main.step("Applying cell file to environment")
- cell_apply_result = main.ONOSbench.set_cell(cell_name)
- main.step("verify cells")
- verify_cell_result = main.ONOSbench.verify_cell()
-
- main.step("Set cell for ONOS cli env")
- main.ONOS1cli.set_cell(cell_name)
- cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
+ else:
+ checkoutResult = main.TRUE
+ pullResult = main.TRUE
+ main.log.info( "Skipped git checkout and pull" )
+
+ # -- END OF INIT SECTION --#
+
+ clusterCount = int(scale[0])
+ scale.remove(scale[0])
+
+ #kill off all onos processes
+ main.log.step("Safety check, killing all ONOS processes")
+ main.log.step("before initiating enviornment setup")
+ for node in range(1, maxNodes + 1):
+ main.ONOSbench.onosDie(ONOSIp[node])
+
+ #Uninstall everywhere
+ main.log.step( "Cleaning Enviornment..." )
+ for i in range(1, maxNodes + 1):
+ main.log.info(" Uninstalling ONOS " + str(i) )
+ main.ONOSbench.onosUninstall( ONOSIp[i] )
+ #construct the cell file
+ main.log.info("Creating cell file")
+ cellIp = []
+ for node in range (1, clusterCount + 1):
+ cellIp.append(ONOSIp[node])
- def CASE2(self, main):
+ main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
- '''
- Increase number of nodes and initiate CLI
- '''
- import time
+ main.step( "Set Cell" )
+ main.ONOSbench.setCell(cellName)
- global cluster_count
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "verify cells" )
+ verifyCellResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
+ for node in range(1, clusterCount + 1):
+ main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
+ main.ONOSbench.onosInstall( ONOSIp[node])
+
+ for node in range(1, clusterCount + 1):
+ for i in range( 2 ):
+ isup = main.ONOSbench.isup( ONOSIp[node] )
+ if isup:
+ main.log.info("ONOS " + str(node) + " is up\n")
+ break
+ if not isup:
+ main.log.report( "ONOS " + str(node) + " didn't start!" )
+ main.log.info("Startup sequence complete")
+
+ def CASE2( self, main ):
+
+ print ("clusterCount: " + str(clusterCount))
+ print ("scale: " + str(scale))
+ print ("ONOSIp: " + str(ONOSIp))
+ print ("INIT: " + str(init))
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- #ONOS4_ip = main.params['CTRL']['ip4']
- #ONOS5_ip = main.params['CTRL']['ip5']
- #ONOS6_ip = main.params['CTRL']['ip6']
- #ONOS7_ip = main.params['CTRL']['ip7']
- cell_name = main.params['ENV']['cellName']
- scale = int(main.params['SCALE'])
-
- #Cluster size increased everytime the case is defined
- cluster_count += scale
-
- main.log.report("Increasing cluster size to "+
- str(cluster_count))
- install_result = main.FALSE
-
- if scale == 2:
- if cluster_count == 3:
- main.log.info("Installing nodes 2 and 3")
- install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
- install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
- cli2 = main.ONOS1cli.start_onos_cli(ONOS2_ip)
- cli3 = main.ONOS1cli.start_onos_cli(ONOS3_ip)
-
- '''
- elif cluster_count == 5:
-
- main.log.info("Installing nodes 4 and 5")
- node4_result = main.ONOSbench.onos_install(node=ONOS4_ip)
- node5_result = main.ONOSbench.onos_install(node=ONOS5_ip)
- install_result = node4_result and node5_result
- time.sleep(5)
-
- main.ONOS4cli.start_onos_cli(ONOS4_ip)
- main.ONOS5cli.start_onos_cli(ONOS5_ip)
-
- elif cluster_count == 7:
-
- main.log.info("Installing nodes 4 and 5")
- node6_result = main.ONOSbench.onos_install(node=ONOS6_ip)
- node7_result = main.ONOSbench.onos_install(node=ONOS7_ip)
- install_result = node6_result and node7_result
- time.sleep(5)
-
- main.ONOS6cli.start_onos_cli(ONOS6_ip)
- main.ONOS7cli.start_onos_cli(ONOS7_ip)
- '''
- if scale == 1:
- if cluster_count == 2:
- main.log.info("Installing node 2")
- install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
- cli2 = main.ONOS1cli.start_onos_cli(ONOS2_ip)
-
- if cluster_count == 3:
- main.log.info("Installing node 3")
- install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
- cli3 = main.ONOS1cli.start_onos_cli(ONOS3_ip)
-
diff --git a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.topo b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.topo
index 88c4d35..0802eca 100644
--- a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.topo
+++ b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.topo
@@ -37,13 +37,13 @@
<connect_order>4</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS3cli>
-
+
<ONOS1>
<host>10.128.5.51</host>
<user>sdn</user>
<password>rocks</password>
<type>OnosDriver</type>
- <connect_order>5</connect_order>
+ <connect_order>9</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS1>
@@ -52,7 +52,7 @@
<user>sdn</user>
<password>rocks</password>
<type>OnosDriver</type>
- <connect_order>6</connect_order>
+ <connect_order>10</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS2>
@@ -61,16 +61,16 @@
<user>sdn</user>
<password>rocks</password>
<type>OnosDriver</type>
- <connect_order>7</connect_order>
+ <connect_order>11</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS3>
<Mininet1>
- <host>10.128.5.59</host>
+ <host>10.128.5.55</host>
<user>admin</user>
<password>onos_test</password>
<type>MininetCliDriver</type>
- <connect_order>8</connect_order>
+ <connect_order>16</connect_order>
<COMPONENTS>
<arg1> --custom ~/mininet/custom/topo-2sw-2host.py </arg1>
<arg2> --arp --mac --topo mytopo</arg2>
diff --git a/TestON/tests/SdnIpSingleSwitch/CASE4-ping-as2host.sh b/TestON/tests/SdnIpSingleSwitch/CASE4-ping-as2host.sh
new file mode 100755
index 0000000..52768b2
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/CASE4-ping-as2host.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+
+#all the address in this for loop should work
+
+# ping test between as2 and as3
+for ((i=0;i<10;i++)); do
+
+ #echo '------from 3.0.0.x to 4.0.1.'$j'------'
+
+ for ((j=0; j<10; ++j )) ; do
+ echo '3.0.'$i'.1 -> 4.0.'$j'.1'
+ ping -c 1 -w 1 -I 3.0.$i.1 4.0.$j.1 | grep 'from 4.0.'$j'.1'
+
+ done
+
+done
+for ((i=0;i<10;i++)); do
+
+ #echo '------from 3.0.0.x to 5.0.1.'$j'------'
+
+ for ((j=0; j<10; ++j )) ; do
+ echo '3.0.'$i'.1 -> 5.0.'$j'.1'
+ ping -c 1 -w 1 -I 3.0.$i.1 5.0.$j.1 | grep 'from 5.0.'$j'.1'
+
+ done
+
+done
+
+# ping test between as2 and as4
+for ((i=1;i<2;i++)); do
+ for ((prefix=101; prefix<=200; ++prefix)) ; do
+ for ((j=0; j<10; ++j )) ; do
+ echo '3.0.0.'$i' - > '$prefix'.0.'$j'.1'
+ ping -c 1 -w 1 -I 3.0.0.$i $prefix.0.$j.1 | grep 'from '$prefix'.0.'$j'.1'
+
+ done
+ done
+
+done
+
diff --git a/TestON/tests/SdnIpSingleSwitch/SdnIpSingleSwitch.params b/TestON/tests/SdnIpSingleSwitch/SdnIpSingleSwitch.params
new file mode 100755
index 0000000..467141d
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/SdnIpSingleSwitch.params
@@ -0,0 +1,25 @@
+<PARAMS>
+
+ <testcases>4</testcases>
+
+ #Environment variables
+ <ENV>
+ <cellName>sdnip_single_instance</cellName>
+ </ENV>
+
+ <CTRL>
+ <ip1>127.0.0.1</ip1>
+ <port1>6633</port1>
+ </CTRL>
+
+ <GIT>
+ <autoPull>off</autoPull>
+ <checkout>master</checkout>
+ </GIT>
+
+ <JSON>
+ <prefix>prefix</prefix>
+ <nextHop>nextHop</nextHop>
+ </JSON>
+
+</PARAMS>
diff --git a/TestON/tests/SdnIpSingleSwitch/SdnIpSingleSwitch.py b/TestON/tests/SdnIpSingleSwitch/SdnIpSingleSwitch.py
new file mode 100644
index 0000000..d13bdb3
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/SdnIpSingleSwitch.py
@@ -0,0 +1,1133 @@
+# from cupshelpers.config import prefix
+
+# Testing the basic functionality of SDN-IP
+
+
+class SdnIpSingleSwitch:
+
+ def __init__( self ):
+ self.default = ''
+
+# from cupshelpers.config import prefix
+
+# Testing the basic functionality of SDN-IP
+
+
+class SdnIpSingleSwitch:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE4( self, main ):
+ """
+ Test the SDN-IP functionality
+ allRoutesExpected: all expected routes for all BGP peers
+ routeIntentsExpected: all expected MultiPointToSinglePointIntent \
+ intents
+ bgpIntentsExpected: expected PointToPointIntent intents
+ allRoutesActual: all routes from ONOS LCI
+ routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
+ ONOS CLI
+ bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
+ """
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
+ SDNIPJSONFILEPATH = \
+ "/home/sdnip/TestON/tests/SdnIpSingleSwitch/sdnip.json"
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+ main.log.info( "Generate prefixes for host3" )
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+
+ main.step( "Checking if ONOS is up yet" )
+ time.sleep( 20 )
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+
+ main.ONOScli.startOnosCli( ONOS1Ip )
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing sdn-ip feature" )
+ main.ONOScli.featureInstall( "onos-app-sdnip" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ time.sleep( 60 )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ time.sleep( 20 )
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+
+ main.step( "Check MultiPointToSinglePointIntent intents installed" )
+ # routeIntentsExpected are generated when generating routes
+ # get rpoute intents from ONOS CLI
+ routeIntentsActual = \
+ main.QuaggaCliHost3.extractActualRouteIntents(
+ getIntentsResult )
+ routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
+ routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
+ main.log.info( "MultiPointToSinglePoint intents expected:" )
+ main.log.info( routeIntentsStrExpected )
+ main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
+ main.log.info( routeIntentsStrActual )
+ utilities.assertEquals(
+ expect=True,
+ actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
+ onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
+ correct!***",
+ onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
+ wrong!***" )
+
+ if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+ main.log.report( "***MultiPointToSinglePoint Intents before \
+ deleting routes correct!***" )
+ else:
+ main.log.report( "***MultiPointToSinglePoint Intents before \
+ deleting routes wrong!***" )
+
+ main.step( "Check BGP PointToPointIntent intents installed" )
+ # bgp intents expected
+ bgpIntentsExpected = \
+ main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
+ # get BGP intents from ONOS CLI
+ bgpIntentsActual = \
+ main.QuaggaCliHost3.extractActualBgpIntents( getIntentsResult )
+
+ bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
+ bgpIntentsStrActual = str( bgpIntentsActual )
+ main.log.info( "PointToPointIntent intents expected:" )
+ main.log.info( bgpIntentsStrExpected )
+ main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
+ main.log.info( bgpIntentsStrActual )
+
+ utilities.assertEquals(
+ expect=True,
+ actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
+ onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
+ onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+ if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are correct!***" )
+ else:
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+ main.log.info( "Ping Test Start" )
+ time.sleep(1000000)
+
+ #============================= Ping Test ========================
+ # wait until all MultiPointToSinglePoint
+ time.sleep( 20 )
+ pingTestScript = "CASE4-ping-as2host.sh"
+ pingTestResultsFile = \
+ "~/CASE4-ping-results-before-delete-routes-" \
+ + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ pingTestResults = main.QuaggaCliHost.pingTest(
+ "1.168.30.100", pingTestScript, pingTestResultsFile )
+ main.log.info( pingTestResults )
+ time.sleep( 20 )
+
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+ main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
+
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report( "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
+
+ main.step( "Check intents after deleting routes" )
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+ routeIntentsActual = \
+ main.QuaggaCliHost3.extractActualRouteIntents(
+ getIntentsResult )
+ main.log.info( "main.ONOScli.intents()= " )
+ main.log.info( routeIntentsActual )
+ utilities.assertEquals(
+ expect="[]", actual=str( routeIntentsActual ),
+ onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
+ correct!***",
+ onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
+ wrong!***" )
+
+ if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+ main.log.report( "***MultiPointToSinglePoint Intents after \
+ deleting routes correct!***" )
+ else:
+ main.log.report( "***MultiPointToSinglePoint Intents after \
+ deleting routes wrong!***" )
+
+ time.sleep( 20 )
+ pingTestScript = "CASE4-ping-as2host.sh"
+ pingTestResultsFile = \
+ "~/CASE4-ping-results-after-delete-routes-" \
+ + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ pingTestResults = main.QuaggaCliHost.pingTest(
+ "1.168.30.100", pingTestScript, pingTestResultsFile )
+ main.log.info( pingTestResults )
+ time.sleep( 100 )
+
+ # main.step( "Test whether Mininet is started" )
+ # main.Mininet2.handle.sendline( "xterm host1" )
+ # main.Mininet2.handle.expect( "mininet>" )
+
+ def CASE3( self, main ):
+ """
+ Test the SDN-IP functionality
+ allRoutesExpected: all expected routes for all BGP peers
+ routeIntentsExpected: all expected MultiPointToSinglePointIntent intents
+ bgpIntentsExpected: expected PointToPointIntent intents
+ allRoutesActual: all routes from ONOS LCI
+ routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
+ ONOS CLI
+ bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
+ """
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case( "The test case is to help to setup the TestON \
+ environment and test new drivers" )
+ # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
+ SDNIPJSONFILEPATH = \
+ "/home/admin/workspace/onos/tools/package/config/sdnip.json"
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+ main.log.info( "Generate prefixes for host3" )
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+
+ main.step( "Checking if ONOS is up yet" )
+ time.sleep( 60 )
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+
+ main.ONOScli.startOnosCli( ONOS1Ip )
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing sdn-ip feature" )
+ main.ONOScli.featureInstall( "onos-app-sdnip" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ for i in range( 101, 201 ):
+ prefixesHostX = \
+ main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
+ main.log.info( prefixesHostX )
+ for prefix in prefixesHostX:
+ allRoutesExpected.append(
+ prefix + "/" + "192.168.40." + str( i - 100 ) )
+
+ routeIntentsExpectedHostX = \
+ main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
+ prefixesHostX, "192.168.40." + str( i - 100 ),
+ "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
+ routeIntentsExpected = routeIntentsExpected + \
+ routeIntentsExpectedHostX
+
+ main.log.info( "Login Quagga CLI on host" + str( i ) )
+ QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
+ QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
+ main.log.info(
+ "Enter configuration model of Quagga CLI on host" + str( i ) )
+ QuaggaCliHostX.enterConfig( 65000 + i - 100 )
+ main.log.info( "Add routes to Quagga on host" + str( i ) )
+ QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
+
+ time.sleep( 60 )
+
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ time.sleep( 20 )
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+
+ main.step( "Check MultiPointToSinglePointIntent intents installed" )
+ # routeIntentsExpected are generated when generating routes
+ # get rpoute intents from ONOS CLI
+ routeIntentsActual = \
+ main.QuaggaCliHost3.extractActualRouteIntents(
+ getIntentsResult )
+ routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
+ routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
+ main.log.info( "MultiPointToSinglePoint intents expected:" )
+ main.log.info( routeIntentsStrExpected )
+ main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
+ main.log.info( routeIntentsStrActual )
+ utilities.assertEquals(
+ expect=True,
+ actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
+ onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
+ correct!***",
+ onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
+ wrong!***" )
+
+ if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+ main.log.report(
+ "***MultiPointToSinglePoint Intents before deleting routes \
+ correct!***" )
+ else:
+ main.log.report(
+ "***MultiPointToSinglePoint Intents before deleting routes \
+ wrong!***" )
+
+ main.step( "Check BGP PointToPointIntent intents installed" )
+ # bgp intents expected
+ bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
+ SDNIPJSONFILEPATH )
+ # get BGP intents from ONOS CLI
+ bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
+ getIntentsResult )
+
+ bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
+ bgpIntentsStrActual = str( bgpIntentsActual )
+ main.log.info( "PointToPointIntent intents expected:" )
+ main.log.info( bgpIntentsStrExpected )
+ main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
+ main.log.info( bgpIntentsStrActual )
+
+ utilities.assertEquals(
+ expect=True,
+ actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
+ onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
+ onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+ if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are correct!***" )
+ else:
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+ #============================= Ping Test ========================
+ # wait until all MultiPointToSinglePoint
+ time.sleep( 20 )
+ pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
+ pingTestResultsFile = \
+ "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-before-delete-routes-" \
+ + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ pingTestResults = main.QuaggaCliHost.pingTest(
+ "1.168.30.100", pingTestScript, pingTestResultsFile )
+ main.log.info( pingTestResults )
+ time.sleep( 20 )
+
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+ for i in range( 101, 201 ):
+ prefixesHostX = \
+ main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
+ main.log.info( prefixesHostX )
+ QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
+ QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
+
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = main.QuaggaCliHost3.extractActualRoutes(
+ getRoutesResult )
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after deleting wrong!***" )
+
+ main.step( "Check intents after deleting routes" )
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+ routeIntentsActual = \
+ main.QuaggaCliHost3.extractActualRouteIntents(
+ getIntentsResult )
+ main.log.info( "main.ONOScli.intents()= " )
+ main.log.info( routeIntentsActual )
+ utilities.assertEquals(
+ expect="[]", actual=str( routeIntentsActual ),
+ onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
+ 0, correct!***",
+ onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
+ 0, wrong!***" )
+
+ if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after deleting routes \
+ correct!***" )
+ else:
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after deleting routes \
+ wrong!***" )
+
+ time.sleep( 20 )
+ pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
+ pingTestResultsFile = \
+ "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-after-delete-routes-" \
+ + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ pingTestResults = main.QuaggaCliHost.pingTest(
+ "1.168.30.100", pingTestScript, pingTestResultsFile )
+ main.log.info( pingTestResults )
+ time.sleep( 100 )
+
+ # main.step( "Test whether Mininet is started" )
+ # main.Mininet2.handle.sendline( "xterm host1" )
+ # main.Mininet2.handle.expect( "mininet>" )
+
+ def CASE1( self, main ):
+ """
+ Test the SDN-IP functionality
+ allRoutesExpected: all expected routes for all BGP peers
+ routeIntentsExpected: all expected MultiPointToSinglePointIntent \
+ intents
+ bgpIntentsExpected: expected PointToPointIntent intents
+ allRoutesActual: all routes from ONOS LCI
+ routeIntentsActual: actual MultiPointToSinglePointIntent intents \
+ from ONOS CLI
+ bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
+ """
+ import time
+ import json
+ from operator import eq
+ # from datetime import datetime
+ from time import localtime, strftime
+
+ main.case("The test case is to help to setup the TestON environment \
+ and test new drivers" )
+ SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+ # bgpPeerHosts = []
+ # for i in range( 3, 5 ):
+ # bgpPeerHosts.append( "host" + str( i ) )
+ # main.log.info( "BGP Peer Hosts are:" + bgpPeerHosts )
+
+ # for i in range( 3, 5 ):
+ # QuaggaCliHost = "QuaggaCliHost" + str( i )
+ # prefixes = main.QuaggaCliHost.generatePrefixes( 3, 10 )
+
+ # main.log.info( prefixes )
+ # allRoutesExpected.append( prefixes )
+ main.log.info( "Generate prefixes for host3" )
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Starting ONOS service" )
+ # TODO: start ONOS from Mininet Script
+ # startResult = main.ONOSbench.onosStart( "127.0.0.1" )
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f", node=ONOS1Ip )
+
+ main.step( "Checking if ONOS is up yet" )
+ time.sleep( 60 )
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+ # TODO: change the hardcode in startOnosCli method in ONOS CLI driver
+
+ main.ONOScli.startOnosCli( ONOS1Ip )
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing sdn-ip feature" )
+ main.ONOScli.featureInstall( "onos-app-sdnip" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+ time.sleep( 60 )
+
+ # get all routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ time.sleep( 20 )
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+
+ main.step( "Check MultiPointToSinglePointIntent intents installed" )
+ # routeIntentsExpected are generated when generating routes
+ # get rpoute intents from ONOS CLI
+ routeIntentsActual = \
+ main.QuaggaCliHost3.extractActualRouteIntents(
+ getIntentsResult )
+ routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
+ routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
+ main.log.info( "MultiPointToSinglePoint intents expected:" )
+ main.log.info( routeIntentsStrExpected )
+ main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
+ main.log.info( routeIntentsStrActual )
+ utilities.assertEquals(
+ expect=True,
+ actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
+ onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
+ correct!***",
+ onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
+ wrong!***" )
+
+ if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+ main.log.report(
+ "***MultiPointToSinglePoint Intents before deleting routes \
+ correct!***" )
+ else:
+ main.log.report(
+ "***MultiPointToSinglePoint Intents before deleting routes \
+ wrong!***" )
+
+ main.step( "Check BGP PointToPointIntent intents installed" )
+ # bgp intents expected
+ bgpIntentsExpected = \
+ main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
+ # get BGP intents from ONOS CLI
+ bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
+ getIntentsResult )
+
+ bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
+ bgpIntentsStrActual = str( bgpIntentsActual )
+ main.log.info( "PointToPointIntent intents expected:" )
+ main.log.info( bgpIntentsStrExpected )
+ main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
+ main.log.info( bgpIntentsStrActual )
+
+ utilities.assertEquals(
+ expect=True,
+ actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
+ onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
+ onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+ if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are correct!***" )
+ else:
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+ #============================= Ping Test ========================
+ # wait until all MultiPointToSinglePoint
+ time.sleep( 20 )
+ pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
+ pingTestResultsFile = \
+ "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" \
+ + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ pingTestResults = main.QuaggaCliHost.pingTest(
+ "1.168.30.100", pingTestScript, pingTestResultsFile )
+ main.log.info( pingTestResults )
+
+ # ping test
+
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+
+ # main.log.info( "main.ONOScli.get_routes_num() = " )
+ # main.log.info( main.ONOScli.getRoutesNum() )
+ # utilities.assertEquals( expect="Total SDN-IP routes = 1", actual=
+ # main.ONOScli.getRoutesNum(),
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after deleting wrong!***" )
+
+ main.step( "Check intents after deleting routes" )
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+ routeIntentsActual = \
+ main.QuaggaCliHost3.extractActualRouteIntents(
+ getIntentsResult )
+ main.log.info( "main.ONOScli.intents()= " )
+ main.log.info( routeIntentsActual )
+ utilities.assertEquals(
+ expect="[]", actual=str( routeIntentsActual ),
+ onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
+ 0, correct!***",
+ onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
+ 0, wrong!***" )
+
+ if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after deleting routes \
+ correct!***" )
+ else:
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after deleting routes \
+ wrong!***" )
+
+ time.sleep( 20 )
+ pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
+ pingTestResultsFile = \
+ "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" \
+ + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ pingTestResults = main.QuaggaCliHost.pingTest(
+ "1.168.30.100", pingTestScript, pingTestResultsFile )
+ main.log.info( pingTestResults )
+ time.sleep( 30 )
+
+ # main.step( "Test whether Mininet is started" )
+ # main.Mininet2.handle.sendline( "xterm host1" )
+ # main.Mininet2.handle.expect( "mininet>" )
+
+ def CASE2( self, main ):
+ """
+ Test the SDN-IP functionality
+ allRoutesExpected: all expected routes for all BGP peers
+ routeIntentsExpected: all expected MultiPointToSinglePointIntent \
+ intents
+ bgpIntentsExpected: expected PointToPointIntent intents
+ allRoutesActual: all routes from ONOS LCI
+ routeIntentsActual: actual MultiPointToSinglePointIntent intents \
+ from ONOS CLI
+ bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
+ """
+ import time
+ import json
+ from operator import eq
+ from time import localtime, strftime
+
+ main.case(
+ "The test case is to help to setup the TestON environment and \
+ test new drivers" )
+ SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+
+ main.log.info( "Generate prefixes for host3" )
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4
+
+ main.log.report( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftLogs()
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Set cell for ONOS-cli environment" )
+ main.ONOScli.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ # main.log.report( "Removing raft logs" )
+ # main.ONOSbench.onosRemoveRaftLogs()
+ # main.log.report( "Uninstalling ONOS" )
+ # main.ONOSbench.onosUninstall( ONOS1Ip )
+ main.step( "Creating ONOS package" )
+ # packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ # onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
+ # node=ONOS1Ip )
+
+ main.step( "Checking if ONOS is up yet" )
+ # time.sleep( 60 )
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ main.step( "Start ONOS-cli" )
+ main.ONOScli.startOnosCli( ONOS1Ip )
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ main.log.info( "Installing sdn-ip feature" )
+ main.ONOScli.featureInstall( "onos-app-sdnip" )
+ time.sleep( 10 )
+
+ main.step( "Check BGP PointToPointIntent intents installed" )
+ # bgp intents expected
+ bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
+ SDNIPJSONFILEPATH )
+ # get BGP intents from ONOS CLI
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+ bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
+ getIntentsResult )
+
+ bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
+ bgpIntentsStrActual = str( bgpIntentsActual )
+ main.log.info( "PointToPointIntent intents expected:" )
+ main.log.info( bgpIntentsStrExpected )
+ main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
+ main.log.info( bgpIntentsStrActual )
+
+ utilities.assertEquals(
+ expect=True,
+ actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
+ onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
+ onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+ if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are correct!***" )
+ else:
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
+ pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
+ # roundNum = 0;
+ # while( True ):
+ for roundNum in range( 1, 6 ):
+ # round = round + 1;
+ main.log.report( "The Round " + str( roundNum ) +
+ " test starts................................" )
+
+ main.step( "Login all BGP peers and add routes into peers" )
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info(
+ "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info(
+ "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+ time.sleep( 60 )
+
+ # get all routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+ # allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding wrong!***" )
+
+ time.sleep( 20 )
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+
+ main.step(
+ "Check MultiPointToSinglePointIntent intents installed" )
+ # routeIntentsExpected are generated when generating routes
+ # get route intents from ONOS CLI
+ routeIntentsActual = \
+ main.QuaggaCliHost3.extractActualRouteIntents(
+ getIntentsResult )
+ # routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
+ routeIntentsStrActual = str(
+ routeIntentsActual ).replace( 'u', "" )
+ main.log.info( "MultiPointToSinglePoint intents expected:" )
+ main.log.info( routeIntentsStrExpected )
+ main.log.info(
+ "MultiPointToSinglePoint intents get from ONOS CLI:" )
+ main.log.info( routeIntentsStrActual )
+ utilities.assertEquals(
+ expect=True,
+ actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
+ onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
+ correct!***",
+ onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
+ wrong!***" )
+
+ if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after adding routes \
+ correct!***" )
+ else:
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after adding routes \
+ wrong!***" )
+
+ #============================= Ping Test ========================
+ # wait until all MultiPointToSinglePoint
+ time.sleep( 20 )
+ # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
+ pingTestResultsFile = \
+ "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
+ + str( roundNum ) + "-ping-results-before-delete-routes-" \
+ + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ pingTestResults = main.QuaggaCliHost.pingTest(
+ "1.168.30.100", pingTestScript, pingTestResultsFile )
+ main.log.info( pingTestResults )
+ # ping test
+
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.log.info( "Delete routes to Quagga on host3" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.log.info( "Delete routes to Quagga on host4" )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after deleting wrong!***" )
+
+ main.step( "Check intents after deleting routes" )
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+ routeIntentsActual = \
+ main.QuaggaCliHost3.extractActualRouteIntents(
+ getIntentsResult )
+ main.log.info( "main.ONOScli.intents()= " )
+ main.log.info( routeIntentsActual )
+ utilities.assertEquals(
+ expect="[]", actual=str( routeIntentsActual ),
+ onpass=
+ "***MultiPointToSinglePoint Intents number in SDN-IP \
+ is 0, correct!***",
+ onfail="***MultiPointToSinglePoint Intents number in SDN-IP \
+ is 0, wrong!***" )
+
+ if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after deleting \
+ routes correct!***" )
+ else:
+ main.log.report(
+ "***MultiPointToSinglePoint Intents after deleting \
+ routes wrong!***" )
+
+ time.sleep( 20 )
+ # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
+ pingTestResultsFile = \
+ "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
+ + str( roundNum ) + "-ping-results-after-delete-routes-" \
+ + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ pingTestResults = main.QuaggaCliHost.pingTest(
+ "1.168.30.100", pingTestScript, pingTestResultsFile )
+ main.log.info( pingTestResults )
+ time.sleep( 30 )
+
diff --git a/TestON/tests/SdnIpSingleSwitch/SdnIpSingleSwitch.topo b/TestON/tests/SdnIpSingleSwitch/SdnIpSingleSwitch.topo
new file mode 100755
index 0000000..df9f7d2
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/SdnIpSingleSwitch.topo
@@ -0,0 +1,73 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>127.0.0.1</host>
+ <user>sdnip</user>
+ <password>sdnip</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ <home>~/onos</home>
+ </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli>
+ <host>127.0.0.1</host>
+ <user>sdnip</user>
+ <password>sdnip</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS>
+ <home>~/onos</home>
+ </COMPONENTS>
+ </ONOScli>
+
+ <ONOS1>
+ <host>127.0.0.1</host>
+ <user>sdnip</user>
+ <password>sdnip</password>
+ <type>OnosDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS>
+ <home>~/onos</home>
+ </COMPONENTS>
+ </ONOS1>
+
+ <QuaggaCliHost3>
+ <host>1.168.30.2</host>
+ <user>sdnip</user>
+ <password>sdnip</password>
+ <type>QuaggaCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </QuaggaCliHost3>
+ <QuaggaCliHost4>
+ <host>1.168.30.3</host>
+ <user>sdnip</user>
+ <password>sdnip</password>
+ <type>QuaggaCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </QuaggaCliHost4>
+ <QuaggaCliHost5>
+ <host>1.168.30.5</host>
+ <user>sdnip</user>
+ <password>sdnip</password>
+ <type>QuaggaCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </QuaggaCliHost5>
+ <QuaggaCliHost>
+ <host>1.168.30.100</host>
+ <user>sdnip</user>
+ <password>sdnip</password>
+ <type>QuaggaCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </QuaggaCliHost>
+
+
+ </COMPONENT>
+</TOPOLOGY>
+
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/SdnIpSingleSwitch/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/SdnIpSingleSwitch/__init__.py
diff --git a/TestON/tests/SdnIpSingleSwitch/addresses.json b/TestON/tests/SdnIpSingleSwitch/addresses.json
new file mode 100644
index 0000000..203de9b
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/addresses.json
@@ -0,0 +1,30 @@
+{
+ "addresses" : [
+ {
+ "dpid" : "00:00:00:00:00:00:00:a1",
+ "port" : "2",
+ "ips" : ["192.168.10.101/24"],
+ "mac" : "00:00:00:00:00:01"
+
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:a1",
+ "port" : "3",
+ "ips" : ["192.168.20.101/24"],
+ "mac" : "00:00:00:00:00:01"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:a1",
+ "port" : "4",
+ "ips" : ["192.168.30.101/24"],
+ "mac" : "00:00:00:00:00:01"
+ },
+ {
+ "dpid" : "00:00:00:00:00:00:00:a1",
+ "port" : "5",
+ "ips" : ["192.168.60.101/24"],
+ "mac" : "00:00:00:00:00:01"
+ }
+
+ ]
+}
diff --git a/TestON/tests/SdnIpSingleSwitch/intents.json b/TestON/tests/SdnIpSingleSwitch/intents.json
new file mode 100644
index 0000000..d17715f
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/intents.json
@@ -0,0 +1,1468 @@
+[
+ {
+ "id":"0xffffffffcb2cb6ec",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.10.101/32}, IPV4_DST{ip=192.168.10.1/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a3",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x140a3304",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a3, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.10.101/32}, IPV4_DST{ip=192.168.10.1/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a3, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffcb2d9828",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.10.1/32}, IPV4_DST{ip=192.168.10.101/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a3",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x1a89f138",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a3, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.10.1/32}, IPV4_DST{ip=192.168.10.101/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a3, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffd1418988",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.30.101/32}, IPV4_DST{ip=192.168.30.1/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a2",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x2cd85684",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a2, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.30.101/32}, IPV4_DST{ip=192.168.30.1/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a2, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x3122a56b",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.40.101/32}, IPV4_DST{ip=192.168.40.1/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a6",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x5874487",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a6, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a6, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.40.101/32}, IPV4_DST{ip=192.168.40.1/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a6, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a6, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x6ae96523",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.10.101/32}, IPV4_DST{ip=192.168.10.1/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a3",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x217361ed",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a3, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.10.101/32}, IPV4_DST{ip=192.168.10.1/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a3, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffaee31428",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.30.1/32}, IPV4_DST{ip=192.168.30.101/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a2",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x68cad35c",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a2, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.30.1/32}, IPV4_DST{ip=192.168.30.101/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a2, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffed2b21fa",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.20.1/32}, IPV4_DST{ip=192.168.20.101/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a5",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffffa5dbcf50",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a5, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.20.1/32}, IPV4_DST{ip=192.168.20.101/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a5, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x373774a3",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.60.101/32}, IPV4_DST{ip=192.168.60.1/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a4",
+ "port":"4"
+ },
+ "installable":[
+ {
+ "id":"0x5a75d509",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a4, portNumber=4}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.60.101/32}, IPV4_DST{ip=192.168.60.1/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a4, portNumber=4}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffff8d492c5d",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.10.1/32}, IPV4_DST{ip=192.168.10.101/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "ingress":{
+ "device":"of:00000000000000a3",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffffef408263",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a3, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.10.1/32}, IPV4_DST{ip=192.168.10.101/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a3, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffff8ce7d031",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.20.1/32}, IPV4_DST{ip=192.168.20.101/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a5",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffffb344fe39",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a5, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.20.1/32}, IPV4_DST{ip=192.168.20.101/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a5, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xf2665f1",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.30.1/32}, IPV4_DST{ip=192.168.30.101/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a2",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x5b61a473",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a2, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.30.1/32}, IPV4_DST{ip=192.168.30.101/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a2, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffd0e186b8",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.40.1/32}, IPV4_DST{ip=192.168.40.101/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a6",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x4d8d4942",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a6, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a6, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.40.1/32}, IPV4_DST{ip=192.168.40.101/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a6, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a6, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x3738d163",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.60.1/32}, IPV4_DST{ip=192.168.60.101/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "ingress":{
+ "device":"of:00000000000000a4",
+ "port":"4"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffff993b0fc9",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a4, portNumber=4}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.60.1/32}, IPV4_DST{ip=192.168.60.101/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a4, portNumber=4}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xfffffffff33e39a0",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.40.101/32}, IPV4_DST{ip=192.168.40.1/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a6",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffffda3dd5b2",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a6, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a6, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.40.101/32}, IPV4_DST{ip=192.168.40.1/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a6, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a6, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffff8ce60db9",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.20.101/32}, IPV4_DST{ip=192.168.20.1/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a5",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xfeca8b9",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a5, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.20.101/32}, IPV4_DST{ip=192.168.20.1/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a5, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x3124d881",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.40.1/32}, IPV4_DST{ip=192.168.40.101/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a6",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x40241a59",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a6, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a6, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.40.1/32}, IPV4_DST{ip=192.168.40.101/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a6, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a6, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffd141fa26",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.30.1/32}, IPV4_DST{ip=192.168.30.101/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "ingress":{
+ "device":"of:00000000000000a2",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x3018359e",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a2, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.30.1/32}, IPV4_DST{ip=192.168.30.101/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a2, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffaee2a38a",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.30.101/32}, IPV4_DST{ip=192.168.30.1/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a2",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x658af442",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a2, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.30.101/32}, IPV4_DST{ip=192.168.30.1/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a2, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffaf46b62f",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.20.1/32}, IPV4_DST{ip=192.168.20.101/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "ingress":{
+ "device":"of:00000000000000a5",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x7a92607b",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a5, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.20.1/32}, IPV4_DST{ip=192.168.20.101/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a5, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffff8d484b21",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.10.101/32}, IPV4_DST{ip=192.168.10.1/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a3",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffffe8c0c42f",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a3, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.10.101/32}, IPV4_DST{ip=192.168.10.1/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a3, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffed295f82",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.20.101/32}, IPV4_DST{ip=192.168.20.1/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a5",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x28379d0",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a5, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.20.101/32}, IPV4_DST{ip=192.168.20.1/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a5, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffdba23bce",
+ "type":"MultiPointToSinglePointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_DST{ip=172.16.30.0/24}, ETH_TYPE{ethType=800}]",
+ "treatment":"[ETH_DST{mac=00:00:00:00:03:01}]",
+ "ingress":[
+ {
+ "device":"of:00000000000000a3",
+ "port":"1"
+ },
+ {
+ "device":"of:00000000000000a4",
+ "port":"4"
+ },
+ {
+ "device":"of:00000000000000a6",
+ "port":"1"
+ },
+ {
+ "device":"of:00000000000000a5",
+ "port":"1"
+ }
+ ],
+ "egress":{
+ "device":"of:00000000000000a2",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x5e70036",
+ "type":"LinkCollectionIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a6, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_DST{ip=172.16.30.0/24}, ETH_TYPE{ethType=800}]",
+ "treatment":"[ETH_DST{mac=00:00:00:00:03:01}]",
+ "links":[
+ {
+ "src":{
+ "device":"of:00000000000000a4",
+ "port":"1"
+ },
+ "dst":{
+ "device":"of:00000000000000a2",
+ "port":"3"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a5",
+ "port":"2"
+ },
+ "dst":{
+ "device":"of:00000000000000a3",
+ "port":"4"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a6",
+ "port":"3"
+ },
+ "dst":{
+ "device":"of:00000000000000a4",
+ "port":"3"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a3",
+ "port":"3"
+ },
+ "dst":{
+ "device":"of:00000000000000a4",
+ "port":"2"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffaf44f3b7",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.20.101/32}, IPV4_DST{ip=192.168.20.1/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a5",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffffd73a0afb",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a5, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.20.101/32}, IPV4_DST{ip=192.168.20.1/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a5, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x751d3d2e",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.60.1/32}, IPV4_DST{ip=192.168.60.101/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a4",
+ "port":"4"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffffc4847e9e",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a4, portNumber=4}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.60.1/32}, IPV4_DST{ip=192.168.60.101/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a4, portNumber=4}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x3fb23806",
+ "type":"MultiPointToSinglePointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_DST{ip=2.0.0.0/24}, ETH_TYPE{ethType=800}]",
+ "treatment":"[ETH_DST{mac=00:00:00:00:03:01}]",
+ "ingress":[
+ {
+ "device":"of:00000000000000a3",
+ "port":"1"
+ },
+ {
+ "device":"of:00000000000000a4",
+ "port":"4"
+ },
+ {
+ "device":"of:00000000000000a6",
+ "port":"1"
+ },
+ {
+ "device":"of:00000000000000a5",
+ "port":"1"
+ }
+ ],
+ "egress":{
+ "device":"of:00000000000000a2",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x23d68afe",
+ "type":"LinkCollectionIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a6, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_DST{ip=2.0.0.0/24}, ETH_TYPE{ethType=800}]",
+ "treatment":"[ETH_DST{mac=00:00:00:00:03:01}]",
+ "links":[
+ {
+ "src":{
+ "device":"of:00000000000000a4",
+ "port":"1"
+ },
+ "dst":{
+ "device":"of:00000000000000a2",
+ "port":"3"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a5",
+ "port":"2"
+ },
+ "dst":{
+ "device":"of:00000000000000a3",
+ "port":"4"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a6",
+ "port":"3"
+ },
+ "dst":{
+ "device":"of:00000000000000a4",
+ "port":"3"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a3",
+ "port":"3"
+ },
+ "dst":{
+ "device":"of:00000000000000a4",
+ "port":"2"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x751be06e",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.60.101/32}, IPV4_DST{ip=192.168.60.1/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a4",
+ "port":"4"
+ },
+ "installable":[
+ {
+ "id":"0xffffffff85bf43de",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a4, portNumber=4}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.60.101/32}, IPV4_DST{ip=192.168.60.1/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a4, portNumber=4}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x6aea465f",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.10.1/32}, IPV4_DST{ip=192.168.10.101/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a3",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x27f32021",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a3, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.10.1/32}, IPV4_DST{ip=192.168.10.101/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a3, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xf25f553",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.30.101/32}, IPV4_DST{ip=192.168.30.1/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a2",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x5821c559",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a2, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.30.101/32}, IPV4_DST{ip=192.168.30.1/32}, IP_PROTO{protocol=1}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a2, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xfffffffff3406cb6",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.40.1/32}, IPV4_DST{ip=192.168.40.101/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "ingress":{
+ "device":"of:00000000000000a6",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x14daab84",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a6, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a6, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.40.1/32}, IPV4_DST{ip=192.168.40.101/32}, IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a6, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a6, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffd7d10b27",
+ "type":"MultiPointToSinglePointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_DST{ip=1.0.0.0/24}, ETH_TYPE{ethType=800}]",
+ "treatment":"[ETH_DST{mac=00:00:00:00:03:01}]",
+ "ingress":[
+ {
+ "device":"of:00000000000000a3",
+ "port":"1"
+ },
+ {
+ "device":"of:00000000000000a4",
+ "port":"4"
+ },
+ {
+ "device":"of:00000000000000a6",
+ "port":"1"
+ },
+ {
+ "device":"of:00000000000000a5",
+ "port":"1"
+ }
+ ],
+ "egress":{
+ "device":"of:00000000000000a2",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffff8f921bfd",
+ "type":"LinkCollectionIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a6, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_DST{ip=1.0.0.0/24}, ETH_TYPE{ethType=800}]",
+ "treatment":"[ETH_DST{mac=00:00:00:00:03:01}]",
+ "links":[
+ {
+ "src":{
+ "device":"of:00000000000000a4",
+ "port":"1"
+ },
+ "dst":{
+ "device":"of:00000000000000a2",
+ "port":"3"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a5",
+ "port":"2"
+ },
+ "dst":{
+ "device":"of:00000000000000a3",
+ "port":"4"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a6",
+ "port":"3"
+ },
+ "dst":{
+ "device":"of:00000000000000a4",
+ "port":"3"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a3",
+ "port":"3"
+ },
+ "dst":{
+ "device":"of:00000000000000a4",
+ "port":"2"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffa79364e5",
+ "type":"MultiPointToSinglePointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_DST{ip=3.0.0.0/24}, ETH_TYPE{ethType=800}]",
+ "treatment":"[ETH_DST{mac=00:00:00:00:03:01}]",
+ "ingress":[
+ {
+ "device":"of:00000000000000a3",
+ "port":"1"
+ },
+ {
+ "device":"of:00000000000000a4",
+ "port":"4"
+ },
+ {
+ "device":"of:00000000000000a6",
+ "port":"1"
+ },
+ {
+ "device":"of:00000000000000a5",
+ "port":"1"
+ }
+ ],
+ "egress":{
+ "device":"of:00000000000000a2",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffffb81af9ff",
+ "type":"LinkCollectionIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a6, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_DST{ip=3.0.0.0/24}, ETH_TYPE{ethType=800}]",
+ "treatment":"[ETH_DST{mac=00:00:00:00:03:01}]",
+ "links":[
+ {
+ "src":{
+ "device":"of:00000000000000a4",
+ "port":"1"
+ },
+ "dst":{
+ "device":"of:00000000000000a2",
+ "port":"3"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a5",
+ "port":"2"
+ },
+ "dst":{
+ "device":"of:00000000000000a3",
+ "port":"4"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a6",
+ "port":"3"
+ },
+ "dst":{
+ "device":"of:00000000000000a4",
+ "port":"3"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ },
+ {
+ "src":{
+ "device":"of:00000000000000a3",
+ "port":"3"
+ },
+ "dst":{
+ "device":"of:00000000000000a4",
+ "port":"2"
+ },
+ "type":"DIRECT",
+ "state":"ACTIVE",
+ "annotations":{
+
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x14d9eb65",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.60.1/32}, IPV4_DST{ip=192.168.60.101/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a4",
+ "port":"4"
+ },
+ "egress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0xffffffffd1edad87",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a4, portNumber=4}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.60.1/32}, IPV4_DST{ip=192.168.60.101/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a4, portNumber=4}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, dst=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a1, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0x14d88ea5",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.60.101/32}, IPV4_DST{ip=192.168.60.1/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a4",
+ "port":"4"
+ },
+ "installable":[
+ {
+ "id":"0xffffffff932872c7",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a4, portNumber=4}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.60.101/32}, IPV4_DST{ip=192.168.60.1/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a2, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a2, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a4, portNumber=1}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a4, portNumber=4}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ },
+ {
+ "id":"0xffffffffd0df53a2",
+ "type":"PointToPointIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "state":"INSTALLED",
+ "selector":"[IPV4_SRC{ip=192.168.40.101/32}, IPV4_DST{ip=192.168.40.1/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "ingress":{
+ "device":"of:00000000000000a1",
+ "port":"1"
+ },
+ "egress":{
+ "device":"of:00000000000000a6",
+ "port":"1"
+ },
+ "installable":[
+ {
+ "id":"0x12f07370",
+ "type":"PathIntent",
+ "appId":"org.onlab.onos.sdnip",
+ "resources":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a6, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a6, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ],
+ "selector":"[IPV4_SRC{ip=192.168.40.101/32}, IPV4_DST{ip=192.168.40.1/32}, IP_PROTO{protocol=6}, TCP_SRC{tcpPort=179}, ETH_TYPE{ethType=800}]",
+ "path":[
+ "DefaultEdgeLink{src=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, dst=HostLocation{elementId=of:00000000000000a1, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a1, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a3, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a3, portNumber=4}, dst=ConnectPoint{elementId=of:00000000000000a5, portNumber=2}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultLink{src=ConnectPoint{elementId=of:00000000000000a5, portNumber=3}, dst=ConnectPoint{elementId=of:00000000000000a6, portNumber=4}, type=DIRECT, state=ACTIVE, durable=false}",
+ "DefaultEdgeLink{src=HostLocation{elementId=of:00000000000000a6, portNumber=1}, dst=ConnectPoint{elementId=00:00:00:00:00:00/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"
+ ]
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/TestON/tests/SdnIpSingleSwitch/sdnip.json b/TestON/tests/SdnIpSingleSwitch/sdnip.json
new file mode 100644
index 0000000..6f719cf
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/sdnip.json
@@ -0,0 +1,59 @@
+{
+
+ "bgpPeers" : [
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:a1",
+ "attachmentPort" : "2",
+ "ipAddress" : "192.168.10.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:a1",
+ "attachmentPort" : "3",
+ "ipAddress" : "192.168.20.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:a1",
+ "attachmentPort" : "4",
+ "ipAddress" : "192.168.30.1"
+ },
+ {
+ "attachmentDpid" : "00:00:00:00:00:00:00:a1",
+ "attachmentPort" : "5",
+ "ipAddress" : "192.168.60.2"
+ }
+
+ ],
+ "bgpSpeakers" : [
+ {
+ "name" : "bgpSpeaker1",
+ "attachmentDpid" : "00:00:00:00:00:00:00:a1",
+ "attachmentPort" : "1",
+ "macAddress" : "00:00:00:00:00:01",
+ "interfaceAddresses" : [
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:a1",
+ "interfacePort" : "2",
+ "ipAddress" : "192.168.10.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:a1",
+ "interfacePort" : "3",
+ "ipAddress" : "192.168.20.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:a1",
+ "interfacePort" : "4",
+ "ipAddress" : "192.168.30.101"
+ },
+ {
+ "interfaceDpid" : "00:00:00:00:00:00:00:a1",
+ "interfacePort" : "5",
+ "ipAddress" : "192.168.60.101"
+ }
+
+ ]
+
+ }
+
+ ]
+}
diff --git a/TestON/tests/SdnIpSingleSwitch/topology/SdnIpSingleSwitchMininet.py b/TestON/tests/SdnIpSingleSwitch/topology/SdnIpSingleSwitchMininet.py
new file mode 100755
index 0000000..6befc1b
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/topology/SdnIpSingleSwitchMininet.py
@@ -0,0 +1,333 @@
+#!/usr/bin/python
+
+"""
+Start up the SDN-IP demo topology
+"""
+
+"""
+AS1 = 64513, (SDN AS)
+AS2 = 64514, reachable by 192.168.10.1, 192.168.20.1
+AS3 = 64516, reachable by 192.168.30.1
+AS4 = 64517, reachable by 192.168.40.1
+AS6 = 64520, reachable by 192.168.60.2, (route server 192.168.60.1)
+"""
+
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+
+import os.path
+import time
+from subprocess import Popen, STDOUT, PIPE
+
+QUAGGA_DIR = '/usr/lib/quagga'
+#QUAGGA_DIR = '/usr/local/sbin'
+QUAGGA_RUN_DIR = '/usr/local/var/run/quagga'
+
+
+class SDNIpModifiedTopo( Topo ):
+ "SDN Ip Modified Topology"
+
+ def __init__( self, *args, **kwargs ):
+ global numHost101
+ global numHost200
+ numHost101 = 101
+ numHost200 = 200
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='00000000000000a1')
+ #sw2 = self.addSwitch('sw2', dpid='00000000000000a2')
+ #sw3 = self.addSwitch('sw3', dpid='00000000000000a3')
+ #sw4 = self.addSwitch('sw4', dpid='00000000000000a4')
+ #sw5 = self.addSwitch('sw5', dpid='00000000000000a5')
+ #sw6 = self.addSwitch('sw6', dpid='00000000000000a6')
+ #add a switch for 3 quagga hosts
+ swTestOn = self.addSwitch('swTestOn', dpid='0000000000000102')
+ #Note this switch isn't part of the SDN topology
+ #We'll use the ovs-controller to turn this into a learning switch
+ as6sw = self.addSwitch('as6sw', dpid='00000000000000a7')
+
+ host1 = self.addHost( 'host1' )
+ root1 = self.addHost( 'root1', inNamespace=False , ip='0')
+ rootTestOn = self.addHost( 'rootTestOn', inNamespace=False, ip='0' )
+
+ #AS2 host
+ host3 = self.addHost( 'host3' )
+ as2host = self.addHost( 'as2host' )
+ #AS3 host
+ host4 = self.addHost( 'host4' )
+ as3host = self.addHost( 'as3host' )
+ #AS6 host
+ host5 = self.addHost( 'host5' )
+ as6host = self.addHost( 'as6host' )
+
+ self.addLink( host1, sw1 )
+ #Links to the multihomed AS
+ self.addLink( host3, sw1 )
+ self.addLink( host3, sw1 )
+ self.addLink( as2host, host3 )
+ #Single links to the remaining two ASes
+ self.addLink( host4, sw1 )
+ self.addLink( as3host, host4 )
+
+ #AS3-AS4 link
+ #self.addLink( host4, host5)
+ #Add new AS6 to its bridge
+ self.addLink( host5, as6sw )
+ self.addLink( as6host, host5 )
+ #test the host behind the router(behind the router server)
+# for i in range(1, 10):
+ # host = self.addHost('as6host%d' % i)
+ # self.addLink(host, as6router)
+
+ ## Internal Connection To Hosts ##
+ self.addLink( root1, host1 )
+
+ # self.addLink( sw1, sw2 )
+ # self.addLink( sw1, sw3 )
+ # self.addLink( sw2, sw4 )
+ # self.addLink( sw3, sw4 )
+ # self.addLink( sw3, sw5 )
+ # self.addLink( sw4, sw6 )
+ # self.addLink( sw5, sw6 )
+ self.addLink( as6sw, sw1 )
+
+
+ self.addLink(swTestOn, rootTestOn)
+ #self.addLink(swTestOn, host1)
+ self.addLink(swTestOn, host3)
+ self.addLink(swTestOn, host4)
+ self.addLink(swTestOn, host5)
+ self.addLink(swTestOn, as2host)
+
+
+ #self.addLink(rootTestOn, host4)
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def startquagga( host, num, config_file ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f %s -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, config_file, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ print zebra_cmd
+ print quagga_cmd
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+def startquaggahost5( host, num ):
+ info( '*** Starting Quagga on %s\n' % host )
+ zebra_cmd = 'sudo %s/zebra -d -f zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' % (QUAGGA_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+ quagga_cmd = 'sudo %s/bgpd -d -f ./as4quaggas/quagga%s.conf -z %s/zserv%s.api -i %s/bgpd%s.pid' % (QUAGGA_DIR, num, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num)
+
+ host.cmd( zebra_cmd )
+ host.cmd( quagga_cmd )
+
+
+def stopquagga( ):
+ quietRun( 'sudo pkill -9 -f bgpd' )
+ quietRun( 'sudo pkill -9 -f zebra' )
+
+def sdn1net():
+ topo = SDNIpModifiedTopo()
+ info( '*** Creating network\n' )
+ net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=RemoteController )
+
+ host1, host3, host4, host5 = net.get( 'host1', 'host3', 'host4', 'host5' )
+
+ #host100.setIP('1.168.30.' + str(i), 24, str(host100) + "-eth2")
+
+ #host500.setMAC('00:00:00:00:04:%d' % (i-101), 'host%d-eth0' %(i))
+ #add IP prefixes
+ #for j in range(0,121):
+ #host100.cmd('sudo ip addr add %s.0.40.%s/24 dev host%s-eth0' %(i,j,i))
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ #sw1 = net.get('sw1')
+ host1.setMAC('00:00:00:00:00:01', 'host1-eth0')
+ host1.cmd('ip addr add 192.168.20.101/24 dev host1-eth0')
+ host1.cmd('ip addr add 192.168.30.101/24 dev host1-eth0')
+ #host1.cmd('ip addr add 192.168.40.101/24 dev host1-eth0')
+ host1.cmd('ip addr add 192.168.60.101/24 dev host1-eth0')
+
+ # Net has to be start after adding the above link
+ net.start()
+
+ # Set up as6sw as a learning switch as quickly as possible so it
+ # hopefully doesn't connect to the actual controller
+ # TODO figure out how to change controller before starting switch
+ as6sw = net.get('as6sw')
+ as6sw.cmd('ovs-vsctl set-controller as6sw none')
+ as6sw.cmd('ovs-vsctl set-fail-mode as6sw standalone')
+
+
+ sw1 = net.get('sw1')
+ sw1.cmd('ovs-vsctl set-controller sw1 tcp:127.0.0.1:6633')
+# sw2.cmd('ovs-vsctl set-controller sw2 tcp:127.0.0.1:6633')
+# sw3.cmd('ovs-vsctl set-controller sw3 tcp:127.0.0.1:6633')
+# sw4.cmd('ovs-vsctl set-controller sw4 tcp:127.0.0.1:6633')
+# sw5.cmd('ovs-vsctl set-controller sw5 tcp:127.0.0.1:6633')
+# sw6.cmd('ovs-vsctl set-controller sw6 tcp:127.0.0.1:6633')
+
+
+ swTestOn = net.get('swTestOn')
+ swTestOn.cmd('ovs-vsctl set-controller swTestOn none')
+ swTestOn.cmd('ovs-vsctl set-fail-mode swTestOn standalone')
+
+ host1.defaultIntf().setIP('192.168.10.101/24')
+ # Run BGPd
+ #host1.cmd('%s -d -f %s' % (BGPD, BGPD_CONF))
+ #host1.cmd('/sbin/route add default gw 192.168.10.254 dev %s-eth0' % (host1.name))
+
+ # Configure new host interfaces
+ #host2.defaultIntf().setIP('172.16.10.2/24')
+ #host2.defaultIntf().setMAC('00:00:00:00:01:02')
+ #host2.cmd('/sbin/route add default gw 172.16.10.254 dev %s-eth0' % (host2.name))
+
+ # Set up AS2
+ host3.setIP('192.168.10.1', 24, 'host3-eth0')
+ #host3.cmd('sudo ip addr add 172.16.20.1/24 dev host3-eth0')
+ host3.setIP('192.168.20.1', 24, 'host3-eth1')
+ host3.setMAC('00:00:00:00:02:01', 'host3-eth0')
+ host3.setMAC('00:00:00:00:02:02', 'host3-eth1')
+ #host3.setIP('172.16.20.254', 24, 'host3-eth2')
+ host3.setIP('3.0.0.254', 8, 'host3-eth2')
+ host3.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+
+ host3.setIP('1.168.30.2', 24, 'host3-eth3')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_ignore=1')
+ host3.cmd('sysctl net.ipv4.conf.all.arp_announce=1')
+ as2host = net.get('as2host')
+ #as2host.defaultIntf().setIP('172.16.20.1/24')
+ for i in range(0, 20):
+ as2host.cmd('sudo ip addr add 3.0.%d.1/24 dev as2host-eth0' %i)
+ as2host.setIP('1.168.30.100', 24, 'as2host-eth1')
+
+ as2host.cmd('ip route add default via 3.0.0.254')
+
+ # Set up AS3
+ host4.setIP('192.168.30.1', 24, 'host4-eth0')
+ host4.setMAC('00:00:00:00:03:01', 'host4-eth0')
+ host4.setIP('4.0.0.254', 8, 'host4-eth1')
+ host4.setMAC('00:00:00:00:03:99', 'host4-eth1')
+ host4.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ as3host = net.get('as3host')
+ for i in range(0, 20):
+ as3host.cmd('sudo ip addr add 4.0.%d.1/24 dev as3host-eth0' %i)
+ as3host.cmd('ip route add default via 4.0.0.254')
+
+ #root space
+ host4.setIP('1.168.30.3', 24, 'host4-eth2')
+ host4.setMAC('00:00:00:00:03:03', 'host4-eth2')
+
+ # Set up AS4
+ #as4host = net.get('as4host')
+ #as4host.defaultIntf().setIP('172.16.40.1/24')
+ #as4host.cmd('ip route add default via 172.16.40.254')
+
+ # setup interface address for 100 quagga hosts
+ time.sleep(10)
+ #for i in range(numHost101, numHost200 + 1):
+ #host100 = net.get('host' + str(i))
+ #host100.cmd(str(i)+'.0.1.254', 24, 'host'+str(i)+'-eth1')
+ #as4host100 = net.get('as4host%s' %(i))
+ #as4host100.defaultIntf().setIP(str(i) + '.0.0.1/24')
+ #as4host100.cmd('ip route add default via ' + str(i) + '.0.0.254')
+ #for j in range(0, 100):
+ #as4host100.cmd('sudo ip addr add %d.0.%d.1/24 dev %s-eth0' %(i, j, as4host100))
+
+ # Set up AS6 - This has a router and a route server
+ #as6rs, host5 = net.get('as6rs', 'host5')
+ host5 = net.get('host5')
+ #as6rs.setIP('192.168.60.1', 24, 'as6rs-eth0')
+ #as6rs.setMAC('00:00:00:00:06:01', 'as6rs-eth0')
+ host5.setIP('192.168.60.2', 24, 'host5-eth0')
+ host5.setMAC('00:00:00:00:06:02', 'host5-eth0')
+ #as6router.setIP('172.16.60.254', 24, 'as6router-eth1')
+ host5.setIP('5.0.0.254', 8, 'host5-eth1')
+ host5.cmd('sysctl net.ipv4.conf.all.forwarding=1')
+ host5.setIP('1.168.30.5', 24, 'host5-eth2')
+ host5.setMAC('00:00:00:00:06:05', 'host5-eth2')
+
+ as6host = net.get('as6host')
+ #as6host.defaultIntf().setIP('5.0.0.1/24')
+ for i in range(0, 10):
+ as6host.cmd('sudo ip addr add 5.0.%d.1/24 dev as6host-eth0' %i)
+ as6host.cmd('ip route add default via 5.0.0.254')
+
+ # test the host in the as6
+ #for i in range(1, 10):
+ # baseip = (i-1)*4
+ # host = net.get('as6host%d' % i)
+ # host.defaultIntf().setIP('172.16.70.%d/24' % (baseip+1))
+ # host.cmd('ip route add default via 172.16.70.%d' % (baseip+2))
+ # as6router.setIP('172.16.70.%d' % (baseip+2), 30, 'as6router-eth%d' % (i+1))
+
+ # Start Quagga on border routers
+ startquagga(host3, 1, 'quagga1.conf')
+ startquagga(host4, 2, 'quagga2.conf')
+ #for i in range(numHost101, numHost200 + 1):
+ #host100=net.get('host%d' % (i))
+ #startquaggahost5(host100, i)
+
+ #startquagga(as6rs, 4, 'quagga-as6-rs.conf')
+ startquagga(host5, 5, 'quagga-as6.conf')
+
+ #root1, root2, rootTestOn = net.get( 'root1', 'root2', 'rootTestOn' )
+ root1, rootTestOn = net.get( 'root1', 'rootTestOn' )
+ host1.intf('host1-eth1').setIP('1.1.1.1/24')
+ root1.intf('root1-eth0').setIP('1.1.1.2/24')
+ #host2.intf('host2-eth1').setIP('1.1.2.1/24')
+ #root2.intf('root2-eth0').setIP('1.1.2.2/24')
+
+ #rootTestOn.cmd('ip addr add 1.168.30.102/24 dev rootTestOn-eth0')
+ rootTestOn.cmd('ip addr add 1.168.30.99/24 dev rootTestOn-eth0')
+
+ stopsshd()
+
+ startquagga(host1, 100, 'quagga-sdn-modified.conf')
+ hosts = [ host1, host3, host4, host5, as2host ];
+ #sshdHosts = sshdHosts + hosts
+ startsshds( hosts )
+ #
+ onos1 = '127.0.0.1'
+ forwarding1 = '%s:2000:%s:2000' % ('1.1.1.2', onos1)
+ root1.cmd( 'ssh -nNT -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % (forwarding1, onos1) )
+
+ # Forward 2605 to root namespace for easier access to SDN domain BGPd
+ # If root can ssh to itself without a password this should work
+ root1.cmd('ssh -N -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -L 2605:1.1.1.1:2605 1.1.1.1 &')
+ #time.sleep(3000000000)
+ CLI( net )
+
+ # Close the ssh port forwarding
+ #quietRun('sudo pkill -f 1.1.1.1')
+
+ stopsshd()
+ stopquagga()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'debug' )
+ sdn1net()
diff --git a/TestON/tests/SdnIpSingleSwitch/topology/quagga-as6-rs.conf b/TestON/tests/SdnIpSingleSwitch/topology/quagga-as6-rs.conf
new file mode 100644
index 0000000..1eac0dd
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/topology/quagga-as6-rs.conf
@@ -0,0 +1,32 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64520
+ bgp router-id 192.168.60.1
+ neighbor 192.168.60.101 remote-as 64513
+ neighbor 192.168.60.101 route-server-client
+ neighbor 192.168.60.2 remote-as 64521
+ neighbor 192.168.60.2 route-server-client
+! network 172.16.60.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/SdnIpSingleSwitch/topology/quagga-as6.conf b/TestON/tests/SdnIpSingleSwitch/topology/quagga-as6.conf
new file mode 100644
index 0000000..434f983
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/topology/quagga-as6.conf
@@ -0,0 +1,39 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64521
+ bgp router-id 192.168.60.2
+ neighbor 192.168.60.101 remote-as 64513
+! neighbor 192.168.60.1 remote-as 64520
+! neighbor 192.168.60.3 remote-as 64520
+! network 172.16.60.0/24
+! network 172.16.70.4/30
+ ! network 172.16.70.8/30
+ ! network 172.16.70.12/30
+ ! network 172.16.70.16/30
+ ! network 172.16.70.20/30
+ ! network 172.16.70.24/30
+ ! network 172.16.70.28/30
+ ! network 172.16.70.32/30
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/SdnIpSingleSwitch/topology/quagga-sdn-modified.conf b/TestON/tests/SdnIpSingleSwitch/topology/quagga-sdn-modified.conf
new file mode 100644
index 0000000..d334c2a
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/topology/quagga-sdn-modified.conf
@@ -0,0 +1,49 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+route-map AS65000 permit 1
+ set as-path prepend 65000
+!
+router bgp 64513
+ bgp router-id 192.168.10.101
+ timers bgp 1 3
+ !timers bgp 3 9
+ neighbor 192.168.10.1 remote-as 64514
+ neighbor 192.168.10.1 ebgp-multihop
+ neighbor 192.168.10.1 timers connect 5
+ neighbor 192.168.20.1 remote-as 64514
+ neighbor 192.168.20.1 ebgp-multihop
+ neighbor 192.168.20.1 timers connect 5
+ neighbor 192.168.20.1 route-map AS65000 in
+ neighbor 192.168.30.1 remote-as 64516
+ neighbor 192.168.30.1 ebgp-multihop
+ neighbor 192.168.30.1 timers connect 5
+ neighbor 192.168.60.2 remote-as 64521
+ neighbor 192.168.60.2 ebgp-multihop
+ neighbor 192.168.60.2 timers connect 5
+ neighbor 1.1.1.2 remote-as 64513
+ neighbor 1.1.1.2 port 2000
+ neighbor 1.1.1.2 timers connect 5
+
+
+
+ network 172.16.10.0/24
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/SdnIpSingleSwitch/topology/quagga-sdn.conf b/TestON/tests/SdnIpSingleSwitch/topology/quagga-sdn.conf
new file mode 100644
index 0000000..77392a6
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/topology/quagga-sdn.conf
@@ -0,0 +1,349 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+route-map AS65000 permit 1
+ set as-path prepend 65000
+!
+router bgp 64513
+ bgp router-id 192.168.10.101
+ timers bgp 1 3
+ !timers bgp 3 9
+ neighbor 192.168.10.1 remote-as 64514
+ neighbor 192.168.10.1 ebgp-multihop
+ neighbor 192.168.10.1 timers connect 5
+ neighbor 192.168.20.1 remote-as 64514
+ neighbor 192.168.20.1 ebgp-multihop
+ neighbor 192.168.20.1 timers connect 5
+ neighbor 192.168.20.1 route-map AS65000 in
+ neighbor 192.168.30.1 remote-as 64516
+ neighbor 192.168.30.1 ebgp-multihop
+ neighbor 192.168.30.1 timers connect 5
+ neighbor 192.168.60.1 remote-as 64520
+ neighbor 192.168.60.1 ebgp-multihop
+ neighbor 192.168.60.1 timers connect 5
+ neighbor 1.1.1.2 remote-as 64513
+ neighbor 1.1.1.2 port 2000
+ neighbor 1.1.1.2 timers connect 5
+
+
+neighbor 192.168.40.1 remote-as 65001
+neighbor 192.168.40.1 ebgp-multihop
+neighbor 192.168.40.1 timers connect 10
+neighbor 192.168.40.2 remote-as 65002
+neighbor 192.168.40.2 ebgp-multihop
+neighbor 192.168.40.2 timers connect 10
+neighbor 192.168.40.3 remote-as 65003
+neighbor 192.168.40.3 ebgp-multihop
+neighbor 192.168.40.3 timers connect 10
+neighbor 192.168.40.4 remote-as 65004
+neighbor 192.168.40.4 ebgp-multihop
+neighbor 192.168.40.4 timers connect 10
+neighbor 192.168.40.5 remote-as 65005
+neighbor 192.168.40.5 ebgp-multihop
+neighbor 192.168.40.5 timers connect 10
+neighbor 192.168.40.6 remote-as 65006
+neighbor 192.168.40.6 ebgp-multihop
+neighbor 192.168.40.6 timers connect 10
+neighbor 192.168.40.7 remote-as 65007
+neighbor 192.168.40.7 ebgp-multihop
+neighbor 192.168.40.7 timers connect 10
+neighbor 192.168.40.8 remote-as 65008
+neighbor 192.168.40.8 ebgp-multihop
+neighbor 192.168.40.8 timers connect 10
+neighbor 192.168.40.9 remote-as 65009
+neighbor 192.168.40.9 ebgp-multihop
+neighbor 192.168.40.9 timers connect 10
+neighbor 192.168.40.10 remote-as 65010
+neighbor 192.168.40.10 ebgp-multihop
+neighbor 192.168.40.10 timers connect 10
+neighbor 192.168.40.11 remote-as 65011
+neighbor 192.168.40.11 ebgp-multihop
+neighbor 192.168.40.11 timers connect 10
+neighbor 192.168.40.12 remote-as 65012
+neighbor 192.168.40.12 ebgp-multihop
+neighbor 192.168.40.12 timers connect 10
+neighbor 192.168.40.13 remote-as 65013
+neighbor 192.168.40.13 ebgp-multihop
+neighbor 192.168.40.13 timers connect 10
+neighbor 192.168.40.14 remote-as 65014
+neighbor 192.168.40.14 ebgp-multihop
+neighbor 192.168.40.14 timers connect 10
+neighbor 192.168.40.15 remote-as 65015
+neighbor 192.168.40.15 ebgp-multihop
+neighbor 192.168.40.15 timers connect 10
+neighbor 192.168.40.16 remote-as 65016
+neighbor 192.168.40.16 ebgp-multihop
+neighbor 192.168.40.16 timers connect 10
+neighbor 192.168.40.17 remote-as 65017
+neighbor 192.168.40.17 ebgp-multihop
+neighbor 192.168.40.17 timers connect 10
+neighbor 192.168.40.18 remote-as 65018
+neighbor 192.168.40.18 ebgp-multihop
+neighbor 192.168.40.18 timers connect 10
+neighbor 192.168.40.19 remote-as 65019
+neighbor 192.168.40.19 ebgp-multihop
+neighbor 192.168.40.19 timers connect 10
+neighbor 192.168.40.20 remote-as 65020
+neighbor 192.168.40.20 ebgp-multihop
+neighbor 192.168.40.20 timers connect 10
+neighbor 192.168.40.21 remote-as 65021
+neighbor 192.168.40.21 ebgp-multihop
+neighbor 192.168.40.21 timers connect 10
+neighbor 192.168.40.22 remote-as 65022
+neighbor 192.168.40.22 ebgp-multihop
+neighbor 192.168.40.22 timers connect 10
+neighbor 192.168.40.23 remote-as 65023
+neighbor 192.168.40.23 ebgp-multihop
+neighbor 192.168.40.23 timers connect 10
+neighbor 192.168.40.24 remote-as 65024
+neighbor 192.168.40.24 ebgp-multihop
+neighbor 192.168.40.24 timers connect 10
+neighbor 192.168.40.25 remote-as 65025
+neighbor 192.168.40.25 ebgp-multihop
+neighbor 192.168.40.25 timers connect 10
+neighbor 192.168.40.26 remote-as 65026
+neighbor 192.168.40.26 ebgp-multihop
+neighbor 192.168.40.26 timers connect 10
+neighbor 192.168.40.27 remote-as 65027
+neighbor 192.168.40.27 ebgp-multihop
+neighbor 192.168.40.27 timers connect 10
+neighbor 192.168.40.28 remote-as 65028
+neighbor 192.168.40.28 ebgp-multihop
+neighbor 192.168.40.28 timers connect 10
+neighbor 192.168.40.29 remote-as 65029
+neighbor 192.168.40.29 ebgp-multihop
+neighbor 192.168.40.29 timers connect 10
+neighbor 192.168.40.30 remote-as 65030
+neighbor 192.168.40.30 ebgp-multihop
+neighbor 192.168.40.30 timers connect 10
+neighbor 192.168.40.31 remote-as 65031
+neighbor 192.168.40.31 ebgp-multihop
+neighbor 192.168.40.31 timers connect 10
+neighbor 192.168.40.32 remote-as 65032
+neighbor 192.168.40.32 ebgp-multihop
+neighbor 192.168.40.32 timers connect 10
+neighbor 192.168.40.33 remote-as 65033
+neighbor 192.168.40.33 ebgp-multihop
+neighbor 192.168.40.33 timers connect 10
+neighbor 192.168.40.34 remote-as 65034
+neighbor 192.168.40.34 ebgp-multihop
+neighbor 192.168.40.34 timers connect 10
+neighbor 192.168.40.35 remote-as 65035
+neighbor 192.168.40.35 ebgp-multihop
+neighbor 192.168.40.35 timers connect 10
+neighbor 192.168.40.36 remote-as 65036
+neighbor 192.168.40.36 ebgp-multihop
+neighbor 192.168.40.36 timers connect 10
+neighbor 192.168.40.37 remote-as 65037
+neighbor 192.168.40.37 ebgp-multihop
+neighbor 192.168.40.37 timers connect 10
+neighbor 192.168.40.38 remote-as 65038
+neighbor 192.168.40.38 ebgp-multihop
+neighbor 192.168.40.38 timers connect 10
+neighbor 192.168.40.39 remote-as 65039
+neighbor 192.168.40.39 ebgp-multihop
+neighbor 192.168.40.39 timers connect 10
+neighbor 192.168.40.40 remote-as 65040
+neighbor 192.168.40.40 ebgp-multihop
+neighbor 192.168.40.40 timers connect 10
+neighbor 192.168.40.41 remote-as 65041
+neighbor 192.168.40.41 ebgp-multihop
+neighbor 192.168.40.41 timers connect 10
+neighbor 192.168.40.42 remote-as 65042
+neighbor 192.168.40.42 ebgp-multihop
+neighbor 192.168.40.42 timers connect 10
+neighbor 192.168.40.43 remote-as 65043
+neighbor 192.168.40.43 ebgp-multihop
+neighbor 192.168.40.43 timers connect 10
+neighbor 192.168.40.44 remote-as 65044
+neighbor 192.168.40.44 ebgp-multihop
+neighbor 192.168.40.44 timers connect 10
+neighbor 192.168.40.45 remote-as 65045
+neighbor 192.168.40.45 ebgp-multihop
+neighbor 192.168.40.45 timers connect 10
+neighbor 192.168.40.46 remote-as 65046
+neighbor 192.168.40.46 ebgp-multihop
+neighbor 192.168.40.46 timers connect 10
+neighbor 192.168.40.47 remote-as 65047
+neighbor 192.168.40.47 ebgp-multihop
+neighbor 192.168.40.47 timers connect 10
+neighbor 192.168.40.48 remote-as 65048
+neighbor 192.168.40.48 ebgp-multihop
+neighbor 192.168.40.48 timers connect 10
+neighbor 192.168.40.49 remote-as 65049
+neighbor 192.168.40.49 ebgp-multihop
+neighbor 192.168.40.49 timers connect 10
+neighbor 192.168.40.50 remote-as 65050
+neighbor 192.168.40.50 ebgp-multihop
+neighbor 192.168.40.50 timers connect 10
+neighbor 192.168.40.51 remote-as 65051
+neighbor 192.168.40.51 ebgp-multihop
+neighbor 192.168.40.51 timers connect 10
+neighbor 192.168.40.52 remote-as 65052
+neighbor 192.168.40.52 ebgp-multihop
+neighbor 192.168.40.52 timers connect 10
+neighbor 192.168.40.53 remote-as 65053
+neighbor 192.168.40.53 ebgp-multihop
+neighbor 192.168.40.53 timers connect 10
+neighbor 192.168.40.54 remote-as 65054
+neighbor 192.168.40.54 ebgp-multihop
+neighbor 192.168.40.54 timers connect 10
+neighbor 192.168.40.55 remote-as 65055
+neighbor 192.168.40.55 ebgp-multihop
+neighbor 192.168.40.55 timers connect 10
+neighbor 192.168.40.56 remote-as 65056
+neighbor 192.168.40.56 ebgp-multihop
+neighbor 192.168.40.56 timers connect 10
+neighbor 192.168.40.57 remote-as 65057
+neighbor 192.168.40.57 ebgp-multihop
+neighbor 192.168.40.57 timers connect 10
+neighbor 192.168.40.58 remote-as 65058
+neighbor 192.168.40.58 ebgp-multihop
+neighbor 192.168.40.58 timers connect 10
+neighbor 192.168.40.59 remote-as 65059
+neighbor 192.168.40.59 ebgp-multihop
+neighbor 192.168.40.59 timers connect 10
+neighbor 192.168.40.60 remote-as 65060
+neighbor 192.168.40.60 ebgp-multihop
+neighbor 192.168.40.60 timers connect 10
+neighbor 192.168.40.61 remote-as 65061
+neighbor 192.168.40.61 ebgp-multihop
+neighbor 192.168.40.61 timers connect 10
+neighbor 192.168.40.62 remote-as 65062
+neighbor 192.168.40.62 ebgp-multihop
+neighbor 192.168.40.62 timers connect 10
+neighbor 192.168.40.63 remote-as 65063
+neighbor 192.168.40.63 ebgp-multihop
+neighbor 192.168.40.63 timers connect 10
+neighbor 192.168.40.64 remote-as 65064
+neighbor 192.168.40.64 ebgp-multihop
+neighbor 192.168.40.64 timers connect 10
+neighbor 192.168.40.65 remote-as 65065
+neighbor 192.168.40.65 ebgp-multihop
+neighbor 192.168.40.65 timers connect 10
+neighbor 192.168.40.66 remote-as 65066
+neighbor 192.168.40.66 ebgp-multihop
+neighbor 192.168.40.66 timers connect 10
+neighbor 192.168.40.67 remote-as 65067
+neighbor 192.168.40.67 ebgp-multihop
+neighbor 192.168.40.67 timers connect 10
+neighbor 192.168.40.68 remote-as 65068
+neighbor 192.168.40.68 ebgp-multihop
+neighbor 192.168.40.68 timers connect 10
+neighbor 192.168.40.69 remote-as 65069
+neighbor 192.168.40.69 ebgp-multihop
+neighbor 192.168.40.69 timers connect 10
+neighbor 192.168.40.70 remote-as 65070
+neighbor 192.168.40.70 ebgp-multihop
+neighbor 192.168.40.70 timers connect 10
+neighbor 192.168.40.71 remote-as 65071
+neighbor 192.168.40.71 ebgp-multihop
+neighbor 192.168.40.71 timers connect 10
+neighbor 192.168.40.72 remote-as 65072
+neighbor 192.168.40.72 ebgp-multihop
+neighbor 192.168.40.72 timers connect 10
+neighbor 192.168.40.73 remote-as 65073
+neighbor 192.168.40.73 ebgp-multihop
+neighbor 192.168.40.73 timers connect 10
+neighbor 192.168.40.74 remote-as 65074
+neighbor 192.168.40.74 ebgp-multihop
+neighbor 192.168.40.74 timers connect 10
+neighbor 192.168.40.75 remote-as 65075
+neighbor 192.168.40.75 ebgp-multihop
+neighbor 192.168.40.75 timers connect 10
+neighbor 192.168.40.76 remote-as 65076
+neighbor 192.168.40.76 ebgp-multihop
+neighbor 192.168.40.76 timers connect 10
+neighbor 192.168.40.77 remote-as 65077
+neighbor 192.168.40.77 ebgp-multihop
+neighbor 192.168.40.77 timers connect 10
+neighbor 192.168.40.78 remote-as 65078
+neighbor 192.168.40.78 ebgp-multihop
+neighbor 192.168.40.78 timers connect 10
+neighbor 192.168.40.79 remote-as 65079
+neighbor 192.168.40.79 ebgp-multihop
+neighbor 192.168.40.79 timers connect 10
+neighbor 192.168.40.80 remote-as 65080
+neighbor 192.168.40.80 ebgp-multihop
+neighbor 192.168.40.80 timers connect 10
+neighbor 192.168.40.81 remote-as 65081
+neighbor 192.168.40.81 ebgp-multihop
+neighbor 192.168.40.81 timers connect 10
+neighbor 192.168.40.82 remote-as 65082
+neighbor 192.168.40.82 ebgp-multihop
+neighbor 192.168.40.82 timers connect 10
+neighbor 192.168.40.83 remote-as 65083
+neighbor 192.168.40.83 ebgp-multihop
+neighbor 192.168.40.83 timers connect 10
+neighbor 192.168.40.84 remote-as 65084
+neighbor 192.168.40.84 ebgp-multihop
+neighbor 192.168.40.84 timers connect 10
+neighbor 192.168.40.85 remote-as 65085
+neighbor 192.168.40.85 ebgp-multihop
+neighbor 192.168.40.85 timers connect 10
+neighbor 192.168.40.86 remote-as 65086
+neighbor 192.168.40.86 ebgp-multihop
+neighbor 192.168.40.86 timers connect 10
+neighbor 192.168.40.87 remote-as 65087
+neighbor 192.168.40.87 ebgp-multihop
+neighbor 192.168.40.87 timers connect 10
+neighbor 192.168.40.88 remote-as 65088
+neighbor 192.168.40.88 ebgp-multihop
+neighbor 192.168.40.88 timers connect 10
+neighbor 192.168.40.89 remote-as 65089
+neighbor 192.168.40.89 ebgp-multihop
+neighbor 192.168.40.89 timers connect 10
+neighbor 192.168.40.90 remote-as 65090
+neighbor 192.168.40.90 ebgp-multihop
+neighbor 192.168.40.90 timers connect 10
+neighbor 192.168.40.91 remote-as 65091
+neighbor 192.168.40.91 ebgp-multihop
+neighbor 192.168.40.91 timers connect 10
+neighbor 192.168.40.92 remote-as 65092
+neighbor 192.168.40.92 ebgp-multihop
+neighbor 192.168.40.92 timers connect 10
+neighbor 192.168.40.93 remote-as 65093
+neighbor 192.168.40.93 ebgp-multihop
+neighbor 192.168.40.93 timers connect 10
+neighbor 192.168.40.94 remote-as 65094
+neighbor 192.168.40.94 ebgp-multihop
+neighbor 192.168.40.94 timers connect 10
+neighbor 192.168.40.95 remote-as 65095
+neighbor 192.168.40.95 ebgp-multihop
+neighbor 192.168.40.95 timers connect 10
+neighbor 192.168.40.96 remote-as 65096
+neighbor 192.168.40.96 ebgp-multihop
+neighbor 192.168.40.96 timers connect 10
+neighbor 192.168.40.97 remote-as 65097
+neighbor 192.168.40.97 ebgp-multihop
+neighbor 192.168.40.97 timers connect 10
+neighbor 192.168.40.98 remote-as 65098
+neighbor 192.168.40.98 ebgp-multihop
+neighbor 192.168.40.98 timers connect 10
+neighbor 192.168.40.99 remote-as 65099
+neighbor 192.168.40.99 ebgp-multihop
+neighbor 192.168.40.99 timers connect 10
+neighbor 192.168.40.100 remote-as 65100
+neighbor 192.168.40.100 ebgp-multihop
+neighbor 192.168.40.100 timers connect 10
+
+ network 172.16.10.0/24
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/SdnIpSingleSwitch/topology/quagga1.conf b/TestON/tests/SdnIpSingleSwitch/topology/quagga1.conf
new file mode 100644
index 0000000..264f85e
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/topology/quagga1.conf
@@ -0,0 +1,32 @@
+!
+! Zebra configuration saved from vty
+! 2014/11/25 11:22:24
+!
+hostname bgpd
+password hello
+log stdout
+!
+router bgp 64514
+ bgp router-id 192.168.10.1
+! network 3.0.0.0/24
+! network 3.0.1.0/24
+! network 3.0.2.0/24
+! network 3.0.3.0/24
+! network 3.0.4.0/24
+! network 3.0.5.0/24
+! network 3.0.6.0/24
+! network 3.0.7.0/24
+! network 3.0.8.0/24
+! network 3.0.9.0/24
+ neighbor 192.168.20.101 remote-as 64513
+ neighbor 192.168.20.101 route-map PREPEND2 in
+ neighbor 192.168.20.101 route-map PREPEND2 out
+!
+route-map PREPEND1 permit 1
+ set as-path prepend 64514
+!
+route-map PREPEND2 permit 2
+ set as-path prepend 64514 64514
+!
+line vty
+!
diff --git a/TestON/tests/SdnIpSingleSwitch/topology/quagga2.conf b/TestON/tests/SdnIpSingleSwitch/topology/quagga2.conf
new file mode 100644
index 0000000..20ca9e4
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/topology/quagga2.conf
@@ -0,0 +1,31 @@
+! -*- bgp -*-
+!
+! BGPd sample configuratin file
+!
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
+!
+hostname bgpd
+password hello
+!enable password please-set-at-here
+!
+!bgp mulitple-instance
+!
+router bgp 64516
+ bgp router-id 192.168.30.1
+! timers bgp 1 3
+ neighbor 192.168.30.101 remote-as 64513
+! neighbor 192.168.50.2 remote-as 65001
+! network 172.16.30.0/24
+! neighbor 10.0.0.2 route-map set-nexthop out
+! neighbor 10.0.0.2 ebgp-multihop
+! neighbor 10.0.0.2 next-hop-self
+!
+! access-list all permit any
+!
+!route-map set-nexthop permit 10
+! match ip address all
+! set ip next-hop 10.0.0.1
+!
+!log file /usr/local/var/log/quagga/bgpd.log
+!
+log stdout
diff --git a/TestON/tests/SdnIpSingleSwitch/topology/zebra.conf b/TestON/tests/SdnIpSingleSwitch/topology/zebra.conf
new file mode 100644
index 0000000..0f8e3a2
--- /dev/null
+++ b/TestON/tests/SdnIpSingleSwitch/topology/zebra.conf
@@ -0,0 +1,26 @@
+! -*- zebra -*-
+!
+! zebra sample configuration file
+!
+! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
+!
+hostname zebra
+password hello
+enable password 0fw0rk
+log stdout
+!
+! Interfaces description.
+!
+!interface lo
+! description test of desc.
+!
+!interface sit0
+! multicast
+
+!
+! Static default route sample.
+!
+!ip route 0.0.0.0/0 203.181.89.241
+!
+
+!log file /usr/local/var/log/quagga/zebra.log
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/TopoConvNext/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/TopoConvNext/__init__.py
diff --git a/TestON/tests/TopoPerfNext/Backup/TopoPerfNext.py b/TestON/tests/TopoPerfNext/Backup/TopoPerfNext.py
deleted file mode 100644
index cc40b94..0000000
--- a/TestON/tests/TopoPerfNext/Backup/TopoPerfNext.py
+++ /dev/null
@@ -1,1710 +0,0 @@
-#TopoPerfNext
-#
-#Topology Performance test for ONOS-next
-#
-#andrew@onlab.us
-#
-#If your machine does not come with numpy
-#run the following command:
-#sudo apt-get install python-numpy python-scipy
-
-import time
-import sys
-import os
-import re
-
-class TopoPerfNext:
- def __init__(self):
- self.default = ''
-
- def CASE1(self, main):
- '''
- ONOS startup sequence
- '''
- import time
-
- ## Global cluster count for scale-out purposes
- global cluster_count
- #Set initial cluster count
- cluster_count = 1
- ##
-
- cell_name = main.params['ENV']['cellName']
-
- git_pull = main.params['GIT']['autoPull']
- checkout_branch = main.params['GIT']['checkout']
-
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
-
- #### Hardcoded ONOS nodes particular to my env ####
- ONOS4_ip = "10.128.174.4"
- ONOS5_ip = "10.128.174.5"
- ONOS6_ip = "10.128.174.6"
- ONOS7_ip = "10.128.174.7"
- #### ####
-
- MN1_ip = main.params['MN']['ip1']
- BENCH_ip = main.params['BENCH']['ip']
-
- topo_cfg_file = main.params['TEST']['topo_config_file']
- topo_cfg_name = main.params['TEST']['topo_config_name']
-
- main.case("Setting up test environment")
- main.log.info("Copying topology event accumulator config"+\
- " to ONOS /package/etc")
- main.ONOSbench.handle.sendline("cp ~/"+\
- topo_cfg_file+\
- " ~/ONOS/tools/package/etc/"+\
- topo_cfg_name)
- main.ONOSbench.handle.expect("\$")
-
- main.log.report("Setting up test environment")
-
- main.step("Cleaning previously installed ONOS if any")
- main.ONOSbench.onos_uninstall(node_ip=ONOS2_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS3_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS4_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS5_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS6_ip)
- main.ONOSbench.onos_uninstall(node_ip=ONOS7_ip)
-
- main.step("Creating cell file")
- cell_file_result = main.ONOSbench.create_cell_file(
- BENCH_ip, cell_name, MN1_ip, "onos-core,onos-app-metrics",
- ONOS1_ip)
-
- main.step("Applying cell file to environment")
- cell_apply_result = main.ONOSbench.set_cell(cell_name)
- verify_cell_result = main.ONOSbench.verify_cell()
-
- #NOTE: This step may be removed after proper
- # copy cat log functionality
- main.step("Removing raft/copy-cat logs from ONOS nodes")
- main.ONOSbench.onos_remove_raft_logs()
- time.sleep(30)
-
- main.step("Git checkout and pull "+checkout_branch)
- if git_pull == 'on':
- checkout_result = \
- main.ONOSbench.git_checkout(checkout_branch)
- pull_result = main.ONOSbench.git_pull()
- else:
- checkout_result = main.TRUE
- pull_result = main.TRUE
- main.log.info("Skipped git checkout and pull")
-
- main.log.report("Commit information - ")
- main.ONOSbench.get_version(report=True)
-
- main.step("Using mvn clean & install")
- mvn_result = main.ONOSbench.clean_install()
- mvn_result = main.TRUE
-
- main.step("Set cell for ONOS cli env")
- main.ONOS1cli.set_cell(cell_name)
- #main.ONOS2cli.set_cell(cell_name)
- #main.ONOS3cli.set_cell(cell_name)
-
- main.step("Creating ONOS package")
- package_result = main.ONOSbench.onos_package()
-
- main.step("Installing ONOS package")
- install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
- #install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
- #install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
-
- time.sleep(10)
-
- main.step("Start onos cli")
- cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
- #cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
- #cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
-
- utilities.assert_equals(expect=main.TRUE,
- actual= cell_file_result and cell_apply_result and\
- verify_cell_result and checkout_result and\
- pull_result and mvn_result and\
- install1_result, #and install2_result and\
- #install3_result,
- onpass="Test Environment setup successful",
- onfail="Failed to setup test environment")
-
- def CASE2(self, main):
- '''
- Assign s1 to ONOS1 and measure latency
-
- There are 4 levels of latency measurements to this test:
- 1) End-to-end measurement: Complete end-to-end measurement
- from TCP (SYN/ACK) handshake to Graph change
- 2) OFP-to-graph measurement: 'ONOS processing' snippet of
- measurement from OFP Vendor message to Graph change
- 3) OFP-to-device measurement: 'ONOS processing without
- graph change' snippet of measurement from OFP vendor
- message to Device change timestamp
- 4) T0-to-device measurement: Measurement that includes
- the switch handshake to devices timestamp without
- the graph view change. (TCP handshake -> Device
- change)
- '''
- import time
- import subprocess
- import json
- import requests
- import os
- import numpy
- global cluster_count
-
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS4_ip = main.params['CTRL']['ip4']
- ONOS5_ip = main.params['CTRL']['ip5']
- ONOS6_ip = main.params['CTRL']['ip6']
- ONOS7_ip = main.params['CTRL']['ip7']
-
- ONOS_user = main.params['CTRL']['user']
-
- default_sw_port = main.params['CTRL']['port1']
-
- #Number of iterations of case
- num_iter = main.params['TEST']['numIter']
- #Number of first 'x' iterations to ignore:
- iter_ignore = int(main.params['TEST']['iterIgnore'])
-
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
-
- debug_mode = main.params['TEST']['debugMode']
- onos_log = main.params['TEST']['onosLogFile']
-
- #Threshold for the test
- threshold_str = main.params['TEST']['singleSwThreshold']
- threshold_obj = threshold_str.split(",")
- threshold_min = int(threshold_obj[0])
- threshold_max = int(threshold_obj[1])
-
- #List of switch add latency collected from
- #all iterations
- latency_end_to_end_list = []
- latency_ofp_to_graph_list = []
- latency_ofp_to_device_list = []
- latency_t0_to_device_list = []
- latency_tcp_to_ofp_list = []
-
- #Directory/file to store tshark results
- tshark_of_output = "/tmp/tshark_of_topo.txt"
- tshark_tcp_output = "/tmp/tshark_tcp_topo.txt"
-
- #String to grep in tshark output
- tshark_tcp_string = "TCP 74 "+default_sw_port
- tshark_of_string = "OFP 86 Vendor"
-
- #Initialize assertion to TRUE
- assertion = main.TRUE
-
- local_time = time.strftime('%x %X')
- local_time = local_time.replace("/","")
- local_time = local_time.replace(" ","_")
- local_time = local_time.replace(":","")
- if debug_mode == 'on':
- main.ONOS1.tshark_pcap("eth0",
- "/tmp/single_sw_lat_pcap_"+local_time)
-
- main.log.info("Debug mode is on")
-
- main.log.report("Latency of adding one switch to controller")
- main.log.report("First "+str(iter_ignore)+" iterations ignored"+
- " for jvm warmup time")
- main.log.report("Total iterations of test: "+str(num_iter))
-
- for i in range(0, int(num_iter)):
- main.log.info("Starting tshark capture")
-
- #* TCP [ACK, SYN] is used as t0_a, the
- # very first "exchange" between ONOS and
- # the switch for end-to-end measurement
- #* OFP [Stats Reply] is used for t0_b
- # the very last OFP message between ONOS
- # and the switch for ONOS measurement
- main.ONOS1.tshark_grep(tshark_tcp_string,
- tshark_tcp_output)
- main.ONOS1.tshark_grep(tshark_of_string,
- tshark_of_output)
-
- #Wait and ensure tshark is started and
- #capturing
- time.sleep(10)
-
- main.log.info("Assigning s1 to controller")
-
- main.Mininet1.assign_sw_controller(sw="1",
- ip1=ONOS1_ip, port1=default_sw_port)
-
- #Wait and ensure switch is assigned
- #before stopping tshark
- time.sleep(30)
-
- main.log.info("Stopping all Tshark processes")
- main.ONOS1.stop_tshark()
-
- #tshark output is saved in ONOS. Use subprocess
- #to copy over files to TestON for parsing
- main.log.info("Copying over tshark files")
-
- #TCP CAPTURE ****
- #Copy the tshark output from ONOS machine to
- #TestON machine in tshark_tcp_output directory>file
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_tcp_output+" /tmp/")
- tcp_file = open(tshark_tcp_output, 'r')
- temp_text = tcp_file.readline()
- temp_text = temp_text.split(" ")
-
- main.log.info("Object read in from TCP capture: "+
- str(temp_text))
- if len(temp_text) > 1:
- t0_tcp = float(temp_text[1])*1000.0
- else:
- main.log.error("Tshark output file for TCP"+
- " returned unexpected results")
- t0_tcp = 0
- assertion = main.FALSE
-
- tcp_file.close()
- #****************
-
- #OF CAPTURE ****
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_of_output+" /tmp/")
- of_file = open(tshark_of_output, 'r')
-
- line_ofp = ""
- #Read until last line of file
- while True:
- temp_text = of_file.readline()
- if temp_text !='':
- line_ofp = temp_text
- else:
- break
- obj = line_ofp.split(" ")
-
- main.log.info("Object read in from OFP capture: "+
- str(line_ofp))
-
- if len(line_ofp) > 1:
- t0_ofp = float(obj[1])*1000.0
- else:
- main.log.error("Tshark output file for OFP"+
- " returned unexpected results")
- t0_ofp = 0
- assertion = main.FALSE
-
- of_file.close()
- #****************
-
- json_str_1 = main.ONOS1cli.topology_events_metrics()
- #Initialize scale-out variables
- json_str_2 = ""
- json_str_3 = ""
- json_str_4 = ""
- json_str_5 = ""
- json_str_6 = ""
- json_str_7 = ""
-
- json_obj_1 = json.loads(json_str_1)
- json_obj_2 = json.loads(json_str_2)
- json_obj_3 = json.loads(json_str_3)
- #Initialize scale-out variables
- json_obj_4 = ""
- json_obj_5 = ""
- json_obj_6 = ""
- json_obj_7 = ""
-
- #Include scale-out measurements when applicable
- if cluster_count == 5:
- json_str_4 = main.ONOS4cli.topology_events_metrics()
- json_str_5 = main.ONOS5cli.topology_events_metrics()
-
- json_obj_4 = json.loads(json_str_4)
- json_obj_5 = json.loads(json_str_5)
- elif cluster_count == 6:
- main.log.info("TODO: create even number cluster events")
- elif cluster_count == 7:
- json_str_6 = main.ONOS6cli.topology_events_metrics()
- json_str_7 = main.ONOS7cli.topology_events_metrics()
-
- json_obj_6 = json.loads(json_str_6)
- json_obj_7 = json.loads(json_str_7)
-
- #Obtain graph timestamp. This timestsamp captures
- #the epoch time at which the topology graph was updated.
- graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
- graph_timestamp_2 = \
- json_obj_2[graphTimestamp]['value']
- graph_timestamp_3 = \
- json_obj_3[graphTimestamp]['value']
-
- #Obtain device timestamp. This timestamp captures
- #the epoch time at which the device event happened
- device_timestamp_1 = \
- json_obj_1[deviceTimestamp]['value']
- device_timestamp_2 = \
- json_obj_2[deviceTimestamp]['value']
- device_timestamp_3 = \
- json_obj_3[deviceTimestamp]['value']
-
- #t0 to device processing latency
- delta_device_1 = int(device_timestamp_1) - int(t0_tcp)
- delta_device_2 = int(device_timestamp_2) - int(t0_tcp)
- delta_device_3 = int(device_timestamp_3) - int(t0_tcp)
-
- #Get average of delta from all instances
- avg_delta_device = \
- (int(delta_device_1)+\
- int(delta_device_2)+\
- int(delta_device_3)) / 3
-
- #Ensure avg delta meets the threshold before appending
- if avg_delta_device > 0.0 and avg_delta_device < 10000\
- and int(i) > iter_ignore:
- latency_t0_to_device_list.append(avg_delta_device)
- else:
- main.log.info("Results for t0-to-device ignored"+\
- "due to excess in threshold / warmup iteration.")
-
- #t0 to graph processing latency (end-to-end)
- delta_graph_1 = int(graph_timestamp_1) - int(t0_tcp)
- delta_graph_2 = int(graph_timestamp_2) - int(t0_tcp)
- delta_graph_3 = int(graph_timestamp_3) - int(t0_tcp)
-
- #Get average of delta from all instances
- #TODO: use max delta graph
- #max_delta_graph = max(three)
- avg_delta_graph = \
- (int(delta_graph_1)+\
- int(delta_graph_2)+\
- int(delta_graph_3)) / 3
-
- #Ensure avg delta meets the threshold before appending
- if avg_delta_graph > 0.0 and avg_delta_graph < 10000\
- and int(i) > iter_ignore:
- latency_end_to_end_list.append(avg_delta_graph)
- else:
- main.log.info("Results for end-to-end ignored"+\
- "due to excess in threshold")
-
- #ofp to graph processing latency (ONOS processing)
- delta_ofp_graph_1 = int(graph_timestamp_1) - int(t0_ofp)
- delta_ofp_graph_2 = int(graph_timestamp_2) - int(t0_ofp)
- delta_ofp_graph_3 = int(graph_timestamp_3) - int(t0_ofp)
-
- avg_delta_ofp_graph = \
- (int(delta_ofp_graph_1)+\
- int(delta_ofp_graph_2)+\
- int(delta_ofp_graph_3)) / 3
-
- if avg_delta_ofp_graph > threshold_min \
- and avg_delta_ofp_graph < threshold_max\
- and int(i) > iter_ignore:
- latency_ofp_to_graph_list.append(avg_delta_ofp_graph)
- elif avg_delta_ofp_graph > (-10) and \
- avg_delta_ofp_graph < 0.0 and\
- int(i) > iter_ignore:
- main.log.info("Sub-millisecond result likely; "+
- "negative result was rounded to 0")
- #NOTE: Current metrics framework does not
- #support sub-millisecond accuracy. Therefore,
- #if the result is negative, we can reasonably
- #conclude sub-millisecond results and just
- #append the best rounded effort - 0 ms.
- latency_ofp_to_graph_list.append(0)
- else:
- main.log.info("Results for ofp-to-graph "+\
- "ignored due to excess in threshold")
-
- #ofp to device processing latency (ONOS processing)
- delta_ofp_device_1 = float(device_timestamp_1) - float(t0_ofp)
- delta_ofp_device_2 = float(device_timestamp_2) - float(t0_ofp)
- delta_ofp_device_3 = float(device_timestamp_3) - float(t0_ofp)
-
- avg_delta_ofp_device = \
- (float(delta_ofp_device_1)+\
- float(delta_ofp_device_2)+\
- float(delta_ofp_device_3)) / 3
-
- #NOTE: ofp - delta measurements are occasionally negative
- # due to system time misalignment.
- latency_ofp_to_device_list.append(avg_delta_ofp_device)
-
- delta_ofp_tcp = int(t0_ofp) - int(t0_tcp)
- if delta_ofp_tcp > threshold_min \
- and delta_ofp_tcp < threshold_max and\
- int(i) > iter_ignore:
- latency_tcp_to_ofp_list.append(delta_ofp_tcp)
- else:
- main.log.info("Results fo tcp-to-ofp "+\
- "ignored due to excess in threshold")
-
- #TODO:
- #Fetch logs upon threshold excess
-
- main.log.info("ONOS1 delta end-to-end: "+
- str(delta_graph_1) + " ms")
- main.log.info("ONOS2 delta end-to-end: "+
- str(delta_graph_2) + " ms")
- main.log.info("ONOS3 delta end-to-end: "+
- str(delta_graph_3) + " ms")
-
- main.log.info("ONOS1 delta OFP - graph: "+
- str(delta_ofp_graph_1) + " ms")
- main.log.info("ONOS2 delta OFP - graph: "+
- str(delta_ofp_graph_2) + " ms")
- main.log.info("ONOS3 delta OFP - graph: "+
- str(delta_ofp_graph_3) + " ms")
-
- main.log.info("ONOS1 delta device - t0: "+
- str(delta_device_1) + " ms")
- main.log.info("ONOS2 delta device - t0: "+
- str(delta_device_2) + " ms")
- main.log.info("ONOS3 delta device - t0: "+
- str(delta_device_3) + " ms")
-
- main.log.info("TCP to OFP delta: "+
- str(delta_ofp_tcp) + " ms")
- #main.log.info("ONOS1 delta OFP - device: "+
- # str(delta_ofp_device_1) + " ms")
- #main.log.info("ONOS2 delta OFP - device: "+
- # str(delta_ofp_device_2) + " ms")
- #main.log.info("ONOS3 delta OFP - device: "+
- # str(delta_ofp_device_3) + " ms")
-
- main.step("Remove switch from controller")
- main.Mininet1.delete_sw_controller("s1")
-
- time.sleep(5)
-
- #END of for loop iteration
-
- #If there is at least 1 element in each list,
- #pass the test case
- if len(latency_end_to_end_list) > 0 and\
- len(latency_ofp_to_graph_list) > 0 and\
- len(latency_ofp_to_device_list) > 0 and\
- len(latency_t0_to_device_list) > 0 and\
- len(latency_tcp_to_ofp_list) > 0:
- assertion = main.TRUE
- elif len(latency_end_to_end_list) == 0:
- #The appending of 0 here is to prevent
- #the min,max,sum functions from failing
- #below
- latency_end_to_end_list.append(0)
- assertion = main.FALSE
- elif len(latency_ofp_to_graph_list) == 0:
- latency_ofp_to_graph_list.append(0)
- assertion = main.FALSE
- elif len(latency_ofp_to_device_list) == 0:
- latency_ofp_to_device_list.append(0)
- assertion = main.FALSE
- elif len(latency_t0_to_device_list) == 0:
- latency_t0_to_device_list.append(0)
- assertion = main.FALSE
- elif len(latency_tcp_to_ofp_list) == 0:
- latency_tcp_to_ofp_list.append(0)
- assertion = main.FALSE
-
- #Calculate min, max, avg of latency lists
- latency_end_to_end_max = \
- int(max(latency_end_to_end_list))
- latency_end_to_end_min = \
- int(min(latency_end_to_end_list))
- latency_end_to_end_avg = \
- (int(sum(latency_end_to_end_list)) / \
- len(latency_end_to_end_list))
- latency_end_to_end_std_dev = \
- str(round(numpy.std(latency_end_to_end_list),1))
-
- latency_ofp_to_graph_max = \
- int(max(latency_ofp_to_graph_list))
- latency_ofp_to_graph_min = \
- int(min(latency_ofp_to_graph_list))
- latency_ofp_to_graph_avg = \
- (int(sum(latency_ofp_to_graph_list)) / \
- len(latency_ofp_to_graph_list))
- latency_ofp_to_graph_std_dev = \
- str(round(numpy.std(latency_ofp_to_graph_list),1))
-
- latency_ofp_to_device_max = \
- int(max(latency_ofp_to_device_list))
- latency_ofp_to_device_min = \
- int(min(latency_ofp_to_device_list))
- latency_ofp_to_device_avg = \
- (int(sum(latency_ofp_to_device_list)) / \
- len(latency_ofp_to_device_list))
- latency_ofp_to_device_std_dev = \
- str(round(numpy.std(latency_ofp_to_device_list),1))
-
- latency_t0_to_device_max = \
- int(max(latency_t0_to_device_list))
- latency_t0_to_device_min = \
- int(min(latency_t0_to_device_list))
- latency_t0_to_device_avg = \
- (int(sum(latency_t0_to_device_list)) / \
- len(latency_t0_to_device_list))
- latency_ofp_to_device_std_dev = \
- str(round(numpy.std(latency_t0_to_device_list),1))
-
- latency_tcp_to_ofp_max = \
- int(max(latency_tcp_to_ofp_list))
- latency_tcp_to_ofp_min = \
- int(min(latency_tcp_to_ofp_list))
- latency_tcp_to_ofp_avg = \
- (int(sum(latency_tcp_to_ofp_list)) / \
- len(latency_tcp_to_ofp_list))
- latency_tcp_to_ofp_std_dev = \
- str(round(numpy.std(latency_tcp_to_ofp_list),1))
-
- main.log.report("Switch add - End-to-end latency: "+\
- "Avg: "+str(latency_end_to_end_avg)+" ms "+
- "Std Deviation: "+latency_end_to_end_std_dev+" ms")
- main.log.report("Switch add - OFP-to-Graph latency: "+\
- "Note: results are not accurate to sub-millisecond. "+
- "Any sub-millisecond results are rounded to 0 ms. ")
- main.log.report("Avg: "+str(latency_ofp_to_graph_avg)+" ms "+
- "Std Deviation: "+latency_ofp_to_graph_std_dev+" ms")
- main.log.report("Switch add - TCP-to-OFP latency: "+\
- "Avg: "+str(latency_tcp_to_ofp_avg)+" ms "+
- "Std Deviation: "+latency_tcp_to_ofp_std_dev+" ms")
-
- if debug_mode == 'on':
- main.ONOS1.cp_logs_to_dir("/opt/onos/log/karaf.log",
- "/tmp/", copy_file_name="sw_lat_karaf")
-
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Switch latency test successful",
- onfail="Switch latency test failed")
-
- def CASE3(self, main):
- '''
- Bring port up / down and measure latency.
- Port enable / disable is simulated by ifconfig up / down
-
- In ONOS-next, we must ensure that the port we are
- manipulating is connected to another switch with a valid
- connection. Otherwise, graph view will not be updated.
- '''
- import time
- import subprocess
- import os
- import requests
- import json
- import numpy
-
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS_user = main.params['CTRL']['user']
-
- default_sw_port = main.params['CTRL']['port1']
-
- assertion = main.TRUE
- #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']
- graphTimestamp = main.params['JSON']['graphTimestamp']
-
- debug_mode = main.params['TEST']['debugMode']
-
- local_time = time.strftime('%x %X')
- local_time = local_time.replace("/","")
- local_time = local_time.replace(" ","_")
- local_time = local_time.replace(":","")
- if debug_mode == 'on':
- main.ONOS1.tshark_pcap("eth0",
- "/tmp/port_lat_pcap_"+local_time)
-
- #Threshold for this test case
- up_threshold_str = main.params['TEST']['portUpThreshold']
- down_threshold_str = main.params['TEST']['portDownThreshold']
-
- up_threshold_obj = up_threshold_str.split(",")
- down_threshold_obj = down_threshold_str.split(",")
-
- up_threshold_min = int(up_threshold_obj[0])
- up_threshold_max = int(up_threshold_obj[1])
-
- down_threshold_min = int(down_threshold_obj[0])
- down_threshold_max = int(down_threshold_obj[1])
-
- #NOTE: Some hardcoded variables you may need to configure
- # besides the params
-
- tshark_port_status = "OFP 130 Port Status"
-
- tshark_port_up = "/tmp/tshark_port_up.txt"
- tshark_port_down = "/tmp/tshark_port_down.txt"
- interface_config = "s1-eth1"
-
- main.log.report("Port enable / disable latency")
- main.log.report("Simulated by ifconfig up / down")
- main.log.report("Total iterations of test: "+str(num_iter))
-
- main.step("Assign switches s1 and s2 to controller 1")
- main.Mininet1.assign_sw_controller(sw="1",ip1=ONOS1_ip,
- port1=default_sw_port)
- main.Mininet1.assign_sw_controller(sw="2",ip1=ONOS1_ip,
- port1=default_sw_port)
-
- #Give enough time for metrics to propagate the
- #assign controller event. Otherwise, these events may
- #carry over to our measurements
- time.sleep(15)
-
- port_up_device_to_ofp_list = []
- port_up_graph_to_ofp_list = []
- port_down_device_to_ofp_list = []
- port_down_graph_to_ofp_list = []
-
- for i in range(0, int(num_iter)):
- main.step("Starting wireshark capture for port status down")
- main.ONOS1.tshark_grep(tshark_port_status,
- tshark_port_down)
-
- time.sleep(5)
-
- #Disable interface that is connected to switch 2
- main.step("Disable port: "+interface_config)
- main.Mininet1.handle.sendline("sh ifconfig "+
- interface_config+" down")
- main.Mininet1.handle.expect("mininet>")
-
- time.sleep(3)
- main.ONOS1.tshark_stop()
-
- main.step("Obtain t1 by metrics call")
- json_str_up_1 = main.ONOS1cli.topology_events_metrics()
- json_str_up_2 = main.ONOS2cli.topology_events_metrics()
- json_str_up_3 = main.ONOS3cli.topology_events_metrics()
-
- json_obj_1 = json.loads(json_str_up_1)
- json_obj_2 = json.loads(json_str_up_2)
- json_obj_3 = json.loads(json_str_up_3)
-
- #Copy tshark output file from ONOS to TestON instance
- #/tmp directory
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_port_down+" /tmp/")
-
- f_port_down = open(tshark_port_down, 'r')
- #Get first line of port down event from tshark
- f_line = f_port_down.readline()
- obj_down = f_line.split(" ")
- if len(f_line) > 0:
- timestamp_begin_pt_down = int(float(obj_down[1])*1000)
- main.log.info("Port down begin timestamp: "+
- str(timestamp_begin_pt_down))
- else:
- main.log.info("Tshark output file returned unexpected"+
- " results: "+str(obj_down))
- timestamp_begin_pt_down = 0
-
- f_port_down.close()
-
- main.log.info("TEST tshark obj: "+str(obj_down))
-
- time.sleep(3)
-
- #Obtain graph timestamp. This timestsamp captures
- #the epoch time at which the topology graph was updated.
- graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
- graph_timestamp_2 = \
- json_obj_2[graphTimestamp]['value']
- graph_timestamp_3 = \
- json_obj_3[graphTimestamp]['value']
-
- main.log.info("TEST graph timestamp ONOS1: "+
- str(graph_timestamp_1))
-
- #Obtain device timestamp. This timestamp captures
- #the epoch time at which the device event happened
- device_timestamp_1 = \
- json_obj_1[deviceTimestamp]['value']
- device_timestamp_2 = \
- json_obj_2[deviceTimestamp]['value']
- device_timestamp_3 = \
- json_obj_3[deviceTimestamp]['value']
-
- #Get delta between graph event and OFP
- pt_down_graph_to_ofp_1 = int(graph_timestamp_1) -\
- int(timestamp_begin_pt_down)
- pt_down_graph_to_ofp_2 = int(graph_timestamp_2) -\
- int(timestamp_begin_pt_down)
- pt_down_graph_to_ofp_3 = int(graph_timestamp_3) -\
- int(timestamp_begin_pt_down)
-
- #Get delta between device event and OFP
- pt_down_device_to_ofp_1 = int(device_timestamp_1) -\
- int(timestamp_begin_pt_down)
- pt_down_device_to_ofp_2 = int(device_timestamp_2) -\
- int(timestamp_begin_pt_down)
- pt_down_device_to_ofp_3 = int(device_timestamp_3) -\
- int(timestamp_begin_pt_down)
-
- #Caluclate average across clusters
- pt_down_graph_to_ofp_avg =\
- (int(pt_down_graph_to_ofp_1) +
- int(pt_down_graph_to_ofp_2) +
- int(pt_down_graph_to_ofp_3)) / 3
- pt_down_device_to_ofp_avg = \
- (int(pt_down_device_to_ofp_1) +
- int(pt_down_device_to_ofp_2) +
- int(pt_down_device_to_ofp_3)) / 3
-
- if pt_down_graph_to_ofp_avg > down_threshold_min and \
- pt_down_graph_to_ofp_avg < down_threshold_max:
- port_down_graph_to_ofp_list.append(
- pt_down_graph_to_ofp_avg)
- main.log.info("Port down: graph to ofp avg: "+
- str(pt_down_graph_to_ofp_avg) + " ms")
- else:
- main.log.info("Average port down graph-to-ofp result" +
- " exceeded the threshold: "+
- str(pt_down_graph_to_ofp_avg))
-
- if pt_down_device_to_ofp_avg > 0 and \
- pt_down_device_to_ofp_avg < 1000:
- port_down_device_to_ofp_list.append(
- pt_down_device_to_ofp_avg)
- main.log.info("Port down: device to ofp avg: "+
- str(pt_down_device_to_ofp_avg) + " ms")
- else:
- main.log.info("Average port down device-to-ofp result" +
- " exceeded the threshold: "+
- str(pt_down_device_to_ofp_avg))
-
- #Port up events
- main.step("Enable port and obtain timestamp")
- main.step("Starting wireshark capture for port status up")
- main.ONOS1.tshark_grep(tshark_port_status, tshark_port_up)
- time.sleep(5)
-
- main.Mininet1.handle.sendline("sh ifconfig "+
- interface_config+" up")
- main.Mininet1.handle.expect("mininet>")
-
- #Allow time for tshark to capture event
- time.sleep(3)
- main.ONOS1.tshark_stop()
-
- #Obtain metrics shortly afterwards
- #This timestsamp captures
- #the epoch time at which the topology graph was updated.
- main.step("Obtain t1 by REST call")
- json_str_up_1 = main.ONOS1cli.topology_events_metrics()
- json_str_up_2 = main.ONOS2cli.topology_events_metrics()
- json_str_up_3 = main.ONOS3cli.topology_events_metrics()
-
- json_obj_1 = json.loads(json_str_up_1)
- json_obj_2 = json.loads(json_str_up_2)
- json_obj_3 = json.loads(json_str_up_3)
-
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_port_up+" /tmp/")
-
- f_port_up = open(tshark_port_up, 'r')
- f_line = f_port_up.readline()
- obj_up = f_line.split(" ")
- if len(f_line) > 0:
- timestamp_begin_pt_up = int(float(obj_up[1])*1000)
- main.log.info("Port up begin timestamp: "+
- str(timestamp_begin_pt_up))
- else:
- main.log.info("Tshark output file returned unexpected"+
- " results.")
- timestamp_begin_pt_up = 0
-
- f_port_up.close()
-
- graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
- graph_timestamp_2 = \
- json_obj_2[graphTimestamp]['value']
- graph_timestamp_3 = \
- json_obj_3[graphTimestamp]['value']
-
- #Obtain device timestamp. This timestamp captures
- #the epoch time at which the device event happened
- device_timestamp_1 = \
- json_obj_1[deviceTimestamp]['value']
- device_timestamp_2 = \
- json_obj_2[deviceTimestamp]['value']
- device_timestamp_3 = \
- json_obj_3[deviceTimestamp]['value']
-
- #Get delta between graph event and OFP
- pt_up_graph_to_ofp_1 = int(graph_timestamp_1) -\
- int(timestamp_begin_pt_up)
- pt_up_graph_to_ofp_2 = int(graph_timestamp_2) -\
- int(timestamp_begin_pt_up)
- pt_up_graph_to_ofp_3 = int(graph_timestamp_3) -\
- int(timestamp_begin_pt_up)
-
- #Get delta between device event and OFP
- pt_up_device_to_ofp_1 = int(device_timestamp_1) -\
- int(timestamp_begin_pt_up)
- pt_up_device_to_ofp_2 = int(device_timestamp_2) -\
- int(timestamp_begin_pt_up)
- pt_up_device_to_ofp_3 = int(device_timestamp_3) -\
- int(timestamp_begin_pt_up)
-
- main.log.info("ONOS1 delta G2O: "+str(pt_up_graph_to_ofp_1))
- main.log.info("ONOS2 delta G2O: "+str(pt_up_graph_to_ofp_2))
- main.log.info("ONOS3 delta G2O: "+str(pt_up_graph_to_ofp_3))
-
- main.log.info("ONOS1 delta D2O: "+str(pt_up_device_to_ofp_1))
- main.log.info("ONOS2 delta D2O: "+str(pt_up_device_to_ofp_2))
- main.log.info("ONOS3 delta D2O: "+str(pt_up_device_to_ofp_3))
-
- pt_up_graph_to_ofp_avg = \
- (int(pt_up_graph_to_ofp_1) +
- int(pt_up_graph_to_ofp_2) +
- int(pt_up_graph_to_ofp_3)) / 3
-
- pt_up_device_to_ofp_avg = \
- (int(pt_up_device_to_ofp_1) +
- int(pt_up_device_to_ofp_2) +
- int(pt_up_device_to_ofp_3)) / 3
-
- if pt_up_graph_to_ofp_avg > up_threshold_min and \
- pt_up_graph_to_ofp_avg < up_threshold_max:
- port_up_graph_to_ofp_list.append(
- pt_up_graph_to_ofp_avg)
- main.log.info("Port down: graph to ofp avg: "+
- str(pt_up_graph_to_ofp_avg) + " ms")
- else:
- main.log.info("Average port up graph-to-ofp result"+
- " exceeded the threshold: "+
- str(pt_up_graph_to_ofp_avg))
-
- if pt_up_device_to_ofp_avg > up_threshold_min and \
- pt_up_device_to_ofp_avg < up_threshold_max:
- port_up_device_to_ofp_list.append(
- pt_up_device_to_ofp_avg)
- main.log.info("Port up: device to ofp avg: "+
- str(pt_up_device_to_ofp_avg) + " ms")
- else:
- main.log.info("Average port up device-to-ofp result"+
- " exceeded the threshold: "+
- str(pt_up_device_to_ofp_avg))
-
- #END ITERATION FOR LOOP
-
- #Check all list for latency existence and set assertion
- if (port_down_graph_to_ofp_list and port_down_device_to_ofp_list\
- and port_up_graph_to_ofp_list and port_up_device_to_ofp_list):
- assertion = main.TRUE
-
- #Calculate and report latency measurements
- port_down_graph_to_ofp_min = min(port_down_graph_to_ofp_list)
- port_down_graph_to_ofp_max = max(port_down_graph_to_ofp_list)
- port_down_graph_to_ofp_avg = \
- (sum(port_down_graph_to_ofp_list) /
- len(port_down_graph_to_ofp_list))
- port_down_graph_to_ofp_std_dev = \
- str(round(numpy.std(port_down_graph_to_ofp_list),1))
-
- main.log.report("Port down graph-to-ofp "+
- "Avg: "+str(port_down_graph_to_ofp_avg)+" ms "+
- "Std Deviation: "+port_down_graph_to_ofp_std_dev+" ms")
-
- port_down_device_to_ofp_min = min(port_down_device_to_ofp_list)
- port_down_device_to_ofp_max = max(port_down_device_to_ofp_list)
- port_down_device_to_ofp_avg = \
- (sum(port_down_device_to_ofp_list) /\
- len(port_down_device_to_ofp_list))
- port_down_device_to_ofp_std_dev = \
- str(round(numpy.std(port_down_device_to_ofp_list),1))
-
- main.log.report("Port down device-to-ofp "+
- "Avg: "+str(port_down_device_to_ofp_avg)+" ms "+
- "Std Deviation: "+port_down_device_to_ofp_std_dev+" ms")
-
- port_up_graph_to_ofp_min = min(port_up_graph_to_ofp_list)
- port_up_graph_to_ofp_max = max(port_up_graph_to_ofp_list)
- port_up_graph_to_ofp_avg = \
- (sum(port_up_graph_to_ofp_list) /\
- len(port_up_graph_to_ofp_list))
- port_up_graph_to_ofp_std_dev = \
- str(round(numpy.std(port_up_graph_to_ofp_list),1))
-
- main.log.report("Port up graph-to-ofp "+
- "Avg: "+str(port_up_graph_to_ofp_avg)+" ms "+
- "Std Deviation: "+port_up_graph_to_ofp_std_dev+" ms")
-
- port_up_device_to_ofp_min = min(port_up_device_to_ofp_list)
- port_up_device_to_ofp_max = max(port_up_device_to_ofp_list)
- port_up_device_to_ofp_avg = \
- (sum(port_up_device_to_ofp_list) /\
- len(port_up_device_to_ofp_list))
- port_up_device_to_ofp_std_dev = \
- str(round(numpy.std(port_up_device_to_ofp_list),1))
-
- main.log.report("Port up device-to-ofp "+
- "Avg: "+str(port_up_device_to_ofp_avg)+" ms "+
- "Std Deviation: "+port_up_device_to_ofp_std_dev+" ms")
-
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Port discovery latency calculation successful",
- onfail="Port discovery test failed")
-
- def CASE4(self, main):
- '''
- Link down event using loss rate 100%
-
- Important:
- Use a simple 2 switch topology with 1 link between
- the two switches. Ensure that mac addresses of the
- switches are 1 / 2 respectively
- '''
- import time
- import subprocess
- import os
- import requests
- import json
- import numpy
-
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- 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']
- linkTimestamp = main.params['JSON']['linkTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
-
- debug_mode = main.params['TEST']['debugMode']
-
- local_time = time.strftime('%x %X')
- local_time = local_time.replace("/","")
- local_time = local_time.replace(" ","_")
- local_time = local_time.replace(":","")
- if debug_mode == 'on':
- main.ONOS1.tshark_pcap("eth0",
- "/tmp/link_lat_pcap_"+local_time)
-
- #Threshold for this test case
- up_threshold_str = main.params['TEST']['linkUpThreshold']
- down_threshold_str = main.params['TEST']['linkDownThreshold']
-
- up_threshold_obj = up_threshold_str.split(",")
- down_threshold_obj = down_threshold_str.split(",")
-
- up_threshold_min = int(up_threshold_obj[0])
- up_threshold_max = int(up_threshold_obj[1])
-
- down_threshold_min = int(down_threshold_obj[0])
- down_threshold_max = int(down_threshold_obj[1])
-
- assertion = main.TRUE
- #Link event timestamp to system time list
- link_down_link_to_system_list = []
- link_up_link_to_system_list = []
- #Graph event timestamp to system time list
- link_down_graph_to_system_list = []
- link_up_graph_to_system_list = []
-
- main.log.report("Link up / down discovery latency between "+
- "two switches")
- main.log.report("Simulated by setting loss-rate 100%")
- main.log.report("'tc qdisc add dev <intfs> root netem loss 100%'")
- main.log.report("Total iterations of test: "+str(num_iter))
-
- main.step("Assign all switches")
- main.Mininet1.assign_sw_controller(sw="1",
- ip1=ONOS1_ip, port1=default_sw_port)
- main.Mininet1.assign_sw_controller(sw="2",
- ip1=ONOS1_ip, port1=default_sw_port)
-
- main.step("Verifying switch assignment")
- result_s1 = main.Mininet1.get_sw_controller(sw="s1")
- result_s2 = main.Mininet1.get_sw_controller(sw="s2")
-
- #Allow time for events to finish before taking measurements
- time.sleep(10)
-
- link_down1 = False
- link_down2 = False
- link_down3 = False
- #Start iteration of link event test
- for i in range(0, int(num_iter)):
- main.step("Getting initial system time as t0")
-
- #System time in epoch ms
- timestamp_link_down_t0 = time.time() * 1000
- #Link down is simulated by 100% loss rate using traffic
- #control command
- main.Mininet1.handle.sendline(
- "sh tc qdisc add dev s1-eth1 root netem loss 100%")
-
- #TODO: Iterate through 'links' command to verify that
- # link s1 -> s2 went down (loop timeout 30 seconds)
- # on all 3 ONOS instances
- main.log.info("Checking ONOS for link update")
- loop_count = 0
- while( not (link_down1 and link_down2 and link_down3)\
- and loop_count < 30 ):
- json_str1 = main.ONOS1cli.links()
- json_str2 = main.ONOS2cli.links()
- json_str3 = main.ONOS3cli.links()
-
- if not (json_str1 and json_str2 and json_str3):
- main.log.error("CLI command returned error ")
- break
- else:
- json_obj1 = json.loads(json_str1)
- json_obj2 = json.loads(json_str2)
- json_obj3 = json.loads(json_str3)
- for obj1 in json_obj1:
- if '01' not in obj1['src']['device']:
- link_down1 = True
- main.log.info("Link down from "+
- "s1 -> s2 on ONOS1 detected")
- for obj2 in json_obj2:
- if '01' not in obj2['src']['device']:
- link_down2 = True
- main.log.info("Link down from "+
- "s1 -> s2 on ONOS2 detected")
- for obj3 in json_obj3:
- if '01' not in obj3['src']['device']:
- link_down3 = True
- main.log.info("Link down from "+
- "s1 -> s2 on ONOS3 detected")
-
- loop_count += 1
- #If CLI doesn't like the continuous requests
- #and exits in this loop, increase the sleep here.
- #Consequently, while loop timeout will increase
- time.sleep(1)
-
- #Give time for metrics measurement to catch up
- #NOTE: May need to be configured more accurately
- time.sleep(10)
- #If we exited the while loop and link down 1,2,3 are still
- #false, then ONOS has failed to discover link down event
- if not (link_down1 and link_down2 and link_down3):
- main.log.info("Link down discovery failed")
-
- link_down_lat_graph1 = 0
- link_down_lat_graph2 = 0
- link_down_lat_graph3 = 0
- link_down_lat_device1 = 0
- link_down_lat_device2 = 0
- link_down_lat_device3 = 0
-
- assertion = main.FALSE
- else:
- json_topo_metrics_1 =\
- main.ONOS1cli.topology_events_metrics()
- json_topo_metrics_2 =\
- main.ONOS2cli.topology_events_metrics()
- json_topo_metrics_3 =\
- main.ONOS3cli.topology_events_metrics()
- json_topo_metrics_1 = json.loads(json_topo_metrics_1)
- json_topo_metrics_2 = json.loads(json_topo_metrics_2)
- json_topo_metrics_3 = json.loads(json_topo_metrics_3)
-
- main.log.info("Obtaining graph and device timestamp")
- graph_timestamp_1 = \
- json_topo_metrics_1[graphTimestamp]['value']
- graph_timestamp_2 = \
- json_topo_metrics_2[graphTimestamp]['value']
- graph_timestamp_3 = \
- json_topo_metrics_3[graphTimestamp]['value']
-
- link_timestamp_1 = \
- json_topo_metrics_1[linkTimestamp]['value']
- link_timestamp_2 = \
- json_topo_metrics_2[linkTimestamp]['value']
- link_timestamp_3 = \
- json_topo_metrics_3[linkTimestamp]['value']
-
- if graph_timestamp_1 and graph_timestamp_2 and\
- graph_timestamp_3 and link_timestamp_1 and\
- link_timestamp_2 and link_timestamp_3:
- link_down_lat_graph1 = int(graph_timestamp_1) -\
- int(timestamp_link_down_t0)
- link_down_lat_graph2 = int(graph_timestamp_2) -\
- int(timestamp_link_down_t0)
- link_down_lat_graph3 = int(graph_timestamp_3) -\
- int(timestamp_link_down_t0)
-
- link_down_lat_link1 = int(link_timestamp_1) -\
- int(timestamp_link_down_t0)
- link_down_lat_link2 = int(link_timestamp_2) -\
- int(timestamp_link_down_t0)
- link_down_lat_link3 = int(link_timestamp_3) -\
- int(timestamp_link_down_t0)
- else:
- main.log.error("There was an error calculating"+
- " the delta for link down event")
- link_down_lat_graph1 = 0
- link_down_lat_graph2 = 0
- link_down_lat_graph3 = 0
-
- link_down_lat_device1 = 0
- link_down_lat_device2 = 0
- link_down_lat_device3 = 0
-
- main.log.info("Link down latency ONOS1 iteration "+
- str(i)+" (end-to-end): "+
- str(link_down_lat_graph1)+" ms")
- main.log.info("Link down latency ONOS2 iteration "+
- str(i)+" (end-to-end): "+
- str(link_down_lat_graph2)+" ms")
- main.log.info("Link down latency ONOS3 iteration "+
- str(i)+" (end-to-end): "+
- str(link_down_lat_graph3)+" ms")
-
- main.log.info("Link down latency ONOS1 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_down_lat_link1)+" ms")
- main.log.info("Link down latency ONOS2 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_down_lat_link2)+" ms")
- main.log.info("Link down latency ONOS3 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_down_lat_link3))
-
- #Calculate avg of node calculations
- link_down_lat_graph_avg =\
- (link_down_lat_graph1 +
- link_down_lat_graph2 +
- link_down_lat_graph3) / 3
- link_down_lat_link_avg =\
- (link_down_lat_link1 +
- link_down_lat_link2 +
- link_down_lat_link3) / 3
-
- #Set threshold and append latency to list
- if link_down_lat_graph_avg > down_threshold_min and\
- link_down_lat_graph_avg < down_threshold_max:
- link_down_graph_to_system_list.append(
- link_down_lat_graph_avg)
- else:
- main.log.info("Link down latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
- if link_down_lat_link_avg > down_threshold_min and\
- link_down_lat_link_avg < down_threshold_max:
- link_down_link_to_system_list.append(
- link_down_lat_link_avg)
- else:
- main.log.info("Link down latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
-
- #NOTE: To remove loss rate and measure latency:
- # 'sh tc qdisc del dev s1-eth1 root'
- timestamp_link_up_t0 = time.time() * 1000
- main.Mininet1.handle.sendline("sh tc qdisc del dev "+
- "s1-eth1 root")
- main.Mininet1.handle.expect("mininet>")
-
- main.log.info("Checking ONOS for link update")
-
- link_down1 = True
- link_down2 = True
- link_down3 = True
- loop_count = 0
- while( (link_down1 and link_down2 and link_down3)\
- and loop_count < 30 ):
- json_str1 = main.ONOS1cli.links()
- json_str2 = main.ONOS2cli.links()
- json_str3 = main.ONOS3cli.links()
- if not (json_str1 and json_str2 and json_str3):
- main.log.error("CLI command returned error ")
- break
- else:
- json_obj1 = json.loads(json_str1)
- json_obj2 = json.loads(json_str2)
- json_obj3 = json.loads(json_str3)
-
- for obj1 in json_obj1:
- if '01' in obj1['src']['device']:
- link_down1 = False
- main.log.info("Link up from "+
- "s1 -> s2 on ONOS1 detected")
- for obj2 in json_obj2:
- if '01' in obj2['src']['device']:
- link_down2 = False
- main.log.info("Link up from "+
- "s1 -> s2 on ONOS2 detected")
- for obj3 in json_obj3:
- if '01' in obj3['src']['device']:
- link_down3 = False
- main.log.info("Link up from "+
- "s1 -> s2 on ONOS3 detected")
-
- loop_count += 1
- time.sleep(1)
-
- if (link_down1 and link_down2 and link_down3):
- main.log.info("Link up discovery failed")
-
- link_up_lat_graph1 = 0
- link_up_lat_graph2 = 0
- link_up_lat_graph3 = 0
- link_up_lat_device1 = 0
- link_up_lat_device2 = 0
- link_up_lat_device3 = 0
-
- assertion = main.FALSE
- else:
- json_topo_metrics_1 =\
- main.ONOS1cli.topology_events_metrics()
- json_topo_metrics_2 =\
- main.ONOS2cli.topology_events_metrics()
- json_topo_metrics_3 =\
- main.ONOS3cli.topology_events_metrics()
- json_topo_metrics_1 = json.loads(json_topo_metrics_1)
- json_topo_metrics_2 = json.loads(json_topo_metrics_2)
- json_topo_metrics_3 = json.loads(json_topo_metrics_3)
-
- main.log.info("Obtaining graph and device timestamp")
- graph_timestamp_1 = \
- json_topo_metrics_1[graphTimestamp]['value']
- graph_timestamp_2 = \
- json_topo_metrics_2[graphTimestamp]['value']
- graph_timestamp_3 = \
- json_topo_metrics_3[graphTimestamp]['value']
-
- link_timestamp_1 = \
- json_topo_metrics_1[linkTimestamp]['value']
- link_timestamp_2 = \
- json_topo_metrics_2[linkTimestamp]['value']
- link_timestamp_3 = \
- json_topo_metrics_3[linkTimestamp]['value']
-
- if graph_timestamp_1 and graph_timestamp_2 and\
- graph_timestamp_3 and link_timestamp_1 and\
- link_timestamp_2 and link_timestamp_3:
- link_up_lat_graph1 = int(graph_timestamp_1) -\
- int(timestamp_link_up_t0)
- link_up_lat_graph2 = int(graph_timestamp_2) -\
- int(timestamp_link_up_t0)
- link_up_lat_graph3 = int(graph_timestamp_3) -\
- int(timestamp_link_up_t0)
-
- link_up_lat_link1 = int(link_timestamp_1) -\
- int(timestamp_link_up_t0)
- link_up_lat_link2 = int(link_timestamp_2) -\
- int(timestamp_link_up_t0)
- link_up_lat_link3 = int(link_timestamp_3) -\
- int(timestamp_link_up_t0)
- else:
- main.log.error("There was an error calculating"+
- " the delta for link down event")
- link_up_lat_graph1 = 0
- link_up_lat_graph2 = 0
- link_up_lat_graph3 = 0
-
- link_up_lat_device1 = 0
- link_up_lat_device2 = 0
- link_up_lat_device3 = 0
-
- if debug_mode == 'on':
- main.log.info("Link up latency ONOS1 iteration "+
- str(i)+" (end-to-end): "+
- str(link_up_lat_graph1)+" ms")
- main.log.info("Link up latency ONOS2 iteration "+
- str(i)+" (end-to-end): "+
- str(link_up_lat_graph2)+" ms")
- main.log.info("Link up latency ONOS3 iteration "+
- str(i)+" (end-to-end): "+
- str(link_up_lat_graph3)+" ms")
-
- main.log.info("Link up latency ONOS1 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_up_lat_link1)+" ms")
- main.log.info("Link up latency ONOS2 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_up_lat_link2)+" ms")
- main.log.info("Link up latency ONOS3 iteration "+
- str(i)+" (link-event-to-system-timestamp): "+
- str(link_up_lat_link3))
-
- #Calculate avg of node calculations
- link_up_lat_graph_avg =\
- (link_up_lat_graph1 +
- link_up_lat_graph2 +
- link_up_lat_graph3) / 3
- link_up_lat_link_avg =\
- (link_up_lat_link1 +
- link_up_lat_link2 +
- link_up_lat_link3) / 3
-
- #Set threshold and append latency to list
- if link_up_lat_graph_avg > up_threshold_min and\
- link_up_lat_graph_avg < up_threshold_max:
- link_up_graph_to_system_list.append(
- link_up_lat_graph_avg)
- else:
- main.log.info("Link up latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
- if link_up_lat_link_avg > up_threshold_min and\
- link_up_lat_link_avg < up_threshold_max:
- link_up_link_to_system_list.append(
- link_up_lat_link_avg)
- else:
- main.log.info("Link up latency exceeded threshold")
- main.log.info("Results for iteration "+str(i)+
- "have been omitted")
-
- #Calculate min, max, avg of list and report
- link_down_min = min(link_down_graph_to_system_list)
- link_down_max = max(link_down_graph_to_system_list)
- link_down_avg = sum(link_down_graph_to_system_list) / \
- len(link_down_graph_to_system_list)
- link_up_min = min(link_up_graph_to_system_list)
- link_up_max = max(link_up_graph_to_system_list)
- link_up_avg = sum(link_up_graph_to_system_list) / \
- len(link_up_graph_to_system_list)
- link_down_std_dev = \
- str(round(numpy.std(link_down_graph_to_system_list),1))
- link_up_std_dev = \
- str(round(numpy.std(link_up_graph_to_system_list),1))
-
- main.log.report("Link down latency " +
- "Avg: "+str(link_down_avg)+" ms "+
- "Std Deviation: "+link_down_std_dev+" ms")
- main.log.report("Link up latency "+
- "Avg: "+str(link_up_avg)+" ms "+
- "Std Deviation: "+link_up_std_dev+" ms")
-
- utilities.assert_equals(expect=main.TRUE, actual=assertion,
- onpass="Link discovery latency calculation successful",
- onfail="Link discovery latency case failed")
-
- def CASE5(self, main):
- '''
- 100 Switch discovery latency
-
- Important:
- This test case can be potentially dangerous if
- your machine has previously set iptables rules.
- One of the steps of the test case will flush
- all existing iptables rules.
- Note:
- You can specify the number of switches in the
- params file to adjust the switch discovery size
- (and specify the corresponding topology in Mininet1
- .topo file)
- '''
- 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']
- num_sw = main.params['TEST']['numSwitch']
-
- #Timestamp 'keys' for json metrics output.
- #These are subject to change, hence moved into params
- deviceTimestamp = main.params['JSON']['deviceTimestamp']
- graphTimestamp = main.params['JSON']['graphTimestamp']
-
- debug_mode = main.params['TEST']['debugMode']
-
- local_time = time.strftime('%X')
- local_time = local_time.replace("/","")
- local_time = local_time.replace(" ","_")
- local_time = local_time.replace(":","")
- if debug_mode == 'on':
- main.ONOS1.tshark_pcap("eth0",
- "/tmp/100_sw_lat_pcap_"+local_time)
-
- #Threshold for this test case
- sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
- sw_disc_threshold_obj = sw_disc_threshold_str.split(",")
- sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
- sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
-
- tshark_ofp_output = "/tmp/tshark_ofp_"+num_sw+"sw.txt"
- tshark_tcp_output = "/tmp/tshark_tcp_"+num_sw+"sw.txt"
-
- tshark_ofp_result_list = []
- tshark_tcp_result_list = []
-
- sw_discovery_lat_list = []
-
- main.case(num_sw+" Switch discovery latency")
- main.step("Assigning all switches to ONOS1")
- for i in range(1, int(num_sw)+1):
- main.Mininet1.assign_sw_controller(
- sw=str(i),
- ip1=ONOS1_ip,
- port1=default_sw_port)
-
- #Ensure that nodes are configured with ptpd
- #Just a warning message
- main.log.info("Please check ptpd configuration to ensure"+\
- " All nodes' system times are in sync")
- time.sleep(5)
-
- 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
- #The rule description is as follows:
- # Append to INPUT rule,
- # behavior DROP that matches following:
- # * packet type: tcp
- # * source IP: MN1_ip
- # * destination PORT: 6633
- main.ONOS1.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s "+MN1_ip+
- " --dport "+default_sw_port+" -j DROP")
- main.ONOS1.handle.expect("\$")
- # Append to OUTPUT rule,
- # behavior DROP that matches following:
- # * packet type: tcp
- # * source IP: MN1_ip
- # * destination PORT: 6633
- main.ONOS1.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s "+MN1_ip+
- " --dport "+default_sw_port+" -j DROP")
- main.ONOS1.handle.expect("\$")
- #Give time to allow rule to take effect
- #NOTE: Sleep period may need to be configured
- # based on the number of switches in the topology
- main.log.info("Please wait for switch connection to "+
- "time out")
- time.sleep(60)
-
- #Gather vendor OFP with tshark
- main.ONOS1.tshark_grep("OFP 86 Vendor",
- tshark_ofp_output)
- main.ONOS1.tshark_grep("TCP 74 ",
- tshark_tcp_output)
-
- #NOTE: 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
-
- t0_system = time.time() * 1000
- main.ONOS1.handle.sendline(
- "sudo iptables -F")
-
- #Counter to track loop count
- counter_loop = 0
- counter_avail1 = 0
- counter_avail2 = 0
- counter_avail3 = 0
- onos1_dev = False
- onos2_dev = False
- onos3_dev = False
- while counter_loop < 60:
- #Continue to check devices for all device
- #availability. When all devices in all 3
- #ONOS instances indicate that devices are available
- #obtain graph event timestamp for t1.
- device_str_obj1 = main.ONOS1cli.devices()
- device_str_obj2 = main.ONOS2cli.devices()
- device_str_obj3 = main.ONOS3cli.devices()
-
- device_json1 = json.loads(device_str_obj1)
- device_json2 = json.loads(device_str_obj2)
- device_json3 = json.loads(device_str_obj3)
-
- for device1 in device_json1:
- if device1['available'] == True:
- counter_avail1 += 1
- if counter_avail1 == int(num_sw):
- onos1_dev = True
- main.log.info("All devices have been "+
- "discovered on ONOS1")
- else:
- counter_avail1 = 0
- for device2 in device_json2:
- if device2['available'] == True:
- counter_avail2 += 1
- if counter_avail2 == int(num_sw):
- onos2_dev = True
- main.log.info("All devices have been "+
- "discovered on ONOS2")
- else:
- counter_avail2 = 0
- for device3 in device_json3:
- if device3['available'] == True:
- counter_avail3 += 1
- if counter_avail3 == int(num_sw):
- onos3_dev = True
- main.log.info("All devices have been "+
- "discovered on ONOS3")
- else:
- counter_avail3 = 0
-
- if onos1_dev and onos2_dev and onos3_dev:
- main.log.info("All devices have been discovered "+
- "on all ONOS instances")
- json_str_topology_metrics_1 =\
- main.ONOS1cli.topology_events_metrics()
- json_str_topology_metrics_2 =\
- main.ONOS2cli.topology_events_metrics()
- json_str_topology_metrics_3 =\
- main.ONOS3cli.topology_events_metrics()
-
- #Exit while loop if all devices discovered
- break
-
- counter_loop += 1
- #Give some time in between CLI calls
- #(will not affect measurement)
- time.sleep(3)
-
- main.ONOS1.tshark_stop()
-
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_ofp_output+" /tmp/")
- os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
- tshark_tcp_output+" /tmp/")
-
- #TODO: Automate OFP output analysis
- #Debug mode - print out packets captured at runtime
- if debug_mode == 'on':
- ofp_file = open(tshark_ofp_output, 'r')
- main.log.info("Tshark OFP Vendor output: ")
- for line in ofp_file:
- tshark_ofp_result_list.append(line)
- main.log.info(line)
- ofp_file.close()
-
- tcp_file = open(tshark_tcp_output, 'r')
- main.log.info("Tshark TCP 74 output: ")
- for line in tcp_file:
- tshark_tcp_result_list.append(line)
- main.log.info(line)
- tcp_file.close()
-
- json_obj_1 = json.loads(json_str_topology_metrics_1)
- json_obj_2 = json.loads(json_str_topology_metrics_2)
- json_obj_3 = json.loads(json_str_topology_metrics_3)
-
- graph_timestamp_1 = \
- json_obj_1[graphTimestamp]['value']
- graph_timestamp_2 = \
- json_obj_2[graphTimestamp]['value']
- graph_timestamp_3 = \
- json_obj_3[graphTimestamp]['value']
-
- graph_lat_1 = int(graph_timestamp_1) - int(t0_system)
- graph_lat_2 = int(graph_timestamp_2) - int(t0_system)
- graph_lat_3 = int(graph_timestamp_3) - int(t0_system)
-
- avg_graph_lat = \
- (int(graph_lat_1) +\
- int(graph_lat_2) +\
- int(graph_lat_3)) / 3
-
- if avg_graph_lat > sw_disc_threshold_min \
- and avg_graph_lat < sw_disc_threshold_max:
- sw_discovery_lat_list.append(
- avg_graph_lat)
- else:
- main.log.info("100 Switch discovery latency "+
- "exceeded the threshold.")
-
- #END ITERATION FOR LOOP
-
- sw_lat_min = min(sw_discovery_lat_list)
- sw_lat_max = max(sw_discovery_lat_list)
- sw_lat_avg = sum(sw_discovery_lat_list) /\
- len(sw_discovery_lat_list)
-
- main.log.report("100 Switch discovery lat "+\
- "Min: "+str(sw_lat_min)+" ms"+\
- "Max: "+str(sw_lat_max)+" ms"+\
- "Avg: "+str(sw_lat_avg)+" ms")
-
- def CASE6(self, main):
- '''
- Increase number of nodes and initiate CLI
- '''
- import time
-
- ONOS1_ip = main.params['CTRL']['ip1']
- ONOS2_ip = main.params['CTRL']['ip2']
- ONOS3_ip = main.params['CTRL']['ip3']
- ONOS4_ip = main.params['CTRL']['ip4']
- ONOS5_ip = main.params['CTRL']['ip5']
- ONOS6_ip = main.params['CTRL']['ip6']
- ONOS7_ip = main.params['CTRL']['ip7']
-
- cell_name = main.params['ENV']['cellName']
-
- global cluster_count
-
- #Cluster size increased everytime the case is defined
- cluster_count += 2
-
- main.log.report("Increasing cluster size to "+
- str(cluster_count))
-
- install_result = main.FALSE
- if cluster_count == 5:
- main.log.info("Installing nodes 4 and 5")
- node4_result = \
- main.ONOSbench.onos_install(node=ONOS4_ip)
- node5_result = \
- main.ONOSbench.onos_install(node=ONOS5_ip)
- install_result = node4_result and node5_result
-
- time.sleep(5)
-
- main.ONOS4cli.start_onos_cli(ONOS4_ip)
- main.ONOS5cli.start_onos_cli(ONOS5_ip)
-
- elif cluster_count == 7:
- main.log.info("Installing nodes 4 and 5")
- node6_result = \
- main.ONOSbench.onos_install(node=ONOS6_ip)
- node7_result = \
- main.ONOSbench.onos_install(node=ONOS7_ip)
- install_result = node6_result and node7_result
-
- time.sleep(5)
-
- main.ONOS6cli.start_onos_cli(ONOS6_ip)
- main.ONOS7cli.start_onos_cli(ONOS7_ip)
-
-
-
-
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.py b/TestON/tests/TopoPerfNext/TopoPerfNext.py
deleted file mode 100644
index 12e53e5..0000000
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.py
+++ /dev/null
@@ -1,1951 +0,0 @@
-# TopoPerfNext
-#
-# Topology Performance test for ONOS-next
-#
-# andrew@onlab.us
-#
-# If your machine does not come with numpy
-# run the following command:
-# sudo apt-get install python-numpy python-scipy
-
-import time
-import sys
-import os
-import re
-
-
-class TopoPerfNext:
-
- def __init__( self ):
- self.default = ''
-
- def CASE1( self, main ):
- """
- ONOS startup sequence
- """
- import time
-
- # Global cluster count for scale-out purposes
- global clusterCount
- # Set initial cluster count
- clusterCount = 1
- ##
-
- cellName = main.params[ 'ENV' ][ 'cellName' ]
-
- gitPull = main.params[ 'GIT' ][ 'autoPull' ]
- checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
-
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
- ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
- ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
- ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
-
- MN1Ip = main.params[ 'MN' ][ 'ip1' ]
- BENCHIp = main.params[ 'BENCH' ][ 'ip' ]
-
- topoCfgFile = main.params[ 'TEST' ][ 'topoConfigFile' ]
- topoCfgName = main.params[ 'TEST' ][ 'topoConfigName' ]
-
- mvnCleanInstall = main.params[ 'TEST' ][ 'mci' ]
-
- main.case( "Setting up test environment" )
- main.log.info( "Copying topology event accumulator config" +
- " to ONOS /package/etc" )
- main.ONOSbench.handle.sendline( "cp ~/" +
- topoCfgFile +
- " ~/ONOS/tools/package/etc/" +
- topoCfgName )
- main.ONOSbench.handle.expect( "\$" )
-
- main.log.report( "Setting up test environment" )
-
- main.step( "Cleaning previously installed ONOS if any" )
- main.ONOSbench.onosUninstall( nodeIp=ONOS2Ip )
- main.ONOSbench.onosUninstall( nodeIp=ONOS3Ip )
- main.ONOSbench.onosUninstall( nodeIp=ONOS4Ip )
- main.ONOSbench.onosUninstall( nodeIp=ONOS5Ip )
- main.ONOSbench.onosUninstall( nodeIp=ONOS6Ip )
- #main.ONOSbench.onosUninstall( nodeIp=ONOS7Ip )
-
- main.step( "Creating cell file" )
- cellFileResult = main.ONOSbench.createCellFile(
- BENCHIp, cellName, MN1Ip,
- "onos-core,onos-app-metrics,onos-app-gui",
- ONOS1Ip )
-
- main.step( "Applying cell file to environment" )
- cellApplyResult = main.ONOSbench.setCell( cellName )
- verifyCellResult = main.ONOSbench.verifyCell()
-
- # NOTE: This step may be removed after proper
- # copy cat log functionality
- main.step( "Removing raft/copy-cat logs from ONOS nodes" )
- main.ONOSbench.onosRemoveRaftLogs()
- time.sleep( 30 )
-
- main.step( "Git checkout and pull " + checkoutBranch )
- if gitPull == 'on':
- # checkoutResult = \
- # main.ONOSbench.gitCheckout( checkoutBranch )
- checkoutResult = main.TRUE
- pullResult = main.ONOSbench.gitPull()
- else:
- checkoutResult = main.TRUE
- pullResult = main.TRUE
- main.log.info( "Skipped git checkout and pull" )
-
- main.log.report( "Commit information - " )
- main.ONOSbench.getVersion( report=True )
-
- main.step( "Using mvn clean & install" )
- if mvnCleanInstall == 'on':
- mvnResult = main.ONOSbench.cleanInstall()
- elif mvnCleanInstall == 'off':
- main.log.info("mci turned off by settings")
- mvnResult = main.TRUE
-
- main.step( "Set cell for ONOS cli env" )
- main.ONOS1cli.setCell( cellName )
- # main.ONOS2cli.setCell( cellName )
- # main.ONOS3cli.setCell( cellName )
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.onosPackage()
-
- main.step( "Installing ONOS package" )
- install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip )
- #install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
- #install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
-
- time.sleep( 10 )
-
- main.step( "Start onos cli" )
- cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip )
- #cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip )
- #cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=cellFileResult and cellApplyResult and
- verifyCellResult and checkoutResult and
- pullResult and mvnResult and
- install1Result, # and install2Result and
- # install3Result,
- onpass="Test Environment setup successful",
- onfail="Failed to setup test environment" )
-
- def CASE2( self, main ):
- """
- Assign s1 to ONOS1 and measure latency
-
- There are 4 levels of latency measurements to this test:
- 1 ) End-to-end measurement: Complete end-to-end measurement
- from TCP ( SYN/ACK ) handshake to Graph change
- 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
- measurement from OFP Vendor message to Graph change
- 3 ) OFP-to-device measurement: 'ONOS processing without
- graph change' snippet of measurement from OFP vendor
- message to Device change timestamp
- 4 ) T0-to-device measurement: Measurement that includes
- the switch handshake to devices timestamp without
- the graph view change. ( TCP handshake -> Device
- change )
- """
- import time
- import subprocess
- import json
- import requests
- import os
- import numpy
- global clusterCount
-
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
- ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
- ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
- ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
-
- ONOSUser = main.params[ 'CTRL' ][ 'user' ]
-
- defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
-
- # Number of iterations of case
- numIter = main.params[ 'TEST' ][ 'numIter' ]
- # Number of first 'x' iterations to ignore:
- iterIgnore = int( main.params[ 'TEST' ][ 'iterIgnore' ] )
-
- # Timestamp 'keys' for json metrics output.
- # These are subject to change, hence moved into params
- deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
- graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
-
- debugMode = main.params[ 'TEST' ][ 'debugMode' ]
- onosLog = main.params[ 'TEST' ][ 'onosLogFile' ]
-
- # Threshold for the test
- thresholdStr = main.params[ 'TEST' ][ 'singleSwThreshold' ]
- thresholdObj = thresholdStr.split( "," )
- thresholdMin = int( thresholdObj[ 0 ] )
- thresholdMax = int( thresholdObj[ 1 ] )
-
- # List of switch add latency collected from
- # all iterations
- latencyEndToEndList = []
- latencyOfpToGraphList = []
- latencyOfpToDeviceList = []
- latencyT0ToDeviceList = []
- latencyTcpToOfpList = []
-
- # Directory/file to store tshark results
- tsharkOfOutput = "/tmp/tshark_of_topo.txt"
- tsharkTcpOutput = "/tmp/tshark_tcp_topo.txt"
-
- # String to grep in tshark output
- tsharkTcpString = "TCP 74 " + defaultSwPort
- tsharkOfString = "OFP 86 Vendor"
-
- # Initialize assertion to TRUE
- assertion = main.TRUE
-
- localTime = time.strftime( '%x %X' )
- localTime = localTime.replace( "/", "" )
- localTime = localTime.replace( " ", "_" )
- localTime = localTime.replace( ":", "" )
- if debugMode == 'on':
- main.ONOS1.tsharkPcap( "eth0",
- "/tmp/single_sw_lat_pcap_" + localTime )
-
- main.log.info( "Debug mode is on" )
-
- main.log.report( "Latency of adding one switch to controller" )
- main.log.report( "First " + str( iterIgnore ) + " iterations ignored" +
- " for jvm warmup time" )
- main.log.report( "Total iterations of test: " + str( numIter ) )
-
- for i in range( 0, int( numIter ) ):
- main.log.info( "Starting tshark capture" )
-
- #* TCP [ ACK, SYN ] is used as t0A, the
- # very first "exchange" between ONOS and
- # the switch for end-to-end measurement
- #* OFP [ Stats Reply ] is used for t0B
- # the very last OFP message between ONOS
- # and the switch for ONOS measurement
- main.ONOS1.tsharkGrep( tsharkTcpString,
- tsharkTcpOutput )
- main.ONOS1.tsharkGrep( tsharkOfString,
- tsharkOfOutput )
-
- # Wait and ensure tshark is started and
- # capturing
- time.sleep( 10 )
-
- main.log.info( "Assigning s1 to controller" )
-
- main.Mininet1.assignSwController(
- sw="1",
- ip1=ONOS1Ip,
- port1=defaultSwPort )
-
- # Wait and ensure switch is assigned
- # before stopping tshark
- time.sleep( 30 )
-
- main.log.info( "Stopping all Tshark processes" )
- main.ONOS1.stopTshark()
-
- # tshark output is saved in ONOS. Use subprocess
- # to copy over files to TestON for parsing
- main.log.info( "Copying over tshark files" )
-
- # TCP CAPTURE ****
- # Copy the tshark output from ONOS machine to
- # TestON machine in tsharkTcpOutput directory>file
- os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
- tsharkTcpOutput + " /tmp/" )
- tcpFile = open( tsharkTcpOutput, 'r' )
- tempText = tcpFile.readline()
- tempText = tempText.split( " " )
-
- main.log.info( "Object read in from TCP capture: " +
- str( tempText ) )
- if len( tempText ) > 1:
- t0Tcp = float( tempText[ 1 ] ) * 1000.0
- else:
- main.log.error( "Tshark output file for TCP" +
- " returned unexpected results" )
- t0Tcp = 0
- assertion = main.FALSE
-
- tcpFile.close()
- #****************
-
- # OF CAPTURE ****
- os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
- tsharkOfOutput + " /tmp/" )
- ofFile = open( tsharkOfOutput, 'r' )
-
- lineOfp = ""
- # Read until last line of file
- while True:
- tempText = ofFile.readline()
- if tempText != '':
- lineOfp = tempText
- else:
- break
- obj = lineOfp.split( " " )
-
- main.log.info( "Object read in from OFP capture: " +
- str( lineOfp ) )
-
- if len( lineOfp ) > 1:
- t0Ofp = float( obj[ 1 ] ) * 1000.0
- else:
- main.log.error( "Tshark output file for OFP" +
- " returned unexpected results" )
- t0Ofp = 0
- assertion = main.FALSE
-
- ofFile.close()
- #****************
-
- jsonStr1 = main.ONOS1cli.topologyEventsMetrics()
- # Initialize scale-out variables
- jsonStr2 = ""
- jsonStr3 = ""
- jsonStr4 = ""
- jsonStr5 = ""
- jsonStr6 = ""
- jsonStr7 = ""
-
- jsonObj1 = json.loads( jsonStr1 )
- # Initialize scale-out variables
- jsonObj2 = ""
- jsonObj3 = ""
- jsonObj4 = ""
- jsonObj5 = ""
- jsonObj6 = ""
- jsonObj7 = ""
-
- # Obtain graph timestamp. This timestsamp captures
- # the epoch time at which the topology graph was updated.
- graphTimestamp1 = \
- jsonObj1[ graphTimestamp ][ 'value' ]
- # Obtain device timestamp. This timestamp captures
- # the epoch time at which the device event happened
- deviceTimestamp1 = \
- jsonObj1[ deviceTimestamp ][ 'value' ]
-
- # t0 to device processing latency
- deltaDevice1 = int( deviceTimestamp1 ) - int( t0Tcp )
-
- # t0 to graph processing latency ( end-to-end )
- deltaGraph1 = int( graphTimestamp1 ) - int( t0Tcp )
-
- # ofp to graph processing latency ( ONOS processing )
- deltaOfpGraph1 = int( graphTimestamp1 ) - int( t0Ofp )
-
- # ofp to device processing latency ( ONOS processing )
- deltaOfpDevice1 = float( deviceTimestamp1 ) - float( t0Ofp )
-
- # TODO: Create even cluster number events
-
- # Include scale-out measurements when applicable
- if clusterCount >= 3:
- jsonStr2 = main.ONOS2cli.topologyEventsMetrics()
- jsonStr3 = main.ONOS3cli.topologyEventsMetrics()
- jsonObj2 = json.loads( jsonStr2 )
- jsonObj3 = json.loads( jsonStr3 )
- graphTimestamp2 = \
- jsonObj2[ graphTimestamp ][ 'value' ]
- graphTimestamp3 = \
- jsonObj3[ graphTimestamp ][ 'value' ]
- deviceTimestamp2 = \
- jsonObj2[ deviceTimestamp ][ 'value' ]
- deviceTimestamp3 = \
- jsonObj3[ deviceTimestamp ][ 'value' ]
- deltaDevice2 = int( deviceTimestamp2 ) - int( t0Tcp )
- deltaDevice3 = int( deviceTimestamp3 ) - int( t0Tcp )
- deltaGraph2 = int( graphTimestamp2 ) - int( t0Tcp )
- deltaGraph3 = int( graphTimestamp3 ) - int( t0Tcp )
- deltaOfpGraph2 = int( graphTimestamp2 ) - int( t0Ofp )
- deltaOfpGraph3 = int( graphTimestamp3 ) - int( t0Ofp )
- deltaOfpDevice2 = float( deviceTimestamp2 ) -\
- float( t0Ofp )
- deltaOfpDevice3 = float( deviceTimestamp3 ) -\
- float( t0Ofp )
- else:
- deltaDevice2 = 0
- deltaDevice3 = 0
- deltaGraph2 = 0
- deltaGraph3 = 0
- deltaOfpGraph2 = 0
- deltaOfpGraph3 = 0
- deltaOfpDevice2 = 0
- deltaOfpDevice3 = 0
-
- if clusterCount >= 5:
- jsonStr4 = main.ONOS4cli.topologyEventsMetrics()
- jsonStr5 = main.ONOS5cli.topologyEventsMetrics()
- jsonObj4 = json.loads( jsonStr4 )
- jsonObj5 = json.loads( jsonStr5 )
- graphTimestamp4 = \
- jsonObj4[ graphTimestamp ][ 'value' ]
- graphTimestamp5 = \
- jsonObj5[ graphTimestamp ][ 'value' ]
- deviceTimestamp4 = \
- jsonObj4[ deviceTimestamp ][ 'value' ]
- deviceTimestamp5 = \
- jsonObj5[ deviceTimestamp ][ 'value' ]
- deltaDevice4 = int( deviceTimestamp4 ) - int( t0Tcp )
- deltaDevice5 = int( deviceTimestamp5 ) - int( t0Tcp )
- deltaGraph4 = int( graphTimestamp4 ) - int( t0Tcp )
- deltaGraph5 = int( graphTimestamp5 ) - int( t0Tcp )
- deltaOfpGraph4 = int( graphTimestamp4 ) - int( t0Ofp )
- deltaOfpGraph5 = int( graphTimestamp5 ) - int( t0Ofp )
- deltaOfpDevice4 = float( deviceTimestamp4 ) -\
- float( t0Ofp )
- deltaOfpDevice5 = float( deviceTimestamp5 ) -\
- float( t0Ofp )
- else:
- deltaDevice4 = 0
- deltaDevice5 = 0
- deltaGraph4 = 0
- deltaGraph5 = 0
- deltaOfpGraph4 = 0
- deltaOfpGraph5 = 0
- deltaOfpDevice4 = 0
- deltaOfpDevice5 = 0
-
- if clusterCount >= 7:
- jsonStr6 = main.ONOS6cli.topologyEventsMetrics()
- jsonStr7 = main.ONOS7cli.topologyEventsMetrics()
- jsonObj6 = json.loads( jsonStr6 )
- jsonObj7 = json.loads( jsonStr7 )
- graphTimestamp6 = \
- jsonObj6[ graphTimestamp ][ 'value' ]
- graphTimestamp7 = \
- jsonObj7[ graphTimestamp ][ 'value' ]
- deviceTimestamp6 = \
- jsonObj6[ deviceTimestamp ][ 'value' ]
- deviceTimestamp7 = \
- jsonObj7[ deviceTimestamp ][ 'value' ]
- deltaDevice6 = int( deviceTimestamp6 ) - int( t0Tcp )
- deltaDevice7 = int( deviceTimestamp7 ) - int( t0Tcp )
- deltaGraph6 = int( graphTimestamp6 ) - int( t0Tcp )
- deltaGraph7 = int( graphTimestamp7 ) - int( t0Tcp )
- deltaOfpGraph6 = int( graphTimestamp6 ) - int( t0Ofp )
- deltaOfpGraph7 = int( graphTimestamp7 ) - int( t0Ofp )
- deltaOfpDevice6 = float( deviceTimestamp6 ) -\
- float( t0Ofp )
- deltaOfpDevice7 = float( deviceTimestamp7 ) -\
- float( t0Ofp )
- else:
- deltaDevice6 = 0
- deltaDevice7 = 0
- deltaGraph6 = 0
- deltaGraph7 = 0
- deltaOfpGraph6 = 0
- deltaOfpGraph7 = 0
- deltaOfpDevice6 = 0
- deltaOfpDevice7 = 0
-
- # Get average of delta from all instances
- avgDeltaDevice = \
- ( int( deltaDevice1 ) +
- int( deltaDevice2 ) +
- int( deltaDevice3 ) +
- int( deltaDevice4 ) +
- int( deltaDevice5 ) +
- int( deltaDevice6 ) +
- int( deltaDevice7 ) ) / clusterCount
-
- # Ensure avg delta meets the threshold before appending
- if avgDeltaDevice > 0.0 and avgDeltaDevice < 10000\
- and int( i ) > iterIgnore:
- latencyT0ToDeviceList.append( avgDeltaDevice )
- else:
- main.log.info(
- "Results for t0-to-device ignored" +
- "due to excess in threshold / warmup iteration." )
-
- # Get average of delta from all instances
- # TODO: use max delta graph
- #maxDeltaGraph = max( three )
- avgDeltaGraph = \
- ( int( deltaGraph1 ) +
- int( deltaGraph2 ) +
- int( deltaGraph3 ) +
- int( deltaGraph4 ) +
- int( deltaGraph5 ) +
- int( deltaGraph6 ) +
- int( deltaGraph7 ) ) / clusterCount
-
- # Ensure avg delta meets the threshold before appending
- if avgDeltaGraph > 0.0 and avgDeltaGraph < 10000\
- and int( i ) > iterIgnore:
- latencyEndToEndList.append( avgDeltaGraph )
- else:
- main.log.info( "Results for end-to-end ignored" +
- "due to excess in threshold" )
-
- avgDeltaOfpGraph = \
- ( int( deltaOfpGraph1 ) +
- int( deltaOfpGraph2 ) +
- int( deltaOfpGraph3 ) +
- int( deltaOfpGraph4 ) +
- int( deltaOfpGraph5 ) +
- int( deltaOfpGraph6 ) +
- int( deltaOfpGraph7 ) ) / clusterCount
-
- if avgDeltaOfpGraph > thresholdMin \
- and avgDeltaOfpGraph < thresholdMax\
- and int( i ) > iterIgnore:
- latencyOfpToGraphList.append( avgDeltaOfpGraph )
- elif avgDeltaOfpGraph > ( -10 ) and \
- avgDeltaOfpGraph < 0.0 and\
- int( i ) > iterIgnore:
- main.log.info( "Sub-millisecond result likely; " +
- "negative result was rounded to 0" )
- # NOTE: Current metrics framework does not
- # support sub-millisecond accuracy. Therefore,
- # if the result is negative, we can reasonably
- # conclude sub-millisecond results and just
- # append the best rounded effort - 0 ms.
- latencyOfpToGraphList.append( 0 )
- else:
- main.log.info( "Results for ofp-to-graph " +
- "ignored due to excess in threshold" )
-
- avgDeltaOfpDevice = \
- ( float( deltaOfpDevice1 ) +
- float( deltaOfpDevice2 ) +
- float( deltaOfpDevice3 ) +
- float( deltaOfpDevice4 ) +
- float( deltaOfpDevice5 ) +
- float( deltaOfpDevice6 ) +
- float( deltaOfpDevice7 ) ) / clusterCount
-
- # NOTE: ofp - delta measurements are occasionally negative
- # due to system time misalignment.
- latencyOfpToDeviceList.append( avgDeltaOfpDevice )
-
- deltaOfpTcp = int( t0Ofp ) - int( t0Tcp )
- if deltaOfpTcp > thresholdMin \
- and deltaOfpTcp < thresholdMax and\
- int( i ) > iterIgnore:
- latencyTcpToOfpList.append( deltaOfpTcp )
- else:
- main.log.info( "Results fo tcp-to-ofp " +
- "ignored due to excess in threshold" )
-
- # TODO:
- # Fetch logs upon threshold excess
-
- main.log.info( "ONOS1 delta end-to-end: " +
- str( deltaGraph1 ) + " ms" )
-
- main.log.info( "ONOS1 delta OFP - graph: " +
- str( deltaOfpGraph1 ) + " ms" )
-
- main.log.info( "ONOS1 delta device - t0: " +
- str( deltaDevice1 ) + " ms" )
-
- main.log.info( "TCP to OFP delta: " +
- str( deltaOfpTcp ) + " ms" )
-
- main.step( "Remove switch from controller" )
- main.Mininet1.deleteSwController( "s1" )
-
- time.sleep( 5 )
-
- # END of for loop iteration
-
- # If there is at least 1 element in each list,
- # pass the test case
- if len( latencyEndToEndList ) > 0 and\
- len( latencyOfpToGraphList ) > 0 and\
- len( latencyOfpToDeviceList ) > 0 and\
- len( latencyT0ToDeviceList ) > 0 and\
- len( latencyTcpToOfpList ) > 0:
- assertion = main.TRUE
- elif len( latencyEndToEndList ) == 0:
- # The appending of 0 here is to prevent
- # the min,max,sum functions from failing
- # below
- latencyEndToEndList.append( 0 )
- assertion = main.FALSE
- elif len( latencyOfpToGraphList ) == 0:
- latencyOfpToGraphList.append( 0 )
- assertion = main.FALSE
- elif len( latencyOfpToDeviceList ) == 0:
- latencyOfpToDeviceList.append( 0 )
- assertion = main.FALSE
- elif len( latencyT0ToDeviceList ) == 0:
- latencyT0ToDeviceList.append( 0 )
- assertion = main.FALSE
- elif len( latencyTcpToOfpList ) == 0:
- latencyTcpToOfpList.append( 0 )
- assertion = main.FALSE
-
- # Calculate min, max, avg of latency lists
- latencyEndToEndMax = \
- int( max( latencyEndToEndList ) )
- latencyEndToEndMin = \
- int( min( latencyEndToEndList ) )
- latencyEndToEndAvg = \
- ( int( sum( latencyEndToEndList ) ) /
- len( latencyEndToEndList ) )
- latencyEndToEndStdDev = \
- str( round( numpy.std( latencyEndToEndList ), 1 ) )
-
- latencyOfpToGraphMax = \
- int( max( latencyOfpToGraphList ) )
- latencyOfpToGraphMin = \
- int( min( latencyOfpToGraphList ) )
- latencyOfpToGraphAvg = \
- ( int( sum( latencyOfpToGraphList ) ) /
- len( latencyOfpToGraphList ) )
- latencyOfpToGraphStdDev = \
- str( round( numpy.std( latencyOfpToGraphList ), 1 ) )
-
- latencyOfpToDeviceMax = \
- int( max( latencyOfpToDeviceList ) )
- latencyOfpToDeviceMin = \
- int( min( latencyOfpToDeviceList ) )
- latencyOfpToDeviceAvg = \
- ( int( sum( latencyOfpToDeviceList ) ) /
- len( latencyOfpToDeviceList ) )
- latencyOfpToDeviceStdDev = \
- str( round( numpy.std( latencyOfpToDeviceList ), 1 ) )
-
- latencyT0ToDeviceMax = \
- int( max( latencyT0ToDeviceList ) )
- latencyT0ToDeviceMin = \
- int( min( latencyT0ToDeviceList ) )
- latencyT0ToDeviceAvg = \
- ( int( sum( latencyT0ToDeviceList ) ) /
- len( latencyT0ToDeviceList ) )
- latencyOfpToDeviceStdDev = \
- str( round( numpy.std( latencyT0ToDeviceList ), 1 ) )
-
- latencyTcpToOfpMax = \
- int( max( latencyTcpToOfpList ) )
- latencyTcpToOfpMin = \
- int( min( latencyTcpToOfpList ) )
- latencyTcpToOfpAvg = \
- ( int( sum( latencyTcpToOfpList ) ) /
- len( latencyTcpToOfpList ) )
- latencyTcpToOfpStdDev = \
- str( round( numpy.std( latencyTcpToOfpList ), 1 ) )
-
- main.log.report( "Cluster size: " + str( clusterCount ) +
- " node(s)" )
- main.log.report( "Switch add - End-to-end latency: " +
- "Avg: " + str( latencyEndToEndAvg ) + " ms " +
- "Std Deviation: " + latencyEndToEndStdDev + " ms" )
- main.log.report(
- "Switch add - OFP-to-Graph latency: " +
- "Note: results are not accurate to sub-millisecond. " +
- "Any sub-millisecond results are rounded to 0 ms. " )
- main.log.report( "Avg: " + str( latencyOfpToGraphAvg ) + " ms " +
- "Std Deviation: " + latencyOfpToGraphStdDev + " ms" )
- main.log.report( "Switch add - TCP-to-OFP latency: " +
- "Avg: " + str( latencyTcpToOfpAvg ) + " ms " +
- "Std Deviation: " + latencyTcpToOfpStdDev + " ms" )
-
- if debugMode == 'on':
- main.ONOS1.cpLogsToDir( "/opt/onos/log/karaf.log",
- "/tmp/", copyFileName="sw_lat_karaf" )
-
- utilities.assert_equals( expect=main.TRUE, actual=assertion,
- onpass="Switch latency test successful",
- onfail="Switch latency test failed" )
-
- def CASE3( self, main ):
- """
- Bring port up / down and measure latency.
- Port enable / disable is simulated by ifconfig up / down
-
- In ONOS-next, we must ensure that the port we are
- manipulating is connected to another switch with a valid
- connection. Otherwise, graph view will not be updated.
- """
- import time
- import subprocess
- import os
- import requests
- import json
- import numpy
- global clusterCount
-
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOSUser = main.params[ 'CTRL' ][ 'user' ]
-
- defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
-
- assertion = main.TRUE
- # Number of iterations of case
- numIter = main.params[ 'TEST' ][ 'numIter' ]
-
- # Timestamp 'keys' for json metrics output.
- # These are subject to change, hence moved into params
- deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
- graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
-
- debugMode = main.params[ 'TEST' ][ 'debugMode' ]
-
- localTime = time.strftime( '%x %X' )
- localTime = localTime.replace( "/", "" )
- localTime = localTime.replace( " ", "_" )
- localTime = localTime.replace( ":", "" )
- if debugMode == 'on':
- main.ONOS1.tsharkPcap( "eth0",
- "/tmp/port_lat_pcap_" + localTime )
-
- # Threshold for this test case
- upThresholdStr = main.params[ 'TEST' ][ 'portUpThreshold' ]
- downThresholdStr = main.params[ 'TEST' ][ 'portDownThreshold' ]
-
- upThresholdObj = upThresholdStr.split( "," )
- downThresholdObj = downThresholdStr.split( "," )
-
- upThresholdMin = int( upThresholdObj[ 0 ] )
- upThresholdMax = int( upThresholdObj[ 1 ] )
-
- downThresholdMin = int( downThresholdObj[ 0 ] )
- downThresholdMax = int( downThresholdObj[ 1 ] )
-
- # NOTE: Some hardcoded variables you may need to configure
- # besides the params
-
- tsharkPortStatus = "OFP 130 Port Status"
-
- tsharkPortUp = "/tmp/tshark_port_up.txt"
- tsharkPortDown = "/tmp/tshark_port_down.txt"
- interfaceConfig = "s1-eth1"
-
- main.log.report( "Port enable / disable latency" )
- main.log.report( "Simulated by ifconfig up / down" )
- main.log.report( "Total iterations of test: " + str( numIter ) )
-
- main.step( "Assign switches s1 and s2 to controller 1" )
- main.Mininet1.assignSwController( sw="1", ip1=ONOS1Ip,
- port1=defaultSwPort )
- main.Mininet1.assignSwController( sw="2", ip1=ONOS1Ip,
- port1=defaultSwPort )
-
- # Give enough time for metrics to propagate the
- # assign controller event. Otherwise, these events may
- # carry over to our measurements
- time.sleep( 15 )
-
- portUpDeviceToOfpList = []
- portUpGraphToOfpList = []
- portDownDeviceToOfpList = []
- portDownGraphToOfpList = []
-
- for i in range( 0, int( numIter ) ):
- main.step( "Starting wireshark capture for port status down" )
- main.ONOS1.tsharkGrep( tsharkPortStatus,
- tsharkPortDown )
-
- time.sleep( 5 )
-
- # Disable interface that is connected to switch 2
- main.step( "Disable port: " + interfaceConfig )
- main.Mininet1.handle.sendline( "sh ifconfig " +
- interfaceConfig + " down" )
- main.Mininet1.handle.expect( "mininet>" )
-
- time.sleep( 3 )
- main.ONOS1.tsharkStop()
-
- # Copy tshark output file from ONOS to TestON instance
- #/tmp directory
- os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
- tsharkPortDown + " /tmp/" )
-
- fPortDown = open( tsharkPortDown, 'r' )
- # Get first line of port down event from tshark
- fLine = fPortDown.readline()
- objDown = fLine.split( " " )
- if len( fLine ) > 0:
- # NOTE: objDown[ 1 ] is a very unreliable
- # way to determine the timestamp. If
- # results seem way off, check the object
- # itself by printing it out
- timestampBeginPtDown = int( float( objDown[ 1 ] ) * 1000 )
- # For some reason, wireshark decides to record the
- # timestamp at the 3rd object position instead of
- # 2nd at unpredictable times. This statement is
- # used to capture that odd behavior and use the
- # correct epoch time
- if timestampBeginPtDown < 1400000000000:
- timestampBeginPtDown = \
- int( float( objDown[ 2 ] ) * 1000 )
-
- main.log.info( "Port down begin timestamp: " +
- str( timestampBeginPtDown ) )
- else:
- main.log.info( "Tshark output file returned unexpected" +
- " results: " + str( objDown ) )
- timestampBeginPtDown = 0
- fPortDown.close()
-
- main.step( "Obtain t1 by metrics call" )
- jsonStrUp1 = main.ONOS1cli.topologyEventsMetrics()
- jsonObj1 = json.loads( jsonStrUp1 )
- # Obtain graph timestamp. This timestsamp captures
- # the epoch time at which the topology graph was updated.
- graphTimestamp1 = \
- jsonObj1[ graphTimestamp ][ 'value' ]
- # Obtain device timestamp. This timestamp captures
- # the epoch time at which the device event happened
- deviceTimestamp1 = \
- jsonObj1[ deviceTimestamp ][ 'value' ]
- # Get delta between graph event and OFP
- ptDownGraphToOfp1 = int( graphTimestamp1 ) -\
- int( timestampBeginPtDown )
- # Get delta between device event and OFP
- ptDownDeviceToOfp1 = int( deviceTimestamp1 ) -\
- int( timestampBeginPtDown )
-
- if clusterCount >= 3:
- jsonStrUp2 = main.ONOS2cli.topologyEventsMetrics()
- jsonStrUp3 = main.ONOS3cli.topologyEventsMetrics()
- jsonObj2 = json.loads( jsonStrUp2 )
- jsonObj3 = json.loads( jsonStrUp3 )
- graphTimestamp2 = \
- jsonObj2[ graphTimestamp ][ 'value' ]
- graphTimestamp3 = \
- jsonObj3[ graphTimestamp ][ 'value' ]
- deviceTimestamp2 = \
- jsonObj2[ deviceTimestamp ][ 'value' ]
- deviceTimestamp3 = \
- jsonObj3[ deviceTimestamp ][ 'value' ]
- ptDownGraphToOfp2 = int( graphTimestamp2 ) -\
- int( timestampBeginPtDown )
- ptDownGraphToOfp3 = int( graphTimestamp3 ) -\
- int( timestampBeginPtDown )
- ptDownDeviceToOfp2 = int( deviceTimestamp2 ) -\
- int( timestampBeginPtDown )
- ptDownDeviceToOfp3 = int( deviceTimestamp3 ) -\
- int( timestampBeginPtDown )
- else:
- ptDownGraphToOfp2 = 0
- ptDownGraphToOfp3 = 0
- ptDownDeviceToOfp2 = 0
- ptDownDeviceToOfp3 = 0
-
- if clusterCount >= 5:
- jsonStrUp4 = main.ONOS4cli.topologyEventsMetrics()
- jsonStrUp5 = main.ONOS5cli.topologyEventsMetrics()
- jsonObj4 = json.loads( jsonStrUp4 )
- jsonObj5 = json.loads( jsonStrUp5 )
- graphTimestamp4 = \
- jsonObj4[ graphTimestamp ][ 'value' ]
- graphTimestamp5 = \
- jsonObj5[ graphTimestamp ][ 'value' ]
- deviceTimestamp4 = \
- jsonObj4[ deviceTimestamp ][ 'value' ]
- deviceTimestamp5 = \
- jsonObj5[ deviceTimestamp ][ 'value' ]
- ptDownGraphToOfp4 = int( graphTimestamp4 ) -\
- int( timestampBeginPtDown )
- ptDownGraphToOfp5 = int( graphTimestamp5 ) -\
- int( timestampBeginPtDown )
- ptDownDeviceToOfp4 = int( deviceTimestamp4 ) -\
- int( timestampBeginPtDown )
- ptDownDeviceToOfp5 = int( deviceTimestamp5 ) -\
- int( timestampBeginPtDown )
- else:
- ptDownGraphToOfp4 = 0
- ptDownGraphToOfp5 = 0
- ptDownDeviceToOfp4 = 0
- ptDownDeviceToOfp5 = 0
-
- if clusterCount >= 7:
- jsonStrUp6 = main.ONOS6cli.topologyEventsMetrics()
- jsonStrUp7 = main.ONOS7cli.topologyEventsMetrics()
- jsonObj6 = json.loads( jsonStrUp6 )
- jsonObj7 = json.loads( jsonStrUp7 )
- graphTimestamp6 = \
- jsonObj6[ graphTimestamp ][ 'value' ]
- graphTimestamp7 = \
- jsonObj7[ graphTimestamp ][ 'value' ]
- deviceTimestamp6 = \
- jsonObj6[ deviceTimestamp ][ 'value' ]
- deviceTimestamp7 = \
- jsonObj7[ deviceTimestamp ][ 'value' ]
- ptDownGraphToOfp6 = int( graphTimestamp6 ) -\
- int( timestampBeginPtDown )
- ptDownGraphToOfp7 = int( graphTimestamp7 ) -\
- int( timestampBeginPtDown )
- ptDownDeviceToOfp6 = int( deviceTimestamp6 ) -\
- int( timestampBeginPtDown )
- ptDownDeviceToOfp7 = int( deviceTimestamp7 ) -\
- int( timestampBeginPtDown )
- else:
- ptDownGraphToOfp6 = 0
- ptDownGraphToOfp7 = 0
- ptDownDeviceToOfp6 = 0
- ptDownDeviceToOfp7 = 0
-
- time.sleep( 3 )
-
- # Caluclate average across clusters
- ptDownGraphToOfpAvg =\
- ( int( ptDownGraphToOfp1 ) +
- int( ptDownGraphToOfp2 ) +
- int( ptDownGraphToOfp3 ) +
- int( ptDownGraphToOfp4 ) +
- int( ptDownGraphToOfp5 ) +
- int( ptDownGraphToOfp6 ) +
- int( ptDownGraphToOfp7 ) ) / clusterCount
- ptDownDeviceToOfpAvg = \
- ( int( ptDownDeviceToOfp1 ) +
- int( ptDownDeviceToOfp2 ) +
- int( ptDownDeviceToOfp3 ) +
- int( ptDownDeviceToOfp4 ) +
- int( ptDownDeviceToOfp5 ) +
- int( ptDownDeviceToOfp6 ) +
- int( ptDownDeviceToOfp7 ) ) / clusterCount
-
- if ptDownGraphToOfpAvg > downThresholdMin and \
- ptDownGraphToOfpAvg < downThresholdMax:
- portDownGraphToOfpList.append(
- ptDownGraphToOfpAvg )
- main.log.info( "Port down: graph to ofp avg: " +
- str( ptDownGraphToOfpAvg ) + " ms" )
- else:
- main.log.info( "Average port down graph-to-ofp result" +
- " exceeded the threshold: " +
- str( ptDownGraphToOfpAvg ) )
-
- if ptDownDeviceToOfpAvg > 0 and \
- ptDownDeviceToOfpAvg < 1000:
- portDownDeviceToOfpList.append(
- ptDownDeviceToOfpAvg )
- main.log.info( "Port down: device to ofp avg: " +
- str( ptDownDeviceToOfpAvg ) + " ms" )
- else:
- main.log.info( "Average port down device-to-ofp result" +
- " exceeded the threshold: " +
- str( ptDownDeviceToOfpAvg ) )
-
- # Port up events
- main.step( "Enable port and obtain timestamp" )
- main.step( "Starting wireshark capture for port status up" )
- main.ONOS1.tsharkGrep( tsharkPortStatus, tsharkPortUp )
- time.sleep( 5 )
-
- main.Mininet1.handle.sendline( "sh ifconfig " +
- interfaceConfig + " up" )
- main.Mininet1.handle.expect( "mininet>" )
-
- # Allow time for tshark to capture event
- time.sleep( 5 )
- main.ONOS1.tsharkStop()
-
- time.sleep( 3 )
- os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
- tsharkPortUp + " /tmp/" )
- fPortUp = open( tsharkPortUp, 'r' )
- fLine = fPortUp.readline()
- objUp = fLine.split( " " )
- if len( fLine ) > 0:
- timestampBeginPtUp = int( float( objUp[ 1 ] ) * 1000 )
- if timestampBeginPtUp < 1400000000000:
- timestampBeginPtUp = \
- int( float( objUp[ 2 ] ) * 1000 )
- main.log.info( "Port up begin timestamp: " +
- str( timestampBeginPtUp ) )
- else:
- main.log.info( "Tshark output file returned unexpected" +
- " results." )
- timestampBeginPtUp = 0
- fPortUp.close()
-
- # Obtain metrics shortly afterwards
- # This timestsamp captures
- # the epoch time at which the topology graph was updated.
- main.step( "Obtain t1 by REST call" )
- jsonStrUp1 = main.ONOS1cli.topologyEventsMetrics()
- jsonObj1 = json.loads( jsonStrUp1 )
- graphTimestamp1 = \
- jsonObj1[ graphTimestamp ][ 'value' ]
- # Obtain device timestamp. This timestamp captures
- # the epoch time at which the device event happened
- deviceTimestamp1 = \
- jsonObj1[ deviceTimestamp ][ 'value' ]
- # Get delta between graph event and OFP
- ptUpGraphToOfp1 = int( graphTimestamp1 ) -\
- int( timestampBeginPtUp )
- # Get delta between device event and OFP
- ptUpDeviceToOfp1 = int( deviceTimestamp1 ) -\
- int( timestampBeginPtUp )
-
- if clusterCount >= 3:
- jsonStrUp2 = main.ONOS2cli.topologyEventsMetrics()
- jsonStrUp3 = main.ONOS3cli.topologyEventsMetrics()
- jsonObj2 = json.loads( jsonStrUp2 )
- jsonObj3 = json.loads( jsonStrUp3 )
- graphTimestamp2 = \
- jsonObj2[ graphTimestamp ][ 'value' ]
- graphTimestamp3 = \
- jsonObj3[ graphTimestamp ][ 'value' ]
- deviceTimestamp2 = \
- jsonObj2[ deviceTimestamp ][ 'value' ]
- deviceTimestamp3 = \
- jsonObj3[ deviceTimestamp ][ 'value' ]
- ptUpGraphToOfp2 = int( graphTimestamp2 ) -\
- int( timestampBeginPtUp )
- ptUpGraphToOfp3 = int( graphTimestamp3 ) -\
- int( timestampBeginPtUp )
- ptUpDeviceToOfp2 = int( deviceTimestamp2 ) -\
- int( timestampBeginPtUp )
- ptUpDeviceToOfp3 = int( deviceTimestamp3 ) -\
- int( timestampBeginPtUp )
- else:
- ptUpGraphToOfp2 = 0
- ptUpGraphToOfp3 = 0
- ptUpDeviceToOfp2 = 0
- ptUpDeviceToOfp3 = 0
-
- if clusterCount >= 5:
- jsonStrUp4 = main.ONOS4cli.topologyEventsMetrics()
- jsonStrUp5 = main.ONOS5cli.topologyEventsMetrics()
- jsonObj4 = json.loads( jsonStrUp4 )
- jsonObj5 = json.loads( jsonStrUp5 )
- graphTimestamp4 = \
- jsonObj4[ graphTimestamp ][ 'value' ]
- graphTimestamp5 = \
- jsonObj5[ graphTimestamp ][ 'value' ]
- deviceTimestamp4 = \
- jsonObj4[ deviceTimestamp ][ 'value' ]
- deviceTimestamp5 = \
- jsonObj5[ deviceTimestamp ][ 'value' ]
- ptUpGraphToOfp4 = int( graphTimestamp4 ) -\
- int( timestampBeginPtUp )
- ptUpGraphToOfp5 = int( graphTimestamp5 ) -\
- int( timestampBeginPtUp )
- ptUpDeviceToOfp4 = int( deviceTimestamp4 ) -\
- int( timestampBeginPtUp )
- ptUpDeviceToOfp5 = int( deviceTimestamp5 ) -\
- int( timestampBeginPtUp )
- else:
- ptUpGraphToOfp4 = 0
- ptUpGraphToOfp5 = 0
- ptUpDeviceToOfp4 = 0
- ptUpDeviceToOfp5 = 0
-
- if clusterCount >= 7:
- jsonStrUp6 = main.ONOS6cli.topologyEventsMetrics()
- jsonStrUp7 = main.ONOS7cli.topologyEventsMetrics()
- jsonObj6 = json.loads( jsonStrUp6 )
- jsonObj7 = json.loads( jsonStrUp7 )
- graphTimestamp6 = \
- jsonObj6[ graphTimestamp ][ 'value' ]
- graphTimestamp7 = \
- jsonObj7[ graphTimestamp ][ 'value' ]
- deviceTimestamp6 = \
- jsonObj6[ deviceTimestamp ][ 'value' ]
- deviceTimestamp7 = \
- jsonObj7[ deviceTimestamp ][ 'value' ]
- ptUpGraphToOfp6 = int( graphTimestamp6 ) -\
- int( timestampBeginPtUp )
- ptUpGraphToOfp7 = int( graphTimestamp7 ) -\
- int( timestampBeginPtUp )
- ptUpDeviceToOfp6 = int( deviceTimestamp6 ) -\
- int( timestampBeginPtUp )
- ptUpDeviceToOfp7 = int( deviceTimestamp7 ) -\
- int( timestampBeginPtUp )
- else:
- ptUpGraphToOfp6 = 0
- ptUpGraphToOfp7 = 0
- ptUpDeviceToOfp6 = 0
- ptUpDeviceToOfp7 = 0
-
- ptUpGraphToOfpAvg = \
- ( int( ptUpGraphToOfp1 ) +
- int( ptUpGraphToOfp2 ) +
- int( ptUpGraphToOfp3 ) +
- int( ptUpGraphToOfp4 ) +
- int( ptUpGraphToOfp5 ) +
- int( ptUpGraphToOfp6 ) +
- int( ptUpGraphToOfp7 ) ) / clusterCount
-
- ptUpDeviceToOfpAvg = \
- ( int( ptUpDeviceToOfp1 ) +
- int( ptUpDeviceToOfp2 ) +
- int( ptUpDeviceToOfp3 ) +
- int( ptUpDeviceToOfp4 ) +
- int( ptUpDeviceToOfp5 ) +
- int( ptUpDeviceToOfp6 ) +
- int( ptUpDeviceToOfp7 ) ) / clusterCount
-
- if ptUpGraphToOfpAvg > upThresholdMin and \
- ptUpGraphToOfpAvg < upThresholdMax:
- portUpGraphToOfpList.append(
- ptUpGraphToOfpAvg )
- main.log.info( "Port down: graph to ofp avg: " +
- str( ptUpGraphToOfpAvg ) + " ms" )
- else:
- main.log.info( "Average port up graph-to-ofp result" +
- " exceeded the threshold: " +
- str( ptUpGraphToOfpAvg ) )
-
- if ptUpDeviceToOfpAvg > upThresholdMin and \
- ptUpDeviceToOfpAvg < upThresholdMax:
- portUpDeviceToOfpList.append(
- ptUpDeviceToOfpAvg )
- main.log.info( "Port up: device to ofp avg: " +
- str( ptUpDeviceToOfpAvg ) + " ms" )
- else:
- main.log.info( "Average port up device-to-ofp result" +
- " exceeded the threshold: " +
- str( ptUpDeviceToOfpAvg ) )
-
- # END ITERATION FOR LOOP
-
- # Check all list for latency existence and set assertion
- if ( portDownGraphToOfpList and portDownDeviceToOfpList
- and portUpGraphToOfpList and portUpDeviceToOfpList ):
- assertion = main.TRUE
-
- main.log.report( "Cluster size: " + str( clusterCount ) +
- " node(s)" )
- # Calculate and report latency measurements
- portDownGraphToOfpMin = min( portDownGraphToOfpList )
- portDownGraphToOfpMax = max( portDownGraphToOfpList )
- portDownGraphToOfpAvg = \
- ( sum( portDownGraphToOfpList ) /
- len( portDownGraphToOfpList ) )
- portDownGraphToOfpStdDev = \
- str( round( numpy.std( portDownGraphToOfpList ), 1 ) )
-
- main.log.report( "Port down graph-to-ofp " +
- "Avg: " + str( portDownGraphToOfpAvg ) + " ms " +
- "Std Deviation: " + portDownGraphToOfpStdDev + " ms" )
-
- portDownDeviceToOfpMin = min( portDownDeviceToOfpList )
- portDownDeviceToOfpMax = max( portDownDeviceToOfpList )
- portDownDeviceToOfpAvg = \
- ( sum( portDownDeviceToOfpList ) /
- len( portDownDeviceToOfpList ) )
- portDownDeviceToOfpStdDev = \
- str( round( numpy.std( portDownDeviceToOfpList ), 1 ) )
-
- main.log.report(
- "Port down device-to-ofp " +
- "Avg: " +
- str( portDownDeviceToOfpAvg ) +
- " ms " +
- "Std Deviation: " +
- portDownDeviceToOfpStdDev +
- " ms" )
-
- portUpGraphToOfpMin = min( portUpGraphToOfpList )
- portUpGraphToOfpMax = max( portUpGraphToOfpList )
- portUpGraphToOfpAvg = \
- ( sum( portUpGraphToOfpList ) /
- len( portUpGraphToOfpList ) )
- portUpGraphToOfpStdDev = \
- str( round( numpy.std( portUpGraphToOfpList ), 1 ) )
-
- main.log.report( "Port up graph-to-ofp " +
- "Avg: " + str( portUpGraphToOfpAvg ) + " ms " +
- "Std Deviation: " + portUpGraphToOfpStdDev + " ms" )
-
- portUpDeviceToOfpMin = min( portUpDeviceToOfpList )
- portUpDeviceToOfpMax = max( portUpDeviceToOfpList )
- portUpDeviceToOfpAvg = \
- ( sum( portUpDeviceToOfpList ) /
- len( portUpDeviceToOfpList ) )
- portUpDeviceToOfpStdDev = \
- str( round( numpy.std( portUpDeviceToOfpList ), 1 ) )
-
- main.log.report( "Port up device-to-ofp " +
- "Avg: " + str( portUpDeviceToOfpAvg ) + " ms " +
- "Std Deviation: " + portUpDeviceToOfpStdDev + " ms" )
-
- # Remove switches from controller for next test
- main.Mininet1.deleteSwController( "s1" )
- main.Mininet1.deleteSwController( "s2" )
-
- utilities.assert_equals(
- expect=main.TRUE,
- actual=assertion,
- onpass="Port discovery latency calculation successful",
- onfail="Port discovery test failed" )
-
- def CASE4( self, main ):
- """
- Link down event using loss rate 100%
-
- Important:
- Use a simple 2 switch topology with 1 link between
- the two switches. Ensure that mac addresses of the
- switches are 1 / 2 respectively
- """
- import time
- import subprocess
- import os
- import requests
- import json
- import numpy
-
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOSUser = main.params[ 'CTRL' ][ 'user' ]
-
- defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
-
- # Number of iterations of case
- numIter = main.params[ 'TEST' ][ 'numIter' ]
-
- # Timestamp 'keys' for json metrics output.
- # These are subject to change, hence moved into params
- deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
- linkTimestamp = main.params[ 'JSON' ][ 'linkTimestamp' ]
- graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
-
- debugMode = main.params[ 'TEST' ][ 'debugMode' ]
-
- localTime = time.strftime( '%x %X' )
- localTime = localTime.replace( "/", "" )
- localTime = localTime.replace( " ", "_" )
- localTime = localTime.replace( ":", "" )
- if debugMode == 'on':
- main.ONOS1.tsharkPcap( "eth0",
- "/tmp/link_lat_pcap_" + localTime )
-
- # Threshold for this test case
- upThresholdStr = main.params[ 'TEST' ][ 'linkUpThreshold' ]
- downThresholdStr = main.params[ 'TEST' ][ 'linkDownThreshold' ]
-
- upThresholdObj = upThresholdStr.split( "," )
- downThresholdObj = downThresholdStr.split( "," )
-
- upThresholdMin = int( upThresholdObj[ 0 ] )
- upThresholdMax = int( upThresholdObj[ 1 ] )
-
- downThresholdMin = int( downThresholdObj[ 0 ] )
- downThresholdMax = int( downThresholdObj[ 1 ] )
-
- assertion = main.TRUE
- # Link event timestamp to system time list
- linkDownLinkToSystemList = []
- linkUpLinkToSystemList = []
- # Graph event timestamp to system time list
- linkDownGraphToSystemList = []
- linkUpGraphToSystemList = []
-
- main.log.report( "Link up / down discovery latency between " +
- "two switches" )
- main.log.report( "Simulated by setting loss-rate 100%" )
- main.log.report( "'tc qdisc add dev <intfs> root netem loss 100%'" )
- main.log.report( "Total iterations of test: " + str( numIter ) )
-
- main.step( "Assign all switches" )
- main.Mininet1.assignSwController( sw="1",
- ip1=ONOS1Ip, port1=defaultSwPort )
- main.Mininet1.assignSwController( sw="2",
- ip1=ONOS1Ip, port1=defaultSwPort )
-
- main.step( "Verifying switch assignment" )
- resultS1 = main.Mininet1.getSwController( sw="s1" )
- resultS2 = main.Mininet1.getSwController( sw="s2" )
-
- # Allow time for events to finish before taking measurements
- time.sleep( 10 )
-
- linkDown1 = False
- linkDown2 = False
- linkDown3 = False
- # Start iteration of link event test
- for i in range( 0, int( numIter ) ):
- main.step( "Getting initial system time as t0" )
-
- # System time in epoch ms
- timestampLinkDownT0 = time.time() * 1000
- # Link down is simulated by 100% loss rate using traffic
- # control command
- main.Mininet1.handle.sendline(
- "sh tc qdisc add dev s1-eth1 root netem loss 100%" )
-
- # TODO: Iterate through 'links' command to verify that
- # link s1 -> s2 went down ( loop timeout 30 seconds )
- # on all 3 ONOS instances
- main.log.info( "Checking ONOS for link update" )
- loopCount = 0
- while( not ( linkDown1 and linkDown2 and linkDown3 )
- and loopCount < 30 ):
- jsonStr1 = main.ONOS1cli.links()
- jsonStr2 = main.ONOS2cli.links()
- jsonStr3 = main.ONOS3cli.links()
-
- if not ( jsonStr1 and jsonStr2 and jsonStr3 ):
- main.log.error( "CLI command returned error " )
- break
- else:
- jsonObj1 = json.loads( jsonStr1 )
- jsonObj2 = json.loads( jsonStr2 )
- jsonObj3 = json.loads( jsonStr3 )
- for obj1 in jsonObj1:
- if '01' not in obj1[ 'src' ][ 'device' ]:
- linkDown1 = True
- main.log.info( "Link down from " +
- "s1 -> s2 on ONOS1 detected" )
- for obj2 in jsonObj2:
- if '01' not in obj2[ 'src' ][ 'device' ]:
- linkDown2 = True
- main.log.info( "Link down from " +
- "s1 -> s2 on ONOS2 detected" )
- for obj3 in jsonObj3:
- if '01' not in obj3[ 'src' ][ 'device' ]:
- linkDown3 = True
- main.log.info( "Link down from " +
- "s1 -> s2 on ONOS3 detected" )
-
- loopCount += 1
- # If CLI doesn't like the continuous requests
- # and exits in this loop, increase the sleep here.
- # Consequently, while loop timeout will increase
- time.sleep( 1 )
-
- # Give time for metrics measurement to catch up
- # NOTE: May need to be configured more accurately
- time.sleep( 10 )
- # If we exited the while loop and link down 1,2,3 are still
- # false, then ONOS has failed to discover link down event
- if not ( linkDown1 and linkDown2 and linkDown3 ):
- main.log.info( "Link down discovery failed" )
-
- linkDownLatGraph1 = 0
- linkDownLatGraph2 = 0
- linkDownLatGraph3 = 0
- linkDownLatDevice1 = 0
- linkDownLatDevice2 = 0
- linkDownLatDevice3 = 0
-
- assertion = main.FALSE
- else:
- jsonTopoMetrics1 =\
- main.ONOS1cli.topologyEventsMetrics()
- jsonTopoMetrics2 =\
- main.ONOS2cli.topologyEventsMetrics()
- jsonTopoMetrics3 =\
- main.ONOS3cli.topologyEventsMetrics()
- jsonTopoMetrics1 = json.loads( jsonTopoMetrics1 )
- jsonTopoMetrics2 = json.loads( jsonTopoMetrics2 )
- jsonTopoMetrics3 = json.loads( jsonTopoMetrics3 )
-
- main.log.info( "Obtaining graph and device timestamp" )
- graphTimestamp1 = \
- jsonTopoMetrics1[ graphTimestamp ][ 'value' ]
- graphTimestamp2 = \
- jsonTopoMetrics2[ graphTimestamp ][ 'value' ]
- graphTimestamp3 = \
- jsonTopoMetrics3[ graphTimestamp ][ 'value' ]
-
- linkTimestamp1 = \
- jsonTopoMetrics1[ linkTimestamp ][ 'value' ]
- linkTimestamp2 = \
- jsonTopoMetrics2[ linkTimestamp ][ 'value' ]
- linkTimestamp3 = \
- jsonTopoMetrics3[ linkTimestamp ][ 'value' ]
-
- if graphTimestamp1 and graphTimestamp2 and\
- graphTimestamp3 and linkTimestamp1 and\
- linkTimestamp2 and linkTimestamp3:
- linkDownLatGraph1 = int( graphTimestamp1 ) -\
- int( timestampLinkDownT0 )
- linkDownLatGraph2 = int( graphTimestamp2 ) -\
- int( timestampLinkDownT0 )
- linkDownLatGraph3 = int( graphTimestamp3 ) -\
- int( timestampLinkDownT0 )
-
- linkDownLatLink1 = int( linkTimestamp1 ) -\
- int( timestampLinkDownT0 )
- linkDownLatLink2 = int( linkTimestamp2 ) -\
- int( timestampLinkDownT0 )
- linkDownLatLink3 = int( linkTimestamp3 ) -\
- int( timestampLinkDownT0 )
- else:
- main.log.error( "There was an error calculating" +
- " the delta for link down event" )
- linkDownLatGraph1 = 0
- linkDownLatGraph2 = 0
- linkDownLatGraph3 = 0
-
- linkDownLatDevice1 = 0
- linkDownLatDevice2 = 0
- linkDownLatDevice3 = 0
-
- main.log.info( "Link down latency ONOS1 iteration " +
- str( i ) + " (end-to-end): " +
- str( linkDownLatGraph1 ) + " ms" )
- main.log.info( "Link down latency ONOS2 iteration " +
- str( i ) + " (end-to-end): " +
- str( linkDownLatGraph2 ) + " ms" )
- main.log.info( "Link down latency ONOS3 iteration " +
- str( i ) + " (end-to-end): " +
- str( linkDownLatGraph3 ) + " ms" )
-
- main.log.info( "Link down latency ONOS1 iteration " +
- str( i ) + " (link-event-to-system-timestamp): " +
- str( linkDownLatLink1 ) + " ms" )
- main.log.info( "Link down latency ONOS2 iteration " +
- str( i ) + " (link-event-to-system-timestamp): " +
- str( linkDownLatLink2 ) + " ms" )
- main.log.info( "Link down latency ONOS3 iteration " +
- str( i ) + " (link-event-to-system-timestamp): " +
- str( linkDownLatLink3 ) )
-
- # Calculate avg of node calculations
- linkDownLatGraphAvg =\
- ( linkDownLatGraph1 +
- linkDownLatGraph2 +
- linkDownLatGraph3 ) / 3
- linkDownLatLinkAvg =\
- ( linkDownLatLink1 +
- linkDownLatLink2 +
- linkDownLatLink3 ) / 3
-
- # Set threshold and append latency to list
- if linkDownLatGraphAvg > downThresholdMin and\
- linkDownLatGraphAvg < downThresholdMax:
- linkDownGraphToSystemList.append(
- linkDownLatGraphAvg )
- else:
- main.log.info( "Link down latency exceeded threshold" )
- main.log.info( "Results for iteration " + str( i ) +
- "have been omitted" )
- if linkDownLatLinkAvg > downThresholdMin and\
- linkDownLatLinkAvg < downThresholdMax:
- linkDownLinkToSystemList.append(
- linkDownLatLinkAvg )
- else:
- main.log.info( "Link down latency exceeded threshold" )
- main.log.info( "Results for iteration " + str( i ) +
- "have been omitted" )
-
- # NOTE: To remove loss rate and measure latency:
- # 'sh tc qdisc del dev s1-eth1 root'
- timestampLinkUpT0 = time.time() * 1000
- main.Mininet1.handle.sendline( "sh tc qdisc del dev " +
- "s1-eth1 root" )
- main.Mininet1.handle.expect( "mininet>" )
-
- main.log.info( "Checking ONOS for link update" )
-
- linkDown1 = True
- linkDown2 = True
- linkDown3 = True
- loopCount = 0
- while( ( linkDown1 and linkDown2 and linkDown3 )
- and loopCount < 30 ):
- jsonStr1 = main.ONOS1cli.links()
- jsonStr2 = main.ONOS2cli.links()
- jsonStr3 = main.ONOS3cli.links()
- if not ( jsonStr1 and jsonStr2 and jsonStr3 ):
- main.log.error( "CLI command returned error " )
- break
- else:
- jsonObj1 = json.loads( jsonStr1 )
- jsonObj2 = json.loads( jsonStr2 )
- jsonObj3 = json.loads( jsonStr3 )
-
- for obj1 in jsonObj1:
- if '01' in obj1[ 'src' ][ 'device' ]:
- linkDown1 = False
- main.log.info( "Link up from " +
- "s1 -> s2 on ONOS1 detected" )
- for obj2 in jsonObj2:
- if '01' in obj2[ 'src' ][ 'device' ]:
- linkDown2 = False
- main.log.info( "Link up from " +
- "s1 -> s2 on ONOS2 detected" )
- for obj3 in jsonObj3:
- if '01' in obj3[ 'src' ][ 'device' ]:
- linkDown3 = False
- main.log.info( "Link up from " +
- "s1 -> s2 on ONOS3 detected" )
-
- loopCount += 1
- time.sleep( 1 )
-
- if ( linkDown1 and linkDown2 and linkDown3 ):
- main.log.info( "Link up discovery failed" )
-
- linkUpLatGraph1 = 0
- linkUpLatGraph2 = 0
- linkUpLatGraph3 = 0
- linkUpLatDevice1 = 0
- linkUpLatDevice2 = 0
- linkUpLatDevice3 = 0
-
- assertion = main.FALSE
- else:
- jsonTopoMetrics1 =\
- main.ONOS1cli.topologyEventsMetrics()
- jsonTopoMetrics2 =\
- main.ONOS2cli.topologyEventsMetrics()
- jsonTopoMetrics3 =\
- main.ONOS3cli.topologyEventsMetrics()
- jsonTopoMetrics1 = json.loads( jsonTopoMetrics1 )
- jsonTopoMetrics2 = json.loads( jsonTopoMetrics2 )
- jsonTopoMetrics3 = json.loads( jsonTopoMetrics3 )
-
- main.log.info( "Obtaining graph and device timestamp" )
- graphTimestamp1 = \
- jsonTopoMetrics1[ graphTimestamp ][ 'value' ]
- graphTimestamp2 = \
- jsonTopoMetrics2[ graphTimestamp ][ 'value' ]
- graphTimestamp3 = \
- jsonTopoMetrics3[ graphTimestamp ][ 'value' ]
-
- linkTimestamp1 = \
- jsonTopoMetrics1[ linkTimestamp ][ 'value' ]
- linkTimestamp2 = \
- jsonTopoMetrics2[ linkTimestamp ][ 'value' ]
- linkTimestamp3 = \
- jsonTopoMetrics3[ linkTimestamp ][ 'value' ]
-
- if graphTimestamp1 and graphTimestamp2 and\
- graphTimestamp3 and linkTimestamp1 and\
- linkTimestamp2 and linkTimestamp3:
- linkUpLatGraph1 = int( graphTimestamp1 ) -\
- int( timestampLinkUpT0 )
- linkUpLatGraph2 = int( graphTimestamp2 ) -\
- int( timestampLinkUpT0 )
- linkUpLatGraph3 = int( graphTimestamp3 ) -\
- int( timestampLinkUpT0 )
-
- linkUpLatLink1 = int( linkTimestamp1 ) -\
- int( timestampLinkUpT0 )
- linkUpLatLink2 = int( linkTimestamp2 ) -\
- int( timestampLinkUpT0 )
- linkUpLatLink3 = int( linkTimestamp3 ) -\
- int( timestampLinkUpT0 )
- else:
- main.log.error( "There was an error calculating" +
- " the delta for link down event" )
- linkUpLatGraph1 = 0
- linkUpLatGraph2 = 0
- linkUpLatGraph3 = 0
-
- linkUpLatDevice1 = 0
- linkUpLatDevice2 = 0
- linkUpLatDevice3 = 0
-
- if debugMode == 'on':
- main.log.info( "Link up latency ONOS1 iteration " +
- str( i ) + " (end-to-end): " +
- str( linkUpLatGraph1 ) + " ms" )
- main.log.info( "Link up latency ONOS2 iteration " +
- str( i ) + " (end-to-end): " +
- str( linkUpLatGraph2 ) + " ms" )
- main.log.info( "Link up latency ONOS3 iteration " +
- str( i ) + " (end-to-end): " +
- str( linkUpLatGraph3 ) + " ms" )
-
- main.log.info(
- "Link up latency ONOS1 iteration " +
- str( i ) +
- " (link-event-to-system-timestamp): " +
- str( linkUpLatLink1 ) +
- " ms" )
- main.log.info(
- "Link up latency ONOS2 iteration " +
- str( i ) +
- " (link-event-to-system-timestamp): " +
- str( linkUpLatLink2 ) +
- " ms" )
- main.log.info(
- "Link up latency ONOS3 iteration " +
- str( i ) +
- " (link-event-to-system-timestamp): " +
- str( linkUpLatLink3 ) )
-
- # Calculate avg of node calculations
- linkUpLatGraphAvg =\
- ( linkUpLatGraph1 +
- linkUpLatGraph2 +
- linkUpLatGraph3 ) / 3
- linkUpLatLinkAvg =\
- ( linkUpLatLink1 +
- linkUpLatLink2 +
- linkUpLatLink3 ) / 3
-
- # Set threshold and append latency to list
- if linkUpLatGraphAvg > upThresholdMin and\
- linkUpLatGraphAvg < upThresholdMax:
- linkUpGraphToSystemList.append(
- linkUpLatGraphAvg )
- else:
- main.log.info( "Link up latency exceeded threshold" )
- main.log.info( "Results for iteration " + str( i ) +
- "have been omitted" )
- if linkUpLatLinkAvg > upThresholdMin and\
- linkUpLatLinkAvg < upThresholdMax:
- linkUpLinkToSystemList.append(
- linkUpLatLinkAvg )
- else:
- main.log.info( "Link up latency exceeded threshold" )
- main.log.info( "Results for iteration " + str( i ) +
- "have been omitted" )
-
- # Calculate min, max, avg of list and report
- linkDownMin = min( linkDownGraphToSystemList )
- linkDownMax = max( linkDownGraphToSystemList )
- linkDownAvg = sum( linkDownGraphToSystemList ) / \
- len( linkDownGraphToSystemList )
- linkUpMin = min( linkUpGraphToSystemList )
- linkUpMax = max( linkUpGraphToSystemList )
- linkUpAvg = sum( linkUpGraphToSystemList ) / \
- len( linkUpGraphToSystemList )
- linkDownStdDev = \
- str( round( numpy.std( linkDownGraphToSystemList ), 1 ) )
- linkUpStdDev = \
- str( round( numpy.std( linkUpGraphToSystemList ), 1 ) )
-
- main.log.report( "Link down latency " +
- "Avg: " + str( linkDownAvg ) + " ms " +
- "Std Deviation: " + linkDownStdDev + " ms" )
- main.log.report( "Link up latency " +
- "Avg: " + str( linkUpAvg ) + " ms " +
- "Std Deviation: " + linkUpStdDev + " ms" )
-
- utilities.assert_equals(
- expect=main.TRUE,
- actual=assertion,
- onpass="Link discovery latency calculation successful",
- onfail="Link discovery latency case failed" )
-
- def CASE5( self, main ):
- """
- 100 Switch discovery latency
-
- Important:
- This test case can be potentially dangerous if
- your machine has previously set iptables rules.
- One of the steps of the test case will flush
- all existing iptables rules.
- Note:
- You can specify the number of switches in the
- params file to adjust the switch discovery size
- ( and specify the corresponding topology in Mininet1
- .topo file )
- """
- import time
- import subprocess
- import os
- import requests
- import json
-
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- MN1Ip = main.params[ 'MN' ][ 'ip1' ]
- ONOSUser = main.params[ 'CTRL' ][ 'user' ]
-
- defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
-
- # Number of iterations of case
- numIter = main.params[ 'TEST' ][ 'numIter' ]
- numSw = main.params[ 'TEST' ][ 'numSwitch' ]
-
- # Timestamp 'keys' for json metrics output.
- # These are subject to change, hence moved into params
- deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
- graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
-
- debugMode = main.params[ 'TEST' ][ 'debugMode' ]
-
- localTime = time.strftime( '%X' )
- localTime = localTime.replace( "/", "" )
- localTime = localTime.replace( " ", "_" )
- localTime = localTime.replace( ":", "" )
- if debugMode == 'on':
- main.ONOS1.tsharkPcap( "eth0",
- "/tmp/100_sw_lat_pcap_" + localTime )
-
- # Threshold for this test case
- swDiscThresholdStr = main.params[ 'TEST' ][ 'swDisc100Threshold' ]
- swDiscThresholdObj = swDiscThresholdStr.split( "," )
- swDiscThresholdMin = int( swDiscThresholdObj[ 0 ] )
- swDiscThresholdMax = int( swDiscThresholdObj[ 1 ] )
-
- tsharkOfpOutput = "/tmp/tshark_ofp_" + numSw + "sw.txt"
- tsharkTcpOutput = "/tmp/tshark_tcp_" + numSw + "sw.txt"
-
- tsharkOfpResultList = []
- tsharkTcpResultList = []
-
- swDiscoveryLatList = []
-
- main.case( numSw + " Switch discovery latency" )
- main.step( "Assigning all switches to ONOS1" )
- for i in range( 1, int( numSw ) + 1 ):
- main.Mininet1.assignSwController(
- sw=str( i ),
- ip1=ONOS1Ip,
- port1=defaultSwPort )
-
- # Ensure that nodes are configured with ptpd
- # Just a warning message
- main.log.info( "Please check ptpd configuration to ensure" +
- " All nodes' system times are in sync" )
- time.sleep( 5 )
-
- for i in range( 0, int( numIter ) ):
-
- main.step( "Set iptables rule to block incoming sw connections" )
- # Set iptables rule to block incoming switch connections
- # The rule description is as follows:
- # Append to INPUT rule,
- # behavior DROP that matches following:
- # * packet type: tcp
- # * source IP: MN1Ip
- # * destination PORT: 6633
- main.ONOS1.handle.sendline(
- "sudo iptables -A INPUT -p tcp -s " + MN1Ip +
- " --dport " + defaultSwPort + " -j DROP" )
- main.ONOS1.handle.expect( "\$" )
- # Append to OUTPUT rule,
- # behavior DROP that matches following:
- # * packet type: tcp
- # * source IP: MN1Ip
- # * destination PORT: 6633
- main.ONOS1.handle.sendline(
- "sudo iptables -A OUTPUT -p tcp -s " + MN1Ip +
- " --dport " + defaultSwPort + " -j DROP" )
- main.ONOS1.handle.expect( "\$" )
- # Give time to allow rule to take effect
- # NOTE: Sleep period may need to be configured
- # based on the number of switches in the topology
- main.log.info( "Please wait for switch connection to " +
- "time out" )
- time.sleep( 60 )
-
- # Gather vendor OFP with tshark
- main.ONOS1.tsharkGrep( "OFP 86 Vendor",
- tsharkOfpOutput )
- main.ONOS1.tsharkGrep( "TCP 74 ",
- tsharkTcpOutput )
-
- # NOTE: 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
-
- t0System = time.time() * 1000
- main.ONOS1.handle.sendline(
- "sudo iptables -F" )
-
- # Counter to track loop count
- counterLoop = 0
- counterAvail1 = 0
- counterAvail2 = 0
- counterAvail3 = 0
- onos1Dev = False
- onos2Dev = False
- onos3Dev = False
- while counterLoop < 60:
- # Continue to check devices for all device
- # availability. When all devices in all 3
- # ONOS instances indicate that devices are available
- # obtain graph event timestamp for t1.
- deviceStrObj1 = main.ONOS1cli.devices()
- deviceStrObj2 = main.ONOS2cli.devices()
- deviceStrObj3 = main.ONOS3cli.devices()
-
- deviceJson1 = json.loads( deviceStrObj1 )
- deviceJson2 = json.loads( deviceStrObj2 )
- deviceJson3 = json.loads( deviceStrObj3 )
-
- for device1 in deviceJson1:
- if device1[ 'available' ]:
- counterAvail1 += 1
- if counterAvail1 == int( numSw ):
- onos1Dev = True
- main.log.info( "All devices have been " +
- "discovered on ONOS1" )
- else:
- counterAvail1 = 0
- for device2 in deviceJson2:
- if device2[ 'available' ]:
- counterAvail2 += 1
- if counterAvail2 == int( numSw ):
- onos2Dev = True
- main.log.info( "All devices have been " +
- "discovered on ONOS2" )
- else:
- counterAvail2 = 0
- for device3 in deviceJson3:
- if device3[ 'available' ]:
- counterAvail3 += 1
- if counterAvail3 == int( numSw ):
- onos3Dev = True
- main.log.info( "All devices have been " +
- "discovered on ONOS3" )
- else:
- counterAvail3 = 0
-
- if onos1Dev and onos2Dev and onos3Dev:
- main.log.info( "All devices have been discovered " +
- "on all ONOS instances" )
- jsonStrTopologyMetrics1 =\
- main.ONOS1cli.topologyEventsMetrics()
- jsonStrTopologyMetrics2 =\
- main.ONOS2cli.topologyEventsMetrics()
- jsonStrTopologyMetrics3 =\
- main.ONOS3cli.topologyEventsMetrics()
-
- # Exit while loop if all devices discovered
- break
-
- counterLoop += 1
- # Give some time in between CLI calls
- #( will not affect measurement )
- time.sleep( 3 )
-
- main.ONOS1.tsharkStop()
-
- os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
- tsharkOfpOutput + " /tmp/" )
- os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
- tsharkTcpOutput + " /tmp/" )
-
- # TODO: Automate OFP output analysis
- # Debug mode - print out packets captured at runtime
- if debugMode == 'on':
- ofpFile = open( tsharkOfpOutput, 'r' )
- main.log.info( "Tshark OFP Vendor output: " )
- for line in ofpFile:
- tsharkOfpResultList.append( line )
- main.log.info( line )
- ofpFile.close()
-
- tcpFile = open( tsharkTcpOutput, 'r' )
- main.log.info( "Tshark TCP 74 output: " )
- for line in tcpFile:
- tsharkTcpResultList.append( line )
- main.log.info( line )
- tcpFile.close()
-
- jsonObj1 = json.loads( jsonStrTopologyMetrics1 )
- jsonObj2 = json.loads( jsonStrTopologyMetrics2 )
- jsonObj3 = json.loads( jsonStrTopologyMetrics3 )
-
- graphTimestamp1 = \
- jsonObj1[ graphTimestamp ][ 'value' ]
- graphTimestamp2 = \
- jsonObj2[ graphTimestamp ][ 'value' ]
- graphTimestamp3 = \
- jsonObj3[ graphTimestamp ][ 'value' ]
-
- graphLat1 = int( graphTimestamp1 ) - int( t0System )
- graphLat2 = int( graphTimestamp2 ) - int( t0System )
- graphLat3 = int( graphTimestamp3 ) - int( t0System )
-
- avgGraphLat = \
- ( int( graphLat1 ) +
- int( graphLat2 ) +
- int( graphLat3 ) ) / 3
-
- if avgGraphLat > swDiscThresholdMin \
- and avgGraphLat < swDiscThresholdMax:
- swDiscoveryLatList.append(
- avgGraphLat )
- else:
- main.log.info( "100 Switch discovery latency " +
- "exceeded the threshold." )
-
- # END ITERATION FOR LOOP
-
- swLatMin = min( swDiscoveryLatList )
- swLatMax = max( swDiscoveryLatList )
- swLatAvg = sum( swDiscoveryLatList ) /\
- len( swDiscoveryLatList )
-
- main.log.report( "100 Switch discovery lat " +
- "Min: " + str( swLatMin ) + " ms" +
- "Max: " + str( swLatMax ) + " ms" +
- "Avg: " + str( swLatAvg ) + " ms" )
-
- def CASE6( self, main ):
- """
- Increase number of nodes and initiate CLI
- """
- import time
-
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
- ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
- ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
- ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
-
- cellName = main.params[ 'ENV' ][ 'cellName' ]
-
- global clusterCount
-
- # Cluster size increased everytime the case is defined
- clusterCount += 2
-
- main.log.report( "Increasing cluster size to " +
- str( clusterCount ) )
-
- installResult = main.FALSE
- if clusterCount == 3:
- main.log.info( "Installing nodes 2 and 3" )
- node2Result = \
- main.ONOSbench.onosInstall( node=ONOS2Ip )
- node3Result = \
- main.ONOSbench.onosInstall( node=ONOS3Ip )
- installResult = node2Result and node3Result
-
- time.sleep( 5 )
-
- main.ONOS2cli.startOnosCli( ONOS2Ip )
- main.ONOS3cli.startOnosCli( ONOS3Ip )
-
- elif clusterCount == 5:
- main.log.info( "Installing nodes 4 and 5" )
- node4Result = \
- main.ONOSbench.onosInstall( node=ONOS4Ip )
- node5Result = \
- main.ONOSbench.onosInstall( node=ONOS5Ip )
- installResult = node4Result and node5Result
-
- time.sleep( 5 )
-
- main.ONOS4cli.startOnosCli( ONOS4Ip )
- main.ONOS5cli.startOnosCli( ONOS5Ip )
-
- elif clusterCount == 7:
- main.log.info( "Installing nodes 4 and 5" )
- node6Result = \
- main.ONOSbench.onosInstall( node=ONOS6Ip )
- node7Result = \
- main.ONOSbench.onosInstall( node=ONOS7Ip )
- installResult = node6Result and node7Result
-
- time.sleep( 5 )
-
- main.ONOS6cli.startOnosCli( ONOS6Ip )
- main.ONOS7cli.startOnosCli( ONOS7Ip )
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.params b/TestON/tests/TopoPerfNextBM/TopoPerfNextBM.params
similarity index 60%
copy from TestON/tests/TopoPerfNext/TopoPerfNext.params
copy to TestON/tests/TopoPerfNextBM/TopoPerfNextBM.params
index 45de48d..eba319c 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.params
+++ b/TestON/tests/TopoPerfNextBM/TopoPerfNextBM.params
@@ -1,8 +1,9 @@
<PARAMS>
- <testcases>1,2,3,6,2,3,6,2,3,6,2,3</testcases>
+ <testcases>1,2,3,4,2,3,4,2,3,4,2,3</testcases>
<ENV>
<cellName>topo_perf_test</cellName>
+ <cellFeatures>"drivers,metrics,openflow"</cellFeatures>
</ENV>
<GIT>
@@ -13,28 +14,37 @@
<CTRL>
<user>admin</user>
- <ip1>10.128.174.1</ip1>
+ <ip1>10.254.1.201</ip1>
<port1>6633</port1>
- <ip2>10.128.174.2</ip2>
+ <ip2>10.254.1.202</ip2>
<port2>6633</port2>
- <ip3>10.128.174.3</ip3>
+ <ip3>10.254.1.203</ip3>
<port3>6633</port3>
- <ip4>10.128.174.4</ip4>
+ <ip4>10.254.1.204</ip4>
- <ip5>10.128.174.5</ip5>
- <ip6>10.128.174.6</ip6>
- <ip7>10.128.174.7</ip7>
+ <ip5>10.254.1.205</ip5>
+ <ip6>10.254.1.206</ip6>
+ <ip7>10.254.1.207</ip7>
</CTRL>
<MN>
- <ip1>10.128.10.90</ip1>
- <ip2>10.128.10.91</ip2>
+ <ip1>10.254.1.200</ip1>
+ <ip2>10.254.1.200</ip2>
</MN>
<BENCH>
- <ip>10.128.174.10</ip>
+ <ip>10.254.1.200</ip>
</BENCH>
+ <TSHARK>
+ <ofpPortStatus>OF 1.3 146</ofpPortStatus>
+ <ofpRoleReply>OF 1.3 90 of_role_reply</ofpRoleReply>
+ <featureReply>OF 1.3 98 of_features_reply</featureReply>
+ <roleRequest>OF 1.3 90 of_role_request</roleRequest>
+ <tcpSynAck>TCP 74 6633</tcpSynAck>
+ <finAckSequence>FIN</finAckSequence>
+ </TSHARK>
+
<TEST>
#'on' or 'off' debug mode.
#If on, logging will be more verbose and
@@ -52,7 +62,7 @@
</topoConfigName>
#Number of times to iterate each case
- <numIter>5</numIter>
+ <numIter>13</numIter>
<numSwitch>2</numSwitch>
#Number of iterations to ignore initially
<iterIgnore>2</iterIgnore>
@@ -67,6 +77,16 @@
<tabletFile>tablets_3node.json</tabletFile>
</TEST>
+ <DB>
+ <postToDB>on</postToDB>
+ <portEventResultPath>
+ /home/admin/ONLabTest/TestON/tests/TopoPerfNextBM/portEventResultDb.log
+ </portEventResultPath>
+ <switchEventResultPath>
+ /home/admin/ONLabTest/TestON/tests/TopoPerfNextBM/switchEventResultDb.log
+ </switchEventResultPath>
+ </DB>
+
<JSON>
<deviceTimestamp>topologyDeviceEventTimestamp</deviceTimestamp>
<hostTimestamp>topologyHostEventTimestamp</hostTimestamp>
diff --git a/TestON/tests/TopoPerfNextBM/TopoPerfNextBM.py b/TestON/tests/TopoPerfNextBM/TopoPerfNextBM.py
new file mode 100644
index 0000000..e2245ba
--- /dev/null
+++ b/TestON/tests/TopoPerfNextBM/TopoPerfNextBM.py
@@ -0,0 +1,1306 @@
+# 2015.03.12 10:22:05 PDT
+#Embedded file name: ../tests/TopoPerfNextBM/TopoPerfNextBM.py
+import time
+import sys
+import os
+import re
+
+class TopoPerfNextBM:
+
+ def __init__(self):
+ self.default = ''
+
+ def CASE1(self, main):
+ """
+ ONOS startup sequence
+ """
+ global clusterCount
+ global timeToPost
+ global runNum
+ global jenkinsBuildNumber
+
+ import time
+ import os
+
+ clusterCount = 1
+ timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
+ runNum = time.strftime('%d%H%M%S')
+ cellName = main.params['ENV']['cellName']
+ gitPull = main.params['GIT']['autoPull']
+ checkoutBranch = main.params['GIT']['checkout']
+
+ # Get jenkins build number from environment.
+ # This environment variable will only exist when
+ # triggered by a jenkins job
+ try:
+ jenkinsBuildNumber = str(os.environ['BUILD_NUMBER'])
+ main.log.report( 'Jenkins build number: ' +
+ jenkinsBuildNumber )
+ except KeyError:
+ # Jenkins build number is also used in posting to DB
+ # If this test is not triggered by jenkins, give
+ # it 0 instead, ensuring that
+ # the DB post will recognize it as a non-jenkins run
+ jenkinsBuildNumber = str(0)
+ main.log.info( 'Job is not run by jenkins. '+
+ 'Build number set to: ' + jenkinsBuildNumber)
+
+ global CLIs
+ CLIs = []
+ global nodes
+ nodes = []
+ global nodeIpList
+ nodeIpList = []
+ for i in range( 1, 8 ):
+ CLIs.append( getattr( main, 'ONOS' + str( i ) + 'cli' ) )
+ nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+ nodeIpList.append( main.params[ 'CTRL' ][ 'ip'+str(i) ] )
+
+ MN1Ip = main.params['MN']['ip1']
+ BENCHIp = main.params['BENCH']['ip']
+ cellFeatures = main.params['ENV']['cellFeatures']
+ topoCfgFile = main.params['TEST']['topoConfigFile']
+ topoCfgName = main.params['TEST']['topoConfigName']
+ portEventResultPath = main.params['DB']['portEventResultPath']
+ switchEventResultPath = main.params['DB']['switchEventResultPath']
+ mvnCleanInstall = main.params['TEST']['mci']
+
+ main.case('Setting up test environment')
+
+ # NOTE: Below is deprecated after new way to install features
+ #main.log.info('Copying topology event accumulator config' +
+ # ' to ONOS /package/etc')
+ #main.ONOSbench.handle.sendline('cp ~/' +
+ # topoCfgFile + ' ~/ONOS/tools/package/etc/' +
+ # topoCfgName)
+ #main.ONOSbench.handle.expect('\\$')
+
+ main.log.report('Setting up test environment')
+
+ main.step('Starting mininet topology ')
+ main.Mininet1.startNet()
+
+ main.step('Cleaning previously installed ONOS if any')
+ # Nodes 2 ~ 7
+ for i in range( 1, 7 ):
+ main.ONOSbench.onosUninstall(nodeIp=nodeIpList[i])
+
+ main.step('Clearing previous DB log file')
+
+ fPortLog = open(portEventResultPath, 'w')
+ fPortLog.write('')
+ fPortLog.close()
+ fSwitchLog = open(switchEventResultPath, 'w')
+ fSwitchLog.write('')
+ fSwitchLog.close()
+
+ main.step('Creating cell file')
+ cellFileResult = main.ONOSbench.createCellFile(
+ BENCHIp, cellName, MN1Ip, cellFeatures, nodeIpList[0])
+
+ main.step('Applying cell file to environment')
+ cellApplyResult = main.ONOSbench.setCell(cellName)
+ verifyCellResult = main.ONOSbench.verifyCell()
+
+ main.step('Git checkout and pull ' + checkoutBranch)
+ if gitPull == 'on':
+ checkoutResult = main.TRUE
+ pullResult = main.ONOSbench.gitPull()
+ else:
+ checkoutResult = main.TRUE
+ pullResult = main.TRUE
+ main.log.info('Skipped git checkout and pull')
+
+ main.log.report('Commit information - ')
+ main.ONOSbench.getVersion(report=True)
+ main.step('Using mvn clean & install')
+ if mvnCleanInstall == 'on':
+ mvnResult = main.ONOSbench.cleanInstall()
+ elif mvnCleanInstall == 'off':
+ main.log.info('mci turned off by settings')
+ mvnResult = main.TRUE
+ main.step('Set cell for ONOS cli env')
+ CLIs[0].setCell(cellName)
+
+ main.step('Creating ONOS package')
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step('Installing ONOS package')
+ install1Result = main.ONOSbench.onosInstall(node=nodeIpList[0])
+
+ time.sleep(10)
+
+ main.step('Start onos cli')
+ cli1 = CLIs[0].startOnosCli(nodeIpList[0])
+
+ main.step( 'activating essential applications' )
+ CLIs[0].activateApp( 'org.onosproject.metrics' )
+ CLIs[0].activateApp( 'org.onosproject.openflow' )
+
+ main.step( 'Configuring application parameters' )
+
+ configName = 'org.onosproject.net.topology.impl.DefaultTopologyProvider'
+ configParam = 'maxEvents 1'
+ main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
+ configParam = 'maxBatchMs 0'
+ main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
+ configParam = 'maxIdleMs 0'
+ main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
+
+ utilities.assert_equals(expect=main.TRUE,
+ actual=cellFileResult and cellApplyResult and\
+ verifyCellResult and checkoutResult and\
+ pullResult and mvnResult and\
+ install1Result,
+ onpass='Test Environment setup successful',
+ onfail='Failed to setup test environment')
+
+ def CASE2(self, main):
+ """
+ Assign s3 to ONOS1 and measure latency
+
+ There are 4 levels of latency measurements to this test:
+ 1 ) End-to-end measurement: Complete end-to-end measurement
+ from TCP ( SYN/ACK ) handshake to Graph change
+ 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
+ measurement from OFP Vendor message to Graph change
+ 3 ) OFP-to-device measurement: 'ONOS processing without
+ graph change' snippet of measurement from OFP vendor
+ message to Device change timestamp
+ 4 ) T0-to-device measurement: Measurement that includes
+ the switch handshake to devices timestamp without
+ the graph view change. ( TCP handshake -> Device
+ change )
+ """
+ import time
+ import subprocess
+ import json
+ import requests
+ import os
+ import numpy
+
+ ONOSUser = main.params['CTRL']['user']
+ defaultSwPort = main.params['CTRL']['port1']
+ numIter = main.params['TEST']['numIter']
+ iterIgnore = int(main.params['TEST']['iterIgnore'])
+
+ deviceTimestampKey = main.params['JSON']['deviceTimestamp']
+ graphTimestampKey = main.params['JSON']['graphTimestamp']
+
+ debugMode = main.params['TEST']['debugMode']
+ onosLog = main.params['TEST']['onosLogFile']
+ resultPath = main.params['DB']['switchEventResultPath']
+ thresholdStr = main.params['TEST']['singleSwThreshold']
+ thresholdObj = thresholdStr.split(',')
+ thresholdMin = int(thresholdObj[0])
+ thresholdMax = int(thresholdObj[1])
+
+ # Look for 'role-request' messages,
+ # which replaces the 'vendor' messages previously seen
+ # on OVS 2.0.1
+ tsharkTcpString = main.params[ 'TSHARK' ][ 'tcpSynAck' ]
+ tsharkFeatureReply = main.params[ 'TSHARK' ][ 'featureReply' ]
+ tsharkRoleRequest = main.params[ 'TSHARK' ][ 'roleRequest' ]
+ tsharkOfString = main.params[ 'TSHARK' ][ 'ofpRoleReply' ]
+ tsharkFinAckSequence = main.params[ 'TSHARK' ][ 'finAckSequence' ]
+
+ tsharkOfOutput = '/tmp/tshark_of_topo.txt'
+ tsharkTcpOutput = '/tmp/tshark_tcp_topo.txt'
+ tsharkRoleOutput = '/tmp/tshark_role_request.txt'
+ tsharkFeatureOutput = '/tmp/tshark_feature_reply.txt'
+ tsharkFinAckOutput = '/tmp/tshark_fin_ack.txt'
+
+ # Switch connect measurement list
+ # TCP Syn/Ack -> Feature Reply latency collection for each node
+ tcpToFeatureLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
+ # Feature Reply -> Role Request latency collection for each node
+ featureToRoleRequestLatNodeIter = numpy.zeros((clusterCount,
+ int(numIter)))
+ # Role Request -> Role Reply latency collection for each node
+ roleRequestToRoleReplyLatNodeIter = numpy.zeros((clusterCount,
+ int(numIter)))
+ # Role Reply -> Device Update latency collection for each node
+ roleReplyToDeviceLatNodeIter = numpy.zeros((clusterCount,
+ int(numIter)))
+ # Device Update -> Graph Update latency collection for each node
+ deviceToGraphLatNodeIter = numpy.zeros((clusterCount,
+ int(numIter)))
+ endToEndLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
+
+ # Switch disconnect measurement lists
+ # Mininet Fin / Ack -> Mininet Ack
+ finAckTransactionLatNodeIter = numpy.zeros((clusterCount,
+ int(numIter)))
+ # Mininet Ack -> Device Event
+ ackToDeviceLatNodeIter = numpy.zeros((clusterCount,
+ int(numIter)))
+ # Device event -> Graph event
+ deviceToGraphDiscLatNodeIter = numpy.zeros((clusterCount,
+ int(numIter)))
+ endToEndDiscLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
+
+ assertion = main.TRUE
+ localTime = time.strftime('%x %X')
+ localTime = localTime.replace('/', '')
+ localTime = localTime.replace(' ', '_')
+ localTime = localTime.replace(':', '')
+
+ if debugMode == 'on':
+ main.ONOS1.tsharkPcap('eth0',
+ '/tmp/single_sw_lat_pcap_' + localTime)
+ main.log.info('Debug mode is on')
+ main.log.report('Latency of adding one switch to controller')
+ main.log.report('First ' + str(iterIgnore) +
+ ' iterations ignored' + ' for jvm warmup time')
+ main.log.report('Total iterations of test: ' + str(numIter))
+
+ for i in range(0, int(numIter)):
+ main.log.info('Starting tshark capture')
+ main.ONOS1.tsharkGrep(tsharkTcpString, tsharkTcpOutput)
+ main.ONOS1.tsharkGrep(tsharkOfString, tsharkOfOutput)
+ main.ONOS1.tsharkGrep(tsharkRoleRequest, tsharkRoleOutput)
+ main.ONOS1.tsharkGrep(tsharkFeatureReply, tsharkFeatureOutput)
+
+ time.sleep(10)
+
+ main.log.info('Assigning s3 to controller')
+ main.Mininet1.assignSwController(sw='3',
+ ip1=nodeIpList[0], port1=defaultSwPort)
+
+ jsonStr = []
+ for node in range (0, clusterCount):
+ metricsSwUp = CLIs[node].topologyEventsMetrics()
+ jsonStr.append(metricsSwUp)
+
+ main.log.info('Stopping all Tshark processes')
+ main.ONOS1.tsharkStop()
+
+ time.sleep(5)
+
+ main.log.info('Copying over tshark files')
+ os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
+ ':' + tsharkTcpOutput + ' /tmp/')
+ os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
+ ':' + tsharkRoleOutput + ' /tmp/')
+ os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
+ ':' + tsharkFeatureOutput + ' /tmp/')
+ os.system('scp ' + ONOSUser + '@' +
+ nodeIpList[0] + ':' + tsharkOfOutput + ' /tmp/')
+
+ # Get tcp syn / ack output
+ time.sleep(1)
+
+ tcpFile = open(tsharkTcpOutput, 'r')
+ tempText = tcpFile.readline()
+ tempText = tempText.split(' ')
+ main.log.info('Object read in from TCP capture: ' +
+ str(tempText))
+
+ if len(tempText) > 1:
+ t0Tcp = float(tempText[1]) * 1000.0
+ else:
+ main.log.error('Tshark output file for TCP' +
+ ' returned unexpected results')
+ t0Tcp = 0
+ assertion = main.FALSE
+ tcpFile.close()
+
+ # Get Role reply output
+ ofFile = open(tsharkOfOutput, 'r')
+ lineOfp = ''
+ while True:
+ tempText = ofFile.readline()
+ if tempText != '':
+ lineOfp = tempText
+ else:
+ break
+ obj = lineOfp.split(' ')
+ main.log.info('Object read in from OFP capture: ' +
+ str(lineOfp))
+ if len(obj) > 1:
+ t0Ofp = float(obj[1]) * 1000.0
+ else:
+ main.log.error('Tshark output file for OFP' +
+ ' returned unexpected results')
+ t0Ofp = 0
+ assertion = main.FALSE
+ ofFile.close()
+
+ # Get role request output
+ roleFile = open(tsharkRoleOutput, 'r')
+ tempText = roleFile.readline()
+ tempText = tempText.split(' ')
+ if len(tempText) > 1:
+ main.log.info('Object read in from role request capture:' +
+ str(tempText))
+ roleTimestamp = float(tempText[1]) * 1000.0
+ else:
+ main.log.error('Tshark output file for role request' +
+ ' returned unexpected results')
+ timeRoleRequest = 0
+ assertion = main.FALSE
+ roleFile.close()
+
+ # Get feature reply output
+ featureFile = open(tsharkFeatureOutput, 'r')
+ tempText = featureFile.readline()
+ tempText = tempText.split(' ')
+ if len(tempText) > 1:
+ main.log.info('Object read in from feature reply capture: '+
+ str(tempText))
+ if tempText[1] != ' ' and float(tempText[1]) > 1400000000.0:
+ temp = tempText[1]
+ elif tempText[2] != ' ' and float(tempText[2]) > 1400000000.0:
+ temp = tempText[2]
+ else:
+ temp = 0
+ featureTimestamp = float(temp) * 1000.0
+ else:
+ main.log.error('Tshark output file for feature reply' +
+ ' returned unexpected results')
+ timeFeatureReply = 0
+ assertion = main.FALSE
+ featureFile.close()
+
+ for node in range(0, clusterCount):
+ nodeNum = node+1
+ #metricsSwUp = CLIs[node].topologyEventsMetrics
+ #jsonStr = metricsSwUp()
+ jsonObj = json.loads(jsonStr[node])
+ if jsonObj:
+ graphTimestamp = jsonObj[graphTimestampKey]['value']
+ deviceTimestamp = jsonObj[deviceTimestampKey]['value']
+ else:
+ main.log.error( "Unexpected JSON object" )
+ # If we could not obtain the JSON object,
+ # set the timestamps to 0, which will be
+ # excluded from the measurement later on
+ # (realized as invalid)
+ graphTimestamp = 0
+ deviceTimestamp = 0
+
+ endToEnd = int(graphTimestamp) - int(t0Tcp)
+
+ # Below are measurement breakdowns of the end-to-end
+ # measurement.
+ tcpToFeature = int(featureTimestamp) - int(t0Tcp)
+ featureToRole = int(roleTimestamp) - int(featureTimestamp)
+ roleToOfp = float(t0Ofp) - float(roleTimestamp)
+ ofpToDevice = float(deviceTimestamp) - float(t0Ofp)
+ # Timestamps gathered from ONOS are millisecond
+ # precision. They are returned as integers, thus no
+ # need to be more precise than 'int'. However,
+ # the processing seems to be mostly under 1 ms,
+ # thus this may be a problem point to handle any
+ # submillisecond output that we are unsure of.
+ # For now, this will be treated as 0 ms if less than 1 ms
+ deviceToGraph = int(graphTimestamp) - int(deviceTimestamp)
+
+ if endToEnd >= thresholdMin and\
+ endToEnd < thresholdMax and i >= iterIgnore:
+ endToEndLatNodeIter[node][i] = endToEnd
+ main.log.info("ONOS "+str(nodeNum)+ " end-to-end: "+
+ str(endToEnd) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+ " end-to-end "+
+ "measurement ignored due to excess in "+
+ "threshold or premature iteration: ")
+ main.log.info(str(endToEnd))
+
+ if tcpToFeature >= thresholdMin and\
+ tcpToFeature < thresholdMax and i >= iterIgnore:
+ tcpToFeatureLatNodeIter[node][i] = tcpToFeature
+ main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature: "+
+ str(tcpToFeature) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature "+
+ "measurement ignored due to excess in "+
+ "threshold or premature iteration: ")
+ main.log.info(str(tcpToFeature))
+
+ if featureToRole >= thresholdMin and\
+ featureToRole < thresholdMax and i >= iterIgnore:
+ featureToRoleRequestLatNodeIter[node][i] = featureToRole
+ main.log.info("ONOS "+str(nodeNum)+ " feature-to-role: "+
+ str(featureToRole) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+ " feature-to-role "+
+ "measurement ignored due to excess in "+
+ "threshold or premature iteration: ")
+ main.log.info(str(featureToRole))
+
+ if roleToOfp >= thresholdMin and\
+ roleToOfp < thresholdMax and i >= iterIgnore:
+ roleRequestToRoleReplyLatNodeIter[node][i] = roleToOfp
+ main.log.info("ONOS "+str(nodeNum)+ " role-to-reply: "+
+ str(roleToOfp) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
+ "measurement ignored due to excess in "+
+ "threshold or premature iteration: ")
+ main.log.info(str(roleToOfp))
+
+ if ofpToDevice >= thresholdMin and\
+ ofpToDevice < thresholdMax and i >= iterIgnore:
+ roleReplyToDeviceLatNodeIter[node][i] = ofpToDevice
+ main.log.info("ONOS "+str(nodeNum)+ " reply-to-device: "+
+ str(ofpToDevice) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+ " reply-to-device "+
+ "measurement ignored due to excess in "+
+ "threshold or premature iteration: ")
+ main.log.info(str(ofpToDevice))
+
+ if deviceToGraph >= thresholdMin and\
+ deviceToGraph < thresholdMax and i >= iterIgnore:
+ deviceToGraphLatNodeIter[node][i] = deviceToGraph
+ main.log.info("ONOS "+str(nodeNum)+ " device-to-graph: "+
+ str(deviceToGraph) + " ms")
+ else:
+ if deviceToGraph == 0:
+ deviceToGraphLatNodeIter[node][i] = 0
+ main.log.info("ONOS "+str(nodeNum) +
+ " device-to-graph measurement "+
+ "was set to 0 ms because of precision "+
+ "uncertainty. ")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " device-to-graph "+
+ "measurement ignored due to excess in "+
+ "threshold or premature iteration: ")
+ main.log.info(str(deviceToGraph))
+
+ # ********************
+ time.sleep(5)
+
+ # Get device id to remove
+ deviceIdJsonStr = main.ONOS1cli.devices()
+
+ main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) )
+ deviceId = json.loads(deviceIdJsonStr)
+
+ deviceList = []
+ for device in deviceId:
+ deviceList.append(device['id'])
+
+ # Measure switch down metrics
+ # TCP FIN/ACK -> TCP FIN
+ # TCP FIN -> Device Event
+ # Device Event -> Graph Event
+ # Capture switch down FIN / ACK packets
+
+ # The -A 1 grep option allows us to grab 1 extra line after the
+ # last tshark output grepped originally
+ main.ONOS1.tsharkGrep( tsharkFinAckSequence, tsharkFinAckOutput,
+ grepOptions = '-A 1' )
+
+ time.sleep( 5 )
+
+ removeJsonList = []
+
+ main.step('Remove switch from controller')
+ main.Mininet1.deleteSwController('s3')
+ firstDevice = deviceList[0]
+
+ # We need to get metrics before removing
+ # device from the store below.
+ for node in range(0, clusterCount):
+ metricsSwDown = CLIs[node].topologyEventsMetrics
+ jsonStr = metricsSwDown()
+ removeJsonList.append( json.loads(jsonStr) )
+
+ main.ONOS1.tsharkStop()
+
+ main.log.info( "Removing device " +str(firstDevice)+
+ " from ONOS" )
+
+ #if deviceId:
+ main.ONOS1cli.deviceRemove(firstDevice)
+
+ main.log.info('Copying over tshark files')
+ os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
+ ':' + tsharkFinAckOutput + ' /tmp/')
+
+ time.sleep( 10 )
+ finAckOutputList = []
+ with open(tsharkFinAckOutput, 'r') as f:
+ tempLine = f.readlines()
+ main.log.info('Object read in from FinAck capture: ' +
+ "\n".join(tempLine))
+
+ index = 1
+ for line in tempLine:
+ obj = line.split(' ')
+
+ # There are at least 3 objects in field (valid
+ # tshark output is lengthy)
+ if len(obj) > 2:
+ # If first index of object is like an epoch time
+ if obj[1] != ' ' and float(obj[1]) > 1400000000.0:
+ temp = obj[1]
+ elif obj[2] != ' 'and float(obj[2]) > 1400000000.0:
+ temp = obj[2]
+ elif obj[3] != ' 'and float(obj[3]) > 1400000000.0:
+ temp = obj[3]
+ else:
+ temp = 0
+ if index == 1:
+ tFinAck = float(temp) * 1000.0
+ elif index == 2:
+ continue
+ elif index == 3:
+ tAck = float(temp) * 1000.0
+ else:
+ tFinAck = 0
+ tAck = 0
+ else:
+ main.log.error('Tshark output file for OFP' +
+ ' returned unexpected results')
+ tFinAck = 0
+ tAck = 0
+ assertion = main.FALSE
+
+ index = index+1
+
+ # with open() as f takes care of closing file
+
+ time.sleep(5)
+
+ for node in range(0, clusterCount):
+ nodeNum = node+1
+ jsonObj = removeJsonList[node]
+ if jsonObj:
+ graphTimestamp = jsonObj[graphTimestampKey]['value']
+ deviceTimestamp = jsonObj[deviceTimestampKey]['value']
+ main.log.info("Graph timestamp: "+str(graphTimestamp))
+ main.log.info("Device timestamp: "+str(deviceTimestamp))
+ else:
+ main.log.error( "Unexpected JSON object" )
+ # If we could not obtain the JSON object,
+ # set the timestamps to 0, which will be
+ # excluded from the measurement later on
+ # (realized as invalid)
+ graphTimestamp = 0
+ deviceTimestamp = 0
+
+ finAckTransaction = float(tAck) - float(tFinAck)
+ ackToDevice = float(deviceTimestamp) - float(tAck)
+ deviceToGraph = float(graphTimestamp) - float(deviceTimestamp)
+ endToEndDisc = int(graphTimestamp) - int(tFinAck)
+
+ if endToEndDisc >= thresholdMin and\
+ endToEndDisc < thresholdMax and i >= iterIgnore:
+ endToEndDiscLatNodeIter[node][i] = endToEndDisc
+ main.log.info("ONOS "+str(nodeNum) +
+ "end-to-end disconnection: "+
+ str(endToEndDisc) + " ms" )
+ else:
+ main.log.info("ONOS " + str(nodeNum) +
+ " end-to-end disconnection "+
+ "measurement ignored due to excess in "+
+ "threshold or premature iteration: ")
+ main.log.info(str(endToEndDisc))
+
+ if finAckTransaction >= thresholdMin and\
+ finAckTransaction < thresholdMax and i >= iterIgnore:
+ finAckTransactionLatNodeIter[node][i] = finAckTransaction
+ main.log.info("ONOS "+str(nodeNum)+
+ " fin/ack transaction: "+
+ str(finAckTransaction) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " fin/ack transaction "+
+ "measurement ignored due to excess in "+
+ "threshold or premature iteration: ")
+ main.log.info(str(finAckTransaction))
+
+ if ackToDevice >= thresholdMin and\
+ ackToDevice < thresholdMax and i >= iterIgnore:
+ ackToDeviceLatNodeIter[node][i] = ackToDevice
+ main.log.info("ONOS "+str(nodeNum)+
+ " ack-to-device: "+
+ str(ackToDevice) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " ack-to-device "+
+ "measurement ignored due to excess in "+
+ "threshold or premature iteration: ")
+ main.log.info(str(ackToDevice))
+
+ if deviceToGraph >= thresholdMin and\
+ deviceToGraph < thresholdMax and i >= iterIgnore:
+ deviceToGraphDiscLatNodeIter[node][i] = deviceToGraph
+ main.log.info("ONOS "+str(nodeNum)+
+ " device-to-graph disconnect: "+
+ str(deviceToGraph) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " device-to-graph disconnect "+
+ "measurement ignored due to excess in "+
+ "threshold or premature iteration: ")
+ main.log.info(str(deviceToGraph))
+
+ endToEndAvg = 0
+ ofpToGraphAvg = 0
+ dbCmdList = []
+ for node in range(0, clusterCount):
+ # List of latency for each node
+ endToEndList = []
+ tcpToFeatureList = []
+ featureToRoleList = []
+ roleToOfpList = []
+ ofpToDeviceList = []
+ deviceToGraphList = []
+
+ finAckTransactionList = []
+ ackToDeviceList = []
+ deviceToGraphDiscList = []
+ endToEndDiscList = []
+
+ # LatNodeIter 2d arrays contain all iteration latency
+ # for each node of the current scale cluster size
+ # Switch connection measurements
+ # Set further acceptance criteria for measurements
+ # here if you would like to filter reporting results
+ for item in endToEndLatNodeIter[node]:
+ if item > 0.0:
+ endToEndList.append(item)
+
+ for item in tcpToFeatureLatNodeIter[node]:
+ if item > 0.0:
+ tcpToFeatureList.append(item)
+
+ for item in featureToRoleRequestLatNodeIter[node]:
+ if item > 0.0:
+ featureToRoleList.append(item)
+
+ for item in roleRequestToRoleReplyLatNodeIter[node]:
+ if item > 0.0:
+ roleToOfpList.append(item)
+
+ for item in roleReplyToDeviceLatNodeIter[node]:
+ if item >= 0.0:
+ ofpToDeviceList.append(item)
+
+ for item in featureToRoleRequestLatNodeIter[node]:
+ if item > 0.0:
+ featureToRoleList.append(item)
+
+ for item in deviceToGraphLatNodeIter[node]:
+ if item >= 0.0:
+ deviceToGraphList.append(item)
+
+ # Switch disconnect measurements
+ for item in endToEndDiscLatNodeIter[node]:
+ if item > 0.0:
+ endToEndDiscList.append(item)
+
+ for item in finAckTransactionLatNodeIter[node]:
+ if item > 0.0:
+ finAckTransactionList.append(item)
+
+ for item in ackToDeviceLatNodeIter[node]:
+ if item > 0.0:
+ ackToDeviceList.append(item)
+
+ for item in deviceToGraphDiscLatNodeIter[node]:
+ if item >= 0.0:
+ deviceToGraphDiscList.append(item)
+
+ endToEndAvg = round(numpy.mean(endToEndList), 2)
+ endToEndStdDev = round(numpy.std(endToEndList), 2)
+
+ tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2)
+ tcpToFeatureStdDev = round(numpy.std(tcpToFeatureList), 2)
+
+ featureToRoleAvg = round(numpy.mean(featureToRoleList), 2)
+ featureToRoleStdDev = round(numpy.std(featureToRoleList), 2)
+
+ roleToOfpAvg = round(numpy.mean(roleToOfpList), 2)
+ roleToOfpStdDev = round(numpy.std(roleToOfpList), 2)
+
+ ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2)
+ ofpToDeviceStdDev = round(numpy.std(ofpToDeviceList), 2)
+
+ deviceToGraphAvg = round(numpy.mean(deviceToGraphList), 2)
+ deviceToGraphStdDev = round(numpy.std(deviceToGraphList), 2)
+
+ endToEndDiscAvg = round(numpy.mean(endToEndDiscList), 2)
+ endToEndDiscStdDev = round(numpy.std(endToEndDiscList), 2)
+
+ finAckAvg = round(numpy.mean(finAckTransactionList), 2)
+ finAckStdDev = round(numpy.std(finAckTransactionList), 2)
+
+ ackToDeviceAvg = round(numpy.mean(ackToDeviceList), 2)
+ ackToDeviceStdDev = round(numpy.std(ackToDeviceList), 2)
+
+ deviceToGraphDiscAvg = round(numpy.mean(deviceToGraphDiscList), 2)
+ deviceToGraphDiscStdDev = round(numpy.std(deviceToGraphDiscList), 2)
+
+ main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
+ main.log.report(' - Switch Connection Statistics - ')
+
+ main.log.report(' End-to-end Avg: ' + str(endToEndAvg) +
+ ' ms' + ' End-to-end Std dev: ' +
+ str(endToEndStdDev) + ' ms')
+
+ main.log.report(' Tcp-to-feature-reply Avg: ' +
+ str(tcpToFeatureAvg) + ' ms')
+ main.log.report(' Tcp-to-feature-reply Std dev: '+
+ str(tcpToFeatureStdDev) + ' ms')
+
+ main.log.report(' Feature-reply-to-role-request Avg: ' +
+ str(featureToRoleAvg) + ' ms')
+ main.log.report(' Feature-reply-to-role-request Std Dev: ' +
+ str(featureToRoleStdDev) + ' ms')
+
+ main.log.report(' Role-request-to-role-reply Avg: ' +
+ str(roleToOfpAvg) +' ms')
+ main.log.report(' Role-request-to-role-reply Std dev: ' +
+ str(roleToOfpStdDev) + ' ms')
+
+ main.log.report(' Role-reply-to-device Avg: ' +
+ str(ofpToDeviceAvg) +' ms')
+ main.log.report(' Role-reply-to-device Std dev: ' +
+ str(ofpToDeviceStdDev) + ' ms')
+
+ main.log.report(' Device-to-graph Avg: ' +
+ str(deviceToGraphAvg) + ' ms')
+ main.log.report( 'Device-to-graph Std dev: ' +
+ str(deviceToGraphStdDev) + ' ms')
+
+ main.log.report(' - Switch Disconnection Statistics - ')
+ main.log.report(' End-to-end switch disconnect Avg: ' +
+ str(endToEndDiscAvg) + ' ms')
+ main.log.report(' End-to-end switch disconnect Std dev: ' +
+ str(endToEndDiscStdDev) + ' ms')
+ main.log.report(' Fin/Ack-to-Ack Avg: ' + str(finAckAvg) + ' ms')
+ main.log.report(' Fin/Ack-to-Ack Std dev: ' +
+ str(finAckStdDev) + ' ms')
+
+ main.log.report(' Ack-to-device Avg: ' + str(ackToDeviceAvg) +
+ ' ms')
+ main.log.report(' Ack-to-device Std dev: ' + str(ackToDeviceStdDev) +
+ ' ms')
+
+ main.log.report(' Device-to-graph (disconnect) Avg: ' +
+ str(deviceToGraphDiscAvg) + ' ms')
+ main.log.report(' Device-to-graph (disconnect) Std dev: ' +
+ str(deviceToGraphDiscStdDev) + ' ms')
+
+ # For database schema, refer to Amazon web services
+ dbCmdList.append(
+ "INSERT INTO switch_latency_details VALUES('" +
+ timeToPost + "','switch_latency_results'," +
+ jenkinsBuildNumber + ',' + str(clusterCount) + ",'baremetal" +
+ str(node + 1) + "'," +
+ str(endToEndAvg) + ',' +
+ str(tcpToFeatureAvg) + ',' +
+ str(featureToRoleAvg) + ',' +
+ str(roleToOfpAvg) + ',' +
+ str(ofpToDeviceAvg) + ',' +
+ str(deviceToGraphAvg) + ',' +
+ str(endToEndDiscAvg) + ',' +
+ str(finAckAvg) + ',' +
+ str(ackToDeviceAvg) + ',' +
+ str(deviceToGraphDiscAvg) +
+ ');')
+
+ if debugMode == 'on':
+ main.ONOS1.cpLogsToDir('/opt/onos/log/karaf.log',
+ '/tmp/', copyFileName='sw_lat_karaf')
+ fResult = open(resultPath, 'a')
+ for line in dbCmdList:
+ if line:
+ fResult.write(line + '\n')
+ fResult.close()
+
+ assertion = main.TRUE
+
+ utilities.assert_equals(expect=main.TRUE, actual=assertion,
+ onpass='Switch latency test successful',
+ onfail='Switch latency test failed')
+
+ def CASE3(self, main):
+ """
+ Bring port up / down and measure latency.
+ Port enable / disable is simulated by ifconfig up / down
+
+ In ONOS-next, we must ensure that the port we are
+ manipulating is connected to another switch with a valid
+ connection. Otherwise, graph view will not be updated.
+ """
+ import time
+ import subprocess
+ import os
+ import requests
+ import json
+ import numpy
+ ONOS1Ip = main.params['CTRL']['ip1']
+ ONOS2Ip = main.params['CTRL']['ip2']
+ ONOS3Ip = main.params['CTRL']['ip3']
+ ONOSUser = main.params['CTRL']['user']
+ defaultSwPort = main.params['CTRL']['port1']
+ assertion = main.TRUE
+ numIter = main.params['TEST']['numIter']
+ iterIgnore = int(main.params['TEST']['iterIgnore'])
+
+ deviceTimestampKey = main.params['JSON']['deviceTimestamp']
+ graphTimestampKey = main.params['JSON']['graphTimestamp']
+ linkTimestampKey = main.params['JSON']['linkTimestamp']
+
+ tsharkPortUp = '/tmp/tshark_port_up.txt'
+ tsharkPortDown = '/tmp/tshark_port_down.txt'
+ tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
+
+ debugMode = main.params['TEST']['debugMode']
+ postToDB = main.params['DB']['postToDB']
+ resultPath = main.params['DB']['portEventResultPath']
+ localTime = time.strftime('%x %X')
+ localTime = localTime.replace('/', '')
+ localTime = localTime.replace(' ', '_')
+ localTime = localTime.replace(':', '')
+
+ if debugMode == 'on':
+ main.ONOS1.tsharkPcap('eth0', '/tmp/port_lat_pcap_' + localTime)
+
+ upThresholdStr = main.params['TEST']['portUpThreshold']
+ downThresholdStr = main.params['TEST']['portDownThreshold']
+ upThresholdObj = upThresholdStr.split(',')
+ downThresholdObj = downThresholdStr.split(',')
+ upThresholdMin = int(upThresholdObj[0])
+ upThresholdMax = int(upThresholdObj[1])
+ downThresholdMin = int(downThresholdObj[0])
+ downThresholdMax = int(downThresholdObj[1])
+
+ interfaceConfig = 's1-eth1'
+ main.log.report('Port enable / disable latency')
+ main.log.report('Simulated by ifconfig up / down')
+ main.log.report('Total iterations of test: ' + str(numIter))
+ main.step('Assign switches s1 and s2 to controller 1')
+
+ main.Mininet1.assignSwController(sw='1',
+ ip1=ONOS1Ip, port1=defaultSwPort)
+ main.Mininet1.assignSwController(sw='2',
+ ip1=ONOS1Ip, port1=defaultSwPort)
+
+ time.sleep(15)
+
+ portUpEndToEndNodeIter = numpy.zeros((clusterCount, int(numIter)))
+ portUpOfpToDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
+ portUpDevToLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
+ portUpLinkToGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
+
+ portDownEndToEndNodeIter = numpy.zeros((clusterCount, int(numIter)))
+ portDownOfpToDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
+ portDownDevToLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
+ portDownLinkToGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
+
+ for i in range(0, int(numIter)):
+ main.step('Starting wireshark capture for port status down')
+ main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown)
+
+ time.sleep(5)
+
+ main.step('Disable port: ' + interfaceConfig)
+ main.Mininet1.handle.sendline('sh ifconfig ' +
+ interfaceConfig + ' down')
+ main.Mininet1.handle.expect('mininet>')
+
+ jsonStrPtDown = []
+ for node in range (0, clusterCount):
+ metricsPortDown = CLIs[node].topologyEventsMetrics()
+ jsonStrPtDown.append(metricsPortDown)
+
+ time.sleep(3)
+
+ main.ONOS1.tsharkStop()
+
+ os.system('scp ' + ONOSUser + '@' + ONOS1Ip + ':' +
+ tsharkPortDown + ' /tmp/')
+
+ fPortDown = open(tsharkPortDown, 'r')
+ fLine = fPortDown.readline()
+ objDown = fLine.split(' ')
+ if len(fLine) > 0:
+ timestampBeginPtDown = int(float(objDown[1]) * 1000)
+ # At times, tshark reports timestamp at the 3rd
+ # index of the array. If initial readings were
+ # unlike the epoch timestamp, then check the 3rd
+ # index and set that as a timestamp
+ if timestampBeginPtDown < 1400000000000:
+ timestampBeginPtDown = int(float(objDown[2]) * 1000)
+ # If there are any suspicion of invalid results
+ # check this reported value
+ main.log.info('Port down begin timestamp: ' +
+ str(timestampBeginPtDown))
+ else:
+ main.log.info('Tshark output file returned unexpected' +
+ ' results: ' + str(objDown))
+ timestampBeginPtDown = 0
+ fPortDown.close()
+
+ for node in range(0, clusterCount):
+ nodeNum = node+1
+ # metricsDown = CLIs[node].topologyEventsMetrics
+ #jsonStrPtDown[node] = metricsDown()
+ jsonObj = json.loads(jsonStrPtDown[node])
+
+ if jsonObj:
+ graphTimestamp = jsonObj[graphTimestampKey]['value']
+ deviceTimestamp = jsonObj[deviceTimestampKey]['value']
+ linkTimestamp = jsonObj[linkTimestampKey]['value']
+ else:
+ main.log.error( "Unexpected json object" )
+ graphTimestamp = 0
+ deviceTimestamp = 0
+ linkTimestamp = 0
+
+ ptDownEndToEnd = int(graphTimestamp) - int(timestampBeginPtDown)
+ ptDownOfpToDevice = float(deviceTimestamp) - float(timestampBeginPtDown)
+ ptDownDeviceToLink = float(linkTimestamp) - float(deviceTimestamp)
+ ptDownLinkToGraph = float(graphTimestamp) - float(linkTimestamp)
+
+ if ptDownEndToEnd >= downThresholdMin and\
+ ptDownEndToEnd < downThresholdMax and i >= iterIgnore:
+ portDownEndToEndNodeIter[node][i] = ptDownEndToEnd
+ main.log.info("ONOS "+str(nodeNum)+
+ " port down End-to-end: "+
+ str(ptDownEndToEnd) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " port down End-to-end ignored"+
+ " due to excess in threshold or premature iteration")
+
+ if ptDownOfpToDevice >= downThresholdMin and\
+ ptDownOfpToDevice < downThresholdMax and i >= iterIgnore:
+ portDownOfpToDevNodeIter[node][i] = ptDownOfpToDevice
+ main.log.info("ONOS "+str(nodeNum)+
+ " port down Ofp-to-device: "+
+ str(ptDownOfpToDevice) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " port down Ofp-to-device ignored"+
+ " due to excess in threshold or premature iteration")
+
+ if ptDownDeviceToLink >= downThresholdMin and\
+ ptDownDeviceToLink < downThresholdMax and i >= iterIgnore:
+ portDownDevToLinkNodeIter[node][i] = ptDownDeviceToLink
+ main.log.info("ONOS "+str(nodeNum)+
+ " port down Device-to-link "+
+ str(ptDownDeviceToLink) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " port down Device-to-link ignored"+
+ " due to excess in threshold or premature iteration")
+
+ if ptDownLinkToGraph >= downThresholdMin and\
+ ptDownLinkToGraph < downThresholdMax and i >= iterIgnore:
+ portDownLinkToGraphNodeIter[node][i] = ptDownLinkToGraph
+ main.log.info("ONOS "+str(nodeNum)+
+ " port down Link-to-graph "+
+ str(ptDownLinkToGraph) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " port down Link-to-graph ignored"+
+ " due to excess in threshold or premature iteration")
+
+ time.sleep(3)
+
+ main.step('Starting wireshark capture for port status up')
+ main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortUp)
+
+ time.sleep(5)
+ main.step('Enable port and obtain timestamp')
+ main.Mininet1.handle.sendline('sh ifconfig ' + interfaceConfig + ' up')
+ main.Mininet1.handle.expect('mininet>')
+
+ jsonStrPtUp = []
+ for node in range (0, clusterCount):
+ metricsPortUp = CLIs[node].topologyEventsMetrics()
+ jsonStrPtUp.append(metricsPortUp)
+
+ time.sleep(5)
+ main.ONOS1.tsharkStop()
+
+ time.sleep(3)
+ os.system('scp ' + ONOSUser + '@' +
+ ONOS1Ip + ':' + tsharkPortUp + ' /tmp/')
+
+ fPortUp = open(tsharkPortUp, 'r')
+ fLine = fPortUp.readline()
+ objUp = fLine.split(' ')
+ if len(fLine) > 0:
+ timestampBeginPtUp = int(float(objUp[1]) * 1000)
+ if timestampBeginPtUp < 1400000000000:
+ timestampBeginPtUp = int(float(objUp[2]) * 1000)
+ main.log.info('Port up begin timestamp: ' + str(timestampBeginPtUp))
+ else:
+ main.log.info('Tshark output file returned unexpected' + ' results.')
+ timestampBeginPtUp = 0
+ fPortUp.close()
+
+ for node in range(0, clusterCount):
+ nodeNum = node+1
+ #metricsUp = CLIs[node].topologyEventsMetrics
+ #jsonStrUp = metricsUp()
+ jsonObj = json.loads(jsonStrPtUp[node])
+
+ if jsonObj:
+ graphTimestamp = jsonObj[graphTimestampKey]['value']
+ deviceTimestamp = jsonObj[deviceTimestampKey]['value']
+ linkTimestamp = jsonObj[linkTimestampKey]['value']
+ else:
+ main.log.error( "Unexpected json object" )
+ graphTimestamp = 0
+ deviceTimestamp = 0
+ linkTimestamp = 0
+
+ ptUpEndToEnd = int(graphTimestamp) - int(timestampBeginPtUp)
+ ptUpOfpToDevice = float(deviceTimestamp) - float(timestampBeginPtUp)
+ ptUpDeviceToLink = float(linkTimestamp) - float(deviceTimestamp)
+ ptUpLinkToGraph = float(graphTimestamp) - float(linkTimestamp)
+
+ if ptUpEndToEnd >= upThresholdMin and\
+ ptUpEndToEnd < upThresholdMax and i > iterIgnore:
+ portUpEndToEndNodeIter[node][i] = ptUpEndToEnd
+ main.log.info("ONOS "+str(nodeNum)+
+ " port up End-to-end: "+
+ str(ptUpEndToEnd) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " port up End-to-end ignored"+
+ " due to excess in threshold or premature iteration")
+
+ if ptUpOfpToDevice >= upThresholdMin and\
+ ptUpOfpToDevice < upThresholdMax and i > iterIgnore:
+ portUpOfpToDevNodeIter[node][i] = ptUpOfpToDevice
+ main.log.info("ONOS "+str(nodeNum)+
+ " port up Ofp-to-device: "+
+ str(ptUpOfpToDevice) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " port up Ofp-to-device ignored"+
+ " due to excess in threshold or premature iteration")
+
+ if ptUpDeviceToLink >= upThresholdMin and\
+ ptUpDeviceToLink < upThresholdMax and i > iterIgnore:
+ portUpDevToLinkNodeIter[node][i] = ptUpDeviceToLink
+ main.log.info("ONOS "+str(nodeNum)+
+ " port up Device-to-link: "+
+ str(ptUpDeviceToLink) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " port up Device-to-link ignored"+
+ " due to excess in threshold or premature iteration")
+
+ if ptUpLinkToGraph >= upThresholdMin and\
+ ptUpLinkToGraph < upThresholdMax and i > iterIgnore:
+ portUpLinkToGraphNodeIter[node][i] = ptUpLinkToGraph
+ main.log.info("ONOS "+str(nodeNum)+
+ " port up Link-to-graph: "+
+ str(ptUpLinkToGraph) + " ms")
+ else:
+ main.log.info("ONOS "+str(nodeNum)+
+ " port up Link-to-graph ignored"+
+ " due to excess in threshold or premature iteration")
+
+ dbCmdList = []
+ for node in range(0, clusterCount):
+ portUpEndToEndList = []
+ portUpOfpToDevList = []
+ portUpDevToLinkList = []
+ portUpLinkToGraphList = []
+
+ portDownEndToEndList = []
+ portDownOfpToDevList = []
+ portDownDevToLinkList = []
+ portDownLinkToGraphList = []
+
+ portUpEndToEndAvg = 0
+ portUpOfpToDevAvg = 0
+ portUpDevToLinkAvg = 0
+ portUpLinkToGraphAvg = 0
+
+ portDownEndToEndAvg = 0
+ portDownOfpToDevAvg = 0
+ portDownDevToLinkAvg = 0
+ portDownLinkToGraphAvg = 0
+
+ # TODO: Update for more pythonic way to get list
+ # portUpDevList = [item for item in portUpDevNodeIter[node]
+ # if item > 0.0]
+ for item in portUpEndToEndNodeIter[node]:
+ if item > 0.0:
+ portUpEndToEndList.append(item)
+
+ for item in portUpOfpToDevNodeIter[node]:
+ if item > 0.0:
+ portUpOfpToDevList.append(item)
+
+ for item in portUpDevToLinkNodeIter[node]:
+ if item > 0.0:
+ portUpDevToLinkList.append(item)
+
+ for item in portUpLinkToGraphNodeIter[node]:
+ if item >= 0.0:
+ portUpLinkToGraphList.append(item)
+
+ for item in portDownEndToEndNodeIter[node]:
+ if item > 0.0:
+ portDownEndToEndList.append(item)
+
+ for item in portDownOfpToDevNodeIter[node]:
+ if item > 0.0:
+ portDownOfpToDevList.append(item)
+
+ for item in portDownDevToLinkNodeIter[node]:
+ if item >= 0.0:
+ portDownDevToLinkList.append(item)
+
+ for item in portDownLinkToGraphNodeIter[node]:
+ if item >= 0.0:
+ portDownLinkToGraphList.append(item)
+
+ portUpEndToEndAvg = round(numpy.mean(portUpEndToEndList), 2)
+ portUpOfpToDevAvg = round(numpy.mean(portUpOfpToDevList), 2)
+ portUpDevToLinkAvg = round(numpy.mean(portUpDevToLinkList), 2)
+ portUpLinkToGraphAvg = round(numpy.mean(portUpLinkToGraphList), 2)
+
+ portDownEndToEndAvg = round(numpy.mean(portDownEndToEndList), 2)
+ portDownOfpToDevAvg = round(numpy.mean(portDownOfpToDevList), 2)
+ portDownDevToLinkAvg = round(numpy.mean(portDownDevToLinkList), 2)
+ portDownLinkToGraphAvg = round(numpy.mean(portDownLinkToGraphList), 2)
+
+ portUpStdDev = round(numpy.std(portUpEndToEndList), 2)
+ portDownStdDev = round(numpy.std(portDownEndToEndList), 2)
+
+ main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
+ main.log.report(' Port up End-to-end ' +
+ str(portUpEndToEndAvg) + ' ms')
+ main.log.report(' Port up Ofp-to-device ' +
+ str(portUpOfpToDevAvg) + ' ms')
+ main.log.report(' Port up Device-to-link ' +
+ str(portUpDevToLinkAvg) + ' ms')
+ main.log.report(' Port up Link-to-graph ' +
+ str(portUpLinkToGraphAvg) + ' ms')
+
+ main.log.report(' Port down End-to-end ' +
+ str(round(portDownEndToEndAvg, 2)) + ' ms')
+ main.log.report(' Port down Ofp-to-device ' +
+ str(portDownOfpToDevAvg) + ' ms')
+ main.log.report(' Port down Device-to-link ' +
+ str(portDownDevToLinkAvg) + ' ms')
+ main.log.report(' Port down Link-to-graph' +
+ str(portDownLinkToGraphAvg) + ' ms')
+
+ dbCmdList.append("INSERT INTO port_latency_details VALUES('" +
+ timeToPost + "','port_latency_results'," + jenkinsBuildNumber +
+ ',' + str(clusterCount) + ",'baremetal" + str(node + 1) +
+ "'," +
+ str(portUpEndToEndAvg) +',' +
+ str(portUpOfpToDevAvg) + ',' +
+ str(portUpDevToLinkAvg) + ',' +
+ str(portUpLinkToGraphAvg) + ',' +
+ str(portDownEndToEndAvg) + ',' +
+ str(portDownOfpToDevAvg) + ',' +
+ str(portDownDevToLinkAvg) + ',' +
+ str(portDownLinkToGraphAvg) +
+ ');')
+
+ fResult = open(resultPath, 'a')
+ for line in dbCmdList:
+ if line:
+ fResult.write(line + '\n')
+
+ fResult.close()
+
+ # Delete switches from controller to prepare for next
+ # set of tests
+ main.Mininet1.deleteSwController('s1')
+ main.Mininet1.deleteSwController('s2')
+ utilities.assert_equals(expect=main.TRUE,
+ actual=assertion,
+ onpass='Port discovery latency calculation successful',
+ onfail='Port discovery test failed')
+
+ def CASE4(self, main):
+ """
+ Increase number of nodes and initiate CLI
+
+ With the most recent implementation, we need a method to
+ ensure all ONOS nodes are killed, as well as redefine
+ the cell files to ensure all nodes that will be used
+ is in the cell file. Otherwise, exceptions will
+ prohibit test from running successfully.
+
+ 3/12/15
+
+ """
+ global clusterCount
+ import time
+ import os
+
+ clusterCount += 2
+
+ benchIp = main.params[ 'BENCH' ][ 'ip' ]
+ features = main.params[ 'ENV' ][ 'cellFeatures' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ mininetIp = main.params[ 'MN' ][ 'ip1' ]
+
+ main.log.report('Increasing cluster size to ' + str(clusterCount))
+
+ main.log.step( "Killing all ONOS processes before scale-out" )
+
+ for i in range( 1, 8 ):
+ main.ONOSbench.onosDie(
+ main.params[ 'CTRL' ][ 'ip'+str(i) ] )
+ main.ONOSbench.onosUninstall(
+ main.params[ 'CTRL' ][ 'ip'+str(i) ] )
+
+ main.step( "Creating scale-out cell file" )
+ cellIp = []
+ for node in range( 1, clusterCount + 1 ):
+ cellIp.append( main.params[ 'CTRL' ][ 'ip'+str(node) ] )
+
+ main.log.info( "Cell Ip list: " + str(cellIp) )
+ main.ONOSbench.createCellFile( benchIp, cellName, mininetIp,
+ str(features), *cellIp )
+
+ main.step( "Setting cell definition" )
+ main.ONOSbench.setCell(cellName)
+
+ main.step( "Packaging cell definition" )
+ main.ONOSbench.onosPackage()
+
+ for node in range( 1, clusterCount + 1 ):
+ main.ONOSbench.onosInstall(
+ node = main.params[ 'CTRL' ][ 'ip'+str(node) ])
+
+ time.sleep( 20 )
+
+ for node in range( 1, clusterCount + 1):
+ for i in range( 2 ):
+ isup = main.ONOSbench.isup(
+ main.params[ 'CTRL' ][ 'ip'+str(node) ] )
+ if isup:
+ main.log.info( "ONOS "+str(node) + " is up\n")
+ break
+ if not isup:
+ main.log.error( "ONOS "+str(node) + " did not start" )
+
+ for node in range( 0, clusterCount ):
+ CLIs[node].startOnosCli( cellIp[node] )
+
+ main.step( 'Setting configurations for metrics' )
+ configParam = 'maxEvents 1'
+ main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
+ configParam = 'maxBatchMs 0'
+ main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
+ configParam = 'maxIdleMs 0'
+ main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
+
+ main.step( 'Activating essential applications' )
+ CLIs[0].activateApp( 'org.onosproject.metrics' )
+ CLIs[0].activateApp( 'org.onosproject.openflow' )
+
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.topo b/TestON/tests/TopoPerfNextBM/TopoPerfNextBM.topo
similarity index 74%
rename from TestON/tests/TopoPerfNext/TopoPerfNext.topo
rename to TestON/tests/TopoPerfNextBM/TopoPerfNextBM.topo
index fc70784..570dece 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.topo
+++ b/TestON/tests/TopoPerfNextBM/TopoPerfNextBM.topo
@@ -2,7 +2,7 @@
<COMPONENT>
<ONOSbench>
- <host>10.128.174.10</host>
+ <host>10.254.1.200</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
@@ -11,7 +11,7 @@
</ONOSbench>
<ONOS1cli>
- <host>10.128.174.10</host>
+ <host>10.254.1.200</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -20,142 +20,142 @@
</ONOS1cli>
<ONOS2cli>
- <host>10.128.174.10</host>
+ <host>10.254.1.200</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>3</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS2cli>
<ONOS3cli>
- <host>10.128.174.10</host>
+ <host>10.254.1.200</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>4</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS3cli>
<ONOS4cli>
- <host>10.128.174.10</host>
+ <host>10.254.1.200</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>5</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS4cli>
<ONOS5cli>
- <host>10.128.174.10</host>
+ <host>10.254.1.200</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>6</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS5cli>
<ONOS6cli>
- <host>10.128.174.10</host>
+ <host>10.254.1.200</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>7</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS6cli>
<ONOS7cli>
- <host>10.128.174.10</host>
+ <host>10.254.1.200</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
- <connect_order>2</connect_order>
+ <connect_order>8</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS7cli>
<ONOS1>
- <host>10.128.174.1</host>
+ <host>10.254.1.201</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
- <connect_order>3</connect_order>
+ <connect_order>9</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS1>
<ONOS2>
- <host>10.128.174.2</host>
+ <host>10.254.1.202</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
- <connect_order>3</connect_order>
+ <connect_order>10</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS2>
<ONOS3>
- <host>10.128.174.3</host>
+ <host>10.254.1.203</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
- <connect_order>3</connect_order>
+ <connect_order>11</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS3>
<ONOS4>
- <host>10.128.174.4</host>
+ <host>10.254.1.204</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
- <connect_order>3</connect_order>
+ <connect_order>12</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS4>
<ONOS5>
- <host>10.128.174.5</host>
+ <host>10.254.1.205</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
- <connect_order>3</connect_order>
+ <connect_order>13</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS5>
<ONOS6>
- <host>10.128.174.6</host>
+ <host>10.254.1.206</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
- <connect_order>3</connect_order>
+ <connect_order>14</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS6>
<ONOS7>
- <host>10.128.174.7</host>
+ <host>10.254.1.207</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
- <connect_order>3</connect_order>
+ <connect_order>15</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS7>
<Mininet1>
- <host>10.128.10.90</host>
+ <host>10.254.1.200</host>
<user>admin</user>
<password>onos_test</password>
<type>MininetCliDriver</type>
- <connect_order>4</connect_order>
+ <connect_order>16</connect_order>
<COMPONENTS>
<arg1> --custom topo-perf-2sw.py </arg1>
- <arg2> --arp --mac --topo mytopo</arg2>
+ <arg2> --topo mytopo</arg2>
<arg3> </arg3>
<controller> remote </controller>
</COMPONENTS>
</Mininet1>
<Mininet2>
- <host>10.128.10.90</host>
+ <host>10.254.1.200</host>
<user>admin</user>
<password>onos_test</password>
<type>RemoteMininetDriver</type>
- <connect_order>5</connect_order>
+ <connect_order>17</connect_order>
<COMPONENTS> </COMPONENTS>
</Mininet2>
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/TopoPerfNextBM/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/TopoPerfNextBM/__init__.py
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.params b/TestON/tests/TopoPerfNextBM/backup/TopoPerfNextBM.params
similarity index 69%
rename from TestON/tests/TopoPerfNext/TopoPerfNext.params
rename to TestON/tests/TopoPerfNextBM/backup/TopoPerfNextBM.params
index 45de48d..d681433 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.params
+++ b/TestON/tests/TopoPerfNextBM/backup/TopoPerfNextBM.params
@@ -1,8 +1,9 @@
<PARAMS>
- <testcases>1,2,3,6,2,3,6,2,3,6,2,3</testcases>
+ <testcases>1,2,3,4,2,3,4,2,3,4,2,3</testcases>
<ENV>
<cellName>topo_perf_test</cellName>
+ <cellFeatures>"org.onosproject.metrics,org.onosproject.openflow"</cellFeatures>
</ENV>
<GIT>
@@ -12,7 +13,7 @@
</GIT>
<CTRL>
- <user>admin</user>
+ <user>sdn</user>
<ip1>10.128.174.1</ip1>
<port1>6633</port1>
<ip2>10.128.174.2</ip2>
@@ -35,6 +36,15 @@
<ip>10.128.174.10</ip>
</BENCH>
+ <TSHARK>
+ <ofpPortStatus>OF 1.3 146</ofpPortStatus>
+ <ofpRoleReply>OF 1.3 90 of_role_reply</ofpRoleReply>
+ <featureReply>OF 1.3 98 of_features_reply</featureReply>
+ <roleRequest>OF 1.3 90 of_role_request</roleRequest>
+ <tcpSynAck>TCP 74 6633</tcpSynAck>
+ <finAckSequence>FIN</finAckSequence>
+ </TSHARK>
+
<TEST>
#'on' or 'off' debug mode.
#If on, logging will be more verbose and
@@ -52,7 +62,7 @@
</topoConfigName>
#Number of times to iterate each case
- <numIter>5</numIter>
+ <numIter>10</numIter>
<numSwitch>2</numSwitch>
#Number of iterations to ignore initially
<iterIgnore>2</iterIgnore>
@@ -67,6 +77,16 @@
<tabletFile>tablets_3node.json</tabletFile>
</TEST>
+ <DB>
+ <postToDB>on</postToDB>
+ <portEventResultPath>
+ /home/admin/ONLabTest/TestON/tests/TopoPerfNextBM/portEventResultDb.log
+ </portEventResultPath>
+ <switchEventResultPath>
+ /home/admin/ONLabTest/TestON/tests/TopoPerfNextBM/switchEventResultDb.log
+ </switchEventResultPath>
+ </DB>
+
<JSON>
<deviceTimestamp>topologyDeviceEventTimestamp</deviceTimestamp>
<hostTimestamp>topologyHostEventTimestamp</hostTimestamp>
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/TopoPerfNextBM/portEventResultDb.log
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/TopoPerfNextBM/portEventResultDb.log
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/TopoPerfNextBM/switchEventResultDb.log
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/TopoPerfNextBM/switchEventResultDb.log
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/TopoPerfNextSingleNode/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/TopoPerfNextSingleNode/__init__.py
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/flowTP1g/__init__.py
similarity index 100%
copy from TestON/tests/IntentsLoad/__init__.py
copy to TestON/tests/flowTP1g/__init__.py
diff --git a/TestON/tests/flowTP1g/flowTP1g.params b/TestON/tests/flowTP1g/flowTP1g.params
new file mode 100644
index 0000000..54320a7
--- /dev/null
+++ b/TestON/tests/flowTP1g/flowTP1g.params
@@ -0,0 +1,73 @@
+<PARAMS>
+
+ <testcases>1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2</testcases>
+
+ <isOnBaremetal>False</isOnBaremetal>
+ <SCALE>1,3,3,5,5,7,7</SCALE>
+ <availableNodes>7</availableNodes>
+
+
+
+ <ENV>
+ <cellName>flowTP</cellName>
+ <cellApps>drivers,null,demo</cellApps>
+ </ENV>
+
+ <TEST>
+ <enableFlowRuleStoreBackup>true</enableFlowRuleStoreBackup>
+ <skipCleanInstall>yes</skipCleanInstall>
+ <warmUp>5</warmUp> #number of runs to warm up the system
+ <sampleSize>20</sampleSize> #number of runs to take data from
+ <neighbors>0,a</neighbors> #list of number of neighbors, a = all
+ <flows>122500</flows>
+ <switches>35</switches>
+ <cooldown>10</cooldown>
+ <testCMD0>flow-tester.py -f</testCMD0> #base command
+ <testCMD1> -n </testCMD1> #neighbors
+
+ </TEST>
+
+ <GIT>
+ <autopull>on</autopull>
+ <checkout>master</checkout>
+ </GIT>
+
+ <CTRL>
+ <USER>admin</USER>
+
+ <ip1>10.128.5.51</ip1>
+ <port1>6633</port1>
+
+ <ip2>10.128.5.52</ip2>
+ <port2>6633</port2>
+
+ <ip3>10.128.5.53</ip3>
+ <port3>6633</port3>
+
+ <ip4>10.128.5.54</ip4>
+ <port4>6633</port4>
+
+ <ip5>10.128.5.55</ip5>
+ <port5>6633</port5>
+
+ <ip6>10.128.5.56</ip6>
+ <port6>6633</port6>
+
+ <ip7>10.128.5.57</ip7>
+ <port7>6633</port7>
+
+ </CTRL>
+
+ <MN>
+ <ip1>10.128.5.59</ip1>
+ </MN>
+
+ <BENCH>
+ <user>admin</user>
+ <ip1>10.128.5.50</ip1>
+ </BENCH>
+
+ <JSON>
+ </JSON>
+
+</PARAMS>
diff --git a/TestON/tests/flowTP1g/flowTP1g.py b/TestON/tests/flowTP1g/flowTP1g.py
new file mode 100644
index 0000000..cbea039
--- /dev/null
+++ b/TestON/tests/flowTP1g/flowTP1g.py
@@ -0,0 +1,403 @@
+# ScaleOutTemplate -> flowTP
+#
+# CASE1 starts number of nodes specified in param file
+#
+# cameron@onlab.us
+
+import sys
+import os.path
+
+
+class flowTP1g:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+
+ import time
+ global init
+ try:
+ if type(init) is not bool:
+ init = False
+ except NameError:
+ init = False
+
+ #Load values from params file
+ checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
+ gitPull = main.params[ 'GIT' ][ 'autopull' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ Apps = main.params[ 'ENV' ][ 'cellApps' ]
+ BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+ BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+ MN1Ip = main.params[ 'MN' ][ 'ip1' ]
+ maxNodes = int(main.params[ 'availableNodes' ])
+ skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+
+ main.log.info("==========DEBUG VERSION 3===========")
+
+ main.exceptions = [0]*11
+ main.warnings = [0]*11
+ main.errors = [0]*11
+
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
+ if init == False:
+ init = True
+ global clusterCount #number of nodes running
+ global ONOSIp #list of ONOS IP addresses
+ global scale
+ global commit
+
+ clusterCount = 0
+ ONOSIp = [ 0 ]
+ scale = (main.params[ 'SCALE' ]).split(",")
+ clusterCount = int(scale[0])
+
+ #Populate ONOSIp with ips from params
+ for i in range(1, maxNodes + 1):
+ ipString = 'ip' + str(i)
+ ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
+
+ #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
+ if skipMvn != "yes":
+ mvnResult = main.ONOSbench.cleanInstall()
+
+ #git
+ main.step( "Git checkout and pull " + checkoutBranch )
+ if gitPull == 'on':
+ checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
+ pullResult = main.ONOSbench.gitPull()
+
+ else:
+ checkoutResult = main.TRUE
+ pullResult = main.TRUE
+ main.log.info( "Skipped git checkout and pull" )
+
+ commit = main.ONOSbench.getVersion()
+ commit = (commit.split(" "))[1]
+
+ resultsDB = open("flowTP1gDB", "w+")
+ resultsDB.close()
+
+ # -- END OF INIT SECTION --#
+
+ clusterCount = int(scale[0])
+ scale.remove(scale[0])
+ main.log.info("CLUSTER COUNT: " + str(clusterCount))
+
+ #kill off all onos processes
+ main.log.step("Safety check, killing all ONOS processes")
+ main.log.step("before initiating enviornment setup")
+ for node in range(1, maxNodes + 1):
+ main.ONOSbench.onosDie(ONOSIp[node])
+
+ #Uninstall everywhere
+ main.log.step( "Cleaning Enviornment..." )
+ for i in range(1, maxNodes + 1):
+ main.log.info(" Uninstalling ONOS " + str(i) )
+ main.ONOSbench.onosUninstall( ONOSIp[i] )
+
+ #construct the cell file
+ main.log.info("Creating cell file")
+ cellIp = []
+ for node in range (1, clusterCount + 1):
+ cellIp.append(ONOSIp[node])
+
+ main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
+ main.log.info("Cell Ip list: " + str(cellIp))
+
+ main.step( "Set Cell" )
+ main.ONOSbench.setCell(cellName)
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "verify cells" )
+ verifyCellResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
+ for node in range(1, clusterCount + 1):
+ main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
+ main.ONOSbench.onosInstall( ONOSIp[node])
+
+ for node in range(1, clusterCount + 1):
+ for i in range( 2 ):
+ isup = main.ONOSbench.isup( ONOSIp[node] )
+ if isup:
+ main.log.info("ONOS " + str(node) + " is up\n")
+ break
+ if not isup:
+ main.log.report( "ONOS " + str(node) + " didn't start!" )
+
+ for node in range(1, clusterCount + 1):
+ exec "a = main.ONOS%scli.startOnosCli" %str(node)
+ a(ONOSIp[node])
+
+ main.log.info("Startup sequence complete")
+ main.ONOSbench.onosErrorLog(ONOSIp[1])
+
+ def CASE2( self, main ):
+ #
+ # This is the flow TP test
+ #
+ import os.path
+ import numpy
+ import math
+ import time
+ import datetime
+ import traceback
+
+ global currentNeighbors
+ try:
+ currentNeighbors
+ except:
+ currentNeighbors = "0"
+ else:
+ if currentNeighbors == "r": #reset
+ currentNeighbors = "0"
+ else:
+ currentNeighbors = "a"
+
+ testCMD = [ 0,0,0,0 ]
+ warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
+ sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
+ switches = int(main.params[ 'TEST' ][ 'switches' ])
+ neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
+ testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
+ testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
+ maxNodes = main.params[ 'availableNodes' ]
+ onBaremetal = main.params['isOnBaremetal']
+ cooldown = main.params[ 'TEST' ][ 'cooldown' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+ BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+ MN1Ip = main.params[ 'MN' ][ 'ip1' ]
+ maxNodes = int(main.params[ 'availableNodes' ])
+ homeDir = os.path.expanduser('~')
+ flowRuleBackup = str(main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ])
+ main.log.info("Flow Rule Backup is set to:" + flowRuleBackup)
+
+ servers = str(clusterCount)
+
+ if clusterCount == 1:
+ neighborList = ['0']
+ currentNeighbors = "r"
+ else:
+ if currentNeighbors == "a":
+ neighborList = [str(clusterCount-1)]
+ currentNeighbors = "r"
+ else:
+ neighborList = ['0']
+
+ main.log.info("neightborlist: " + str(neighborList))
+
+ ts = time.time()
+ st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
+
+ #write file to change mem limit to 32 gigs (BAREMETAL ONLY!)
+ if onBaremetal == "true":
+ filename = "/onos/tools/package/bin/onos-service"
+ serviceConfig = open(homeDir + filename, 'w+')
+ serviceConfig.write("#!/bin/bash\n ")
+ serviceConfig.write("#------------------------------------- \n ")
+ serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
+ serviceConfig.write("#------------------------------------- \n ")
+ serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
+ serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
+ serviceConfig.write("")
+ serviceConfig.write("ONOS_HOME=/opt/onos \n ")
+ serviceConfig.write("")
+ serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
+ serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
+ serviceConfig.close()
+
+ for n in neighborList:
+ main.log.step("\tSTARTING TEST")
+ main.log.step("\tLOADING FROM SERVERS: \t" + str(clusterCount) )
+ main.log.step("\tNEIGHBORS:\t" + n )
+ main.log.info("=============================================================")
+ main.log.info("=============================================================")
+ #write file to configure nil link
+ ipCSV = ""
+ for i in range (1, int(maxNodes) + 1):
+ tempstr = "ip" + str(i)
+ ipCSV += main.params[ 'CTRL' ][ tempstr ]
+ if i < int(maxNodes):
+ ipCSV +=","
+
+
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount 35" """)
+ main.ONOSbench.handle.expect(":~")
+ time.sleep(3)
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
+ main.ONOSbench.handle.expect(":~")
+ time.sleep(3)
+ main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
+ main.ONOSbench.handle.expect(":~")
+ time.sleep(3)
+ main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
+ main.ONOSbench.handle.expect(":~")
+ time.sleep(3)
+ main.log.info("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBackup + """" """)
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBackup + """" """)
+ main.ONOSbench.handle.expect(":~")
+
+ main.ONOSbench.handle.sendline("onos $OC1 summary")
+ main.ONOSbench.handle.expect(":~")
+ check = main.ONOSbench.handle.before
+
+ main.ONOSbench.handle.sendline("""onos $OC1 "cfg get" """)
+ main.ONOSbench.handle.expect(":~")
+ check = main.ONOSbench.handle.before
+ main.log.info("\nStart up check: \n" + check + "\n")
+
+ #devide flows
+ flows = int(main.params[ 'TEST' ][ 'flows' ])
+ main.log.info("Flow Target = " + str(flows))
+
+ flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
+
+ main.log.info("Flows per switch = " + str(flows))
+
+ #build list of servers in "$OC1, $OC2...." format
+ serverEnvVars = ""
+ for i in range (1,int(servers)+1):
+ serverEnvVars += ("-s " + ONOSIp[i] + " ")
+
+ data = [[""]*int(servers)]*int(sampleSize)
+ maxes = [""]*int(sampleSize)
+
+ flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
+ flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
+ flowCMD += " " + str(n) + " " + str(serverEnvVars) + "-j"
+
+ main.log.info(flowCMD)
+ #time.sleep(60)
+
+ for test in range(0, warmUp + sampleSize):
+ if test < warmUp:
+ main.log.info("Warm up " + str(test + 1) + " of " + str(warmUp))
+ else:
+ main.log.info("====== Test run: " + str(test-warmUp+1) + " ======")
+
+ main.ONOSbench.handle.sendline(flowCMD)
+ main.ONOSbench.handle.expect(":~")
+ rawResult = main.ONOSbench.handle.before
+ main.log.info("Raw results: \n" + rawResult + "\n")
+
+ if "failed" in rawResult:
+ main.log.report("FLOW_TESTER.PY FAILURE")
+ main.log.report( " \n" + rawResult + " \n")
+ break
+
+ ########################################################################################
+ result = [""]*(clusterCount)
+ rawResult = rawResult.splitlines()
+
+ for node in range(1, clusterCount + 1):
+ for line in rawResult:
+ #print("line: " + line)
+ if ONOSIp[node] in line and "server" in line:
+ temp = line.split(" ")
+ for word in temp:
+ #print ("word: " + word)
+ if "elapsed" in repr(word):
+ #print("in elapsed ==========")
+ index = temp.index(word) + 1
+ #print ("index: " + str(index))
+ #print ("temp[index]: " + temp[index])
+ myParsed = (temp[index]).replace(",","")
+ myParsed = myParsed.replace("}","")
+ myParsed = int(myParsed)
+ result[node-1] = myParsed
+ main.log.info( ONOSIp[node] + " : " + str(myParsed))
+ break
+
+ if test >= warmUp:
+ for i in result:
+ if i == "":
+ main.log.error("Missing data point, critical failure incoming")
+
+ print result
+ maxes[test-warmUp] = max(result)
+ main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize))
+ main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)")
+
+ data[test-warmUp] = result
+
+ # wait for flows = 0
+ for checkCount in range(0,5):
+ time.sleep(10)
+ main.ONOSbench.handle.sendline("onos $OC1 summary")
+ main.ONOSbench.handle.expect(":~")
+ flowCheck = main.ONOSbench.handle.before
+ if "flows=0," in flowCheck:
+ main.log.info("Flows removed")
+ break
+ else:
+ for line in flowCheck.splitlines():
+ if "flows=" in line:
+ main.log.info("Current Summary: " + line)
+ if checkCount == 2:
+ main.log.info("Flows are stuck, moving on ")
+
+
+ time.sleep(5)
+
+ main.log.info("raw data: " + str(data))
+ main.log.info("maxes:" + str(maxes))
+
+
+ # report data
+ print("")
+ main.log.info("\t Results (measurments are in milliseconds)")
+ print("")
+
+ nodeString = ""
+ for i in range(1, int(servers) + 1):
+ nodeString += ("\tNode " + str(i))
+
+ for test in range(0, sampleSize ):
+ main.log.info("\t Test iteration " + str(test + 1) )
+ main.log.info("\t------------------")
+ main.log.info(nodeString)
+ resultString = ""
+
+ for i in range(0, int(servers) ):
+ resultString += ("\t" + str(data[test][i]) )
+ main.log.info(resultString)
+
+ print("\n")
+
+ avgOfMaxes = numpy.mean(maxes)
+ main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
+
+ stdOfMaxes = numpy.std(maxes)
+ main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
+ print("\n\n")
+
+ avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second
+
+ tp = []
+ for i in maxes:
+ tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i ))
+
+ stdTP = numpy.std(tp)
+
+ main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
+ main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
+
+ resultsLog = open("flowTP1gDB","a")
+ resultString = ("'" + commit + "',")
+ resultString += ("'1gig',")
+ resultString += ((main.params[ 'TEST' ][ 'flows' ]) + ",")
+ resultString += (str(clusterCount) + ",")
+ resultString += (str(n) + ",")
+ resultString += (str(avgTP) + "," + str(stdTP) + "\n")
+ resultsLog.write(resultString)
+ resultsLog.close()
+
+ main.log.report("Result line to file: " + resultString)
+
+ main.ONOSbench.onosErrorLog(ONOSIp[1])
diff --git a/TestON/tests/flowTP1g/flowTP1g.topo b/TestON/tests/flowTP1g/flowTP1g.topo
new file mode 100644
index 0000000..763a4d6
--- /dev/null
+++ b/TestON/tests/flowTP1g/flowTP1g.topo
@@ -0,0 +1,144 @@
+<TOPOLOGY>
+
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS><home>~/onos</home></COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1cli>
+
+ <ONOS2cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2cli>
+
+ <ONOS3cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3cli>
+
+ <ONOS4cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4cli>
+
+ <ONOS5cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5cli>
+
+ <ONOS6cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6cli>
+
+ <ONOS7cli>
+ <host>10.128.5.50</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7cli>
+
+ <ONOS1>
+ <host>10.128.5.51</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.5.52</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.5.53</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.128.5.54</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4>
+
+
+ <ONOS5>
+ <host>10.128.5.55</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5>
+
+ <ONOS6>
+ <host>10.128.5.56</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>14</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6>
+
+ <ONOS7>
+ <host>10.128.5.57</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>15</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7>
+
+ </COMPONENT>
+
+</TOPOLOGY>
+