Merge "Platform Test: docker driver"
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 17893a1..bc23be0 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -33,16 +33,16 @@
import xmldict
import importlib
import threading
-module = new.module("test")
+module = new.module( "test" )
import openspeak
import subprocess
-global path, drivers_path, core_path, tests_path,logs_path
+global path, drivers_path, core_path, tests_path, logs_path
location = os.path.abspath( os.path.dirname( __file__ ) )
path = re.sub( "(core|bin)$", "", location )
-drivers_path = path+"drivers"
-core_path = path+"core"
-tests_path = path+"tests"
-logs_path = path+"logs/"
+drivers_path = path + "drivers"
+core_path = path + "core"
+tests_path = path + "tests"
+logs_path = path + "logs/"
config_path = path + "config/"
sys.path.append( path )
sys.path.append( drivers_path )
@@ -56,13 +56,14 @@
class TestON:
'''
TestON will initiate the specified test.
- The main tasks are :
+ The main tasks are:
* Initiate the required Component handles for the test.
* Create Log file Handles.
'''
- def __init__(self,options):
+ def __init__( self, options ):
'''
- Initialise the component handles specified in the topology file of the specified test.
+ Initialise the component handles specified in the topology file of
+ the specified test.
'''
# Initialization of the variables.
__builtin__.main = self
@@ -76,7 +77,6 @@
self.PASS = True
self.CASERESULT = self.ERROR
self.STEPRESULT = self.NORESULT
- self.stepResults = []
self.init_result = self.TRUE
self.testResult = "Summary"
self.stepName = ""
@@ -98,101 +98,111 @@
self.initiated = False
self.configparser()
- verifyOptions(options)
+ verifyOptions( options )
load_logger()
self.componentDictionary = {}
- self.componentDictionary = self.topology ['COMPONENT']
- self.driversList=[]
- if type(self.componentDictionary) == str :
- self.componentDictionary = dict(self.componentDictionary)
+ self.componentDictionary = self.topology['COMPONENT']
+ self.driversList = []
+ if isinstance( self.componentDictionary, str):
+ self.componentDictionary = dict( self.componentDictionary )
- for component in self.componentDictionary :
- self.driversList.append(self.componentDictionary[component]['type'])
+ for component in self.componentDictionary:
+ self.driversList.append( self.componentDictionary[component]['type'] )
- self.driversList = list(set(self.driversList)) # Removing duplicates.
+ self.driversList = list( set( self.driversList ) ) # Removing duplicates.
# Checking the test_target option set for the component or not
- if type(self.componentDictionary) == dict:
+ if isinstance( 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
- self.logger.initlog(self)
+ self.logger.initlog( self )
# Creating Drivers Handles
- initString = "\n"+"*" * 30+"\n CASE INIT \n"+"*" * 30+"\n"
- self.log.exact(initString)
+ initString = "\n" + "*" * 30 + "\n CASE INIT \n" + "*" * 30 + "\n"
+ self.log.exact( initString )
self.driverObject = {}
- self.random_order = 111 # Random order id to connect the components
+ self.random_order = 111 # Random order id to connect the components
components_connect_order = {}
- #component_list.append()
- if type(self.componentDictionary) == dict:
+ if isinstance( self.componentDictionary, dict ):
for component in self.componentDictionary.keys():
- self.componentDictionary[component]['connect_order'] = self.componentDictionary[component]['connect_order'] if ('connect_order' in self.componentDictionary[component].keys()) else str(self.get_random())
- components_connect_order[component] = eval(self.componentDictionary[component]['connect_order'])
- #Ordering components based on the connect order.
- ordered_component_list =sorted(components_connect_order, key=lambda key: components_connect_order[key])
+ if 'connect_order' not in self.componentDictionary[component].keys():
+ self.componentDictionary[component]['connect_order'] = str( self.get_random() )
+ components_connect_order[component] = eval( self.componentDictionary[component]['connect_order'] )
+ # 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)
+ self.componentInit( component )
- def configparser(self):
+ def configparser( self ):
'''
It will parse the config file (teston.cfg) and return as dictionary
'''
- matchFileName = re.match(r'(.*)\.cfg', self.configFile, re.M | re.I)
+ matchFileName = re.match( r'(.*)\.cfg', self.configFile, re.M | re.I )
if matchFileName:
- xml = open(self.configFile).read()
- try :
- self.configDict = xmldict.xml_to_dict(xml)
+ xml = open( self.configFile ).read()
+ try:
+ self.configDict = xmldict.xml_to_dict( xml )
return self.configDict
except IOError:
print "There is no such file to parse " + self.configFile
else:
print "There is no such file to parse " + self.configFile
- def componentInit(self,component):
+ def componentInit( self, component ):
'''
This method will initialize specified component
'''
global driver_options
self.initiated = False
- self.log.info("Creating component Handle: "+component)
+ self.log.info( "Creating component Handle: " + component )
driver_options = {}
if 'COMPONENTS' in self.componentDictionary[component].keys():
- driver_options =dict(self.componentDictionary[component]['COMPONENTS'])
+ driver_options = dict( self.componentDictionary[component]['COMPONENTS'] )
- driver_options['name']=component
+ driver_options['name'] = component
driverName = self.componentDictionary[component]['type']
- driver_options ['type'] = driverName
+ driver_options['type'] = driverName
- classPath = self.getDriverPath(driverName.lower())
- driverModule = importlib.import_module(classPath)
- driverClass = getattr(driverModule, driverName)
+ classPath = self.getDriverPath( driverName.lower() )
+ driverModule = importlib.import_module( classPath )
+ driverClass = getattr( driverModule, driverName )
driverObject = driverClass()
- if ( "OCN" in self.componentDictionary[component]['host'] and main.onoscell ):
+ if "OCN" in self.componentDictionary[component]['host'] and\
+ main.onoscell:
self.componentDictionary[component]['host'] = main.mnIP
- 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',
- port = self.componentDictionary[component]['port'] if ('port' in self.componentDictionary[component].keys()) else None,
- options = driver_options)
+ user_name = self.componentDictionary[component].get( 'user',
+ getpass.getuser() )
+ ip_address = self.componentDictionary[component].get( 'host',
+ 'localhost' )
+ pwd = self.componentDictionary[component].get( 'password',
+ 'changeme' )
+ port = self.componentDictionary[component].get( 'port' )
+ connect_result = driverObject.connect( user_name=user_name,
+ ip_address=ip_address,
+ pwd=pwd,
+ port=port,
+ options=driver_options)
if not connect_result:
- self.log.error("Exiting from the test execution because the connecting to the "+component+" component failed.")
+ self.log.error( "Exiting from the test execution because connecting to the " +
+ component + " component failed." )
self.exit()
- vars(self)[component] = driverObject
+ vars( self )[component] = driverObject
self.initiated = True
- def run(self):
+ 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,
- else will retun FALSE
+ The Execution of the test script's cases listed in the Test params
+ file will be done here then update each test case result.
+ This method will return main.TRUE if it executed all the test cases
+ successfully, else will retun main.FALSE
'''
self.testCaseResult = {}
self.TOTAL_TC = 0
@@ -202,117 +212,167 @@
self.TOTAL_TC_FAIL = 0
self.TOTAL_TC_PASS = 0
self.TEST_ITERATION = 0
+
+ # NOTE: number of main.step statements in the
+ # outer most level of the test case. used to
+ # execute code in smaller steps
self.stepCount = 0
self.CASERESULT = self.NORESULT
import testparser
- testFile = self.tests_path + "/"+self.TEST + "/"+self.TEST + ".py"
- test = testparser.TestParser(testFile)
+ 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
- self.TOTAL_TC_PLANNED = len(self.testcases_list)*repeat
+ repeat = int( self.params.get( 'repeat', 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 = []
+
+ # List of step results in a case. ANDed together to get the result
+ self.stepResultsList = []
self.stepName = ""
self.caseExplanation = ""
result = self.TRUE
+
+ # NOTE: number of main.step statements in the
+ # outer most level of the test case. used to
+ # execute code in smaller steps
self.stepCount = 0
+
+ # NOTE: This is the current number of main.step()'s executed
+ # in a case. Used for logging.
+ self.stepNumber = 0
self.EXPERIMENTAL_MODE = self.FALSE
self.addCaseHeader()
self.testCaseNumber = str( testCaseNumber )
self.CASERESULT = self.NORESULT
stopped = False
- try :
- self.stepList = self.code[self.testCaseNumber].keys()
+ try:
+ self.code[self.testCaseNumber]
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)
+ while self.stepCount < len( self.code[self.testCaseNumber].keys() ):
+ result = self.runStep( self.code, self.testCaseNumber )
if result == self.FALSE:
break
elif result == self.TRUE:
continue
+ # stepResults format: ( stepNo[], stepName[], stepResult[], onFail[] )
+ stepResults = self.stepResultsList
if not stopped:
if self.CASERESULT == self.TRUE or self.CASERESULT == self.FALSE:
- # Result was already explitily set somewhere else like skipCase()
+ # Result was already explitily set somewhere else like
+ # in skipCase()
pass
- elif all( self.TRUE == i for i in self.stepResults ):
+ elif all( self.TRUE == i for i in stepResults ):
# ALL PASSED
self.CASERESULT = self.TRUE
- elif self.FALSE in self.stepResults:
+ elif self.FALSE in stepResults:
# AT LEAST ONE FAILED
self.CASERESULT = self.FALSE
- elif self.TRUE in self.stepResults:
+ elif self.TRUE in 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.testCaseResult[str( self.CurrentTestCaseNumber )] = self.CASERESULT
+ self.logger.updateCaseResults( self )
self.log.wiki( "<p>" + self.caseExplanation + "</p>" )
self.log.summary( self.caseExplanation )
self.log.wiki( "<ul>" )
+ subcaseMessage = False
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" )
- else: # Should only be on fail message
- self.log.wiki( "<ul><li>" + line + "</li></ul>\n" )
+ if re.search( "[0-9]\.[0-9]", line ): # Step
+ if subcaseMessage: # End of Failure Message Printout
+ self.log.wiki( "</ul>\n" )
+ subcaseMessage = False
+ 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" )
+ else: # Substep
+ if not subcaseMessage: # Open Failure Message Printout
+ self.log.wiki( "<ul><li>" + line + "</li>\n" )
+ subcaseMessage = True
+ else: # Add to Failure Message Printout
+ self.log.wiki( "<li>" + line + "</li>\n" )
+ if subcaseMessage: # End of Failure Message Printout for last item
+ self.log.wiki( "</ul>\n" )
self.log.wiki( "</ul>" )
self.log.summary( self.stepCache )
self.stepCache = ""
return result
- def runStep(self,stepList,code,testCaseNumber):
+ def runStep( self, code, testCaseNumber ):
if not cli.pause:
- try :
- step = stepList[self.stepCount]
- self.STEPRESULT = self.NORESULT
- self.onFailMsg = "No on fail message given"
+ try:
+ step = self.stepCount
+ # stepResults format: ( stepNo, stepName, stepResult, onFail )
+ # NOTE: This is needed to catch results of main.step()'s
+ # called inside functions or loops
+ self.stepResults = ( [], [], [], [] )
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:
+
+ # Iterate through each of the steps and print them
+ for index in range( len( self.stepResults[0] ) ):
+ # stepResults = ( stepNo, stepName, stepResult, onFail )
+ stepNo = self.stepResults[0][ index ]
+ stepName = self.stepResults[1][ index ]
+ stepResult = self.stepResults[2][ index ]
+ onFail = self.stepResults[3][ index ]
+ self.stepCache += "\t" + str( testCaseNumber ) + "."
+ self.stepCache += str( stepNo ) + " "
+ self.stepCache += stepName + " - "
+ if stepResult == self.TRUE:
self.stepCache += "PASS\n"
- elif self.STEPRESULT == self.FALSE:
+ elif stepResult == self.FALSE:
self.stepCache += "FAIL\n"
- # TODO: Print the on-fail statement here
- self.stepCache += "\t\t" + self.onFailMsg + "\n"
+ self.stepCache += "\t\t" + onFail + "\n"
else:
self.stepCache += "No Result\n"
- self.stepResults.append(self.STEPRESULT)
+ self.stepResultsList.append( stepResult )
except StopIteration: # Raised in self.skipCase()
self.log.warn( "Skipping the rest of CASE" +
str( testCaseNumber ) )
- self.stepResults.append(self.STEPRESULT)
+ self.stepResultsList.append( self.STEPRESULT )
self.stepCache += "\t\t" + self.onFailMsg + "\n"
self.stepCount = self.stepCount + 1
return self.FALSE
- except StandardError:
- self.log.exception( "\nException in the following section of" +
- " code: " + str( testCaseNumber ) + "." +
- str( step ) + ": " + self.stepName )
- #print code[testCaseNumber][step]
+ except StandardError as e:
+ try:
+ stepNo = self.stepResults[0][ self.stepNumber - 1 ]
+ except IndexError:
+ stepNo = "<IndexError>"
+ main.log.warn( "Error trying to get step number. " +
+ "It is likely between step " +
+ str( self.stepNumber ) + " and step" +
+ str( self.stepNumber + 1 ) )
+ try:
+ stepName = self.stepResults[1][ self.stepNumber - 1 ]
+ except IndexError:
+ stepName = "<IndexError>"
+ self.log.error( "\nException in the following section of" +
+ " code: " + str( testCaseNumber ) + "." +
+ str( stepNo ) + ": " + stepName )
+ self.log.error( e )
self.stepCount = self.stepCount + 1
- self.logger.updateCaseResults(self)
- #WIKI results
+ self.logger.updateCaseResults( self )
+ # WIKI results
self.log.wiki( "<ul>" )
for line in self.stepCache.splitlines():
if re.search( " - PASS$", line ):
@@ -324,7 +384,7 @@
else: # Should only be on fail message
self.log.wiki( "<ul><li>" + line + "</li></ul>\n" )
self.log.wiki( "</ul>" )
- #summary results
+ # summary results
self.log.summary( self.stepCache )
self.stepCache = ""
self.cleanup()
@@ -332,10 +392,9 @@
return self.TRUE
if cli.stop:
cli.stop = False
- stopped = True
self.TOTAL_TC_NORESULT = self.TOTAL_TC_NORESULT + 1
- self.testCaseResult[str(self.CurrentTestCaseNumber)] = "Stopped"
- self.logger.updateCaseResults(self)
+ self.testCaseResult[str( self.CurrentTestCaseNumber )] = "Stopped"
+ self.logger.updateCaseResults( self )
result = self.cleanup()
return self.FALSE
@@ -360,24 +419,30 @@
self.onFailMsg += str( msg )
raise StopIteration
- 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)+" : "
+ 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 ) + " : "
for driver in self.componentDictionary.keys():
- vars(self)[driver+'log'].info(caseHeader)
+ 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"
+ def addCaseFooter( self ):
+ stepNo = self.stepResults[0][-2]
+ if stepNo > 0:
+ previousStep = " " + str( self.CurrentTestCaseNumber ) + "." +\
+ str( stepNo ) + ": " + 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"
+ 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)
+ vars( self )[driver].write( stepHeader + "\n" + caseFooter )
- def cleanup(self):
+ def cleanup( self ):
'''
Print a summary of the current test's results then attempt to release
all the component handles and the close opened file handles.
@@ -395,12 +460,12 @@
if self.cleanupFlag is False: # First thread to run this
self.cleanupFlag = True
if self.initiated:
- self.logger.testSummary(self)
+ self.logger.testSummary( self )
for component in self.componentDictionary.keys():
- try :
- tempObject = vars(self)[component]
- print "Disconnecting from " + str(tempObject.name) + ": " + \
- str(tempObject)
+ try:
+ tempObject = vars( self )[component]
+ print "Disconnecting from " + str( tempObject.name ) +\
+ ": " + str( tempObject.__class__)
tempObject.disconnect()
except KeyboardInterrupt:
pass
@@ -415,7 +480,7 @@
# Closing all the driver's session files
for driver in self.componentDictionary.keys():
try:
- vars(self)[driver].close_log_handles()
+ vars( self )[driver].close_log_handles()
except KeyboardInterrupt:
pass
except KeyError:
@@ -440,210 +505,226 @@
lock.release()
return result
- def pause(self):
+ def pause( self ):
'''
- This function will pause the test's execution, and will continue after user provide 'resume' command.
+ This function will pause the test's execution, and will continue after
+ user provide 'resume' command.
'''
__builtin__.testthread.pause()
- def onfail(self,*components):
+ def onfail( self, *components ):
'''
When test step failed, calling all the components onfail.
'''
if not components:
- try :
+ try:
for component in self.componentDictionary.keys():
- tempObject = vars(self)[component]
+ tempObject = vars( self )[component]
result = tempObject.onfail()
except StandardError as e:
- print str(e)
+ print str( e )
result = self.FALSE
else:
- try :
+ try:
for component in components:
- tempObject = vars(self)[component]
+ tempObject = vars( self )[component]
result = tempObject.onfail()
except StandardError as e:
- print str(e)
+ print str( e )
result = self.FALSE
- def getDriverPath(self,driverName):
+ def getDriverPath( self, driverName ):
'''
- Based on the component 'type' specified in the params , this method will find the absolute path ,
- by recursively searching the name of the component.
+ Based on the component 'type' specified in the params , this method
+ will find the absolute path, by recursively searching the name of
+ the component.
+
+ NOTE: This function requires the linux 'find' command.
'''
import commands
- cmd = "find "+drivers_path+" -name "+driverName+".py"
- result = commands.getoutput(cmd)
+ cmd = "find " + drivers_path + " -name " + driverName + ".py"
+ result = commands.getoutput( cmd )
- result_array = str(result).split('\n')
+ 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)
+ result_count = result_count + 1
+ if result_count > 1:
+ print "Found " + driverName + " " + str( result_count ) + " times:"
+ print str( result_array )
self.exit()
- result = re.sub("(.*)drivers","",result)
- result = re.sub("\/\/","/",result)
- result = re.sub("\.py","",result)
- result = re.sub("\.pyc","",result)
- result = re.sub("\/",".",result)
- result = "drivers"+result
+ result = re.sub( "(.*)drivers", "", result )
+ result = re.sub( "\/\/", "/", result )
+ result = re.sub( "\.py", "", result )
+ result = re.sub( "\.pyc", "", result )
+ result = re.sub( "\/", ".", result )
+ result = "drivers" + result
return result
- def step(self,stepDesc):
+ def step( self, stepDesc ):
'''
The step information of the test-case will append to the logs.
'''
- previousStep = " "+str(self.CurrentTestCaseNumber)+"."+str(self.stepCount-1)+": "+ str(self.stepName) + ""
+ previousStep = " " + str( self.CurrentTestCaseNumber ) + "." +\
+ str( self.stepNumber ) + ": " + str( self.stepName )
self.stepName = stepDesc
+ self.stepNumber += 1
+ self.stepResults[0].append( self.stepNumber )
+ self.stepResults[1].append( stepDesc )
+ self.stepResults[2].append( self.NORESULT )
+ self.stepResults[3].append( "No on fail message given" )
- stepName = " "+str(self.CurrentTestCaseNumber)+"."+str(self.stepCount)+": "+ str(stepDesc) + ""
- try :
- if self.stepCount == 0:
- stepName = " INIT : Initializing the test case :"+self.CurrentTestCase
- except AttributeError:
- stepName = " INIT : Initializing the test case :"+str(self.CurrentTestCaseNumber)
-
+ stepName = " " + str( self.CurrentTestCaseNumber ) + "." +\
+ str( self.stepNumber ) + ": " + str( stepDesc )
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"
+ line = "\n" + "-" * 45 + "\n"
+ if self.stepNumber > 1:
+ stepHeader = line + "End of Step " + previousStep + line
+ stepHeader += line + "Start of Step" + stepName + line
for driver in self.componentDictionary.keys():
- vars(self)[driver+'log'].info(stepHeader)
+ vars( self )[driver + 'log'].info( stepHeader )
- def case(self,testCaseName):
+ def case( self, testCaseName ):
'''
Test's each test-case information will append to the logs.
'''
self.CurrentTestCase = testCaseName
- testCaseName = " " + str(testCaseName) + ""
- self.log.case(testCaseName)
- caseHeader = testCaseName+"\n"+"*" * 40+"\n"
+ testCaseName = " " + str( testCaseName )
+ self.log.case( testCaseName )
+ caseHeader = testCaseName + "\n" + "*" * 40 + "\n"
for driver in self.componentDictionary.keys():
- vars(self)[driver+'log'].info(caseHeader)
+ vars( self )[driver + 'log'].info( caseHeader )
- def testDesc(self,description):
+ def testDesc( self, description ):
'''
Test description will append to the logs.
'''
- description = "Test Description : " + str (description) + ""
- self.log.info(description)
+ description = "Test Description : " + str( description )
+ self.log.info( description )
- def _getTest(self):
+ def _getTest( self ):
'''
- This method will parse the test script to find required test information.
+ This method will parse the test script to find required test
+ information.
'''
- testFile = self.tests_path + "/"+self.TEST + "/"+self.TEST + ".py"
- testFileHandler = open(testFile, 'r')
+ testFile = self.tests_path + "/" + self.TEST + "/" + self.TEST + ".py"
+ testFileHandler = open( testFile, 'r' )
testFileList = testFileHandler.readlines()
testFileHandler.close()
- #self.TOTAL_TC_PLANNED = 0
counter = 0
- for index in range(len(testFileList)):
- lineMatch = re.match('\s+def CASE(\d+)(.*):',testFileList[index],0)
+ for index in range( len( testFileList ) ):
+ lineMatch = re.match( '\s+def CASE(\d+)(.*):',
+ testFileList[index],
+ 0 )
if lineMatch:
- counter = counter + 1
- self.TC_PLANNED = len(self.testcases_list)
+ counter = counter + 1
+ self.TC_PLANNED = len( self.testcases_list )
- def response_parser(self,response, return_format):
+ 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)
+ response_dict = self.response_to_dict( response, return_format )
+ 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):
+ 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 :
- self.log.info(" Response is in 'JSON' format and Converting to '"+return_format+"' format")
+ json_match = re.search( '^\s*{', response )
+ xml_match = re.search( '^\s*\<', response )
+ ini_match = re.search( '^\s*\[', response )
+ if json_match:
+ self.log.info( "Response is in 'JSON' format, 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 :
+ 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)
+ response_dict = json.loads( response )
except StandardError:
self.log.exception( "Json Parser is unable to parse the string" )
return response_dict
- elif ini_match :
- self.log.info(" Response is in 'INI' format and Converting to '"+return_format+"' format")
+ elif ini_match:
+ self.log.info( "Response is in 'INI' format, converting to '" +
+ return_format + "' format" )
from configobj import ConfigObj
- response_file = open("respnse_file.temp",'w')
- response_file.write(response)
+ response_file = open( "respnse_file.temp", 'w' )
+ response_file.write( response )
response_file.close()
- response_dict = ConfigObj("respnse_file.temp")
+ response_dict = ConfigObj( "respnse_file.temp" )
return response_dict
- elif xml_match :
- self.log.info(" Response is in 'XML' format and Converting to '"+return_format+"' format")
- try :
- response_dict = xmldict.xml_to_dict("<response> "+str(response)+" </response>")
+ elif xml_match:
+ self.log.info( "Response is in 'XML' format, converting to '" +
+ return_format + "' format" )
+ try:
+ response_dict = xmldict.xml_to_dict( "<response> " +
+ str( response ) +
+ " </response>" )
except StandardError:
self.log.exception()
return response_dict
- def dict_to_return_format(self,response,return_format,response_dict):
- if return_format =='table' :
+ 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"
+ 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'''
+ def get_table( value_to_convert ):
+ ''' This will parse the dictionary recusrsively and print as
+ table format'''
table_data = ""
- if type(value_to_convert) == dict :
- table_data = table_data +'\t'.join(value_to_convert)+"\n"
- for temp_val in value_to_convert.values() :
- table_data = table_data + get_table(temp_val)
- else :
- table_data = table_data + str(value_to_convert) +"\t"
+ if isinstance( value_to_convert, dict ):
+ table_data = table_data + '\t'.join( value_to_convert ) +\
+ "\n"
+ for temp_val in value_to_convert.values():
+ table_data = table_data + get_table( temp_val )
+ else:
+ table_data = table_data + str( value_to_convert ) + "\t"
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())
+ for value in response_dict.values():
+ response_table = response_table + get_table( value )
return response_table
- elif return_format =='config':
+ elif return_format == 'config':
''' Will return in config format'''
to_do = 'Call dict to config coverter'
- response_string = str(response_dict)
+ response_string = str( response_dict )
print response_string
- response_config = re.sub(",", "\n\t", response_string)
- response_config = re.sub("u\'", "\'", response_config)
- response_config = re.sub("{", "", response_config)
- response_config = re.sub("}", "\n", response_config)
- response_config = re.sub(":", " =", response_config)
- return "[response]\n\t "+response_config
+ response_config = re.sub( ",", "\n\t", response_string )
+ response_config = re.sub( "u\'", "\'", response_config )
+ response_config = re.sub( "{", "", response_config )
+ 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'''
- response_xml = xmldict.dict_to_xml(response_dict)
- response_xml = re.sub(">\s*<", ">\n<", response_xml)
- return "\n"+response_xml
+ 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)
+ response_json = json.dumps( response_dict )
return response_json
- def get_random(self):
+ def get_random( self ):
self.random_order = self.random_order + 1
return self.random_order
- def exit(self):
+ def exit( self ):
__builtin__.testthread = None
for thread in threading.enumerate():
if thread.isAlive():
@@ -653,248 +734,302 @@
# NOTE: We should catch any exceptions while trying to
# close the thread so that we can try to close the other
# threads as well
- print( str( thread.getName() ) + ' could not be terminated' )
+ print str( thread.getName() ) +\
+ ' could not be terminated'
sys.exit()
-def verifyOptions(options):
- '''
- This will verify the command line options and set to default values, if any option not given in command line.
- '''
- import pprint
- pp = pprint.PrettyPrinter(indent=4)
+ def stop( self, email=False ):
+ """
+ Stop the test until Ctrl-D is entered.
+ Ctrl-C will kill the test
+ """
+ try:
+ if email:
+ # FIXME: implement this
+ raise NotImplementedError
+ self.log.error( "Test execution suspended. Press Ctrl-D to "
+ "resume or Ctrl-C to exit the test" )
+ # NOTE: Ctrl-D needs to be entered on a new line
+ while True:
+ # TODO: we could give the user an interactive prompt where
+ # they could call functions
+ raw_input()
+ except EOFError:
+ return
+ # Pass all other exceptions up to caller
- # pp.pprint(options)
- verifyTest(options)
- verifyExample(options)
- verifyTestScript(options)
+
+def verifyOptions( options ):
+ '''
+ This will verify the command line options and set to default values,
+ if any option not given in command line.
+ '''
+ verifyTest( options )
+ verifyExample( options )
+ verifyTestScript( options )
verifyParams()
- verifyLogdir(options)
- verifyMail(options)
- verifyTestCases(options)
- verifyOnosCell(options)
+ verifyLogdir( options )
+ verifyMail( options )
+ verifyTestCases( options )
+ verifyOnosCell( options )
-def verifyTest(options):
+def verifyTest( options ):
try:
if options.testname:
main.TEST = options.testname
- main.classPath = "tests."+main.TEST+"."+main.TEST
+ main.classPath = "tests." + main.TEST + "." + main.TEST
main.tests_path = tests_path
elif options.example:
main.TEST = options.example
- main.tests_path = path+"/examples/"
- main.classPath = "examples."+main.TEST+"."+main.TEST
+ main.tests_path = path + "/examples/"
+ main.classPath = "examples." + main.TEST + "." + main.TEST
except AttributeError:
print "Test or Example not specified please specify the --test <test name > or --example <example name>"
main.exit()
-def verifyExample(options):
+def verifyExample( options ):
if options.example:
- main.testDir = path+'/examples/'
- main.tests_path = path+"/examples/"
- main.classPath = "examples."+main.TEST+"."+main.TEST
+ main.testDir = path + '/examples/'
+ main.tests_path = path + "/examples/"
+ main.classPath = "examples." + main.TEST + "." + main.TEST
-def verifyLogdir(options):
+def verifyLogdir( options ):
# Verifying Log directory option
if options.logdir:
main.logdir = options.logdir
- else :
+ else:
main.logdir = main.FALSE
-def verifyMail(options):
+def verifyMail( options ):
# Checking the mailing list
if options.mail:
main.mail = options.mail
- elif main.params.has_key('mail'):
- main.mail = main.params['mail']
- else :
- main.mail = 'paxweb@paxterrasolutions.com'
+ else:
+ main.mail = main.params.get( 'mail', 'paxweb@paxterrasolutions.com' )
-def verifyTestCases(options):
+def verifyTestCases( options ):
# Getting Test cases list
if options.testcases:
testcases_list = options.testcases
# sys.exit()
- testcases_list = re.sub("(\[|\])", "", options.testcases)
- main.testcases_list = eval(testcases_list+",")
- else :
+ testcases_list = re.sub( "(\[|\])", "", options.testcases )
+ main.testcases_list = eval( testcases_list + "," )
+ else:
if 'testcases' in main.params.keys():
- temp = eval(main.params['testcases']+",")
- list1=[]
- if type(temp[0])==list:
+ temp = eval( main.params['testcases'] + "," )
+ list1 = []
+ if isinstance( temp[0], list ):
for test in temp:
for testcase in test:
- if type(testcase)==int:
- testcase=[testcase]
- list1.extend(testcase)
- else :
- temp=list(temp)
+ if isinstance( 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"
+ if isinstance( 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()
-def verifyOnosCell(options):
+def verifyOnosCell( options ):
# Verifying onoscell option
if options.onoscell:
main.onoscell = options.onoscell
main.onosIPs = []
main.mnIP = ""
- cellCMD = ". ~/.profile; cell "+main.onoscell
- output=subprocess.check_output( ["bash", '-c', cellCMD] )
+ cellCMD = ". ~/.profile; cell " + main.onoscell
+ output = subprocess.check_output( ["bash", '-c', cellCMD] )
splitOutput = output.splitlines()
- for i in range( len(splitOutput) ):
- if( re.match( "OCN", splitOutput[i] ) ):
- mnNode=splitOutput[i].split("=")
+ for i in range( len( splitOutput ) ):
+ if re.match( "OCN", splitOutput[i] ):
+ mnNode = splitOutput[i].split( "=" )
main.mnIP = mnNode[1]
- # cell already sorts OC variables in bash, so no need to sort in TestON
- if( re.match( "OC[1-9]", splitOutput[i] ) ):
- onosNodes = splitOutput[i].split("=")
+ # cell already sorts OC variables in bash, so no need to
+ # sort in TestON
+ if re.match( "OC[1-9]", splitOutput[i] ):
+ onosNodes = splitOutput[i].split( "=" )
main.onosIPs.append( onosNodes[1] )
- else :
+ else:
main.onoscell = main.FALSE
-def verifyTestScript(options):
+def verifyTestScript( options ):
'''
Verifyies test script.
'''
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):
+ openspeakfile = main.testDir + "/" + main.TEST + "/" + main.TEST + ".ospk"
+ testfile = main.testDir + "/" + main.TEST + "/" + main.TEST + ".py"
+ if os.path.exists( openspeakfile ):
# Openspeak file found, compiling to python
- main.openspeak.compiler(openspeakfile=openspeakfile,writetofile=1)
- elif os.path.exists(testfile):
+ main.openspeak.compiler( openspeakfile=openspeakfile, writetofile=1 )
+ elif os.path.exists( testfile ):
# No openspeak found, using python file instead
pass
else:
- print "\nThere is no \""+main.TEST+"\" test script.\nPlease provide a " +\
+ print "\nThere is no \"" + main.TEST + "\" test script.\nPlease provide a " +\
"Python or OpenSpeak test script in the tests folder: " +\
- main.testDir+"/" + main.TEST + "/"
+ main.testDir + "/" + main.TEST + "/"
__builtin__.testthread = None
main.exit()
- try :
- testModule = __import__(main.classPath, globals(), locals(), [main.TEST], -1)
+ 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 named "+main.TEST
+ print "There was an import error, it might mean that there is " +\
+ "no test named " + main.TEST
main.exit()
- testClass = getattr(testModule, main.TEST)
+ 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 :
+ 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"
+ print "Error with the params file: Either the file not specified " +\
+ "or the format is not correct"
main.exit()
- try :
+ 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"
+ print "Error with the Topology file: Either the file not specified " +\
+ "or the format is not correct"
main.exit()
-def load_parser() :
+def load_parser():
'''
It facilitates the loading customised parser for topology and params file.
It loads parser mentioned in tab named parser of teston.cfg file.
- It also loads default xmlparser if no parser have specified in teston.cfg file.
+ It also loads default xmlparser if no parser have specified in teston.cfg
+ file.
'''
confighash = main.configDict
- if 'file' in confighash['config']['parser'] and 'class' in confighash['config']['parser']:
+ if 'file' in confighash['config']['parser'] and\
+ 'class' in confighash['config']['parser']:
path = confighash['config']['parser']['file']
- if path != None or confighash['config']['parser']['class']!= None:
+ if path is not None or\
+ confighash['config']['parser']['class'] is not None:
try:
module = re.sub( r".py\s*$", "", path )
moduleList = module.split("/")
- newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
+ newModule = ".".join( moduleList[-2:] )
parsingClass = confighash['config']['parser']['class']
- parsingModule = __import__(newModule, globals(), locals(), [parsingClass], -1)
- parsingClass = getattr(parsingModule, parsingClass)
+ parsingModule = __import__( newModule,
+ globals(),
+ locals(),
+ [parsingClass],
+ -1 )
+ parsingClass = getattr( parsingModule, parsingClass )
main.parser = parsingClass()
- #hashobj = main.parser.parseParams(main.classPath)
- if hasattr(main.parser,"parseParams") and hasattr(main.parser,"parseTopology") and hasattr(main.parser,"parse"):
+ if hasattr( main.parser, "parseParams" ) and\
+ hasattr( main.parser, "parseTopology" ) and\
+ hasattr( main.parser, "parse" ):
pass
else:
print "Invalid parser format"
main.exit()
except ImportError:
- print "Could not find the file " + path + " using default parser."
+ print "Could not find the file " + path +\
+ " using default parser."
load_defaultParser()
- elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None:
+ elif confighash['config']['parser']['file'] is None or\
+ confighash['config']['parser']['class'] is None:
load_defaultParser()
else:
load_defaultParser()
def load_defaultParser():
'''
- It will load the default parser which is xml parser to parse the params and topology file.
+ It will load the default parser which is xml parser to parse the params and
+ topology file.
'''
moduleList = main.parserPath.split("/")
- newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
- try :
+ newModule = ".".join( moduleList[-2:] )
+ try:
parsingClass = main.parsingClass
- parsingModule = __import__(newModule, globals(), locals(), [parsingClass], -1)
- parsingClass = getattr(parsingModule, parsingClass)
+ parsingModule = __import__( newModule,
+ globals(),
+ locals(),
+ [parsingClass],
+ -1 )
+ parsingClass = getattr( parsingModule, parsingClass )
main.parser = parsingClass()
- if hasattr(main.parser,"parseParams") and hasattr(main.parser,"parseTopology") and hasattr(main.parser,"parse") :
+ 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]
-def load_logger() :
+def load_logger():
'''
It facilitates the loading customised parser for topology and params file.
It loads parser mentioned in tab named parser of teston.cfg file.
- It also loads default xmlparser if no parser have specified in teston.cfg file.
-
+ It also loads default xmlparser if no parser have specified in teston.cfg
+ file.
'''
confighash = main.configDict
- if 'file' in confighash['config']['logger'] and 'class' in confighash['config']['logger']:
+ if 'file' in confighash['config']['logger'] and\
+ 'class' in confighash['config']['logger']:
path = confighash['config']['logger']['file']
- if path != None or confighash['config']['logger']['class']!= None :
+ if path is not None or\
+ confighash['config']['logger']['class'] is not None:
try:
module = re.sub( r".py\s*$", "", path )
- moduleList = module.split("/")
- newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
+ moduleList = module.split( "/" )
+ newModule = ".".join( moduleList[-2:] )
loggerClass = confighash['config']['logger']['class']
- loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1)
- loggerClass = getattr(loggerModule, loggerClass)
+ loggerModule = __import__( newModule,
+ globals(),
+ locals(),
+ [loggerClass],
+ -1 )
+ loggerClass = getattr( loggerModule, loggerClass )
main.logger = loggerClass()
- #hashobj = main.parser.parseParams(main.classPath)
except ImportError:
- print "Could not find the file " + path + " using default logger."
+ print "Could not find the file " + path +\
+ " using default logger."
load_defaultlogger()
- elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :
+ elif confighash['config']['parser']['file'] is None or\
+ confighash['config']['parser']['class'] is None:
load_defaultlogger()
else:
load_defaultlogger()
def load_defaultlogger():
'''
- It will load the default parser which is xml parser to parse the params and topology file.
+ 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 :
+ newModule = ".".join( moduleList[-2:] )
+ try:
loggerClass = main.loggerClass
- loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1)
- loggerClass = getattr(loggerModule, 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):
+def _echo( self ):
print "THIS IS ECHO"
diff --git a/TestON/core/utilities.py b/TestON/core/utilities.py
index 8cd81e5..d5a5c0f 100644
--- a/TestON/core/utilities.py
+++ b/TestON/core/utilities.py
@@ -185,6 +185,14 @@
print e
main.last_result = result
+ if main.stepResults[2]:
+ main.stepResults[2][-1] = result
+ try:
+ main.stepResults[3][-1] = arguments[ 'ONFAIL' ]
+ except AttributeError:
+ pass
+ else:
+ main.log.warn( "Assertion called before a test step" )
return result
def parse_args(self,args, **kwargs):
diff --git a/TestON/drivers/common/api/controller/onosrestdriver.py b/TestON/drivers/common/api/controller/onosrestdriver.py
index 66cd8b4..3ff43c7 100644
--- a/TestON/drivers/common/api/controller/onosrestdriver.py
+++ b/TestON/drivers/common/api/controller/onosrestdriver.py
@@ -20,6 +20,7 @@
import os
import requests
import types
+import sys
from drivers.common.api.controllerdriver import Controller
@@ -32,6 +33,7 @@
super( Controller, self ).__init__()
self.ip_address = "localhost"
self.port = "8080"
+ self.wrapped = sys.modules[ __name__ ]
def connect( self, **connectargs ):
try:
@@ -55,6 +57,24 @@
self.handle = super( OnosRestDriver, self ).connect()
return self.handle
+ def pprint( self, jsonObject ):
+ """
+ Pretty Prints a json object
+
+ arguments:
+ jsonObject - a parsed json object
+ returns:
+ A formatted string for printing or None on error
+ """
+ try:
+ if isinstance( jsonObject, str ):
+ jsonObject = json.loads( jsonObject )
+ return json.dumps( jsonObject, sort_keys=True,
+ indent=4, separators=(',', ': '))
+ except ( TypeError, ValueError ):
+ main.log.exception( "Error parsing jsonObject" )
+ return None
+
def send( self, ip, port, url, base="/onos/v1", method="GET",
query=None, data=None, debug=False ):
"""
@@ -93,10 +113,10 @@
except requests.exceptions:
main.log.exception( "Error sending request." )
return None
- except Exception as e:
- main.log.exception( e )
- return None
- # FIXME: add other exceptions
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def intents( self, ip="DEFAULT", port="DEFAULT" ):
"""
@@ -121,15 +141,20 @@
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
a = json.loads( output ).get( 'intents' )
+ assert a is not None, "Error parsing json object"
b = json.dumps( a )
return b
else:
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, AssertionError, 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()
def intent( self, intentId, appId="org.onosproject.cli",
ip="DEFAULT", port="DEFAULT" ):
@@ -169,9 +194,13 @@
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def getIntentsId( self, ip="DEFAULT", port="DEFAULT" ):
"""
@@ -187,18 +216,19 @@
intentsDict = json.loads( self.intents( ip=ip, port=port ) )
for intent in intentsDict:
intentsIdList.append( intent.get( 'id' ) )
-
if not intentsIdList:
main.log.debug( "Cannot find any intents" )
return main.FALSE
else:
main.log.info( "Found intents: " + str( intentsIdList ) )
return main.TRUE
-
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def apps( self, ip="DEFAULT", port="DEFAULT" ):
"""
@@ -222,15 +252,20 @@
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
a = json.loads( output ).get( 'applications' )
+ assert a is not None, "Error parsing json object"
b = json.dumps( a )
return b
else:
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, AssertionError, 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()
def activateApp( self, appName, ip="DEFAULT", port="DEFAULT", check=True ):
"""
@@ -280,9 +315,13 @@
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def deactivateApp( self, appName, ip="DEFAULT", port="DEFAULT",
check=True ):
@@ -332,9 +371,13 @@
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def getApp( self, appName, project="org.onosproject.", ip="DEFAULT",
port="DEFAULT" ):
@@ -367,9 +410,13 @@
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def addHostIntent( self, hostIdOne, hostIdTwo, appId='org.onosproject.cli',
ip="DEFAULT", port="DEFAULT" ):
@@ -419,9 +466,13 @@
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def addPointIntent( self,
ingressDevice,
@@ -567,10 +618,13 @@
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def removeIntent( self, intentId, appId='org.onosproject.cli',
ip="DEFAULT", port="DEFAULT" ):
@@ -600,9 +654,13 @@
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def getIntentsId( self, ip="DEFAULT", port="DEFAULT" ):
"""
@@ -611,14 +669,16 @@
try:
intentIdList = []
intentsJson = json.loads( self.intents() )
- print intentsJson
for intent in intentsJson:
intentIdList.append( intent.get( 'id' ) )
- print intentIdList
return intentIdList
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def removeAllIntents( self, intentIdList ='ALL',appId='org.onosproject.cli',
ip="DEFAULT", port="DEFAULT", delay=5 ):
@@ -660,10 +720,13 @@
return main.FALSE
else:
main.log.debug( self.name + ": There is no intents ID list" )
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def hosts( self, ip="DEFAULT", port="DEFAULT" ):
"""
@@ -688,15 +751,20 @@
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
a = json.loads( output ).get( 'hosts' )
+ assert a is not None, "Error parsing json object"
b = json.dumps( a )
return b
else:
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, AssertionError, 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()
def getHost( self, mac, vlan="-1", ip="DEFAULT", port="DEFAULT" ):
"""
@@ -738,9 +806,13 @@
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def topology( self, ip="DEFAULT", port="DEFAULT" ):
"""
@@ -770,9 +842,51 @@
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
+
+ def devices( self, ip="DEFAULT", port="DEFAULT" ):
+ """
+ Description:
+ Get the devices discovered by ONOS is json string format
+ Returns:
+ a json string of the devices currently discovered by ONOS OR
+ main.FALSE if there is an error in the request OR
+ Returns None for exception
+ """
+ try:
+ output = None
+ if ip == "DEFAULT":
+ main.log.warn( "No ip given, reverting to ip from topo file" )
+ ip = self.ip_address
+ if port == "DEFAULT":
+ main.log.warn( "No port given, reverting to port " +
+ "from topo file" )
+ port = self.port
+ response = self.send( ip, port, url="/devices" )
+ if response:
+ if 200 <= response[ 0 ] <= 299:
+ output = response[ 1 ]
+ a = json.loads( output ).get( 'devices' )
+ assert a is not None, "Error parsing json object"
+ b = json.dumps( a )
+ return b
+ else:
+ main.log.error( "Error with REST request, response was: " +
+ str( response ) )
+ return main.FALSE
+ except ( AttributeError, AssertionError, 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()
def getIntentState( self, intentsId, intentsJson=None,
ip="DEFAULT", port="DEFAULT" ):
@@ -823,12 +937,13 @@
main.log.info( "Invalid intents ID entry" )
return None
- except TypeError:
- main.log.exception( self.name + ": Object Type not as expected" )
+ except ( AttributeError, TypeError ):
+ main.log.exception( self.name + ": Object not as expected" )
return None
- except Exception as e:
- main.log.exception( e )
- return None
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def checkIntentState( self, intentsId="ALL", expectedState='INSTALLED',
ip="DEFAULT", port="DEFAULT"):
@@ -889,12 +1004,13 @@
" intents are in " + str( expectedState ) +
" state" )
return returnValue
- except TypeError:
+ except ( AttributeError, TypeError ):
main.log.exception( self.name + ": Object not as expected" )
- return main.FALSE
- except Exception as e:
- main.log.exception( e )
return None
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def flows( self, ip="DEFAULT", port="DEFAULT" ):
"""
@@ -902,7 +1018,9 @@
Get flows currently added to the system
NOTE:
The flows -j cli command has completely different format than
- the REST output; Returns None for exception
+ the REST output
+
+ Returns None for exception
"""
try:
output = None
@@ -918,23 +1036,28 @@
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
a = json.loads( output ).get( 'flows' )
+ assert a is not None, "Error parsing json object"
b = json.dumps( a )
return b
else:
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, AssertionError, 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()
- def getFlows( self, device, flowId=0, ip="DEFAULT", port="DEFAULT" ):
+ def getFlows( self, deviceId, flowId=None, ip="DEFAULT", port="DEFAULT" ):
"""
Description:
Gets all the flows of the device or get a specific flow in the
device by giving its flow ID
Required:
- str device - device/switch Id
+ str deviceId - device/switch Id
Optional:
int/hex flowId - ID of the flow
"""
@@ -947,7 +1070,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- url = "/flows/" + device
+ url = "/flows/" + deviceId
if flowId:
url += "/" + str( int( flowId ) )
print url
@@ -956,16 +1079,20 @@
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
a = json.loads( output ).get( 'flows' )
+ assert a is not None, "Error parsing json object"
b = json.dumps( a )
return b
else:
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, AssertionError, 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()
def addFlow( self,
deviceId,
@@ -1009,17 +1136,14 @@
of the ONOS node
"""
try:
-
flowJson = { "priority":100,
"isPermanent":"true",
"timeout":0,
"deviceId":deviceId,
"treatment":{"instructions":[]},
"selector": {"criteria":[]}}
-
if appId:
flowJson[ "appId" ] = appId
-
if egressPort:
flowJson[ 'treatment' ][ 'instructions' ].append(
{ "type":"OUTPUT",
@@ -1064,11 +1188,10 @@
flowJson[ 'selector' ][ 'criteria' ].append(
{ "type":"IP_PROTO",
"protocol": ipProto } )
-
- # TODO: Bandwidth and Lambda will be implemented if needed
-
- main.log.debug( flowJson )
-
+ if bandwidth or lambdaAlloc:
+ # TODO: Bandwidth and Lambda will be implemented if needed
+ raise NotImplementedError
+ main.log.debug( "Adding flow: " + self.pprint( flowJson ) )
output = None
if ip == "DEFAULT":
main.log.warn( "No ip given, reverting to ip from topo file" )
@@ -1092,10 +1215,15 @@
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
-
- except Exception as e:
- main.log.exception( e )
+ except NotImplementedError as e:
+ raise e # Inform the caller
+ except ( AttributeError, 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()
def removeFlow( self, deviceId, flowId,
ip="DEFAULT", port="DEFAULT" ):
@@ -1131,9 +1259,13 @@
main.log.error( "Error with REST request, response was: " +
str( response ) )
return main.FALSE
- except Exception as e:
- main.log.exception( e )
+ except ( AttributeError, 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()
def checkFlowsState( self , ip="DEFAULT", port="DEFAULT" ):
"""
@@ -1155,11 +1287,8 @@
str( flow.get( 'state' ) ) )
returnValue = main.FALSE
return returnValue
- except TypeError:
+ except ( AttributeError, TypeError ):
main.log.exception( self.name + ": Object not as expected" )
- return main.FALSE
- except Exception as e:
- main.log.exception( e )
return None
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index d726f2e..fd05a41 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -405,7 +405,7 @@
main.log.info( self.name + ": \n---\n" + response )
return main.FALSE
- def pingallHosts( self, hostList ):
+ def pingallHosts( self, hostList, wait=1 ):
"""
Ping all specified IPv4 hosts
@@ -417,8 +417,8 @@
Returns main.FALSE if one or more of hosts specified
cannot reach each other"""
-
- cmd = " ping -c 1 -i 1 -W 8 "
+ wait = int( wait )
+ cmd = " ping -c 1 -i 1 -W " + str( wait ) + " "
try:
main.log.info( "Testing reachability between specified hosts" )
@@ -437,7 +437,7 @@
for temp in pingList:
# Current host pings all other hosts specified
pingCmd = str( host ) + cmd + str( temp )
- self.handle.sendline( pingCmd )
+ self.handle.sendline( pingCmd, timeout=wait + 1 )
self.handle.expect( "mininet>" )
response = self.handle.before
if re.search( ',\s0\%\spacket\sloss', response ):
@@ -463,19 +463,20 @@
main.cleanup()
main.exit()
- def pingIpv6Hosts(self, hostList, prefix='1000::'):
+ def pingIpv6Hosts( self, hostList, prefix='1000::', wait=1 ):
"""
- IPv6 ping all hosts in hostList. If no prefix passed this will use
- default prefix of 1000::
+ IPv6 ping all hosts in hostList. If no prefix passed this will use
+ default prefix of 1000::
- Returns main.TRUE if all hosts specified can reach each other
+ 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
+ Returns main.FALSE if one or more of hosts specified cannot reach each other
"""
try:
main.log.info( "Testing reachability between specified IPv6 hosts" )
isReachable = main.TRUE
- cmd = " ping6 -c 1 -i 1 -W 8 "
+ wait = int( wait )
+ cmd = " ping6 -c 1 -i 1 -W " + str( wait ) + " "
pingResponse = "IPv6 Pingall output:\n"
failedPings = 0
for host in hostList:
@@ -489,7 +490,7 @@
for temp in pingList:
# Current host pings all other hosts specified
pingCmd = str( host ) + cmd + prefix + str( temp[1:] )
- self.handle.sendline( pingCmd )
+ self.handle.sendline( pingCmd, timeout=wait + 1 )
self.handle.expect( "mininet>" )
response = self.handle.before
if re.search( ',\s0\%\spacket\sloss', response ):
@@ -518,15 +519,19 @@
def pingHost( self, **pingParams ):
"""
- Ping from one mininet host to another
- Currently the only supported Params: SRC and TARGET"""
- args = utilities.parse_args( [ "SRC", "TARGET" ], **pingParams )
+ Ping from one mininet host to another
+ Currently the only supported Params: SRC, TARGET, and WAIT
+ """
+ args = utilities.parse_args( [ "SRC", "TARGET", 'WAIT' ], **pingParams )
+ wait = args['WAIT']
+ wait = int( wait if wait else 1 )
command = args[ "SRC" ] + " ping " + \
- args[ "TARGET" ] + " -c 1 -i 1 -W 8"
+ args[ "TARGET" ] + " -c 1 -i 1 -W " + str( wait ) + " "
try:
main.log.info( "Sending: " + command )
self.handle.sendline( command )
- i = self.handle.expect( [ command, pexpect.TIMEOUT ] )
+ i = self.handle.expect( [ command, pexpect.TIMEOUT ],
+ timeout=wait + 1 )
if i == 1:
main.log.error(
self.name +
@@ -561,17 +566,20 @@
def ping6pair( self, **pingParams ):
"""
IPv6 Ping between a pair of mininet hosts
- Currently the only supported Params are: SRC , TARGET
+ Currently the only supported Params are: SRC, TARGET, and WAIT
FLOWLABEL and -I (src interface) will be added later after running some tests.
Example: main.Mininet1.ping6pair( src="h1", target="1000::2" )
"""
- args = utilities.parse_args( [ "SRC", "TARGET" ], **pingParams )
- command = args[ "SRC" ] + " ping6 " + \
- args[ "TARGET" ] + " -c 1 -i 1 -W 8"
+ args = utilities.parse_args( [ "SRC", "TARGET", 'WAIT' ], **pingParams )
+ wait = args['WAIT']
+ wait = int( wait if wait else 1 )
+ command = args[ "SRC" ] + " ping " + \
+ args[ "TARGET" ] + " -c 1 -i 1 -W " + str( wait ) + " "
try:
main.log.info( "Sending: " + command )
self.handle.sendline( command )
- i = self.handle.expect( [ command, pexpect.TIMEOUT ] )
+ i = self.handle.expect( [ command, pexpect.TIMEOUT ],
+ timeout=wait + 1 )
if i == 1:
main.log.error(
self.name +
@@ -1039,7 +1047,7 @@
main.log.info( self.name + ": List network links" )
try:
response = self.execute( cmd='links', prompt='mininet>',
- timeout=10 )
+ timeout=20 )
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1104,12 +1112,15 @@
else:
main.log.error( self.name + ": iperf test failed" )
return main.FALSE
-
except pexpect.TIMEOUT:
- main.log.error( self.name + ": TIMEOUT exception found")
- main.log.error( self.name + ": Exception: Cannot connect to iperf on port 5001" )
+ main.log.error( self.name + ": TIMEOUT exception found" )
+ main.log.error( self.name + " response: " +
+ repr ( self.handle.before ) )
+ # NOTE: Send ctrl-c to make sure iperf is done
+ self.handle.sendline( "\x03" )
+ self.handle.expect( "Interrupt" )
+ self.handle.expect( "mininet>" )
return main.FALSE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index c261872..2fae817 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -192,6 +192,7 @@
self.handle.sendline( "onos-package" )
self.handle.expect( "onos-package" )
self.handle.expect( "tar.gz", opTimeout )
+ self.handle.expect( "\$" )
handle = str( self.handle.before )
main.log.info( "onos-package command returned: " +
handle )
@@ -221,6 +222,7 @@
"BUILD FAILED" ],
timeout=120 )
handle = str( self.handle.before )
+ self.handle.expect( "\$" )
main.log.info( "onos-build command returned: " +
handle )
@@ -752,12 +754,11 @@
# 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(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.expect( "\$" )
handleMore = self.handle.before
cell_result = handleBefore + handleAfter + handleMore
@@ -768,7 +769,6 @@
main.cleanup()
main.exit()
return main.TRUE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -793,19 +793,11 @@
self.handle.expect( "\$" )
handleBefore = self.handle.before
handleAfter = self.handle.after
- # Get the rest of the handle
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
- handleMore = self.handle.before
-
main.log.info( "Verify cell returned: " + handleBefore +
- handleAfter + handleMore )
-
+ handleAfter )
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.exception( self.name + ": Pexpect exception found: " )
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
@@ -851,9 +843,7 @@
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.exception( self.name + ": Pexpect exception found: " )
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
@@ -904,23 +894,12 @@
self.handle.expect( "\$" )
handleBefore = self.handle.before
- print "handle_before = ", self.handle.before
- # handleAfter = str( self.handle.after )
-
- # self.handle.sendline( "" )
- # self.handle.expect( "\$" )
- # handleMore = str( self.handle.before )
-
main.log.info( "Command sent successfully" )
-
# Obtain return handle that consists of result from
# the onos command. The string may need to be
# configured further.
- # returnString = handleBefore + handleAfter
returnString = handleBefore
- print "return_string = ", returnString
return returnString
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -954,26 +933,28 @@
"onos\sstart/running,\sprocess",
"ONOS\sis\salready\sinstalled",
pexpect.TIMEOUT ], timeout=60 )
-
if i == 0:
main.log.warn( "Network is unreachable" )
+ self.handle.expect( "\$" )
return main.FALSE
elif i == 1:
main.log.info(
"ONOS was installed on " +
node +
" and started" )
+ self.handle.expect( "\$" )
return main.TRUE
elif i == 2:
main.log.info( "ONOS is already installed on " + node )
+ self.handle.expect( "\$" )
return main.TRUE
elif i == 3:
main.log.info(
"Installation of ONOS on " +
node +
" timed out" )
+ self.handle.expect( "\$" )
return main.FALSE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -999,7 +980,7 @@
"start/running",
"Unknown\sinstance",
pexpect.TIMEOUT ], timeout=120 )
-
+ self.handle.expect( "\$" )
if i == 0:
main.log.info( "Service is already running" )
return main.TRUE
@@ -1035,7 +1016,7 @@
"Could not resolve hostname",
"Unknown\sinstance",
pexpect.TIMEOUT ], timeout=60 )
-
+ self.handle.expect( "\$" )
if i == 0:
main.log.info( "ONOS service stopped" )
return main.TRUE
@@ -1049,7 +1030,6 @@
else:
main.log.error( "ONOS service failed to stop" )
return main.FALSE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1070,13 +1050,10 @@
self.handle.sendline( "" )
self.handle.expect( "\$", timeout=60 )
self.handle.sendline( "onos-uninstall " + str( nodeIp ) )
- self.handle.expect( "\$" )
-
+ self.handle.expect( "\$", timeout=60 )
main.log.info( "ONOS " + nodeIp + " was uninstalled" )
-
# 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
@@ -1186,10 +1163,7 @@
timeout=120 )
if i == 1:
return main.FALSE
- #self.handle.sendline( "" )
- #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 )
@@ -1237,7 +1211,7 @@
main.cleanup()
main.exit()
- def isup(self, node = "", timeout = 120):
+ 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)
@@ -1245,8 +1219,8 @@
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)
if i == 0:
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index 0202a15..7d6ef0b 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -145,12 +145,11 @@
"""
result = super( CLI, self ).execute( self )
defaultPrompt = '.*[$>\#]'
- args = utilities.parse_args( [
- "CMD",
- "TIMEOUT",
- "PROMPT",
- "MORE" ],
- **execparams )
+ args = utilities.parse_args( [ "CMD",
+ "TIMEOUT",
+ "PROMPT",
+ "MORE" ],
+ **execparams )
expectPrompt = args[ "PROMPT" ] if args[ "PROMPT" ] else defaultPrompt
self.LASTRSP = ""
@@ -164,20 +163,18 @@
args[ "MORE" ] = " "
self.handle.sendline( cmd )
self.lastCommand = cmd
- index = self.handle.expect( [
- expectPrompt,
- "--More--",
- 'Command not found.',
- pexpect.TIMEOUT,
- "^:$" ],
- timeout=timeoutVar )
+ index = self.handle.expect( [ expectPrompt,
+ "--More--",
+ 'Command not found.',
+ pexpect.TIMEOUT,
+ "^:$" ],
+ timeout=timeoutVar )
if index == 0:
self.LASTRSP = self.LASTRSP + \
self.handle.before + self.handle.after
- main.log.info(
- "Executed :" + str(
- cmd ) + " \t\t Expected Prompt '" + str(
- expectPrompt) + "' Found" )
+ main.log.info( "Executed :" + str(cmd ) +
+ " \t\t Expected Prompt '" + str( expectPrompt) +
+ "' Found" )
elif index == 1:
self.LASTRSP = self.LASTRSP + self.handle.before
self.handle.send( args[ "MORE" ] )
@@ -196,26 +193,25 @@
main.log.error( "Command not found" )
self.LASTRSP = self.LASTRSP + self.handle.before
elif index == 3:
- main.log.error( "Expected Prompt not found , Time Out!!" )
+ main.log.error( "Expected Prompt not found, Time Out!!" )
main.log.error( expectPrompt )
- return "Expected Prompt not found , Time Out!!"
-
+ self.LASTRSP = self.LASTRSP + self.handle.before
+ return self.LASTRSP
elif index == 4:
self.LASTRSP = self.LASTRSP + self.handle.before
# self.handle.send( args[ "MORE" ] )
self.handle.sendcontrol( "D" )
main.log.info(
- "Found More screen to go , Sending a key to proceed" )
+ "Found More screen to go, Sending a key to proceed" )
indexMore = self.handle.expect(
[ "^:$", expectPrompt ], timeout=timeoutVar )
while indexMore == 0:
main.log.info(
- "Found another More screen to go , Sending a key to proceed" )
+ "Found another More screen to go, Sending a key to proceed" )
self.handle.sendcontrol( "D" )
indexMore = self.handle.expect(
[ "^:$", expectPrompt ], timeout=timeoutVar )
self.LASTRSP = self.LASTRSP + self.handle.before
-
main.last_response = self.remove_contol_chars( self.LASTRSP )
return self.LASTRSP
@@ -297,7 +293,6 @@
pexpect.EOF,
pexpect.TIMEOUT ],
120 )
-
if i == 0: # ask for ssh key confirmation
main.log.info( "ssh key confirmation received, sending yes" )
self.handle.sendline( 'yes' )
@@ -327,10 +322,7 @@
"@" +
ipAddress )
returnVal = main.FALSE
-
- self.handle.sendline( "" )
- self.handle.expect( "$" )
-
+ self.handle.expect( "\$" )
return returnVal
def scp( self, remoteHost, filePath, dstPath, direction="from" ):
diff --git a/TestON/tests/CHOtest/CHOtest.params b/TestON/tests/CHOtest/CHOtest.params
index d4199ad..965e297 100644
--- a/TestON/tests/CHOtest/CHOtest.params
+++ b/TestON/tests/CHOtest/CHOtest.params
@@ -18,7 +18,7 @@
# 19X. IPv6 ping across Point,Multi-single,Single-Multi Intents
<testcases>
-1,20,3,[40,5,140,60,160,70,170,80,180,10,5,90,190,71,171,81,181,10,5]*50,21,3,[41,5,141,61,161,72,172,82,182,10,5,91,191,73,173,83,183,10,5]*50,22,3,[42,5,142,62,162,74,174,84,184,10,5,92,192,75,175,85,185,10,5]*50
+1,20,3,[40,5,140,60,160,70,170,80,180,10,5,90,190,71,171,81,181,10,5]*10,21,3,[41,5,141,61,161,72,172,82,182,10,5,91,191,73,173,83,183,10,5]*10,22,3,[42,5,142,62,162,74,174,84,184,10,5,92,192,75,175,85,185,10,5]*10
</testcases>
<GIT>
@@ -90,7 +90,13 @@
<LinkDiscovery>15</LinkDiscovery>
<SwitchDiscovery>10</SwitchDiscovery>
<IntentPurgeDelay>15</IntentPurgeDelay>
- <CheckIntentDelay>40</CheckIntentDelay>
+ <CheckIntentDelay>8</CheckIntentDelay>
</timers>
+ <TEST>
+ <pause_test>on</pause_test>
+ <email>off</email>
+ <intent_check>8</intent_check>
+ </TEST>
+
</PARAMS>
diff --git a/TestON/tests/CHOtest/CHOtest.py b/TestON/tests/CHOtest/CHOtest.py
index fbe51cd..fdee4be 100644
--- a/TestON/tests/CHOtest/CHOtest.py
+++ b/TestON/tests/CHOtest/CHOtest.py
@@ -33,9 +33,15 @@
git_branch = main.params[ 'GIT' ][ 'branch' ]
karafTimeout = main.params['CTRL']['karafCliTimeout']
main.checkIntentsDelay = int( main.params['timers']['CheckIntentDelay'] )
+ main.failSwitch = main.params['TEST']['pause_test']
+ main.emailOnStop = main.params['TEST']['email']
+ main.intentCheck = int( main.params['TEST']['intent_check'] )
main.newTopo = ""
main.CLIs = []
+ main.failSwitch = True if main.failSwitch == "on" else False
+ main.emailOnStop = True if main.emailOnStop == "on" else False
+
for i in range( 1, int(main.numCtrls) + 1 ):
main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
@@ -283,11 +289,11 @@
# giving some breathing time for ONOS to complete re-balance
time.sleep( 5 )
- case21Result = switch_mastership
+ caseResult = switch_mastership
time.sleep(30)
utilities.assert_equals(
expect=main.TRUE,
- actual=case21Result,
+ actual=caseResult,
onpass="Starting new Chordal topology test PASS",
onfail="Starting new Chordal topology test FAIL" )
@@ -350,11 +356,11 @@
# giving some breathing time for ONOS to complete re-balance
time.sleep( 3 )
- case22Result = switch_mastership
+ caseResult = switch_mastership
time.sleep(60)
utilities.assert_equals(
expect=main.TRUE,
- actual=case22Result,
+ actual=caseResult,
onpass="Starting new Spine topology test PASS",
onfail="Starting new Spine topology test FAIL" )
@@ -526,8 +532,8 @@
else:
main.log.report( "IPv4 Pingall Test in Reactive mode failed" )
- case40Result = appCheck and pingResult
- utilities.assert_equals( expect=main.TRUE, actual=case40Result,
+ caseResult = appCheck and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Reactive Mode IPv4 Pingall test PASS",
onfail="Reactive Mode IPv4 Pingall test FAIL" )
@@ -585,8 +591,8 @@
else:
main.log.report( "IPv4 Pingall Test in Reactive mode failed" )
- case41Result = appCheck and pingResult
- utilities.assert_equals( expect=main.TRUE, actual=case41Result,
+ caseResult = appCheck and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Reactive Mode IPv4 Pingall test PASS",
onfail="Reactive Mode IPv4 Pingall test FAIL" )
@@ -644,8 +650,8 @@
else:
main.log.report( "IPv4 Pingall Test in Reactive mode failed" )
- case42Result = appCheck and pingResult
- utilities.assert_equals( expect=main.TRUE, actual=case42Result,
+ caseResult = appCheck and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Reactive Mode IPv4 Pingall test PASS",
onfail="Reactive Mode IPv4 Pingall test FAIL" )
@@ -713,8 +719,8 @@
# Waiting for reative flows to be cleared.
time.sleep( 30 )
- case140Result = appCheck and cfgResult and pingResult
- utilities.assert_equals( expect=main.TRUE, actual=case140Result,
+ caseResult = appCheck and cfgResult and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Reactive Mode IPv6 Pingall test PASS",
onfail="Reactive Mode IPv6 Pingall test FAIL" )
@@ -782,8 +788,8 @@
# Waiting for reative flows to be cleared.
time.sleep( 30 )
- case140Result = appCheck and cfgResult and pingResult
- utilities.assert_equals( expect=main.TRUE, actual=case140Result,
+ caseResult = appCheck and cfgResult and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Reactive Mode IPv6 Pingall test PASS",
onfail="Reactive Mode IPv6 Pingall test FAIL" )
@@ -810,10 +816,10 @@
main.step( "Verify IPv6 Pingall" )
pingResult = main.FALSE
time1 = time.time()
- ping_result = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout)
- if not ping_result:
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout)
+ if not pingResult:
main.log.warn("First pingall failed. Trying again...")
- ping_result = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -851,8 +857,8 @@
# Waiting for reative flows to be cleared.
time.sleep( 30 )
- case142Result = appCheck and cfgResult and pingResult
- utilities.assert_equals( expect=main.TRUE, actual=case142Result,
+ caseResult = appCheck and cfgResult and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Reactive Mode IPv6 Pingall test PASS",
onfail="Reactive Mode IPv6 Pingall test FAIL" )
@@ -989,27 +995,31 @@
time2 = time.time()
main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
+ # Saving intent ids to check intents in later cases
+ main.intentIds = list(intentIdList)
+
main.step("Verify intents are installed")
- # Giving onos 3 chances to install intents
- for i in range(3):
- intentsJson = main.ONOScli1.intents()
- getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
- intentsJson = intentsJson)
- main.log.info("Waiting for onos to get intents...")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
time.sleep( main.checkIntentsDelay )
intentState = main.TRUE
- failedIntents = 0
- for intent in getIntentStateResult:
- state = intent.items()[0][1]
- if state != 'INSTALLED':
- main.log.info("Intent State: " + state)
- failedIntents += 1
- intentState = main.FALSE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
if intentState:
break
- main.log.error("Total # of intents not in an INSTALLED state: " + str(failedIntents))
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
utilities.assert_equals( expect=main.TRUE, actual=intentState,
onpass="INTENTS INSTALLED",
@@ -1033,13 +1043,22 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case60Result = ( intentState and pingResult )
+ caseResult = ( intentState and pingResult )
utilities.assert_equals(
expect=main.TRUE,
- actual=case60Result,
+ actual=caseResult,
onpass="Install 300 Host Intents and Ping All test PASS",
onfail="Install 300 Host Intents and Ping All test FAIL" )
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE61( self ):
"""
Install 600 host intents and verify ping all for Chordal Topology
@@ -1075,28 +1094,30 @@
time2 = time.time()
main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
+ # Saving intent ids to check intents in later cases
+ main.intentIds = list(intentIdList)
+
main.step("Verify intents are installed")
- # Giving onos 3 chances to install intents
- for i in range(3):
- intentsJson = main.ONOScli1.intents()
- getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
- intentsJson = intentsJson)
- main.log.info("Waiting for onos to get intents...")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
time.sleep( main.checkIntentsDelay )
intentState = main.TRUE
- failedIntents = 0
- for intent in getIntentStateResult:
- state = intent.items()[0][1]
- if state != 'INSTALLED':
- main.log.info("Intent State: " + state)
- failedIntents += 1
- intentState = main.FALSE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
if intentState:
break
- main.log.error("Total # of intents not in an INSTALLED state: " + str(failedIntents))
-
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intents Summary ****\n" + str(main.ONOScli1.intents(jsonFormat=False, summary=True)) )
utilities.assert_equals( expect=main.TRUE, actual=intentState,
onpass="INTENTS INSTALLED",
@@ -1120,14 +1141,23 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case14Result = ( intentState and pingResult )
+ caseResult = ( intentState and pingResult )
utilities.assert_equals(
expect=main.TRUE,
- actual=case14Result,
+ actual=caseResult,
onpass="Install 300 Host Intents and Ping All test PASS",
onfail="Install 300 Host Intents and Ping All test FAIL" )
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE62( self ):
"""
Install 2278 host intents and verify ping all for Spine Topology
@@ -1162,27 +1192,30 @@
time2 = time.time()
main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
+ # Saving intent ids to check intents in later cases
+ main.intentIds = list(intentIdList)
+
main.step("Verify intents are installed")
- # Giving onos 5 chances to install intents
- for i in range(5):
- intentsJson = main.ONOScli1.intents()
- getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
- intentsJson = intentsJson)
- main.log.info("Waiting for onos to get intents...")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
time.sleep( main.checkIntentsDelay )
intentState = main.TRUE
- failedIntents = 0
- for intent in getIntentStateResult:
- state = intent.items()[0][1]
- if state != 'INSTALLED':
- main.log.info("Intent State: " + state)
- failedIntents += 1
- intentState = main.FALSE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
if intentState:
break
- main.log.error("Total # of intents not in an INSTALLED state: " + str(failedIntents))
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intents Summary ****\n" + str(main.ONOScli1.intents(jsonFormat=False, summary=True)) )
utilities.assert_equals( expect=main.TRUE, actual=intentState,
onpass="INTENTS INSTALLED",
@@ -1206,14 +1239,23 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case15Result = ( intentState and pingResult )
+ caseResult = ( intentState and pingResult )
utilities.assert_equals(
expect=main.TRUE,
- actual=case15Result,
+ actual=caseResult,
onpass="Install 2278 Host Intents and Ping All test PASS",
onfail="Install 2278 Host Intents and Ping All test FAIL" )
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE160( self ):
"""
Verify IPv6 ping across 300 host intents (Att Topology)
@@ -1224,14 +1266,13 @@
import time
main.case( "IPv6 ping all 300 host intents" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -1242,10 +1283,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case160Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case160Result,
+ actual=caseResult,
onpass="IPv6 Ping across 300 host intents test PASS",
onfail="IPv6 Ping across 300 host intents test FAIL" )
@@ -1259,15 +1300,13 @@
import time
main.case( "IPv6 ping all 600 host intents" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -1278,10 +1317,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case161Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case161Result,
+ actual=caseResult,
onpass="IPv6 Ping across 600 host intents test PASS",
onfail="IPv6 Ping across 600 host intents test FAIL" )
@@ -1295,15 +1334,13 @@
import time
main.case( "IPv6 ping all 600 host intents" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 11)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -1314,10 +1351,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case162Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case162Result,
+ actual=caseResult,
onpass="IPv6 Ping across 600 host intents test PASS",
onfail="IPv6 Ping across 600 host intents test FAIL" )
@@ -1383,14 +1420,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkDown = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout )
- if not pingResultLinkDown:
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1398,15 +1461,27 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult70 = linkDown and pingResultLinkDown
- utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
+ caseResult = linkDown and pingResult and intentState
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Random Link cut Test PASS",
onfail="Random Link cut Test FAIL" )
+ # Printing what exactly failed
+ if not linkDown:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE80( self, main ):
"""
Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
@@ -1455,14 +1530,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkUp = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall( timeout=main.pingTimeout )
- if not pingResultLinkUp:
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1470,14 +1571,25 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult80 = linkUp and pingResultLinkUp
- utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
+ caseResult = linkUp and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Link Up Test PASS",
onfail="Link Up Test FAIL" )
+ # Printing what exactly failed
+ if not linkUp:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
def CASE71( self, main ):
"""
@@ -1541,14 +1653,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkDown = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
- if not pingResultLinkDown:
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1556,15 +1694,27 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult71 = linkDown and pingResultLinkDown
- utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
+ caseResult = linkDown and pingResult and intentState
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Random Link cut Test PASS",
onfail="Random Link cut Test FAIL" )
+ # Printing what exactly failed
+ if not linkDown:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE81( self, main ):
"""
Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
@@ -1613,14 +1763,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkUp = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout )
- if not pingResultLinkUp:
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout )
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1628,14 +1804,25 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult81 = linkUp and pingResultLinkUp
- utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
+ caseResult = linkUp and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Link Up Test PASS",
onfail="Link Up Test FAIL" )
+ # Printing what exactly failed
+ if not linkUp:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( mail=main.emailOnStop )
def CASE72( self, main ):
"""
@@ -1676,15 +1863,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkDown = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
- if not pingResultLinkDown:
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
-
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1692,15 +1904,27 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult71 = pingResultLinkDown
- utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
+ caseResult = linkDown and pingResult and intentState
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Random Link cut Test PASS",
onfail="Random Link cut Test FAIL" )
+ # Printing what exactly failed
+ if not linkDown:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE82( self, main ):
"""
Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
@@ -1736,15 +1960,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkUp = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
- if not pingResultLinkUp:
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
-
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1752,14 +2001,25 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult82 = linkUp and pingResultLinkUp
- utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
+ caseResult = linkUp and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Link Up Test PASS",
onfail="Link Up Test FAIL" )
+ # Printing what exactly failed
+ if not linkUp:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
def CASE73( self, main ):
"""
@@ -1800,14 +2060,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkDown = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
- if not pingResultLinkDown:
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1815,15 +2101,27 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult73 = pingResultLinkDown
- utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
+ caseResult = linkDown and pingResult and intentState
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Random Link cut Test PASS",
onfail="Random Link cut Test FAIL" )
+ # Printing what exactly failed
+ if not linkDown:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE83( self, main ):
"""
Bring the core links up that are down and verify ping all ( Point Intents Chordal Topo )
@@ -1859,14 +2157,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkUp = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
- if not pingResultLinkUp:
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1874,14 +2198,25 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult83 = linkUp and pingResultLinkUp
- utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
+ caseResult = linkUp and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Link Up Test PASS",
onfail="Link Up Test FAIL" )
+ # Printing what exactly failed
+ if not linkUp:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
def CASE74( self, main ):
"""
@@ -1933,14 +2268,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkDown = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
- if not pingResultLinkDown:
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -1948,15 +2309,27 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult74 = linkDown and pingResultLinkDown
- utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
+ caseResult = linkDown and pingResult and intentState
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Random Link cut Test PASS",
onfail="Random Link cut Test FAIL" )
+ # Printing what exactly failed
+ if not linkDown:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE84( self, main ):
"""
Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
@@ -1993,14 +2366,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkUp = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
- if not pingResultLinkUp:
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -2008,14 +2407,25 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult84 = linkUp and pingResultLinkUp
- utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
+ caseResult = linkUp and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Link Up Test PASS",
onfail="Link Up Test FAIL" )
+ # Printing what exactly failed
+ if not linkUp:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
def CASE75( self, main ):
"""
@@ -2067,14 +2477,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkDown = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
- if not pingResultLinkDown:
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -2082,15 +2518,27 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult75 = linkDown and pingResultLinkDown
- utilities.assert_equals( expect=main.TRUE, actual=caseResult75,
+ caseResult = linkDown and pingResult and intentState
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Random Link cut Test PASS",
onfail="Random Link cut Test FAIL" )
+ # Printing what exactly failed
+ if not linkDown:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE85( self, main ):
"""
Bring the core links up that are down and verify ping all ( Point Intents-Spine Topo )
@@ -2127,14 +2575,40 @@
str( link_sleep ) +
" seconds" )
+ main.step("Verify intents are installed")
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Giving onos some time...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = main.intentIds ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "**** Intent Summary ****\n" + str(main.ONOScli1.intents( jsonFormat=False, summary=True)) )
+
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
main.step( "Verify Ping across all hosts" )
- pingResultLinkUp = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
- if not pingResultLinkUp:
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall(timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
@@ -2142,14 +2616,25 @@
"Time taken for Ping All: " +
str( timeDiff ) +
" seconds" )
- utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- caseResult85 = linkUp and pingResultLinkUp
- utilities.assert_equals( expect=main.TRUE, actual=caseResult85,
+ caseResult = linkUp and pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Link Up Test PASS",
onfail="Link Up Test FAIL" )
+ # Printing what exactly failed
+ if not linkUp:
+ main.log.debug( "Link down was not discovered correctly" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not intentState:
+ main.log.debug( "Intents are not all installed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
def CASE170( self ):
"""
@@ -2161,13 +2646,12 @@
import time
main.case( "IPv6 ping all with some core links down( Host Intents-Att Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("Failed to ping Ipv6 hosts. Retrying...")
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2178,10 +2662,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case170Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case170Result,
+ actual=caseResult,
onpass="IPv6 Ping across 300 host intents test PASS",
onfail="IPv6 Ping across 300 host intents test FAIL" )
@@ -2195,15 +2679,13 @@
import time
main.case( "IPv6 ping all with after core links back up( Host Intents-Att Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2214,10 +2696,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case180Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case180Result,
+ actual=caseResult,
onpass="IPv6 Ping across 300 host intents test PASS",
onfail="IPv6 Ping across 300 host intents test FAIL" )
@@ -2231,15 +2713,13 @@
import time
main.case( "IPv6 ping all with some core links down( Point Intents-Att Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2250,10 +2730,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case171Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case171Result,
+ actual=caseResult,
onpass="IPv6 Ping across 600 point intents test PASS",
onfail="IPv6 Ping across 600 point intents test FAIL" )
@@ -2267,15 +2747,13 @@
import time
main.case( "IPv6 ping all with after core links back up( Point Intents-Att Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2286,10 +2764,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case181Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case181Result,
+ actual=caseResult,
onpass="IPv6 Ping across 600 Point intents test PASS",
onfail="IPv6 Ping across 600 Point intents test FAIL" )
@@ -2303,15 +2781,13 @@
import time
main.case( "IPv6 ping all with some core links down( Host Intents-Chordal Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2322,10 +2798,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case172Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case172Result,
+ actual=caseResult,
onpass="IPv6 Ping across 300 host intents test PASS",
onfail="IPv6 Ping across 300 host intents test FAIL" )
@@ -2339,15 +2815,13 @@
import time
main.case( "IPv6 ping all with after core links back up( Host Intents-Chordal Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2358,10 +2832,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case182Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case182Result,
+ actual=caseResult,
onpass="IPv6 Ping across 300 host intents test PASS",
onfail="IPv6 Ping across 300 host intents test FAIL" )
@@ -2375,15 +2849,13 @@
import time
main.case( "IPv6 ping all with some core links down( Point Intents-Chordal Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2394,10 +2866,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case173Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case173Result,
+ actual=caseResult,
onpass="IPv6 Ping across 600 point intents test PASS",
onfail="IPv6 Ping across 600 point intents test FAIL" )
@@ -2411,15 +2883,13 @@
import time
main.case( "IPv6 ping all with after core links back up( Point Intents-Chordal Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2430,10 +2900,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case183Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case183Result,
+ actual=caseResult,
onpass="IPv6 Ping across 600 Point intents test PASS",
onfail="IPv6 Ping across 600 Point intents test FAIL" )
@@ -2447,15 +2917,13 @@
import time
main.case( "IPv6 ping all with some core links down( Host Intents-Spine Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 11)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2466,10 +2934,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case174Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case174Result,
+ actual=caseResult,
onpass="IPv6 Ping across 2278 host intents test PASS",
onfail="IPv6 Ping across 2278 host intents test FAIL" )
@@ -2483,15 +2951,13 @@
import time
main.case( "IPv6 ping all with after core links back up( Host Intents-Spine Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 11)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2502,10 +2968,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case184Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case184Result,
+ actual=caseResult,
onpass="IPv6 Ping across 2278 host intents test PASS",
onfail="IPv6 Ping across 2278 host intents test FAIL" )
@@ -2519,15 +2985,13 @@
import time
main.case( "IPv6 ping all with some core links down( Point Intents-Spine Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 11)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2538,10 +3002,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case175Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case175Result,
+ actual=caseResult,
onpass="IPv6 Ping across 4556 point intents test PASS",
onfail="IPv6 Ping across 4556 point intents test FAIL" )
@@ -2555,15 +3019,13 @@
import time
main.case( "IPv6 ping all with after core links back up( Point Intents-Spine Topo )" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 11)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First ping failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2574,10 +3036,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case183Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case183Result,
+ actual=caseResult,
onpass="IPv6 Ping across 4556 Point intents test PASS",
onfail="IPv6 Ping across 4556 Point intents test FAIL" )
@@ -2614,33 +3076,36 @@
intentIdList.append(thread.result)
time2 = time.time()
main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
- intentResult = main.TRUE
- intentsJson = main.ONOScli1.intents()
- getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
- intentsJson = intentsJson)
- # Takes awhile for all the onos to get the intents
- time.sleep(60)
+
+ # Saving intent ids to check intents in later case
+ main.intentIds = list(intentIdList)
main.step("Verify intents are installed")
- for i in range(3):
+
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
+ time.sleep( main.checkIntentsDelay )
+
intentState = main.TRUE
- failedIntents = 0
- for intent in getIntentStateResult:
- state = intent.items()[0][1]
- if state != 'INSTALLED':
- main.log.info("Intent State: " + state)
- failedIntents += 1
- intentState = main.FALSE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
if intentState:
break
- main.log.error("Total: " + str(failedIntents))
- time.sleep(5)
+ else:
+ #Dumping intent summary
+ main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
utilities.assert_equals( expect=main.TRUE, actual=intentState,
onpass="INTENTS INSTALLED",
onfail="SOME INTENTS NOT INSTALLED" )
-
main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
@@ -2655,14 +3120,23 @@
onpass="PING tALL PASS",
onfail="PING ALL FAIL" )
- case90Result = ( intentResult and pingResult )
+ caseResult = ( intentState and pingResult )
utilities.assert_equals(
expect=main.TRUE,
- actual=case90Result,
+ actual=caseResult,
onpass="Install 600 point Intents and Ping All test PASS",
onfail="Install 600 point Intents and Ping All test FAIL" )
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE91( self ):
"""
Install 600 point intents and verify ping all (Chordal Topology)
@@ -2697,33 +3171,36 @@
intentIdList.append(thread.result)
time2 = time.time()
main.log.info( "Time for adding point intents: %2f seconds" %(time2-time1) )
- intentResult = main.TRUE
- intentsJson = main.ONOScli1.intents()
- getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
- intentsJson = intentsJson)
- # Takes awhile for all the onos to get the intents
- time.sleep(30)
+
+ # Saving intent ids to check intents in later case
+ main.intentIds = list(intentIdList)
main.step("Verify intents are installed")
- for i in range(3):
+
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
+ time.sleep( main.checkIntentsDelay )
+
intentState = main.TRUE
- failedIntents = 0
- for intent in getIntentStateResult:
- state = intent.items()[0][1]
- if state != 'INSTALLED':
- main.log.info("Intent State: " + state)
- failedIntents += 1
- intentState = main.FALSE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
if intentState:
break
- main.log.error("Total: " + str(failedIntents))
- time.sleep(5)
+ else:
+ #Dumping intent summary
+ main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
utilities.assert_equals( expect=main.TRUE, actual=intentState,
onpass="INTENTS INSTALLED",
onfail="SOME INTENTS NOT INSTALLED" )
-
main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
@@ -2738,14 +3215,23 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case91Result = ( intentResult and pingResult )
+ caseResult = ( intentState and pingResult )
utilities.assert_equals(
expect=main.TRUE,
- actual=case91Result,
+ actual=caseResult,
onpass="Install 600 point Intents and Ping All test PASS",
onfail="Install 600 point Intents and Ping All test FAIL" )
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE92( self ):
"""
Install 4556 point intents and verify ping all (Spine Topology)
@@ -2783,34 +3269,36 @@
intentIdList.append(thread.result)
time2 = time.time()
main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
- intentResult = main.TRUE
- intentsJson = main.ONOScli1.intents()
- getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
- intentsJson = intentsJson)
- #print getIntentStateResult
- # Takes awhile for all the onos to get the intents
- time.sleep(60)
+
+ # Saving intent ids to check intents in later case
+ main.intentIds = list(intentIdList)
main.step("Verify intents are installed")
- for i in range(3):
+
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
+ time.sleep( main.checkIntentsDelay )
+
intentState = main.TRUE
- failedIntents = 0
- for intent in getIntentStateResult:
- state = intent.items()[0][1]
- if state != 'INSTALLED':
- main.log.info("Intent State: " + state)
- failedIntents += 1
- intentState = main.FALSE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
if intentState:
break
- main.log.error("Total: " + str(failedIntents))
- time.sleep(5)
+ else:
+ #Dumping intent summary
+ main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
utilities.assert_equals( expect=main.TRUE, actual=intentState,
onpass="INTENTS INSTALLED",
onfail="SOME INTENTS NOT INSTALLED" )
-
main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
@@ -2825,14 +3313,23 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case92Result = ( intentResult and pingResult )
+ caseResult = ( intentState and pingResult )
utilities.assert_equals(
expect=main.TRUE,
- actual=case92Result,
+ actual=caseResult,
onpass="Install 4556 point Intents and Ping All test PASS",
onfail="Install 4556 point Intents and Ping All test FAIL" )
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE93( self ):
"""
Install multi-single point intents and verify Ping all works
@@ -2840,13 +3337,14 @@
"""
import copy
import time
+ from collections import Counter
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
+ main.log.info( "MACsDict" + str(main.MACsDict) )
time1 = time.time()
for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
pool = []
@@ -2861,7 +3359,6 @@
name="addMultipointToSinglepointIntent",
args =[ingressDeviceList,egressDevice,portIngressList,'1','','',main.MACsDict.get(egressDevice)])
pool.append(t)
- #time.sleep(1)
t.start()
i = i + 1
main.threadID = main.threadID + 1
@@ -2870,44 +3367,90 @@
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 " )
+ main.step("Verify intents are installed")
- print "Checking flows state "
- checkFlowsState = main.ONOScli1.checkFlowsState()
- time.sleep(50)
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
+ main.step("Verify flows are all added")
+
+ for i in range( main.flowCheck ):
+ if i != 0:
+ main.log.warn( "verification failed. Retrying..." )
+ main.log.info( "Waiting for onos to add flows..." )
+ time.sleep( main.checkFlowsDelay )
+
+ flowState = main.TRUE
+ for cli in main.CLIs:
+ flowState = cli.checkFlowState()
+ if not flowState:
+ main.log.warn( "Not all flows added" )
+ if flowState:
+ break
+ else:
+ #Dumping summary
+ main.log.info( "Summary:\n" + str( main.ONOScli1.summary(jsonFormat=False) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=flowState,
+ onpass="FLOWS INSTALLED",
+ onfail="SOME FLOWS NOT ADDED" )
+
main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
+ time1 = time.time()
+ main.log.warn("First pingall failed. Retrying")
+ pingResult = 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" )
- checkFlowsState = main.ONOScli1.checkFlowsState()
- case93Result = pingResult
+
+ caseResult = ( checkFlowsState and pingResult and intentState )
utilities.assert_equals(
expect=main.TRUE,
- actual=case93Result,
+ actual=caseResult,
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" )
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not checkFlowsState:
+ main.log.debug( "Flows failed to add completely" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE94( self ):
"""
Install multi-single point intents and verify Ping all works
@@ -2921,7 +3464,7 @@
deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
intentIdList = []
- print "MACsDict", main.MACsDict
+ main.log.info( "MACsDict" + str(main.MACsDict) )
time1 = time.time()
for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
pool = []
@@ -2936,7 +3479,6 @@
name="addMultipointToSinglepointIntent",
args =[ingressDeviceList,egressDevice,portIngressList,'1','','',main.MACsDict.get(egressDevice)])
pool.append(t)
- #time.sleep(1)
t.start()
i = i + 1
main.threadID = main.threadID + 1
@@ -2945,11 +3487,65 @@
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 intents are installed")
+
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
+ main.step("Verify flows are all added")
+
+ for i in range( main.flowCheck ):
+ if i != 0:
+ main.log.warn( "verification failed. Retrying..." )
+ main.log.info( "Waiting for onos to add flows..." )
+ time.sleep( main.checkFlowsDelay )
+
+ flowState = main.TRUE
+ for cli in main.CLIs:
+ flowState = cli.checkFlowState()
+ if not flowState:
+ main.log.warn( "Not all flows added" )
+ if flowState:
+ break
+ else:
+ #Dumping summary
+ main.log.info( "Summary:\n" + str( main.ONOScli1.summary(jsonFormat=False) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=flowState,
+ onpass="FLOWS INSTALLED",
+ onfail="SOME FLOWS NOT ADDED" )
+
main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
+ time1 = time.time()
+ main.log.warn("First pingall failed. Retrying")
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -2957,14 +3553,143 @@
str( timeDiff ) +
" seconds" )
- case94Result = pingResult
+ caseResult = ( checkFlowsState and pingResult and intentState )
utilities.assert_equals(
expect=main.TRUE,
- actual=case94Result,
+ actual=caseResult,
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
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not checkFlowsState:
+ main.log.debug( "Flows failed to add completely" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
+ def CASE95( self ):
+ """
+ Install multi-single point intents and verify Ping all works
+ for Spine 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 = []
+ main.log.info( "MACsDict" + str(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','','',main.MACsDict.get(egressDevice)])
+ 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 point intents: %2f seconds" %(time2-time1))
+
+ main.step("Verify intents are installed")
+
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
+ main.step("Verify flows are all added")
+
+ for i in range( main.flowCheck ):
+ if i != 0:
+ main.log.warn( "verification failed. Retrying..." )
+ main.log.info( "Waiting for onos to add flows..." )
+ time.sleep( main.checkFlowsDelay )
+
+ flowState = main.TRUE
+ for cli in main.CLIs:
+ flowState = cli.checkFlowState()
+ if not flowState:
+ main.log.warn( "Not all flows added" )
+ if flowState:
+ break
+ else:
+ #Dumping summary
+ main.log.info( "Summary:\n" + str( main.ONOScli1.summary(jsonFormat=False) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=flowState,
+ onpass="FLOWS INSTALLED",
+ onfail="SOME FLOWS NOT ADDED" )
+
+ main.step( "Verify Ping across all hosts" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
+ time1 = time.time()
+ main.log.warn("First pingall failed. Retrying")
+ pingResult = 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" )
+
+ caseResult = ( checkFlowsState and pingResult and intentState )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=caseResult,
+ 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" )
+
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not checkFlowsState:
+ main.log.debug( "Flows failed to add completely" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
def CASE96( self ):
"""
@@ -2978,7 +3703,7 @@
deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
intentIdList = []
- print "MACsDict", main.MACsDict
+ main.log.info( "MACsDict" + str(main.MACsDict) )
time1 = time.time()
for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
pool = []
@@ -2993,7 +3718,6 @@
name="addSinglepointToMultipointIntent",
args =[ingressDevice,egressDeviceList,'1',portEgressList,'',main.MACsDict.get(ingressDevice)])
pool.append(t)
- #time.sleep(1)
t.start()
i = i + 1
main.threadID = main.threadID + 1
@@ -3002,11 +3726,65 @@
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 intents are installed")
+
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
+ main.step("Verify flows are all added")
+
+ for i in range( main.flowCheck ):
+ if i != 0:
+ main.log.warn( "verification failed. Retrying..." )
+ main.log.info( "Waiting for onos to add flows..." )
+ time.sleep( main.checkFlowsDelay )
+
+ flowState = main.TRUE
+ for cli in main.CLIs:
+ flowState = cli.checkFlowState()
+ if not flowState:
+ main.log.warn( "Not all flows added" )
+ if flowState:
+ break
+ else:
+ #Dumping summary
+ main.log.info( "Summary:\n" + str( main.ONOScli1.summary(jsonFormat=False) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=flowState,
+ onpass="FLOWS INSTALLED",
+ onfail="SOME FLOWS NOT ADDED" )
+
main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
+ time1 = time.time()
+ main.log.warn("First pingall failed. Retrying")
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -3014,13 +3792,24 @@
str( timeDiff ) +
" seconds" )
- case96Result = pingResult
+ caseResult = ( pingResult and intentState and flowState)
utilities.assert_equals(
expect=main.TRUE,
- actual=case96Result,
+ actual=caseResult,
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" )
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not checkFlowsState:
+ main.log.debug( "Flows failed to add completely" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE97( self ):
"""
Install single-multi point intents and verify Ping all works
@@ -3033,7 +3822,7 @@
deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
intentIdList = []
- print "MACsDict", main.MACsDict
+ main.log.info( "MACsDict" + str(main.MACsDict) )
time1 = time.time()
for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
pool = []
@@ -3048,7 +3837,6 @@
name="addSinglepointToMultipointIntent",
args =[ingressDevice,egressDeviceList,'1',portEgressList,'',main.MACsDict.get(ingressDevice),''])
pool.append(t)
- #time.sleep(1)
t.start()
i = i + 1
main.threadID = main.threadID + 1
@@ -3057,11 +3845,65 @@
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 intents are installed")
+
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
+ main.step("Verify flows are all added")
+
+ for i in range( main.flowCheck ):
+ if i != 0:
+ main.log.warn( "verification failed. Retrying..." )
+ main.log.info( "Waiting for onos to add flows..." )
+ time.sleep( main.checkFlowsDelay )
+
+ flowState = main.TRUE
+ for cli in main.CLIs:
+ flowState = cli.checkFlowState()
+ if not flowState:
+ main.log.warn( "Not all flows added" )
+ if flowState:
+ break
+ else:
+ #Dumping summary
+ main.log.info( "Summary:\n" + str( main.ONOScli1.summary(jsonFormat=False) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=flowState,
+ onpass="FLOWS INSTALLED",
+ onfail="SOME FLOWS NOT ADDED" )
+
main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
+ time1 = time.time()
+ main.log.warn("First pingall failed. Retrying")
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -3069,13 +3911,24 @@
str( timeDiff ) +
" seconds" )
- case97Result = pingResult
+ caseResult = ( pingResult and intentState and flowState)
utilities.assert_equals(
expect=main.TRUE,
- actual=case97Result,
+ actual=caseResult,
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" )
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not checkFlowsState:
+ main.log.debug( "Flows failed to add completely" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE98( self ):
"""
Install single-multi point intents and verify Ping all works
@@ -3093,9 +3946,8 @@
for i in range( len( deviceDPIDsCopy ) ):
MACsDictCopy[ deviceDPIDsCopy[ i ] ] = main.hostMACs[i].split( '/' )[ 0 ]
- print "deviceDPIDsCopy", deviceDPIDsCopy
- print ""
- print "MACsDictCopy", MACsDictCopy
+ main.log.info( "deviceDPIDsCopy" + str(deviceDPIDsCopy) )
+ main.log.info( "MACsDictCopy" + str(MACsDictCopy) )
time1 = time.time()
for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
pool = []
@@ -3110,7 +3962,6 @@
name="addSinglepointToMultipointIntent",
args =[ingressDevice,egressDeviceList,'1',portEgressList,'',MACsDictCopy.get(ingressDevice),''])
pool.append(t)
- #time.sleep(1)
t.start()
i = i + 1
main.threadID = main.threadID + 1
@@ -3119,11 +3970,65 @@
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 intents are installed")
+
+ # Giving onos multiple chances to install intents
+ for i in range( main.intentCheck ):
+ if i != 0:
+ main.log.warn( "Verification failed. Retrying..." )
+ main.log.info("Waiting for onos to install intents...")
+ time.sleep( main.checkIntentsDelay )
+
+ intentState = main.TRUE
+ for e in range(int(main.numCtrls)):
+ main.log.info( "Checking intents on CLI %s" % (e+1) )
+ intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+ intentState
+ if not intentState:
+ main.log.warn( "Not all intents installed" )
+ if intentState:
+ break
+ else:
+ #Dumping intent summary
+ main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=intentState,
+ onpass="INTENTS INSTALLED",
+ onfail="SOME INTENTS NOT INSTALLED" )
+
+ main.step("Verify flows are all added")
+
+ for i in range( main.flowCheck ):
+ if i != 0:
+ main.log.warn( "verification failed. Retrying..." )
+ main.log.info( "Waiting for onos to add flows..." )
+ time.sleep( main.checkFlowsDelay )
+
+ flowState = main.TRUE
+ for cli in main.CLIs:
+ flowState = cli.checkFlowState()
+ if not flowState:
+ main.log.warn( "Not all flows added" )
+ if flowState:
+ break
+ else:
+ #Dumping summary
+ main.log.info( "Summary:\n" + str( main.ONOScli1.summary(jsonFormat=False) ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=flowState,
+ onpass="FLOWS INSTALLED",
+ onfail="SOME FLOWS NOT ADDED" )
+
main.step( "Verify Ping across all hosts" )
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+ if not pingResult:
+ time1 = time.time()
+ main.log.warn("First pingall failed. Retrying")
+ pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -3131,13 +4036,24 @@
str( timeDiff ) +
" seconds" )
- case98Result = pingResult
+ caseResult = ( pingResult and intentState and flowState)
utilities.assert_equals(
expect=main.TRUE,
- actual=case98Result,
+ actual=caseResult,
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" )
+ if not intentState:
+ main.log.debug( "Intents failed to install completely" )
+ if not pingResult:
+ main.log.debug( "Pingall failed" )
+ if not checkFlowsState:
+ main.log.debug( "Flows failed to add completely" )
+
+ if not caseResult and main.failSwitch:
+ main.log.report("Stopping test")
+ main.stop( email=main.emailOnStop )
+
def CASE190( self ):
"""
Verify IPv6 ping across 600 Point intents (Att Topology)
@@ -3148,15 +4064,13 @@
import time
main.case( "IPv6 ping all 600 Point intents" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -3167,10 +4081,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case160Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case160Result,
+ actual=caseResult,
onpass="IPv6 Ping across 600 Point intents test PASS",
onfail="IPv6 Ping across 600 Point intents test FAIL" )
@@ -3184,15 +4098,13 @@
import time
main.case( "IPv6 ping all 600 Point intents" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 1)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -3203,10 +4115,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case191Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case191Result,
+ actual=caseResult,
onpass="IPv6 Ping across 600 Point intents test PASS",
onfail="IPv6 Ping across 600 Point intents test FAIL" )
@@ -3220,15 +4132,13 @@
import time
main.case( "IPv6 ping all 4556 Point intents" )
main.step( "Verify IPv6 Ping across all hosts" )
- hostList = [ ('h'+ str(x + 11)) for x in range (main.numMNhosts) ]
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
if not pingResult:
main.log.warn("First pingall failed. Retrying...")
time1 = time.time()
- pingResult = main.Mininet1.pingIpv6Hosts( hostList, prefix='1000::' )
-
+ pingResult = main.Mininet1.pingall( protocol="IPv6", timeout=main.pingTimeout )
time2 = time.time()
timeDiff = round( ( time2 - time1 ), 2 )
main.log.report(
@@ -3239,10 +4149,10 @@
onpass="PING ALL PASS",
onfail="PING ALL FAIL" )
- case192Result = pingResult
+ caseResult = pingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case192Result,
+ actual=caseResult,
onpass="IPv6 Ping across 4556 Point intents test PASS",
onfail="IPv6 Ping across 4556 Point intents test FAIL" )
@@ -3343,8 +4253,8 @@
step1Result = main.FALSE
print main.ONOScli1.intents()
- caseResult10 = step1Result
- utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
+ caseResult = step1Result
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Intent removal test successful",
onfail="Intent removal test failed" )
@@ -3436,7 +4346,7 @@
# Waiting for reative flows to be cleared.
time.sleep( 10 )
- case11Result = installResult and pingResult and uninstallResult
- utilities.assert_equals( expect=main.TRUE, actual=case11Result,
+ caseResult = installResult and pingResult and uninstallResult
+ utilities.assert_equals( expect=main.TRUE, actual=caseResult,
onpass="Intent based Reactive forwarding Pingall test PASS",
onfail="Intent based Reactive forwarding Pingall test FAIL" )
diff --git a/TestON/tests/FUNCflow/Dependency/startUp.py b/TestON/tests/FUNCflow/Dependency/startUp.py
new file mode 100644
index 0000000..bf2a2b6
--- /dev/null
+++ b/TestON/tests/FUNCflow/Dependency/startUp.py
@@ -0,0 +1,38 @@
+"""
+ This wrapper function is use for starting up onos instance
+"""
+
+import time
+import os
+import json
+
+def onosBuild( main, gitBranch ):
+ """
+ This includes pulling ONOS and building it using maven install
+ """
+
+ buildResult = main.FALSE
+
+ # Git checkout a branch of ONOS
+ checkOutResult = main.ONOSbench.gitCheckout( gitBranch )
+ # Does the git pull on the branch that was checked out
+ if not checkOutResult:
+ main.log.warn( "Failed to checked out " + gitBranch +
+ " branch")
+ else:
+ main.log.info( "Successfully checked out " + gitBranch +
+ " branch")
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == main.ERROR:
+ main.log.error( "Error pulling git branch" )
+ else:
+ main.log.info( "Successfully pulled " + gitBranch + " branch" )
+
+ # Maven clean install
+ buildResult = main.ONOSbench.cleanInstall()
+
+ return buildResult
+
+
+
+
diff --git a/TestON/tests/FUNCflow/FUNCflow.params b/TestON/tests/FUNCflow/FUNCflow.params
new file mode 100755
index 0000000..d6312b3
--- /dev/null
+++ b/TestON/tests/FUNCflow/FUNCflow.params
@@ -0,0 +1,52 @@
+
+<PARAMS>
+ # CASE - Descritpion
+ # 1 - Variable initialization and optional pull and build ONOS package
+ # 2 - install ONOS
+ # 8 - Compare topology
+ # 9 - Report logs
+ # 10 - Start mininet and assign switches to controller
+ # 1000 - Add flows
+ # 2000 - Delete flows
+ # 3000 - Modify flow rule selectors
+ # 4000 - Modify flow rule treatments
+ # 5000 - flow rule controller
+ # 100 - Compare switch flow table with ONOS
+ <testcases>1,2,10,8</testcases>
+
+ <SCALE>
+ <max>3</max>
+ </SCALE>
+
+ <DEPENDENCY>
+ <path>/tests/FUNCflow/Dependency/</path>
+ <wrapper1>startUp</wrapper1>
+ <wrapper2>topo</wrapper2>
+ <topology>flow-2sw.py</topology>
+ </DEPENDENCY>
+
+ <TOPO>
+ <numSwitches>2</numSwitches>
+ <numHosts>4</numHosts>
+ <numLinks>2</numLinks>
+ </TOPO>
+
+ <ENV>
+ <cellName>productionCell</cellName>
+ <cellApps>drivers,openflow,proxyarp,mobility,fwd</cellApps>
+ </ENV>
+
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
+
+ <CTRL>
+ <port>6653</port>
+ </CTRL>
+
+ <SLEEP>
+ <startup>15</startup>
+ </SLEEP>
+
+</PARAMS>
diff --git a/TestON/tests/FUNCflow/FUNCflow.py b/TestON/tests/FUNCflow/FUNCflow.py
new file mode 100644
index 0000000..74c3464
--- /dev/null
+++ b/TestON/tests/FUNCflow/FUNCflow.py
@@ -0,0 +1,362 @@
+class FUNCflow:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ import time
+ import os
+ import imp
+
+ """
+ - Construct tests variables
+ - GIT ( optional )
+ - Checkout ONOS master branch
+ - Pull latest ONOS code
+ - Building ONOS ( optional )
+ - Install ONOS package
+ - Build ONOS package
+ """
+
+ main.case( "Constructing test variables and building ONOS package" )
+ main.step( "Constructing test variables" )
+ stepResult = main.FALSE
+
+ # Test variables
+ main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
+ main.cellName = main.params[ 'ENV' ][ 'cellName' ]
+ main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+ gitBranch = main.params[ 'GIT' ][ 'branch' ]
+ main.dependencyPath = main.testOnDirectory + \
+ main.params[ 'DEPENDENCY' ][ 'path' ]
+ main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
+ main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
+ main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
+ main.numSwitches = int( main.params[ 'TOPO' ][ 'numSwitches' ] )
+ main.numHosts = int( main.params[ 'TOPO' ][ 'numHosts' ] )
+ main.numLinks = int( main.params[ 'TOPO' ][ 'numLinks' ] )
+ wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+ wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
+ main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+ gitPull = main.params[ 'GIT' ][ 'pull' ]
+ main.cellData = {} # for creating cell file
+ main.CLIs = []
+ main.ONOSip = []
+
+ main.ONOSip = main.ONOSbench.getOnosIps()
+ print main.ONOSip
+
+ # Assigning ONOS cli handles to a list
+ for i in range( 1, main.maxNodes + 1 ):
+ main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
+ main.startUp = imp.load_source( wrapperFile1,
+ main.dependencyPath +
+ wrapperFile1 +
+ ".py" )
+
+ main.topo = imp.load_source( wrapperFile2,
+ main.dependencyPath +
+ wrapperFile2 +
+ ".py" )
+
+ copyResult = main.ONOSbench.scp( main.Mininet1,
+ main.dependencyPath+main.topology,
+ main.Mininet1.home+'/custom/',
+ direction="to" )
+
+ if main.CLIs:
+ stepResult = main.TRUE
+ else:
+ main.log.error( "Did not properly created list of ONOS CLI handle" )
+ stepResult = main.FALSE
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully construct " +
+ "test variables ",
+ onfail="Failed to construct test variables" )
+
+ if gitPull == 'True':
+ main.step( "Building ONOS in " + gitBranch + " branch" )
+ onosBuildResult = main.startUp.onosBuild( main, gitBranch )
+ stepResult = onosBuildResult
+ 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" )
+
+ def CASE2( self, main ):
+ """
+ - Set up cell
+ - Create cell file
+ - Set cell file
+ - Verify cell file
+ - Kill ONOS process
+ - Uninstall ONOS cluster
+ - Verify ONOS start up
+ - Install ONOS cluster
+ - Connect to cli
+ """
+
+ main.numCtrls = int( main.maxNodes )
+
+ main.case( "Starting up " + str( main.numCtrls ) +
+ " node(s) ONOS cluster" )
+
+ #kill off all onos processes
+ main.log.info( "Safety check, killing all ONOS processes" +
+ " before initiating enviornment setup" )
+
+ for i in range( main.maxNodes ):
+ main.ONOSbench.onosDie( main.ONOSip[ i ] )
+
+ print "NODE COUNT = ", main.numCtrls
+
+ tempOnosIp = []
+ for i in range( main.numCtrls ):
+ tempOnosIp.append( main.ONOSip[i] )
+
+ main.ONOSbench.createCellFile( main.ONOSbench.ip_address, "temp", main.Mininet1.ip_address, main.apps, tempOnosIp )
+
+ main.step( "Apply cell to environment" )
+ cellResult = main.ONOSbench.setCell( "temp" )
+ 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" )
+
+ time.sleep( main.startUpSleep )
+ 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( main.startUpSleep )
+ 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( main.startUpSleep )
+ 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 CASE8( self, main ):
+ '''
+ Compare topology
+ '''
+ import json
+
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplanation = "Compare topology elements between Mininet" +\
+ " and ONOS"
+
+ main.step( "Gathering topology information" )
+ # TODO: add a paramaterized sleep here
+ devicesResults = main.TRUE
+ linksResults = main.TRUE
+ hostsResults = main.TRUE
+ devices = main.topo.getAllDevices( main )
+ hosts = main.topo.getAllHosts( main )
+ ports = main.topo.getAllPorts( main )
+ links = main.topo.getAllLinks( main )
+ clusters = main.topo.getAllClusters( main )
+
+ mnSwitches = main.Mininet1.getSwitches()
+ mnLinks = main.Mininet1.getLinks()
+ mnHosts = main.Mininet1.getHosts()
+
+ main.step( "Conmparing MN topology to ONOS topology" )
+ for controller in range( main.numCtrls ):
+ controllerStr = str( controller + 1 )
+ if devices[ controller ] and ports[ controller ] and\
+ "Error" not in devices[ controller ] and\
+ "Error" not in ports[ controller ]:
+
+ currentDevicesResult = main.Mininet1.compareSwitches(
+ mnSwitches,
+ json.loads( devices[ controller ] ),
+ json.loads( ports[ 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 links[ controller ] and "Error" not in links[ controller ]:
+ currentLinksResult = main.Mininet1.compareLinks(
+ mnSwitches, mnLinks,
+ 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(
+ mnHosts,
+ json.loads( 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" )
+
+ def CASE9( self, main ):
+ '''
+ Report errors/warnings/exceptions
+ '''
+ main.log.info("Error report: \n" )
+ main.ONOSbench.logReport( main.ONOSip[ 0 ],
+ [ "INFO",
+ "FOLLOWER",
+ "WARN",
+ "flow",
+ "ERROR",
+ "Except" ],
+ "s" )
+
+ def CASE10( self, main ):
+ '''
+ Start Mininet with
+ '''
+ main.case( "Setup mininet and assign switches to controllers" )
+ main.step( "Setup Mininet Topology" )
+ topology = main.Mininet1.home + '/custom/' + main.topology
+ stepResult1 = main.Mininet1.startNet( topoFile=topology )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult1,
+ onpass="Successfully loaded topology",
+ onfail="Failed to load topology" )
+
+ main.step( "Assign switches to controllers" )
+ for i in range( main.numSwitches ):
+ stepResult2 = main.Mininet1.assignSwController(
+ sw="s" + str( i+1 ),
+ ip=main.ONOSip )
+ if not stepResult2:
+ break
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult2,
+ onpass="Controller assignment successfull",
+ onfail="Controller assignment failed" )
+
+ time.sleep(5)
+
+ main.step( "Pingall hosts for discovery" )
+ stepResult3 = main.Mininet1.pingall()
+ if not stepResult3:
+ stepResult3 = main.Mininet1.pingall()
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult3,
+ onpass="Pingall successfull",
+ onfail="Pingall unsuccessfull" )
+
+ caseResult = stepResult1 and stepResult2 and stepResult3
+ if not caseResult:
+ main.cleanup()
+ main.exit()
+
+ def CASE1000( self, main ):
+ '''
+ Add flows
+ '''
+
+ def CASE2000( self, main ):
+ '''
+ Delete flows
+ '''
+
+ def CASE3000( self, main ):
+ '''
+ Modify flow rule selectors
+ '''
+
+ def CASE4000( self, main ):
+ '''
+ Modify flow rule treatment
+ '''
+
+ def CASE5000( self, main ):
+ '''
+ Modify flow rule controller
+ '''
+
+ def CASE100( self, main ):
+ '''
+ Compare switch flow table with ONOS
+ '''
+
diff --git a/TestON/tests/FUNCflow/FUNCflow.topo b/TestON/tests/FUNCflow/FUNCflow.topo
new file mode 100755
index 0000000..cfb3fb8
--- /dev/null
+++ b/TestON/tests/FUNCflow/FUNCflow.topo
@@ -0,0 +1,65 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>localhost</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>localhost</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>localhost</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>localhost</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOScli3>
+
+ <Mininet1>
+ <host>localhost</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </Mininet1>
+
+ <ONOSrest>
+ <host>OC1</host>
+ <port>8181</port>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosRestDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSrest>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/FUNCflow/__init__.py b/TestON/tests/FUNCflow/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FUNCflow/__init__.py
diff --git a/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py b/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
index ff886a2..377fd20 100644
--- a/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
+++ b/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
@@ -153,13 +153,22 @@
" something wrong with ONOS performance" )
# Ping hosts again...
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
+ if pingTemp:
+ main.assertReturnString += 'Initial Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Initial Pingall Failed\n'
# Test rerouting if these variables exist
if sw1 and sw2 and expectedLink:
- # link down
+ # Link down
linkDownResult = link( main, sw1, sw2, "down" )
- intentResult = intentResult and checkIntentState( main, intentsId )
+
+ if linkDownResult:
+ main.assertReturnString += 'Link Down Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Failed\n'
# Check flows count in each node
checkFlowsCount( main )
@@ -168,11 +177,27 @@
# Check OnosTopology
topoResult = checkTopology( main, expectedLink )
+ if topoResult:
+ main.assertReturnString += 'Link Down Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Topology State Failed\n'
# Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
- intentResult = checkIntentState( main, intentsId )
+ if pingTemp:
+ main.assertReturnString += 'Link Down Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Pingall Failed\n'
+
+ # Check intent states
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
# Checks ONOS state in link down
if linkDownResult and topoResult and pingResult and intentResult:
@@ -180,10 +205,15 @@
else:
main.log.error( itemName + ": Failed to bring link down" )
- # link up
+ # Link up
linkUpResult = link( main, sw1, sw2, "up" )
time.sleep( main.rerouteSleep )
+ if linkUpResult:
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+
# Check flows count in each node
checkFlowsCount( main )
# Verify flows
@@ -192,10 +222,26 @@
# Check OnosTopology
topoResult = checkTopology( main, main.numLinks )
- # Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
+ if topoResult:
+ main.assertReturnString += 'Link Up Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Topology State Failed\n'
- intentResult = checkIntentState( main, intentsId )
+ # Ping hosts
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
+
+ if pingTemp:
+ main.assertReturnString += 'Link Up Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Pingall Failed\n'
+
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Up Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Intent State Failed\n'
# Checks ONOS state in link up
if linkUpResult and topoResult and pingResult and intentResult:
@@ -206,6 +252,11 @@
# Remove all intents
removeIntentResult = removeAllIntents( main, intentsId )
+ if removeIntentResult:
+ main.assertReturnString += 'Remove Intents Passed'
+ else:
+ main.assertReturnString += 'Remove Intents Failed'
+
stepResult = pingResult and linkDownResult and linkUpResult \
and intentResult and removeIntentResult
@@ -354,13 +405,22 @@
checkFlowsState( main )
# Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
+ if pingTemp:
+ main.assertReturnString += 'Initial Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Initial Pingall Failed\n'
# Test rerouting if these variables exist
if sw1 and sw2 and expectedLink:
# link down
linkDownResult = link( main, sw1, sw2, "down" )
- intentResult = intentResult and checkIntentState( main, intentsId )
+
+ if linkDownResult:
+ main.assertReturnString += 'Link Down Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Failed\n'
# Check flows count in each node
checkFlowsCount( main )
@@ -369,11 +429,26 @@
# Check OnosTopology
topoResult = checkTopology( main, expectedLink )
+ if topoResult:
+ main.assertReturnString += 'Link Down Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Topology State Failed\n'
# Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
+ if pingTemp:
+ main.assertReturnString += 'Link Down Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Pingall Failed\n'
- intentResult = checkIntentState( main, intentsId )
+ # Check intent state
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
# Checks ONOS state in link down
if linkDownResult and topoResult and pingResult and intentResult:
@@ -383,6 +458,11 @@
# link up
linkUpResult = link( main, sw1, sw2, "up" )
+ if linkUpResult:
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+
time.sleep( main.rerouteSleep )
# Check flows count in each node
@@ -392,11 +472,26 @@
# Check OnosTopology
topoResult = checkTopology( main, main.numLinks )
+ if topoResult:
+ main.assertReturnString += 'Link Up Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Topology State Failed\n'
# Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
- intentResult = checkIntentState( main, intentsId )
+ if pingTemp:
+ main.assertReturnString += 'Link Up Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Pingall Failed\n'
+
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Up Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Intent State Failed\n'
# Checks ONOS state in link up
if linkUpResult and topoResult and pingResult and intentResult:
@@ -406,6 +501,10 @@
# Remove all intents
removeIntentResult = removeAllIntents( main, intentsId )
+ if removeIntentResult:
+ main.assertReturnString += 'Remove Intents Passed'
+ else:
+ main.assertReturnString += 'Remove Intents Failed'
stepResult = pingResult and linkDownResult and linkUpResult \
and intentResult and removeIntentResult
@@ -588,14 +687,22 @@
checkFlowsState( main )
# Run iperf to both host
- iperfResult = iperfResult and main.Mininet1.iperftcp( host1,
- host2, 10 )
+ iperfTemp = main.Mininet1.iperftcp( host1,host2,10 )
+ iperfResult = iperfResult and iperfTemp
+ if iperfTemp:
+ main.assertReturnString += 'Initial Iperf Passed\n'
+ else:
+ main.assertReturnString += 'Initial Iperf Failed\n'
# Test rerouting if these variables exist
if sw1 and sw2 and expectedLink:
# link down
linkDownResult = link( main, sw1, sw2, "down" )
- intentResult = intentResult and checkIntentState( main, intentsId )
+
+ if linkDownResult:
+ main.assertReturnString += 'Link Down Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Failed\n'
# Check flows count in each node
checkFlowsCount( main )
@@ -604,12 +711,26 @@
# Check OnosTopology
topoResult = checkTopology( main, expectedLink )
+ if topoResult:
+ main.assertReturnString += 'Link Down Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Topology State Failed\n'
# Run iperf to both host
- iperfResult = iperfResult and main.Mininet1.iperftcp( host1,
- host2, 10 )
+ iperfTemp = main.Mininet1.iperftcp( host1,host2,10 )
+ iperfResult = iperfResult and iperfTemp
+ if iperfTemp:
+ main.assertReturnString += 'Link Down Iperf Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Iperf Failed\n'
- intentResult = checkIntentState( main, intentsId )
+ # Check intent state
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
# Checks ONOS state in link down
if linkDownResult and topoResult and iperfResult and intentResult:
@@ -619,6 +740,11 @@
# link up
linkUpResult = link( main, sw1, sw2, "up" )
+ if linkUpTemp:
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+
time.sleep( main.rerouteSleep )
# Check flows count in each node
@@ -629,11 +755,26 @@
# Check OnosTopology
topoResult = checkTopology( main, main.numLinks )
- # Run iperf to both host
- iperfResult = iperfResult and main.Mininet1.iperftcp( host1,
- host2, 10 )
+ if topoResult:
+ main.assertReturnString += 'Link Up Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Topology State Failed\n'
- intentResult = checkIntentState( main, intentsId )
+ # Run iperf to both host
+ iperfTemp = main.Mininet1.iperftcp( host1,host2,10 )
+ iperfResult = iperfResult and iperfTemp
+ if iperfTemp:
+ main.assertReturnString += 'Link Up Iperf Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Iperf Failed\n'
+
+ # Check intent state
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
# Checks ONOS state in link up
if linkUpResult and topoResult and iperfResult and intentResult:
@@ -643,6 +784,10 @@
# Remove all intents
removeIntentResult = removeAllIntents( main, intentsId )
+ if removeIntentResult:
+ main.assertReturnString += 'Remove Intents Passed'
+ else:
+ main.assertReturnString += 'Remove Intents Failed'
stepResult = iperfResult and linkDownResult and linkUpResult \
and intentResult and removeIntentResult
@@ -819,7 +964,7 @@
tcpDst="" ) )
# Wait some time for the flow to go through when using multi instance
- pingResult = pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
# Check intents state
time.sleep( main.checkIntentSleep )
@@ -834,13 +979,22 @@
# Verify flows
checkFlowsState( main )
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
+ if pingTemp:
+ main.assertReturnString += 'Initial Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Initial Pingall Failed\n'
# Test rerouting if these variables exist
if sw1 and sw2 and expectedLink:
# link down
linkDownResult = link( main, sw1, sw2, "down" )
- intentResult = intentResult and checkIntentState( main, intentsId )
+
+ if linkDownResult:
+ main.assertReturnString += 'Link Down Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Failed\n'
# Check flows count in each node
checkFlowsCount( main )
@@ -849,11 +1003,26 @@
# Check OnosTopology
topoResult = checkTopology( main, expectedLink )
+ if topoResult:
+ main.assertReturnString += 'Link Down Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Topology State Failed\n'
# Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
+ if pingTemp:
+ main.assertReturnString += 'Link Down Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Pingall Failed\n'
- intentResult = checkIntentState( main, intentsId )
+ # Check intent state
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
# Checks ONOS state in link down
if linkDownResult and topoResult and pingResult and intentResult:
@@ -863,6 +1032,11 @@
# link up
linkUpResult = link( main, sw1, sw2, "up" )
+ if linkUpResult:
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+
time.sleep( main.rerouteSleep )
# Check flows count in each node
@@ -872,11 +1046,26 @@
# Check OnosTopology
topoResult = checkTopology( main, main.numLinks )
+ if topoResult:
+ main.assertReturnString += 'Link Up Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Topology State Failed\n'
# Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
+ if pingTemp:
+ main.assertReturnString += 'Link Up Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Pingall Failed\n'
- intentResult = checkIntentState( main, intentsId )
+ # Check Intents
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Up Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Intent State Failed\n'
# Checks ONOS state in link up
if linkUpResult and topoResult and pingResult and intentResult:
@@ -886,6 +1075,10 @@
# Remove all intents
removeIntentResult = removeAllIntents( main, intentsId )
+ if removeIntentResult:
+ main.assertReturnString += 'Remove Intents Passed'
+ else:
+ main.assertReturnString += 'Remove Intents Failed'
stepResult = pingResult and linkDownResult and linkUpResult \
and intentResult and removeIntentResult
@@ -1059,7 +1252,7 @@
tcpSrc="",
tcpDst="" ) )
- pingResult = pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
# Check intents state
time.sleep( main.checkIntentSleep )
@@ -1075,15 +1268,25 @@
checkFlowsState( main )
# Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+
# Ping hosts again...
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
+ if pingTemp:
+ main.assertReturnString += 'Initial Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Initial Pingall Failed\n'
# Test rerouting if these variables exist
if sw1 and sw2 and expectedLink:
# link down
linkDownResult = link( main, sw1, sw2, "down" )
- intentResult = intentResult and checkIntentState( main, intentsId )
+
+ if linkDownResult:
+ main.assertReturnString += 'Link Down Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Failed\n'
# Check flows count in each node
checkFlowsCount( main )
@@ -1092,11 +1295,26 @@
# Check OnosTopology
topoResult = checkTopology( main, expectedLink )
+ if topoResult:
+ main.assertReturnString += 'Link Down Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Topology State Failed\n'
# Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
+ if pingTemp:
+ main.assertReturnString += 'Link Down Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Pingall Failed\n'
- intentResult = checkIntentState( main, intentsId )
+ # Check intent state
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Down Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Down Intent State Failed\n'
# Checks ONOS state in link down
if linkDownResult and topoResult and pingResult and intentResult:
@@ -1106,6 +1324,11 @@
# link up
linkUpResult = link( main, sw1, sw2, "up" )
+ if linkUpResult:
+ main.assertReturnString += 'Link Up Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Failed\n'
+
time.sleep( main.rerouteSleep )
# Check flows count in each node
@@ -1115,11 +1338,26 @@
# Check OnosTopology
topoResult = checkTopology( main, main.numLinks )
+ if topoResult:
+ main.assertReturnString += 'Link Up Topology State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Topology State Failed\n'
# Ping hosts
- pingResult = pingResult and pingallHosts( main, hostNames )
+ pingTemp = pingallHosts( main, hostNames )
+ pingResult = pingResult and pingTemp
+ if pingTemp:
+ main.assertReturnString += 'Link Up Pingall Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Pingall Failed\n'
- intentResult = checkIntentState( main, intentsId )
+ # Check Intents
+ intentTemp = checkIntentState( main, intentsId )
+ intentResult = intentResult and intentTemp
+ if intentTemp:
+ main.assertReturnString += 'Link Up Intent State Passed\n'
+ else:
+ main.assertReturnString += 'Link Up Intent State Failed\n'
# Checks ONOS state in link up
if linkUpResult and topoResult and pingResult and intentResult:
@@ -1129,6 +1367,10 @@
# Remove all intents
removeIntentResult = removeAllIntents( main, intentsId )
+ if removeIntentResult:
+ main.assertReturnString += 'Remove Intents Passed'
+ else:
+ main.assertReturnString += 'Remove Intents Failed'
stepResult = pingResult and linkDownResult and linkUpResult \
and intentResult and removeIntentResult
diff --git a/TestON/tests/FUNCintent/Dependency/newFuncTopo.py b/TestON/tests/FUNCintent/Dependency/newFuncTopo.py
index 5edf7f7..df808a7 100755
--- a/TestON/tests/FUNCintent/Dependency/newFuncTopo.py
+++ b/TestON/tests/FUNCintent/Dependency/newFuncTopo.py
@@ -15,19 +15,20 @@
from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
class VLANHost( Host ):
- def config( self, vlan=100, **params ):
+ def config( self, vlan=100, v6Addr='3000::1/64', **params ):
r = super( Host, self ).config( **params )
intf = self.defaultIntf()
self.cmd( 'ifconfig %s inet 0' % intf )
self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+ self.cmd( 'ip -6 addr add %s dev %s.%d' % ( v6Addr, intf, vlan ) )
newName = '%s.%d' % ( intf, vlan )
intf.name = newName
self.nameToIntf[ newName ] = intf
return r
class IPv6Host( Host ):
- def config( self, v6Addr='1000:1/64', **params ):
+ def config( self, v6Addr='1000::1/64', **params ):
r = super( Host, self ).config( **params )
intf = self.defaultIntf()
self.cmd( 'ifconfig %s inet 0' % intf )
@@ -47,42 +48,51 @@
# Initialize topology
Topo.__init__( self )
# Switch S5 Hosts
+ # IPv4 only Host
host1=self.addHost( 'h1', ip='10.1.0.2/24' )
+ # IPv6 only Host
host2=self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
+ # Dual Stack Host
host3=self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
- #VLAN hosts
- host4=self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100 )
- host5=self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
+ # VLAN hosts
+ host4=self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100, v6Addr='3000::2/64' )
+ host5=self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200, v6Addr='4000::2/64' )
+ # VPN-1 and VPN-2 Hosts
host6=self.addHost( 'h6', ip='11.1.0.2/24' )
host7=self.addHost( 'h7', ip='12.1.0.2/24' )
- #Multicast Sender
+ # Multicast Sender
host8=self.addHost( 'h8', ip='10.1.0.4/24' )
# Switch S6 Hosts
+ # IPv4 only Host
host9=self.addHost( 'h9', ip='10.1.0.5/24' )
+ # IPv6 only Host
host10=self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
+ # Dual Stack Host
host11=self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
- #VLAN hosts
- host12=self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100 )
- host13=self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
+ # VLAN hosts
+ host12=self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100, v6Addr='3000::3/64' )
+ host13=self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200, v6Addr='4000::3/64' )
+ # VPN-1 and VPN-2 Hosts
host14=self.addHost( 'h14', ip='11.1.0.3/24' )
host15=self.addHost( 'h15', ip='12.1.0.3/24' )
- #Multicast Receiver
+ # Multicast Receiver
host16=self.addHost( 'h16', ip='10.1.0.7/24' )
# Switch S7 Hosts
+ # IPv4 only Host
host17=self.addHost( 'h17', ip='10.1.0.8/24' )
+ # IPv6 only Host
host18=self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
+ # Dual Stack Host
host19=self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
- #VLAN hosts
- host20=self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100 )
- host21=self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
+ # VLAN hosts
+ host20=self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100, v6Addr='3000::4/64' )
+ host21=self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200, v6Addr='4000::4/64' )
+ # VPN-1 and VPN-2 Hosts
host22=self.addHost( 'h22', ip='11.1.0.4/24' )
host23=self.addHost( 'h23', ip='12.1.0.4/24' )
- #Multicast Receiver
+ # Multicast Receiver
host24=self.addHost( 'h24', ip='10.1.0.10/24' )
s1 = self.addSwitch( 's1' )
diff --git a/TestON/tests/FUNCintent/FUNCintent.py b/TestON/tests/FUNCintent/FUNCintent.py
index 4dab42c..483b2b4 100644
--- a/TestON/tests/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNCintent/FUNCintent.py
@@ -56,6 +56,7 @@
main.hostsData = {}
main.CLIs = []
main.ONOSip = []
+ main.assertReturnString = '' # Assembled assert return string
main.ONOSip = main.ONOSbench.getOnosIps()
print main.ONOSip
@@ -454,6 +455,7 @@
"to controller",
onfail="Failed to assign switches to " +
"controller" )
+
def CASE13( self, main ):
"""
Discover all hosts and store its data to a dictionary
@@ -533,6 +535,7 @@
+ " OVS running in Mininet"
main.step( "IPV4: Add host intents between h1 and h9" )
+ main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
stepResult = main.TRUE
stepResult = main.intentFunction.hostIntent( main,
onosNode='0',
@@ -544,15 +547,13 @@
sw1='s5',
sw2='s2',
expectedLink=18 )
-
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="IPV4: Host intent test successful " +
- "between two IPV4 hosts",
- onfail="IPV4: Host intent test failed " +
- "between two IPV4 hosts")
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString)
main.step( "DUALSTACK1: Add host intents between h3 and h11" )
+ main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
stepResult = main.TRUE
stepResult = main.intentFunction.hostIntent( main,
name='DUALSTACK',
@@ -566,15 +567,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="DUALSTACK: Host intent test " +
- "successful between two " +
- "dual stack host using IPV4",
- onfail="DUALSTACK: Host intent test " +
- "failed between two" +
- "dual stack host using IPV4" )
-
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "DUALSTACK2: Add host intents between h1 and h11" )
+ main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
stepResult = main.TRUE
stepResult = main.intentFunction.hostIntent( main,
name='DUALSTACK2',
@@ -586,14 +583,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="DUALSTACK2: Host intent test " +
- "successful between two " +
- "dual stack host using IPV4",
- onfail="DUALSTACK2: Host intent test " +
- "failed between two" +
- "dual stack host using IPV4" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "1HOP: Add host intents between h1 and h3" )
+ main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
stepResult = main.TRUE
stepResult = main.intentFunction.hostIntent( main,
name='1HOP',
@@ -602,14 +596,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="1HOP: Host intent test " +
- "successful between two " +
- "host using IPV4 in the same switch",
- onfail="1HOP: Host intent test " +
- "failed between two" +
- "host using IPV4 in the same switch" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "VLAN1: Add vlan host intents between h4 and h12" )
+ main.assertReturnString = "Assertion Result vlan IPV4\n"
stepResult = main.TRUE
stepResult = main.intentFunction.hostIntent( main,
name='VLAN1',
@@ -623,14 +614,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="VLAN1: Host intent test " +
- "successful between two " +
- "host using IPV4 in the same VLAN",
- onfail="VLAN1: Host intent test " +
- "failed between two" +
- "host using IPV4 in the same VLAN" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
+ main.assertReturnString = "Assertion Result different VLAN negative test\n"
stepResult = main.TRUE
stepResult = main.intentFunction.hostIntent( main,
name='VLAN2',
@@ -639,12 +627,8 @@
utilities.assert_equals( expect=main.FALSE,
actual=stepResult,
- onpass="VLAN2: Host intent negative test " +
- "successful between two " +
- "host using IPV4 in different VLAN",
- onfail="VLAN2: Host intent negative test " +
- "failed between two" +
- "host using IPV4 in different VLAN" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
@@ -697,6 +681,7 @@
# No option point intents
main.step( "NOOPTION: Add point intents between h1 and h9" )
+ main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
stepResult = main.TRUE
stepResult = main.intentFunction.pointIntent(
main,
@@ -711,13 +696,12 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="NOOPTION: Point intent test " +
- "successful using no match action",
- onfail="NOOPTION: Point intent test " +
- "failed using no match action" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
stepResult = main.TRUE
main.step( "IPV4: Add point intents between h1 and h9" )
+ main.assertReturnString = "Assertion Result for IPV4 point intent\n"
stepResult = main.intentFunction.pointIntent(
main,
name="IPV4",
@@ -743,14 +727,10 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="IPV4: Point intent test " +
- "successful using IPV4 type with " +
- "MAC addresses",
- onfail="IPV4: Point intent test " +
- "failed using IPV4 type with " +
- "MAC addresses" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "IPV4_2: Add point intents between h1 and h9" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
stepResult = main.intentFunction.pointIntent(
main,
name="IPV4_2",
@@ -769,15 +749,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="IPV4_2: Point intent test " +
- "successful using IPV4 type with " +
- "no MAC addresses",
- onfail="IPV4_2: Point intent test " +
- "failed using IPV4 type with " +
- "no MAC addresses" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
mac1 = main.hostsData[ 'h1' ][ 'mac' ]
mac2 = main.hostsData[ 'h9' ][ 'mac' ]
try:
@@ -810,15 +786,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="SDNIP-ICMP: Point intent test " +
- "successful using IPV4 type with " +
- "IP protocol TCP enabled",
- onfail="SDNIP-ICMP: Point intent test " +
- "failed using IPV4 type with " +
- "IP protocol TCP enabled" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
mac1 = main.hostsData[ 'h1' ][ 'mac' ]
mac2 = main.hostsData[ 'h9' ][ 'mac' ]
ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
@@ -845,15 +817,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="SDNIP-TCP: Point intent test " +
- "successful using IPV4 type with " +
- "IP protocol ICMP enabled",
- onfail="SDNIP-TCP: Point intent test " +
- "failed using IPV4 type with " +
- "IP protocol ICMP enabled" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
- main.step( "DUALSTACK1: Add point intents between h1 and h9" )
- stepResult = main.TRUE
+ main.step( "DUALSTACK1: Add point intents between h3 and h11" )
+ main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
stepResult = main.intentFunction.pointIntent(
main,
name="DUALSTACK1",
@@ -879,15 +847,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="DUALSTACK1: Point intent test " +
- "successful using IPV4 type with " +
- "MAC addresses",
- onfail="DUALSTACK1: Point intent test " +
- "failed using IPV4 type with " +
- "MAC addresses" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "VLAN: Add point intents between h5 and h21" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
stepResult = main.intentFunction.pointIntent(
main,
name="VLAN",
@@ -913,15 +877,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="VLAN1: Point intent test " +
- "successful using IPV4 type with " +
- "MAC addresses",
- onfail="VLAN1: Point intent test " +
- "failed using IPV4 type with " +
- "MAC addresses" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "1HOP: Add point intents between h1 and h3" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
stepResult = main.intentFunction.hostIntent( main,
name='1HOP',
host1='h1',
@@ -929,12 +889,8 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="1HOP: Point intent test " +
- "successful using IPV4 type with " +
- "no MAC addresses",
- onfail="1HOP: Point intent test " +
- "failed using IPV4 type with " +
- "no MAC addresses" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.intentFunction.report( main )
@@ -1006,7 +962,7 @@
# " with no match action" )
main.step( "IPV4: Add single point to multi point intents" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
stepResult = main.intentFunction.singleToMultiIntent(
main,
name="IPV4",
@@ -1026,15 +982,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="IPV4: Successfully added single "
- + " point to multi point intents" +
- " with IPV4 type and MAC addresses",
- onfail="IPV4: Failed to add single point"
- + " point to multi point intents" +
- " with IPV4 type and MAC addresses" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "IPV4_2: Add single point to multi point intents" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and no MAC addresses\n"
hostNames = [ 'h8', 'h16', 'h24' ]
stepResult = main.intentFunction.singleToMultiIntent(
main,
@@ -1045,15 +997,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="IPV4_2: Successfully added single "
- + " point to multi point intents" +
- " with IPV4 type and no MAC addresses",
- onfail="IPV4_2: Failed to add single point"
- + " point to multi point intents" +
- " with IPV4 type and no MAC addresses" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "VLAN: Add single point to multi point intents" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses in the same VLAN\n"
hostNames = [ 'h4', 'h12', 'h20' ]
devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
'of:0000000000000007/4' ]
@@ -1077,14 +1025,8 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="VLAN: Successfully added single "
- + " point to multi point intents" +
- " with IPV4 type and MAC addresses" +
- " in the same VLAN",
- onfail="VLAN: Failed to add single point"
- + " point to multi point intents" +
- " with IPV4 type and MAC addresses" +
- " in the same VLAN")
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.intentFunction.report( main )
@@ -1156,7 +1098,7 @@
# " with no match action" )
main.step( "IPV4: Add multi point to single point intents" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and MAC addresses\n"
stepResult = main.intentFunction.multiToSingleIntent(
main,
name="IPV4",
@@ -1176,15 +1118,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="IPV4: Successfully added multi point"
- + " to single point intents" +
- " with IPV4 type and MAC addresses",
- onfail="IPV4: Failed to add multi point" +
- " to single point intents" +
- " with IPV4 type and MAC addresses" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "IPV4_2: Add multi point to single point intents" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses\n"
hostNames = [ 'h8', 'h16', 'h24' ]
stepResult = main.intentFunction.multiToSingleIntent(
main,
@@ -1195,15 +1133,11 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="IPV4_2: Successfully added multi point"
- + " to single point intents" +
- " with IPV4 type and no MAC addresses",
- onfail="IPV4_2: Failed to add multi point" +
- " to single point intents" +
- " with IPV4 type and no MAC addresses" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.step( "VLAN: Add multi point to single point intents" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses in the same VLAN\n"
hostNames = [ 'h5', 'h13', 'h21' ]
devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
'of:0000000000000007/5' ]
@@ -1227,16 +1161,13 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="VLAN: Successfully added multi point"
- + " to single point intents" +
- " with IPV4 type and MAC addresses" +
- " in the same VLAN",
- onfail="VLAN: Failed to add multi point" +
- " to single point intents" )
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
def CASE5000( self, main ):
"""
- Will add description in next patch set
+ Tests Host Mobility
+ Modifies the topology location of h1
"""
assert main, "There is no main"
assert main.CLIs, "There is no main.CLIs"
@@ -1257,13 +1188,13 @@
utilities.assert_equals( expect="of:0000000000000006",
actual=h1PostMove,
onpass="Mobility: Successfully moved h1 to s6",
- onfail="Mobility: Failed to moved h1 to s6" +
+ onfail="Mobility: Failed to move h1 to s6" +
" to single point intents" +
" with IPV4 type and MAC addresses" +
" in the same VLAN" )
main.step( "IPV4: Add host intents between h1 and h9" )
- stepResult = main.TRUE
+ main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
stepResult = main.intentFunction.hostIntent( main,
onosNode='0',
name='IPV4',
@@ -1274,9 +1205,7 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="IPV4: Host intent test successful " +
- "between two IPV4 hosts",
- onfail="IPV4: Host intent test failed " +
- "between two IPV4 hosts")
+ onpass=main.assertReturnString,
+ onfail=main.assertReturnString )
main.intentFunction.report( main )
diff --git a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
index 7577d49..4bbc0bb 100644
--- a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
+++ b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
@@ -404,12 +404,12 @@
Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
'GET', None, None )
utilities.assert_equals(
- expect='The tenantNetwork does not exists',
+ expect='Network is not found',
actual=result,
onpass="Get Success",
onfail="Get Failed " + str( Getstatus ) + str( result ) )
- if result != 'The tenantNetwork does not exists':
+ if result != 'Network is not found':
main.log.error( "Delete Network failed" )
def CASE5( self, main ):
@@ -675,12 +675,12 @@
Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
'GET', None, None )
utilities.assert_equals(
- expect='The subnet does not exists',
+ expect='Subnet is not found',
actual=result,
onpass="Get Subnet Success",
onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
- if result != 'The subnet does not exists':
+ if result != 'Subnet is not found':
main.log.error( "Delete Subnet failed" )
def CASE8( self, main ):
@@ -998,12 +998,12 @@
Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
'GET', None, None )
utilities.assert_equals(
- expect='The virtualPort does not exists',
+ expect='VirtualPort is not found',
actual=result,
onpass="Get Port Success",
onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
- if result != 'The virtualPort does not exists':
+ if result != 'VirtualPort is not found':
main.log.error( "Delete Port failed" )
main.step( "Clean Data via HTTP" )
diff --git a/TestON/tests/HAclusterRestart/HAclusterRestart.params b/TestON/tests/HAclusterRestart/HAclusterRestart.params
index f10636e..4626c39 100644
--- a/TestON/tests/HAclusterRestart/HAclusterRestart.params
+++ b/TestON/tests/HAclusterRestart/HAclusterRestart.params
@@ -40,7 +40,7 @@
<port7>6653</port7>
</CTRL>
<BACKUP>
- <ENABLED>True</ENABLED>
+ <ENABLED>False</ENABLED>
<TESTONUSER>admin</TESTONUSER>
<TESTONIP>10.128.30.9</TESTONIP>
</BACKUP>
diff --git a/TestON/tests/HAminorityRestart/HAminorityRestart.py b/TestON/tests/HAminorityRestart/HAminorityRestart.py
index d175fd7..ca8a194 100644
--- a/TestON/tests/HAminorityRestart/HAminorityRestart.py
+++ b/TestON/tests/HAminorityRestart/HAminorityRestart.py
@@ -48,6 +48,7 @@
start tcpdump
"""
import imp
+ import pexpect
main.log.info( "ONOS HA test: Restart minority of ONOS nodes - " +
"initialization" )
main.case( "Setting up test environment" )
@@ -189,6 +190,16 @@
main.log.wiki(graphs)
main.step( "Creating ONOS package" )
+ # copy gen-partions file to ONOS
+ # NOTE: this assumes TestON and ONOS are on the same machine
+ srcFile = main.testDir + "/" + main.TEST + "/dependencies/onos-gen-partitions"
+ dstDir = main.ONOSbench.home + "/tools/test/bin/onos-gen-partitions"
+ cpResult = main.ONOSbench.secureCopy( main.ONOSbench.user_name,
+ main.ONOSbench.ip_address,
+ srcFile,
+ dstDir,
+ pwd=main.ONOSbench.pwd,
+ direction="from" )
packageResult = main.ONOSbench.onosPackage()
utilities.assert_equals( expect=main.TRUE, actual=packageResult,
onpass="ONOS package successful",
@@ -203,6 +214,19 @@
utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
onpass="ONOS install successful",
onfail="ONOS install failed" )
+ # clean up gen-partitions file
+ try:
+ main.ONOSbench.handle.sendline( "cd " + main.ONOSbench.home )
+ main.ONOSbench.handle.expect( main.ONOSbench.home + "\$" )
+ main.ONOSbench.handle.sendline( "git checkout -- tools/test/bin/onos-gen-partitions" )
+ main.ONOSbench.handle.expect( main.ONOSbench.home + "\$" )
+ main.log.info( " Cleaning custom gen partitions file, response was: \n" +
+ str( main.ONOSbench.handle.before ) )
+ except ( pexpect.TIMEOUT, pexpect.EOF ):
+ main.log.exception( "ONOSbench: pexpect exception found:" +
+ main.ONOSbench.handle.before )
+ main.cleanup()
+ main.exit()
main.step( "Checking if ONOS is up yet" )
for i in range( 2 ):
@@ -1680,17 +1704,19 @@
main.log.debug( "Checking logs for errors on " + node.name + ":" )
main.log.warn( main.ONOSbench.checkLogs( node.ip_address ) )
- main.step( "Killing 3 ONOS nodes" )
+ n = len( main.nodes ) # Number of nodes
+ p = ( ( n + 1 ) / 2 ) + 1 # Number of partitions
+ main.kill = [ 0 ] # ONOS node to kill, listed by index in main.nodes
+ if n > 3:
+ main.kill.append( p - 1 )
+ # NOTE: This only works for cluster sizes of 3,5, or 7.
+
+ main.step( "Killing " + str( len( main.kill ) ) + " ONOS nodes" )
killTime = time.time()
- # TODO: Randomize these nodes or base this on partitions
- # TODO: use threads in this case
- killResults = main.ONOSbench.onosKill( main.nodes[0].ip_address )
- time.sleep( 10 )
- killResults = killResults and\
- main.ONOSbench.onosKill( main.nodes[1].ip_address )
- time.sleep( 10 )
- killResults = killResults and\
- main.ONOSbench.onosKill( main.nodes[2].ip_address )
+ killResults = main.TRUE
+ for i in main.kill:
+ killResults = killResults and\
+ main.ONOSbench.onosKill( main.nodes[i].ip_address )
utilities.assert_equals( expect=main.TRUE, actual=killResults,
onpass="ONOS Killed successfully",
onfail="ONOS kill NOT successful" )
@@ -1699,21 +1725,20 @@
count = 0
onosIsupResult = main.FALSE
while onosIsupResult == main.FALSE and count < 10:
- onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
- onos2Isup = main.ONOSbench.isup( main.nodes[1].ip_address )
- onos3Isup = main.ONOSbench.isup( main.nodes[2].ip_address )
- onosIsupResult = onos1Isup and onos2Isup and onos3Isup
+ onosIsupResult = main.TRUE
+ for i in main.kill:
+ onosIsupResult = onosIsupResult and\
+ main.ONOSbench.isup( main.nodes[i].ip_address )
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" )
main.step( "Restarting ONOS main.CLIs" )
- cliResult1 = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
- cliResult2 = main.ONOScli2.startOnosCli( main.nodes[1].ip_address )
- cliResult3 = main.ONOScli3.startOnosCli( main.nodes[2].ip_address )
- cliResults = cliResult1 and cliResult2 and cliResult3
+ cliResults = main.TRUE
+ for i in main.kill:
+ cliResults = cliResults and\
+ main.CLIs[i].startOnosCli( main.nodes[i].ip_address )
utilities.assert_equals( expect=main.TRUE, actual=cliResults,
onpass="ONOS cli restarted",
onfail="ONOS cli did not restart" )
@@ -1722,17 +1747,6 @@
# 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 = main.CLIs[0].electionTestRun()
- run2 = main.CLIs[1].electionTestRun()
- run3 = main.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( main.CLIs[0].nodes( jsonFormat=False ) )
@@ -2052,11 +2066,12 @@
main.step( "Leadership Election is still functional" )
# Test of LeadershipElection
leaderList = []
- # FIXME: make sure this matches nodes that were restarted
- restarted = [ main.nodes[0].ip_address, main.nodes[1].ip_address,
- main.nodes[2].ip_address ]
+ restarted = []
+ for i in main.kill:
+ restarted.append( main.nodes[i].ip_address )
leaderResult = main.TRUE
+
for cli in main.CLIs:
leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
@@ -3409,23 +3424,7 @@
onfail="Added counters are incorrect" )
main.step( "Check counters are consistant across nodes" )
- onosCounters = []
- threads = []
- for i in range( main.numCtrls ):
- t = main.Thread( target=main.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
+ onosCounters, consistentCounterResults = main.Counters.consistentCheck()
utilities.assert_equals( expect=main.TRUE,
actual=consistentCounterResults,
onpass="ONOS counters are consistent " +
@@ -3441,7 +3440,6 @@
actual=incrementCheck,
onpass="Added counters are correct",
onfail="Added counters are incorrect" )
-
# DISTRIBUTED SETS
main.step( "Distributed Set get" )
size = len( onosSet )
diff --git a/TestON/tests/HAminorityRestart/README b/TestON/tests/HAminorityRestart/README
new file mode 100644
index 0000000..a913f85
--- /dev/null
+++ b/TestON/tests/HAminorityRestart/README
@@ -0,0 +1,24 @@
+This test is designed to verify that an ONOS cluster behaves correctly when
+ONOS nodes die. Currently, we will kill nodes so that each raft partition will
+lose a member, but we make sure that there is always a majority of nodes
+available in each partition.
+
+As written, the test only supports an ONOS cluster of 3,5, or 7 nodes.
+This is because the test doesn't apply to a single node cluster, ONOS clusters
+should be deployed in odd numbers, and the partition generation and node
+killing scheme used doesn't give the same properties for clusters of more
+than 7 nodes. Namely, each partition won't have exactly one node killed.
+
+The gerneral structure for the test:
+- Startup
+- Assign switches
+- Verify ONOS state and functionality
+ - Device mastership
+ - Intents
+ - Leadership election
+ - Distributed Primitives
+- Kill some ONOS nodes
+- Verify ONOS state and functionality
+- Dataplane failures
+ - link down and up
+ - switch down and up
diff --git a/TestON/tests/HAminorityRestart/dependencies/Counters.py b/TestON/tests/HAminorityRestart/dependencies/Counters.py
index 21308c2..6614887 100644
--- a/TestON/tests/HAminorityRestart/dependencies/Counters.py
+++ b/TestON/tests/HAminorityRestart/dependencies/Counters.py
@@ -1,14 +1,19 @@
def __init__( self ):
self.default = ''
-def counterCheck( counterName, counterValue ):
+def consistentCheck():
"""
- Add Text here
+ Checks that TestON counters are consistent across all nodes.
+
+ Returns the tuple (onosCounters, consistent)
+ - onosCounters is the parsed json output of the counters command on all nodes
+ - consistent is main.TRUE if all "TestON" counters are consitent across all
+ nodes or main.FALSE
"""
import json
correctResults = main.TRUE
# Get onos counters results
- onosCounters = []
+ onosCountersRaw = []
threads = []
for i in range( main.numCtrls ):
t = main.Thread( target=main.CLIs[i].counters,
@@ -17,25 +22,58 @@
t.start()
for t in threads:
t.join()
- onosCounters.append( t.result )
- tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
+ onosCountersRaw.append( t.result )
+ onosCounters = []
+ for i in range( main.numCtrls ):
+ try:
+ onosCounters.append( json.loads( onosCountersRaw[i] ) )
+ except ( ValueError, TypeError ):
+ main.log.error( "Could not parse counters response from ONOS" +
+ str( i + 1 ) )
+ main.log.warn( repr( onosCountersRaw[ i ] ) )
+ return main.FALSE
+
+ testCounters = {}
+ # make a list of all the "TestON-*" counters in ONOS
+ # lookes like a dict whose keys are the name of the ONOS node and values
+ # are a list of the counters. I.E.
+ # { "ONOS1": [ {"name":"TestON-inMemory","value":56},
+ # {"name":"TestON-Partitions","value":56} ]
+ # }
+ # NOTE: There is an assumtion that all nodes are active
+ # based on the above for loops
+ for controller in enumerate( onosCounters ):
+ for dbType in controller[1]:
+ for dbName, items in dbType.iteritems():
+ for item in items:
+ if 'TestON' in item['name']:
+ node = 'ONOS' + str( controller[0] + 1 )
+ try:
+ testCounters[node].append( item )
+ except KeyError:
+ testCounters[node] = [ item ]
+ # compare the counters on each node
+ tmp = [ v == testCounters['ONOS1'] for k, v in testCounters.iteritems() ]
if all( tmp ):
consistent = main.TRUE
else:
consistent = main.FALSE
- main.log.error( "ONOS nodes have different values for counters" )
- for node in onosCounters:
- main.log.debug( node )
+ main.log.error( "ONOS nodes have different values for counters:\n" +
+ testCounters )
+ return ( onosCounters, consistent )
+def counterCheck( counterName, counterValue ):
+ """
+ Checks that TestON counters are consistent across all nodes and that
+ specified counter is in ONOS with the given value
+ """
+ import json
+ correctResults = main.TRUE
+ # Get onos counters results and consistentCheck
+ onosCounters, consistent = main.Counters.consistentCheck()
# Check for correct values
for i in range( main.numCtrls ):
- try:
- current = json.loads( onosCounters[i] )
- except ( ValueError, TypeError ):
- main.log.error( "Could not parse counters response from ONOS" +
- str( i + 1 ) )
- main.log.warn( repr( onosCounters[ i ] ) )
- return main.FALSE
+ current = onosCounters[i]
onosValue = None
try:
for database in current:
diff --git a/TestON/tests/HAminorityRestart/dependencies/onos-gen-partitions b/TestON/tests/HAminorityRestart/dependencies/onos-gen-partitions
new file mode 100755
index 0000000..bf9a77b
--- /dev/null
+++ b/TestON/tests/HAminorityRestart/dependencies/onos-gen-partitions
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+'''
+ Generate the partitions json file from the $OC* environment variables
+
+ Usage: onos-gen-partitions [output file]
+ If output file is not provided, the json is written to stdout.
+'''
+
+from os import environ
+from collections import deque, OrderedDict
+import re
+import json
+import sys
+
+convert = lambda text: int(text) if text.isdigit() else text.lower()
+alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
+
+def get_OC_vars():
+ vars = []
+ for var in environ:
+ if re.match(r"OC[0-9]+", var):
+ vars.append(var)
+ return sorted(vars, key=alphanum_key)
+
+def get_nodes(vars, port=9876):
+ node = lambda k: { 'id': k, 'ip': k, 'tcpPort': port }
+ return [ node(environ[v]) for v in vars ]
+
+def generate_permutations(nodes, k):
+ l = deque(nodes)
+ perms = {}
+ for i in range(1, len(nodes)+1):
+ perms['p%d' % i] = list(l)[:k]
+ l.rotate(-1)
+ return OrderedDict(sorted(perms.iteritems(), key=lambda (k, v): alphanum_key(k)))
+
+def generate_permutations2(nodes, k):
+ l = deque(nodes)
+ perms = {}
+ for i in range(1, (len(nodes) + 1) / 2 + 1):
+ perms['p%d' % i] = list(l)[:k]
+ l.rotate(-2)
+ return OrderedDict(sorted(perms.iteritems(), key=lambda (k, v): alphanum_key(k)))
+
+
+if __name__ == '__main__':
+ vars = get_OC_vars()
+ nodes = get_nodes(vars)
+ partitions = generate_permutations2(nodes, 3)
+ data = {
+ 'nodes': nodes,
+ 'partitions': partitions
+ }
+ output = json.dumps(data, indent=4)
+
+ if len(sys.argv) == 2:
+ filename = sys.argv[1]
+ with open(filename, 'w') as f:
+ f.write(output)
+ else:
+ print output
diff --git a/TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py b/TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py
index 0f25012..ddd8c1e 100644
--- a/TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py
+++ b/TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py
@@ -9,8 +9,8 @@
main.log.info( routeNumActual )
utilities.assertEquals( \
expect = routeNumExpected, actual = routeNumActual,
- onpass = "***Route number is correct!***",
- onfail = "***Route number is wrong!***" )
+ onpass = "Route number is correct!",
+ onfail = "Route number is wrong!" )
def checkM2SintentNum( main, intentNumExpected ):
main.step( "Check M2S intents installed" )
@@ -23,8 +23,8 @@
main.log.info( intentNumActual )
utilities.assertEquals( \
expect = intentNumExpected, actual = intentNumActual,
- onpass = "***M2S intent number is correct!***",
- onfail = "***M2S intent number is wrong!***" )
+ onpass = "M2S intent number is correct!",
+ onfail = "M2S intent number is wrong!" )
def checkP2PintentNum( main, intentNumExpected ):
main.step( "Check P2P intents installed" )
@@ -37,8 +37,8 @@
main.log.info( intentNumActual )
utilities.assertEquals( \
expect = intentNumExpected, actual = intentNumActual,
- onpass = "***P2P intent number is correct!***",
- onfail = "***P2P intent number is wrong!***" )
+ onpass = "P2P intent number is correct!",
+ onfail = "P2P intent number is wrong!" )
def checkFlowNum( main, switch, flowNumExpected ):
main.step( "Check flow entry number in " + switch )
@@ -49,8 +49,8 @@
main.log.info( flowNumActual )
utilities.assertEquals( \
expect = flowNumExpected, actual = flowNumActual,
- onpass = "***Flow number in " + switch + " is correct!***",
- onfail = "***Flow number in " + switch + " is wrong!***" )
+ onpass = "Flow number in " + switch + " is correct!",
+ onfail = "Flow number in " + switch + " is wrong!" )
def pingSpeakerToPeer( main, speakers = ["speaker1"],
@@ -74,11 +74,9 @@
main.exit()
if expectAllSuccess:
- main.step( "Check ping between BGP peers and speakers, expect all tests\
- will SUCCEED" )
+ main.step( "BGP speakers ping peers, expect all tests to succeed" )
else:
- main.step( "Check ping between BGP peers and speakers, expect all tests\
- will FAIL" )
+ main.step( "BGP speakers ping peers, expect all tests to fail" )
result = True
if expectAllSuccess:
@@ -137,7 +135,9 @@
onpass = "Ping test results are expected",
onfail = "Ping test results are Not expected" )
+ '''
if result == False:
main.cleanup()
main.exit()
+ '''
diff --git a/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params
index 5ba6b2d..a7a8f72 100644
--- a/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params
+++ b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params
@@ -14,7 +14,6 @@
</CTRL>
<GIT>
- <autoPull>on</autoPull>
<branch1>master</branch1>
<branch2>onos-1.3</branch2>
</GIT>
@@ -37,6 +36,7 @@
<timers>
<SdnIpSetup>10</SdnIpSetup>
+ <TopoDiscovery>60</TopoDiscovery>
<PingTestWithRoutes>20</PingTestWithRoutes>
<PingTestWithoutRoutes>100</PingTestWithoutRoutes>
<RouteDelivery>60</RouteDelivery>
diff --git a/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py
index 82a6ea3..41bad86 100644
--- a/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py
+++ b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py
@@ -12,7 +12,7 @@
"""
import os
import imp
- main.log.case( "This case is to setup the Mininet testbed" )
+ main.log.case( "Setup the Mininet testbed" )
main.dependencyPath = main.testDir + \
main.params[ 'DEPENDENCY' ][ 'path' ]
main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
@@ -53,18 +53,19 @@
tunnelResult = main.TRUE
tunnelResult = main.Mininet.node( "root", command )
- if not tunnelResult:
- main.log.report("Failed to create tunnel")
+ utilities.assert_equals( expect = True,
+ actual = ( "PasswordAuthentication" in tunnelResult ),
+ onpass = "Created tunnel succeeded",
+ onfail = "Create tunnel failed" )
+ if ("PasswordAuthentication" not in tunnelResult) :
main.cleanup()
main.exit()
- elif "PasswordAuthentication" in tunnelResult:
- main.log.report("Successfully created tunnel")
# This case is to setup ONOS
def CASE101( self, main ):
"""
- CASE100 is to compile ONOS and install it
+ Compile ONOS and install it
Startup sequence:
cell <name>
onos-verify-cell
@@ -84,68 +85,122 @@
main.step( "Applying cell variable to environment" )
cellResult = main.ONOSbench.setCell( cellName )
+ utilities.assert_equals( expect = main.TRUE,
+ actual = cellResult,
+ onpass = "Set cell succeeded",
+ onfail = "Set cell failed" )
+
verifyResult = main.ONOSbench.verifyCell()
+ utilities.assert_equals( expect = main.TRUE,
+ actual = verifyResult,
+ onpass = "Verify cell succeeded",
+ onfail = "Verify cell failed" )
branchName = main.ONOSbench.getBranchName()
- main.log.info( "ONOS is on branch: " + branchName )
+ main.log.report( "ONOS is on branch: " + branchName )
- main.log.report( "Uninstalling ONOS" )
- main.ONOSbench.onosUninstall( ONOS1Ip )
-
- # cleanInstallResult = main.TRUE
- # gitPullResult = main.TRUE
-
+ main.log.step( "Uninstalling ONOS" )
+ uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
+ utilities.assert_equals( expect = main.TRUE,
+ actual = uninstallResult,
+ onpass = "Uninstall ONOS succeeded",
+ onfail = "Uninstall ONOS failed" )
+ '''
main.step( "Git pull" )
gitPullResult = main.ONOSbench.gitPull()
+ main.log.info( "gitPullResult" )
+ main.log.info( gitPullResult )
+ gitPullResult2 = ( gitPullResult == main.TRUE ) or ( gitPullResult == 3 )
+ utilities.assert_equals( expect = True,
+ actual = gitPullResult2,
+ onpass = "Git pull ONOS succeeded",
+ onfail = "Git pull ONOS failed" )
main.step( "Using mvn clean install" )
if gitPullResult == main.TRUE:
- cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 )
+ mciResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 )
+ utilities.assert_equals( expect = main.TRUE,
+ actual = mciResult,
+ onpass = "Maven clean install ONOS succeeded",
+ onfail = "Maven clean install ONOS failed" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
- cleanInstallResult = main.TRUE
+ mciResult = main.TRUE
+ '''
main.ONOSbench.getVersion( report = True )
main.step( "Creating ONOS package" )
packageResult = main.ONOSbench.onosPackage( opTimeout = 500 )
+ utilities.assert_equals( expect = main.TRUE,
+ actual = packageResult,
+ onpass = "Package ONOS succeeded",
+ onfail = "Package ONOS failed" )
main.step( "Installing ONOS package" )
onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
- node = ONOS1Ip )
+ node = ONOS1Ip )
+ utilities.assert_equals( expect = main.TRUE,
+ actual = onos1InstallResult,
+ onpass = "Install ONOS succeeded",
+ onfail = "Install ONOS failed" )
main.step( "Checking if ONOS is up yet" )
- for i in range( 2 ):
- onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
- if onos1Isup:
- break
- if not onos1Isup:
- main.log.report( "ONOS1 didn't start!" )
+ onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
+ utilities.assert_equals( expect = main.TRUE,
+ actual = onos1UpResult,
+ onpass = "ONOS is up",
+ onfail = "ONOS is NOT up" )
+ main.step( "Checking if ONOS CLI is ready" )
cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
commandlineTimeout = 100, onosStartTimeout = 600 )
+ utilities.assert_equals( expect = main.TRUE,
+ actual = cliResult,
+ onpass = "ONOS CLI is ready",
+ onfail = "ONOS CLI is NOT ready" )
- caseResult = ( cleanInstallResult and packageResult and
- cellResult and verifyResult and
- onos1InstallResult and
- onos1Isup and cliResult )
+ caseResult = ( cellResult and verifyResult and
+ packageResult and
+ onos1InstallResult and onos1UpResult and cliResult )
utilities.assert_equals( expect = main.TRUE, actual = caseResult,
onpass = "ONOS startup successful",
onfail = "ONOS startup NOT successful" )
if caseResult == main.FALSE:
+ main.log.info( "ONOS startup failed!" )
main.cleanup()
main.exit()
- main.step( "Get links in the network" )
+ main.log.info( "Get links in the network" )
+ time.sleep( int ( main.params['timers']['TopoDiscovery'] ) )
+ summaryResult = main.ONOScli.summary()
+ linkNum = json.loads( summaryResult )[ "links" ]
+ if linkNum < 100:
+ main.log.info( "Link number is wrong!" )
+ listResult = main.ONOScli.links( jsonFormat = False )
+ main.log.info( listResult )
+ main.cleanup()
+ main.exit()
+
listResult = main.ONOScli.links( jsonFormat = False )
main.log.info( listResult )
- main.log.info( "Activate sdn-ip application" )
- main.ONOScli.activateApp( "org.onosproject.sdnip" )
- main.log.info( "Wait sdn-ip to finish installing connectivity intents, \
+ main.step( "Activate sdn-ip application" )
+ activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" )
+ utilities.assert_equals( expect = main.TRUE,
+ actual = activeSDNIPresult,
+ onpass = "Activate SDN-IP succeeded",
+ onfail = "Activate SDN-IP failed" )
+ if not activeSDNIPresult:
+ main.log.info( "Activate SDN-IP failed!" )
+ main.cleanup()
+ main.exit()
+
+
+ main.log.info( "Wait SDN-IP to finish installing connectivity intents \
and the BGP paths in data plane are ready..." )
time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
main.log.info( "Wait Quagga to finish delivery all routes to each \
@@ -158,7 +213,7 @@
'''
This test case is to load the methods from other Python files.
'''
- main.case( "Loading the methods from other Python file" )
+ main.case( "Loading methods from other Python file" )
# load the methods from other file
wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
main.Functions = imp.load_source( wrapperFile,
@@ -172,7 +227,7 @@
ping test from 3 bgp peers to BGP speaker
'''
- main.case( "This case is to check ping between BGP peers and speakers" )
+ main.case( "Ping tests between BGP peers and speakers" )
main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
peers = ["peer64514", "peer64515", "peer64516"],
expectAllSuccess = True )
@@ -182,10 +237,10 @@
'''
point-to-point intents test for each BGP peer and BGP speaker pair
'''
- main.case( "This case is to check point-to-point intents" )
+ main.case( "Check point-to-point intents" )
main.log.info( "There are %s BGP peers in total "
% main.params[ 'config' ][ 'peerNum' ] )
- main.step( "Get point-to-point intents from ONOS CLI" )
+ main.step( "Check P2P intents number from ONOS CLI" )
getIntentsResult = main.ONOScli.intents( jsonFormat = True )
bgpIntentsActualNum = \
@@ -198,15 +253,15 @@
utilities.assertEquals( \
expect = True,
actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
- onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***",
- onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" )
+ onpass = "PointToPointIntent Intent Num is correct!",
+ onfail = "PointToPointIntent Intent Num is wrong!" )
def CASE3( self, main ):
'''
routes and intents check to all BGP peers
'''
- main.case( "This case is to check routes and intents to all BGP peers" )
+ main.case( "Check routes and M2S intents to all BGP peers" )
allRoutesExpected = []
allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
@@ -226,10 +281,10 @@
main.log.info( allRoutesStrActual )
utilities.assertEquals( \
expect = allRoutesStrExpected, actual = allRoutesStrActual,
- onpass = "***Routes in SDN-IP are correct!***",
- onfail = "***Routes in SDN-IP are wrong!***" )
+ onpass = "Routes are correct!",
+ onfail = "Routes are wrong!" )
- main.step( "Check MultiPointToSinglePointIntent intents installed" )
+ main.step( "Check M2S intents installed" )
getIntentsResult = main.ONOScli.intents( jsonFormat = True )
routeIntentsActualNum = \
main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
@@ -242,25 +297,22 @@
utilities.assertEquals( \
expect = True,
actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
- onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
- correct!***",
- onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
- wrong!***" )
+ onpass = "MultiPointToSinglePoint Intent Num is correct!",
+ onfail = "MultiPointToSinglePoint Intent Num is wrong!" )
main.step( "Check whether all flow status are ADDED" )
utilities.assertEquals( \
expect = main.TRUE,
actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
- onpass = "***Flow status is correct!***",
- onfail = "***Flow status is wrong!***" )
+ onpass = "Flow status is correct!",
+ onfail = "Flow status is wrong!" )
def CASE4( self, main ):
'''
Ping test in data plane for each route
'''
- main.case( "This case is to check ping for each route, \
- all hosts behind BGP peers" )
+ main.case( "Ping test for each route, all hosts behind BGP peers" )
main.Functions.pingHostToHost( main,
hosts = ["host64514", "host64515", "host64516"],
expectAllSuccess = True )
@@ -271,46 +323,62 @@
Cut links to peers one by one, check routes/intents
'''
import time
- main.case( "This case is to bring down links and check routes/intents" )
+ main.case( "Bring down links and check routes/intents" )
main.step( "Bring down the link between sw32 and peer64514" )
- result = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
- OPTION = "down" )
- if result == main.TRUE:
+ linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
+ OPTION = "down" )
+ utilities.assertEquals( expect = main.TRUE,
+ actual = linkResult1,
+ onpass = "Bring down link succeeded!",
+ onfail = "Bring down link failed!" )
+
+ if linkResult1 == main.TRUE:
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
main.Functions.checkRouteNum( main, 2 )
main.Functions.checkM2SintentNum( main, 2 )
else:
- main.log.info( "Bring down link failed!!!" )
- main.exit();
+ main.log.info( "Bring down link failed!" )
+ main.cleanup()
+ main.exit()
main.step( "Bring down the link between sw8 and peer64515" )
- result = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
- OPTION = "down" )
- if result == main.TRUE:
+ linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
+ OPTION = "down" )
+ utilities.assertEquals( expect = main.TRUE,
+ actual = linkResult2,
+ onpass = "Bring down link succeeded!",
+ onfail = "Bring down link failed!" )
+ if linkResult2 == main.TRUE:
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
main.Functions.checkRouteNum( main, 1 )
main.Functions.checkM2SintentNum( main, 1 )
else:
- main.log.info( "Bring down link failed!!!" )
- main.exit();
+ main.log.info( "Bring down link failed!" )
+ main.cleanup()
+ main.exit()
main.step( "Bring down the link between sw28 and peer64516" )
- result = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
- OPTION = "down" )
- if result == main.TRUE:
+ linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
+ OPTION = "down" )
+ utilities.assertEquals( expect = main.TRUE,
+ actual = linkResult3,
+ onpass = "Bring down link succeeded!",
+ onfail = "Bring down link failed!" )
+ if linkResult3 == main.TRUE:
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
main.Functions.checkRouteNum( main, 0 )
main.Functions.checkM2SintentNum( main, 0 )
else:
- main.log.info( "Bring down link failed!!!" )
- main.exit();
+ main.log.info( "Bring down link failed!" )
+ main.cleanup()
+ main.exit()
main.step( "Check whether all flow status are ADDED" )
utilities.assertEquals( \
expect = main.TRUE,
actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
- onpass = "***Flow status is correct!***",
- onfail = "***Flow status is wrong!***" )
+ onpass = "Flow status is correct!",
+ onfail = "Flow status is wrong!" )
# Ping test
main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
@@ -326,46 +394,61 @@
Recover links to peers one by one, check routes/intents
'''
import time
- main.case( "This case is to bring up links and check routes/intents" )
+ main.case( "Bring up links and check routes/intents" )
main.step( "Bring up the link between sw32 and peer64514" )
- result = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
- OPTION = "up" )
- if result == main.TRUE:
+ linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
+ OPTION = "up" )
+ utilities.assertEquals( expect = main.TRUE,
+ actual = linkResult1,
+ onpass = "Bring up link succeeded!",
+ onfail = "Bring up link failed!" )
+ if linkResult1 == main.TRUE:
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
main.Functions.checkRouteNum( main, 1 )
main.Functions.checkM2SintentNum( main, 1 )
else:
- main.log.info( "Bring up link failed!!!" )
- main.exit();
+ main.log.info( "Bring up link failed!" )
+ main.cleanup()
+ main.exit()
main.step( "Bring up the link between sw8 and peer64515" )
- result = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
- OPTION = "up" )
- if result == main.TRUE:
+ linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
+ OPTION = "up" )
+ utilities.assertEquals( expect = main.TRUE,
+ actual = linkResult2,
+ onpass = "Bring up link succeeded!",
+ onfail = "Bring up link failed!" )
+ if linkResult2 == main.TRUE:
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
main.Functions.checkRouteNum( main, 2 )
main.Functions.checkM2SintentNum( main, 2 )
else:
- main.log.info( "Bring up link failed!!!" )
- main.exit();
+ main.log.info( "Bring up link failed!" )
+ main.cleanup()
+ main.exit()
main.step( "Bring up the link between sw28 and peer64516" )
- result = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
- OPTION = "up" )
- if result == main.TRUE:
+ linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
+ OPTION = "up" )
+ utilities.assertEquals( expect = main.TRUE,
+ actual = linkResult3,
+ onpass = "Bring up link succeeded!",
+ onfail = "Bring up link failed!" )
+ if linkResult3 == main.TRUE:
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
main.Functions.checkRouteNum( main, 3 )
main.Functions.checkM2SintentNum( main, 3 )
else:
- main.log.info( "Bring up link failed!!!" )
- main.exit();
+ main.log.info( "Bring up link failed!" )
+ main.cleanup()
+ main.exit()
main.step( "Check whether all flow status are ADDED" )
utilities.assertEquals( \
expect = main.TRUE,
actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
- onpass = "***Flow status is correct!***",
- onfail = "***Flow status is wrong!***" )
+ onpass = "Flow status is correct!",
+ onfail = "Flow status is wrong!" )
# Ping test
main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
@@ -381,18 +464,22 @@
Shut down a edge switch, check P-2-P and M-2-S intents, ping test
'''
import time
- main.case( "This case is to stop 1 edge switch,\
- check P-2-P and M-2-S intents, ping test" )
+ main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
main.step( "Stop sw32" )
result = main.Mininet.switch( SW = "sw32", OPTION = "stop" )
+ utilities.assertEquals( expect = main.TRUE, actual = result,
+ onpass = "Stopping switch succeeded!",
+ onfail = "Stopping switch failed!" )
+
if result == main.TRUE:
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
main.Functions.checkRouteNum( main, 2 )
main.Functions.checkM2SintentNum( main, 2 )
main.Functions.checkP2PintentNum( main, 12 )
else:
- main.log.info( "Stop switch failed!!!" )
- main.exit();
+ main.log.info( "Stopping switch failed!" )
+ main.cleanup()
+ main.exit()
main.step( "Check ping between hosts behind BGP peers" )
result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
@@ -428,47 +515,31 @@
utilities.assertEquals( \
expect = main.TRUE,
actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
- onpass = "***Flow status is correct!***",
- onfail = "***Flow status is wrong!***" )
-
- '''
- main.step( "Stop sw8" )
- result = main.Mininet.switch( SW = "sw8", OPTION = "stop" )
- if result == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 1 )
-
- # Note: there should be 0 M2S intent, not 1.
- main.Functions.checkM2SintentNum( main, 0 )
- main.Functions.checkP2PintentNum( main, 6 )
- else:
- main.log.info( "Stop switch failed!!!" )
- main.exit();
-
- main.step( "Stop sw28" )
- result = main.Mininet.switch( SW = "sw28", OPTION = "stop" )
- if result == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 0 )
- main.Functions.checkM2SintentNum( main, 0 )
- main.Functions.checkP2PintentNum( main, 0 )
- else:
- main.log.info( "Stop switch failed!!!" )
- main.exit();
- '''
+ onpass = "Flow status is correct!",
+ onfail = "Flow status is wrong!" )
def CASE8( self, main ):
'''
- Bring up the edge switch which was shut down in CASE7,
+ Bring up the edge switch (sw32) which was shut down in CASE7,
check P-2-P and M-2-S intents, ping test
'''
import time
- main.case( "This case is to start the switch which was shut down in CASE7,\
- check P-2-P and M-2-S intents, ping test" )
+ main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
main.step( "Start sw32" )
result1 = main.Mininet.switch( SW = "sw32", OPTION = "start" )
+ utilities.assertEquals( \
+ expect = main.TRUE,
+ actual = result1,
+ onpass = "Starting switch succeeded!",
+ onfail = "Starting switch failed!" )
+
result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
+ utilities.assertEquals( \
+ expect = main.TRUE,
+ actual = result2,
+ onpass = "Connect switch to ONOS succeeded!",
+ onfail = "Connect switch to ONOS failed!" )
if result1 and result2:
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
@@ -476,16 +547,16 @@
main.Functions.checkM2SintentNum( main, 3 )
main.Functions.checkP2PintentNum( main, 18 )
else:
- main.log.info( "Start switch failed!!!" )
+ main.log.info( "Starting switch failed!" )
main.cleanup()
- main.exit();
+ main.exit()
main.step( "Check whether all flow status are ADDED" )
utilities.assertEquals( \
expect = main.TRUE,
actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
- onpass = "***Flow status is correct!***",
- onfail = "***Flow status is wrong!***" )
+ onpass = "Flow status is correct!",
+ onfail = "Flow status is wrong!" )
# Ping test
main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
@@ -501,10 +572,10 @@
Bring down a switch in best path, check:
route number, P2P intent number, M2S intent number, ping test
'''
- main.case( "This case is to stop switch in best path, \
+ main.case( "Stop sw11 located in best path, \
check route number, P2P intent number, M2S intent number, ping test" )
- main.step( "Check the flow status before stopping sw11" )
+ main.log.info( "Check the flow number correctness before stopping sw11" )
main.Functions.checkFlowNum( main, "sw11", 13 )
main.Functions.checkFlowNum( main, "sw1", 3 )
main.Functions.checkFlowNum( main, "sw7", 3 )
@@ -514,22 +585,26 @@
main.step( "Stop sw11" )
result = main.Mininet.switch( SW = "sw11", OPTION = "stop" )
+ utilities.assertEquals( expect = main.TRUE, actual = result,
+ onpass = "Stopping switch succeeded!",
+ onfail = "Stopping switch failed!" )
if result:
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
main.Functions.checkRouteNum( main, 3 )
main.Functions.checkM2SintentNum( main, 3 )
main.Functions.checkP2PintentNum( main, 18 )
else:
- main.log.info( "Stop switch failed!!!" )
+ main.log.info( "Stopping switch failed!" )
main.cleanup()
- main.exit();
+ main.exit()
main.step( "Check whether all flow status are ADDED" )
utilities.assertEquals( \
expect = main.TRUE,
actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
- onpass = "***Flow status is correct!***",
- onfail = "***Flow status is wrong!***" )
+ onpass = "Flow status is correct!",
+ onfail = "Flow status is wrong!" )
# Ping test
main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
peers = ["peer64514", "peer64515", "peer64516"],
@@ -544,35 +619,44 @@
Bring up the switch which was stopped in CASE9, check:
route number, P2P intent number, M2S intent number, ping test
'''
- main.case( "This case is to start switch which was stopped in CASE9, \
+ main.case( "Start sw11 which was stopped in CASE9, \
check route number, P2P intent number, M2S intent number, ping test" )
+
+ main.log.info( "Check the flow status before starting sw11" )
+ main.Functions.checkFlowNum( main, "sw1", 11 )
+ main.Functions.checkFlowNum( main, "sw7", 5 )
+ main.log.info( main.Mininet.checkFlows( "sw1" ) )
+ main.log.info( main.Mininet.checkFlows( "sw7" ) )
+
main.step( "Start sw11" )
result1 = main.Mininet.switch( SW = "sw11", OPTION = "start" )
+ utilities.assertEquals( expect = main.TRUE, actual = result1,
+ onpass = "Starting switch succeeded!",
+ onfail = "Starting switch failed!" )
result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
+ utilities.assertEquals( expect = main.TRUE, actual = result2,
+ onpass = "Connect switch to ONOS succeeded!",
+ onfail = "Connect switch to ONOS failed!" )
if result1 and result2:
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
main.Functions.checkRouteNum( main, 3 )
main.Functions.checkM2SintentNum( main, 3 )
main.Functions.checkP2PintentNum( main, 18 )
- main.step( "Check the flow status after stop and start sw11" )
- main.Functions.checkFlowNum( main, "sw11", 3 )
- main.Functions.checkFlowNum( main, "sw1", 11 )
- main.Functions.checkFlowNum( main, "sw7", 5 )
- main.log.info( main.Mininet.checkFlows( "sw11" ) )
- main.log.info( main.Mininet.checkFlows( "sw1" ) )
- main.log.info( main.Mininet.checkFlows( "sw7" ) )
+ main.log.debug( main.Mininet.checkFlows( "sw11" ) )
+ main.log.debug( main.Mininet.checkFlows( "sw1" ) )
+ main.log.debug( main.Mininet.checkFlows( "sw7" ) )
else:
- main.log.info( "Start switch failed!!!" )
+ main.log.info( "Starting switch failed!" )
main.cleanup()
- main.exit();
+ main.exit()
main.step( "Check whether all flow status are ADDED" )
utilities.assertEquals( \
expect = main.TRUE,
actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
- onpass = "***Flow status is correct!***",
- onfail = "***Flow status is wrong!***" )
+ onpass = "Flow status is correct!",
+ onfail = "Flow status is wrong!" )
# Ping test
main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
peers = ["peer64514", "peer64515", "peer64516"],