Merge branch 'master' of https://github.com/opennetworkinglab/ONLabTest
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 7199280..271c0dd 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -32,6 +32,7 @@
import new
import xmldict
import importlib
+import os
module = new.module("test")
import openspeak
global path, drivers_path, core_path, tests_path,logs_path
@@ -78,8 +79,6 @@
self.testResult = "Summary"
self.stepName = ""
self.stepCache = ""
- # make this into two lists? one for step names, one for results?
- # this way, the case result could be a true AND of these results
self.EXPERIMENTAL_MODE = False
self.test_target = None
self.lastcommand = None
@@ -164,11 +163,19 @@
driverClass = getattr(driverModule, driverName)
driverObject = driverClass()
+ try:
+ self.componentDictionary[component]['host'] = os.environ[str( self.componentDictionary[component]['host'])]
+ except KeyError:
+ self.log.info("Missing OC environment variable! Using stored IPs")
+ except Exception as inst:
+ self.log.error("Uncaught exception: " + str(inst))
+
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)
+
if not connect_result:
self.log.error("Exiting form the test execution because the connecting to the "+component+" component failed.")
self.exit()
@@ -257,6 +264,8 @@
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" )
self.log.wiki( "</ul>" )
self.log.summary( self.stepCache )
self.stepCache = ""
@@ -267,27 +276,26 @@
try :
step = stepList[self.stepCount]
self.STEPRESULT = self.NORESULT
+ self.onFailMsg = "\t\tNo on fail message given"
exec code[testCaseNumber][step] in module.__dict__
self.stepCount = self.stepCount + 1
if step > 0:
self.stepCache += "\t"+str(testCaseNumber)+"."+str(step)+" "+self.stepName+" - "
if self.STEPRESULT == self.TRUE:
self.stepCache += "PASS\n"
- #self.stepCache += "PASS <ac:emoticon ac:name=\"tick\" /></li>\n"
elif self.STEPRESULT == self.FALSE:
self.stepCache += "FAIL\n"
- #self.stepCache += "FAIL <ac:emoticon ac:name=\"cross\" /></li>\n"
+ # TODO: Print the on-fail statement here
+ self.stepCache += "\t\t" + self.onFailMsg + "\n"
else:
self.stepCache += "No Result\n"
- #self.stepCache += "No Result <ac:emoticon ac:name=\"warning\" /></li>\n"
self.stepResults.append(self.STEPRESULT)
- except TypeError,e:
- print "\nException in the following section of code: " +\
- str(testCaseNumber) + "." + str(step) + ": " +\
- self.stepName
+ except StandardError as e:
+ self.log.exception( "\nException in the following section of" +
+ " code: " + str(testCaseNumber) + "." +
+ str(step) + ": " + self.stepName )
#print code[testCaseNumber][step]
self.stepCount = self.stepCount + 1
- self.log.exception(e)
self.logger.updateCaseResults(self)
#WIKI results
self.log.wiki( "<ul>" )
@@ -298,6 +306,8 @@
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" )
self.log.wiki( "</ul>" )
#summary results
self.log.summary( self.stepCache )
diff --git a/TestON/core/testparser.py b/TestON/core/testparser.py
index 37f50f0..24b1ca2 100644
--- a/TestON/core/testparser.py
+++ b/TestON/core/testparser.py
@@ -16,7 +16,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
'''
@@ -26,21 +26,21 @@
def __init__(self,testFile):
try :
testFileHandler = open(testFile, 'r')
- except IOError:
+ except IOError:
print "No such file "+testFile
sys.exit(0)
-
+
testFileList = testFileHandler.readlines()
- self.testscript = testFileList
+ self.testscript = testFileList
self.caseCode = {}
self.caseBlock = ''
self.statementsList = []
- index = 0
+ index = 0
self.statementsList = []
#initialSpaces = len(line) -len(line.lstrip())
while index < len(testFileList):
testFileList[index] = re.sub("^\s{8}|^\s{4}", "", testFileList[index])
- # Skip multiline comments
+ # Skip multiline comments
if re.match('^(\'\'\')|^(\"\"\")',testFileList[index],0) :
index = index + 1
try :
@@ -48,16 +48,15 @@
index = index + 1
except IndexError,e:
print ''
-
- # skip empty lines and single line comments
+ # skip empty lines and single line comments
elif not re.match('#|^\s*$',testFileList[index],0):
self.statementsList.append(testFileList[index])
index = index + 1
-
+
def case_code(self):
- index = 0
- statementsList = self.statementsList
+ index = 0
+ statementsList = self.statementsList
while index < len(statementsList):
#print statementsList[index]
m= re.match('def\s+CASE(\d+)',statementsList[index],0)
@@ -76,18 +75,16 @@
except IndexError,e:
#print 'IndexError'
print ''
-
self.caseCode [str(m.group(1))] = self.caseBlock
#print "Case CODE "+self.caseCode [str(m.group(1))]
index = index + 1
-
- return self.caseCode
-
+ return self.caseCode
+
def step_code(self,caseStatements):
index = 0
- step = 0
- stepCode = {}
- step_flag = False
+ step = 0
+ stepCode = {}
+ step_flag = False
while index < len(caseStatements):
m= re.match('main\.step',caseStatements[index],0)
stepBlock = ''
@@ -99,13 +96,13 @@
while i < index :
block += caseStatements[i]
i = i + 1
- stepCode[step] = block
+ stepCode[step] = block
step = step + 1
- stepBlock= stepBlock + caseStatements[index]
+ stepBlock = stepBlock + caseStatements[index]
index = index + 1
try :
while not re.match('main\.step',caseStatements[index],0) :
- stepBlock= stepBlock + caseStatements[index]
+ stepBlock = stepBlock + caseStatements[index]
if index < len(caseStatements)-1:
index = index + 1
else :
@@ -121,11 +118,10 @@
if not step_flag :
stepCode[step] = "".join(caseStatements)
return stepCode
-
+
def getStepCode(self):
case_step_code = {}
case_block = self.case_code()
-
for case in case_block :
case_step_code[case] = {}
step_block = self.step_code(case_block[case])
diff --git a/TestON/core/utilities.py b/TestON/core/utilities.py
index dda43bf..1ba403d 100644
--- a/TestON/core/utilities.py
+++ b/TestON/core/utilities.py
@@ -84,27 +84,27 @@
return result
return assertHandling
- def _assert (self,**assertParam):
+ def _assert (self,**assertParam):
'''
It will take the arguments :
- expect:'Expected output'
- actual:'Actual output'
+ expect:'Expected output'
+ actual:'Actual output'
onpass:'Action or string to be triggered or displayed respectively when the assert passed'
onfail:'Action or string to be triggered or displayed respectively when the assert failed'
not:'optional argument to specify the negation of the each assertion type'
operator:'assertion type will be defined by using operator. Like equal , greater, lesser, matches.'
-
+
It will return the assertion result.
-
+
'''
-
+
arguments = self.parse_args(["EXPECT","ACTUAL","ONPASS","ONFAIL","NOT","OPERATOR"],**assertParam)
-
+
result = 0
valuetype = ''
operation = "not "+ str(arguments["OPERATOR"]) if arguments['NOT'] and arguments['NOT'] == 1 else arguments["OPERATOR"]
operators = {'equals':{'STR':'==','NUM':'=='}, 'matches' : '=~', 'greater':'>' ,'lesser':'<'}
-
+
expectMatch = re.match('^\s*[+-]?0(e0)?\s*$', str(arguments["EXPECT"]), re.I+re.M)
if not ((not expectMatch) and (arguments["EXPECT"]==0)):
valuetype = 'NUM'
@@ -112,31 +112,30 @@
if arguments["OPERATOR"] == 'greater' or arguments["OPERATOR"] == 'lesser':
main.log.error("Numeric comparison on strings is not possibele")
return main.ERROR
-
+
valuetype = 'STR'
arguments["ACTUAL"] = str(arguments["ACTUAL"])
if arguments["OPERATOR"] != 'matches':
arguments["EXPECT"] = str(arguments["EXPECT"])
-
+
try :
opcode = operators[str(arguments["OPERATOR"])][valuetype] if arguments["OPERATOR"] == 'equals' else operators[str(arguments["OPERATOR"])]
-
+
except KeyError:
print "Key Error in assertion"
return main.FALSE
-
+
if opcode == '=~':
try:
assert re.search(str(arguments["EXPECT"]),str(arguments["ACTUAL"]))
result = main.TRUE
except AssertionError:
try :
- assert re.match(str(arguments["EXPECT"]),str(arguments["ACTUAL"]))
+ assert re.match(str(arguments["EXPECT"]),str(arguments["ACTUAL"]))
result = main.TRUE
except AssertionError:
main.log.error("Assertion Failed")
result = main.FALSE
-
else :
try:
if str(opcode)=="==":
@@ -145,27 +144,21 @@
result = main.TRUE
else :
result = main.FALSE
-
elif str(opcode) == ">":
main.log.info("Verifying the Expected is Greater than the actual or not using assert_greater")
if (ast.literal_eval(arguments["EXPECT"]) > ast.literal_eval(arguments["ACTUAL"])) :
result = main.TRUE
else :
result = main.FALSE
-
elif str(opcode) == "<":
main.log.info("Verifying the Expected is Lesser than the actual or not using assert_lesser")
if (ast.literal_eval(arguments["EXPECT"]) < ast.literal_eval(arguments["ACTUAL"])):
result = main.TRUE
else :
result = main.FALSE
-
-
except AssertionError:
main.log.error("Assertion Failed")
result = main.FALSE
-
-
result = result if result else 0
result = not result if arguments["NOT"] and arguments["NOT"] == 1 else result
resultString = ""
@@ -179,7 +172,8 @@
else :
main.log.error(arguments["ONFAIL"])
main.log.report(arguments["ONFAIL"])
-
+ main.onFailMsg = arguments[ 'ONFAIL' ]
+
msg = arguments["ON" + str(resultString)]
if not isinstance(msg,str):
@@ -190,8 +184,7 @@
main.last_result = result
return result
-
-
+
def parse_args(self,args, **kwargs):
'''
It will accept the (key,value) pair and will return the (key,value) pairs with keys in uppercase.
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index ad50b9c..57d8c9b 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -367,6 +367,64 @@
main.log.info( self.name + ": \n---\n" + response )
return main.FALSE
+ def pingallHosts( self, hostList, pingType='ipv4' ):
+ """
+ Ping all specified hosts with a specific ping type
+
+ Acceptable pingTypes:
+ - 'ipv4'
+ - 'ipv6'
+
+ Acceptable hostList:
+ - ['h1','h2','h3','h4']
+
+ Returns main.TRUE if all hosts specified can reach
+ each other
+
+ Returns main.FALSE if one or more of hosts specified
+ cannot reach each other"""
+
+ if pingType == "ipv4":
+ cmd = " ping -c 1 -i 1 -W 8 "
+ elif pingType == "ipv6":
+ cmd = " ping6 -c 1 -i 1 -W 8 "
+ else:
+ main.log.warn( "Invalid pingType specified" )
+ return
+
+ try:
+ main.log.info( "Testing reachability between specified hosts" )
+
+ isReachable = main.TRUE
+
+ for host in hostList:
+ listIndex = hostList.index(host)
+ # List of hosts to ping other than itself
+ pingList = hostList[:listIndex] + hostList[(listIndex+1):]
+
+ for temp in pingList:
+ # Current host pings all other hosts specified
+ pingCmd = str(host) + cmd + str(temp)
+ self.handle.sendline( pingCmd )
+ i = self.handle.expect( [ pingCmd, pexpect.TIMEOUT ] )
+ j = self.handle.expect( [ "mininet>", pexpect.TIMEOUT ] )
+ response = self.handle.before
+ if re.search( ',\s0\%\spacket\sloss', response ):
+ main.log.info( str(host) + " -> " + str(temp) )
+ else:
+ main.log.info( str(host) + " -> X ("+str(temp)+") "
+ " Destination Unreachable" )
+ # One of the host to host pair is unreachable
+ isReachable = main.FALSE
+
+ return isReachable
+
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+
def pingHost( self, **pingParams ):
"""
Ping from one mininet host to another
@@ -1377,20 +1435,32 @@
response = main.FALSE
return response
- def arping( self, src, dest, destmac ):
- self.handle.sendline( '' )
- self.handle.expect( [ "mininet", pexpect.EOF, pexpect.TIMEOUT ] )
-
- self.handle.sendline( src + ' arping ' + dest )
+ def arping( self, host="", ip="10.128.20.211", ethDevice="" ):
+ """
+ Description:
+ Sends arp message from mininet host for hosts discovery
+ Required:
+ host - hosts name
+ Optional:
+ ip - ip address that does not exist in the network so there would
+ be no reply.
+ """
+ if ethDevice:
+ ethDevice = '-I ' + ethDevice + ' '
+ cmd = " py " + host + ".cmd(\"arping -c 1 " + ethDevice + ip + "\")"
try:
- self.handle.expect( [ destmac, pexpect.EOF, pexpect.TIMEOUT ] )
- main.log.info( self.name + ": ARP successful" )
- self.handle.expect( [ "mininet", pexpect.EOF, pexpect.TIMEOUT ] )
+ main.log.warn( "Sending: " + cmd )
+ self.handle.sendline( cmd )
+ response = self.handle.before
+ self.handle.sendline( "" )
+ self.handle.expect( "mininet>" )
return main.TRUE
- except Exception:
- main.log.warn( self.name + ": ARP FAILURE" )
- self.handle.expect( [ "mininet", pexpect.EOF, pexpect.TIMEOUT ] )
- return main.FALSE
+
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
def decToHex( self, num ):
return hex( num ).split( 'x' )[ 1 ]
@@ -1557,7 +1627,7 @@
if switchesJson == "": # if rest call fails
main.log.error(
self.name +
- ".compare_switches(): Empty JSON object given from ONOS" )
+ ".compareSwitches(): Empty JSON object given from ONOS" )
return main.FALSE
onos = switchesJson
onosDPIDs = []
@@ -1866,7 +1936,7 @@
if onosMAC == mnIntf[ 'hw_addr' ].lower() :
match = True
for ip in mnIntf[ 'ips' ]:
- if ip in onosHost[ 'ips' ]:
+ if ip in onosHost[ 'ipAddresses' ]:
pass # all is well
else:
# misssing ip
@@ -1911,6 +1981,7 @@
hostStr = handlePy.replace( "]", "" )
hostStr = hostStr.replace( "'", "" )
hostStr = hostStr.replace( "[", "" )
+ hostStr = hostStr.replace( " ", "" )
hostList = hostStr.split( "," )
return hostList
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index e95e5c1..c2c011a 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -91,10 +91,36 @@
elif re.search( "found multiple mininet", outputs ):
return main.ERROR
else:
+ # TODO: Parse for failed pings, give some truncated output
main.log.error( "Error, unexpected output in the ping file" )
main.log.warn( outputs )
return main.TRUE
+ def arping( self, host="", ip="10.128.20.211" ):
+ """
+ Description:
+ Sends arp message from mininet host for hosts discovery
+ Required:
+ host - hosts name
+ Optional:
+ ip - ip address that does not exist in the network so there would
+ be no reply.
+ """
+ cmd = " py " + host + ".cmd(\"arping -c 1 " + ip + "\")"
+ try:
+ main.log.warn( "Sending: " + cmd )
+ self.handle.sendline( cmd )
+ response = self.handle.before
+ self.handle.sendline( "" )
+ self.handle.expect( "mininet>" )
+ return main.TRUE
+
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+
def pingLong( self, **pingParams ):
"""
Starts a continuous ping on the mininet host outputting
@@ -344,29 +370,48 @@
main.cleanup()
main.exit()
- def runOpticalMnScript( self, ctrllerIP = None ):
+ def runOpticalMnScript( self,name = 'onos', ctrllerIP = None ):
import time
+ import types
"""
- This function is only meant for Packet Optical.
- It runs python script "opticalTest.py" to create the
- packet layer( mn ) and optical topology
-
- TODO: If no ctrllerIP is provided, a default
+ Description:
+ This function is only meant for Packet Optical.
+ It runs python script "opticalTest.py" to create the
+ packet layer( mn ) and optical topology
+ Optional:
+ name - Name of onos directory. (ONOS | onos)
+ Required:
+ ctrllerIP = Controller(s) IP address
+ TODO: If no ctrllerIP is provided, a default
$OC1 can be accepted
"""
try:
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "cd ~/onos/tools/test/topos" )
+ self.handle.sendline( "cd ~/" + name + "/tools/test/topos" )
self.handle.expect( "topos\$" )
if ctrllerIP == None:
main.log.info( "You need to specify the IP" )
return main.FALSE
else:
- cmd = "sudo -E python opticalTest.py " + ctrllerIP
+ controller = ''
+ if isinstance( ctrllerIP, types.ListType ):
+ for i in xrange( len( ctrllerIP ) ):
+ controller += ctrllerIP[i] + ' '
+ main.log.info( "Mininet topology is being loaded with " +
+ "controllers: " + controller )
+ elif isinstance( ctrllerIP, types.StringType ):
+ controller = ctrllerIP
+ main.log.info( "Mininet topology is being loaded with " +
+ "controller: " + controller )
+ else:
+ main.log.info( "You need to specify a valid IP" )
+ return main.FALSE
+ cmd = "sudo -E python opticalTest.py " + controller
+ main.log.info( self.name + ": cmd = " + cmd )
self.handle.sendline( cmd )
- self.handle.expect( "Press ENTER to push Topology.json" )
- time.sleep(15)
+ time.sleep(30)
+ self.handle.sendline( "" )
self.handle.sendline( "" )
self.handle.expect("mininet>")
return main.TRUE
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index a67205c..d4900ad 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -188,7 +188,8 @@
main.cleanup()
main.exit()
- def startOnosCli( self, ONOSIp, karafTimeout="" ):
+ def startOnosCli( self, ONOSIp, karafTimeout="",
+ commandlineTimeout=10, onosStartTimeout=60 ):
"""
karafTimeout is an optional argument. karafTimeout value passed
by user would be used to set the current karaf shell idle timeout.
@@ -206,7 +207,7 @@
try:
self.handle.sendline( "" )
x = self.handle.expect( [
- "\$", "onos>" ], timeout=10 )
+ "\$", "onos>" ], commandlineTimeout)
if x == 1:
main.log.info( "ONOS cli is already running" )
@@ -216,7 +217,7 @@
self.handle.sendline( "onos -w " + str( ONOSIp ) )
i = self.handle.expect( [
"onos>",
- pexpect.TIMEOUT ], timeout=60 )
+ pexpect.TIMEOUT ], onosStartTimeout )
if i == 0:
main.log.info( str( ONOSIp ) + " CLI Started successfully" )
@@ -280,7 +281,14 @@
lvlStr = "--level=" + level
self.handle.sendline( "" )
- self.handle.expect( "onos>" )
+ i = self.handle.expect( [ "onos>","\$", pexpect.TIMEOUT ] )
+ if i == 1:
+ main.log.error( self.name + ": onos cli session closed." )
+ main.cleanup()
+ main.exit()
+ if i == 2:
+ self.handle.sendline( "" )
+ self.handle.expect( "onos>" )
self.handle.sendline( "log:log " + lvlStr + " " + cmdStr )
self.handle.expect( "log:log" )
self.handle.expect( "onos>" )
@@ -289,7 +297,10 @@
if re.search( "Error", response ):
return main.FALSE
return main.TRUE
-
+ except pexpect.TIMEOUT:
+ main.log.exception( self.name + ": TIMEOUT exception found" )
+ main.cleanup()
+ main.exit()
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1814,15 +1825,18 @@
"""
try:
tempFlows = json.loads( self.flows() )
+ #print tempFlows[0]
returnValue = main.TRUE
+
for device in tempFlows:
for flow in device.get( 'flows' ):
if flow.get( 'state' ) != 'ADDED' and flow.get( 'state' ) != \
'PENDING_ADD':
main.log.info( self.name + ": flow Id: " +
- flow.get( 'flowId' ) +
+ flow.get( 'groupId' ) +
" | state:" + flow.get( 'state' ) )
returnValue = main.FALSE
+
return returnValue
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
@@ -3129,6 +3143,20 @@
try:
cmdStr = "set-test-add " + str( setName ) + " " + str( values )
output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
assert "Error executing command" not in output
positiveMatch = "\[(.*)\] was added to the set " + str( setName )
negativeMatch = "\[(.*)\] was already in set " + str( setName )
@@ -3140,7 +3168,6 @@
else:
main.log.error( self.name + ": setTestAdd did not" +
" match expected output" )
- main.log.debug( self.name + " expected: " + pattern )
main.log.debug( self.name + " actual: " + repr( output ) )
return main.ERROR
except AssertionError:
@@ -3184,6 +3211,20 @@
else:
cmdStr += str( setName ) + " " + str( values )
output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
assert "Error executing command" not in output
main.log.info( self.name + ": " + output )
if clear:
@@ -3269,6 +3310,20 @@
cmdStr = "set-test-get "
cmdStr += setName + " " + values
output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
assert "Error executing command" not in output
main.log.info( self.name + ": " + output )
@@ -3334,7 +3389,7 @@
Required arguments:
setName - The name of the set to remove from.
returns:
- The integer value of the size returned or
+ The integer value of the size returned or
None on error
"""
try:
@@ -3348,6 +3403,20 @@
cmdStr = "set-test-get -s "
cmdStr += setName
output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
assert "Error executing command" not in output
main.log.info( self.name + ": " + output )
match = re.search( pattern, output )
@@ -3386,42 +3455,31 @@
main.cleanup()
main.exit()
- def counters( self ):
+ def counters( self, jsonFormat=True ):
"""
Command to list the various counters in the system.
returns:
- A dict containing the counters in the system with the counter
- names being the keys and the value of the counters being the
- values OR
+ if jsonFormat, a string of the json object returned by the cli
+ command
+ if not jsonFormat, the normal string output of the cli command
None on error
"""
- #FIXME: JSON FORMAT
try:
counters = {}
cmdStr = "counters"
+ if jsonFormat:
+ cmdStr += " -j"
output = self.sendline( cmdStr )
assert "Error executing command" not in output
main.log.info( self.name + ": " + output )
- for line in output.splitlines():
- match = re.search( "name=(\S+) value=(\d+)", line )
- if match:
- key = match.group( 1 )
- value = int( match.group( 2 ) )
- counters[key] = value
- else:
- main.log.error( self.name + ": counters did not match " +
- "expected output" )
- main.log.debug( self.name + " expected: " + pattern )
- main.log.debug( self.name + " actual: " + repr( output ) )
- return None
- return counters
+ return output
except AssertionError:
main.log.error( "Error in processing 'counters' command: " +
str( output ) )
- return main.ERROR
+ return None
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
- return main.ERROR
+ return None
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -3450,6 +3508,20 @@
cmdStr += "-i "
cmdStr += counter
output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing 'set-test-add' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
assert "Error executing command" not in output
main.log.info( self.name + ": " + output )
pattern = counter + " was incremented to (\d+)"
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index a78f4f2..7abbcc6 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -20,6 +20,7 @@
import time
import pexpect
import os.path
+from requests.models import Response
sys.path.append( "../" )
from drivers.common.clidriver import CLI
@@ -97,7 +98,28 @@
response = main.FALSE
return response
- def onosPackage( self ):
+ def getEpochMs( self ):
+ """
+ Returns milliseconds since epoch
+
+ When checking multiple nodes in a for loop,
+ around a hundred milliseconds of difference (ascending) is
+ generally acceptable due to calltime of the function.
+ Few seconds, however, is not and it means clocks
+ are off sync.
+ """
+ try:
+ self.handle.sendline( 'date +%s.%N' )
+ self.handle.expect( 'date \+\%s\.\%N' )
+ self.handle.expect( '\$' )
+ epochMs = self.handle.before
+ return epochMs
+ except Exception:
+ main.log.exception( 'Uncaught exception getting epoch time' )
+ main.cleanup()
+ main.exit()
+
+ def onosPackage( self, opTimeout=30 ):
"""
Produce a self-contained tar.gz file that can be deployed
and executed on any platform with Java 7 JRE.
@@ -105,7 +127,7 @@
try:
self.handle.sendline( "onos-package" )
self.handle.expect( "onos-package" )
- self.handle.expect( "tar.gz", timeout=30 )
+ self.handle.expect( "tar.gz", opTimeout )
handle = str( self.handle.before )
main.log.info( "onos-package command returned: " +
handle )
@@ -152,11 +174,14 @@
main.cleanup()
main.exit()
- def cleanInstall( self ):
+ def cleanInstall( self, skipTest=False, mciTimeout=600 ):
"""
Runs mvn clean install in the root of the ONOS directory.
This will clean all ONOS artifacts then compile each module
-
+ Optional:
+ skipTest - Does "-DskipTests -Dcheckstyle.skip -U -T 1C" which
+ skip the test. This will make the building faster.
+ Disregarding the credibility of the build
Returns: main.TRUE on success
On Failure, exits the test
"""
@@ -169,8 +194,15 @@
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "mvn clean install" )
- self.handle.expect( "mvn clean install" )
+
+ if not skipTest:
+ self.handle.sendline( "mvn clean install" )
+ self.handle.expect( "mvn clean install" )
+ else:
+ self.handle.sendline( "mvn clean install -DskipTests" +
+ " -Dcheckstyle.skip -U -T 1C" )
+ self.handle.expect( "mvn clean install -DskipTests" +
+ " -Dcheckstyle.skip -U -T 1C" )
while True:
i = self.handle.expect( [
'There\sis\sinsufficient\smemory\sfor\sthe\sJava\s' +
@@ -179,7 +211,7 @@
'BUILD\sSUCCESS',
'onos\$', #TODO: fix this to be more generic?
'ONOS\$',
- pexpect.TIMEOUT ], timeout=600 )
+ pexpect.TIMEOUT ], mciTimeout )
if i == 0:
main.log.error( self.name + ":There is insufficient memory \
for the Java Runtime Environment to continue." )
@@ -390,7 +422,7 @@
[ 'fatal',
'Username for (.*): ',
'Already on \'',
- 'Switched to branch \'' + str( branch ),
+ 'Switched to (a new )?branch \'' + str( branch ),
pexpect.TIMEOUT,
'error: Your local changes to the following files' +
'would be overwritten by checkout:',
@@ -483,6 +515,24 @@
main.cleanup()
main.exit()
+ def getBranchName( self ):
+ main.log.info( "self.home = " )
+ main.log.info( self.home )
+ self.handle.sendline( "cd " + self.home )
+ self.handle.expect( self.home + "\$" )
+ self.handle.sendline( "git name-rev --name-only HEAD" )
+ self.handle.expect( "git name-rev --name-only HEAD" )
+ self.handle.expect( "\$" )
+
+ lines = self.handle.before.splitlines()
+ if lines[1] == "master":
+ return "master"
+ elif lines[1] == "onos-1.0":
+ return "onos-1.0"
+ else:
+ main.log.info( lines[1] )
+ return "unexpected ONOS branch for SDN-IP test"
+
def getVersion( self, report=False ):
"""
Writes the COMMIT number to the report to be parsed
@@ -567,6 +617,8 @@
# on here.
appString = "export ONOS_APPS=" + appString
mnString = "export OCN="
+ if mnIpAddrs == "":
+ mnString = ""
onosString = "export OC"
tempCount = 1
@@ -926,7 +978,7 @@
"""
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( "\$", timeout=60 )
self.handle.sendline( "onos-uninstall " + str( nodeIp ) )
self.handle.expect( "\$" )
@@ -935,6 +987,9 @@
# onos-uninstall command does not return any text
return main.TRUE
+ except pexpect.TIMEOUT:
+ main.log.exception( self.name + ": Timeout in onosUninstall" )
+ return main.FALSE
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1239,8 +1294,8 @@
return main.ERROR
output = ""
# Is the number of switches is what we expected
- devices = topology.get( 'deviceCount', False )
- links = topology.get( 'linkCount', False )
+ devices = topology.get( 'devices', False )
+ links = topology.get( 'links', False )
if not devices or not links:
return main.ERROR
switchCheck = ( int( devices ) == int( numoswitch ) )
@@ -1497,13 +1552,18 @@
except Exception:
main.log.exception( "Copying files failed" )
- def checkLogs( self, onosIp ):
+ def checkLogs( self, onosIp, restart=False):
"""
runs onos-check-logs on the given onos node
+ If restart is True, use the old version of onos-check-logs which
+ does not print the full stacktrace, but shows the entire log file,
+ including across restarts
returns the response
"""
try:
cmd = "onos-check-logs " + str( onosIp )
+ if restart:
+ cmd += " old"
self.handle.sendline( cmd )
self.handle.expect( cmd )
self.handle.expect( "\$" )
@@ -1901,6 +1961,160 @@
main.cleanup()
main.exit()
+ def getOnosIps(self):
+
+ import os
+
+ # reads env for OC variables, also saves file with OC variables. If file and env conflict
+ # priority goes to env. If file has OCs that are not in the env, the file OCs are used.
+ # In other words, if the env is set, the test will use those values.
+
+ # returns a list of ip addresses for the onos nodes, will work with up to 7 nodes + OCN and OCI
+ # returns in format [ OC1 ip, OC2 ...ect. , OCN, OCI ]
+
+ envONOSIps = {}
+
+ x = 1
+ while True:
+ try:
+ temp = os.environ[ 'OC' + str(x) ]
+ except KeyError:
+ break
+ envONOSIps[ ("OC" + str(x)) ] = temp
+ x += 1
+
+ try:
+ temp = os.environ[ 'OCN' ]
+ envONOSIps[ "OCN" ] = temp
+ except KeyError:
+ main.log.info("OCN not set in env")
+
+ try:
+ temp = os.environ[ 'OCI' ]
+ envONOSIps[ "OCI" ] = temp
+ except:
+ main.log.error("OCI not set in env")
+
+ print(str(envONOSIps))
+
+ order = [ "OC1", "OC2", "OC3","OC4","OC5","OC6","OC7","OCN","OCI" ]
+ ONOSIps = []
+
+ try:
+ if os.path.exists("myIps"):
+ ipFile = open("myIps","r+")
+ else:
+ ipFile = open("myIps","w+")
+
+ fileONOSIps = ipFile.readlines()
+ ipFile.close()
+
+ print str(fileONOSIps)
+
+ if str(fileONOSIps) == "[]":
+ ipFile = open("myIps","w+")
+ for key in envONOSIps:
+ ipFile.write(key+ "=" + envONOSIps[key] + "\n")
+ ipFile.close()
+ for i in order:
+ if i in envONOSIps:
+ ONOSIps.append(envONOSIps[i])
+
+ return ONOSIps
+
+ else:
+ fileDict = {}
+ for line in fileONOSIps:
+ line = line.replace("\n","")
+ line = line.split("=")
+ key = line[0]
+ value = line[1]
+ fileDict[key] = value
+
+ for x in envONOSIps:
+ if x in fileDict:
+ if envONOSIps[x] == fileDict[x]:
+ continue
+ else:
+ fileDict[x] = envONOSIps[x]
+ else:
+ fileDict[x] = envONOSIps[x]
+
+ ipFile = open("myIps","w+")
+ for key in order:
+ if key in fileDict:
+ ipFile.write(key + "=" + fileDict[key] + "\n")
+ ONOSIps.append(fileDict[key])
+ ipFile.close()
+
+ return ONOSIps
+
+ except IOError as a:
+ main.log.error(a)
+
+ except Exception as a:
+ main.log.error(a)
+
+
+ def logReport(self, nodeIp, searchTerms, outputMode="s"):
+ '''
+ - accepts either a list or a string for "searchTerms" these
+ terms will be searched for in the log and have their
+ instances counted
+
+ - nodeIp is the ip of the node whos log is to be scanned
+
+ - output modes:
+ "s" - Simple. Quiet output mode that just prints
+ the occurences of each search term
+
+ "d" - Detailed. Prints number of occurences as well as the entire
+ line for each of the last 5 occurences
+
+ - returns total of the number of instances of all search terms
+ '''
+ main.log.info("========================== Log Report ===========================\n")
+
+ if type(searchTerms) is str:
+ searchTerms = [searchTerms]
+
+ logLines = [ [" "] for i in range(len(searchTerms)) ]
+
+ for term in range(len(searchTerms)):
+ logLines[term][0] = searchTerms[term]
+
+ totalHits = 0
+ for term in range(len(searchTerms)):
+ cmd = "onos-ssh " + nodeIp + " cat /opt/onos/log/karaf.log | grep " + searchTerms[term]
+ self.handle.sendline(cmd)
+ self.handle.expect(":~")
+ before = (self.handle.before).splitlines()
+
+ count = [searchTerms[term],0]
+
+ for line in before:
+ if searchTerms[term] in line and "grep" not in line:
+ count[1] += 1
+ if before.index(line) > ( len(before) - 7 ):
+ logLines[term].append(line)
+
+ main.log.info( str(count[0]) + ": " + str(count[1]) )
+ if term == len(searchTerms)-1:
+ print("\n")
+ totalHits += int(count[1])
+
+ if outputMode != "s" and outputMode != "S":
+ outputString = ""
+ for i in logLines:
+ outputString = i[0] + ": \n"
+ for x in range(1,len(i)):
+ outputString += ( i[x] + "\n" )
+
+ if outputString != (i[0] + ": \n"):
+ main.log.info(outputString)
+
+ main.log.info("================================================================\n")
+ return totalHits
def getOnosIpFromEnv(self):
@@ -1966,14 +2180,14 @@
return ONOSIps
-
+
def onosErrorLog(self, nodeIp):
cmd = "onos-ssh " + nodeIp + " cat /opt/onos/log/karaf.log | grep WARN"
self.handle.sendline(cmd)
self.handle.expect(":~")
before = (self.handle.before).splitlines()
-
+
warnings = []
for line in before:
@@ -2044,4 +2258,3 @@
if len(exceptions) > 0:
main.log.info(msg3)
main.log.info("===============================================================\n")
-
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 1c63206..7e3df2b 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -40,9 +40,9 @@
ip_address="1.1.1.1",
port=self.port,
pwd=self.pwd )
- main.log.info( "connect parameters:" + str( self.user_name ) + ";"
- + str( self.ip_address ) + ";" + str( self.port )
- + ";" + str(self.pwd ) )
+ #main.log.info( "connect parameters:" + str( self.user_name ) + ";"
+ # + str( self.ip_address ) + ";" + str( self.port )
+ # + ";" + str(self.pwd ) )
if self.handle:
# self.handle.expect( "",timeout=10 )
@@ -186,7 +186,7 @@
return intents
# This method extracts all actual routes from ONOS CLI
- def extractActualRoutes( self, getRoutesResult ):
+ def extractActualRoutesOneDotZero( self, getRoutesResult ):
routesJsonObj = json.loads( getRoutesResult )
allRoutesActual = []
@@ -199,6 +199,18 @@
return sorted( allRoutesActual )
+ def extractActualRoutesMaster( self, getRoutesResult ):
+ routesJsonObj = json.loads( getRoutesResult )
+
+ allRoutesActual = []
+ for route in routesJsonObj['routes4']:
+ if route[ 'prefix' ] == '172.16.10.0/24':
+ continue
+ allRoutesActual.append(
+ route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
+
+ return sorted( allRoutesActual )
+
# This method extracts all actual route intents from ONOS CLI
def extractActualRouteIntents( self, getIntentsResult ):
intents = []
@@ -207,8 +219,8 @@
intentsJsonObj = json.loads( getIntentsResult )
for intent in intentsJsonObj:
- if intent[ 'appId' ] != "org.onosproject.sdnip":
- continue
+ #if intent[ 'appId' ] != "org.onosproject.sdnip":
+ # continue
if intent[ 'type' ] == "MultiPointToSinglePointIntent" \
and intent[ 'state' ] == 'INSTALLED':
egress = str( intent[ 'egress' ][ 'device' ] ) + ":" \
@@ -230,6 +242,26 @@
intents.append( intent )
return sorted( intents )
+ # This method calculates the MultiPointToSinglePointIntent number installed
+ def extractActualRouteIntentNum( self, getIntentsResult ):
+ intentsJsonObj = json.loads( getIntentsResult )
+ num = 0
+ for intent in intentsJsonObj:
+ if intent[ 'type' ] == "MultiPointToSinglePointIntent" \
+ and intent[ 'state' ] == 'INSTALLED':
+ num = num + 1
+ return num
+
+ # This method calculates the PointToPointIntent number installed
+ def extractActualBgpIntentNum( self, getIntentsResult ):
+ intentsJsonObj = json.loads( getIntentsResult )
+ num = 0
+ for intent in intentsJsonObj:
+ if intent[ 'type' ] == "PointToPointIntent" \
+ and intent[ 'state' ] == 'INSTALLED':
+ num = num + 1
+ return num
+
# This method extracts all actual BGP intents from ONOS CLI
def extractActualBgpIntents( self, getIntentsResult ):
intents = []
@@ -238,8 +270,8 @@
intentsJsonObj = json.loads( getIntentsResult )
for intent in intentsJsonObj:
- if intent[ 'appId' ] != "org.onosproject.sdnip":
- continue
+ #if intent[ 'appId' ] != "org.onosproject.sdnip":
+ # continue
if intent[ 'type' ] == "PointToPointIntent" \
and "protocol=6" in str( intent[ 'selector' ] ):
ingress = str( intent[ 'ingress' ][ 'device' ] ) + ":" \
@@ -489,7 +521,7 @@
if routesAdded == numRoutes:
return main.TRUE
return main.FALSE
-
+
# Please use deleteRoutes method instead of this one!
def delRoute( self, net, numRoutes, routeRate ):
try:
@@ -562,7 +594,7 @@
child.expect( "Flow table show" )
count = 0
while True:
- i = child.expect( [ '17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}',
+ i = child.expect( [ '17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}',
'CLI#', pexpect.TIMEOUT ] )
if i == 0:
count = count + 1
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index 44552ae..3b94ef7 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -81,7 +81,7 @@
while i == 5:
i = self.handle.expect( [
ssh_newkey,
- 'password:',
+ 'password:|Password:',
pexpect.EOF,
pexpect.TIMEOUT,
refused,
diff --git a/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py b/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py
new file mode 100644
index 0000000..3f41180
--- /dev/null
+++ b/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py
@@ -0,0 +1,967 @@
+"""
+ Wrapper functions for FuncIntent
+ This functions include Onosclidriver and Mininetclidriver driver functions
+ Author: kelvin@onlab.us
+"""
+def __init__( self ):
+ self.default = ''
+
+def hostIntent( main,
+ name,
+ host1,
+ host2,
+ host1Id="",
+ host2Id="",
+ mac1="",
+ mac2="",
+ vlan1="-1",
+ vlan2="-1",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+ """
+ Description:
+ Verify add-host-intent
+ Steps:
+ - Discover hosts
+ - Add host intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ Required:
+ name - Type of host intent to add eg. IPV4 | VLAN | Dualstack
+ host1 - Name of first host
+ host2 - Name of second host
+ Optional:
+ host1Id - ONOS id of the first host eg. 00:00:00:00:00:01/-1
+ host2Id - ONOS id of the second host
+ mac1 - Mac address of first host
+ mac2 - Mac address of the second host
+ vlan1 - Vlan tag of first host, defaults to -1
+ vlan2 - Vlan tag of second host, defaults to -1
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+ import time
+
+ # Assert variables
+ assert main, "There is no main variable"
+ assert name, "variable name is empty"
+ assert host1 and host2, "You must specify hosts"
+
+ global itemName
+ itemName = name
+ h1Id = host1Id
+ h2Id = host2Id
+ h1Mac = mac1
+ h2Mac = mac2
+ vlan1 = vlan1
+ vlan2 = vlan2
+ hostNames = [ host1 , host2 ]
+ intentsId = []
+ stepResult = main.TRUE
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ removeIntentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+
+ if main.hostsData:
+ if not h1Mac:
+ h1Mac = main.hostsData[ host1 ][ 'mac' ]
+ if not h2Mac:
+ h2Mac = main.hostsData[ host2 ][ 'mac' ]
+ if main.hostsData[ host1 ][ 'vlan' ] != '-1':
+ vlan1 = main.hostsData[ host1 ][ 'vlan' ]
+ if main.hostsData[ host2 ][ 'vlan' ] != '-1':
+ vlan2 = main.hostsData[ host2 ][ 'vlan' ]
+ if not h1Id:
+ h1Id = main.hostsData[ host1 ][ 'id' ]
+ if not h2Id:
+ h2Id = main.hostsData[ host2 ][ 'id' ]
+
+ assert h1Id and h2Id, "You must specify host IDs"
+ if not ( h1Id and h2Id ):
+ main.log.info( "There are no host IDs" )
+ return main.FALSE
+
+ # Discover hosts using arping
+ main.log.info( itemName + ": Discover host using arping" )
+ main.Mininet1.arping( host=host1 )
+ main.Mininet1.arping( host=host2 )
+ host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
+ host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
+
+ # Adding host intents
+ main.log.info( itemName + ": Adding host intents" )
+ intent1 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h1Id,
+ hostIdTwo=h2Id )
+ intentsId.append( intent1 )
+ time.sleep( 5 )
+
+ # Check intents state
+ time.sleep( 30 )
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check intents state again if first check fails...
+ if not intentResult:
+ intentResult = checkIntentState( main, intentsId )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Ping hosts
+ firstPingResult = pingallHosts( main, hostNames )
+ if not firstPingResult:
+ main.log.debug( "First ping failed, there must be" +
+ " something wrong with ONOS performance" )
+
+ # Ping hosts again...
+ pingResult = pingResult and pingallHosts( main, hostNames )
+ time.sleep( 5 )
+
+ # 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 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link down
+ if linkDownResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link down" )
+ else:
+ main.log.error( itemName + ": Failed to bring link down" )
+
+ # link up
+ linkUpResult = link( main, sw1, sw2, "up" )
+ time.sleep( 5 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, main.numLinks )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link up
+ if linkUpResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link back up" )
+ else:
+ main.log.error( itemName + ": Failed to bring link back up" )
+
+ # Remove all intents
+ removeIntentResult = removeAllIntents( main, intentsId )
+
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult and removeIntentResult
+
+ return stepResult
+
+def pointIntent( main,
+ name,
+ host1,
+ host2,
+ deviceId1="",
+ deviceId2="",
+ port1="",
+ port2="",
+ ethType="",
+ mac1="",
+ mac2="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+
+ """
+ Description:
+ Verify add-point-intent
+ Steps:
+ - Get device ids | ports
+ - Add point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ host1 - Name of first host
+ host2 - Name of second host
+ Optional:
+ deviceId1 - ONOS device id of the first switch, the same as the
+ location of the first host eg. of:0000000000000001/1,
+ located at device 1 port 1
+ deviceId2 - ONOS device id of the second switch
+ port1 - The port number where the first host is attached
+ port2 - The port number where the second host is attached
+ ethType - Ethernet type eg. IPV4, IPV6
+ mac1 - Mac address of first host
+ mac2 - Mac address of the second host
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ ip1 - IP address of first host
+ ip2 - IP address of second host
+ tcp1 - TCP port of first host
+ tcp2 - TCP port of second host
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ import time
+ assert main, "There is no main variable"
+ assert name, "variable name is empty"
+ assert host1 and host2, "You must specify hosts"
+
+ global itemName
+ itemName = name
+ host1 = host1
+ host2 = host2
+ hostNames = [ host1, host2 ]
+ intentsId = []
+
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ removeIntentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+
+ # Adding bidirectional point intents
+ main.log.info( itemName + ": Adding point intents" )
+ intent1 = main.CLIs[ 0 ].addPointIntent( ingressDevice=deviceId1,
+ egressDevice=deviceId2,
+ portIngress=port1,
+ portEgress=port2,
+ ethType=ethType,
+ ethSrc=mac1,
+ ethDst=mac2,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc=ip1,
+ ipDst=ip2,
+ tcpSrc=tcp1,
+ tcpDst=tcp2 )
+
+ intentsId.append( intent1 )
+ time.sleep( 5 )
+ intent2 = main.CLIs[ 0 ].addPointIntent( ingressDevice=deviceId2,
+ egressDevice=deviceId1,
+ portIngress=port2,
+ portEgress=port1,
+ ethType=ethType,
+ ethSrc=mac2,
+ ethDst=mac1,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc=ip2,
+ ipDst=ip1,
+ tcpSrc=tcp2,
+ tcpDst=tcp1 )
+ intentsId.append( intent2 )
+
+ # Check intents state
+ time.sleep( 30 )
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check intents state again if first check fails...
+ if not intentResult:
+ intentResult = checkIntentState( main, intentsId )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Ping hosts
+ firstPingResult = pingallHosts( main, hostNames )
+ if not firstPingResult:
+ main.log.debug( "First ping failed, there must be" +
+ " something wrong with ONOS performance" )
+
+ # Ping hosts again...
+ pingResult = pingResult and pingallHosts( main, hostNames )
+ time.sleep( 5 )
+
+ # 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 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link down
+ if linkDownResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link down" )
+ else:
+ main.log.error( itemName + ": Failed to bring link down" )
+
+ # link up
+ linkUpResult = link( main, sw1, sw2, "up" )
+ time.sleep( 5 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, main.numLinks )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link up
+ if linkUpResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link back up" )
+ else:
+ main.log.error( itemName + ": Failed to bring link back up" )
+
+ # Remove all intents
+ removeIntentResult = removeAllIntents( main, intentsId )
+
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult and removeIntentResult
+
+ return stepResult
+
+def singleToMultiIntent( main,
+ name,
+ hostNames,
+ devices="",
+ ports=None,
+ ethType="",
+ macs=None,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+ """
+ Verify Single to Multi Point intents
+ NOTE:If main.hostsData is not defined, variables data should be passed in the
+ same order index wise. All devices in the list should have the same
+ format, either all the devices have its port or it doesn't.
+ eg. hostName = [ 'h1', 'h2' ,.. ]
+ devices = [ 'of:0000000000000001', 'of:0000000000000002', ...]
+ ports = [ '1', '1', ..]
+ ...
+ Description:
+ Verify add-single-to-multi-intent iterates through the list of given
+ host | devices and add intents
+ Steps:
+ - Get device ids | ports
+ - Add single to multi point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ hostNames - List of host names
+ Optional:
+ devices - List of device ids in the same order as the hosts
+ in hostNames
+ ports - List of port numbers in the same order as the device in
+ devices
+ ethType - Ethernet type eg. IPV4, IPV6
+ macs - List of hosts mac address in the same order as the hosts in
+ hostNames
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ ipAddresses - IP addresses of host in the same order as the hosts in
+ hostNames
+ tcp - TCP ports in the same order as the hosts in hostNames
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ import time
+ import copy
+ assert main, "There is no main variable"
+ assert hostNames, "You must specify hosts"
+ assert devices or main.hostsData, "You must specify devices"
+
+ global itemName
+ itemName = name
+ tempHostsData = {}
+ intentsId = []
+
+ macsDict = {}
+ ipDict = {}
+ if hostNames and devices:
+ if len( hostNames ) != len( devices ):
+ main.log.debug( "hosts and devices does not have the same length" )
+ #print "len hostNames = ", len( hostNames )
+ #print "len devices = ", len( devices )
+ return main.FALSE
+ if ports:
+ if len( ports ) != len( devices ):
+ main.log.error( "Ports and devices does " +
+ "not have the same length" )
+ #print "len devices = ", len( devices )
+ #print "len ports = ", len( ports )
+ return main.FALSE
+ for i in range( len( devices ) ):
+ macsDict[ devices[ i ] ] = macs[ i ]
+ else:
+ main.log.info( "Device Ports are not specified" )
+ elif hostNames and not devices and main.hostsData:
+ devices = []
+ main.log.info( "singleToMultiIntent function is using main.hostsData" )
+ for host in hostNames:
+ devices.append( main.hostsData.get( host ).get( 'location' ) )
+ macsDict[ main.hostsData.get( host ).get( 'location' ) ] = \
+ main.hostsData.get( host ).get( 'mac' )
+ ipDict[ main.hostsData.get( host ).get( 'location' ) ] = \
+ main.hostsData.get( host ).get( 'ipAddresses' )
+ #print main.hostsData
+
+ #print 'host names = ', hostNames
+ #print 'devices = ', devices
+ #print "macsDict = ", macsDict
+
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ removeIntentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+
+ devicesCopy = copy.copy( devices )
+ if ports:
+ portsCopy = copy.copy( ports )
+ main.log.info( itemName + ": Adding single point to multi point intents" )
+ # Adding bidirectional point intents
+ for i in range( len( devices ) ):
+ ingressDevice = devicesCopy[ i ]
+ egressDeviceList = copy.copy( devicesCopy )
+ egressDeviceList.remove( ingressDevice )
+ if ports:
+ portIngress = portsCopy[ i ]
+ portEgressList = copy.copy( portsCopy )
+ del portEgressList[ i ]
+ else:
+ portIngress = ""
+ portEgressList = None
+ if not macsDict:
+ srcMac = ""
+ else:
+ srcMac = macsDict[ ingressDevice ]
+ if srcMac == None:
+ main.log.debug( "There is no MAC in device - " + ingressDevice )
+ srcMac = ""
+
+ intentsId.append( main.CLIs[ 0 ].addSinglepointToMultipointIntent(
+ ingressDevice=ingressDevice,
+ egressDeviceList=egressDeviceList,
+ portIngress=portIngress,
+ portEgressList=portEgressList,
+ ethType=ethType,
+ ethSrc=srcMac,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="" ) )
+
+ pingResult = pingallHosts( main, hostNames )
+
+ # Check intents state
+ time.sleep( 30 )
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check intents state again if first check fails...
+ if not intentResult:
+ intentResult = checkIntentState( main, intentsId )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+ # Ping hosts again...
+ pingResult = pingResult and pingallHosts( main, hostNames )
+ time.sleep( 5 )
+
+ # 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 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link down
+ if linkDownResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link down" )
+ else:
+ main.log.error( itemName + ": Failed to bring link down" )
+
+ # link up
+ linkUpResult = link( main, sw1, sw2, "up" )
+ time.sleep( 5 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, main.numLinks )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link up
+ if linkUpResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link back up" )
+ else:
+ main.log.error( itemName + ": Failed to bring link back up" )
+
+ # Remove all intents
+ removeIntentResult = removeAllIntents( main, intentsId )
+
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult and removeIntentResult
+
+ return stepResult
+
+def multiToSingleIntent( main,
+ name,
+ hostNames,
+ devices="",
+ ports=None,
+ ethType="",
+ macs=None,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+ """
+ Verify Single to Multi Point intents
+ NOTE:If main.hostsData is not defined, variables data should be passed in the
+ same order index wise. All devices in the list should have the same
+ format, either all the devices have its port or it doesn't.
+ eg. hostName = [ 'h1', 'h2' ,.. ]
+ devices = [ 'of:0000000000000001', 'of:0000000000000002', ...]
+ ports = [ '1', '1', ..]
+ ...
+ Description:
+ Verify add-multi-to-single-intent
+ Steps:
+ - Get device ids | ports
+ - Add single to multi point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ hostNames - List of host names
+ Optional:
+ devices - List of device ids in the same order as the hosts
+ in hostNames
+ ports - List of port numbers in the same order as the device in
+ devices
+ ethType - Ethernet type eg. IPV4, IPV6
+ macs - List of hosts mac address in the same order as the hosts in
+ hostNames
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ ipAddresses - IP addresses of host in the same order as the hosts in
+ hostNames
+ tcp - TCP ports in the same order as the hosts in hostNames
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ import time
+ import copy
+ assert main, "There is no main variable"
+ assert hostNames, "You must specify hosts"
+ assert devices or main.hostsData, "You must specify devices"
+
+ global itemName
+ itemName = name
+ tempHostsData = {}
+ intentsId = []
+
+ macsDict = {}
+ ipDict = {}
+ if hostNames and devices:
+ if len( hostNames ) != len( devices ):
+ main.log.debug( "hosts and devices does not have the same length" )
+ #print "len hostNames = ", len( hostNames )
+ #print "len devices = ", len( devices )
+ return main.FALSE
+ if ports:
+ if len( ports ) != len( devices ):
+ main.log.error( "Ports and devices does " +
+ "not have the same length" )
+ #print "len devices = ", len( devices )
+ #print "len ports = ", len( ports )
+ return main.FALSE
+ for i in range( len( devices ) ):
+ macsDict[ devices[ i ] ] = macs[ i ]
+ else:
+ main.log.info( "Device Ports are not specified" )
+ elif hostNames and not devices and main.hostsData:
+ devices = []
+ main.log.info( "singleToMultiIntent function is using main.hostsData" )
+ for host in hostNames:
+ devices.append( main.hostsData.get( host ).get( 'location' ) )
+ macsDict[ main.hostsData.get( host ).get( 'location' ) ] = \
+ main.hostsData.get( host ).get( 'mac' )
+ ipDict[ main.hostsData.get( host ).get( 'location' ) ] = \
+ main.hostsData.get( host ).get( 'ipAddresses' )
+ #print main.hostsData
+
+ #print 'host names = ', hostNames
+ #print 'devices = ', devices
+ #print "macsDict = ", macsDict
+
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ removeIntentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+
+ devicesCopy = copy.copy( devices )
+ if ports:
+ portsCopy = copy.copy( ports )
+ main.log.info( itemName + ": Adding single point to multi point intents" )
+ # Adding bidirectional point intents
+ for i in range( len( devices ) ):
+ egressDevice = devicesCopy[ i ]
+ ingressDeviceList = copy.copy( devicesCopy )
+ ingressDeviceList.remove( egressDevice )
+ if ports:
+ portEgress = portsCopy[ i ]
+ portIngressList = copy.copy( portsCopy )
+ del portIngressList[ i ]
+ else:
+ portEgress = ""
+ portIngressList = None
+ if not macsDict:
+ dstMac = ""
+ else:
+ dstMac = macsDict[ egressDevice ]
+ if dstMac == None:
+ main.log.debug( "There is no MAC in device - " + egressDevice )
+ dstMac = ""
+
+ intentsId.append( main.CLIs[ 0 ].addMultipointToSinglepointIntent(
+ ingressDeviceList=ingressDeviceList,
+ egressDevice=egressDevice,
+ portIngressList=portIngressList,
+ portEgress=portEgress,
+ ethType=ethType,
+ ethDst=dstMac,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="" ) )
+
+ pingResult = pingallHosts( main, hostNames )
+
+ # Check intents state
+ time.sleep( 30 )
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check intents state again if first check fails...
+ if not intentResult:
+ intentResult = checkIntentState( main, intentsId )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+ # Ping hosts again...
+ pingResult = pingResult and pingallHosts( main, hostNames )
+ time.sleep( 5 )
+
+ # 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 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link down
+ if linkDownResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link down" )
+ else:
+ main.log.error( itemName + ": Failed to bring link down" )
+
+ # link up
+ linkUpResult = link( main, sw1, sw2, "up" )
+ time.sleep( 5 )
+
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, main.numLinks )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link up
+ if linkUpResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link back up" )
+ else:
+ main.log.error( itemName + ": Failed to bring link back up" )
+
+ # Remove all intents
+ removeIntentResult = removeAllIntents( main, intentsId )
+
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult and removeIntentResult
+
+ return stepResult
+
+def pingallHosts( main, hostList, pingType="ipv4" ):
+ # Ping all host in the hosts list variable
+ print "Pinging : ", hostList
+ pingResult = main.TRUE
+ pingResult = main.Mininet1.pingallHosts( hostList, pingType )
+ return pingResult
+
+def getHostsData( main ):
+ """
+ Use fwd app and pingall to discover all the hosts
+ """
+ import json
+ activateResult = main.TRUE
+ appCheck = main.TRUE
+ getDataResult = main.TRUE
+ main.log.info( "Activating reactive forwarding app " )
+ activateResult = main.CLIs[ 0 ].activateApp( "org.onosproject.fwd" )
+
+ for i in range( main.numCtrls ):
+ appCheck = appCheck and main.CLIs[ i ].appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[ i ].apps() )
+ main.log.warn( main.CLIs[ i ].appIDs() )
+
+ pingResult = main.Mininet1.pingall()
+ hostsJson = json.loads( main.CLIs[ 0 ].hosts() )
+ hosts = main.Mininet1.getHosts()
+ for host in hosts:
+ main.hostsData[ host ] = {}
+ main.hostsData[ host ][ 'mac' ] = \
+ main.Mininet1.getMacAddress( host ).upper()
+ for hostj in hostsJson:
+ if main.hostsData[ host ][ 'mac' ] == hostj[ 'mac' ]:
+ main.hostsData[ host ][ 'id' ] = hostj[ 'id' ]
+ main.hostsData[ host ][ 'vlan' ] = hostj[ 'vlan' ]
+ main.hostsData[ host ][ 'location' ] = \
+ hostj[ 'location' ][ 'elementId' ] + '/' + \
+ hostj[ 'location' ][ 'port' ]
+ main.hostsData[ host ][ 'ipAddresses' ] = hostj[ 'ipAddresses' ]
+
+ main.log.info( "Deactivating reactive forwarding app " )
+ deactivateResult = main.CLIs[ 0 ].deactivateApp( "org.onosproject.fwd" )
+ if activateResult and deactivateResult and main.hostsData:
+ main.log.info( "Successfully used fwd app to discover hosts " )
+ getDataResult = main.TRUE
+ else:
+ main.log.info( "Failed to use fwd app to discover hosts " )
+ getDataResult = main.FALSE
+
+ print main.hostsData
+
+ return getDataResult
+
+def checkTopology( main, expectedLink ):
+ statusResult = main.TRUE
+ # Check onos topology
+ main.log.info( itemName + ": Checking ONOS topology " )
+
+ for i in range( main.numCtrls ):
+ topologyResult = main.CLIs[ i ].topology()
+ statusResult = main.ONOSbench.checkStatus( topologyResult,
+ main.numSwitch,
+ expectedLink )\
+ and statusResult
+ if not statusResult:
+ main.log.error( itemName + ": Topology mismatch" )
+ else:
+ main.log.info( itemName + ": Topology match" )
+ return statusResult
+
+def checkIntentState( main, intentsId ):
+
+ intentResult = main.TRUE
+
+ main.log.info( itemName + ": Checking intents state" )
+ for i in range( main.numCtrls ):
+ intentResult = intentResult and \
+ main.CLIs[ i ].checkIntentState( intentsId=intentsId )
+
+ return intentResult
+
+def checkFlowsState( main ):
+
+ main.log.info( itemName + ": Check flows state" )
+ checkFlowsResult = main.CLIs[ 0 ].checkFlowsState()
+ return checkFlowsResult
+
+def link( main, sw1, sw2, option):
+
+ # link down
+ main.log.info( itemName + ": Bring link " + option + "between " +
+ sw1 + " and " + sw2 )
+ linkResult = main.Mininet1.link( end1=sw1, end2=sw2, option=option )
+ return linkResult
+
+def removeAllIntents( main, intentsId ):
+ """
+ Remove all intents in the intentsId
+ """
+ import time
+ intentsRemaining = []
+ removeIntentResult = main.TRUE
+ # Remove intents
+ for intent in intentsId:
+ main.CLIs[ 0 ].removeIntent( intentId=intent, purge=True )
+
+ time.sleep( 5 )
+ # Checks if there is remaining intents using intents()
+ intentsRemaining = main.CLIs[ 0 ].intents( jsonFormat=False )
+ # If there is remianing intents then remove intents should fail
+
+ if intentsRemaining:
+ main.log.info( itemName + ": There are " +
+ str( len( intentsRemaining ) ) + " intents remaining, "
+ + "failed to remove all the intents " )
+ removeIntentResult = main.FALSE
+ main.log.info( intentsRemaining )
+ else:
+ main.log.info( itemName + ": There are no intents remaining, " +
+ "successfully removed all the intents." )
+ removeIntentResult = main.TRUE
+ return removeIntentResult
diff --git a/TestON/tests/FuncIntent/Dependency/__init__.py b/TestON/tests/FuncIntent/Dependency/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FuncIntent/Dependency/__init__.py
diff --git a/TestON/tests/FuncIntent/FuncIntent.py b/TestON/tests/FuncIntent/FuncIntent.py
index 1db5752..d5dc2a7 100644
--- a/TestON/tests/FuncIntent/FuncIntent.py
+++ b/TestON/tests/FuncIntent/FuncIntent.py
@@ -5,8 +5,6 @@
import time
import json
-time.sleep( 1 )
-
class FuncIntent:
def __init__( self ):
@@ -15,6 +13,7 @@
def CASE10( self, main ):
import time
import os
+ import imp
"""
Startup sequence:
cell <name>
@@ -27,22 +26,29 @@
onos-wait-for-start
"""
global init
+ global globalONOSip
try:
if type(init) is not bool:
init = False
except NameError:
init = False
+
+ main.wrapper = imp.load_source( 'FuncIntentFunction',
+ '/home/admin/ONLabTest/TestON/tests/' +
+ 'FuncIntent/Dependency/' +
+ 'FuncIntentFunction.py' )
#Local variables
cellName = main.params[ 'ENV' ][ 'cellName' ]
apps = main.params[ 'ENV' ][ 'cellApps' ]
gitBranch = main.params[ 'GIT' ][ 'branch' ]
- #benchIp = main.params[ 'BENCH' ][ 'ip1' ]
+ benchIp = os.environ[ 'OCN' ]
benchUser = main.params[ 'BENCH' ][ 'user' ]
topology = main.params[ 'MININET' ][ 'topo' ]
- #maxNodes = int( main.params[ 'availableNodes' ] )
main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
+ main.ONOSport = []
+ main.hostsData = {}
PULLCODE = False
if main.params[ 'GIT' ][ 'pull' ] == 'True':
PULLCODE = True
@@ -50,13 +56,12 @@
main.CLIs = []
for i in range( 1, int( main.numCtrls ) + 1 ):
main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+ main.ONOSport.append( main.params[ 'CTRL' ][ 'port' + str( i ) ] )
# -- INIT SECTION, ONLY RUNS ONCE -- #
if init == False:
init = True
- #main.ONOSip = []
- main.ONOSport = []
main.scale = ( main.params[ 'SCALE' ] ).split( "," )
main.numCtrls = int( main.scale[ 0 ] )
@@ -78,42 +83,24 @@
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
- # Populate main.ONOSip with ips from params
- #for i in range( 1, maxNodes + 1):
- # main.ONOSip.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
- # main.ONOSport.append( main.params[ 'CTRL' ][ 'port' +
- # str( i ) ])
-
- ONOSip = main.ONOSbench.getOnosIpFromEnv()
- main.log.info("\t\t CLUSTER IPs: \n\n" + str(ONOSip) + "\n\n")
+
+ globalONOSip = main.ONOSbench.getOnosIps()
+
+ maxNodes = ( len(globalONOSip) - 2 )
main.numCtrls = int( main.scale[ 0 ] )
main.scale.remove( main.scale[ 0 ] )
-
+
+ main.ONOSip = []
+ for i in range( maxNodes ):
+ main.ONOSip.append( globalONOSip[i] )
+
#kill off all onos processes
main.log.info( "Safety check, killing all ONOS processes" +
" before initiating enviornment setup" )
- for i in range( maxNodes ):
- main.ONOSbench.onosDie( main.ONOSip[ i ] )
- """
- main.step( "Apply cell to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- verifyResult = main.ONOSbench.verifyCell()
- stepResult = cellResult and verifyResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully applied cell to " + \
- "environment",
- onfail="Failed to apply cell to environment " )
- """
- """main.step( "Removing raft logs" )
- removeRaftResult = main.ONOSbench.onosRemoveRaftLogs()
- stepResult = removeRaftResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully removed raft logs",
- onfail="Failed to remove raft logs" )
- """
+ for i in range(maxNodes):
+ main.ONOSbench.onosDie( globalONOSip[ i ] )
+
print "NODE COUNT = ", main.numCtrls
main.log.info( "Creating cell file" )
cellIp = []
@@ -143,7 +130,7 @@
main.step( "Uninstalling ONOS package" )
onosUninstallResult = main.TRUE
- for i in range( main.numCtrls):
+ for i in range( main.numCtrls ):
onosUninstallResult = onosUninstallResult and \
main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
stepResult = onosUninstallResult
@@ -154,7 +141,7 @@
time.sleep( 5 )
main.step( "Installing ONOS package" )
onosInstallResult = main.TRUE
- for i in range( main.numCtrls):
+ for i in range( main.numCtrls ):
onosInstallResult = onosInstallResult and \
main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
stepResult = onosInstallResult
@@ -163,7 +150,7 @@
onpass="Successfully installed ONOS package",
onfail="Failed to install ONOS package" )
- time.sleep( 5 )
+ time.sleep( 20 )
main.step( "Starting ONOS service" )
stopResult = main.TRUE
startResult = main.TRUE
@@ -186,7 +173,7 @@
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 ):
@@ -198,6 +185,16 @@
onpass="Successfully start ONOS cli",
onfail="Failed to start ONOS cli" )
+ def CASE9( self, main ):
+ '''
+ Report errors/warnings/exceptions
+ '''
+ main.log.info( "Error report: \n" )
+ main.ONOSbench.logReport( globalONOSip[0],
+ [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
+ "s" )
+ #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
+
def CASE11( self, main ):
"""
Start mininet
@@ -223,6 +220,7 @@
"""
import re
+ main.case( "Assign switches to controllers" )
main.step( "Assigning switches to controllers" )
assignResult = main.TRUE
for i in range( 1, ( main.numSwitch + 1 ) ):
@@ -244,6 +242,19 @@
"to controller",
onfail="Failed to assign switches to " +
"controller" )
+ def CASE13( self, main ):
+ """
+ Discover all hosts and store its data to a dictionary
+ """
+ main.case( "Discover all hosts" )
+
+ stepResult = main.TRUE
+ main.step( "Discover all hosts using pingall " )
+ stepResult = main.wrapper.getHostsData( main )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully discovered hosts",
+ onfail="Failed to discover hosts" )
def CASE1001( self, main ):
"""
@@ -251,222 +262,177 @@
- Discover hosts
- Add host intents
- Check intents
- - Check flows
+ - Verify flows
- Ping hosts
- Reroute
- Link down
+ - Verify flows
+ - Check topology
- Ping hosts
- Link up
+ - Verify flows
+ - Check topology
- Ping hosts
- Remove intents
"""
import time
import json
import re
- """
- Create your item(s) here
- item = { 'name': '', 'host1':
- { 'name': '', 'MAC': '00:00:00:00:00:0X',
- 'id':'00:00:00:00:00:0X/-X' } , 'host2':
- { 'name': '', 'MAC': '00:00:00:00:00:0X',
- 'id':'00:00:00:00:00:0X/-X'}, 'link': { 'switch1': '',
- 'switch2': '', 'num':'' } }
- """
- # Local variables
- items = []
- ipv4 = { 'name': 'IPV4', 'host1':
- { 'name': 'h1', 'MAC': '00:00:00:00:00:01',
- 'id':'00:00:00:00:00:01/-1' } , 'host2':
- { 'name': 'h9', 'MAC': '00:00:00:00:00:09',
- 'id':'00:00:00:00:00:09/-1'}, 'link': { 'switch1': 's5',
- 'switch2': 's2', 'num':'18' } }
- dualStack1 = { 'name': 'DUALSTACK1', 'host1':
- { 'name': 'h3', 'MAC': '00:00:00:00:00:03',
- 'id':'00:00:00:00:00:03/-1' } , 'host2':
- { 'name': 'h11', 'MAC': '00:00:00:00:00:0B',
- 'id':'00:00:00:00:00:0B/-1'}, 'link': { 'switch1': 's5',
- 'switch2': 's2', 'num':'18' } }
- items.append( ipv4 )
- items.append( dualStack1 )
- # Global variables
-
- main.log.case( "Add host intents between 2 host" )
-
- for item in items:
- stepResult = main.TRUE
- itemName = item[ 'name' ]
- h1Name = item[ 'host1' ][ 'name' ]
- h2Name = item[ 'host2' ][ 'name' ]
- h1Mac = item[ 'host1' ][ 'MAC' ]
- h2Mac = item[ 'host2' ][ 'MAC' ]
- h1Id = item[ 'host1' ][ 'id']
- h2Id = item[ 'host2' ][ 'id']
- # Link down/up for rerouting
- sw1 = item[ 'link' ][ 'switch1' ]
- sw2 = item[ 'link' ][ 'switch2' ]
- remLink = item[ 'link' ][ 'num' ]
- pingResult = main.TRUE
- statusResult = main.TRUE
- linkDownResult = main.TRUE
- linkUpResult = main.TRUE
- intentsId = []
- main.step( itemName + ": Add host intents between " + h1Name
- + " and " + h2Name )
- main.log.info( itemName + ": Discover host using arping" )
- main.Mininet1.arping( host=h1Name )
- main.Mininet1.arping( host=h2Name )
- host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
- host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
- print host1
- print host2
- # Adding intents
- main.log.info( itemName + ": Adding host intents" )
- intent1 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h1Id,
- hostIdTwo=h2Id )
- intentsId.append( intent1 )
- time.sleep( 5 )
- intent2 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h2Id,
- hostIdTwo=h1Id )
- intentsId.append( intent2 )
- # Checking intents
- main.log.info( itemName + ": Check host intents state" )
- time.sleep( 30 )
- for i in range( main.numCtrls ):
- intentResult = main.CLIs[ i ].checkIntentState(
- intentsId=intentsId )
- if not intentResult:
- main.log.info( itemName + ": Check host intents state" +
- " again")
- for i in range( main.numCtrls ):
- intentResult = main.CLIs[ i ].checkIntentState(
- intentsId=intentsId )
- # Ping hosts
- time.sleep( 10 )
- main.log.info( itemName + ": Ping " + h1Name + " and " +
- h2Name )
- pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
- if not pingResult1:
- main.log.info( itemName + ": " + h1Name + " cannot ping "
- + h2Name )
- pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
- if not pingResult2:
- main.log.info( itemName + ": " + h2Name + " cannot ping "
- + h1Name )
- pingResult = pingResult1 and pingResult2
- if pingResult:
- main.log.info( itemName + ": Successfully pinged " +
- "both hosts" )
- else:
- main.log.info( itemName + ": Failed to ping " +
- "both hosts" )
- # Rerouting ( link down )
- main.log.info( itemName + ": Bring link down between " +
- sw1 + " and " + sw2 )
- main.Mininet1.link( end1=sw1,
- end2=sw2,
- option="down" )
- time.sleep( 5 )
- # Check onos topology
- main.log.info( itemName + ": Checking ONOS topology " )
+ # Assert variables - These variable's name|format must be followed
+ # if you want to use the wrapper function
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
- for i in range( main.numCtrls ):
- topologyResult = main.CLIs[ i ].topology()
- linkDownResult = main.ONOSbench.checkStatus( topologyResult,
- main.numSwitch,
- remLink )\
- and linkDownResult
- if not linkDownResult:
- main.log.info( itemName + ": Topology mismatch" )
- else:
- main.log.info( itemName + ": Topology match" )
+ main.case( "Add host intents between 2 host" )
- # Ping hosts
- main.log.info( itemName + ": Ping " + h1Name + " and " +
- h2Name )
- pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
- if not pingResult1:
- main.log.info( itemName + ": " + h1Name + " cannot ping "
- + h2Name )
- pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
- if not pingResult2:
- main.log.info( itemName + ": " + h2Name + " cannot ping "
- + h1Name )
- pingResult = pingResult1 and pingResult2
- if pingResult:
- main.log.info( itemName + ": Successfully pinged " +
- "both hosts" )
- else:
- main.log.info( itemName + ": Failed to ping " +
- "both hosts" )
- # link up
- main.log.info( itemName + ": Bring link up between " +
- sw1 + " and " + sw2 )
- main.Mininet1.link( end1=sw1,
- end2=sw2,
- option="up" )
- time.sleep( 5 )
+ stepResult = main.TRUE
+ main.step( "IPV4: Add host intents between h1 and h9" )
+ stepResult = main.wrapper.hostIntent( main,
+ name='IPV4',
+ host1='h1',
+ host2='h9',
+ host1Id='00:00:00:00:00:01/-1',
+ host2Id='00:00:00:00:00:09/-1',
+ sw1='s5',
+ sw2='s2',
+ expectedLink=18 )
- # Check onos topology
- main.log.info( itemName + ": Checking ONOS topology " )
- for i in range( main.numCtrls ):
- topologyResult = main.CLIs[ i ].topology()
- linkUpResult = main.ONOSbench.checkStatus( topologyResult,
- main.numSwitch,
- main.numLinks )\
- and linkUpResult
- if not linkUpResult:
- main.log.info( itemName + ": Topology mismatch" )
- else:
- main.log.info( itemName + ": Topology match" )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Add host intent successful",
+ onfail="IPV4: Add host intent failed" )
+ stepResult = main.TRUE
- # Ping hosts
- main.log.info( itemName + ": Ping " + h1Name + " and " +
- h2Name )
- pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
- if not pingResult1:
- main.log.info( itemName + ": " + h1Name + " cannot ping "
- + h2Name )
- pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
- if not pingResult2:
- main.log.info( itemName + ": " + h2Name + " cannot ping "
- + h1Name )
- pingResult = pingResult1 and pingResult2
- if pingResult:
- main.log.info( itemName + ": Successfully pinged " +
- "both hosts" )
- else:
- main.log.info( itemName + ": Failed to ping " +
- "both hosts" )
+ main.step( "DUALSTACK1: Add host intents between h3 and h11" )
+ stepResult = main.wrapper.hostIntent( main,
+ name='DUALSTACK',
+ host1='h3',
+ host2='h11',
+ host1Id='00:00:00:00:00:03/-1',
+ host2Id='00:00:00:00:00:0B/-1',
+ sw1='s5',
+ sw2='s2',
+ expectedLink=18 )
- # Remove intents
- for intent in intentsId:
- main.CLIs[ 0 ].removeIntent( intentId=intent, purge=True )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="DUALSTACK1: Add host intent" +
+ " successful",
+ onfail="DUALSTACK1: Add host intent failed" )
- print main.CLIs[ 0 ].intents()
- stepResult = pingResult and linkDownResult and linkUpResult \
- and intentResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass=itemName +
- ": host intent successful",
- onfail=itemName +
- ": Add host intent failed" )
+ stepResult = main.TRUE
+ main.step( "DUALSTACK2: Add host intents between h1 and h9" )
+ stepResult = main.wrapper.hostIntent( main,
+ name='DUALSTACK2',
+ host1='h1',
+ host2='h11',
+ sw1='s5',
+ sw2='s2',
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="DUALSTACK2: Add host intent" +
+ " successful",
+ onfail="DUALSTACK2: Add host intent failed" )
+
def CASE1002( self, main ):
"""
Add point intents between 2 hosts:
- - Get device ids
+ - Get device ids | ports
- Add point intents
- Check intents
- - Check flows
+ - Verify flows
- Ping hosts
- Reroute
- Link down
+ - Verify flows
+ - Check topology
- Ping hosts
- Link up
+ - Verify flows
+ - Check topology
- Ping hosts
- Remove intents
"""
+ import time
+ import json
+ import re
+
+ # Assert variables - These variable's name|format must be followed
+ # if you want to use the wrapper function
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+
+ main.case( "Add point intents between 2 devices" )
+
+ stepResult = main.TRUE
+ main.step( "IPV4: Add point intents between h1 and h9" )
+ stepResult = main.wrapper.pointIntent(
+ main,
+ name="IPV4",
+ host1="h1",
+ host2="h9",
+ deviceId1="of:0000000000000005/1",
+ deviceId2="of:0000000000000006/1",
+ port1="",
+ port2="",
+ ethType="IPV4",
+ mac1="00:00:00:00:00:01",
+ mac2="00:00:00:00:00:09",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Add point intent successful",
+ onfail="IPV4: Add point intent failed" )
+
+ stepResult = main.TRUE
+ main.step( "DUALSTACK1: Add point intents between h1 and h9" )
+ stepResult = main.wrapper.pointIntent(
+ main,
+ name="DUALSTACK1",
+ host1="h3",
+ host2="h11",
+ deviceId1="of:0000000000000005",
+ deviceId2="of:0000000000000006",
+ port1="3",
+ port2="3",
+ ethType="IPV4",
+ mac1="00:00:00:00:00:03",
+ mac2="00:00:00:00:00:0B",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="DUALSTACK1: Add point intent" +
+ " successful",
+ onfail="DUALSTACK1: Add point intent failed" )
def CASE1003( self, main ):
"""
@@ -474,28 +440,141 @@
- Get device ids
- Add single point to multi point intents
- Check intents
- - Check flows
+ - Verify flows
- Ping hosts
- Reroute
- Link down
+ - Verify flows
+ - Check topology
- Ping hosts
- Link up
+ - Verify flows
+ - Check topology
- Ping hosts
- Remove intents
"""
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+ main.case( "Add single point to multi point intents between devices" )
+
+ stepResult = main.TRUE
+ main.step( "IPV4: Add single point to multi point intents" )
+ hostNames = [ 'h8', 'h16', 'h24' ]
+ devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
+ 'of:0000000000000007/8' ]
+ macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
+ stepResult = main.wrapper.singleToMultiIntent(
+ main,
+ name="IPV4",
+ hostNames=hostNames,
+ devices=devices,
+ ports=None,
+ ethType="IPV4",
+ macs=macs,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Successfully added single point"
+ + " to multi point intents",
+ onfail="IPV4: Failed to add single point" +
+ " to multi point intents" )
+
+ main.step( "IPV4_2: Add single point to multi point intents" )
+ hostNames = [ 'h8', 'h16', 'h24' ]
+ stepResult = main.wrapper.singleToMultiIntent(
+ main,
+ name="IPV4",
+ hostNames=hostNames,
+ ethType="IPV4",
+ lambdaAlloc=False )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4_2: Successfully added single point"
+ + " to multi point intents",
+ onfail="IPV4_2: Failed to add single point" +
+ " to multi point intents" )
def CASE1004( self, main ):
"""
Add multi point to single point intents
- Get device ids
- Add multi point to single point intents
- Check intents
- - Check flows
+ - Verify flows
- Ping hosts
- Reroute
- Link down
+ - Verify flows
+ - Check topology
- Ping hosts
- Link up
+ - Verify flows
+ - Check topology
- Ping hosts
- Remove intents
"""
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+
+ main.case( "Add multi point to single point intents between devices" )
+
+ stepResult = main.TRUE
+ main.step( "IPV4: Add multi point to single point intents" )
+ hostNames = [ 'h8', 'h16', 'h24' ]
+ devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
+ 'of:0000000000000007/8' ]
+ macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
+ stepResult = main.wrapper.multiToSingleIntent(
+ main,
+ name="IPV4",
+ hostNames=hostNames,
+ devices=devices,
+ ports=None,
+ ethType="IPV4",
+ macs=macs,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Successfully added multi point"
+ + " to single point intents",
+ onfail="IPV4: Failed to add multi point" +
+ " to single point intents" )
+
+ main.step( "IPV4_2: Add multi point to single point intents" )
+ hostNames = [ 'h8', 'h16', 'h24' ]
+ stepResult = main.wrapper.multiToSingleIntent(
+ main,
+ name="IPV4",
+ hostNames=hostNames,
+ ethType="IPV4",
+ lambdaAlloc=False )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4_2: Successfully added multi point"
+ + " to single point intents",
+ onfail="IPV4_2: Failed to add multi point" +
+ " to single point intents" )
diff --git a/TestON/tests/FuncIntent/FuncIntent.topo b/TestON/tests/FuncIntent/FuncIntent.topo
index e85b397..e6613de 100755
--- a/TestON/tests/FuncIntent/FuncIntent.topo
+++ b/TestON/tests/FuncIntent/FuncIntent.topo
@@ -2,7 +2,7 @@
<COMPONENT>
<ONOSbench>
- <host>10.128.5.55</host>
+ <host>OCN</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosDriver</type>
@@ -13,7 +13,7 @@
</ONOSbench>
<ONOScli1>
- <host>10.128.5.55</host>
+ <host>OCN</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -22,7 +22,7 @@
</ONOScli1>
<ONOScli2>
- <host>10.128.5.55</host>
+ <host>OCN</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -31,7 +31,7 @@
</ONOScli2>
<ONOScli3>
- <host>10.128.5.55</host>
+ <host>OCN</host>
<user>admin</user>
<password>onos_test</password>
<type>OnosCliDriver</type>
@@ -40,7 +40,7 @@
</ONOScli3>
<Mininet1>
- <host>10.128.10.20</host>
+ <host>OCN</host>
<user>admin</user>
<password>onos_test</password>
<type>MininetCliDriver</type>
diff --git a/TestON/tests/FuncIntent/__init__.py b/TestON/tests/FuncIntent/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FuncIntent/__init__.py
diff --git a/TestON/tests/FuncPlatform/Dependency/App.py b/TestON/tests/FuncPlatform/Dependency/App.py
new file mode 100644
index 0000000..5410c32
--- /dev/null
+++ b/TestON/tests/FuncPlatform/Dependency/App.py
@@ -0,0 +1,68 @@
+"""
+Methods related to application interaction
+
+"""
+
+
+def __init__( self ):
+ self.ip = '127.0.0.1'
+
+def activate( apps, nodeToActivateFrom=0 ):
+ """
+ Activate specified applications from node specified
+
+ Ex) apps = ['metrics', 'fwd']
+ nodeToActivateFrom = range( 0, nodes )
+ """
+ if isinstance( apps, ( int, basestring ) ):
+ main.log.error( 'Please pass in a list of strings for args' )
+ return main.FALSE
+
+ if not isinstance( nodeToActivateFrom, ( int ) ) or \
+ nodeToActivateFrom < 0:
+ main.log.error( 'Incorrect node specified' )
+ return main.FALSE
+
+ # TODO: Start log capture and listen for exceptions
+ # and errors. Also investigate possible keywords
+ # to listen for when activating applications
+
+
+ for app in apps:
+ # Check if app str in appList is in the main scope
+ # definition main.appList
+ if app not in main.appList:
+ main.log.error( 'Invalid app name given' )
+ return main.FALSE
+
+ try:
+ # NOTE: assumes node 1 is always activating application
+ appOutput = main.CLIs[nodeToActivateFrom].activateApp(
+ main.appList[app] )
+ except KeyError:
+ main.log.error( 'There was an error with the key '+
+ str(app) + '. Check the appList dictionary' )
+ return main.FALSE
+ except Exception:
+ main.log.error( 'Uncaught exception error while ' +
+ 'activating applications: ' + str(app) )
+ return main.FALSE
+
+ return main.TRUE
+
+def deactivate( apps, nodeToDeactivateFrom=0 ):
+ """
+ Deactivate specified applications from node specified
+
+ """
+ main.log.report( 'deactivate implment me' )
+
+def isAppInstallSuccess():
+ """
+ Check the app list across clusters to determine
+ that apps have been installed successfully
+
+ """
+
+ main.log.report( 'isAppInstallSuccess implement me' )
+
diff --git a/TestON/tests/FuncPlatform/Dependency/Logger.py b/TestON/tests/FuncPlatform/Dependency/Logger.py
new file mode 100644
index 0000000..22d3f61
--- /dev/null
+++ b/TestON/tests/FuncPlatform/Dependency/Logger.py
@@ -0,0 +1,57 @@
+
+def __init__( self ):
+ self.ip = '127.0.0.1'
+
+def checkOnosLog( nodeIp, option='',
+ outputType=0):
+ """
+ Listens to the log for any Errors and Exceptions.
+
+ Runs 'onos-check-logs <option>'
+ This script only returns if there are any errors
+ or exceptions
+
+ outputType
+ 0: Return output of log
+ 1: Return (#Errors, #Exceptions, #Warn)
+
+ """
+ if not isinstance( option, basestring ):
+ main.log.error( 'Incorrect grep format specified' )
+ return main.FALSE
+
+ try:
+ main.log.info( 'Starting Onos-log listening for '+
+ str(option) )
+ cmd = 'onos-check-logs ' + str(nodeIp) + ' old'
+ if outputType == 0:
+ main.ONOSbench.handle.sendline( cmd )
+ main.ONOSbench.handle.expect( cmd )
+ main.ONOSbench.handle.expect('\$')
+ logResult = main.ONOSbench.handle.before
+ return logResult
+ elif outputType == 1:
+ # Important in assertion criteria
+ # to determine how much warn / error is
+ # acceptable
+ return 'Implement option 1'
+ else:
+ main.log.error( 'Incorrect outputType specified' )
+ return main.FALSE
+
+ except Exception:
+ main.log.exception( self.name + ': Uncaught exception' )
+ main.cleanup()
+ main.exit()
+
+def setLogLevel( level ):
+ """
+ Set the log level of onos
+ """
+ main.log.info( 'setLogLevel implement me' )
+
+def getLogReport( nodeIp, searchTerms ):
+ """
+ Refer to CLI driver for 'logReport'
+ """
+ main.log.info( 'getLogReport - implement me!' )
diff --git a/TestON/tests/FuncPlatform/Dependency/Shutdown.py b/TestON/tests/FuncPlatform/Dependency/Shutdown.py
new file mode 100644
index 0000000..ba77bbd
--- /dev/null
+++ b/TestON/tests/FuncPlatform/Dependency/Shutdown.py
@@ -0,0 +1,19 @@
+
+def __init__( self ):
+ self.ip = '127.0.0.1'
+
+def killOnosNodes( nodeIps ):
+ """
+ Kill all components of Onos on
+ given list of ips
+
+ Ex) nodeIps = ['10.0.0.1', '10.0.0.2']
+ """
+ killResult = main.TRUE
+
+ for node in nodeIps:
+ killResult = killResult and main.ONOSbench.onosDie( node )
+ if killResult == main.TRUE:
+ main.log.info( str(node) + ' was killed' )
+
+ return killResult
diff --git a/TestON/tests/FuncPlatform/Dependency/Startup.py b/TestON/tests/FuncPlatform/Dependency/Startup.py
new file mode 100644
index 0000000..f3f90a9
--- /dev/null
+++ b/TestON/tests/FuncPlatform/Dependency/Startup.py
@@ -0,0 +1,219 @@
+
+"""
+Startup related methods for ONOS
+
+Guidelines:
+ * Group sequential functionalities together
+ * Methods should not be dependent on platform
+ * Return main.TRUE on success or comprehensive error message
+ on failure (TBD)
+ * All methods should be consistent in expected behavior
+"""
+import time
+import json
+
+def __init__( self ):
+ self.ip = '127.0.0.1'
+
+def gitPullAndMci( branchName, commitLog=False ):
+ """
+ Pull from branch repository specified and compile changes
+ If commitLog is True, report commit information
+
+ Any errors / warnings will be handled by respective
+ driver function calls
+ """
+ co = main.ONOSbench.gitCheckout( branchName )
+ gp = main.ONOSbench.gitPull()
+ ci = main.ONOSbench.cleanInstall()
+
+ if co and gp and ci == main.TRUE:
+ if commitLog:
+ main.log.report( 'Commit information - ' )
+ main.ONOSbench.getVersion(report=True)
+
+ return main.TRUE
+
+ else:
+ # TODO: Comprehensive error message
+ return 'git pull and mci failed'
+
+def initOnosStartupSequence( cellName, appStr, benchIp, mnIp, onosIps ):
+ """
+ Startup sequence includes the following:
+ * Create cell file
+ * Set cell variables on ONOS bench
+ * Verify cell
+ * Create ONOS package
+ * Force install ONOS package
+ * Start ONOS service
+ * Start ONOS cli
+
+ Also verifies that Onos is up and running by
+ 'isup' driver function which executs
+ 'onos-wait-for-start'
+ """
+
+ # NOTE: leave out create cell file until bug addressed
+ #cf = main.ONOSbench.createCellFile( benchIp, cellName, mnIp,
+ # str(appStr), *onosIps )
+ numNodes = len(onosIps)
+
+ sc = main.ONOSbench.setCell( cellName )
+ vc = main.ONOSbench.verifyCell()
+ op = main.ONOSbench.onosPackage()
+ for addr in onosIps:
+ oi = main.ONOSbench.onosInstall( node = addr )
+
+ time.sleep( 5 )
+
+ iu = main.TRUE
+ for node in onosIps:
+ iu = iu and main.ONOSbench.isup( node )
+
+ cli = main.TRUE
+ for node in range( 0, numNodes ):
+ cli = cli and main.CLIs[node].startOnosCli( onosIps[node] )
+
+ # Check if all nodes are discovered correctly using
+ # 'nodes' command in Onos Cli
+ na = main.TRUE
+ try:
+ nodeCmdJson = json.loads( main.CLIs[0].nodes() )
+ for node in nodeCmdJson:
+ if node['state'] != 'ACTIVE':
+ main.log.warn( str( node['id'] ) +
+ ' Node is not in ACTIVE state.' )
+ na = main.FALSE
+ if na != main.FALSE:
+ main.log.info( 'All nodes discovered successfully' )
+ except Exception:
+ main.log.error( 'nodes command did not execute properly' )
+ return main.FALSE
+
+ if sc and vc and op and oi and iu and cli and na == main.TRUE:
+ return main.TRUE
+ else:
+ return main.FALSE
+
+def installOnosFromTar( wgetAddr, nodeIps ):
+ """
+ Install Onos directly from tar.gz file.
+ Due to the nature of the specific steps required
+ to startup Onos in this fashion, all commands
+ required to start Onos from tar.gz will be
+ grouped in this method.
+
+ 1) wget latest onos tar.gz on onos node
+ 2) untar package
+ 3) specify onos-config cluster
+ 4) start onos via onos-service
+ 5) form onos cluster using onos-form-cluster
+ 6) check for successful startup
+
+ Specify the download link for the tar.gz.
+ Provide a list of nodeIps
+
+ Ex) wgetAddr = 'https://mytargzdownload.com/file.tar.gz'
+ nodeIps = ['10.0.0.1', '10.0.0.2']
+ """
+ if isinstance( nodeIps, ( int, basestring ) ):
+ main.log.error( 'Please pass in a list of string nodes' )
+ return main.FALSE
+
+ # Obtain filename from provided address
+ # assumes that filename is separated by '/' character
+ f_name = ''
+ addr = str( wgetAddr ).split('/')
+ for phrase in addr:
+ if 'tar.gz' in phrase:
+ f_name = str( phrase )
+ main.log.info( 'Using ' + f_name + ' as file' )
+
+ clusterCount = len( nodeIps )
+
+ main.log.info( 'Initiating Onos installation sequence ' +
+ 'using tar.gz ... This may take a few minutes' )
+
+ for node in range( 0, clusterCount ):
+ # Use the wgetAddr to download a new tar.gz from server
+ try:
+ main.ONOSnode[node].handle.sendline( 'wget ' + wgetAddr )
+ main.ONOSnode[node].handle.expect( 'saved' )
+ main.ONOSnode[node].handle.expect( '\$' )
+ main.log.info( 'Successfully downloaded tar.gz ' +
+ 'on node: ' + str( main.ONOSips[node] ) )
+ except Exception:
+ # NOTE: Additional exception may be appropriate
+ main.log.error( 'Uncaught exception while ' +
+ 'downloading Onos tar.gz: ' +
+ main.ONOSnode[node].handle.before )
+ return main.FALSE
+
+ for node in range( 0, clusterCount ):
+ # Untar files on all nodes, then enter the
+ # newly created directory
+ try:
+ main.ONOSnode[node].handle.sendline( 'tar zxvf ' + f_name )
+ # Verbose output of tar will contain some onos returns
+ main.ONOSnode[node].handle.expect( 'onos' )
+ main.ONOSnode[node].handle.expect( '\$' )
+ # NOTE: Making an assumption here:
+ # the directory created by tar file has a name that
+ # starts with 'onos-' followed by version number
+ # '1.2.0'. If this is NOT true, this method must
+ # be changed to enter the correct directory.
+ # The directory name is currently dynamic
+ # and depends on the day at which you downloaded
+ # the tar file
+ # Enter onos- wildcard to disregard its version / date
+ # suffix
+ main.ONOSnode[node].handle.sendline( 'cd onos-*' )
+ main.ONOSnode[node].handle.expect( '\$' )
+
+ main.ONOSnode[node].handle.sendline( 'pwd' )
+ main.ONOSnode[node].handle.expect( 'pwd' )
+ main.ONOSnode[node].handle.expect( '\$' )
+ pwd = main.ONOSnode[node].handle.before
+ if 'onos' in str(pwd):
+ main.log.info( 'tar zxvf ' + f_name + ' successful ' +
+ 'on node ' + str( main.ONOSips[node] ) )
+
+ except Exception:
+ main.log.error( 'Uncaught exception while executing ' +
+ 'tar zxvf of ' + f_name + ': ' +
+ main.ONOSnode[node].handle.before +
+ main.ONOSnode[node].handle.after)
+ return main.FALSE
+
+ for node in range( 0, clusterCount ):
+ try:
+ main.ONOSnode[node].handle.sendline( 'bin/onos-service '+
+ 'server &' )
+ # Send some extra characters to run the process
+ main.ONOSnode[node].handle.sendline( '' )
+ main.ONOSnode[node].handle.sendline( '' )
+ main.ONOSnode[node].handle.expect( '\$' )
+ except Exception:
+ main.log.error( 'Uncaught exception while executing ' +
+ 'onos-service server command ' +
+ str( main.ONOSnode[node].handle.before ) )
+ return main.FALSE
+
+ iu = main.TRUE
+ for node in nodeIps:
+ iu = iu and main.ONOSbench.isup( node )
+
+ if iu == main.TRUE:
+ return main.TRUE
+ else:
+ return main.FALSE
+
+def addAndStartOnosNode( nodeIps ):
+ """
+ A scale-out scenario that adds specified list of
+ nodes and starts those instances.
+
+ Ex) nodeIps = ['10.0.0.2', '10.0.0.3', 10.0.0.4']
+ """
+ main.log.info( 'addAndStartOnosNode implement me!' )
diff --git a/TestON/tests/FuncPlatform/FuncPlatform.params b/TestON/tests/FuncPlatform/FuncPlatform.params
new file mode 100644
index 0000000..3895660
--- /dev/null
+++ b/TestON/tests/FuncPlatform/FuncPlatform.params
@@ -0,0 +1,63 @@
+<PARAMS>
+ <testcases>1,2,3,4</testcases>
+ <DEP>
+ <startupSrc>
+ /home/admin/ONLabTest/TestON/tests/FuncPlatform/Dependency/Startup.py
+ </startupSrc>
+ <startupClassName>
+ Startup
+ </startupClassName>
+
+ <appSrc>
+ /home/admin/ONLabTest/TestON/tests/FuncPlatform/Dependency/App.py
+ </appSrc>
+ <appClassName>
+ App
+ </appClassName>
+
+ <logSrc>
+ /home/admin/ONLabTest/TestON/tests/FuncPlatform/Dependency/Logger.py
+ </logSrc>
+ <logClassName>
+ Log
+ </logClassName>
+
+ <shutdownSrc>
+ /home/admin/ONLabTest/TestON/tests/FuncPlatform/Dependency/Shutdown.py
+ </shutdownSrc>
+ <shutdownClassName>
+ Shutdown
+ </shutdownClassName>
+
+ <targz>
+ http://downloads.onosproject.org/nightly/onos-1.2.0.latest-NIGHTLY.tar.gz
+ </targz>
+ </DEP>
+
+ <CTRL>
+ <num>3</num>
+ <port>6633</port>
+ <ip1>10.128.174.1</ip1>
+ <ip2>10.128.174.2</ip2>
+ <ip3>10.128.174.3</ip3>
+ </CTRL>
+
+ <MN>
+ <ip>10.128.10.90</ip>
+ </MN>
+
+ <BENCH>
+ <ip>10.128.174.10</ip>
+ </BENCH>
+
+ <CELL>
+ <name>func_plat</name>
+ <appStr>"drivers,openflow"</appStr>
+ </CELL>
+
+ <GIT>
+ <branchName>master</branchName>
+ <pull>off</pull>
+ </GIT>
+
+</PARAMS>
diff --git a/TestON/tests/FuncPlatform/FuncPlatform.py b/TestON/tests/FuncPlatform/FuncPlatform.py
new file mode 100644
index 0000000..60b1aa0
--- /dev/null
+++ b/TestON/tests/FuncPlatform/FuncPlatform.py
@@ -0,0 +1,194 @@
+"""
+FuncPlatform
+
+A functional test designed to test the environment and
+gather information on startup -> shutdown related issues.
+
+Future works may also include security mode startup /
+shutdown check and cfg get and set.
+
+Abstracting the collection of commands that go hand in hand
+should allow easy rearrangement of steps to replicate or
+create scenarios.
+For example:
+ CASE N - Represents a particular scenario
+ Steps - Represents abstraction methods called from
+ dependency
+ 1. Bring ONOS 1 up
+ 2. Activate application X
+ 3. Activate application Y
+ 4. Deactivate application X
+
+The ideal platform test script should have incredible
+robustness to possible exceptions and report the most
+useful error messages.
+
+contributers to contact for help:
+andrew@onlab.us
+"""
+
+class FuncPlatform:
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ """
+ Main scope initialization case
+ Must include to run any other test cases
+ """
+ import imp
+
+ # NOTE: Hardcoded application name subject to change
+ # closely monitor and make changes when necessary
+ # (or implement ways to dynamically get names)
+ main.appList = {
+ 'bgprouter' : 'org.onosproject.bgprouter',
+ 'config' : 'org.onosproject.config',
+ 'cordfabric' : 'org.onosproject.cordfabric',
+ 'demo' : 'org.onosproject.demo',
+ 'distributedprimitives' : 'org.onosproject.distributedprimitives',
+ 'election' : 'org.onosproject.election',
+ 'flowrule' : 'org.onosproject.flowrule',
+ 'fwd' : 'org.onosproject.fwd',
+ 'intentperf' : 'org.onosproject.intentperf',
+ 'messagingperf' : 'org.onosproject.messagingperf',
+ 'metrics' : 'org.onosproject.metrics',
+ 'mobility' : 'org.onosproject.mobility',
+ 'netconf' : 'org.onosproject.netconf',
+ 'null' : 'org.onosproject.null',
+ 'optical' : 'org.onosproject.optical',
+ 'pcep' : 'org.onosproject.pcep',
+ 'proxyarp' : 'org.onosproject.proxyarp',
+ 'reactive.routing' : 'org.onosproject.reactive.routing',
+ 'sdnip' : 'org.onosproject.sdnip',
+ 'segmentrouting' : 'org.onosproject.segmentrouting',
+ 'tunnel' : 'org.onosproject.tunnel',
+ 'virtualbng' : 'org.onosproject.virtualbng',
+ 'xosintegration' : 'org.onosproject.xosintegration'
+ }
+ # List of ONOS ip's specififed in params
+ main.ONOSips = []
+ main.CLIs = []
+ main.ONOSnode = []
+
+ for node in range( 0, int(main.params['CTRL']['num']) ):
+ main.ONOSips.append( main.params['CTRL']['ip'+str(node+1)] )
+ main.CLIs.append(
+ getattr( main, 'ONOS' + str(node+1) + 'cli' ) )
+ main.ONOSnode.append(
+ getattr( main, 'ONOS' + str(node+1) ) )
+
+ # Application source and name definitions
+ startupSrc = main.params['DEP']['startupSrc']
+ startupClassName = main.params['DEP']['startupClassName']
+
+ appClassName = main.params['DEP']['appClassName']
+ appSrc = main.params['DEP']['appSrc']
+
+ logClassName = main.params['DEP']['logClassName']
+ logSrc = main.params['DEP']['logSrc']
+
+ shutdownClassName = main.params['DEP']['shutdownClassName']
+ shutdownSrc = main.params['DEP']['shutdownSrc']
+
+ # Importing dependency class(es)
+ # Refer to source files in Dependency folder to
+ # make changes to its respective methods
+ # Be weary of naming collisions
+ try:
+ main.startup = imp.load_source( startupClassName, startupSrc )
+ main.app = imp.load_source( appClassName, appSrc )
+ main.onosLog = imp.load_source( logClassName, logSrc )
+ main.shutdown = imp.load_source( shutdownClassName, shutdownSrc )
+ except ImportError:
+ main.log.error( 'Error importing class file(s). Please ' +
+ 'check file location' )
+ main.cleanup()
+ main.exit()
+
+ def CASE2( self, main ):
+ import time
+
+ cellName = main.params['CELL']['name']
+ appStr = main.params['CELL']['appStr']
+ benchIp = main.params['BENCH']['ip']
+ branchName = main.params['GIT']['branchName']
+ gitPull = main.params['GIT']['pull']
+ mnIp = main.params['MN']['ip']
+
+ main.case( 'Setup environment and install ONOS' )
+ if gitPull == 'on':
+ main.step( 'Git pull and clean install' )
+ gitPullResult = main.startup.gitPullAndMci( branchName )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=gitPullResult,
+ onpass='Git pull and install successful',
+ onfail='Git pull and install failed: ' +
+ str(gitPullResult) )
+
+ main.step( 'Initiate ONOS startup sequence' )
+ startupResult = main.startup.initOnosStartupSequence(
+ cellName, appStr, benchIp, mnIp, main.ONOSips )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=startupResult,
+ onpass='ONOS startup sequence successful',
+ onfail='ONOS startup sequence failed: ' +
+ str(startupResult) )
+
+ def CASE3( self, main ):
+ import time
+
+ main.case( 'Activate applications and check installation' )
+
+ # NOTE: Test only
+ # Unceremoniously kill onos 2
+ main.ONOSbench.onosDie( '10.128.174.2' )
+
+ time.sleep( 30 )
+
+ main.step( 'Sample Onos log check' )
+ logResult = main.onosLog.checkOnosLog( main.ONOSips[0] )
+ main.log.info( logResult )
+ # TODO: Define pass criteria
+ utilities.assert_equals( expect=main.TRUE,
+ actual=main.TRUE,
+ onpass= 'Logging successful',
+ onfail= 'Logging failed ' )
+
+ # Sample app activation
+ main.step( 'Activating applications metrics and fwd' )
+ appList = ['metrics', 'fwd']
+ appResult = main.app.activate( appList )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=appResult,
+ onpass= 'App activation of ' + str(appList) + ' successful',
+ onfail= 'App activation failed ' + str(appResult) )
+
+ def CASE4( self, main ):
+ """
+ Download ONOS tar.gz built from latest nightly
+ (following tutorial on wiki) and run ONOS directly on the
+ instance
+ """
+ import imp
+
+ targz = main.params['DEP']['targz']
+ clusterCount = main.params['CTRL']['num']
+
+ main.case( 'Install ONOS from onos.tar.gz file' )
+
+ main.step( 'Killing all ONOS instances previous started' )
+ killResult = main.shutdown.killOnosNodes( main.ONOSips )
+ utilities.assert_equals( expect=main.TRUE,
+ actual = killResult,
+ onpass = 'All Onos nodes successfully killed',
+ onfail = 'Onos nodes were not successfully killed' )
+
+ main.step( 'Starting ONOS using tar.gz on all nodes' )
+ installResult = main.startup.installOnosFromTar( targz, main.ONOSips )
+ utilities.assert_equals( expect=main.TRUE,
+ actual = installResult,
+ onpass= 'Onos tar.gz installation successful',
+ onfail= 'Onos tar.gz installation failed' )
+
+
diff --git a/TestON/tests/FuncPlatform/FuncPlatform.topo b/TestON/tests/FuncPlatform/FuncPlatform.topo
new file mode 100644
index 0000000..f19e8f8
--- /dev/null
+++ b/TestON/tests/FuncPlatform/FuncPlatform.topo
@@ -0,0 +1,82 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.174.10</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1>
+ <host>10.128.174.1</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.174.2</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.174.3</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS1cli>
+ <host>10.128.174.10</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1cli>
+
+ <ONOS2cli>
+ <host>10.128.174.10</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2cli>
+
+ <ONOS3cli>
+ <host>10.128.174.10</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3cli>
+
+ <MininetOvs>
+ <host>10.128.10.90</host>
+ <user>admin</user>
+ <password></password>
+ <type>MininetCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS>
+ <arg1> --custom topo-perf-2sw.py </arg1>
+ <arg2> --arp --mac --topo mytopo </arg2>
+ <arg3> </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </MininetOvs>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/FuncIntent/FuncIntent.params b/TestON/tests/FuncStartTemplate/FuncStartTemplate.params
similarity index 84%
rename from TestON/tests/FuncIntent/FuncIntent.params
rename to TestON/tests/FuncStartTemplate/FuncStartTemplate.params
index 3d2ef8a..310e5f8 100755
--- a/TestON/tests/FuncIntent/FuncIntent.params
+++ b/TestON/tests/FuncStartTemplate/FuncStartTemplate.params
@@ -1,8 +1,8 @@
<PARAMS>
- <testcases>10,11,12,1001,10,12,1001</testcases>
-
- <SCALE>1,3</SCALE>
+ <testcases>10,9,10,9</testcases>
+
+ <SCALE>3,1</SCALE>
<availableNodes>3</availableNodes>
<ENV>
<cellName>single_func</cellName>
@@ -23,7 +23,7 @@
</CTRL>
<BENCH>
<user>admin</user>
- <ip1>10.128.10.20</ip1>
+ <ip1>OCN</ip1>
</BENCH>
<MININET>
<switch>7</switch>
diff --git a/TestON/tests/FuncStartTemplate/FuncStartTemplate.py b/TestON/tests/FuncStartTemplate/FuncStartTemplate.py
new file mode 100644
index 0000000..4beefae
--- /dev/null
+++ b/TestON/tests/FuncStartTemplate/FuncStartTemplate.py
@@ -0,0 +1,231 @@
+
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
+
+import time
+import json
+
+time.sleep( 1 )
+
+class FuncStartTemplate:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE10( self, main ):
+ import time
+ import os
+ """
+ Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-log
+ git pull
+ mvn clean install
+ onos-package
+ onos-install -f
+ onos-wait-for-start
+ """
+ global init
+ global globalONOSip
+ try:
+ if type(init) is not bool:
+ init = False
+ except NameError:
+ init = False
+
+ #Local variables
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ apps = main.params[ 'ENV' ][ 'cellApps' ]
+ gitBranch = main.params[ 'GIT' ][ 'branch' ]
+ benchIp = os.environ[ 'OCN' ]
+ benchUser = main.params[ 'BENCH' ][ 'user' ]
+ topology = main.params[ 'MININET' ][ 'topo' ]
+ main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
+ main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
+ main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
+ PULLCODE = False
+ if main.params[ 'GIT' ][ 'pull' ] == 'True':
+ PULLCODE = True
+ main.case( "Setting up test environment" )
+ main.CLIs = []
+ for i in range( 1, int( main.numCtrls ) + 1 ):
+ main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
+ if init == False:
+ init = True
+
+ main.ONOSport = []
+ main.scale = ( main.params[ 'SCALE' ] ).split( "," )
+ main.numCtrls = int( main.scale[ 0 ] )
+
+ if PULLCODE:
+ main.step( "Git checkout and pull " + gitBranch )
+ main.ONOSbench.gitCheckout( gitBranch )
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == main.ERROR:
+ main.log.error( "Error pulling git branch" )
+ main.step( "Using mvn clean & install" )
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ stepResult = cleanInstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully compiled " +
+ "latest ONOS",
+ onfail="Failed to compile " +
+ "latest ONOS" )
+ else:
+ main.log.warn( "Did not pull new code so skipping mvn " +
+ "clean install" )
+
+ globalONOSip = main.ONOSbench.getOnosIps()
+
+ maxNodes = ( len(globalONOSip) - 2 )
+
+ main.numCtrls = int( main.scale[ 0 ] )
+ main.scale.remove( main.scale[ 0 ] )
+
+ main.ONOSip = []
+ for i in range( maxNodes ):
+ main.ONOSip.append( globalONOSip[i] )
+
+
+
+ #kill off all onos processes
+ main.log.info( "Safety check, killing all ONOS processes" +
+ " before initiating enviornment setup" )
+ for i in range(maxNodes):
+ main.ONOSbench.onosDie( globalONOSip[ i ] )
+
+ """
+ main.step( "Apply cell to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ stepResult = cellResult and verifyResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully applied cell to " + \
+ "environment",
+ onfail="Failed to apply cell to environment " )
+ """
+ """main.step( "Removing raft logs" )
+ removeRaftResult = main.ONOSbench.onosRemoveRaftLogs()
+ stepResult = removeRaftResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully removed raft logs",
+ onfail="Failed to remove raft logs" )
+ """
+
+ print "NODE COUNT = ", main.numCtrls
+ main.log.info( "Creating cell file" )
+ cellIp = []
+ for i in range( main.numCtrls ):
+ cellIp.append( str( main.ONOSip[ i ] ) )
+ print cellIp
+ main.ONOSbench.createCellFile( benchIp, cellName, "",
+ str( apps ), *cellIp )
+
+ main.step( "Apply cell to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ stepResult = cellResult and verifyResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully applied cell to " + \
+ "environment",
+ onfail="Failed to apply cell to environment " )
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+ stepResult = packageResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully created ONOS package",
+ onfail="Failed to create ONOS package" )
+
+ main.step( "Uninstalling ONOS package" )
+ onosUninstallResult = main.TRUE
+ for i in range( main.numCtrls ):
+ onosUninstallResult = onosUninstallResult and \
+ main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
+ stepResult = onosUninstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully uninstalled ONOS package",
+ onfail="Failed to uninstall ONOS package" )
+ time.sleep( 5 )
+ main.step( "Installing ONOS package" )
+ onosInstallResult = main.TRUE
+ for i in range( main.numCtrls ):
+ onosInstallResult = onosInstallResult and \
+ main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
+ stepResult = onosInstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully installed ONOS package",
+ onfail="Failed to install ONOS package" )
+
+ time.sleep( 20 )
+ 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 CASE9( self, main ):
+ '''
+ Report errors/warnings/exceptions
+ '''
+ main.log.info("Error report: \n")
+ main.ONOSbench.logReport( globalONOSip[0], [ "INFO","FOLLOWER","WARN","flow","ERROR","Except" ], "s" )
+ #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
+
+ def CASE11( self, main ):
+ """
+ Start mininet
+ """
+ main.log.report( "Start Mininet topology" )
+ main.log.case( "Start Mininet topology" )
+
+ main.step( "Starting Mininet Topology" )
+ topoResult = main.Mininet1.startNet( topoFile=topology )
+ stepResult = topoResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully loaded topology",
+ onfail="Failed to load topology" )
+ # Exit if topology did not load properly
+ if not topoResult:
+ main.cleanup()
+ main.exit()
+
diff --git a/TestON/tests/FuncStartTemplate/FuncStartTemplate.topo b/TestON/tests/FuncStartTemplate/FuncStartTemplate.topo
new file mode 100755
index 0000000..2321da0
--- /dev/null
+++ b/TestON/tests/FuncStartTemplate/FuncStartTemplate.topo
@@ -0,0 +1,52 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>OCN</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ <home>~/onos</home>
+ </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>OCN</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>OCN</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>OCN</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli3>
+
+ <Mininet1>
+ <host>OCN</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </Mininet1>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/FuncStartTemplate/__init__.py b/TestON/tests/FuncStartTemplate/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FuncStartTemplate/__init__.py
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.params b/TestON/tests/HATestClusterRestart/HATestClusterRestart.params
index 500c3ad..207e693 100644
--- a/TestON/tests/HATestClusterRestart/HATestClusterRestart.params
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.params
@@ -1,11 +1,12 @@
<PARAMS>
- <testcases>1,2,8,3,4,5,14,16,17,[6],8,3,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ <testcases>1,2,8,3,8,4,5,14,16,17,[6],8,3,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
<ENV>
<cellName>HA</cellName>
</ENV>
- <Git>False</Git>
+ <Git> False </Git>
<branch> master </branch>
<num_controllers> 7 </num_controllers>
+ <tcpdump> False </tcpdump>
<CTRL>
<ip1>10.128.30.11</ip1>
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.py b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
index 2499625..c1bd2f0 100644
--- a/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
@@ -4,7 +4,8 @@
List of test cases:
CASE1: Compile ONOS and push it to the test machines
-CASE2: Assign mastership to controllers
+CASE2: Assign devices to controllers
+CASE21: Assign mastership to controllers
CASE3: Assign intents
CASE4: Ping across added host intents
CASE5: Reading state of ONOS
@@ -46,9 +47,12 @@
start cli sessions
start tcpdump
"""
- main.log.report( "ONOS HA test: Restart all ONOS nodes - " +
+ main.log.info( "ONOS HA test: Restart all ONOS nodes - " +
"initialization" )
main.case( "Setting up test environment" )
+ main.caseExplaination = "Setup the test environment including " +\
+ "installing ONOS, starting Mininet and ONOS" +\
+ "cli sessions."
# TODO: save all the timers and output them for plotting
# load some variables from the params file
@@ -67,6 +71,11 @@
global ONOS6Port
global ONOS7Port
global numControllers
+ # These are for csv plotting in jenkins
+ global labels
+ global data
+ labels = []
+ data = []
numControllers = int( main.params[ 'num_controllers' ] )
# FIXME: just get controller port from params?
@@ -92,15 +101,15 @@
verifyResult = main.ONOSbench.verifyCell()
# FIXME:this is short term fix
- main.log.report( "Removing raft logs" )
+ main.log.info( "Removing raft logs" )
main.ONOSbench.onosRemoveRaftLogs()
- main.log.report( "Uninstalling ONOS" )
+ main.log.info( "Uninstalling ONOS" )
for node in nodes:
main.ONOSbench.onosUninstall( node.ip_address )
# Make sure ONOS is DEAD
- main.log.report( "Killing any ONOS processes" )
+ main.log.info( "Killing any ONOS processes" )
killResults = main.TRUE
for node in nodes:
killed = main.ONOSbench.onosKill( node.ip_address )
@@ -115,36 +124,39 @@
onpass="Mininet Started",
onfail="Error starting Mininet" )
- main.step( "Compiling the latest version of ONOS" )
+ main.step( "Git checkout and pull " + gitBranch )
if PULLCODE:
- main.step( "Git checkout and pull " + gitBranch )
main.ONOSbench.gitCheckout( gitBranch )
gitPullResult = main.ONOSbench.gitPull()
# values of 1 or 3 are good
utilities.assert_lesser( expect=0, actual=gitPullResult,
onpass="Git pull successful",
onfail="Git pull failed" )
+ main.ONOSbench.getVersion( report=True )
- main.step( "Using mvn clean and install" )
+ main.step( "Using mvn clean install" )
+ cleanInstallResult = main.TRUE
+ if PULLCODE and gitPullResult == main.TRUE:
cleanInstallResult = main.ONOSbench.cleanInstall()
- utilities.assert_equals( expect=main.TRUE,
- actual=cleanInstallResult,
- onpass="MCI successful",
- onfail="MCI failed" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
- main.ONOSbench.getVersion( report=True )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cleanInstallResult,
+ onpass="MCI successful",
+ onfail="MCI failed" )
# GRAPHS
# NOTE: important params here:
# job = name of Jenkins job
# Plot Name = Plot-HA, only can be used if multiple plots
# index = The number of the graph under plot name
job = "HAClusterRestart"
+ plotName = "Plot-HA"
graphs = '<ac:structured-macro ac:name="html">\n'
graphs += '<ac:plain-text-body><![CDATA[\n'
graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
- '/plot/getPlot?index=0&width=500&height=300"' +\
+ '/plot/' + plotName + '/getPlot?index=0' +\
+ '&width=500&height=300"' +\
'noborder="0" width="500" height="300" scrolling="yes" ' +\
'seamless="seamless"></iframe>\n'
graphs += ']]></ac:plain-text-body>\n'
@@ -173,7 +185,7 @@
for node in nodes:
started = main.ONOSbench.isup( node.ip_address )
if not started:
- main.log.report( node.name + " didn't start!" )
+ main.log.error( node.name + " didn't start!" )
main.ONOSbench.onosStop( node.ip_address )
main.ONOSbench.onosStart( node.ip_address )
onosIsupResult = onosIsupResult and started
@@ -200,12 +212,13 @@
onpass="ONOS cli startup successful",
onfail="ONOS cli startup failed" )
- main.step( "Start Packet Capture MN" )
- main.Mininet2.startTcpdump(
- str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
- + "-MN.pcap",
- intf=main.params[ 'MNtcpdump' ][ 'intf' ],
- port=main.params[ 'MNtcpdump' ][ 'port' ] )
+ if main.params[ 'tcpdump' ].lower() == "true":
+ main.step( "Start Packet Capture MN" )
+ main.Mininet2.startTcpdump(
+ str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
+ + "-MN.pcap",
+ intf=main.params[ 'MNtcpdump' ][ 'intf' ],
+ port=main.params[ 'MNtcpdump' ][ 'port' ] )
main.step( "App Ids check" )
appCheck = main.TRUE
@@ -227,16 +240,14 @@
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
- case1Result = ( cleanInstallResult and packageResult and
- cellResult and verifyResult and onosInstallResult
- and onosIsupResult and cliResults )
- if case1Result == main.FALSE:
+ if cliResults == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
def CASE2( self, main ):
"""
- Assign mastership to controllers
+ Assign devices to controllers
"""
import re
import time
@@ -253,8 +264,10 @@
assert ONOS6Port, "ONOS6Port not defined"
assert ONOS7Port, "ONOS7Port not defined"
- main.log.report( "Assigning switches to controllers" )
- main.case( "Assigning Controllers" )
+ main.case( "Assigning devices to controllers" )
+ main.caseExplaination = "Assign switches to ONOS using 'ovs-vsctl' " +\
+ "and check that an ONOS node becomes the " +\
+ "master of the device."
main.step( "Assign switches to controllers" )
# TODO: rewrite this function to take lists of ips and ports?
@@ -286,14 +299,36 @@
"not in the list of controllers s" +
str( i ) + " is connecting to." )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Switch mastership assigned correctly" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
onpass="Switch mastership assigned correctly",
onfail="Switches not assigned correctly to controllers" )
+ def CASE21( self, main ):
+ """
+ Assign mastership to controllers
+ """
+ import re
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
+
+ main.case( "Assigning Controller roles for switches" )
+ main.caseExplaination = "Check that ONOS is connected to each " +\
+ "device. Then manually assign" +\
+ " mastership to specific ONOS nodes using" +\
+ " 'device-role'"
main.step( "Assign mastership of switches to specific controllers" )
# Manually assign mastership to the controller we want
roleCall = main.TRUE
@@ -338,6 +373,7 @@
else:
main.log.error( "You didn't write an else statement for " +
"switch s" + str( i ) )
+ roleCall = main.FALSE
# Assign switch
assert deviceId, "No device id for s" + str( i ) + " in ONOS"
# TODO: make this controller dynamic
@@ -378,18 +414,11 @@
onpass="Switches were successfully reassigned to designated " +
"controller",
onfail="Switches were not successfully reassigned" )
- mastershipCheck = mastershipCheck and roleCall and roleCheck
- utilities.assert_equals( expect=main.TRUE, actual=mastershipCheck,
- onpass="Switch mastership correctly assigned",
- onfail="Error in (re)assigning switch" +
- " mastership" )
def CASE3( self, main ):
"""
Assign intents
"""
- # FIXME: we must reinstall intents until we have a persistant
- # datastore!
import time
import json
assert numControllers, "numControllers not defined"
@@ -397,11 +426,24 @@
assert utilities.assert_equals, "utilities.assert_equals not defined"
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- main.log.report( "Adding host intents" )
+ try:
+ labels
+ except NameError:
+ main.log.error( "labels not defined, setting to []" )
+ labels = []
+ try:
+ data
+ except NameError:
+ main.log.error( "data not defined, setting to []" )
+ data = []
+ # NOTE: we must reinstall intents until we have a persistant intent
+ # datastore!
main.case( "Adding host Intents" )
-
- main.step( "Discovering Hosts( Via pingall for now )" )
- # FIXME: Once we have a host discovery mechanism, use that instead
+ main.caseExplaination = "Discover hosts by using pingall then " +\
+ "assign predetermined host-to-host intents." +\
+ " After installation, check that the intent" +\
+ " is distributed to all nodes and the state" +\
+ " is INSTALLED"
# install onos-app-fwd
main.step( "Install reactive forwarding app" )
@@ -410,6 +452,7 @@
onpass="Install fwd successful",
onfail="Install fwd failed" )
+ main.step( "Check app ids" )
appCheck = main.TRUE
threads = []
for i in range( numControllers ):
@@ -429,6 +472,8 @@
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
+ main.step( "Discovering Hosts( Via pingall for now )" )
+ # FIXME: Once we have a host discovery mechanism, use that instead
# REACTIVE FWD test
pingResult = main.FALSE
for i in range(2): # Retry if pingall fails first time
@@ -451,8 +496,10 @@
utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
onpass="Uninstall fwd successful",
onfail="Uninstall fwd failed" )
- main.step( "Check app ids check" )
+
+ main.step( "Check app ids" )
threads = []
+ appCheck2 = main.TRUE
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].appToIDCheck,
name="appToIDCheck-" + str( i ),
@@ -462,15 +509,15 @@
for t in threads:
t.join()
- appCheck = appCheck and t.result
- if appCheck != main.TRUE:
+ appCheck2 = appCheck2 and t.result
+ if appCheck2 != main.TRUE:
main.log.warn( CLIs[0].apps() )
main.log.warn( CLIs[0].appIDs() )
- utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck2,
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
- main.step( "Add host intents" )
+ main.step( "Add host intents via cli" )
intentIds = []
# TODO: move the host numbers to params
# Maybe look at all the paths we ping?
@@ -513,7 +560,10 @@
except ( ValueError, TypeError ):
main.log.warn( repr( hosts ) )
hostResult = main.FALSE
- # FIXME: DEBUG
+ utilities.assert_equals( expect=main.TRUE, actual=hostResult,
+ onpass="Found a host id for each host",
+ onfail="Error looking up host ids" )
+
intentStart = time.time()
onosIds = main.ONOScli1.getAllIntentsId()
main.log.info( "Submitted intents: " + str( intentIds ) )
@@ -523,7 +573,6 @@
pass # intent submitted is in onos
else:
intentAddResult = False
- # FIXME: DEBUG
if intentAddResult:
intentStop = time.time()
else:
@@ -557,6 +606,7 @@
( str( count ), str( i ), str( s ) ) )
leaders = main.ONOScli1.leaders()
try:
+ missing = False
if leaders:
parsedLeaders = json.loads( leaders )
main.log.warn( json.dumps( parsedLeaders,
@@ -573,11 +623,19 @@
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
" not in leaders" )
+ missing = True
else:
main.log.error( "leaders() returned None" )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing leaders" )
main.log.error( repr( leaders ) )
+ # Check all nodes
+ if missing:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
partitions = main.ONOScli1.partitions()
try:
if partitions :
@@ -608,13 +666,11 @@
main.log.exception( "Error parsing pending map" )
main.log.error( repr( pendingMap ) )
- intentAddResult = bool( pingResult and hostResult and intentAddResult
- and not missingIntents and installedCheck )
- utilities.assert_equals(
- expect=True,
- actual=intentAddResult,
- onpass="Pushed host intents to ONOS",
- onfail="Error in pushing host intents to ONOS" )
+ intentAddResult = bool( intentAddResult and not missingIntents and
+ installedCheck )
+ if not intentAddResult:
+ main.log.error( "Error in pushing host intents to ONOS" )
+
main.step( "Intent Anti-Entropy dispersion" )
for i in range(100):
correct = True
@@ -626,7 +682,17 @@
main.log.debug( "Intents in " + cli.name + ": " +
str( sorted( onosIds ) ) )
if sorted( ids ) != sorted( intentIds ):
+ main.log.debug( "Set of intent IDs doesn't match" )
correct = False
+ break
+ else:
+ intents = json.loads( cli.intents() )
+ for intent in intents:
+ if intent[ 'state' ] != "INSTALLED":
+ main.log.warn( "Intent " + intent[ 'id' ] +
+ " is " + intent[ 'state' ] )
+ correct = False
+ break
if correct:
break
else:
@@ -637,6 +703,17 @@
gossipTime = intentStop - intentStart
main.log.info( "It took about " + str( gossipTime ) +
" seconds for all intents to appear in each node" )
+ append = False
+ title = "Gossip Intents"
+ count = 1
+ while append is False:
+ curTitle = title + str( count )
+ if curTitle not in labels:
+ labels.append( curTitle )
+ data.append( str( gossipTime ) )
+ append = True
+ else:
+ count += 1
# FIXME: make this time configurable/calculate based off of number of
# nodes and gossip rounds
utilities.assert_greater_equals(
@@ -682,6 +759,7 @@
( str( count ), str( i ), str( s ) ) )
leaders = main.ONOScli1.leaders()
try:
+ missing = False
if leaders:
parsedLeaders = json.loads( leaders )
main.log.warn( json.dumps( parsedLeaders,
@@ -701,11 +779,19 @@
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
" not in leaders" )
+ missing = True
else:
main.log.error( "leaders() returned None" )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing leaders" )
main.log.error( repr( leaders ) )
+ # Check all nodes
+ if missing:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
partitions = main.ONOScli1.partitions()
try:
if partitions :
@@ -747,9 +833,11 @@
assert utilities.assert_equals, "utilities.assert_equals not defined"
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- description = " Ping across added host intents"
- main.log.report( description )
- main.case( description )
+ main.case( "Verify connectivity by sendind traffic across Intents" )
+ main.caseExplaination = "Ping across added host intents to check " +\
+ "functionality and check the state of " +\
+ "the intent"
+ main.step( "Ping across added host intents" )
PingResult = main.TRUE
for i in range( 8, 18 ):
ping = main.Mininet1.pingHost( src="h" + str( i ),
@@ -762,7 +850,7 @@
main.log.info( "Ping test passed!" )
# Don't set PingResult or you'd override failures
if PingResult == main.FALSE:
- main.log.report(
+ main.log.error(
"Intents have not been installed correctly, pings failed." )
# TODO: pretty print
main.log.warn( "ONOS1 intents: " )
@@ -774,22 +862,21 @@
separators=( ',', ': ' ) ) )
except ( ValueError, TypeError ):
main.log.warn( repr( tmpIntents ) )
- if PingResult == main.TRUE:
- main.log.report(
- "Intents have been installed correctly and verified by pings" )
utilities.assert_equals(
expect=main.TRUE,
actual=PingResult,
onpass="Intents have been installed correctly and pings work",
onfail="Intents have not been installed correctly, pings failed." )
- installedCheck = True
- if PingResult is not main.TRUE:
+ main.step( "Check Intent state" )
+ installedCheck = False
+ loopCount = 0
+ while not installedCheck and loopCount < 40:
+ installedCheck = True
# Print the intent states
intents = main.ONOScli1.intents()
intentStates = []
main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
- count = 0
# Iter through intents of a node
try:
for intent in json.loads( intents ):
@@ -800,66 +887,95 @@
intentStates.append( ( intentId, state ) )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing intents." )
+ # Print states
intentStates.sort()
for i, s in intentStates:
count += 1
main.log.info( "%-6s%-15s%-15s" %
( str( count ), str( i ), str( s ) ) )
- leaders = main.ONOScli1.leaders()
- try:
- if leaders:
- parsedLeaders = json.loads( leaders )
- main.log.warn( json.dumps( parsedLeaders,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # check for all intent partitions
- # check for election
- topics = []
- for i in range( 14 ):
- topics.append( "intent-partition-" + str( i ) )
- # FIXME: this should only be after we start the app
- topics.append( "org.onosproject.election" )
- main.log.debug( topics )
- ONOStopics = [ j['topic'] for j in parsedLeaders ]
- for topic in topics:
- if topic not in ONOStopics:
- main.log.error( "Error: " + topic +
- " not in leaders" )
- else:
- main.log.error( "leaders() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing leaders" )
- main.log.error( repr( leaders ) )
- partitions = main.ONOScli1.partitions()
- try:
- if partitions :
- parsedPartitions = json.loads( partitions )
- main.log.warn( json.dumps( parsedPartitions,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # TODO check for a leader in all paritions
- # TODO check for consistency among nodes
- else:
- main.log.error( "partitions() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing partitions" )
- main.log.error( repr( partitions ) )
- pendingMap = main.ONOScli1.pendingMap()
- try:
- if pendingMap :
- parsedPending = json.loads( pendingMap )
- main.log.warn( json.dumps( parsedPending,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # TODO check something here?
- else:
- main.log.error( "pendingMap() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing pending map" )
- main.log.error( repr( pendingMap ) )
+ if not installedCheck:
+ time.sleep( 1 )
+ loopCount += 1
+ utilities.assert_equals( expect=True, actual=installedCheck,
+ onpass="Intents are all INSTALLED",
+ onfail="Intents are not all in " +
+ "INSTALLED state" )
+
+ main.step( "Check leadership of topics" )
+ leaders = main.ONOScli1.leaders()
+ topicCheck = main.TRUE
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ # TODO: Look at Devices as topics now that it uses this system
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ # FIXME: topics.append( "org.onosproject.election" )
+ # Print leaders output
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ topicCheck = main.FALSE
+ else:
+ main.log.error( "leaders() returned None" )
+ topicCheck = main.FALSE
+ except ( ValueError, TypeError ):
+ topicCheck = main.FALSE
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ # TODO: Check for a leader of these topics
+ # Check all nodes
+ if topicCheck:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=topicCheck,
+ onpass="intent Partitions is in leaders",
+ onfail="Some topics were lost " )
+ # Print partitions
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ # Print Pending Map
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
if not installedCheck:
main.log.info( "Waiting 60 seconds to see if the state of " +
@@ -887,6 +1003,7 @@
( str( count ), str( i ), str( s ) ) )
leaders = main.ONOScli1.leaders()
try:
+ missing = False
if leaders:
parsedLeaders = json.loads( leaders )
main.log.warn( json.dumps( parsedLeaders,
@@ -906,11 +1023,18 @@
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
" not in leaders" )
+ missing = True
else:
main.log.error( "leaders() returned None" )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing leaders" )
main.log.error( repr( leaders ) )
+ if missing:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
partitions = main.ONOScli1.partitions()
try:
if partitions :
@@ -940,7 +1064,39 @@
except ( ValueError, TypeError ):
main.log.exception( "Error parsing pending map" )
main.log.error( repr( pendingMap ) )
- main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+ # Print flowrules
+ main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+ main.step( "Wait a minute then ping again" )
+ # the wait is above
+ PingResult = main.TRUE
+ for i in range( 8, 18 ):
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
+ PingResult = PingResult and ping
+ if ping == main.FALSE:
+ main.log.warn( "Ping failed between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ elif ping == main.TRUE:
+ main.log.info( "Ping test passed!" )
+ # Don't set PingResult or you'd override failures
+ if PingResult == main.FALSE:
+ main.log.error(
+ "Intents have not been installed correctly, pings failed." )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=PingResult,
+ onpass="Intents have been installed correctly and pings work",
+ onfail="Intents have not been installed correctly, pings failed." )
def CASE5( self, main ):
"""
@@ -956,7 +1112,6 @@
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
- main.log.report( "Setting up and gathering data for current state" )
main.case( "Setting up and gathering data for current state" )
# The general idea for this test case is to pull the state of
# ( intents,flows, topology,... ) from each ONOS node
@@ -1004,7 +1159,7 @@
for i in range( numControllers ):
if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" roles" )
main.log.warn(
"ONOS" + str( i + 1 ) + " mastership response: " +
@@ -1018,7 +1173,7 @@
main.step( "Check for consistency in roles from each controller" )
if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
- main.log.report(
+ main.log.info(
"Switch roles are consistent across all ONOS nodes" )
else:
consistentMastership = False
@@ -1066,7 +1221,7 @@
for i in range( numControllers ):
if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" intents" )
main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
repr( ONOSIntents[ i ] ) )
@@ -1079,11 +1234,11 @@
main.step( "Check for consistency in Intents from each controller" )
if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
- main.log.report( "Intents are consistent across all ONOS " +
+ main.log.info( "Intents are consistent across all ONOS " +
"nodes" )
else:
consistentIntents = False
- main.log.report( "Intents not consistent" )
+ main.log.error( "Intents not consistent" )
utilities.assert_equals(
expect=True,
actual=consistentIntents,
@@ -1167,7 +1322,7 @@
for i in range( numControllers ):
num = str( i + 1 )
if not ONOSFlows[ i ] or "Error" in ONOSFlows[ i ]:
- main.log.report( "Error in getting ONOS" + num + " flows" )
+ main.log.error( "Error in getting ONOS" + num + " flows" )
main.log.warn( "ONOS" + num + " flows response: " +
repr( ONOSFlows[ i ] ) )
flowsResults = False
@@ -1191,7 +1346,7 @@
main.step( "Check for consistency in Flows from each controller" )
tmp = [ len( i ) == len( ONOSFlowsJson[ 0 ] ) for i in ONOSFlowsJson ]
if all( tmp ):
- main.log.report( "Flow count is consistent across all ONOS nodes" )
+ main.log.info( "Flow count is consistent across all ONOS nodes" )
else:
consistentFlows = False
utilities.assert_equals(
@@ -1354,14 +1509,14 @@
if hosts[ controller ] == hosts[ 0 ]:
continue
else: # hosts not consistent
- main.log.report( "hosts from ONOS" +
+ main.log.error( "hosts from ONOS" +
controllerStr +
" is inconsistent with ONOS1" )
main.log.warn( repr( hosts[ controller ] ) )
consistentHostsResult = main.FALSE
else:
- main.log.report( "Error in getting ONOS hosts from ONOS" +
+ main.log.error( "Error in getting ONOS hosts from ONOS" +
controllerStr )
consistentHostsResult = main.FALSE
main.log.warn( "ONOS" + controllerStr +
@@ -1378,7 +1533,7 @@
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- if not host.get( 'ips', [ ] ):
+ if not host.get( 'ipAddresses', [ ] ):
main.log.error( "DEBUG:Error with host ips on controller" +
controllerStr + ": " + str( host ) )
ipResult = main.FALSE
@@ -1397,12 +1552,12 @@
if clusters[ controller ] == clusters[ 0 ]:
continue
else: # clusters not consistent
- main.log.report( "clusters from ONOS" + controllerStr +
+ main.log.error( "clusters from ONOS" + controllerStr +
" is inconsistent with ONOS1" )
consistentClustersResult = main.FALSE
else:
- main.log.report( "Error in getting dataplane clusters " +
+ main.log.error( "Error in getting dataplane clusters " +
"from ONOS" + controllerStr )
consistentClustersResult = main.FALSE
main.log.warn( "ONOS" + controllerStr +
@@ -1489,12 +1644,24 @@
"""
The Failure case.
"""
+ import time
assert numControllers, "numControllers not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
-
+ try:
+ labels
+ except NameError:
+ main.log.error( "labels not defined, setting to []" )
+ global labels
+ labels = []
+ try:
+ data
+ except NameError:
+ main.log.error( "data not defined, setting to []" )
+ global data
+ data = []
# Reset non-persistent variables
try:
iCounterValue = 0
@@ -1503,8 +1670,10 @@
iCounterValue = 0
main.case( "Restart entire ONOS cluster" )
+
main.step( "Killing ONOS nodes" )
killResults = main.TRUE
+ killTime = time.time()
for node in nodes:
killed = main.ONOSbench.onosKill( node.ip_address )
killResults = killResults and killed
@@ -1518,7 +1687,7 @@
for node in nodes:
started = main.ONOSbench.isup( node.ip_address )
if not started:
- main.log.report( node.name + " didn't start!" )
+ main.log.error( node.name + " didn't start!" )
onosIsupResult = onosIsupResult and started
if onosIsupResult == main.TRUE:
break
@@ -1543,6 +1712,31 @@
onpass="ONOS cli started",
onfail="ONOS clis did not restart" )
+ # Grab the time of restart so we chan check how long the gossip
+ # protocol has had time to work
+ main.restartTime = time.time() - killTime
+ main.log.debug( "Restart time: " + str( main.restartTime ) )
+ labels.append( "Restart" )
+ data.append( str( main.restartTime ) )
+
+ # FIXME: revisit test plan for election with madan
+ # Rerun for election on restarted nodes
+ runResults = main.TRUE
+ for cli in CLIs:
+ run = CLIs[0].electionTestRun()
+ if run != main.TRUE:
+ main.log.error( "Error running for election on " + cli.name )
+ runResults = runResults and run
+ utilities.assert_equals( expect=main.TRUE, actual=runResults,
+ onpass="Reran for election",
+ onfail="Failed to rerun for election" )
+
+ # TODO: Make this configurable
+ time.sleep( 60 )
+ main.log.debug( CLIs[0].nodes( jsonFormat=False ) )
+ main.log.debug( CLIs[0].leaders( jsonFormat=False ) )
+ main.log.debug( CLIs[0].partitions( jsonFormat=False ) )
+
def CASE7( self, main ):
"""
Check state after ONOS failure
@@ -1594,7 +1788,7 @@
for i in range( numControllers ):
if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" roles" )
main.log.warn(
"ONOS" + str( i + 1 ) + " mastership response: " +
@@ -1608,7 +1802,7 @@
main.step( "Check for consistency in roles from each controller" )
if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
- main.log.report(
+ main.log.info(
"Switch roles are consistent across all ONOS nodes" )
else:
consistentMastership = False
@@ -1630,6 +1824,7 @@
elif rolesResults and not consistentMastership:
mastershipCheck = main.TRUE
+ '''
description2 = "Compare switch roles from before failure"
main.step( description2 )
try:
@@ -1655,15 +1850,13 @@
else:
main.log.warn( "Mastership of switch %s changed" % switchDPID )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Mastership of Switches was not changed" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
onpass="Mastership of Switches was not changed",
onfail="Mastership of some switches changed" )
+ '''
# NOTE: we expect mastership to change on controller failure
- mastershipCheck = mastershipCheck and consistentMastership
main.step( "Get the intents and compare across all nodes" )
ONOSIntents = []
@@ -1685,7 +1878,7 @@
for i in range( numControllers ):
if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" intents" )
main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
repr( ONOSIntents[ i ] ) )
@@ -1698,7 +1891,7 @@
main.step( "Check for consistency in Intents from each controller" )
if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
- main.log.report( "Intents are consistent across all ONOS " +
+ main.log.info( "Intents are consistent across all ONOS " +
"nodes" )
else:
consistentIntents = False
@@ -1766,22 +1959,41 @@
main.step( "Compare current intents with intents before the failure" )
# NOTE: this requires case 5 to pass for intentState to be set.
# maybe we should stop the test if that fails?
- sameIntents = main.TRUE
+ sameIntents = main.FALSE
if intentState and intentState == ONOSIntents[ 0 ]:
sameIntents = main.TRUE
- main.log.report( "Intents are consistent with before failure" )
+ main.log.info( "Intents are consistent with before failure" )
# TODO: possibly the states have changed? we may need to figure out
# what the acceptable states are
- else:
+ elif len( intentState ) == len( ONOSIntents[ 0 ] ):
+ sameIntents = main.TRUE
try:
- main.log.warn( "ONOS intents: " )
- main.log.warn( json.dumps( json.loads( ONOSIntents[ 0 ] ),
- sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
+ before = json.loads( intentState )
+ after = json.loads( ONOSIntents[ 0 ] )
+ for intent in before:
+ if intent not in after:
+ sameIntents = main.FALSE
+ main.log.debug( "Intent is not currently in ONOS " +
+ "(at least in the same form):" )
+ main.log.debug( json.dumps( intent ) )
except ( ValueError, TypeError ):
main.log.exception( "Exception printing intents" )
- main.log.warn( repr( ONOSIntents[0] ) )
- sameIntents = main.FALSE
+ main.log.debug( repr( ONOSIntents[0] ) )
+ main.log.debug( repr( intentState ) )
+ if sameIntents == main.FALSE:
+ try:
+ main.log.debug( "ONOS intents before: " )
+ main.log.debug( json.dumps( json.loads( intentState ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ main.log.debug( "Current ONOS intents: " )
+ main.log.debug( json.dumps( json.loads( ONOSIntents[ 0 ] ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Exception printing intents" )
+ main.log.debug( repr( ONOSIntents[0] ) )
+ main.log.debug( repr( intentState ) )
utilities.assert_equals(
expect=main.TRUE,
actual=sameIntents,
@@ -1804,16 +2016,14 @@
if FlowTables == main.FALSE:
main.log.info( "Differences in flow table for switch: s" +
str( i + 1 ) )
- if FlowTables == main.TRUE:
- main.log.report( "No changes were found in the flow tables" )
utilities.assert_equals(
expect=main.TRUE,
actual=FlowTables,
onpass="No changes were found in the flow tables",
onfail="Changes were found in the flow tables" )
- main.step( "Check the continuous pings to ensure that no packets " +
- "were dropped during component failure" )
+ # main.step( "Check the continuous pings to ensure that no packets " +
+ # "were dropped during component failure" )
main.Mininet2.pingKill( main.params[ 'TESTONUSER' ],
main.params[ 'TESTONIP' ] )
LossInPings = main.FALSE
@@ -1831,12 +2041,13 @@
main.log.info( "There are multiple mininet process running" )
elif LossInPings == main.FALSE:
main.log.info( "No Loss in the pings" )
- main.log.report( "No loss of dataplane connectivity" )
- utilities.assert_equals(
- expect=main.FALSE,
- actual=LossInPings,
- onpass="No Loss of connectivity",
- onfail="Loss of dataplane connectivity detected" )
+ main.log.info( "No loss of dataplane connectivity" )
+ # utilities.assert_equals(
+ # expect=main.FALSE,
+ # actual=LossInPings,
+ # onpass="No Loss of connectivity",
+ # onfail="Loss of dataplane connectivity detected" )
+
# NOTE: Since intents are not persisted with IntnentStore,
# we expect loss in dataplane connectivity
LossInPings = main.FALSE
@@ -1849,25 +2060,20 @@
leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == main.FALSE:
- # error in response
- main.log.report( "Something is wrong with " +
+ # error in response
+ main.log.error( "Something is wrong with " +
"electionTestLeader function, check the" +
" error logs" )
leaderResult = main.FALSE
elif leaderN is None:
- main.log.report( cli.name +
- " shows no leader for the election-app was" +
- " elected after the old one died" )
+ main.log.error( cli.name +
+ " shows no leader for the election-app." )
leaderResult = main.FALSE
if len( set( leaderList ) ) != 1:
leaderResult = main.FALSE
main.log.error(
"Inconsistent view of leader for the election test app" )
# TODO: print the list
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was re-elected if applicable )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
@@ -1891,20 +2097,31 @@
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- description = "Compare ONOS Topology view to Mininet topology"
- main.case( description )
- main.log.report( description )
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplaination = "Compare topology objects between Mininet" +\
+ " and ONOS"
main.step( "Create TestONTopology object" )
- ctrls = []
- for node in nodes:
- temp = ( node, node.name, node.ip_address, 6633 )
- ctrls.append( temp )
- MNTopo = TestONTopology( main.Mininet1, ctrls )
+ try:
+ ctrls = []
+ for node in nodes:
+ temp = ( node, node.name, node.ip_address, 6633 )
+ ctrls.append( temp )
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
+ except Exception:
+ objResult = main.FALSE
+ else:
+ objResult = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=objResult,
+ onpass="Created TestONTopology object",
+ onfail="Exception while creating " +
+ "TestONTopology object" )
+ main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
portsResults = main.TRUE
linksResults = main.TRUE
hostsResults = main.TRUE
+ hostAttachmentResults = True
topoResult = main.FALSE
elapsed = 0
count = 0
@@ -1949,9 +2166,9 @@
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- if host is None or host.get( 'ips', [] ) == []:
+ if host is None or host.get( 'ipAddresses', [] ) == []:
main.log.error(
- "DEBUG:Error with host ips on controller" +
+ "DEBUG:Error with host ipAddresses on controller" +
controllerStr + ": " + str( host ) )
ipResult = main.FALSE
ports = []
@@ -1993,6 +2210,7 @@
elapsed = time.time() - startTime
cliTime = time.time() - cliStart
+ print "Elapsed time: " + str( elapsed )
print "CLI time: " + str( cliTime )
for controller in range( numControllers ):
@@ -2048,88 +2266,188 @@
" hosts exist in Mininet",
onfail="ONOS" + controllerStr +
" hosts don't match Mininet" )
+ # CHECKING HOST ATTACHMENT POINTS
+ hostAttachment = True
+ zeroHosts = False
+ # FIXME: topo-HA/obelisk specific mappings:
+ # key is mac and value is dpid
+ mappings = {}
+ for i in range( 1, 29 ): # hosts 1 through 28
+ # set up correct variables:
+ macId = "00:" * 5 + hex( i ).split( "0x" )[1].upper().zfill(2)
+ if i == 1:
+ deviceId = "1000".zfill(16)
+ elif i == 2:
+ deviceId = "2000".zfill(16)
+ elif i == 3:
+ deviceId = "3000".zfill(16)
+ elif i == 4:
+ deviceId = "3004".zfill(16)
+ elif i == 5:
+ deviceId = "5000".zfill(16)
+ elif i == 6:
+ deviceId = "6000".zfill(16)
+ elif i == 7:
+ deviceId = "6007".zfill(16)
+ elif i >= 8 and i <= 17:
+ dpid = '3' + str( i ).zfill( 3 )
+ deviceId = dpid.zfill(16)
+ elif i >= 18 and i <= 27:
+ dpid = '6' + str( i ).zfill( 3 )
+ deviceId = dpid.zfill(16)
+ elif i == 28:
+ deviceId = "2800".zfill(16)
+ mappings[ macId ] = deviceId
+ if hosts[ controller ] or "Error" not in hosts[ controller ]:
+ if hosts[ controller ] == []:
+ main.log.warn( "There are no hosts discovered" )
+ zeroHosts = True
+ else:
+ for host in hosts[ controller ]:
+ mac = None
+ location = None
+ device = None
+ port = None
+ try:
+ mac = host.get( 'mac' )
+ assert mac, "mac field could not be found for this host object"
+ location = host.get( 'location' )
+ assert location, "location field could not be found for this host object"
+
+ # Trim the protocol identifier off deviceId
+ device = str( location.get( 'elementId' ) ).split(':')[1]
+ assert device, "elementId field could not be found for this host location object"
+
+ port = location.get( 'port' )
+ assert port, "port field could not be found for this host location object"
+
+ # Now check if this matches where they should be
+ if mac and device and port:
+ if str( port ) != "1":
+ main.log.error( "The attachment port is incorrect for " +
+ "host " + str( mac ) +
+ ". Expected: 1 Actual: " + str( port) )
+ hostAttachment = False
+ if device != mappings[ str( mac ) ]:
+ main.log.error( "The attachment device is incorrect for " +
+ "host " + str( mac ) +
+ ". Expected: " + mappings[ str( mac ) ] +
+ " Actual: " + device )
+ hostAttachment = False
+ else:
+ hostAttachment = False
+ except AssertionError:
+ main.log.exception( "Json object not as expected" )
+ main.log.error( repr( host ) )
+ hostAttachment = False
+ else:
+ main.log.error( "No hosts json output or \"Error\"" +
+ " in output. hosts = " +
+ repr( hosts[ controller ] ) )
+ if zeroHosts:
+ # TODO: Find a way to know if there should be hosts in a
+ # given point of the test
+ hostAttachment = True
+
+ # END CHECKING HOST ATTACHMENT POINTS
devicesResults = devicesResults and currentDevicesResult
portsResults = portsResults and currentPortsResult
linksResults = linksResults and currentLinksResult
hostsResults = hostsResults and currentHostsResult
+ hostAttachmentResults = hostAttachmentResults and hostAttachment
- # Compare json objects for hosts and dataplane clusters
+ # Compare json objects for hosts and dataplane clusters
- # hosts
- main.step( "Hosts view is consistent across all ONOS nodes" )
- consistentHostsResult = main.TRUE
- for controller in range( len( hosts ) ):
- controllerStr = str( controller + 1 )
- if "Error" not in hosts[ controller ]:
- if hosts[ controller ] == hosts[ 0 ]:
- continue
- else: # hosts not consistent
- main.log.report( "hosts from ONOS" + controllerStr +
- " is inconsistent with ONOS1" )
- main.log.warn( repr( hosts[ controller ] ) )
- consistentHostsResult = main.FALSE
-
- else:
- main.log.report( "Error in getting ONOS hosts from ONOS" +
- controllerStr )
+ # hosts
+ main.step( "Hosts view is consistent across all ONOS nodes" )
+ consistentHostsResult = main.TRUE
+ for controller in range( len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in hosts[ controller ]:
+ if hosts[ controller ] == hosts[ 0 ]:
+ continue
+ else: # hosts not consistent
+ main.log.error( "hosts from ONOS" + controllerStr +
+ " is inconsistent with ONOS1" )
+ main.log.warn( repr( hosts[ controller ] ) )
consistentHostsResult = main.FALSE
- main.log.warn( "ONOS" + controllerStr +
- " hosts response: " +
- repr( hosts[ controller ] ) )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=consistentHostsResult,
- onpass="Hosts view is consistent across all ONOS nodes",
- onfail="ONOS nodes have different views of hosts" )
- # Strongly connected clusters of devices
- main.step( "Clusters view is consistent across all ONOS nodes" )
- consistentClustersResult = main.TRUE
- for controller in range( len( clusters ) ):
- controllerStr = str( controller + 1 )
- if "Error" not in clusters[ controller ]:
- if clusters[ controller ] == clusters[ 0 ]:
- continue
- else: # clusters not consistent
- main.log.report( "clusters from ONOS" +
- controllerStr +
- " is inconsistent with ONOS1" )
- consistentClustersResult = main.FALSE
+ else:
+ main.log.error( "Error in getting ONOS hosts from ONOS" +
+ controllerStr )
+ consistentHostsResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " hosts response: " +
+ repr( hosts[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentHostsResult,
+ onpass="Hosts view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of hosts" )
- else:
- main.log.report( "Error in getting dataplane clusters " +
- "from ONOS" + controllerStr )
+ main.step( "Hosts information is correct" )
+ hostsResults = hostsResults and ipResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=hostsResults,
+ onpass="Host information is correct",
+ onfail="Host information is incorrect" )
+
+ main.step( "Host attachment points to the network" )
+ utilities.assert_equals(
+ expect=True,
+ actual=hostAttachmentResults,
+ onpass="Hosts are correctly attached to the network",
+ onfail="ONOS did not correctly attach hosts to the network" )
+
+ # Strongly connected clusters of devices
+ main.step( "Clusters view is consistent across all ONOS nodes" )
+ consistentClustersResult = main.TRUE
+ for controller in range( len( clusters ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in clusters[ controller ]:
+ if clusters[ controller ] == clusters[ 0 ]:
+ continue
+ else: # clusters not consistent
+ main.log.error( "clusters from ONOS" +
+ controllerStr +
+ " is inconsistent with ONOS1" )
consistentClustersResult = main.FALSE
- main.log.warn( "ONOS" + controllerStr +
- " clusters response: " +
- repr( clusters[ controller ] ) )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=consistentClustersResult,
- onpass="Clusters view is consistent across all ONOS nodes",
- onfail="ONOS nodes have different views of clusters" )
- # there should always only be one cluster
- main.step( "Topology view is correct and consistent across all " +
- "ONOS nodes" )
- try:
- numClusters = len( json.loads( clusters[ 0 ] ) )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing clusters[0]: " +
- repr( clusters[0] ) )
- clusterResults = main.FALSE
- if numClusters == 1:
- clusterResults = main.TRUE
- utilities.assert_equals(
- expect=1,
- actual=numClusters,
- onpass="ONOS shows 1 SCC",
- onfail="ONOS shows " + str( numClusters ) + " SCCs" )
- topoResult = ( devicesResults and portsResults and linksResults
- and hostsResults and consistentHostsResult
- and consistentClustersResult and clusterResults
- and ipResult )
+ else:
+ main.log.error( "Error in getting dataplane clusters " +
+ "from ONOS" + controllerStr )
+ consistentClustersResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " clusters response: " +
+ repr( clusters[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentClustersResult,
+ onpass="Clusters view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of clusters" )
+
+ main.step( "There is only one SCC" )
+ # there should always only be one cluster
+ try:
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing clusters[0]: " +
+ repr( clusters[0] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
+ utilities.assert_equals(
+ expect=1,
+ actual=numClusters,
+ onpass="ONOS shows 1 SCC",
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
+
+ topoResult = ( devicesResults and portsResults and linksResults
+ and hostsResults and consistentHostsResult
+ and consistentClustersResult and clusterResults
+ and ipResult and hostAttachmentResults )
topoResult = topoResult and int( count <= 2 )
note = "note it takes about " + str( int( cliTime ) ) + \
@@ -2139,11 +2457,27 @@
"Very crass estimate for topology discovery/convergence( " +
str( note ) + " ): " + str( elapsed ) + " seconds, " +
str( count ) + " tries" )
- utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
- if topoResult == main.TRUE:
- main.log.report( "ONOS topology view matches Mininet topology" )
+
+ main.step( "Device information is correct" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=devicesResults,
+ onpass="Device information is correct",
+ onfail="Device information is incorrect" )
+
+ main.step( "Port information is correct" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=portsResults,
+ onpass="Port information is correct",
+ onfail="Port information is incorrect" )
+
+ main.step( "Links are correct" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linksResults,
+ onpass="Link are correct",
+ onfail="Links are incorrect" )
# FIXME: move this to an ONOS state case
main.step( "Checking ONOS nodes" )
@@ -2201,7 +2535,6 @@
description = "Turn off a link to ensure that Link Discovery " +\
"is working properly"
- main.log.report( description )
main.case( description )
main.step( "Kill Link between s3 and s28" )
@@ -2230,7 +2563,6 @@
description = "Restore a link to ensure that Link Discovery is " + \
"working properly"
- main.log.report( description )
main.case( description )
main.step( "Bring link between s3 and s28 back up" )
@@ -2258,14 +2590,13 @@
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
description = "Killing a switch to ensure it is discovered correctly"
- main.log.report( description )
main.case( description )
switch = main.params[ 'kill' ][ 'switch' ]
switchDPID = main.params[ 'kill' ][ 'dpid' ]
# TODO: Make this switch parameterizable
main.step( "Kill " + switch )
- main.log.report( "Deleting " + switch )
+ main.log.info( "Deleting " + switch )
main.Mininet1.delSwitch( switch )
main.log.info( "Waiting " + str( switchSleep ) +
" seconds for switch down to be discovered" )
@@ -2304,11 +2635,9 @@
switchDPID = main.params[ 'kill' ][ 'dpid' ]
links = main.params[ 'kill' ][ 'links' ].split()
description = "Adding a switch to ensure it is discovered correctly"
- main.log.report( description )
main.case( description )
main.step( "Add back " + switch )
- main.log.report( "Adding back " + switch )
main.Mininet1.addSwitch( switch, dpid=switchDPID )
for peer in links:
main.Mininet1.addLink( switch, peer )
@@ -2357,9 +2686,7 @@
colors = { 'cyan': '\033[96m', 'purple': '\033[95m',
'blue': '\033[94m', 'green': '\033[92m',
'yellow': '\033[93m', 'red': '\033[91m', 'end': '\033[0m' }
- description = "Test Cleanup"
- main.log.report( description )
- main.case( description )
+ main.case( "Test Cleanup" )
main.step( "Killing tcpdumps" )
main.Mininet2.stopTcpdump()
@@ -2415,11 +2742,19 @@
for node in nodes:
print colors[ 'purple' ] + "Checking logs for errors on " + \
node.name + ":" + colors[ 'end' ]
- print main.ONOSbench.checkLogs( node.ip_address )
+ print main.ONOSbench.checkLogs( node.ip_address, restart=True )
main.step( "Packing and rotating pcap archives" )
os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
+ try:
+ timerLog = open( main.logdir + "/Timers.csv", 'w')
+ main.log.error( ", ".join( labels ) + "\n" + ", ".join( data ) )
+ timerLog.write( ", ".join( labels ) + "\n" + ", ".join( data ) )
+ timerLog.close()
+ except NameError, e:
+ main.log.exception(e)
+
def CASE14( self, main ):
"""
start election app on all onos nodes
@@ -2430,34 +2765,45 @@
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- leaderResult = main.TRUE
main.case("Start Leadership Election app")
main.step( "Install leadership election app" )
- main.ONOScli1.activateApp( "org.onosproject.election" )
+ appResult = main.ONOScli1.activateApp( "org.onosproject.election" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=appResult,
+ onpass="Election app installed",
+ onfail="Something went wrong with installing Leadership election" )
+
+ main.step( "Run for election on each node" )
+ leaderResult = main.TRUE
leaders = []
for cli in CLIs:
cli.electionTestRun()
for cli in CLIs:
leader = cli.electionTestLeader()
if leader is None or leader == main.FALSE:
- main.log.report( cli.name + ": Leader for the election app " +
+ main.log.error( cli.name + ": Leader for the election app " +
"should be an ONOS node, instead got '" +
str( leader ) + "'" )
leaderResult = main.FALSE
leaders.append( leader )
- if len( set( leaders ) ) != 1:
- leaderResult = main.FALSE
- main.log.error( "Results of electionTestLeader is order of CLIs:" +
- str( leaders ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a leader " +
- "was elected )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
- onpass="Leadership election passed",
- onfail="Something went wrong with Leadership election" )
+ onpass="Successfully ran for leadership",
+ onfail="Failed to run for leadership" )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
def CASE15( self, main ):
"""
@@ -2472,14 +2818,45 @@
leaderResult = main.TRUE
description = "Check that Leadership Election is still functional"
- main.log.report( description )
main.case( description )
+ # NOTE: Need to re-run since being a canidate is not persistant
+ main.step( "Run for election on each node" )
+ leaderResult = main.TRUE
+ leaders = []
+ for cli in CLIs:
+ cli.electionTestRun()
+ for cli in CLIs:
+ leader = cli.electionTestLeader()
+ if leader is None or leader == main.FALSE:
+ main.log.error( cli.name + ": Leader for the election app " +
+ "should be an ONOS node, instead got '" +
+ str( leader ) + "'" )
+ leaderResult = main.FALSE
+ leaders.append( leader )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=leaderResult,
+ onpass="Successfully ran for leadership",
+ onfail="Failed to run for leadership" )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
+
main.step( "Find current leader and withdraw" )
leader = main.ONOScli1.electionTestLeader()
# do some sanity checking on leader before using it
withdrawResult = main.FALSE
if leader is None or leader == main.FALSE:
- main.log.report(
+ main.log.error(
"Leader for the election app should be an ONOS node," +
"instead got '" + str( leader ) + "'" )
leaderResult = main.FALSE
@@ -2495,8 +2872,8 @@
utilities.assert_equals(
expect=main.TRUE,
actual=withdrawResult,
- onpass="App was withdrawn from election",
- onfail="App was not withdrawn from election" )
+ onpass="Node was withdrawn from election",
+ onfail="Node was not withdrawn from election" )
main.step( "Make sure new leader is elected" )
# FIXME: use threads
@@ -2505,14 +2882,14 @@
leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == leader:
- main.log.report( cli.name + " still sees " + str( leader ) +
+ main.log.error( cli.name + " still sees " + str( leader ) +
" as leader after they withdrew" )
leaderResult = main.FALSE
elif leaderN == main.FALSE:
# error in response
# TODO: add check for "Command not found:" in the driver, this
# means the app isn't loaded
- main.log.report( "Something is wrong with " +
+ main.log.error( "Something is wrong with " +
"electionTestLeader function, " +
"check the error logs" )
leaderResult = main.FALSE
@@ -2529,17 +2906,12 @@
"' as the leader" )
consistentLeader = main.TRUE
else:
- main.log.report(
+ main.log.error(
"Inconsistent responses for leader of Election-app:" )
for n in range( len( leaderList ) ):
- main.log.report( "ONOS" + str( n + 1 ) + " response: " +
+ main.log.error( "ONOS" + str( n + 1 ) + " response: " +
str( leaderList[ n ] ) )
leaderResult = leaderResult and consistentLeader
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was elected when the old leader " +
- "resigned )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
@@ -2558,6 +2930,7 @@
onpass="App re-ran for election",
onfail="App failed to run for election" )
+ main.step( "Leader did not change when old leader re-ran" )
afterRun = main.ONOScli1.electionTestLeader()
# verify leader didn't just change
if afterRun == leaderList[ 0 ]:
@@ -2572,18 +2945,11 @@
onfail="Something went wrong with Leadership election after " +
"the old leader re-ran for election" )
- case15Result = withdrawResult and leaderResult and runResult and\
- afterResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case15Result,
- onpass="Leadership election is still functional",
- onfail="Leadership Election is no longer functional" )
-
def CASE16( self, main ):
"""
Install Distributed Primitives app
"""
+ import time
assert numControllers, "numControllers not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
@@ -2613,11 +2979,13 @@
actual=appResults,
onpass="Primitives app activated",
onfail="Primitives app not activated" )
+ time.sleep( 5 ) # To allow all nodes to activate
def CASE17( self, main ):
"""
Check for basic functionality with distributed primitives
"""
+ import json
# Make sure variables are defined/set
assert numControllers, "numControllers not defined"
assert main, "main not defined"
@@ -2656,11 +3024,13 @@
main.step( "Increment and get a default counter on each node" )
pCounters = []
threads = []
+ addedPValues = []
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].counterTestIncrement,
name="counterIncrement-" + str( i ),
args=[ pCounterName ] )
pCounterValue += 1
+ addedPValues.append( pCounterValue )
threads.append( t )
t.start()
@@ -2669,8 +3039,12 @@
pCounters.append( t.result )
# Check that counter incremented numController times
pCounterResults = True
- for i in range( numControllers ):
- pCounterResults and ( i + 1 ) in pCounters
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
utilities.assert_equals( expect=True,
actual=pCounterResults,
onpass="Default counter incremented",
@@ -2679,6 +3053,7 @@
main.step( "Increment and get an in memory counter on each node" )
iCounters = []
+ addedIValues = []
threads = []
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].counterTestIncrement,
@@ -2686,6 +3061,7 @@
args=[ iCounterName ],
kwargs={ "inMemory": True } )
iCounterValue += 1
+ addedIValues.append( iCounterValue )
threads.append( t )
t.start()
@@ -2694,8 +3070,12 @@
iCounters.append( t.result )
# Check that counter incremented numController times
iCounterResults = True
- for i in range( numControllers ):
- iCounterResults and ( i + 1 ) in iCounters
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in the in-memory "
+ "counter incremented results" )
utilities.assert_equals( expect=True,
actual=iCounterResults,
onpass="In memory counter incremented",
@@ -2730,28 +3110,41 @@
main.step( "Counters we added have the correct values" )
correctResults = main.TRUE
for i in range( numControllers ):
- current = onosCounters[i]
+ current = json.loads( onosCounters[i] )
+ pValue = None
+ iValue = None
try:
- pValue = current.get( pCounterName )
- iValue = current.get( iCounterName )
- if pValue == pCounterValue:
- main.log.info( "Partitioned counter value is correct" )
- else:
- main.log.error( "Partitioned counter value is incorrect," +
- " expected value: " + str( pCounterValue )
- + " current value: " + str( pValue ) )
- correctResults = main.FALSE
- if iValue == iCounterValue:
- main.log.info( "In memory counter value is correct" )
- else:
- main.log.error( "In memory counter value is incorrect, " +
- "expected value: " + str( iCounterValue ) +
- " current value: " + str( iValue ) )
- correctResults = main.FALSE
+ for database in current:
+ partitioned = database.get( 'partitionedDatabaseCounters' )
+ if partitioned:
+ for value in partitioned:
+ if value.get( 'name' ) == pCounterName:
+ pValue = value.get( 'value' )
+ break
+ inMemory = database.get( 'inMemoryDatabaseCounters' )
+ if inMemory:
+ for value in inMemory:
+ if value.get( 'name' ) == iCounterName:
+ iValue = value.get( 'value' )
+ break
except AttributeError, e:
main.log.error( "ONOS" + str( i + 1 ) + " counters result " +
"is not as expected" )
correctResults = main.FALSE
+ if pValue == pCounterValue:
+ main.log.info( "Partitioned counter value is correct" )
+ else:
+ main.log.error( "Partitioned counter value is incorrect," +
+ " expected value: " + str( pCounterValue )
+ + " current value: " + str( pValue ) )
+ correctResults = main.FALSE
+ if iValue == iCounterValue:
+ main.log.info( "In memory counter value is correct" )
+ else:
+ main.log.error( "In memory counter value is incorrect, " +
+ "expected value: " + str( iCounterValue ) +
+ " current value: " + str( iValue ) )
+ correctResults = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=correctResults,
onpass="Added counters are correct",
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params
index ca1f915..956d889 100644
--- a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params
@@ -6,6 +6,7 @@
<Git>False</Git>
<branch> master </branch>
<num_controllers> 7 </num_controllers>
+ <tcpdump> False </tcpdump>
<CTRL>
<ip1>10.128.30.11</ip1>
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
index 0dd40ed..08d81c2 100644
--- a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
@@ -4,7 +4,8 @@
List of test cases:
CASE1: Compile ONOS and push it to the test machines
-CASE2: Assign mastership to controllers
+CASE2: Assign devices to controllers
+CASE21: Assign mastership to controllers
CASE3: Assign intents
CASE4: Ping across added host intents
CASE5: Reading state of ONOS
@@ -46,9 +47,12 @@
start cli sessions
start tcpdump
"""
- main.log.report( "ONOS HA test: Restart minority of ONOS nodes - " +
+ main.log.info( "ONOS HA test: Restart minority of ONOS nodes - " +
"initialization" )
main.case( "Setting up test environment" )
+ main.caseExplaination = "Setup the test environment including " +\
+ "installing ONOS, starting Mininet and ONOS" +\
+ "cli sessions."
# TODO: save all the timers and output them for plotting
# load some variables from the params file
@@ -92,15 +96,15 @@
verifyResult = main.ONOSbench.verifyCell()
# FIXME:this is short term fix
- main.log.report( "Removing raft logs" )
+ main.log.info( "Removing raft logs" )
main.ONOSbench.onosRemoveRaftLogs()
- main.log.report( "Uninstalling ONOS" )
+ main.log.info( "Uninstalling ONOS" )
for node in nodes:
main.ONOSbench.onosUninstall( node.ip_address )
# Make sure ONOS is DEAD
- main.log.report( "Killing any ONOS processes" )
+ main.log.info( "Killing any ONOS processes" )
killResults = main.TRUE
for node in nodes:
killed = main.ONOSbench.onosKill( node.ip_address )
@@ -115,36 +119,39 @@
onpass="Mininet Started",
onfail="Error starting Mininet" )
- main.step( "Compiling the latest version of ONOS" )
+ main.step( "Git checkout and pull " + gitBranch )
if PULLCODE:
- main.step( "Git checkout and pull " + gitBranch )
main.ONOSbench.gitCheckout( gitBranch )
gitPullResult = main.ONOSbench.gitPull()
# values of 1 or 3 are good
utilities.assert_lesser( expect=0, actual=gitPullResult,
onpass="Git pull successful",
onfail="Git pull failed" )
+ main.ONOSbench.getVersion( report=True )
- main.step( "Using mvn clean and install" )
+ main.step( "Using mvn clean install" )
+ cleanInstallResult = main.TRUE
+ if PULLCODE and gitPullResult == main.TRUE:
cleanInstallResult = main.ONOSbench.cleanInstall()
- utilities.assert_equals( expect=main.TRUE,
- actual=cleanInstallResult,
- onpass="MCI successful",
- onfail="MCI failed" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
- main.ONOSbench.getVersion( report=True )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cleanInstallResult,
+ onpass="MCI successful",
+ onfail="MCI failed" )
# GRAPHS
# NOTE: important params here:
# job = name of Jenkins job
# Plot Name = Plot-HA, only can be used if multiple plots
# index = The number of the graph under plot name
job = "HAMinorityRestart"
+ plotName = "Plot-HA"
graphs = '<ac:structured-macro ac:name="html">\n'
graphs += '<ac:plain-text-body><![CDATA[\n'
graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
- '/plot/getPlot?index=0&width=500&height=300"' +\
+ '/plot/' + plotName + '/getPlot?index=0' +\
+ '&width=500&height=300"' +\
'noborder="0" width="500" height="300" scrolling="yes" ' +\
'seamless="seamless"></iframe>\n'
graphs += ']]></ac:plain-text-body>\n'
@@ -173,7 +180,7 @@
for node in nodes:
started = main.ONOSbench.isup( node.ip_address )
if not started:
- main.log.report( node.name + " didn't start!" )
+ main.log.error( node.name + " didn't start!" )
main.ONOSbench.onosStop( node.ip_address )
main.ONOSbench.onosStart( node.ip_address )
onosIsupResult = onosIsupResult and started
@@ -200,12 +207,13 @@
onpass="ONOS cli startup successful",
onfail="ONOS cli startup failed" )
- main.step( "Start Packet Capture MN" )
- main.Mininet2.startTcpdump(
- str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
- + "-MN.pcap",
- intf=main.params[ 'MNtcpdump' ][ 'intf' ],
- port=main.params[ 'MNtcpdump' ][ 'port' ] )
+ if main.params[ 'tcpdump' ].lower() == "true":
+ main.step( "Start Packet Capture MN" )
+ main.Mininet2.startTcpdump(
+ str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
+ + "-MN.pcap",
+ intf=main.params[ 'MNtcpdump' ][ 'intf' ],
+ port=main.params[ 'MNtcpdump' ][ 'port' ] )
main.step( "App Ids check" )
appCheck = main.TRUE
@@ -227,16 +235,14 @@
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
- case1Result = ( cleanInstallResult and packageResult and
- cellResult and verifyResult and onosInstallResult
- and onosIsupResult and cliResults )
- if case1Result == main.FALSE:
+ if cliResults == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
def CASE2( self, main ):
"""
- Assign mastership to controllers
+ Assign devices to controllers
"""
import re
import time
@@ -253,8 +259,10 @@
assert ONOS6Port, "ONOS6Port not defined"
assert ONOS7Port, "ONOS7Port not defined"
- main.log.report( "Assigning switches to controllers" )
- main.case( "Assigning Controllers" )
+ main.case( "Assigning devices to controllers" )
+ main.caseExplaination = "Assign switches to ONOS using 'ovs-vsctl' " +\
+ "and check that an ONOS node becomes the " +\
+ "master of the device."
main.step( "Assign switches to controllers" )
# TODO: rewrite this function to take lists of ips and ports?
@@ -286,14 +294,36 @@
"not in the list of controllers s" +
str( i ) + " is connecting to." )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Switch mastership assigned correctly" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
onpass="Switch mastership assigned correctly",
onfail="Switches not assigned correctly to controllers" )
+ def CASE21( self, main ):
+ """
+ Assign mastership to controllers
+ """
+ import re
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
+
+ main.case( "Assigning Controller roles for switches" )
+ main.caseExplaination = "Check that ONOS is connected to each " +\
+ "device. Then manually assign" +\
+ " mastership to specific ONOS nodes using" +\
+ " 'device-role'"
main.step( "Assign mastership of switches to specific controllers" )
# Manually assign mastership to the controller we want
roleCall = main.TRUE
@@ -338,6 +368,7 @@
else:
main.log.error( "You didn't write an else statement for " +
"switch s" + str( i ) )
+ roleCall = main.FALSE
# Assign switch
assert deviceId, "No device id for s" + str( i ) + " in ONOS"
# TODO: make this controller dynamic
@@ -378,11 +409,6 @@
onpass="Switches were successfully reassigned to designated " +
"controller",
onfail="Switches were not successfully reassigned" )
- mastershipCheck = mastershipCheck and roleCall and roleCheck
- utilities.assert_equals( expect=main.TRUE, actual=mastershipCheck,
- onpass="Switch mastership correctly assigned",
- onfail="Error in (re)assigning switch" +
- " mastership" )
def CASE3( self, main ):
"""
@@ -395,11 +421,12 @@
assert utilities.assert_equals, "utilities.assert_equals not defined"
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- main.log.report( "Adding host intents" )
main.case( "Adding host Intents" )
-
- main.step( "Discovering Hosts( Via pingall for now )" )
- # FIXME: Once we have a host discovery mechanism, use that instead
+ main.caseExplaination = "Discover hosts by using pingall then " +\
+ "assign predetermined host-to-host intents." +\
+ " After installation, check that the intent" +\
+ " is distributed to all nodes and the state" +\
+ " is INSTALLED"
# install onos-app-fwd
main.step( "Install reactive forwarding app" )
@@ -408,6 +435,7 @@
onpass="Install fwd successful",
onfail="Install fwd failed" )
+ main.step( "Check app ids" )
appCheck = main.TRUE
threads = []
for i in range( numControllers ):
@@ -427,6 +455,8 @@
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
+ main.step( "Discovering Hosts( Via pingall for now )" )
+ # FIXME: Once we have a host discovery mechanism, use that instead
# REACTIVE FWD test
pingResult = main.FALSE
for i in range(2): # Retry if pingall fails first time
@@ -449,8 +479,10 @@
utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
onpass="Uninstall fwd successful",
onfail="Uninstall fwd failed" )
- main.step( "Check app ids check" )
+
+ main.step( "Check app ids" )
threads = []
+ appCheck2 = main.TRUE
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].appToIDCheck,
name="appToIDCheck-" + str( i ),
@@ -460,15 +492,15 @@
for t in threads:
t.join()
- appCheck = appCheck and t.result
- if appCheck != main.TRUE:
+ appCheck2 = appCheck2 and t.result
+ if appCheck2 != main.TRUE:
main.log.warn( CLIs[0].apps() )
main.log.warn( CLIs[0].appIDs() )
- utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck2,
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
- main.step( "Add host intents" )
+ main.step( "Add host intents via cli" )
intentIds = []
# TODO: move the host numbers to params
# Maybe look at all the paths we ping?
@@ -511,7 +543,10 @@
except ( ValueError, TypeError ):
main.log.warn( repr( hosts ) )
hostResult = main.FALSE
- # FIXME: DEBUG
+ utilities.assert_equals( expect=main.TRUE, actual=hostResult,
+ onpass="Found a host id for each host",
+ onfail="Error looking up host ids" )
+
intentStart = time.time()
onosIds = main.ONOScli1.getAllIntentsId()
main.log.info( "Submitted intents: " + str( intentIds ) )
@@ -521,7 +556,6 @@
pass # intent submitted is in onos
else:
intentAddResult = False
- # FIXME: DEBUG
if intentAddResult:
intentStop = time.time()
else:
@@ -555,6 +589,7 @@
( str( count ), str( i ), str( s ) ) )
leaders = main.ONOScli1.leaders()
try:
+ missing = False
if leaders:
parsedLeaders = json.loads( leaders )
main.log.warn( json.dumps( parsedLeaders,
@@ -571,11 +606,19 @@
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
" not in leaders" )
+ missing = True
else:
main.log.error( "leaders() returned None" )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing leaders" )
main.log.error( repr( leaders ) )
+ # Check all nodes
+ if missing:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
partitions = main.ONOScli1.partitions()
try:
if partitions :
@@ -606,13 +649,11 @@
main.log.exception( "Error parsing pending map" )
main.log.error( repr( pendingMap ) )
- intentAddResult = bool( pingResult and hostResult and intentAddResult
- and not missingIntents and installedCheck )
- utilities.assert_equals(
- expect=True,
- actual=intentAddResult,
- onpass="Pushed host intents to ONOS",
- onfail="Error in pushing host intents to ONOS" )
+ intentAddResult = bool( intentAddResult and not missingIntents and
+ installedCheck )
+ if not intentAddResult:
+ main.log.error( "Error in pushing host intents to ONOS" )
+
main.step( "Intent Anti-Entropy dispersion" )
for i in range(100):
correct = True
@@ -624,7 +665,17 @@
main.log.debug( "Intents in " + cli.name + ": " +
str( sorted( onosIds ) ) )
if sorted( ids ) != sorted( intentIds ):
+ main.log.debug( "Set of intent IDs doesn't match" )
correct = False
+ break
+ else:
+ intents = json.loads( cli.intents() )
+ for intent in intents:
+ if intent[ 'state' ] != "INSTALLED":
+ main.log.warn( "Intent " + intent[ 'id' ] +
+ " is " + intent[ 'state' ] )
+ correct = False
+ break
if correct:
break
else:
@@ -680,6 +731,7 @@
( str( count ), str( i ), str( s ) ) )
leaders = main.ONOScli1.leaders()
try:
+ missing = False
if leaders:
parsedLeaders = json.loads( leaders )
main.log.warn( json.dumps( parsedLeaders,
@@ -699,11 +751,19 @@
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
" not in leaders" )
+ missing = True
else:
main.log.error( "leaders() returned None" )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing leaders" )
main.log.error( repr( leaders ) )
+ # Check all nodes
+ if missing:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
partitions = main.ONOScli1.partitions()
try:
if partitions :
@@ -745,9 +805,11 @@
assert utilities.assert_equals, "utilities.assert_equals not defined"
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- description = " Ping across added host intents"
- main.log.report( description )
- main.case( description )
+ main.case( "Verify connectivity by sendind traffic across Intents" )
+ main.caseExplaination = "Ping across added host intents to check " +\
+ "functionality and check the state of " +\
+ "the intent"
+ main.step( "Ping across added host intents" )
PingResult = main.TRUE
for i in range( 8, 18 ):
ping = main.Mininet1.pingHost( src="h" + str( i ),
@@ -760,7 +822,7 @@
main.log.info( "Ping test passed!" )
# Don't set PingResult or you'd override failures
if PingResult == main.FALSE:
- main.log.report(
+ main.log.error(
"Intents have not been installed correctly, pings failed." )
# TODO: pretty print
main.log.warn( "ONOS1 intents: " )
@@ -772,17 +834,17 @@
separators=( ',', ': ' ) ) )
except ( ValueError, TypeError ):
main.log.warn( repr( tmpIntents ) )
- if PingResult == main.TRUE:
- main.log.report(
- "Intents have been installed correctly and verified by pings" )
utilities.assert_equals(
expect=main.TRUE,
actual=PingResult,
onpass="Intents have been installed correctly and pings work",
onfail="Intents have not been installed correctly, pings failed." )
- installedCheck = True
- if PingResult is not main.TRUE:
+ main.step( "Check Intent state" )
+ installedCheck = False
+ loopCount = 0
+ while not installedCheck and loopCount < 40:
+ installedCheck = True
# Print the intent states
intents = main.ONOScli1.intents()
intentStates = []
@@ -798,66 +860,95 @@
intentStates.append( ( intentId, state ) )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing intents." )
+ # Print states
intentStates.sort()
for i, s in intentStates:
count += 1
main.log.info( "%-6s%-15s%-15s" %
( str( count ), str( i ), str( s ) ) )
- leaders = main.ONOScli1.leaders()
- try:
- if leaders:
- parsedLeaders = json.loads( leaders )
- main.log.warn( json.dumps( parsedLeaders,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # check for all intent partitions
- # check for election
- topics = []
- for i in range( 14 ):
- topics.append( "intent-partition-" + str( i ) )
- # FIXME: this should only be after we start the app
- topics.append( "org.onosproject.election" )
- main.log.debug( topics )
- ONOStopics = [ j['topic'] for j in parsedLeaders ]
- for topic in topics:
- if topic not in ONOStopics:
- main.log.error( "Error: " + topic +
- " not in leaders" )
- else:
- main.log.error( "leaders() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing leaders" )
- main.log.error( repr( leaders ) )
- partitions = main.ONOScli1.partitions()
- try:
- if partitions :
- parsedPartitions = json.loads( partitions )
- main.log.warn( json.dumps( parsedPartitions,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # TODO check for a leader in all paritions
- # TODO check for consistency among nodes
- else:
- main.log.error( "partitions() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing partitions" )
- main.log.error( repr( partitions ) )
- pendingMap = main.ONOScli1.pendingMap()
- try:
- if pendingMap :
- parsedPending = json.loads( pendingMap )
- main.log.warn( json.dumps( parsedPending,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # TODO check something here?
- else:
- main.log.error( "pendingMap() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing pending map" )
- main.log.error( repr( pendingMap ) )
+ if not installedCheck:
+ time.sleep( 1 )
+ loopCount += 1
+ utilities.assert_equals( expect=True, actual=installedCheck,
+ onpass="Intents are all INSTALLED",
+ onfail="Intents are not all in " +
+ "INSTALLED state" )
+
+ main.step( "Check leadership of topics" )
+ leaders = main.ONOScli1.leaders()
+ topicCheck = main.TRUE
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ # TODO: Look at Devices as topics now that it uses this system
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ # FIXME: topics.append( "org.onosproject.election" )
+ # Print leaders output
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ topicCheck = main.FALSE
+ else:
+ main.log.error( "leaders() returned None" )
+ topicCheck = main.FALSE
+ except ( ValueError, TypeError ):
+ topicCheck = main.FALSE
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ # TODO: Check for a leader of these topics
+ # Check all nodes
+ if topicCheck:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=topicCheck,
+ onpass="intent Partitions is in leaders",
+ onfail="Some topics were lost " )
+ # Print partitions
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ # Print Pending Map
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
if not installedCheck:
main.log.info( "Waiting 60 seconds to see if the state of " +
@@ -885,6 +976,7 @@
( str( count ), str( i ), str( s ) ) )
leaders = main.ONOScli1.leaders()
try:
+ missing = False
if leaders:
parsedLeaders = json.loads( leaders )
main.log.warn( json.dumps( parsedLeaders,
@@ -904,11 +996,18 @@
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
" not in leaders" )
+ missing = True
else:
main.log.error( "leaders() returned None" )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing leaders" )
main.log.error( repr( leaders ) )
+ if missing:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
partitions = main.ONOScli1.partitions()
try:
if partitions :
@@ -938,7 +1037,39 @@
except ( ValueError, TypeError ):
main.log.exception( "Error parsing pending map" )
main.log.error( repr( pendingMap ) )
- main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+ # Print flowrules
+ main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+ main.step( "Wait a minute then ping again" )
+ # the wait is above
+ PingResult = main.TRUE
+ for i in range( 8, 18 ):
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
+ PingResult = PingResult and ping
+ if ping == main.FALSE:
+ main.log.warn( "Ping failed between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ elif ping == main.TRUE:
+ main.log.info( "Ping test passed!" )
+ # Don't set PingResult or you'd override failures
+ if PingResult == main.FALSE:
+ main.log.error(
+ "Intents have not been installed correctly, pings failed." )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=PingResult,
+ onpass="Intents have been installed correctly and pings work",
+ onfail="Intents have not been installed correctly, pings failed." )
def CASE5( self, main ):
"""
@@ -954,7 +1085,6 @@
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
- main.log.report( "Setting up and gathering data for current state" )
main.case( "Setting up and gathering data for current state" )
# The general idea for this test case is to pull the state of
# ( intents,flows, topology,... ) from each ONOS node
@@ -1002,7 +1132,7 @@
for i in range( numControllers ):
if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" roles" )
main.log.warn(
"ONOS" + str( i + 1 ) + " mastership response: " +
@@ -1016,7 +1146,7 @@
main.step( "Check for consistency in roles from each controller" )
if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
- main.log.report(
+ main.log.info(
"Switch roles are consistent across all ONOS nodes" )
else:
consistentMastership = False
@@ -1064,7 +1194,7 @@
for i in range( numControllers ):
if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" intents" )
main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
repr( ONOSIntents[ i ] ) )
@@ -1077,11 +1207,11 @@
main.step( "Check for consistency in Intents from each controller" )
if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
- main.log.report( "Intents are consistent across all ONOS " +
+ main.log.info( "Intents are consistent across all ONOS " +
"nodes" )
else:
consistentIntents = False
- main.log.report( "Intents not consistent" )
+ main.log.error( "Intents not consistent" )
utilities.assert_equals(
expect=True,
actual=consistentIntents,
@@ -1165,7 +1295,7 @@
for i in range( numControllers ):
num = str( i + 1 )
if not ONOSFlows[ i ] or "Error" in ONOSFlows[ i ]:
- main.log.report( "Error in getting ONOS" + num + " flows" )
+ main.log.error( "Error in getting ONOS" + num + " flows" )
main.log.warn( "ONOS" + num + " flows response: " +
repr( ONOSFlows[ i ] ) )
flowsResults = False
@@ -1189,7 +1319,7 @@
main.step( "Check for consistency in Flows from each controller" )
tmp = [ len( i ) == len( ONOSFlowsJson[ 0 ] ) for i in ONOSFlowsJson ]
if all( tmp ):
- main.log.report( "Flow count is consistent across all ONOS nodes" )
+ main.log.info( "Flow count is consistent across all ONOS nodes" )
else:
consistentFlows = False
utilities.assert_equals(
@@ -1352,14 +1482,14 @@
if hosts[ controller ] == hosts[ 0 ]:
continue
else: # hosts not consistent
- main.log.report( "hosts from ONOS" +
+ main.log.error( "hosts from ONOS" +
controllerStr +
" is inconsistent with ONOS1" )
main.log.warn( repr( hosts[ controller ] ) )
consistentHostsResult = main.FALSE
else:
- main.log.report( "Error in getting ONOS hosts from ONOS" +
+ main.log.error( "Error in getting ONOS hosts from ONOS" +
controllerStr )
consistentHostsResult = main.FALSE
main.log.warn( "ONOS" + controllerStr +
@@ -1376,7 +1506,7 @@
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- if not host.get( 'ips', [ ] ):
+ if not host.get( 'ipAddresses', [ ] ):
main.log.error( "DEBUG:Error with host ips on controller" +
controllerStr + ": " + str( host ) )
ipResult = main.FALSE
@@ -1395,12 +1525,12 @@
if clusters[ controller ] == clusters[ 0 ]:
continue
else: # clusters not consistent
- main.log.report( "clusters from ONOS" + controllerStr +
+ main.log.error( "clusters from ONOS" + controllerStr +
" is inconsistent with ONOS1" )
consistentClustersResult = main.FALSE
else:
- main.log.report( "Error in getting dataplane clusters " +
+ main.log.error( "Error in getting dataplane clusters " +
"from ONOS" + controllerStr )
consistentClustersResult = main.FALSE
main.log.warn( "ONOS" + controllerStr +
@@ -1495,6 +1625,7 @@
assert nodes, "nodes not defined"
main.case( "Restart minority of ONOS nodes" )
main.step( "Killing 3 ONOS nodes" )
+ killTime = time.time()
# TODO: Randomize these nodes or base this on partitions
# TODO: use threads in this case
killResults = main.ONOSbench.onosKill( nodes[0].ip_address )
@@ -1533,7 +1664,24 @@
# Grab the time of restart so we chan check how long the gossip
# protocol has had time to work
- main.restartTime = time.time()
+ main.restartTime = time.time() - killTime
+ main.log.debug( "Restart time: " + str( main.restartTime ) )
+ '''
+ # FIXME: revisit test plan for election with madan
+ # Rerun for election on restarted nodes
+ run1 = CLIs[0].electionTestRun()
+ run2 = CLIs[1].electionTestRun()
+ run3 = CLIs[2].electionTestRun()
+ runResults = run1 and run2 and run3
+ utilities.assert_equals( expect=main.TRUE, actual=runResults,
+ onpass="Reran for election",
+ onfail="Failed to rerun for election" )
+ '''
+ # TODO: MAke this configurable. Also, we are breaking the above timer
+ time.sleep( 60 )
+ main.log.debug( CLIs[0].nodes( jsonFormat=False ) )
+ main.log.debug( CLIs[0].leaders( jsonFormat=False ) )
+ main.log.debug( CLIs[0].partitions( jsonFormat=False ) )
def CASE7( self, main ):
"""
@@ -1569,7 +1717,6 @@
main.step( "Read device roles from ONOS" )
ONOSMastership = []
- mastershipCheck = main.FALSE
consistentMastership = True
rolesResults = True
threads = []
@@ -1586,7 +1733,7 @@
for i in range( numControllers ):
if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" roles" )
main.log.warn(
"ONOS" + str( i + 1 ) + " mastership response: " +
@@ -1600,7 +1747,7 @@
main.step( "Check for consistency in roles from each controller" )
if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
- main.log.report(
+ main.log.info(
"Switch roles are consistent across all ONOS nodes" )
else:
consistentMastership = False
@@ -1619,9 +1766,9 @@
sort_keys=True,
indent=4,
separators=( ',', ': ' ) ) )
- elif rolesResults and not consistentMastership:
- mastershipCheck = main.TRUE
+ # NOTE: we expect mastership to change on controller failure
+ '''
description2 = "Compare switch roles from before failure"
main.step( description2 )
try:
@@ -1647,15 +1794,12 @@
else:
main.log.warn( "Mastership of switch %s changed" % switchDPID )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Mastership of Switches was not changed" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
onpass="Mastership of Switches was not changed",
onfail="Mastership of some switches changed" )
- # NOTE: we expect mastership to change on controller failure
- mastershipCheck = consistentMastership
+ '''
main.step( "Get the intents and compare across all nodes" )
ONOSIntents = []
@@ -1677,7 +1821,7 @@
for i in range( numControllers ):
if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" intents" )
main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
repr( ONOSIntents[ i ] ) )
@@ -1690,7 +1834,7 @@
main.step( "Check for consistency in Intents from each controller" )
if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
- main.log.report( "Intents are consistent across all ONOS " +
+ main.log.info( "Intents are consistent across all ONOS " +
"nodes" )
else:
consistentIntents = False
@@ -1757,22 +1901,41 @@
main.step( "Compare current intents with intents before the failure" )
# NOTE: this requires case 5 to pass for intentState to be set.
# maybe we should stop the test if that fails?
- sameIntents = main.TRUE
+ sameIntents = main.FALSE
if intentState and intentState == ONOSIntents[ 0 ]:
sameIntents = main.TRUE
- main.log.report( "Intents are consistent with before failure" )
+ main.log.info( "Intents are consistent with before failure" )
# TODO: possibly the states have changed? we may need to figure out
# what the acceptable states are
- else:
+ elif len( intentState ) == len( ONOSIntents[ 0 ] ):
+ sameIntents = main.TRUE
try:
- main.log.warn( "ONOS intents: " )
- main.log.warn( json.dumps( json.loads( ONOSIntents[ 0 ] ),
- sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
+ before = json.loads( intentState )
+ after = json.loads( ONOSIntents[ 0 ] )
+ for intent in before:
+ if intent not in after:
+ sameIntents = main.FALSE
+ main.log.debug( "Intent is not currently in ONOS " +
+ "(at least in the same form):" )
+ main.log.debug( json.dumps( intent ) )
except ( ValueError, TypeError ):
main.log.exception( "Exception printing intents" )
- main.log.warn( repr( ONOSIntents[0] ) )
- sameIntents = main.FALSE
+ main.log.debug( repr( ONOSIntents[0] ) )
+ main.log.debug( repr( intentState ) )
+ if sameIntents == main.FALSE:
+ try:
+ main.log.debug( "ONOS intents before: " )
+ main.log.debug( json.dumps( json.loads( intentState ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ main.log.debug( "Current ONOS intents: " )
+ main.log.debug( json.dumps( json.loads( ONOSIntents[ 0 ] ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Exception printing intents" )
+ main.log.debug( repr( ONOSIntents[0] ) )
+ main.log.debug( repr( intentState ) )
utilities.assert_equals(
expect=main.TRUE,
actual=sameIntents,
@@ -1795,8 +1958,6 @@
if FlowTables == main.FALSE:
main.log.info( "Differences in flow table for switch: s" +
str( i + 1 ) )
- if FlowTables == main.TRUE:
- main.log.report( "No changes were found in the flow tables" )
utilities.assert_equals(
expect=main.TRUE,
actual=FlowTables,
@@ -1822,7 +1983,7 @@
main.log.info( "There are multiple mininet process running" )
elif LossInPings == main.FALSE:
main.log.info( "No Loss in the pings" )
- main.log.report( "No loss of dataplane connectivity" )
+ main.log.info( "No loss of dataplane connectivity" )
utilities.assert_equals(
expect=main.FALSE,
actual=LossInPings,
@@ -1841,18 +2002,18 @@
leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == main.FALSE:
- # error in response
- main.log.report( "Something is wrong with " +
+ # error in response
+ main.log.error( "Something is wrong with " +
"electionTestLeader function, check the" +
" error logs" )
leaderResult = main.FALSE
elif leaderN is None:
- main.log.report( cli.name +
+ main.log.error( cli.name +
" shows no leader for the election-app was" +
" elected after the old one died" )
leaderResult = main.FALSE
elif leaderN in restarted:
- main.log.report( cli.name + " shows " + str( leaderN ) +
+ main.log.error( cli.name + " shows " + str( leaderN ) +
" as leader for the election-app, but it " +
"was restarted" )
leaderResult = main.FALSE
@@ -1861,10 +2022,6 @@
main.log.error(
"Inconsistent view of leader for the election test app" )
# TODO: print the list
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was re-elected if applicable )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
@@ -1888,20 +2045,31 @@
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- description = "Compare ONOS Topology view to Mininet topology"
- main.case( description )
- main.log.report( description )
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplaination = "Compare topology objects between Mininet" +\
+ " and ONOS"
main.step( "Create TestONTopology object" )
- ctrls = []
- for node in nodes:
- temp = ( node, node.name, node.ip_address, 6633 )
- ctrls.append( temp )
- MNTopo = TestONTopology( main.Mininet1, ctrls )
+ try:
+ ctrls = []
+ for node in nodes:
+ temp = ( node, node.name, node.ip_address, 6633 )
+ ctrls.append( temp )
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
+ except Exception:
+ objResult = main.FALSE
+ else:
+ objResult = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=objResult,
+ onpass="Created TestONTopology object",
+ onfail="Exception while creating " +
+ "TestONTopology object" )
+ main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
portsResults = main.TRUE
linksResults = main.TRUE
hostsResults = main.TRUE
+ hostAttachmentResults = True
topoResult = main.FALSE
elapsed = 0
count = 0
@@ -1946,9 +2114,9 @@
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- if host is None or host.get( 'ips', [] ) == []:
+ if host is None or host.get( 'ipAddresses', [] ) == []:
main.log.error(
- "DEBUG:Error with host ips on controller" +
+ "DEBUG:Error with host ipAddresses on controller" +
controllerStr + ": " + str( host ) )
ipResult = main.FALSE
ports = []
@@ -1990,6 +2158,7 @@
elapsed = time.time() - startTime
cliTime = time.time() - cliStart
+ print "Elapsed time: " + str( elapsed )
print "CLI time: " + str( cliTime )
for controller in range( numControllers ):
@@ -2045,88 +2214,186 @@
" hosts exist in Mininet",
onfail="ONOS" + controllerStr +
" hosts don't match Mininet" )
+ # CHECKING HOST ATTACHMENT POINTS
+ hostAttachment = True
+ noHosts = False
+ # FIXME: topo-HA/obelisk specific mappings:
+ # key is mac and value is dpid
+ mappings = {}
+ for i in range( 1, 29 ): # hosts 1 through 28
+ # set up correct variables:
+ macId = "00:" * 5 + hex( i ).split( "0x" )[1].upper().zfill(2)
+ if i == 1:
+ deviceId = "1000".zfill(16)
+ elif i == 2:
+ deviceId = "2000".zfill(16)
+ elif i == 3:
+ deviceId = "3000".zfill(16)
+ elif i == 4:
+ deviceId = "3004".zfill(16)
+ elif i == 5:
+ deviceId = "5000".zfill(16)
+ elif i == 6:
+ deviceId = "6000".zfill(16)
+ elif i == 7:
+ deviceId = "6007".zfill(16)
+ elif i >= 8 and i <= 17:
+ dpid = '3' + str( i ).zfill( 3 )
+ deviceId = dpid.zfill(16)
+ elif i >= 18 and i <= 27:
+ dpid = '6' + str( i ).zfill( 3 )
+ deviceId = dpid.zfill(16)
+ elif i == 28:
+ deviceId = "2800".zfill(16)
+ mappings[ macId ] = deviceId
+ if hosts[ controller ] or "Error" not in hosts[ controller ]:
+ if hosts[ controller ] == []:
+ main.log.warn( "There are no hosts discovered" )
+ noHosts = True
+ else:
+ for host in hosts[ controller ]:
+ mac = None
+ location = None
+ device = None
+ port = None
+ try:
+ mac = host.get( 'mac' )
+ assert mac, "mac field could not be found for this host object"
+ location = host.get( 'location' )
+ assert location, "location field could not be found for this host object"
+
+ # Trim the protocol identifier off deviceId
+ device = str( location.get( 'elementId' ) ).split(':')[1]
+ assert device, "elementId field could not be found for this host location object"
+
+ port = location.get( 'port' )
+ assert port, "port field could not be found for this host location object"
+
+ # Now check if this matches where they should be
+ if mac and device and port:
+ if str( port ) != "1":
+ main.log.error( "The attachment port is incorrect for " +
+ "host " + str( mac ) +
+ ". Expected: 1 Actual: " + str( port) )
+ hostAttachment = False
+ if device != mappings[ str( mac ) ]:
+ main.log.error( "The attachment device is incorrect for " +
+ "host " + str( mac ) +
+ ". Expected: " + mappings[ str( mac ) ] +
+ " Actual: " + device )
+ hostAttachment = False
+ else:
+ hostAttachment = False
+ except AssertionError:
+ main.log.exception( "Json object not as expected" )
+ main.log.error( repr( host ) )
+ hostAttachment = False
+ else:
+ main.log.error( "No hosts json output or \"Error\"" +
+ " in output. hosts = " +
+ repr( hosts[ controller ] ) )
+ if noHosts is False:
+ hostAttachment = True
+
+ # END CHECKING HOST ATTACHMENT POINTS
devicesResults = devicesResults and currentDevicesResult
portsResults = portsResults and currentPortsResult
linksResults = linksResults and currentLinksResult
hostsResults = hostsResults and currentHostsResult
+ hostAttachmentResults = hostAttachmentResults and hostAttachment
- # Compare json objects for hosts and dataplane clusters
+ # Compare json objects for hosts and dataplane clusters
- # hosts
- main.step( "Hosts view is consistent across all ONOS nodes" )
- consistentHostsResult = main.TRUE
- for controller in range( len( hosts ) ):
- controllerStr = str( controller + 1 )
- if "Error" not in hosts[ controller ]:
- if hosts[ controller ] == hosts[ 0 ]:
- continue
- else: # hosts not consistent
- main.log.report( "hosts from ONOS" + controllerStr +
- " is inconsistent with ONOS1" )
- main.log.warn( repr( hosts[ controller ] ) )
- consistentHostsResult = main.FALSE
-
- else:
- main.log.report( "Error in getting ONOS hosts from ONOS" +
- controllerStr )
+ # hosts
+ main.step( "Hosts view is consistent across all ONOS nodes" )
+ consistentHostsResult = main.TRUE
+ for controller in range( len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in hosts[ controller ]:
+ if hosts[ controller ] == hosts[ 0 ]:
+ continue
+ else: # hosts not consistent
+ main.log.error( "hosts from ONOS" + controllerStr +
+ " is inconsistent with ONOS1" )
+ main.log.warn( repr( hosts[ controller ] ) )
consistentHostsResult = main.FALSE
- main.log.warn( "ONOS" + controllerStr +
- " hosts response: " +
- repr( hosts[ controller ] ) )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=consistentHostsResult,
- onpass="Hosts view is consistent across all ONOS nodes",
- onfail="ONOS nodes have different views of hosts" )
- # Strongly connected clusters of devices
- main.step( "Clusters view is consistent across all ONOS nodes" )
- consistentClustersResult = main.TRUE
- for controller in range( len( clusters ) ):
- controllerStr = str( controller + 1 )
- if "Error" not in clusters[ controller ]:
- if clusters[ controller ] == clusters[ 0 ]:
- continue
- else: # clusters not consistent
- main.log.report( "clusters from ONOS" +
- controllerStr +
- " is inconsistent with ONOS1" )
- consistentClustersResult = main.FALSE
+ else:
+ main.log.error( "Error in getting ONOS hosts from ONOS" +
+ controllerStr )
+ consistentHostsResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " hosts response: " +
+ repr( hosts[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentHostsResult,
+ onpass="Hosts view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of hosts" )
- else:
- main.log.report( "Error in getting dataplane clusters " +
- "from ONOS" + controllerStr )
+ main.step( "Hosts information is correct" )
+ hostsResults = hostsResults and ipResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=hostsResults,
+ onpass="Host information is correct",
+ onfail="Host information is incorrect" )
+
+ main.step( "Host attachment points to the network" )
+ utilities.assert_equals(
+ expect=True,
+ actual=hostAttachmentResults,
+ onpass="Hosts are correctly attached to the network",
+ onfail="ONOS did not correctly attach hosts to the network" )
+
+ # Strongly connected clusters of devices
+ main.step( "Clusters view is consistent across all ONOS nodes" )
+ consistentClustersResult = main.TRUE
+ for controller in range( len( clusters ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in clusters[ controller ]:
+ if clusters[ controller ] == clusters[ 0 ]:
+ continue
+ else: # clusters not consistent
+ main.log.error( "clusters from ONOS" +
+ controllerStr +
+ " is inconsistent with ONOS1" )
consistentClustersResult = main.FALSE
- main.log.warn( "ONOS" + controllerStr +
- " clusters response: " +
- repr( clusters[ controller ] ) )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=consistentClustersResult,
- onpass="Clusters view is consistent across all ONOS nodes",
- onfail="ONOS nodes have different views of clusters" )
- # there should always only be one cluster
- main.step( "Topology view is correct and consistent across all " +
- "ONOS nodes" )
- try:
- numClusters = len( json.loads( clusters[ 0 ] ) )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing clusters[0]: " +
- repr( clusters[0] ) )
- clusterResults = main.FALSE
- if numClusters == 1:
- clusterResults = main.TRUE
- utilities.assert_equals(
- expect=1,
- actual=numClusters,
- onpass="ONOS shows 1 SCC",
- onfail="ONOS shows " + str( numClusters ) + " SCCs" )
- topoResult = ( devicesResults and portsResults and linksResults
- and hostsResults and consistentHostsResult
- and consistentClustersResult and clusterResults
- and ipResult )
+ else:
+ main.log.error( "Error in getting dataplane clusters " +
+ "from ONOS" + controllerStr )
+ consistentClustersResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " clusters response: " +
+ repr( clusters[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentClustersResult,
+ onpass="Clusters view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of clusters" )
+
+ main.step( "There is only one SCC" )
+ # there should always only be one cluster
+ try:
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing clusters[0]: " +
+ repr( clusters[0] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
+ utilities.assert_equals(
+ expect=1,
+ actual=numClusters,
+ onpass="ONOS shows 1 SCC",
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
+
+ topoResult = ( devicesResults and portsResults and linksResults
+ and hostsResults and consistentHostsResult
+ and consistentClustersResult and clusterResults
+ and ipResult and hostAttachmentResults )
topoResult = topoResult and int( count <= 2 )
note = "note it takes about " + str( int( cliTime ) ) + \
@@ -2136,11 +2403,27 @@
"Very crass estimate for topology discovery/convergence( " +
str( note ) + " ): " + str( elapsed ) + " seconds, " +
str( count ) + " tries" )
- utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
- if topoResult == main.TRUE:
- main.log.report( "ONOS topology view matches Mininet topology" )
+
+ main.step( "Device information is correct" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=devicesResults,
+ onpass="Device information is correct",
+ onfail="Device information is incorrect" )
+
+ main.step( "Port information is correct" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=portsResults,
+ onpass="Port information is correct",
+ onfail="Port information is incorrect" )
+
+ main.step( "Links are correct" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linksResults,
+ onpass="Link are correct",
+ onfail="Links are incorrect" )
# FIXME: move this to an ONOS state case
main.step( "Checking ONOS nodes" )
@@ -2198,7 +2481,6 @@
description = "Turn off a link to ensure that Link Discovery " +\
"is working properly"
- main.log.report( description )
main.case( description )
main.step( "Kill Link between s3 and s28" )
@@ -2227,7 +2509,6 @@
description = "Restore a link to ensure that Link Discovery is " + \
"working properly"
- main.log.report( description )
main.case( description )
main.step( "Bring link between s3 and s28 back up" )
@@ -2255,14 +2536,13 @@
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
description = "Killing a switch to ensure it is discovered correctly"
- main.log.report( description )
main.case( description )
switch = main.params[ 'kill' ][ 'switch' ]
switchDPID = main.params[ 'kill' ][ 'dpid' ]
# TODO: Make this switch parameterizable
main.step( "Kill " + switch )
- main.log.report( "Deleting " + switch )
+ main.log.info( "Deleting " + switch )
main.Mininet1.delSwitch( switch )
main.log.info( "Waiting " + str( switchSleep ) +
" seconds for switch down to be discovered" )
@@ -2301,11 +2581,9 @@
switchDPID = main.params[ 'kill' ][ 'dpid' ]
links = main.params[ 'kill' ][ 'links' ].split()
description = "Adding a switch to ensure it is discovered correctly"
- main.log.report( description )
main.case( description )
main.step( "Add back " + switch )
- main.log.report( "Adding back " + switch )
main.Mininet1.addSwitch( switch, dpid=switchDPID )
for peer in links:
main.Mininet1.addLink( switch, peer )
@@ -2354,9 +2632,7 @@
colors = { 'cyan': '\033[96m', 'purple': '\033[95m',
'blue': '\033[94m', 'green': '\033[92m',
'yellow': '\033[93m', 'red': '\033[91m', 'end': '\033[0m' }
- description = "Test Cleanup"
- main.log.report( description )
- main.case( description )
+ main.case( "Test Cleanup" )
main.step( "Killing tcpdumps" )
main.Mininet2.stopTcpdump()
@@ -2412,11 +2688,21 @@
for node in nodes:
print colors[ 'purple' ] + "Checking logs for errors on " + \
node.name + ":" + colors[ 'end' ]
- print main.ONOSbench.checkLogs( node.ip_address )
+ print main.ONOSbench.checkLogs( node.ip_address, restart=True )
main.step( "Packing and rotating pcap archives" )
os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
+ try:
+ timerLog = open( main.logdir + "/Timers.csv", 'w')
+ # Overwrite with empty line and close
+ labels = "Gossip Intents, Restart"
+ data = str( gossipTime ) + ", " + str( main.restartTime )
+ timerLog.write( labels + "\n" + data )
+ timerLog.close()
+ except NameError, e:
+ main.log.exception(e)
+
def CASE14( self, main ):
"""
start election app on all onos nodes
@@ -2427,34 +2713,45 @@
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- leaderResult = main.TRUE
main.case("Start Leadership Election app")
main.step( "Install leadership election app" )
- main.ONOScli1.activateApp( "org.onosproject.election" )
+ appResult = main.ONOScli1.activateApp( "org.onosproject.election" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=appResult,
+ onpass="Election app installed",
+ onfail="Something went wrong with installing Leadership election" )
+
+ main.step( "Run for election on each node" )
+ leaderResult = main.TRUE
leaders = []
for cli in CLIs:
cli.electionTestRun()
for cli in CLIs:
leader = cli.electionTestLeader()
if leader is None or leader == main.FALSE:
- main.log.report( cli.name + ": Leader for the election app " +
+ main.log.error( cli.name + ": Leader for the election app " +
"should be an ONOS node, instead got '" +
str( leader ) + "'" )
leaderResult = main.FALSE
leaders.append( leader )
- if len( set( leaders ) ) != 1:
- leaderResult = main.FALSE
- main.log.error( "Results of electionTestLeader is order of CLIs:" +
- str( leaders ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a leader " +
- "was elected )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
- onpass="Leadership election passed",
- onfail="Something went wrong with Leadership election" )
+ onpass="Successfully ran for leadership",
+ onfail="Failed to run for leadership" )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
def CASE15( self, main ):
"""
@@ -2469,14 +2766,30 @@
leaderResult = main.TRUE
description = "Check that Leadership Election is still functional"
- main.log.report( description )
main.case( description )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ leaders = []
+ for cli in CLIs:
+ leader = cli.electionTestLeader()
+ leaders.append( leader )
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
+
main.step( "Find current leader and withdraw" )
leader = main.ONOScli1.electionTestLeader()
# do some sanity checking on leader before using it
withdrawResult = main.FALSE
if leader is None or leader == main.FALSE:
- main.log.report(
+ main.log.error(
"Leader for the election app should be an ONOS node," +
"instead got '" + str( leader ) + "'" )
leaderResult = main.FALSE
@@ -2492,8 +2805,8 @@
utilities.assert_equals(
expect=main.TRUE,
actual=withdrawResult,
- onpass="App was withdrawn from election",
- onfail="App was not withdrawn from election" )
+ onpass="Node was withdrawn from election",
+ onfail="Node was not withdrawn from election" )
main.step( "Make sure new leader is elected" )
# FIXME: use threads
@@ -2502,14 +2815,14 @@
leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == leader:
- main.log.report( cli.name + " still sees " + str( leader ) +
+ main.log.error( cli.name + " still sees " + str( leader ) +
" as leader after they withdrew" )
leaderResult = main.FALSE
elif leaderN == main.FALSE:
# error in response
# TODO: add check for "Command not found:" in the driver, this
# means the app isn't loaded
- main.log.report( "Something is wrong with " +
+ main.log.error( "Something is wrong with " +
"electionTestLeader function, " +
"check the error logs" )
leaderResult = main.FALSE
@@ -2526,17 +2839,12 @@
"' as the leader" )
consistentLeader = main.TRUE
else:
- main.log.report(
+ main.log.error(
"Inconsistent responses for leader of Election-app:" )
for n in range( len( leaderList ) ):
- main.log.report( "ONOS" + str( n + 1 ) + " response: " +
+ main.log.error( "ONOS" + str( n + 1 ) + " response: " +
str( leaderList[ n ] ) )
leaderResult = leaderResult and consistentLeader
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was elected when the old leader " +
- "resigned )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
@@ -2555,6 +2863,7 @@
onpass="App re-ran for election",
onfail="App failed to run for election" )
+ main.step( "Leader did not change when old leader re-ran" )
afterRun = main.ONOScli1.electionTestLeader()
# verify leader didn't just change
if afterRun == leaderList[ 0 ]:
@@ -2569,18 +2878,11 @@
onfail="Something went wrong with Leadership election after " +
"the old leader re-ran for election" )
- case15Result = withdrawResult and leaderResult and runResult and\
- afterResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case15Result,
- onpass="Leadership election is still functional",
- onfail="Leadership Election is no longer functional" )
-
def CASE16( self, main ):
"""
Install Distributed Primitives app
"""
+ import time
assert numControllers, "numControllers not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
@@ -2610,11 +2912,13 @@
actual=appResults,
onpass="Primitives app activated",
onfail="Primitives app not activated" )
+ time.sleep( 5 ) # To allow all nodes to activate
def CASE17( self, main ):
"""
Check for basic functionality with distributed primitives
"""
+ import json
# Make sure variables are defined/set
assert numControllers, "numControllers not defined"
assert main, "main not defined"
@@ -2653,11 +2957,13 @@
main.step( "Increment and get a default counter on each node" )
pCounters = []
threads = []
+ addedPValues = []
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].counterTestIncrement,
name="counterIncrement-" + str( i ),
args=[ pCounterName ] )
pCounterValue += 1
+ addedPValues.append( pCounterValue )
threads.append( t )
t.start()
@@ -2666,8 +2972,12 @@
pCounters.append( t.result )
# Check that counter incremented numController times
pCounterResults = True
- for i in range( numControllers ):
- pCounterResults and ( i + 1 ) in pCounters
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
utilities.assert_equals( expect=True,
actual=pCounterResults,
onpass="Default counter incremented",
@@ -2676,6 +2986,7 @@
main.step( "Increment and get an in memory counter on each node" )
iCounters = []
+ addedIValues = []
threads = []
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].counterTestIncrement,
@@ -2683,6 +2994,7 @@
args=[ iCounterName ],
kwargs={ "inMemory": True } )
iCounterValue += 1
+ addedIValues.append( iCounterValue )
threads.append( t )
t.start()
@@ -2691,8 +3003,12 @@
iCounters.append( t.result )
# Check that counter incremented numController times
iCounterResults = True
- for i in range( numControllers ):
- iCounterResults and ( i + 1 ) in iCounters
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in the in-memory "
+ "counter incremented results" )
utilities.assert_equals( expect=True,
actual=iCounterResults,
onpass="In memory counter incremented",
@@ -2727,28 +3043,41 @@
main.step( "Counters we added have the correct values" )
correctResults = main.TRUE
for i in range( numControllers ):
- current = onosCounters[i]
+ current = json.loads( onosCounters[i] )
+ pValue = None
+ iValue = None
try:
- pValue = current.get( pCounterName )
- iValue = current.get( iCounterName )
- if pValue == pCounterValue:
- main.log.info( "Partitioned counter value is correct" )
- else:
- main.log.error( "Partitioned counter value is incorrect," +
- " expected value: " + str( pCounterValue )
- + " current value: " + str( pValue ) )
- correctResults = main.FALSE
- if iValue == iCounterValue:
- main.log.info( "In memory counter value is correct" )
- else:
- main.log.error( "In memory counter value is incorrect, " +
- "expected value: " + str( iCounterValue ) +
- " current value: " + str( iValue ) )
- correctResults = main.FALSE
+ for database in current:
+ partitioned = database.get( 'partitionedDatabaseCounters' )
+ if partitioned:
+ for value in partitioned:
+ if value.get( 'name' ) == pCounterName:
+ pValue = value.get( 'value' )
+ break
+ inMemory = database.get( 'inMemoryDatabaseCounters' )
+ if inMemory:
+ for value in inMemory:
+ if value.get( 'name' ) == iCounterName:
+ iValue = value.get( 'value' )
+ break
except AttributeError, e:
main.log.error( "ONOS" + str( i + 1 ) + " counters result " +
"is not as expected" )
correctResults = main.FALSE
+ if pValue == pCounterValue:
+ main.log.info( "Partitioned counter value is correct" )
+ else:
+ main.log.error( "Partitioned counter value is incorrect," +
+ " expected value: " + str( pCounterValue )
+ + " current value: " + str( pValue ) )
+ correctResults = main.FALSE
+ if iValue == iCounterValue:
+ main.log.info( "In memory counter value is correct" )
+ else:
+ main.log.error( "In memory counter value is incorrect, " +
+ "expected value: " + str( iCounterValue ) +
+ " current value: " + str( iValue ) )
+ correctResults = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=correctResults,
onpass="Added counters are correct",
diff --git a/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.params b/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.params
index e1421cd..f82aba3 100644
--- a/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.params
+++ b/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.params
@@ -25,6 +25,7 @@
<Git> False </Git>
<branch> master </branch>
<num_controllers> 7 </num_controllers>
+ <tcpdump> False </tcpdump>
<CTRL>
<ip1>10.128.30.11</ip1>
diff --git a/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.py b/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.py
index 3c4541c..d2a2ec1 100644
--- a/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.py
+++ b/TestON/tests/HATestNetworkPartition/HATestNetworkPartition.py
@@ -120,12 +120,27 @@
main.ONOSbench.gitCheckout( gitBranch )
gitPullResult = main.ONOSbench.gitPull()
- main.step( "Using mvn clean & install" )
+ main.step( "Using mvn clean and install" )
cleanInstallResult = main.ONOSbench.cleanInstall()
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
main.ONOSbench.getVersion( report=True )
+ # GRAPHS
+ # NOTE: important params here:
+ # job = name of Jenkins job
+ # Plot Name = Plot-HA, only can be used if multiple plots
+ # index = The number of the graph under plot name
+ job = "HANetworkPartition"
+ graphs = '<ac:structured-macro ac:name="html">\n'
+ graphs += '<ac:plain-text-body><![CDATA[\n'
+ graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
+ '/plot/getPlot?index=0&width=500&height=300"' +\
+ 'noborder="0" width="500" height="300" scrolling="yes" '+\
+ 'seamless="seamless"></iframe>\n'
+ graphs += ']]></ac:plain-text-body>\n'
+ graphs += '</ac:structured-macro>\n'
+ main.log.wiki(graphs)
main.step( "Creating ONOS package" )
packageResult = main.ONOSbench.onosPackage()
@@ -202,12 +217,13 @@
cliResults = cliResult1 and cliResult2 and cliResult3 and\
cliResult4 and cliResult5 and cliResult6 and cliResult7
- main.step( "Start Packet Capture MN" )
- main.Mininet2.startTcpdump(
- str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
- + "-MN.pcap",
- intf=main.params[ 'MNtcpdump' ][ 'intf' ],
- port=main.params[ 'MNtcpdump' ][ 'port' ] )
+ if main.params[ 'tcpdump' ].lower() == "true":
+ main.step( "Start Packet Capture MN" )
+ main.Mininet2.startTcpdump(
+ str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
+ + "-MN.pcap",
+ intf=main.params[ 'MNtcpdump' ][ 'intf' ],
+ port=main.params[ 'MNtcpdump' ][ 'port' ] )
case1Result = ( cleanInstallResult and packageResult and
cellResult and verifyResult and onosInstallResult
@@ -218,6 +234,7 @@
onfail="Test startup NOT successful" )
if case1Result == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
@@ -1414,7 +1431,7 @@
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- if host[ 'ips' ] == []:
+ if host[ 'ipAddresses' ] == []:
main.log.error(
"DEBUG:Error with host ips on controller" +
controllerStr + ": " + str( host ) )
diff --git a/TestON/tests/HATestSanity/HATestSanity.params b/TestON/tests/HATestSanity/HATestSanity.params
index dace37a..1e9d141 100644
--- a/TestON/tests/HATestSanity/HATestSanity.params
+++ b/TestON/tests/HATestSanity/HATestSanity.params
@@ -17,15 +17,15 @@
#CASE15: Check that Leadership Election is still functional
#CASE16: Install Distributed Primitives app
#CASE17: Check for basic functionality with distributed primitives
- #1,2,8,3,4,5,14,[6],8,7,4,15,9,8,4,10,8,4,11,8,4,12,8,4,13
#1,2,8,3,4,5,14,16,17,[6],8,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13
- <testcases>1,2,8,3,4,5,14,16,17,[6],8,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ <testcases>1,2,8,21,8,3,4,5,14,16,17,[6],8,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
<ENV>
<cellName>HA</cellName>
</ENV>
<Git> True </Git>
<branch> master </branch>
<num_controllers> 7 </num_controllers>
+ <tcpdump> False </tcpdump>
<CTRL>
<ip1>10.128.30.11</ip1>
diff --git a/TestON/tests/HATestSanity/HATestSanity.py b/TestON/tests/HATestSanity/HATestSanity.py
index 8bc21b0..306e547 100644
--- a/TestON/tests/HATestSanity/HATestSanity.py
+++ b/TestON/tests/HATestSanity/HATestSanity.py
@@ -5,7 +5,8 @@
List of test cases:
CASE1: Compile ONOS and push it to the test machines
-CASE2: Assign mastership to controllers
+CASE2: Assign devices to controllers
+CASE21: Assign mastership to controllers
CASE3: Assign intents
CASE4: Ping across added host intents
CASE5: Reading state of ONOS
@@ -47,8 +48,11 @@
start cli sessions
start tcpdump
"""
- main.log.report( "ONOS HA Sanity test - initialization" )
+ main.log.info( "ONOS HA Sanity test - initialization" )
main.case( "Setting up test environment" )
+ main.caseExplaination = "Setup the test environment including " +\
+ "installing ONOS, starting Mininet and ONOS" +\
+ "cli sessions."
# TODO: save all the timers and output them for plotting
# load some variables from the params file
@@ -92,15 +96,15 @@
verifyResult = main.ONOSbench.verifyCell()
# FIXME:this is short term fix
- main.log.report( "Removing raft logs" )
+ main.log.info( "Removing raft logs" )
main.ONOSbench.onosRemoveRaftLogs()
- main.log.report( "Uninstalling ONOS" )
+ main.log.info( "Uninstalling ONOS" )
for node in nodes:
main.ONOSbench.onosUninstall( node.ip_address )
# Make sure ONOS is DEAD
- main.log.report( "Killing any ONOS processes" )
+ main.log.info( "Killing any ONOS processes" )
killResults = main.TRUE
for node in nodes:
killed = main.ONOSbench.onosKill( node.ip_address )
@@ -115,26 +119,27 @@
onpass="Mininet Started",
onfail="Error starting Mininet" )
- main.step( "Compiling the latest version of ONOS" )
+ main.step( "Git checkout and pull " + gitBranch )
if PULLCODE:
- main.step( "Git checkout and pull " + gitBranch )
main.ONOSbench.gitCheckout( gitBranch )
gitPullResult = main.ONOSbench.gitPull()
# values of 1 or 3 are good
utilities.assert_lesser( expect=0, actual=gitPullResult,
onpass="Git pull successful",
onfail="Git pull failed" )
+ main.ONOSbench.getVersion( report=True )
- main.step( "Using mvn clean and install" )
+ main.step( "Using mvn clean install" )
+ cleanInstallResult = main.TRUE
+ if PULLCODE and gitPullResult == main.TRUE:
cleanInstallResult = main.ONOSbench.cleanInstall()
- utilities.assert_equals( expect=main.TRUE,
- actual=cleanInstallResult,
- onpass="MCI successful",
- onfail="MCI failed" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
- main.ONOSbench.getVersion( report=True )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cleanInstallResult,
+ onpass="MCI successful",
+ onfail="MCI failed" )
# GRAPHS
# NOTE: important params here:
# job = name of Jenkins job
@@ -175,7 +180,7 @@
for node in nodes:
started = main.ONOSbench.isup( node.ip_address )
if not started:
- main.log.report( node.name + " didn't start!" )
+ main.log.error( node.name + " didn't start!" )
main.ONOSbench.onosStop( node.ip_address )
main.ONOSbench.onosStart( node.ip_address )
onosIsupResult = onosIsupResult and started
@@ -202,12 +207,13 @@
onpass="ONOS cli startup successful",
onfail="ONOS cli startup failed" )
- main.step( "Start Packet Capture MN" )
- main.Mininet2.startTcpdump(
- str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
- + "-MN.pcap",
- intf=main.params[ 'MNtcpdump' ][ 'intf' ],
- port=main.params[ 'MNtcpdump' ][ 'port' ] )
+ if main.params[ 'tcpdump' ].lower() == "true":
+ main.step( "Start Packet Capture MN" )
+ main.Mininet2.startTcpdump(
+ str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
+ + "-MN.pcap",
+ intf=main.params[ 'MNtcpdump' ][ 'intf' ],
+ port=main.params[ 'MNtcpdump' ][ 'port' ] )
main.step( "App Ids check" )
appCheck = main.TRUE
@@ -229,16 +235,14 @@
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
- case1Result = ( cleanInstallResult and packageResult and
- cellResult and verifyResult and onosInstallResult
- and onosIsupResult and cliResults )
- if case1Result == main.FALSE:
+ if cliResults == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
def CASE2( self, main ):
"""
- Assign mastership to controllers
+ Assign devices to controllers
"""
import re
import time
@@ -255,8 +259,10 @@
assert ONOS6Port, "ONOS6Port not defined"
assert ONOS7Port, "ONOS7Port not defined"
- main.log.report( "Assigning switches to controllers" )
- main.case( "Assigning Controllers" )
+ main.case( "Assigning devices to controllers" )
+ main.caseExplaination = "Assign switches to ONOS using 'ovs-vsctl' " +\
+ "and check that an ONOS node becomes the " +\
+ "master of the device."
main.step( "Assign switches to controllers" )
# TODO: rewrite this function to take lists of ips and ports?
@@ -288,14 +294,36 @@
"not in the list of controllers s" +
str( i ) + " is connecting to." )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Switch mastership assigned correctly" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
onpass="Switch mastership assigned correctly",
onfail="Switches not assigned correctly to controllers" )
+ def CASE21( self, main ):
+ """
+ Assign mastership to controllers
+ """
+ import re
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
+
+ main.case( "Assigning Controller roles for switches" )
+ main.caseExplaination = "Check that ONOS is connected to each " +\
+ "device. Then manually assign" +\
+ " mastership to specific ONOS nodes using" +\
+ " 'device-role'"
main.step( "Assign mastership of switches to specific controllers" )
# Manually assign mastership to the controller we want
roleCall = main.TRUE
@@ -340,6 +368,7 @@
else:
main.log.error( "You didn't write an else statement for " +
"switch s" + str( i ) )
+ roleCall = main.FALSE
# Assign switch
assert deviceId, "No device id for s" + str( i ) + " in ONOS"
# TODO: make this controller dynamic
@@ -380,11 +409,6 @@
onpass="Switches were successfully reassigned to designated " +
"controller",
onfail="Switches were not successfully reassigned" )
- mastershipCheck = mastershipCheck and roleCall and roleCheck
- utilities.assert_equals( expect=main.TRUE, actual=mastershipCheck,
- onpass="Switch mastership correctly assigned",
- onfail="Error in (re)assigning switch" +
- " mastership" )
def CASE3( self, main ):
"""
@@ -397,11 +421,12 @@
assert utilities.assert_equals, "utilities.assert_equals not defined"
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- main.log.report( "Adding host intents" )
main.case( "Adding host Intents" )
-
- main.step( "Discovering Hosts( Via pingall for now )" )
- # FIXME: Once we have a host discovery mechanism, use that instead
+ main.caseExplaination = "Discover hosts by using pingall then " +\
+ "assign predetermined host-to-host intents." +\
+ " After installation, check that the intent" +\
+ " is distributed to all nodes and the state" +\
+ " is INSTALLED"
# install onos-app-fwd
main.step( "Install reactive forwarding app" )
@@ -410,6 +435,7 @@
onpass="Install fwd successful",
onfail="Install fwd failed" )
+ main.step( "Check app ids" )
appCheck = main.TRUE
threads = []
for i in range( numControllers ):
@@ -429,6 +455,8 @@
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
+ main.step( "Discovering Hosts( Via pingall for now )" )
+ # FIXME: Once we have a host discovery mechanism, use that instead
# REACTIVE FWD test
pingResult = main.FALSE
for i in range(2): # Retry if pingall fails first time
@@ -451,8 +479,15 @@
utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
onpass="Uninstall fwd successful",
onfail="Uninstall fwd failed" )
- main.step( "Check app ids check" )
+ '''
+ main.Mininet1.handle.sendline( "py [ h.cmd( \"arping -c 1 10.1.1.1 \" ) for h in net.hosts ] ")
+ import time
+ time.sleep(60)
+ '''
+
+ main.step( "Check app ids" )
threads = []
+ appCheck2 = main.TRUE
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].appToIDCheck,
name="appToIDCheck-" + str( i ),
@@ -462,15 +497,15 @@
for t in threads:
t.join()
- appCheck = appCheck and t.result
- if appCheck != main.TRUE:
+ appCheck2 = appCheck2 and t.result
+ if appCheck2 != main.TRUE:
main.log.warn( CLIs[0].apps() )
main.log.warn( CLIs[0].appIDs() )
- utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck2,
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
- main.step( "Add host intents" )
+ main.step( "Add host intents via cli" )
intentIds = []
# TODO: move the host numbers to params
# Maybe look at all the paths we ping?
@@ -513,7 +548,10 @@
except ( ValueError, TypeError ):
main.log.warn( repr( hosts ) )
hostResult = main.FALSE
- # FIXME: DEBUG
+ utilities.assert_equals( expect=main.TRUE, actual=hostResult,
+ onpass="Found a host id for each host",
+ onfail="Error looking up host ids" )
+
intentStart = time.time()
onosIds = main.ONOScli1.getAllIntentsId()
main.log.info( "Submitted intents: " + str( intentIds ) )
@@ -523,7 +561,6 @@
pass # intent submitted is in onos
else:
intentAddResult = False
- # FIXME: DEBUG
if intentAddResult:
intentStop = time.time()
else:
@@ -557,6 +594,7 @@
( str( count ), str( i ), str( s ) ) )
leaders = main.ONOScli1.leaders()
try:
+ missing = False
if leaders:
parsedLeaders = json.loads( leaders )
main.log.warn( json.dumps( parsedLeaders,
@@ -573,11 +611,19 @@
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
" not in leaders" )
+ missing = True
else:
main.log.error( "leaders() returned None" )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing leaders" )
main.log.error( repr( leaders ) )
+ # Check all nodes
+ if missing:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
partitions = main.ONOScli1.partitions()
try:
if partitions :
@@ -608,13 +654,11 @@
main.log.exception( "Error parsing pending map" )
main.log.error( repr( pendingMap ) )
- intentAddResult = bool( pingResult and hostResult and intentAddResult
- and not missingIntents and installedCheck )
- utilities.assert_equals(
- expect=True,
- actual=intentAddResult,
- onpass="Pushed host intents to ONOS",
- onfail="Error in pushing host intents to ONOS" )
+ intentAddResult = bool( intentAddResult and not missingIntents and
+ installedCheck )
+ if not intentAddResult:
+ main.log.error( "Error in pushing host intents to ONOS" )
+
main.step( "Intent Anti-Entropy dispersion" )
for i in range(100):
correct = True
@@ -626,7 +670,17 @@
main.log.debug( "Intents in " + cli.name + ": " +
str( sorted( onosIds ) ) )
if sorted( ids ) != sorted( intentIds ):
+ main.log.debug( "Set of intent IDs doesn't match" )
correct = False
+ break
+ else:
+ intents = json.loads( cli.intents() )
+ for intent in intents:
+ if intent[ 'state' ] != "INSTALLED":
+ main.log.warn( "Intent " + intent[ 'id' ] +
+ " is " + intent[ 'state' ] )
+ correct = False
+ break
if correct:
break
else:
@@ -682,6 +736,7 @@
( str( count ), str( i ), str( s ) ) )
leaders = main.ONOScli1.leaders()
try:
+ missing = False
if leaders:
parsedLeaders = json.loads( leaders )
main.log.warn( json.dumps( parsedLeaders,
@@ -701,11 +756,19 @@
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
" not in leaders" )
+ missing = True
else:
main.log.error( "leaders() returned None" )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing leaders" )
main.log.error( repr( leaders ) )
+ # Check all nodes
+ if missing:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
partitions = main.ONOScli1.partitions()
try:
if partitions :
@@ -747,9 +810,11 @@
assert utilities.assert_equals, "utilities.assert_equals not defined"
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- description = " Ping across added host intents"
- main.log.report( description )
- main.case( description )
+ main.case( "Verify connectivity by sendind traffic across Intents" )
+ main.caseExplaination = "Ping across added host intents to check " +\
+ "functionality and check the state of " +\
+ "the intent"
+ main.step( "Ping across added host intents" )
PingResult = main.TRUE
for i in range( 8, 18 ):
ping = main.Mininet1.pingHost( src="h" + str( i ),
@@ -762,7 +827,7 @@
main.log.info( "Ping test passed!" )
# Don't set PingResult or you'd override failures
if PingResult == main.FALSE:
- main.log.report(
+ main.log.error(
"Intents have not been installed correctly, pings failed." )
# TODO: pretty print
main.log.warn( "ONOS1 intents: " )
@@ -774,22 +839,21 @@
separators=( ',', ': ' ) ) )
except ( ValueError, TypeError ):
main.log.warn( repr( tmpIntents ) )
- if PingResult == main.TRUE:
- main.log.report(
- "Intents have been installed correctly and verified by pings" )
utilities.assert_equals(
expect=main.TRUE,
actual=PingResult,
onpass="Intents have been installed correctly and pings work",
onfail="Intents have not been installed correctly, pings failed." )
- installedCheck = True
- if PingResult is not main.TRUE:
+ main.step( "Check Intent state" )
+ installedCheck = False
+ loopCount = 0
+ while not installedCheck and loopCount < 40:
+ installedCheck = True
# Print the intent states
intents = main.ONOScli1.intents()
intentStates = []
main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
- count = 0
# Iter through intents of a node
try:
for intent in json.loads( intents ):
@@ -800,66 +864,95 @@
intentStates.append( ( intentId, state ) )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing intents." )
+ # Print states
intentStates.sort()
for i, s in intentStates:
count += 1
main.log.info( "%-6s%-15s%-15s" %
( str( count ), str( i ), str( s ) ) )
- leaders = main.ONOScli1.leaders()
- try:
- if leaders:
- parsedLeaders = json.loads( leaders )
- main.log.warn( json.dumps( parsedLeaders,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # check for all intent partitions
- # check for election
- topics = []
- for i in range( 14 ):
- topics.append( "intent-partition-" + str( i ) )
- # FIXME: this should only be after we start the app
- topics.append( "org.onosproject.election" )
- main.log.debug( topics )
- ONOStopics = [ j['topic'] for j in parsedLeaders ]
- for topic in topics:
- if topic not in ONOStopics:
- main.log.error( "Error: " + topic +
- " not in leaders" )
- else:
- main.log.error( "leaders() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing leaders" )
- main.log.error( repr( leaders ) )
- partitions = main.ONOScli1.partitions()
- try:
- if partitions :
- parsedPartitions = json.loads( partitions )
- main.log.warn( json.dumps( parsedPartitions,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # TODO check for a leader in all paritions
- # TODO check for consistency among nodes
- else:
- main.log.error( "partitions() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing partitions" )
- main.log.error( repr( partitions ) )
- pendingMap = main.ONOScli1.pendingMap()
- try:
- if pendingMap :
- parsedPending = json.loads( pendingMap )
- main.log.warn( json.dumps( parsedPending,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # TODO check something here?
- else:
- main.log.error( "pendingMap() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing pending map" )
- main.log.error( repr( pendingMap ) )
+ if not installedCheck:
+ time.sleep( 1 )
+ loopCount += 1
+ utilities.assert_equals( expect=True, actual=installedCheck,
+ onpass="Intents are all INSTALLED",
+ onfail="Intents are not all in " +
+ "INSTALLED state" )
+
+ main.step( "Check leadership of topics" )
+ leaders = main.ONOScli1.leaders()
+ topicCheck = main.TRUE
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ # TODO: Look at Devices as topics now that it uses this system
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ # FIXME: topics.append( "org.onosproject.election" )
+ # Print leaders output
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ topicCheck = main.FALSE
+ else:
+ main.log.error( "leaders() returned None" )
+ topicCheck = main.FALSE
+ except ( ValueError, TypeError ):
+ topicCheck = main.FALSE
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ # TODO: Check for a leader of these topics
+ # Check all nodes
+ if topicCheck:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
+ utilities.assert_equals( expect=main.TRUE, actual=topicCheck,
+ onpass="intent Partitions is in leaders",
+ onfail="Some topics were lost " )
+ # Print partitions
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ # Print Pending Map
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
if not installedCheck:
main.log.info( "Waiting 60 seconds to see if the state of " +
@@ -887,6 +980,7 @@
( str( count ), str( i ), str( s ) ) )
leaders = main.ONOScli1.leaders()
try:
+ missing = False
if leaders:
parsedLeaders = json.loads( leaders )
main.log.warn( json.dumps( parsedLeaders,
@@ -906,11 +1000,18 @@
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
" not in leaders" )
+ missing = True
else:
main.log.error( "leaders() returned None" )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing leaders" )
main.log.error( repr( leaders ) )
+ if missing:
+ for node in CLIs:
+ response = node.leaders( jsonFormat=False)
+ main.log.warn( str( node.name ) + " leaders output: \n" +
+ str( response ) )
+
partitions = main.ONOScli1.partitions()
try:
if partitions :
@@ -940,7 +1041,39 @@
except ( ValueError, TypeError ):
main.log.exception( "Error parsing pending map" )
main.log.error( repr( pendingMap ) )
- main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+ # Print flowrules
+ main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+ main.step( "Wait a minute then ping again" )
+ # the wait is above
+ PingResult = main.TRUE
+ for i in range( 8, 18 ):
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
+ PingResult = PingResult and ping
+ if ping == main.FALSE:
+ main.log.warn( "Ping failed between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ elif ping == main.TRUE:
+ main.log.info( "Ping test passed!" )
+ # Don't set PingResult or you'd override failures
+ if PingResult == main.FALSE:
+ main.log.error(
+ "Intents have not been installed correctly, pings failed." )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=PingResult,
+ onpass="Intents have been installed correctly and pings work",
+ onfail="Intents have not been installed correctly, pings failed." )
def CASE5( self, main ):
"""
@@ -956,7 +1089,6 @@
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
- main.log.report( "Setting up and gathering data for current state" )
main.case( "Setting up and gathering data for current state" )
# The general idea for this test case is to pull the state of
# ( intents,flows, topology,... ) from each ONOS node
@@ -1004,7 +1136,7 @@
for i in range( numControllers ):
if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" roles" )
main.log.warn(
"ONOS" + str( i + 1 ) + " mastership response: " +
@@ -1018,7 +1150,7 @@
main.step( "Check for consistency in roles from each controller" )
if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
- main.log.report(
+ main.log.info(
"Switch roles are consistent across all ONOS nodes" )
else:
consistentMastership = False
@@ -1066,7 +1198,7 @@
for i in range( numControllers ):
if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" intents" )
main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
repr( ONOSIntents[ i ] ) )
@@ -1079,11 +1211,11 @@
main.step( "Check for consistency in Intents from each controller" )
if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
- main.log.report( "Intents are consistent across all ONOS " +
+ main.log.info( "Intents are consistent across all ONOS " +
"nodes" )
else:
consistentIntents = False
- main.log.report( "Intents not consistent" )
+ main.log.error( "Intents not consistent" )
utilities.assert_equals(
expect=True,
actual=consistentIntents,
@@ -1101,22 +1233,27 @@
for n in range( numControllers ):
title += " " * 10 + "ONOS" + str( n + 1 )
main.log.warn( title )
- # get all intent keys in the cluster
keys = []
- for nodeStr in ONOSIntents:
- node = json.loads( nodeStr )
- for intent in node:
- keys.append( intent.get( 'id' ) )
- keys = set( keys )
- for key in keys:
- row = "%-13s" % key
+ try:
+ # Get the set of all intent keys
for nodeStr in ONOSIntents:
node = json.loads( nodeStr )
for intent in node:
- if intent.get( 'id', "Error" ) == key:
- row += "%-15s" % intent.get( 'state' )
- main.log.warn( row )
- # End table view
+ keys.append( intent.get( 'id' ) )
+ keys = set( keys )
+ # For each intent key, print the state on each node
+ for key in keys:
+ row = "%-13s" % key
+ for nodeStr in ONOSIntents:
+ node = json.loads( nodeStr )
+ for intent in node:
+ if intent.get( 'id', "Error" ) == key:
+ row += "%-15s" % intent.get( 'state' )
+ main.log.warn( row )
+ # End of intent state table
+ except ValueError as e:
+ main.log.exception( e )
+ main.log.debug( "nodeStr was: " + repr( nodeStr ) )
if intentsResults and not consistentIntents:
# print the json objects
@@ -1167,7 +1304,7 @@
for i in range( numControllers ):
num = str( i + 1 )
if not ONOSFlows[ i ] or "Error" in ONOSFlows[ i ]:
- main.log.report( "Error in getting ONOS" + num + " flows" )
+ main.log.error( "Error in getting ONOS" + num + " flows" )
main.log.warn( "ONOS" + num + " flows response: " +
repr( ONOSFlows[ i ] ) )
flowsResults = False
@@ -1191,7 +1328,7 @@
main.step( "Check for consistency in Flows from each controller" )
tmp = [ len( i ) == len( ONOSFlowsJson[ 0 ] ) for i in ONOSFlowsJson ]
if all( tmp ):
- main.log.report( "Flow count is consistent across all ONOS nodes" )
+ main.log.info( "Flow count is consistent across all ONOS nodes" )
else:
consistentFlows = False
utilities.assert_equals(
@@ -1354,14 +1491,14 @@
if hosts[ controller ] == hosts[ 0 ]:
continue
else: # hosts not consistent
- main.log.report( "hosts from ONOS" +
+ main.log.error( "hosts from ONOS" +
controllerStr +
" is inconsistent with ONOS1" )
main.log.warn( repr( hosts[ controller ] ) )
consistentHostsResult = main.FALSE
else:
- main.log.report( "Error in getting ONOS hosts from ONOS" +
+ main.log.error( "Error in getting ONOS hosts from ONOS" +
controllerStr )
consistentHostsResult = main.FALSE
main.log.warn( "ONOS" + controllerStr +
@@ -1378,7 +1515,7 @@
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- if not host.get( 'ips', [ ] ):
+ if not host.get( 'ipAddresses', [ ] ):
main.log.error( "DEBUG:Error with host ips on controller" +
controllerStr + ": " + str( host ) )
ipResult = main.FALSE
@@ -1397,12 +1534,12 @@
if clusters[ controller ] == clusters[ 0 ]:
continue
else: # clusters not consistent
- main.log.report( "clusters from ONOS" + controllerStr +
+ main.log.error( "clusters from ONOS" + controllerStr +
" is inconsistent with ONOS1" )
consistentClustersResult = main.FALSE
else:
- main.log.report( "Error in getting dataplane clusters " +
+ main.log.error( "Error in getting dataplane clusters " +
"from ONOS" + controllerStr )
consistentClustersResult = main.FALSE
main.log.warn( "ONOS" + controllerStr +
@@ -1554,7 +1691,7 @@
for i in range( numControllers ):
if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" roles" )
main.log.warn(
"ONOS" + str( i + 1 ) + " mastership response: " +
@@ -1568,7 +1705,7 @@
main.step( "Check for consistency in roles from each controller" )
if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
- main.log.report(
+ main.log.info(
"Switch roles are consistent across all ONOS nodes" )
else:
consistentMastership = False
@@ -1615,8 +1752,6 @@
else:
main.log.warn( "Mastership of switch %s changed" % switchDPID )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Mastership of Switches was not changed" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
@@ -1644,7 +1779,7 @@
for i in range( numControllers ):
if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
- main.log.report( "Error in getting ONOS" + str( i + 1 ) +
+ main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" intents" )
main.log.warn( "ONOS" + str( i + 1 ) + " intents response: " +
repr( ONOSIntents[ i ] ) )
@@ -1657,7 +1792,7 @@
main.step( "Check for consistency in Intents from each controller" )
if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
- main.log.report( "Intents are consistent across all ONOS " +
+ main.log.info( "Intents are consistent across all ONOS " +
"nodes" )
else:
consistentIntents = False
@@ -1724,22 +1859,41 @@
main.step( "Compare current intents with intents before the failure" )
# NOTE: this requires case 5 to pass for intentState to be set.
# maybe we should stop the test if that fails?
- sameIntents = main.TRUE
+ sameIntents = main.FALSE
if intentState and intentState == ONOSIntents[ 0 ]:
sameIntents = main.TRUE
- main.log.report( "Intents are consistent with before failure" )
+ main.log.info( "Intents are consistent with before failure" )
# TODO: possibly the states have changed? we may need to figure out
# what the acceptable states are
- else:
+ elif len( intentState ) == len( ONOSIntents[ 0 ] ):
+ sameIntents = main.TRUE
try:
- main.log.warn( "ONOS intents: " )
- main.log.warn( json.dumps( json.loads( ONOSIntents[ 0 ] ),
- sort_keys=True, indent=4,
- separators=( ',', ': ' ) ) )
+ before = json.loads( intentState )
+ after = json.loads( ONOSIntents[ 0 ] )
+ for intent in before:
+ if intent not in after:
+ sameIntents = main.FALSE
+ main.log.debug( "Intent is not currently in ONOS " +
+ "(at least in the same form):" )
+ main.log.debug( json.dumps( intent ) )
except ( ValueError, TypeError ):
main.log.exception( "Exception printing intents" )
- main.log.warn( repr( ONOSIntents[0] ) )
- sameIntents = main.FALSE
+ main.log.debug( repr( ONOSIntents[0] ) )
+ main.log.debug( repr( intentState ) )
+ if sameIntents == main.FALSE:
+ try:
+ main.log.debug( "ONOS intents before: " )
+ main.log.debug( json.dumps( json.loads( intentState ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ main.log.debug( "Current ONOS intents: " )
+ main.log.debug( json.dumps( json.loads( ONOSIntents[ 0 ] ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Exception printing intents" )
+ main.log.debug( repr( ONOSIntents[0] ) )
+ main.log.debug( repr( intentState ) )
utilities.assert_equals(
expect=main.TRUE,
actual=sameIntents,
@@ -1762,8 +1916,6 @@
if FlowTables == main.FALSE:
main.log.info( "Differences in flow table for switch: s" +
str( i + 1 ) )
- if FlowTables == main.TRUE:
- main.log.report( "No changes were found in the flow tables" )
utilities.assert_equals(
expect=main.TRUE,
actual=FlowTables,
@@ -1789,7 +1941,7 @@
main.log.info( "There are multiple mininet process running" )
elif LossInPings == main.FALSE:
main.log.info( "No Loss in the pings" )
- main.log.report( "No loss of dataplane connectivity" )
+ main.log.info( "No loss of dataplane connectivity" )
utilities.assert_equals(
expect=main.FALSE,
actual=LossInPings,
@@ -1812,19 +1964,15 @@
pass
elif leaderN == main.FALSE:
# error in response
- main.log.report( "Something is wrong with " +
+ main.log.error( "Something is wrong with " +
"electionTestLeader function, check the" +
" error logs" )
leaderResult = main.FALSE
elif leader != leaderN:
leaderResult = main.FALSE
- main.log.report( cli.name + " sees " + str( leaderN ) +
+ main.log.error( cli.name + " sees " + str( leaderN ) +
" as the leader of the election app. " +
"Leader should be " + str( leader ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was re-elected if applicable )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
@@ -1848,20 +1996,31 @@
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- description = "Compare ONOS Topology view to Mininet topology"
- main.case( description )
- main.log.report( description )
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplaination = "Compare topology objects between Mininet" +\
+ " and ONOS"
main.step( "Create TestONTopology object" )
- ctrls = []
- for node in nodes:
- temp = ( node, node.name, node.ip_address, 6633 )
- ctrls.append( temp )
- MNTopo = TestONTopology( main.Mininet1, ctrls )
+ try:
+ ctrls = []
+ for node in nodes:
+ temp = ( node, node.name, node.ip_address, 6633 )
+ ctrls.append( temp )
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
+ except Exception:
+ objResult = main.FALSE
+ else:
+ objResult = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=objResult,
+ onpass="Created TestONTopology object",
+ onfail="Exception while creating " +
+ "TestONTopology object" )
+ main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
portsResults = main.TRUE
linksResults = main.TRUE
hostsResults = main.TRUE
+ hostAttachmentResults = True
topoResult = main.FALSE
elapsed = 0
count = 0
@@ -1906,9 +2065,9 @@
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- if host is None or host.get( 'ips', [] ) == []:
+ if host is None or host.get( 'ipAddresses', [] ) == []:
main.log.error(
- "DEBUG:Error with host ips on controller" +
+ "DEBUG:Error with host ipAddresses on controller" +
controllerStr + ": " + str( host ) )
ipResult = main.FALSE
ports = []
@@ -1950,6 +2109,7 @@
elapsed = time.time() - startTime
cliTime = time.time() - cliStart
+ print "Elapsed time: " + str( elapsed )
print "CLI time: " + str( cliTime )
for controller in range( numControllers ):
@@ -2005,88 +2165,186 @@
" hosts exist in Mininet",
onfail="ONOS" + controllerStr +
" hosts don't match Mininet" )
+ # CHECKING HOST ATTACHMENT POINTS
+ hostAttachment = True
+ noHosts = False
+ # FIXME: topo-HA/obelisk specific mappings:
+ # key is mac and value is dpid
+ mappings = {}
+ for i in range( 1, 29 ): # hosts 1 through 28
+ # set up correct variables:
+ macId = "00:" * 5 + hex( i ).split( "0x" )[1].upper().zfill(2)
+ if i == 1:
+ deviceId = "1000".zfill(16)
+ elif i == 2:
+ deviceId = "2000".zfill(16)
+ elif i == 3:
+ deviceId = "3000".zfill(16)
+ elif i == 4:
+ deviceId = "3004".zfill(16)
+ elif i == 5:
+ deviceId = "5000".zfill(16)
+ elif i == 6:
+ deviceId = "6000".zfill(16)
+ elif i == 7:
+ deviceId = "6007".zfill(16)
+ elif i >= 8 and i <= 17:
+ dpid = '3' + str( i ).zfill( 3 )
+ deviceId = dpid.zfill(16)
+ elif i >= 18 and i <= 27:
+ dpid = '6' + str( i ).zfill( 3 )
+ deviceId = dpid.zfill(16)
+ elif i == 28:
+ deviceId = "2800".zfill(16)
+ mappings[ macId ] = deviceId
+ if hosts[ controller ] or "Error" not in hosts[ controller ]:
+ if hosts[ controller ] == []:
+ main.log.warn( "There are no hosts discovered" )
+ noHosts = True
+ else:
+ for host in hosts[ controller ]:
+ mac = None
+ location = None
+ device = None
+ port = None
+ try:
+ mac = host.get( 'mac' )
+ assert mac, "mac field could not be found for this host object"
+ location = host.get( 'location' )
+ assert location, "location field could not be found for this host object"
+
+ # Trim the protocol identifier off deviceId
+ device = str( location.get( 'elementId' ) ).split(':')[1]
+ assert device, "elementId field could not be found for this host location object"
+
+ port = location.get( 'port' )
+ assert port, "port field could not be found for this host location object"
+
+ # Now check if this matches where they should be
+ if mac and device and port:
+ if str( port ) != "1":
+ main.log.error( "The attachment port is incorrect for " +
+ "host " + str( mac ) +
+ ". Expected: 1 Actual: " + str( port) )
+ hostAttachment = False
+ if device != mappings[ str( mac ) ]:
+ main.log.error( "The attachment device is incorrect for " +
+ "host " + str( mac ) +
+ ". Expected: " + mappings[ str( mac ) ] +
+ " Actual: " + device )
+ hostAttachment = False
+ else:
+ hostAttachment = False
+ except AssertionError:
+ main.log.exception( "Json object not as expected" )
+ main.log.error( repr( host ) )
+ hostAttachment = False
+ else:
+ main.log.error( "No hosts json output or \"Error\"" +
+ " in output. hosts = " +
+ repr( hosts[ controller ] ) )
+ if noHosts is False:
+ hostAttachment = True
+
+ # END CHECKING HOST ATTACHMENT POINTS
devicesResults = devicesResults and currentDevicesResult
portsResults = portsResults and currentPortsResult
linksResults = linksResults and currentLinksResult
hostsResults = hostsResults and currentHostsResult
+ hostAttachmentResults = hostAttachmentResults and hostAttachment
- # Compare json objects for hosts and dataplane clusters
+ # Compare json objects for hosts and dataplane clusters
- # hosts
- main.step( "Hosts view is consistent across all ONOS nodes" )
- consistentHostsResult = main.TRUE
- for controller in range( len( hosts ) ):
- controllerStr = str( controller + 1 )
- if "Error" not in hosts[ controller ]:
- if hosts[ controller ] == hosts[ 0 ]:
- continue
- else: # hosts not consistent
- main.log.report( "hosts from ONOS" + controllerStr +
- " is inconsistent with ONOS1" )
- main.log.warn( repr( hosts[ controller ] ) )
- consistentHostsResult = main.FALSE
-
- else:
- main.log.report( "Error in getting ONOS hosts from ONOS" +
- controllerStr )
+ # hosts
+ main.step( "Hosts view is consistent across all ONOS nodes" )
+ consistentHostsResult = main.TRUE
+ for controller in range( len( hosts ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in hosts[ controller ]:
+ if hosts[ controller ] == hosts[ 0 ]:
+ continue
+ else: # hosts not consistent
+ main.log.error( "hosts from ONOS" + controllerStr +
+ " is inconsistent with ONOS1" )
+ main.log.warn( repr( hosts[ controller ] ) )
consistentHostsResult = main.FALSE
- main.log.warn( "ONOS" + controllerStr +
- " hosts response: " +
- repr( hosts[ controller ] ) )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=consistentHostsResult,
- onpass="Hosts view is consistent across all ONOS nodes",
- onfail="ONOS nodes have different views of hosts" )
- # Strongly connected clusters of devices
- main.step( "Clusters view is consistent across all ONOS nodes" )
- consistentClustersResult = main.TRUE
- for controller in range( len( clusters ) ):
- controllerStr = str( controller + 1 )
- if "Error" not in clusters[ controller ]:
- if clusters[ controller ] == clusters[ 0 ]:
- continue
- else: # clusters not consistent
- main.log.report( "clusters from ONOS" +
- controllerStr +
- " is inconsistent with ONOS1" )
- consistentClustersResult = main.FALSE
+ else:
+ main.log.error( "Error in getting ONOS hosts from ONOS" +
+ controllerStr )
+ consistentHostsResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " hosts response: " +
+ repr( hosts[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentHostsResult,
+ onpass="Hosts view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of hosts" )
- else:
- main.log.report( "Error in getting dataplane clusters " +
- "from ONOS" + controllerStr )
+ main.step( "Hosts information is correct" )
+ hostsResults = hostsResults and ipResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=hostsResults,
+ onpass="Host information is correct",
+ onfail="Host information is incorrect" )
+
+ main.step( "Host attachment points to the network" )
+ utilities.assert_equals(
+ expect=True,
+ actual=hostAttachmentResults,
+ onpass="Hosts are correctly attached to the network",
+ onfail="ONOS did not correctly attach hosts to the network" )
+
+ # Strongly connected clusters of devices
+ main.step( "Clusters view is consistent across all ONOS nodes" )
+ consistentClustersResult = main.TRUE
+ for controller in range( len( clusters ) ):
+ controllerStr = str( controller + 1 )
+ if "Error" not in clusters[ controller ]:
+ if clusters[ controller ] == clusters[ 0 ]:
+ continue
+ else: # clusters not consistent
+ main.log.error( "clusters from ONOS" +
+ controllerStr +
+ " is inconsistent with ONOS1" )
consistentClustersResult = main.FALSE
- main.log.warn( "ONOS" + controllerStr +
- " clusters response: " +
- repr( clusters[ controller ] ) )
- utilities.assert_equals(
- expect=main.TRUE,
- actual=consistentClustersResult,
- onpass="Clusters view is consistent across all ONOS nodes",
- onfail="ONOS nodes have different views of clusters" )
- # there should always only be one cluster
- main.step( "Topology view is correct and consistent across all " +
- "ONOS nodes" )
- try:
- numClusters = len( json.loads( clusters[ 0 ] ) )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing clusters[0]: " +
- repr( clusters[0] ) )
- clusterResults = main.FALSE
- if numClusters == 1:
- clusterResults = main.TRUE
- utilities.assert_equals(
- expect=1,
- actual=numClusters,
- onpass="ONOS shows 1 SCC",
- onfail="ONOS shows " + str( numClusters ) + " SCCs" )
- topoResult = ( devicesResults and portsResults and linksResults
- and hostsResults and consistentHostsResult
- and consistentClustersResult and clusterResults
- and ipResult )
+ else:
+ main.log.error( "Error in getting dataplane clusters " +
+ "from ONOS" + controllerStr )
+ consistentClustersResult = main.FALSE
+ main.log.warn( "ONOS" + controllerStr +
+ " clusters response: " +
+ repr( clusters[ controller ] ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=consistentClustersResult,
+ onpass="Clusters view is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of clusters" )
+
+ main.step( "There is only one SCC" )
+ # there should always only be one cluster
+ try:
+ numClusters = len( json.loads( clusters[ 0 ] ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing clusters[0]: " +
+ repr( clusters[0] ) )
+ clusterResults = main.FALSE
+ if numClusters == 1:
+ clusterResults = main.TRUE
+ utilities.assert_equals(
+ expect=1,
+ actual=numClusters,
+ onpass="ONOS shows 1 SCC",
+ onfail="ONOS shows " + str( numClusters ) + " SCCs" )
+
+ topoResult = ( devicesResults and portsResults and linksResults
+ and hostsResults and consistentHostsResult
+ and consistentClustersResult and clusterResults
+ and ipResult and hostAttachmentResults )
topoResult = topoResult and int( count <= 2 )
note = "note it takes about " + str( int( cliTime ) ) + \
@@ -2096,11 +2354,27 @@
"Very crass estimate for topology discovery/convergence( " +
str( note ) + " ): " + str( elapsed ) + " seconds, " +
str( count ) + " tries" )
- utilities.assert_equals( expect=main.TRUE, actual=topoResult,
- onpass="Topology Check Test successful",
- onfail="Topology Check Test NOT successful" )
- if topoResult == main.TRUE:
- main.log.report( "ONOS topology view matches Mininet topology" )
+
+ main.step( "Device information is correct" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=devicesResults,
+ onpass="Device information is correct",
+ onfail="Device information is incorrect" )
+
+ main.step( "Port information is correct" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=portsResults,
+ onpass="Port information is correct",
+ onfail="Port information is incorrect" )
+
+ main.step( "Links are correct" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=linksResults,
+ onpass="Link are correct",
+ onfail="Links are incorrect" )
# FIXME: move this to an ONOS state case
main.step( "Checking ONOS nodes" )
@@ -2158,7 +2432,6 @@
description = "Turn off a link to ensure that Link Discovery " +\
"is working properly"
- main.log.report( description )
main.case( description )
main.step( "Kill Link between s3 and s28" )
@@ -2187,7 +2460,6 @@
description = "Restore a link to ensure that Link Discovery is " + \
"working properly"
- main.log.report( description )
main.case( description )
main.step( "Bring link between s3 and s28 back up" )
@@ -2215,14 +2487,13 @@
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
description = "Killing a switch to ensure it is discovered correctly"
- main.log.report( description )
main.case( description )
switch = main.params[ 'kill' ][ 'switch' ]
switchDPID = main.params[ 'kill' ][ 'dpid' ]
# TODO: Make this switch parameterizable
main.step( "Kill " + switch )
- main.log.report( "Deleting " + switch )
+ main.log.info( "Deleting " + switch )
main.Mininet1.delSwitch( switch )
main.log.info( "Waiting " + str( switchSleep ) +
" seconds for switch down to be discovered" )
@@ -2261,11 +2532,9 @@
switchDPID = main.params[ 'kill' ][ 'dpid' ]
links = main.params[ 'kill' ][ 'links' ].split()
description = "Adding a switch to ensure it is discovered correctly"
- main.log.report( description )
main.case( description )
main.step( "Add back " + switch )
- main.log.report( "Adding back " + switch )
main.Mininet1.addSwitch( switch, dpid=switchDPID )
for peer in links:
main.Mininet1.addLink( switch, peer )
@@ -2314,9 +2583,7 @@
colors = { 'cyan': '\033[96m', 'purple': '\033[95m',
'blue': '\033[94m', 'green': '\033[92m',
'yellow': '\033[93m', 'red': '\033[91m', 'end': '\033[0m' }
- description = "Test Cleanup"
- main.log.report( description )
- main.case( description )
+ main.case( "Test Cleanup" )
main.step( "Killing tcpdumps" )
main.Mininet2.stopTcpdump()
@@ -2378,11 +2645,12 @@
os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
try:
- gossipIntentLog = open( main.logdir + "/Timers.csv", 'w')
+ timerLog = open( main.logdir + "/Timers.csv", 'w')
# Overwrite with empty line and close
- gossipIntentLog.write( "Gossip Intents\n" )
- gossipIntentLog.write( str( gossipTime ) )
- gossipIntentLog.close()
+ labels = "Gossip Intents"
+ data = str( gossipTime )
+ timerLog.write( labels + "\n" + data )
+ timerLog.close()
except NameError, e:
main.log.exception(e)
@@ -2396,34 +2664,45 @@
assert CLIs, "CLIs not defined"
assert nodes, "nodes not defined"
- leaderResult = main.TRUE
main.case("Start Leadership Election app")
main.step( "Install leadership election app" )
- main.ONOScli1.activateApp( "org.onosproject.election" )
+ appResult = main.ONOScli1.activateApp( "org.onosproject.election" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=appResult,
+ onpass="Election app installed",
+ onfail="Something went wrong with installing Leadership election" )
+
+ main.step( "Run for election on each node" )
+ leaderResult = main.TRUE
leaders = []
for cli in CLIs:
cli.electionTestRun()
for cli in CLIs:
leader = cli.electionTestLeader()
if leader is None or leader == main.FALSE:
- main.log.report( cli.name + ": Leader for the election app " +
+ main.log.error( cli.name + ": Leader for the election app " +
"should be an ONOS node, instead got '" +
str( leader ) + "'" )
leaderResult = main.FALSE
leaders.append( leader )
- if len( set( leaders ) ) != 1:
- leaderResult = main.FALSE
- main.log.error( "Results of electionTestLeader is order of CLIs:" +
- str( leaders ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a leader " +
- "was elected )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
- onpass="Leadership election passed",
- onfail="Something went wrong with Leadership election" )
+ onpass="Successfully ran for leadership",
+ onfail="Failed to run for leadership" )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
def CASE15( self, main ):
"""
@@ -2438,14 +2717,30 @@
leaderResult = main.TRUE
description = "Check that Leadership Election is still functional"
- main.log.report( description )
main.case( description )
+
+ main.step( "Check that each node shows the same leader" )
+ sameLeader = main.TRUE
+ leaders = []
+ for cli in CLIs:
+ leader = cli.electionTestLeader()
+ leaders.append( leader )
+ if len( set( leaders ) ) != 1:
+ sameLeader = main.FALSE
+ main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ str( leaders ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=sameLeader,
+ onpass="Leadership is consistent for the election topic",
+ onfail="Nodes have different leaders" )
+
main.step( "Find current leader and withdraw" )
leader = main.ONOScli1.electionTestLeader()
# do some sanity checking on leader before using it
withdrawResult = main.FALSE
if leader is None or leader == main.FALSE:
- main.log.report(
+ main.log.error(
"Leader for the election app should be an ONOS node," +
"instead got '" + str( leader ) + "'" )
leaderResult = main.FALSE
@@ -2461,8 +2756,8 @@
utilities.assert_equals(
expect=main.TRUE,
actual=withdrawResult,
- onpass="App was withdrawn from election",
- onfail="App was not withdrawn from election" )
+ onpass="Node was withdrawn from election",
+ onfail="Node was not withdrawn from election" )
main.step( "Make sure new leader is elected" )
# FIXME: use threads
@@ -2471,14 +2766,14 @@
leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == leader:
- main.log.report( cli.name + " still sees " + str( leader ) +
+ main.log.error( cli.name + " still sees " + str( leader ) +
" as leader after they withdrew" )
leaderResult = main.FALSE
elif leaderN == main.FALSE:
# error in response
# TODO: add check for "Command not found:" in the driver, this
# means the app isn't loaded
- main.log.report( "Something is wrong with " +
+ main.log.error( "Something is wrong with " +
"electionTestLeader function, " +
"check the error logs" )
leaderResult = main.FALSE
@@ -2495,17 +2790,12 @@
"' as the leader" )
consistentLeader = main.TRUE
else:
- main.log.report(
+ main.log.error(
"Inconsistent responses for leader of Election-app:" )
for n in range( len( leaderList ) ):
- main.log.report( "ONOS" + str( n + 1 ) + " response: " +
+ main.log.error( "ONOS" + str( n + 1 ) + " response: " +
str( leaderList[ n ] ) )
leaderResult = leaderResult and consistentLeader
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was elected when the old leader " +
- "resigned )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
@@ -2524,6 +2814,7 @@
onpass="App re-ran for election",
onfail="App failed to run for election" )
+ main.step( "Leader did not change when old leader re-ran" )
afterRun = main.ONOScli1.electionTestLeader()
# verify leader didn't just change
if afterRun == leaderList[ 0 ]:
@@ -2538,18 +2829,11 @@
onfail="Something went wrong with Leadership election after " +
"the old leader re-ran for election" )
- case15Result = withdrawResult and leaderResult and runResult and\
- afterResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case15Result,
- onpass="Leadership election is still functional",
- onfail="Leadership Election is no longer functional" )
-
def CASE16( self, main ):
"""
Install Distributed Primitives app
"""
+ import time
assert numControllers, "numControllers not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
@@ -2579,11 +2863,13 @@
actual=appResults,
onpass="Primitives app activated",
onfail="Primitives app not activated" )
+ time.sleep( 5 ) # To allow all nodes to activate
def CASE17( self, main ):
"""
Check for basic functionality with distributed primitives
"""
+ import json
# Make sure variables are defined/set
assert numControllers, "numControllers not defined"
assert main, "main not defined"
@@ -2622,11 +2908,13 @@
main.step( "Increment and get a default counter on each node" )
pCounters = []
threads = []
+ addedPValues = []
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].counterTestIncrement,
name="counterIncrement-" + str( i ),
args=[ pCounterName ] )
pCounterValue += 1
+ addedPValues.append( pCounterValue )
threads.append( t )
t.start()
@@ -2635,8 +2923,12 @@
pCounters.append( t.result )
# Check that counter incremented numController times
pCounterResults = True
- for i in range( numControllers ):
- pCounterResults and ( i + 1 ) in pCounters
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
utilities.assert_equals( expect=True,
actual=pCounterResults,
onpass="Default counter incremented",
@@ -2645,6 +2937,7 @@
main.step( "Increment and get an in memory counter on each node" )
iCounters = []
+ addedIValues = []
threads = []
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].counterTestIncrement,
@@ -2652,6 +2945,7 @@
args=[ iCounterName ],
kwargs={ "inMemory": True } )
iCounterValue += 1
+ addedIValues.append( iCounterValue )
threads.append( t )
t.start()
@@ -2660,8 +2954,12 @@
iCounters.append( t.result )
# Check that counter incremented numController times
iCounterResults = True
- for i in range( numControllers ):
- iCounterResults and ( i + 1 ) in iCounters
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in the in-memory "
+ "counter incremented results" )
utilities.assert_equals( expect=True,
actual=iCounterResults,
onpass="In memory counter incremented",
@@ -2696,28 +2994,41 @@
main.step( "Counters we added have the correct values" )
correctResults = main.TRUE
for i in range( numControllers ):
- current = onosCounters[i]
+ current = json.loads( onosCounters[i] )
+ pValue = None
+ iValue = None
try:
- pValue = current.get( pCounterName )
- iValue = current.get( iCounterName )
- if pValue == pCounterValue:
- main.log.info( "Partitioned counter value is correct" )
- else:
- main.log.error( "Partitioned counter value is incorrect," +
- " expected value: " + str( pCounterValue )
- + " current value: " + str( pValue ) )
- correctResults = main.FALSE
- if iValue == iCounterValue:
- main.log.info( "In memory counter value is correct" )
- else:
- main.log.error( "In memory counter value is incorrect, " +
- "expected value: " + str( iCounterValue ) +
- " current value: " + str( iValue ) )
- correctResults = main.FALSE
+ for database in current:
+ partitioned = database.get( 'partitionedDatabaseCounters' )
+ if partitioned:
+ for value in partitioned:
+ if value.get( 'name' ) == pCounterName:
+ pValue = value.get( 'value' )
+ break
+ inMemory = database.get( 'inMemoryDatabaseCounters' )
+ if inMemory:
+ for value in inMemory:
+ if value.get( 'name' ) == iCounterName:
+ iValue = value.get( 'value' )
+ break
except AttributeError, e:
main.log.error( "ONOS" + str( i + 1 ) + " counters result " +
"is not as expected" )
correctResults = main.FALSE
+ if pValue == pCounterValue:
+ main.log.info( "Partitioned counter value is correct" )
+ else:
+ main.log.error( "Partitioned counter value is incorrect," +
+ " expected value: " + str( pCounterValue )
+ + " current value: " + str( pValue ) )
+ correctResults = main.FALSE
+ if iValue == iCounterValue:
+ main.log.info( "In memory counter value is correct" )
+ else:
+ main.log.error( "In memory counter value is incorrect, " +
+ "expected value: " + str( iCounterValue ) +
+ " current value: " + str( iValue ) )
+ correctResults = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=correctResults,
onpass="Added counters are correct",
diff --git a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.params b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.params
index d027c36..108ab88 100644
--- a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.params
+++ b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.params
@@ -16,13 +16,14 @@
#CASE15: Check that Leadership Election is still functional
#1,2,8,3,4,5,14,[6],8,3,7,4,15,9,8,4,10,8,4,11,8,4,12,8,4,13
#extra hosts test 1,2,8,11,8,12,8
- <testcases>1,2,8,3,4,5,14,16,17,[6],8,3,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ <testcases>1,2,8,3,4,5,14,15,16,17,[6],8,3,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
<ENV>
<cellName>HA</cellName>
</ENV>
<Git>False</Git>
<branch> master </branch>
<num_controllers> 1 </num_controllers>
+ <tcpdump> False </tcpdump>
<CTRL>
<ip1>10.128.30.11</ip1>
diff --git a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
index 0f68a02..f77ca3d 100644
--- a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
+++ b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
@@ -4,11 +4,12 @@
List of test cases:
CASE1: Compile ONOS and push it to the test machines
-CASE2: Assign mastership to controllers
+CASE2: Assign devices to controllers
+CASE21: Assign mastership to controllers
CASE3: Assign intents
CASE4: Ping across added host intents
CASE5: Reading state of ONOS
-CASE6: The Failure case. Since this is the Sanity test, we do nothing.
+CASE6: The Failure case.
CASE7: Check state after control plane failure
CASE8: Compare topo
CASE9: Link s3-s28 down
@@ -46,9 +47,12 @@
start cli sessions
start tcpdump
"""
- main.log.report( "ONOS Single node cluster restart " +
+ main.log.info( "ONOS Single node cluster restart " +
"HA test - initialization" )
main.case( "Setting up test environment" )
+ main.caseExplaination = "Setup the test environment including " +\
+ "installing ONOS, starting Mininet and ONOS" +\
+ "cli sessions."
# TODO: save all the timers and output them for plotting
# load some variables from the params file
@@ -92,15 +96,15 @@
verifyResult = main.ONOSbench.verifyCell()
# FIXME:this is short term fix
- main.log.report( "Removing raft logs" )
+ main.log.info( "Removing raft logs" )
main.ONOSbench.onosRemoveRaftLogs()
- main.log.report( "Uninstalling ONOS" )
+ main.log.info( "Uninstalling ONOS" )
for node in nodes:
main.ONOSbench.onosUninstall( node.ip_address )
# Make sure ONOS is DEAD
- main.log.report( "Killing any ONOS processes" )
+ main.log.info( "Killing any ONOS processes" )
killResults = main.TRUE
for node in nodes:
killed = main.ONOSbench.onosKill( node.ip_address )
@@ -115,36 +119,39 @@
onpass="Mininet Started",
onfail="Error starting Mininet" )
- main.step( "Compiling the latest version of ONOS" )
+ main.step( "Git checkout and pull " + gitBranch )
if PULLCODE:
- main.step( "Git checkout and pull " + gitBranch )
main.ONOSbench.gitCheckout( gitBranch )
gitPullResult = main.ONOSbench.gitPull()
# values of 1 or 3 are good
utilities.assert_lesser( expect=0, actual=gitPullResult,
onpass="Git pull successful",
onfail="Git pull failed" )
+ main.ONOSbench.getVersion( report=True )
- main.step( "Using mvn clean and install" )
+ main.step( "Using mvn clean install" )
+ cleanInstallResult = main.TRUE
+ if PULLCODE and gitPullResult == main.TRUE:
cleanInstallResult = main.ONOSbench.cleanInstall()
- utilities.assert_equals( expect=main.TRUE,
- actual=cleanInstallResult,
- onpass="MCI successful",
- onfail="MCI failed" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
- main.ONOSbench.getVersion( report=True )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cleanInstallResult,
+ onpass="MCI successful",
+ onfail="MCI failed" )
# GRAPHS
# NOTE: important params here:
# job = name of Jenkins job
# Plot Name = Plot-HA, only can be used if multiple plots
# index = The number of the graph under plot name
job = "HASingleInstanceRestart"
+ plotName = "Plot-HA"
graphs = '<ac:structured-macro ac:name="html">\n'
graphs += '<ac:plain-text-body><![CDATA[\n'
graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
- '/plot/getPlot?index=0&width=500&height=300"' +\
+ '/plot/' + plotName + '/getPlot?index=0' +\
+ '&width=500&height=300"' +\
'noborder="0" width="500" height="300" scrolling="yes" ' +\
'seamless="seamless"></iframe>\n'
graphs += ']]></ac:plain-text-body>\n'
@@ -171,8 +178,6 @@
onos1Isup = main.ONOSbench.isup( ONOS1Ip )
if onos1Isup:
break
- if not onos1Isup:
- main.log.report( "ONOS1 didn't start!" )
utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
onpass="ONOS startup successful",
onfail="ONOS startup failed" )
@@ -183,26 +188,16 @@
onpass="ONOS cli startup successful",
onfail="ONOS cli startup failed" )
- main.step( "Start Packet Capture MN" )
- main.Mininet2.startTcpdump(
- str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
- + "-MN.pcap",
- intf=main.params[ 'MNtcpdump' ][ 'intf' ],
- port=main.params[ 'MNtcpdump' ][ 'port' ] )
+ if main.params[ 'tcpdump' ].lower() == "true":
+ main.step( "Start Packet Capture MN" )
+ main.Mininet2.startTcpdump(
+ str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
+ + "-MN.pcap",
+ intf=main.params[ 'MNtcpdump' ][ 'intf' ],
+ port=main.params[ 'MNtcpdump' ][ 'port' ] )
main.step( "App Ids check" )
- appCheck = main.TRUE
- threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].appToIDCheck,
- name="appToIDCheck-" + str( i ),
- args=[] )
- threads.append( t )
- t.start()
-
- for t in threads:
- t.join()
- appCheck = appCheck and t.result
+ appCheck = main.ONOScli1.appToIDCheck()
if appCheck != main.TRUE:
main.log.warn( CLIs[0].apps() )
main.log.warn( CLIs[0].appIDs() )
@@ -210,19 +205,17 @@
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
- case1Result = ( cleanInstallResult and packageResult and
- cellResult and verifyResult and onosInstallResult
- and onos1Isup and cliResults )
-
- if case1Result == main.FALSE:
+ if cliResults == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
main.cleanup()
main.exit()
def CASE2( self, main ):
"""
- Assign mastership to controllers
+ Assign devices to controllers
"""
import re
+ import time
assert numControllers, "numControllers not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
@@ -234,8 +227,10 @@
assert ONOS6Port, "ONOS6Port not defined"
assert ONOS7Port, "ONOS7Port not defined"
- main.log.report( "Assigning switches to controllers" )
- main.case( "Assigning Controllers" )
+ main.case( "Assigning devices to controllers" )
+ main.caseExplaination = "Assign switches to ONOS using 'ovs-vsctl' " +\
+ "and check that an ONOS node becomes the " +\
+ "master of the device."
main.step( "Assign switches to controllers" )
for i in range( 1, 29 ):
@@ -255,13 +250,37 @@
else:
mastershipCheck = main.FALSE
if mastershipCheck == main.TRUE:
- main.log.report( "Switch mastership assigned correctly" )
+ main.log.info( "Switch mastership assigned correctly" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
onpass="Switch mastership assigned correctly",
onfail="Switches not assigned correctly to controllers" )
+ def CASE21( self, main ):
+ """
+ Assign mastership to controllers
+ """
+ import re
+ import time
+ assert numControllers, "numControllers not defined"
+ assert main, "main not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert CLIs, "CLIs not defined"
+ assert nodes, "nodes not defined"
+ assert ONOS1Port, "ONOS1Port not defined"
+ assert ONOS2Port, "ONOS2Port not defined"
+ assert ONOS3Port, "ONOS3Port not defined"
+ assert ONOS4Port, "ONOS4Port not defined"
+ assert ONOS5Port, "ONOS5Port not defined"
+ assert ONOS6Port, "ONOS6Port not defined"
+ assert ONOS7Port, "ONOS7Port not defined"
+
+ main.case( "Assigning Controller roles for switches" )
+ main.caseExplaination = "Check that ONOS is connected to each " +\
+ "device. Then manually assign" +\
+ " mastership to specific ONOS nodes using" +\
+ " 'device-role'"
main.step( "Assign mastership of switches to specific controllers" )
roleCall = main.TRUE
roleCheck = main.TRUE
@@ -325,11 +344,6 @@
onpass="Switches were successfully reassigned to designated " +
"controller",
onfail="Switches were not successfully reassigned" )
- mastershipCheck = mastershipCheck and roleCall and roleCheck
- utilities.assert_equals( expect=main.TRUE, actual=mastershipCheck,
- onpass="Switch mastership correctly assigned",
- onfail="Error in (re)assigning switch" +
- " mastership" )
def CASE3( self, main ):
"""
@@ -340,13 +354,14 @@
assert numControllers, "numControllers not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- # FIXME: we must reinstall intents until we have a persistant
- # datastore!
- main.log.report( "Adding host intents" )
+ # NOTE: we must reinstall intents until we have a persistant intent
+ # datastore!
main.case( "Adding host Intents" )
-
- main.step( "Discovering Hosts( Via pingall for now )" )
- # FIXME: Once we have a host discovery mechanism, use that instead
+ main.caseExplaination = "Discover hosts by using pingall then " +\
+ "assign predetermined host-to-host intents." +\
+ " After installation, check that the intent" +\
+ " is distributed to all nodes and the state" +\
+ " is INSTALLED"
# install onos-app-fwd
main.step( "Install reactive forwarding app" )
@@ -355,6 +370,7 @@
onpass="Install fwd successful",
onfail="Install fwd failed" )
+ main.step( "Check app ids" )
appCheck = main.ONOScli1.appToIDCheck()
if appCheck != main.TRUE:
main.log.warn( CLIs[0].apps() )
@@ -363,6 +379,8 @@
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
+ main.step( "Discovering Hosts( Via pingall for now )" )
+ # FIXME: Once we have a host discovery mechanism, use that instead
# REACTIVE FWD test
pingResult = main.FALSE
for i in range(2): # Retry if pingall fails first time
@@ -385,6 +403,8 @@
utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
onpass="Uninstall fwd successful",
onfail="Uninstall fwd failed" )
+
+ main.step( "Check app ids" )
appCheck2 = main.ONOScli1.appToIDCheck()
if appCheck2 != main.TRUE:
main.log.warn( CLIs[0].apps() )
@@ -393,7 +413,7 @@
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
- main.step( "Add host intents" )
+ main.step( "Add host intents via cli" )
intentIds = []
# TODO: move the host numbers to params
# Maybe look at all the paths we ping?
@@ -435,7 +455,10 @@
except ( ValueError, TypeError ):
main.log.warn( repr( hosts ) )
hostResult = main.FALSE
- # FIXME: DEBUG
+ utilities.assert_equals( expect=main.TRUE, actual=hostResult,
+ onpass="Found a host id for each host",
+ onfail="Error looking up host ids" )
+
intentStart = time.time()
onosIds = main.ONOScli1.getAllIntentsId()
main.log.info( "Submitted intents: " + str( intentIds ) )
@@ -530,13 +553,11 @@
main.log.exception( "Error parsing pending map" )
main.log.error( repr( pendingMap ) )
- intentAddResult = bool( pingResult and hostResult and intentAddResult
- and not missingIntents and installedCheck )
- utilities.assert_equals(
- expect=True,
- actual=intentAddResult,
- onpass="Pushed host intents to ONOS",
- onfail="Error in pushing host intents to ONOS" )
+ intentAddResult = bool( intentAddResult and not missingIntents and
+ installedCheck )
+ if not intentAddResult:
+ main.log.error( "Error in pushing host intents to ONOS" )
+
main.step( "Intent Anti-Entropy dispersion" )
for i in range(100):
correct = True
@@ -667,9 +688,11 @@
assert numControllers, "numControllers not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- description = " Ping across added host intents"
- main.log.report( description )
- main.case( description )
+ main.case( "Verify connectivity by sendind traffic across Intents" )
+ main.caseExplaination = "Ping across added host intents to check " +\
+ "functionality and check the state of " +\
+ "the intent"
+ main.step( "Ping across added host intents" )
PingResult = main.TRUE
for i in range( 8, 18 ):
ping = main.Mininet1.pingHost( src="h" + str( i ),
@@ -682,7 +705,7 @@
main.log.info( "Ping test passed!" )
# Don't set PingResult or you'd override failures
if PingResult == main.FALSE:
- main.log.report(
+ main.log.error(
"Intents have not been installed correctly, pings failed." )
# TODO: pretty print
main.log.warn( "ONOS1 intents: " )
@@ -694,92 +717,108 @@
separators=( ',', ': ' ) ) )
except ( ValueError, TypeError ):
main.log.warn( repr( tmpIntents ) )
- if PingResult == main.TRUE:
- main.log.report(
- "Intents have been installed correctly and verified by pings" )
utilities.assert_equals(
expect=main.TRUE,
actual=PingResult,
onpass="Intents have been installed correctly and pings work",
onfail="Intents have not been installed correctly, pings failed." )
+ main.step( "Check Intent state" )
installedCheck = True
- if PingResult is not main.TRUE:
- # Print the intent states
- intents = main.ONOScli1.intents()
- intentStates = []
- main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
- count = 0
- # Iter through intents of a node
- try:
- for intent in json.loads( intents ):
- state = intent.get( 'state', None )
- if "INSTALLED" not in state:
- installedCheck = False
- intentId = intent.get( 'id', None )
- intentStates.append( ( intentId, state ) )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing intents." )
- intentStates.sort()
- for i, s in intentStates:
- count += 1
- main.log.info( "%-6s%-15s%-15s" %
- ( str( count ), str( i ), str( s ) ) )
- leaders = main.ONOScli1.leaders()
- try:
- if leaders:
- parsedLeaders = json.loads( leaders )
- main.log.warn( json.dumps( parsedLeaders,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # check for all intent partitions
- # check for election
- topics = []
- for i in range( 14 ):
- topics.append( "intent-partition-" + str( i ) )
- # FIXME: this should only be after we start the app
- topics.append( "org.onosproject.election" )
- main.log.debug( topics )
- ONOStopics = [ j['topic'] for j in parsedLeaders ]
- for topic in topics:
- if topic not in ONOStopics:
- main.log.error( "Error: " + topic +
- " not in leaders" )
- else:
- main.log.error( "leaders() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing leaders" )
- main.log.error( repr( leaders ) )
- partitions = main.ONOScli1.partitions()
- try:
- if partitions :
- parsedPartitions = json.loads( partitions )
- main.log.warn( json.dumps( parsedPartitions,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # TODO check for a leader in all paritions
- # TODO check for consistency among nodes
- else:
- main.log.error( "partitions() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing partitions" )
- main.log.error( repr( partitions ) )
- pendingMap = main.ONOScli1.pendingMap()
- try:
- if pendingMap :
- parsedPending = json.loads( pendingMap )
- main.log.warn( json.dumps( parsedPending,
- sort_keys=True,
- indent=4,
- separators=( ',', ': ' ) ) )
- # TODO check something here?
- else:
- main.log.error( "pendingMap() returned None" )
- except ( ValueError, TypeError ):
- main.log.exception( "Error parsing pending map" )
- main.log.error( repr( pendingMap ) )
+ # Print the intent states
+ intents = main.ONOScli1.intents()
+ intentStates = []
+ main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
+ # Iter through intents of a node
+ try:
+ for intent in json.loads( intents ):
+ state = intent.get( 'state', None )
+ if "INSTALLED" not in state:
+ installedCheck = False
+ intentId = intent.get( 'id', None )
+ intentStates.append( ( intentId, state ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing intents." )
+ # Print states
+ intentStates.sort()
+ for i, s in intentStates:
+ count += 1
+ main.log.info( "%-6s%-15s%-15s" %
+ ( str( count ), str( i ), str( s ) ) )
+ utilities.assert_equals( expect=True, actual=installedCheck,
+ onpass="Intents are all INSTALLED",
+ onfail="Intents are not all in " +
+ "INSTALLED state" )
+
+ main.step( "Check leadership of topics" )
+ leaders = main.ONOScli1.leaders()
+ topicCheck = main.TRUE
+ try:
+ if leaders:
+ parsedLeaders = json.loads( leaders )
+ main.log.warn( json.dumps( parsedLeaders,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # check for all intent partitions
+ # check for election
+ # TODO: Look at Devices as topics now that it uses this system
+ topics = []
+ for i in range( 14 ):
+ topics.append( "intent-partition-" + str( i ) )
+ # FIXME: this should only be after we start the app
+ # FIXME: topics.append( "org.onosproject.election" )
+ # Print leaders output
+ main.log.debug( topics )
+ ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ for topic in topics:
+ if topic not in ONOStopics:
+ main.log.error( "Error: " + topic +
+ " not in leaders" )
+ topicCheck = main.FALSE
+ else:
+ main.log.error( "leaders() returned None" )
+ topicCheck = main.FALSE
+ except ( ValueError, TypeError ):
+ topicCheck = main.FALSE
+ main.log.exception( "Error parsing leaders" )
+ main.log.error( repr( leaders ) )
+ # TODO: Check for a leader of these topics
+ utilities.assert_equals( expect=main.TRUE, actual=topicCheck,
+ onpass="intent Partitions is in leaders",
+ onfail="Some topics were lost " )
+ # Print partitions
+ partitions = main.ONOScli1.partitions()
+ try:
+ if partitions :
+ parsedPartitions = json.loads( partitions )
+ main.log.warn( json.dumps( parsedPartitions,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check for a leader in all paritions
+ # TODO check for consistency among nodes
+ else:
+ main.log.error( "partitions() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing partitions" )
+ main.log.error( repr( partitions ) )
+ # Print Pending Map
+ pendingMap = main.ONOScli1.pendingMap()
+ try:
+ if pendingMap :
+ parsedPending = json.loads( pendingMap )
+ main.log.warn( json.dumps( parsedPending,
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ # TODO check something here?
+ else:
+ main.log.error( "pendingMap() returned None" )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Error parsing pending map" )
+ main.log.error( repr( pendingMap ) )
if not installedCheck:
main.log.info( "Waiting 60 seconds to see if the state of " +
@@ -860,7 +899,39 @@
except ( ValueError, TypeError ):
main.log.exception( "Error parsing pending map" )
main.log.error( repr( pendingMap ) )
- main.log.debug( main.ONOScli1.flows( jsonFormat=False ) )
+ # Print flowrules
+ main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+ main.step( "Wait a minute then ping again" )
+ # the wait is above
+ PingResult = main.TRUE
+ for i in range( 8, 18 ):
+ ping = main.Mininet1.pingHost( src="h" + str( i ),
+ target="h" + str( i + 10 ) )
+ PingResult = PingResult and ping
+ if ping == main.FALSE:
+ main.log.warn( "Ping failed between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ elif ping == main.TRUE:
+ main.log.info( "Ping test passed!" )
+ # Don't set PingResult or you'd override failures
+ if PingResult == main.FALSE:
+ main.log.error(
+ "Intents have not been installed correctly, pings failed." )
+ # TODO: pretty print
+ main.log.warn( "ONOS1 intents: " )
+ try:
+ tmpIntents = main.ONOScli1.intents()
+ main.log.warn( json.dumps( json.loads( tmpIntents ),
+ sort_keys=True,
+ indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.warn( repr( tmpIntents ) )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=PingResult,
+ onpass="Intents have been installed correctly and pings work",
+ onfail="Intents have not been installed correctly, pings failed." )
def CASE5( self, main ):
"""
@@ -873,7 +944,6 @@
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
- main.log.report( "Setting up and gathering data for current state" )
main.case( "Setting up and gathering data for current state" )
# The general idea for this test case is to pull the state of
# ( intents,flows, topology,... ) from each ONOS node
@@ -895,7 +965,7 @@
ONOS1Mastership = main.ONOScli1.roles()
# TODO: Make this a meaningful check
if "Error" in ONOS1Mastership or not ONOS1Mastership:
- main.log.report( "Error in getting ONOS roles" )
+ main.log.error( "Error in getting ONOS roles" )
main.log.warn(
"ONOS1 mastership response: " +
repr( ONOS1Mastership ) )
@@ -910,7 +980,7 @@
ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
intentCheck = main.FALSE
if "Error" in ONOS1Intents or not ONOS1Intents:
- main.log.report( "Error in getting ONOS intents" )
+ main.log.error( "Error in getting ONOS intents" )
main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
else:
intentCheck = main.TRUE
@@ -921,7 +991,7 @@
flowCheck = main.FALSE
ONOS1Flows = main.ONOScli1.flows( jsonFormat=True )
if "Error" in ONOS1Flows or not ONOS1Flows:
- main.log.report( "Error in getting ONOS flows" )
+ main.log.error( "Error in getting ONOS flows" )
main.log.warn( "ONOS1 flows repsponse: " + ONOS1Flows )
else:
# TODO: Do a better check, maybe compare flows on switches?
@@ -961,7 +1031,7 @@
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- if host is None or host.get( 'ips', [] ) == []:
+ if host is None or host.get( 'ipAddresses', [] ) == []:
main.log.error(
"DEBUG:Error with host ips on controller" +
controllerStr + ": " + str( host ) )
@@ -1073,8 +1143,9 @@
main.log.error( "iCounterValue not defined, setting to 0" )
iCounterValue = 0
- main.log.report( "Restart ONOS node" )
- main.log.case( "Restart ONOS node" )
+ main.case( "Restart ONOS node" )
+ main.caseExplaination = "Killing ONOS process and restart cli " +\
+ "sessions once onos is up."
main.step( "Killing ONOS processes" )
killResult = main.ONOSbench.onosKill( ONOS1Ip )
start = time.time()
@@ -1104,7 +1175,12 @@
if elapsed:
main.log.info( "ESTIMATE: ONOS took %s seconds to restart" %
str( elapsed ) )
+ main.restartTime = elapsed
+ else:
+ main.restartTime = -1
time.sleep( 5 )
+ # rerun on election apps
+ main.ONOScli1.electionTestRun()
def CASE7( self, main ):
"""
@@ -1115,7 +1191,6 @@
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
main.case( "Running ONOS Constant State Tests" )
-
main.step( "Check that each switch has a master" )
# Assert that each device has a master
rolesNotNull = main.ONOScli1.rolesNotNull()
@@ -1129,14 +1204,12 @@
ONOS1Mastership = main.ONOScli1.roles()
# FIXME: Refactor this whole case for single instance
if "Error" in ONOS1Mastership or not ONOS1Mastership:
- main.log.report( "Error in getting ONOS mastership" )
+ main.log.error( "Error in getting ONOS mastership" )
main.log.warn( "ONOS1 mastership response: " +
repr( ONOS1Mastership ) )
consistentMastership = main.FALSE
else:
consistentMastership = main.TRUE
- main.log.report(
- "Switch roles are consistent across all ONOS nodes" )
utilities.assert_equals(
expect=main.TRUE,
actual=consistentMastership,
@@ -1162,8 +1235,6 @@
else:
main.log.warn( "Mastership of switch %s changed" % switchDPID )
mastershipCheck = main.FALSE
- if mastershipCheck == main.TRUE:
- main.log.report( "Mastership of Switches was not changed" )
utilities.assert_equals(
expect=main.TRUE,
actual=mastershipCheck,
@@ -1175,11 +1246,11 @@
ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
intentCheck = main.FALSE
if "Error" in ONOS1Intents or not ONOS1Intents:
- main.log.report( "Error in getting ONOS intents" )
+ main.log.error( "Error in getting ONOS intents" )
main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
else:
intentCheck = main.TRUE
- main.log.report( "Intents are consistent across all ONOS nodes" )
+ main.log.error( "Intents are consistent across all ONOS nodes" )
utilities.assert_equals(
expect=main.TRUE,
actual=intentCheck,
@@ -1204,21 +1275,41 @@
main.step( "Compare current intents with intents before the failure" )
# NOTE: this requires case 5 to pass for intentState to be set.
# maybe we should stop the test if that fails?
- sameIntents = main.TRUE
- if intentState and intentState == ONOS1Intents:
+ sameIntents = main.FALSE
+ if intentState and intentState == ONOSIntents[ 0 ]:
sameIntents = main.TRUE
- main.log.report( "Intents are consistent with before failure" )
+ main.log.info( "Intents are consistent with before failure" )
# TODO: possibly the states have changed? we may need to figure out
- # what the aceptable states are
- else:
+ # what the acceptable states are
+ elif len( intentState ) == len( ONOSIntents[ 0 ] ):
+ sameIntents = main.TRUE
try:
- main.log.warn( "ONOS1 intents: " )
- print json.dumps( json.loads( ONOS1Intents ),
- sort_keys=True, indent=4,
- separators=( ',', ': ' ) )
- except Exception:
- pass
- sameIntents = main.FALSE
+ before = json.loads( intentState )
+ after = json.loads( ONOSIntents[ 0 ] )
+ for intent in before:
+ if intent not in after:
+ sameIntents = main.FALSE
+ main.log.debug( "Intent is not currently in ONOS " +
+ "(at least in the same form):" )
+ main.log.debug( json.dumps( intent ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Exception printing intents" )
+ main.log.debug( repr( ONOSIntents[0] ) )
+ main.log.debug( repr( intentState ) )
+ if sameIntents == main.FALSE:
+ try:
+ main.log.debug( "ONOS intents before: " )
+ main.log.debug( json.dumps( json.loads( intentState ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ main.log.debug( "Current ONOS intents: " )
+ main.log.debug( json.dumps( json.loads( ONOSIntents[ 0 ] ),
+ sort_keys=True, indent=4,
+ separators=( ',', ': ' ) ) )
+ except ( ValueError, TypeError ):
+ main.log.exception( "Exception printing intents" )
+ main.log.debug( repr( ONOSIntents[0] ) )
+ main.log.debug( repr( intentState ) )
utilities.assert_equals(
expect=main.TRUE,
actual=sameIntents,
@@ -1241,14 +1332,13 @@
if FlowTables == main.FALSE:
main.log.info( "Differences in flow table for switch: s" +
str( i + 1 ) )
- if FlowTables == main.TRUE:
- main.log.report( "No changes were found in the flow tables" )
utilities.assert_equals(
expect=main.TRUE,
actual=FlowTables,
onpass="No changes were found in the flow tables",
onfail="Changes were found in the flow tables" )
+ main.step( "Leadership Election is still functional" )
# Test of LeadershipElection
leader = ONOS1Ip
@@ -1264,36 +1354,23 @@
# all is well
pass
elif leaderN == main.FALSE:
- # error in response
- main.log.report( "Something is wrong with " +
+ # error in response
+ main.log.error( "Something is wrong with " +
"electionTestLeader function, check the" +
" error logs" )
leaderResult = main.FALSE
elif leader != leaderN:
leaderResult = main.FALSE
- main.log.report( "ONOS" + str( controller ) + " sees " +
+ main.log.error( "ONOS" + str( controller ) + " sees " +
str( leaderN ) +
" as the leader of the election app. " +
"Leader should be " + str( leader ) )
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a new " +
- "leader was re-elected if applicable )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
onpass="Leadership election passed",
onfail="Something went wrong with Leadership election" )
- result = ( mastershipCheck and intentCheck and FlowTables and
- rolesNotNull and leaderResult )
- result = int( result )
- if result == main.TRUE:
- main.log.report( "Constant State Tests Passed" )
- utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Constant State Tests Passed",
- onfail="Constant state tests failed" )
-
def CASE8( self, main ):
"""
Compare topo
@@ -1309,15 +1386,24 @@
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- description = "Compare ONOS Topology view to Mininet topology"
- main.case( description )
- main.log.report( description )
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplaination = "Compare topology objects between Mininet" +\
+ " and ONOS"
main.step( "Create TestONTopology object" )
- ctrls = []
- node = main.ONOS1
- temp = ( node, node.name, node.ip_address, 6633 )
- ctrls.append( temp )
- MNTopo = TestONTopology( main.Mininet1, ctrls )
+ try:
+ ctrls = []
+ node = main.ONOS1
+ temp = ( node, node.name, node.ip_address, 6633 )
+ ctrls.append( temp )
+ MNTopo = TestONTopology( main.Mininet1, ctrls )
+ except Exception:
+ objResult = main.FALSE
+ else:
+ objResult = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=objResult,
+ onpass="Created TestONTopology object",
+ onfail="Exception while creating " +
+ "TestONTopology object" )
main.step( "Comparing ONOS topology to MN" )
devicesResults = main.TRUE
@@ -1344,7 +1430,7 @@
for controller in range( 0, len( hosts ) ):
controllerStr = str( controller + 1 )
for host in hosts[ controller ]:
- if host is None or host.get( 'ips', [] ) == []:
+ if host is None or host.get( 'ipAddresses', [] ) == []:
main.log.error(
"DEBUG:Error with host ips on controller" +
controllerStr + ": " + str( host ) )
@@ -1445,8 +1531,6 @@
utilities.assert_equals( expect=main.TRUE, actual=topoResult,
onpass="Topology Check Test successful",
onfail="Topology Check Test NOT successful" )
- if topoResult == main.TRUE:
- main.log.report( "ONOS topology view matches Mininet topology" )
def CASE9( self, main ):
"""
@@ -1462,7 +1546,6 @@
description = "Turn off a link to ensure that Link Discovery " +\
"is working properly"
- main.log.report( description )
main.case( description )
main.step( "Kill Link between s3 and s28" )
@@ -1489,7 +1572,6 @@
description = "Restore a link to ensure that Link Discovery is " + \
"working properly"
- main.log.report( description )
main.case( description )
main.step( "Bring link between s3 and s28 back up" )
@@ -1515,14 +1597,13 @@
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
description = "Killing a switch to ensure it is discovered correctly"
- main.log.report( description )
main.case( description )
switch = main.params[ 'kill' ][ 'switch' ]
switchDPID = main.params[ 'kill' ][ 'dpid' ]
# TODO: Make this switch parameterizable
main.step( "Kill " + switch )
- main.log.report( "Deleting " + switch )
+ main.log.info( "Deleting " + switch )
main.Mininet1.delSwitch( switch )
main.log.info( "Waiting " + str( switchSleep ) +
" seconds for switch down to be discovered" )
@@ -1559,11 +1640,9 @@
switchDPID = main.params[ 'kill' ][ 'dpid' ]
links = main.params[ 'kill' ][ 'links' ].split()
description = "Adding a switch to ensure it is discovered correctly"
- main.log.report( description )
main.case( description )
main.step( "Add back " + switch )
- main.log.report( "Adding back " + switch )
main.Mininet1.addSwitch( switch, dpid=switchDPID )
for peer in links:
main.Mininet1.addLink( switch, peer )
@@ -1596,9 +1675,7 @@
colors = { 'cyan': '\033[96m', 'purple': '\033[95m',
'blue': '\033[94m', 'green': '\033[92m',
'yellow': '\033[93m', 'red': '\033[91m', 'end': '\033[0m' }
- description = "Test Cleanup"
- main.log.report( description )
- main.case( description )
+ main.case( "Test Cleanup" )
main.step( "Killing tcpdumps" )
main.Mininet2.stopTcpdump()
@@ -1649,11 +1726,21 @@
main.step( "Checking ONOS Logs for errors" )
print colors[ 'purple' ] + "Checking logs for errors on ONOS1:" + \
colors[ 'end' ]
- print main.ONOSbench.checkLogs( ONOS1Ip )
+ print main.ONOSbench.checkLogs( ONOS1Ip, restart=True )
main.step( "Packing and rotating pcap archives" )
os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
+ try:
+ timerLog = open( main.logdir + "/Timers.csv", 'w')
+ # Overwrite with empty line and close
+ labels = "Gossip Intents, Restart"
+ data = str( gossipTime ) + ", " + str( main.restartTime )
+ timerLog.write( labels + "\n" + data )
+ timerLog.close()
+ except NameError, e:
+ main.log.exception(e)
+
def CASE14( self, main ):
"""
start election app on all onos nodes
@@ -1662,10 +1749,17 @@
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- leaderResult = main.TRUE
main.case("Start Leadership Election app")
main.step( "Install leadership election app" )
- main.ONOScli1.activateApp( "org.onosproject.election" )
+ appResult = main.ONOScli1.activateApp( "org.onosproject.election" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=appResult,
+ onpass="Election app installed",
+ onfail="Something went wrong with installing Leadership election" )
+
+ main.step( "Run for election on each node" )
+ leaderResult = main.ONOScli1.electionTestRun()
# check for leader
leader = main.ONOScli1.electionTestLeader()
# verify leader is ONOS1
@@ -1674,32 +1768,27 @@
pass
elif leader is None:
# No leader elected
- main.log.report( "No leader was elected" )
+ main.log.error( "No leader was elected" )
leaderResult = main.FALSE
elif leader == main.FALSE:
# error in response
# TODO: add check for "Command not found:" in the driver, this
# means the app isn't loaded
- main.log.report( "Something is wrong with electionTestLeader" +
+ main.log.error( "Something is wrong with electionTestLeader" +
" function, check the error logs" )
leaderResult = main.FALSE
else:
# error in response
- main.log.report(
+ main.log.error(
"Unexpected response from electionTestLeader function:'" +
str( leader ) +
"'" )
leaderResult = main.FALSE
-
- if leaderResult:
- main.log.report( "Leadership election tests passed( consistent " +
- "view of leader across listeners and a leader " +
- "was elected )" )
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
- onpass="Leadership election passed",
- onfail="Something went wrong with Leadership election" )
+ onpass="Successfully ran for leadership",
+ onfail="Failed to run for leadership" )
def CASE15( self, main ):
"""
@@ -1710,7 +1799,6 @@
assert utilities.assert_equals, "utilities.assert_equals not defined"
leaderResult = main.TRUE
description = "Check that Leadership Election is still functional"
- main.log.report( description )
main.case( description )
main.step( "Find current leader and withdraw" )
leader = main.ONOScli1.electionTestLeader()
@@ -1719,40 +1807,40 @@
if leader == ONOS1Ip:
oldLeader = getattr( main, "ONOScli1" )
elif leader is None or leader == main.FALSE:
- main.log.report(
+ main.log.error(
"Leader for the election app should be an ONOS node," +
"instead got '" + str( leader ) + "'" )
leaderResult = main.FALSE
oldLeader = None
else:
main.log.error( "Leader election --- why am I HERE?!?")
+ leaderResult = main.FALSE
+ oldLeader = None
if oldLeader:
withdrawResult = oldLeader.electionTestWithdraw()
utilities.assert_equals(
expect=main.TRUE,
actual=withdrawResult,
- onpass="App was withdrawn from election",
- onfail="App was not withdrawn from election" )
+ onpass="Node was withdrawn from election",
+ onfail="Node was not withdrawn from election" )
main.step( "Make sure new leader is elected" )
leaderN = main.ONOScli1.electionTestLeader()
if leaderN == leader:
- main.log.report( "ONOS still sees " + str( leaderN ) +
+ main.log.error( "ONOS still sees " + str( leaderN ) +
" as leader after they withdrew" )
leaderResult = main.FALSE
elif leaderN == main.FALSE:
# error in response
# TODO: add check for "Command not found:" in the driver, this
# means the app isn't loaded
- main.log.report( "Something is wrong with electionTestLeader " +
+ main.log.error( "Something is wrong with electionTestLeader " +
"function, check the error logs" )
leaderResult = main.FALSE
elif leaderN is None:
main.log.info(
"There is no leader after the app withdrew from election" )
- if leaderResult:
- main.log.report( "Leadership election tests passed( There is no " +
- "leader after the old leader resigned )" )
+ leaderResult = main.TRUE
utilities.assert_equals(
expect=main.TRUE,
actual=leaderResult,
@@ -1770,20 +1858,21 @@
actual=runResult,
onpass="App re-ran for election",
onfail="App failed to run for election" )
- leader = main.ONOScli1.electionTestLeader()
+
+ main.step( "Node became leader when it ran for election" )
+ afterRun = main.ONOScli1.electionTestLeader()
# verify leader is ONOS1
- if leader == ONOS1Ip:
- leaderResult = main.TRUE
+ if afterRun == ONOS1Ip:
+ afterResult = main.TRUE
else:
- leaderResult = main.FALSE
- # TODO: assert on run and withdraw results?
+ afterResult = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
- actual=leaderResult,
- onpass="Leadership election passed",
- onfail="ONOS1's election app was not leader after it re-ran " +
- "for election" )
+ actual=afterResult,
+ onpass="Old leader successfully re-ran for election",
+ onfail="Something went wrong with Leadership election after " +
+ "the old leader re-ran for election" )
def CASE16( self, main ):
"""
@@ -1823,6 +1912,7 @@
"""
Check for basic functionality with distributed primitives
"""
+ import json
# Make sure variables are defined/set
assert numControllers, "numControllers not defined"
assert main, "main not defined"
@@ -1861,11 +1951,13 @@
main.step( "Increment and get a default counter on each node" )
pCounters = []
threads = []
+ addedPValues = []
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].counterTestIncrement,
name="counterIncrement-" + str( i ),
args=[ pCounterName ] )
pCounterValue += 1
+ addedPValues.append( pCounterValue )
threads.append( t )
t.start()
@@ -1874,8 +1966,12 @@
pCounters.append( t.result )
# Check that counter incremented numController times
pCounterResults = True
- for i in range( numControllers ):
- pCounterResults and ( i + 1 ) in pCounters
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
utilities.assert_equals( expect=True,
actual=pCounterResults,
onpass="Default counter incremented",
@@ -1884,6 +1980,7 @@
main.step( "Increment and get an in memory counter on each node" )
iCounters = []
+ addedIValues = []
threads = []
for i in range( numControllers ):
t = main.Thread( target=CLIs[i].counterTestIncrement,
@@ -1891,6 +1988,7 @@
args=[ iCounterName ],
kwargs={ "inMemory": True } )
iCounterValue += 1
+ addedIValues.append( iCounterValue )
threads.append( t )
t.start()
@@ -1899,8 +1997,12 @@
iCounters.append( t.result )
# Check that counter incremented numController times
iCounterResults = True
- for i in range( numControllers ):
- iCounterResults and ( i + 1 ) in iCounters
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in the in-memory "
+ "counter incremented results" )
utilities.assert_equals( expect=True,
actual=iCounterResults,
onpass="In memory counter incremented",
@@ -1935,28 +2037,41 @@
main.step( "Counters we added have the correct values" )
correctResults = main.TRUE
for i in range( numControllers ):
- current = onosCounters[i]
+ current = json.loads( onosCounters[i] )
+ pValue = None
+ iValue = None
try:
- pValue = current.get( pCounterName )
- iValue = current.get( iCounterName )
- if pValue == pCounterValue:
- main.log.info( "Partitioned counter value is correct" )
- else:
- main.log.error( "Partitioned counter value is incorrect," +
- " expected value: " + str( pCounterValue )
- + " current value: " + str( pValue ) )
- correctResults = main.FALSE
- if iValue == iCounterValue:
- main.log.info( "In memory counter value is correct" )
- else:
- main.log.error( "In memory counter value is incorrect, " +
- "expected value: " + str( iCounterValue ) +
- " current value: " + str( iValue ) )
- correctResults = main.FALSE
+ for database in current:
+ partitioned = database.get( 'partitionedDatabaseCounters' )
+ if partitioned:
+ for value in partitioned:
+ if value.get( 'name' ) == pCounterName:
+ pValue = value.get( 'value' )
+ break
+ inMemory = database.get( 'inMemoryDatabaseCounters' )
+ if inMemory:
+ for value in inMemory:
+ if value.get( 'name' ) == iCounterName:
+ iValue = value.get( 'value' )
+ break
except AttributeError, e:
main.log.error( "ONOS" + str( i + 1 ) + " counters result " +
"is not as expected" )
correctResults = main.FALSE
+ if pValue == pCounterValue:
+ main.log.info( "Partitioned counter value is correct" )
+ else:
+ main.log.error( "Partitioned counter value is incorrect," +
+ " expected value: " + str( pCounterValue )
+ + " current value: " + str( pValue ) )
+ correctResults = main.FALSE
+ if iValue == iCounterValue:
+ main.log.info( "In memory counter value is correct" )
+ else:
+ main.log.error( "In memory counter value is incorrect, " +
+ "expected value: " + str( iCounterValue ) +
+ " current value: " + str( iValue ) )
+ correctResults = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=correctResults,
onpass="Added counters are correct",
diff --git a/TestON/tests/IpOptical/IpOptical.params b/TestON/tests/IpOptical/IpOptical.params
new file mode 100755
index 0000000..62e44a8
--- /dev/null
+++ b/TestON/tests/IpOptical/IpOptical.params
@@ -0,0 +1,41 @@
+<PARAMS>
+ #20,21,22,25,10,23,24
+ <testcases>20,21,22,10,25,23,24</testcases>
+ #Environment variables
+ <ENV>
+ <cellName>driver_test</cellName>
+ </ENV>
+
+ <CTRL>
+ <ip1>10.128.20.11</ip1>
+ <port1>6633</port1>
+ </CTRL>
+
+ <PING>
+ <source1>h8</source1>
+ <source2>h9</source2>
+ <source3>h10</source3>
+ <source4>h11</source4>
+ <source5>h12</source5>
+ <source6>h13</source6>
+ <source7>h14</source7>
+ <source8>h15</source8>
+ <source9>h16</source9>
+ <source10>h17</source10>
+ <target1>10.0.0.18</target1>
+ <target2>10.0.0.19</target2>
+ <target3>10.0.0.20</target3>
+ <target4>10.0.0.21</target4>
+ <target5>10.0.0.22</target5>
+ <target6>10.0.0.23</target6>
+ <target7>10.0.0.24</target7>
+ <target8>10.0.0.25</target8>
+ <target9>10.0.0.26</target9>
+ <target10>10.0.0.27</target10>
+ </PING>
+
+ <timers>
+ <LinkDiscovery>5</LinkDiscovery>
+ <SwitchDiscovery>15</SwitchDiscovery>
+ </timers>
+</PARAMS>
diff --git a/TestON/tests/IpOptical/IpOptical.py b/TestON/tests/IpOptical/IpOptical.py
new file mode 100644
index 0000000..c4a4eb6
--- /dev/null
+++ b/TestON/tests/IpOptical/IpOptical.py
@@ -0,0 +1,630 @@
+
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
+
+import time
+# import sys
+# import os
+# import re
+import json
+
+time.sleep( 1 )
+
+class IpOptical:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ import time
+ """
+ Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-log
+ git pull
+ mvn clean install
+ onos-package
+ onos-install -f
+ onos-wait-for-start
+ """
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.case( "Setting up test environment" )
+ main.log.report(
+ "This testcase is testing setting up test environment" )
+ main.log.report( "__________________________________" )
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ main.ONOSbench.onosRemoveRaftLogs()
+
+ main.step( "Git checkout and get version" )
+ #main.ONOSbench.gitCheckout( "master" )
+ gitPullResult = main.ONOSbench.gitPull()
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
+ main.ONOSbench.getVersion( report=True )
+
+ if gitPullResult == 100:
+ main.step( "Using mvn clean & install" )
+ main.ONOSbench.cleanInstall()
+ elif gitPullResult == 0:
+ main.log.report(
+ "Git Pull Failed, look into logs for detailed reason" )
+ main.cleanup()
+ main.exit()
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Uninstalling ONOS package" )
+ ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ]
+ onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1)
+ if onosUninstallResult:
+ main.log.report( "Uninstalling ONOS package successful" )
+ else:
+ main.log.report( "Uninstalled ONOS package unsucessful" )
+ time.sleep( 5 )
+ main.step( "Installing ONOS package" )
+ onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 )
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Installing ONOS package successful" )
+ else:
+ main.log.report( "Installing ONOS package failed" )
+
+ onos1Isup = main.ONOSbench.isup()
+ if onos1Isup == main.TRUE:
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up" )
+
+ main.step( "Starting ONOS service" )
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
+
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.step( "Starting Mininet CLI..." )
+
+ def CASE20( self ):
+ """
+ Exit from mininet cli
+ reinstall ONOS
+ """
+ import time
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.log.report( "This testcase exits the mininet cli and reinstalls" +
+ "ONOS to switch over to Packet Optical topology" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Disconnecting mininet and restarting ONOS" )
+
+ main.step( "Disconnecting mininet and restarting ONOS" )
+ step1Result = main.TRUE
+ mininetDisconnect = main.Mininet1.disconnect()
+ print "mininetDisconnect = ", mininetDisconnect
+ step1Result = mininetDisconnect
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Mininet disconnect successfully",
+ onfail="Mininet failed to disconnect")
+ """
+ main.step( "Removing raft logs before a clean installation of ONOS" )
+ step2Result = main.TRUE
+ removeRaftLogsResult = main.ONOSbench.onosRemoveRaftLogs()
+ step2Result = removeRaftLogsResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Raft logs removed successfully",
+ onfail="Failed to remove raft logs")
+ """
+ main.step( "Applying cell variable to environment" )
+ step3Result = main.TRUE
+ setCellResult = main.ONOSbench.setCell( cellName )
+ verifyCellResult = main.ONOSbench.verifyCell()
+ step3Result = setCellResult and verifyCellResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step3Result,
+ onpass="Cell applied successfully",
+ onfail="Failed to apply cell")
+
+ main.step( "Uninstalling ONOS package" )
+ step4Result = main.TRUE
+ ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ]
+ onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1)
+ step4Result = onosUninstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully uninstalled ONOS",
+ onfail="Failed to uninstall ONOS")
+
+ time.sleep( 5 )
+ main.step( "Installing ONOS package" )
+ step5Result = main.TRUE
+ onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 )
+ step5Result = onosInstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step5Result,
+ onpass="Successfully installed ONOS",
+ onfail="Failed to install ONOS")
+
+ onos1Isup = main.ONOSbench.isup()
+ if onos1Isup == main.TRUE:
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up" )
+
+ main.step( "Starting ONOS service" )
+ step6Result = main.TRUE
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
+ step6Result = startResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step6Result,
+ onpass="Successfully started ONOS",
+ onfail="Failed to start ONOS")
+
+ main.step( "Starting ONOS cli" )
+ step7Result = main.TRUE
+ cliResult = main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ step7Result = cliResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step7Result,
+ onpass="Successfully started ONOS cli",
+ onfail="Failed to start ONOS cli")
+
+ def CASE21( self, main ):
+ """
+ On ONOS bench, run this command:
+ sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
+ which spawns packet optical topology and copies the links
+ json file to the onos instance.
+ Note that in case of Packet Optical, the links are not learnt
+ from the topology, instead the links are learnt
+ from the json config file
+ """
+ import time
+ main.log.report(
+ "This testcase starts the packet layer topology and REST" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Starting LINC-OE and other components" )
+
+ main.step( "Activate optical app" )
+ step1Result = main.TRUE
+ activateOpticalResult = main.ONOS2.activateApp( "org.onosproject.optical" )
+ step1Result = activateOpticalResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully activated optical app",
+ onfail="Failed to activate optical app")
+
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
+
+ main.step( "Starting mininet and LINC-OE" )
+ step2Result = main.TRUE
+ time.sleep( 10 )
+ opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
+ step2Result = opticalMnScript
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Started the topology successfully ",
+ onfail="Failed to start the topology")
+
+ def CASE22( self, main ):
+ """
+ Curretly we use, 10 optical switches(ROADM's) and
+ 6 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 10,
+ packetLayerSWCount variable = 6, hostCount=6 and
+ links=46.
+ All this is hardcoded in the testcase. If the topology changes,
+ these hardcoded values need to be changed
+ """
+ import time
+ main.log.report(
+ "This testcase compares the optical+packet topology against what" +
+ " is expected" )
+ main.case( "Topology comparision" )
+
+ main.step( "Starts new ONOS cli" )
+ step1Result = main.TRUE
+ cliResult = main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ]\
+ [ 'ip1' ] )
+ step1Result = cliResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully starts a new cli",
+ onfail="Failed to start new cli" )
+
+ main.step( "Compare topology" )
+ step2Result = main.TRUE
+ devicesResult = main.ONOS3.devices( jsonFormat=False )
+ print "devices_result :\n", devicesResult
+ devicesLinewise = devicesResult.split( "\n" )
+ roadmCount = 0
+ packetLayerSWCount = 0
+ for line in devicesLinewise:
+ components = line.split( "," )
+ availability = components[ 1 ].split( "=" )[ 1 ]
+ type = components[ 3 ].split( "=" )[ 1 ]
+ if availability == 'true' and type == 'ROADM':
+ roadmCount += 1
+ elif availability == 'true' and type == 'SWITCH':
+ packetLayerSWCount += 1
+ if roadmCount == 10:
+ print "Number of Optical Switches = %d and is" % roadmCount +\
+ " correctly detected"
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is correctly detected" )
+ opticalSWResult = main.TRUE
+ else:
+ print "Number of Optical Switches = %d and is wrong" % roadmCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is wrong" )
+ opticalSWResult = main.FALSE
+ if packetLayerSWCount == 6:
+ print "Number of Packet layer or mininet Switches = %d "\
+ % packetLayerSWCount + "and is correctly detected"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is correctly detected" )
+ packetSWResult = main.TRUE
+ else:
+ print "Number of Packet layer or mininet Switches = %d and"\
+ % packetLayerSWCount + " is wrong"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is wrong" )
+ packetSWResult = main.FALSE
+ # sleeps for sometime so the state of the switches will be active
+ time.sleep( 30 )
+ print "_________________________________"
+ linksResult = main.ONOS3.links( jsonFormat=False )
+ print "links_result = ", linksResult
+ print "_________________________________"
+ linkActiveCount = linksResult.count("state=ACTIVE")
+ main.log.info( "linkActiveCount = " + str( linkActiveCount ))
+ if linkActiveCount == 46:
+ linkActiveResult = main.TRUE
+ main.log.info(
+ "Number of links in ACTIVE state are correct")
+ else:
+ linkActiveResult = main.FALSE
+ main.log.info(
+ "Number of links in ACTIVE state are wrong")
+ step2Result = opticalSWResult and packetSWResult and \
+ linkActiveResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Successfully loaded packet optical topology",
+ onfail="Failed to load packet optical topology" )
+
+ def CASE23( self, main ):
+ import time
+ """
+ Add bidirectional point intents between 2 packet layer( mininet )
+ devices and
+ ping mininet hosts
+ """
+ main.log.report(
+ "This testcase adds bidirectional point intents between 2 " +
+ "packet layer( mininet ) devices and ping mininet hosts" )
+ main.case( "Install point intents between 2 packet layer device and " +
+ "ping the hosts" )
+
+ main.step( "Adding point intents" )
+ checkFlowResult = main.TRUE
+ step1Result = main.TRUE
+ main.pIntentsId = []
+ pIntent1 = main.ONOS3.addPointIntent(
+ "of:0000ffffffff0001/1",
+ "of:0000ffffffff0005/1" )
+ time.sleep( 10 )
+ pIntent2 = main.ONOS3.addPointIntent(
+ "of:0000ffffffff0005/1",
+ "of:0000ffffffff0001/1" )
+ main.pIntentsId.append( pIntent1 )
+ main.pIntentsId.append( pIntent2 )
+ time.sleep( 10 )
+ main.log.info( "Checking intents state")
+ checkStateResult = main.ONOS3.checkIntentState(
+ intentsId = main.pIntentsId )
+ time.sleep( 10 )
+ main.log.info( "Checking flows state")
+ checkFlowResult = main.ONOS3.checkFlowsState()
+ # Sleep for 30 seconds to provide time for the intent state to change
+ time.sleep( 10 )
+ main.log.info( "Checking intents state one more time")
+ checkStateResult = main.ONOS3.checkIntentState(
+ intentsId = main.pIntentsId )
+ step1Result = checkStateResult and checkFlowResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully added point intents",
+ onfail="Failed to add point intents")
+
+ print main.ONOS3.intents()
+
+ main.step( "Ping h1 and h5" )
+ step2Result = main.TRUE
+ main.log.info( "\n\nh1 is Pinging h5" )
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ step2Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Successfully pinged h1 and h5",
+ onfail="Failed to ping between h1 and h5")
+
+ def CASE24( self, main ):
+ import time
+ import json
+ """
+ LINC uses its own switch IDs. You can use the following
+ command on the LINC console to find the mapping between
+ DPIDs and LINC IDs.
+ rp(application:get_all_key(linc)).
+
+ Test Rerouting of Packet Optical by bringing a port down
+ ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
+ so that link
+ ( between switch1 port20 - switch5 port50 ) is inactive
+ and do a ping test. If rerouting is successful,
+ ping should pass. also check the flows
+ """
+ main.log.report(
+ "This testcase tests rerouting and pings mininet hosts" )
+ main.case( "Test rerouting and pings mininet hosts" )
+
+ main.step( "Attach to the Linc-OE session" )
+ step1Result = main.TRUE
+ attachConsole = main.LincOE1.attachLincOESession()
+ step1Result = attachConsole
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully attached Linc-OE session",
+ onfail="Failed to attached Linc-OE session")
+
+ main.step( "Bring a port down and verify the link state" )
+ step2Result = main.TRUE
+ main.LincOE1.portDown( swId="9", ptId="20" )
+ linksNonjson = main.ONOS3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+ linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 2:
+ main.log.info(
+ "Number of links in INACTIVE state are correct")
+ else:
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+ links = main.ONOS3.links()
+ main.log.info( "links = " + links )
+ linksResult = json.loads( links )
+ linksStateResult = main.FALSE
+ for item in linksResult:
+ if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
+ 'src' ][ 'port' ] == "20":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
+ 'dst' ][ 'port' ] == "50":
+ linksState = item[ 'state' ]
+ if linksState == "INACTIVE":
+ main.log.info(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ main.log.report(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ linksStateResult = main.TRUE
+ break
+ else:
+ main.log.info(
+ "Links state is not inactive as expected" )
+ main.log.report(
+ "Links state is not inactive as expected" )
+ linksStateResult = main.FALSE
+ time.sleep( 10 )
+ #checkFlowsState = main.ONOS3.checkFlowsState()
+ step2Result = linksStateResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Successfuly brought down a link",
+ onfail="Failed to bring down a link")
+
+ main.step( "Verify Rerouting by a ping test" )
+ step3Result = main.TRUE
+ main.log.info( "\n\nh1 is Pinging h5" )
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ step3Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step3Result,
+ onpass="Successfully pinged h1 and h5",
+ onfail="Failed to ping between h1 and h5")
+
+ main.step( "Bring the downed port up and verify the link state" )
+ step4Result = main.TRUE
+ main.LincOE1.portUp( swId="9", ptId="20" )
+ linksNonjson = main.ONOS3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+ linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
+ time.sleep( 30 )
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 0:
+ main.log.info(
+ "Number of links in INACTIVE state are correct")
+ else:
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+ step4Result = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully brought the port up",
+ onfail="Failed to bring the port up")
+ """
+ main.step( "Removing host intents" )
+ step5Result = main.TRUE
+ removeResult = main.TRUE
+ # Check remaining intents
+ intentsJson = json.loads( main.ONOS3.intents() )
+ main.ONOS3.removeIntent( intentId=intent1, purge=True )
+ main.ONOS3.removeIntent( intentId=intent2, purge=True )
+ for intents in intentsJson:
+ main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
+ app='org.onosproject.optical',
+ purge=True )
+ print json.loads( main.ONOS3.intents() )
+ if len( json.loads( main.ONOS3.intents() ) ):
+ removeResult = main.FALSE
+ step5Result = removeResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step5Result,
+ onpass="Successfully removed host intents",
+ onfail="Failed to remove host intents" )
+ """
+ def CASE10( self ):
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ main.step( "Uninstalling reactive forwarding app" )
+ step1Result = main.TRUE
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ main.log.info( "deactivate reactive forwarding app" )
+ appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
+ step1Result = appUninstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully deactivate reactive forwarding app",
+ onfail="Failed to deactivate reactive forwarding app")
+ # After reactive forwarding is disabled, the reactive flows on
+ # switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
+ flows = main.ONOS2.flows()
+ main.log.info( flows )
+
+ def CASE25( self ):
+ """
+ Add host intents between 2 packet layer host
+ """
+ import time
+ import json
+ main.log.report( "Adding host intents between 2 optical layer host" )
+ main.case( "Test add host intents between optical layer host" )
+
+ main.step( "Discover host using arping" )
+ step1Result = main.TRUE
+ main.hostMACs = []
+ main.hostId = []
+ #Listing host MAC addresses
+ for i in range( 1 , 7 ):
+ main.hostMACs.append( "00:00:00:00:00:" +
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
+ for macs in main.hostMACs:
+ main.hostId.append( macs + "/-1" )
+ host1 = main.hostId[ 0 ]
+ host2 = main.hostId[ 1 ]
+ # Use arping to discover the hosts
+ main.LincOE2.arping( host = "h1" )
+ main.LincOE2.arping( host = "h2" )
+ time.sleep( 5 )
+ hostsDict = main.ONOS3.hosts()
+ if not len( hostsDict ):
+ step1Result = main.FALSE
+ # Adding host intent
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Hosts discovered",
+ onfail="Failed to discover hosts")
+
+ main.step( "Adding host intents to h1 and h2" )
+ step2Result = main.TRUE
+ intentsId = []
+ intent1 = main.ONOS3.addHostIntent( hostIdOne = host1,
+ hostIdTwo = host2 )
+ intentsId.append( intent1 )
+ """
+ intent2 = main.ONOS3.addHostIntent( hostIdOne = host2,
+ hostIdTwo = host1 )
+ intentsId.append( intent2 )
+ """
+ # Checking intents state before pinging
+ main.log.info( "Checking intents state" )
+ time.sleep( 15 )
+ intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
+ #check intent state again if intents are not in installed state
+ print main.ONOS3.intents()
+ if not intentResult:
+ intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
+ step2Result = intentResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step2Result,
+ onpass="All intents are in INSTALLED state ",
+ onfail="Some of the intents are not in " +
+ "INSTALLED state " )
+
+ # pinging h1 to h2 and then ping h2 to h1
+ main.step( "Pinging h1 and h2" )
+ step3Result = main.TRUE
+ pingResult = main.TRUE
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2",
+ target="h1" )
+ step3Result = pingResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step3Result,
+ onpass="Pinged successfully between h1 and h2",
+ onfail="Pinged failed between h1 and h2" )
+ # Removed all added host intents
+ main.step( "Removing host intents" )
+ step4Result = main.TRUE
+ removeResult = main.TRUE
+ # Check remaining intents
+ intentsJson = json.loads( main.ONOS3.intents() )
+ main.ONOS3.removeIntent( intentId=intent1, purge=True )
+ #main.ONOS3.removeIntent( intentId=intent2, purge=True )
+ for intents in intentsJson:
+ main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
+ app='org.onosproject.optical',
+ purge=True )
+ print json.loads( main.ONOS3.intents() )
+ if len( json.loads( main.ONOS3.intents() ) ):
+ removeResult = main.FALSE
+ step4Result = removeResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully removed host intents",
+ onfail="Failed to remove host intents" )
diff --git a/TestON/tests/IpOptical/IpOptical.topo b/TestON/tests/IpOptical/IpOptical.topo
new file mode 100755
index 0000000..9cef3f7
--- /dev/null
+++ b/TestON/tests/IpOptical/IpOptical.topo
@@ -0,0 +1,92 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1>
+ <host>10.128.10.11</host>
+ <user>sdn</user>
+ <password>sdn</password>
+ <type>OnosDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+
+ <Mininet1>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> --switch ovs,protocols=OpenFlow13 </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> --switch ovs,protocols=OpenFlow13 </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet2>
+
+ <LincOE1>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>LincOEDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </LincOE1>
+
+ <LincOE2>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </LincOE2>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/IpOptical/__init__.py b/TestON/tests/IpOptical/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/IpOptical/__init__.py
diff --git a/TestON/tests/IpOpticalMulti/IpOpticalMulti.params b/TestON/tests/IpOpticalMulti/IpOpticalMulti.params
new file mode 100755
index 0000000..c17bf21
--- /dev/null
+++ b/TestON/tests/IpOpticalMulti/IpOpticalMulti.params
@@ -0,0 +1,64 @@
+<PARAMS>
+
+ <testcases>20,21,22,10,25,23,24</testcases>
+ #Environment variables
+ <ENV>
+ <cellName>multi_test</cellName>
+ </ENV>
+
+ <CTRL>
+ <ip1>10.128.20.11</ip1>
+ <ip2>10.128.20.12</ip2>
+ <ip3>10.128.20.13</ip3>
+ <port1>6633</port1>
+ <port2>6633</port2>
+ <port3>6633</port3>
+ </CTRL>
+
+ <SDNIP>
+ <ethType>IPV4</ethType>
+ <tcpProto>6</tcpProto>
+ <icmpProto>1</icmpProto>
+ <srcPort>5001</srcPort>
+ <dstPort>5001</dstPort>
+ </SDNIP>
+
+ <MULTIPOINT_INTENT>
+ <device1>of:0000000000003008/1 </device1>
+ <device2>of:0000000000003009/1 </device2>
+ <device3>of:0000000000003010/1 </device3>
+ <mac1>00:00:00:00:00:0A </mac1>
+ <mac2>00:00:00:00:00:08 </mac2>
+ <ip1>10.0.3.0/24 </ip1>
+ <ip2>10.0.1.0/24 </ip2>
+ </MULTIPOINT_INTENT>
+
+ <PING>
+ <source1>h8</source1>
+ <source2>h9</source2>
+ <source3>h10</source3>
+ <source4>h11</source4>
+ <source5>h12</source5>
+ <source6>h13</source6>
+ <source7>h14</source7>
+ <source8>h15</source8>
+ <source9>h16</source9>
+ <source10>h17</source10>
+ <target1>10.0.0.18</target1>
+ <target2>10.0.0.19</target2>
+ <target3>10.0.0.20</target3>
+ <target4>10.0.0.21</target4>
+ <target5>10.0.0.22</target5>
+ <target6>10.0.0.23</target6>
+ <target7>10.0.0.24</target7>
+ <target8>10.0.0.25</target8>
+ <target9>10.0.0.26</target9>
+ <target10>10.0.0.27</target10>
+ </PING>
+
+ <timers>
+ <LinkDiscovery>5</LinkDiscovery>
+ <SwitchDiscovery>31</SwitchDiscovery>
+ </timers>
+
+</PARAMS>
diff --git a/TestON/tests/IpOpticalMulti/IpOpticalMulti.py b/TestON/tests/IpOpticalMulti/IpOpticalMulti.py
new file mode 100644
index 0000000..ff09766
--- /dev/null
+++ b/TestON/tests/IpOpticalMulti/IpOpticalMulti.py
@@ -0,0 +1,703 @@
+
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
+
+import time
+import sys
+import os
+import re
+import time
+import json
+
+time.sleep( 1 )
+
+class IpOpticalMulti:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ """
+ Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-logs
+ git pull
+ mvn clean install
+ onos-package
+ onos-install -f
+ onos-wait-for-start
+ """
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+
+ main.case( "Setting up test environment" )
+ main.log.report(
+ "This testcase is testing setting up test environment" )
+ main.log.report( "__________________________________" )
+
+ main.step( "Applying cell variable to environment" )
+ cellResult1 = main.ONOSbench.setCell( cellName )
+ # cellResult2 = main.ONOScli1.setCell( cellName )
+ # cellResult3 = main.ONOScli2.setCell( cellName )
+ # cellResult4 = main.ONOScli3.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ cellResult = cellResult1
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ removeLogResult = main.ONOSbench.onosRemoveRaftLogs()
+
+ main.step( "Git checkout, pull and get version" )
+ #main.ONOSbench.gitCheckout( "master" )
+ gitPullResult = main.ONOSbench.gitPull()
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
+ versionResult = main.ONOSbench.getVersion( report=True )
+
+ if gitPullResult == 100:
+ main.step( "Using mvn clean & install" )
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ # cleanInstallResult = main.TRUE
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ # main.step( "Creating a cell" )
+ # cellCreateResult = main.ONOSbench.createCellFile( **************
+ # )
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS1Ip )
+ onos2InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS2Ip )
+ onos3InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS3Ip )
+ onosInstallResult = onos1InstallResult and onos2InstallResult and\
+ onos3InstallResult
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Installing ONOS package successful" )
+ else:
+ main.log.report( "Installing ONOS package failed" )
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ onos2Isup = main.ONOSbench.isup( ONOS2Ip )
+ onos3Isup = main.ONOSbench.isup( ONOS3Ip )
+ onosIsup = onos1Isup and onos2Isup and onos3Isup
+ if onosIsup == main.TRUE:
+ main.log.report( "ONOS instances are up and ready" )
+ else:
+ main.log.report( "ONOS instances may not be up" )
+
+ main.step( "Starting ONOS service" )
+ startResult = main.TRUE
+ # startResult = main.ONOSbench.onosStart( ONOS1Ip )
+ startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
+ startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
+ startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
+ print startcli1
+ print startcli2
+ print startcli3
+
+ case1Result = ( packageResult and
+ cellResult and verifyResult and onosInstallResult and
+ onosIsup and startResult )
+ utilities.assertEquals( expect=main.TRUE, actual=case1Result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ def CASE20( self ):
+ """
+ Exit from mininet cli
+ reinstall ONOS
+ """
+ import time
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+
+
+ main.log.report( "This testcase exits the mininet cli and reinstalls" +
+ "ONOS to switch over to Packet Optical topology" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Disconnecting mininet and restarting ONOS" )
+
+ main.step( "Disconnecting mininet and restarting ONOS" )
+ step1Result = main.TRUE
+ mininetDisconnect = main.Mininet1.disconnect()
+ print "mininetDisconnect = ", mininetDisconnect
+ step1Result = mininetDisconnect
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Mininet disconnect successfully",
+ onfail="Mininet failed to disconnect")
+ """
+ main.step( "Removing raft logs before a clean installation of ONOS" )
+ step2Result = main.TRUE
+ removeRaftLogsResult = main.ONOSbench.onosRemoveRaftLogs()
+ step2Result = removeRaftLogsResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Raft logs removed successfully",
+ onfail="Failed to remove raft logs")
+ """
+ main.step( "Applying cell variable to environment" )
+ step3Result = main.TRUE
+ setCellResult = main.ONOSbench.setCell( cellName )
+ verifyCellResult = main.ONOSbench.verifyCell()
+ step3Result = setCellResult and verifyCellResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step3Result,
+ onpass="Cell applied successfully",
+ onfail="Failed to apply cell")
+
+ main.step( "Uninstalling ONOS package" )
+ step4Result = main.TRUE
+ onos1UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS1Ip)
+ onos2UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS2Ip)
+ onos3UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS3Ip)
+ onosUninstallResult = onos1UninstallResult and onos2UninstallResult \
+ and onos3UninstallResult
+ step4Result = onosUninstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully uninstalled ONOS",
+ onfail="Failed to uninstall ONOS")
+
+ time.sleep( 5 )
+ main.step( "Installing ONOS package" )
+ step5Result = main.TRUE
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS1Ip )
+ onos2InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS2Ip )
+ onos3InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS3Ip )
+ onosInstallResult = onos1InstallResult and onos2InstallResult and\
+ onos3InstallResult
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ onos2Isup = main.ONOSbench.isup( ONOS2Ip )
+ onos3Isup = main.ONOSbench.isup( ONOS3Ip )
+ onosIsUp = onos1Isup and onos2Isup and onos3Isup
+ if onosIsUp == main.TRUE:
+ main.log.report( "ONOS instances are up and ready" )
+ else:
+ main.log.report( "ONOS instances may not be up" )
+ step5Result = onosInstallResult and onosIsUp
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step5Result,
+ onpass="Successfully installed ONOS",
+ onfail="Failed to install ONOS")
+
+ main.step( "Starting ONOS service" )
+ step6Result = main.TRUE
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
+ step6Result = startResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step6Result,
+ onpass="Successfully started ONOS",
+ onfail="Failed to start ONOS")
+
+ main.step( "Starting ONOS cli" )
+ step7Result = main.TRUE
+ startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
+ startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
+ startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
+ startResult = startcli1 and startcli2 and startcli3
+ step7Result = startResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step7Result,
+ onpass="Successfully started ONOS cli",
+ onfail="Failed to start ONOS cli")
+
+ case20Result = step1Result and step3Result and\
+ step4Result and step5Result and step6Result and\
+ step7Result
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case20Result,
+ onpass= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS successful",
+ onfail= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS failed" )
+
+ def CASE21( self, main ):
+ """
+ On ONOS bench, run this command:
+ sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
+ which spawns packet optical topology and copies the links
+ json file to the onos instance.
+ Note that in case of Packet Optical, the links are not learnt
+ from the topology, instead the links are learnt
+ from the json config file
+ """
+ import time
+ main.log.report(
+ "This testcase starts the packet layer topology and REST" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Starting LINC-OE and other components" )
+
+ main.step( "Activate optical app" )
+ step1Result = main.TRUE
+ activateOpticalResult = main.ONOScli2.activateApp( "org.onosproject.optical" )
+ step1Result = activateOpticalResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully activated optical app",
+ onfail="Failed to activate optical app")
+
+ appCheck = main.ONOScli2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOScli2.apps() )
+ main.log.warn( main.ONOScli2.appIDs() )
+
+ main.step( "Starting mininet and LINC-OE" )
+ step2Result = main.TRUE
+ time.sleep( 10 )
+ opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
+ step2Result = opticalMnScript
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Started the topology successfully ",
+ onfail="Failed to start the topology")
+
+ case21Result = step1Result and step2Result
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case21Result,
+ onpass="Packet optical topology spawned successsfully",
+ onfail="Packet optical topology spawning failed" )
+
+ def CASE22( self, main ):
+ """
+ Curretly we use, 10 optical switches(ROADM's) and
+ 6 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 10,
+ packetLayerSWCount variable = 6, hostCount=6 and
+ links=46.
+ All this is hardcoded in the testcase. If the topology changes,
+ these hardcoded values need to be changed
+ """
+ import time
+ main.log.report(
+ "This testcase compares the optical+packet topology against what" +
+ " is expected" )
+ main.case( "Topology comparision" )
+
+ main.step( "Starts new ONOS cli" )
+ step1Result = main.TRUE
+ cliResult = main.ONOScli1.startOnosCli( ONOSIp=main.params[ 'CTRL' ]\
+ [ 'ip1' ] )
+ step1Result = cliResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully starts a new cli",
+ onfail="Failed to start new cli" )
+
+ main.step( "Compare topology" )
+ step2Result = main.TRUE
+ devicesResult = main.ONOScli1.devices( jsonFormat=False )
+ print "devices_result :\n", devicesResult
+ devicesLinewise = devicesResult.split( "\n" )
+ roadmCount = 0
+ packetLayerSWCount = 0
+ for line in devicesLinewise:
+ components = line.split( "," )
+ availability = components[ 1 ].split( "=" )[ 1 ]
+ type = components[ 3 ].split( "=" )[ 1 ]
+ if availability == 'true' and type == 'ROADM':
+ roadmCount += 1
+ elif availability == 'true' and type == 'SWITCH':
+ packetLayerSWCount += 1
+ if roadmCount == 10:
+ print "Number of Optical Switches = %d and is" % roadmCount +\
+ " correctly detected"
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is correctly detected" )
+ opticalSWResult = main.TRUE
+ else:
+ print "Number of Optical Switches = %d and is wrong" % roadmCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is wrong" )
+ opticalSWResult = main.FALSE
+ if packetLayerSWCount == 6:
+ print "Number of Packet layer or mininet Switches = %d "\
+ % packetLayerSWCount + "and is correctly detected"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is correctly detected" )
+ packetSWResult = main.TRUE
+ else:
+ print "Number of Packet layer or mininet Switches = %d and"\
+ % packetLayerSWCount + " is wrong"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is wrong" )
+ packetSWResult = main.FALSE
+ # sleeps for sometime so the state of the switches will be active
+ time.sleep( 30 )
+ print "_________________________________"
+ linksResult = main.ONOScli1.links( jsonFormat=False )
+ print "links_result = ", linksResult
+ print "_________________________________"
+ linkActiveCount = linksResult.count("state=ACTIVE")
+ main.log.info( "linkActiveCount = " + str( linkActiveCount ))
+ if linkActiveCount == 46:
+ linkActiveResult = main.TRUE
+ main.log.info(
+ "Number of links in ACTIVE state are correct")
+ else:
+ linkActiveResult = main.FALSE
+ main.log.info(
+ "Number of links in ACTIVE state are wrong")
+ step2Result = opticalSWResult and packetSWResult and \
+ linkActiveResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Successfully loaded packet optical topology",
+ onfail="Failed to load packet optical topology" )
+
+ case22Result = step1Result and step2Result
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case22Result,
+ onpass="Packet optical topology discovery successful",
+ onfail="Packet optical topology discovery failed" )
+
+ def CASE23( self, main ):
+ import time
+ """
+ Add bidirectional point intents between 2 packet layer( mininet )
+ devices and
+ ping mininet hosts
+ """
+ main.log.report(
+ "This testcase adds bidirectional point intents between 2 " +
+ "packet layer( mininet ) devices and ping mininet hosts" )
+ main.case( "Install point intents between 2 packet layer device and " +
+ "ping the hosts" )
+
+ main.step( "Adding point intents" )
+ step1Result = main.TRUE
+ intentsId = []
+ pIntent1 = main.ONOScli1.addPointIntent(
+ "of:0000ffffffff0001/1",
+ "of:0000ffffffff0005/1" )
+ pIntent2 = main.ONOScli1.addPointIntent(
+ "of:0000ffffffff0005/1",
+ "of:0000ffffffff0001/1" )
+ intentsId.append( pIntent1 )
+ intentsId.append( pIntent2 )
+ main.log.info( "Checking intents state")
+ checkStateResult = main.ONOScli1.checkIntentState( intentsId = intentsId )
+ time.sleep( 30 )
+ main.log.info( "Checking flows state")
+ checkFlowResult = main.ONOScli1.checkFlowsState()
+ # Sleep for 30 seconds to provide time for the intent state to change
+ time.sleep( 30 )
+ main.log.info( "Checking intents state one more time")
+ checkStateResult = main.ONOScli1.checkIntentState( intentsId = intentsId )
+ step1Result = checkStateResult and checkFlowResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully added point intents",
+ onfail="Failed to add point intents")
+
+ main.step( "Ping h1 and h5" )
+ step2Result = main.TRUE
+ main.log.info( "\n\nh1 is Pinging h5" )
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ step2Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Successfully pinged h1 and h5",
+ onfail="Failed to ping between h1 and h5")
+
+ case23Result = step1Result and step2Result
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case23Result,
+ onpass="Point intents are installed properly",
+ onfail="Failed to install point intents" )
+
+ def CASE24( self, main ):
+ import time
+ import json
+ """
+ LINC uses its own switch IDs. You can use the following
+ command on the LINC console to find the mapping between
+ DPIDs and LINC IDs.
+ rp(application:get_all_key(linc)).
+
+ Test Rerouting of Packet Optical by bringing a port down
+ ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
+ so that link
+ ( between switch1 port20 - switch5 port50 ) is inactive
+ and do a ping test. If rerouting is successful,
+ ping should pass. also check the flows
+ """
+ main.log.report(
+ "This testcase tests rerouting and pings mininet hosts" )
+ main.case( "Test rerouting and pings mininet hosts" )
+
+ main.step( "Attach to the Linc-OE session" )
+ step1Result = main.TRUE
+ attachConsole = main.LincOE1.attachLincOESession()
+ step1Result = attachConsole
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully attached Linc-OE session",
+ onfail="Failed to attached Linc-OE session")
+
+ main.step( "Bring a port down and verify the link state" )
+ step2Result = main.TRUE
+ main.LincOE1.portDown( swId="9", ptId="20" )
+ linksNonjson = main.ONOScli1.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+ linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 2:
+ main.log.info(
+ "Number of links in INACTIVE state are correct")
+ else:
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+ links = main.ONOScli1.links()
+ main.log.info( "links = " + links )
+ linksResult = json.loads( links )
+ linksStateResult = main.FALSE
+ for item in linksResult:
+ if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
+ 'src' ][ 'port' ] == "20":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
+ 'dst' ][ 'port' ] == "50":
+ linksState = item[ 'state' ]
+ if linksState == "INACTIVE":
+ main.log.info(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ main.log.report(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ linksStateResult = main.TRUE
+ break
+ else:
+ main.log.info(
+ "Links state is not inactive as expected" )
+ main.log.report(
+ "Links state is not inactive as expected" )
+ linksStateResult = main.FALSE
+ time.sleep( 10 )
+ checkFlowsState = main.ONOScli1.checkFlowsState()
+ step2Result = linksStateResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Successfuly brought down a link",
+ onfail="Failed to bring down a link")
+
+ main.step( "Verify Rerouting by a ping test" )
+ step3Result = main.TRUE
+ main.log.info( "\n\nh1 is Pinging h5" )
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ step3Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step3Result,
+ onpass="Successfully pinged h1 and h5",
+ onfail="Failed to ping between h1 and h5")
+
+ main.step( "Bring the downed port up and verify the link state" )
+ step4Result = main.TRUE
+ main.LincOE1.portUp( swId="9", ptId="20" )
+ linksNonjson = main.ONOScli1.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+ linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 0:
+ main.log.info(
+ "Number of links in INACTIVE state are correct")
+ else:
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+ step4Result = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully brought the port up",
+ onfail="Failed to bring the port up")
+
+ case24Result = step1Result and step2Result and step3Result \
+ and step4Result
+ utilities.assert_equals( expect=main.TRUE,
+ actual=case24Result,
+ onpass="Packet optical rerouting successful",
+ onfail="Packet optical rerouting failed" )
+
+ def CASE10( self ):
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ main.step( "Uninstalling reactive forwarding app" )
+ step1Result = main.TRUE
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ main.log.info( "deactivate reactive forwarding app" )
+ appUninstallResult = main.ONOScli2.deactivateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOScli2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOScli2.apps() )
+ main.log.warn( main.ONOScli2.appIDs() )
+ step1Result = appUninstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully deactivate reactive forwarding app",
+ onfail="Failed to deactivate reactive forwarding app")
+ # After reactive forwarding is disabled, the reactive flows on
+ # switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
+ flows = main.ONOScli2.flows()
+ main.log.info( flows )
+
+ case10Result = step1Result
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case10Result,
+ onpass="Reactive forwarding app uninstallation successful",
+ onfail="Reactive forwarding app uninstallation failed" )
+
+ def CASE25( self ):
+ """
+ Add host intents between 2 packet layer host
+ """
+ import time
+ import json
+ main.log.report( "Adding host intents between 2 optical layer host" )
+ main.case( "Test add host intents between optical layer host" )
+
+ main.step( "Discover host using arping" )
+ step1Result = main.TRUE
+ main.hostMACs = []
+ main.hostId = []
+ #Listing host MAC addresses
+ for i in range( 1 , 7 ):
+ main.hostMACs.append( "00:00:00:00:00:" +
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
+ for macs in main.hostMACs:
+ main.hostId.append( macs + "/-1" )
+ host1 = main.hostId[ 0 ]
+ host2 = main.hostId[ 1 ]
+ # Use arping to discover the hosts
+ main.LincOE2.arping( host = "h1" )
+ main.LincOE2.arping( host = "h2" )
+ time.sleep( 5 )
+ hostsDict = main.ONOScli1.hosts()
+ if not len( hostsDict ):
+ step1Result = main.FALSE
+ # Adding host intent
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Hosts discovered",
+ onfail="Failed to discover hosts")
+
+ main.step( "Adding host intents to h1 and h2" )
+ step2Result = main.TRUE
+ intentsId = []
+ intent1 = main.ONOScli1.addHostIntent( hostIdOne = host1,
+ hostIdTwo = host2 )
+ intentsId.append( intent1 )
+ time.sleep( 5 )
+ intent2 = main.ONOScli1.addHostIntent( hostIdOne = host2,
+ hostIdTwo = host1 )
+ intentsId.append( intent2 )
+ # Checking intents state before pinging
+ main.log.info( "Checking intents state" )
+ time.sleep( 30 )
+ intentResult = main.ONOScli1.checkIntentState( intentsId = intentsId )
+ #check intent state again if intents are not in installed state
+ if not intentResult:
+ intentResult = main.ONOScli1.checkIntentState( intentsId = intentsId )
+ step2Result = intentResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step2Result,
+ onpass="All intents are in INSTALLED state ",
+ onfail="Some of the intents are not in " +
+ "INSTALLED state " )
+
+ # pinging h1 to h2 and then ping h2 to h1
+ main.step( "Pinging h1 and h2" )
+ step3Result = main.TRUE
+ pingResult = main.TRUE
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2",
+ target="h1" )
+ step3Result = pingResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step3Result,
+ onpass="Pinged successfully between h1 and h2",
+ onfail="Pinged failed between h1 and h2" )
+ # Removed all added host intents
+ main.step( "Removing host intents" )
+ step4Result = main.TRUE
+ removeResult = main.TRUE
+ # Check remaining intents
+ intentsJson = json.loads( main.ONOScli1.intents() )
+ main.ONOScli1.removeIntent( intentId=intent1, purge=True )
+ main.ONOScli1.removeIntent( intentId=intent2, purge=True )
+ for intents in intentsJson:
+ main.ONOScli1.removeIntent( intentId=intents.get( 'id' ),
+ app='org.onosproject.optical',
+ purge=True )
+ print json.loads( main.ONOScli1.intents() )
+ if len( json.loads( main.ONOScli1.intents() ) ):
+ removeResult = main.FALSE
+ step4Result = removeResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully removed host intents",
+ onfail="Failed to remove host intents" )
+ case25Result = step1Result and step2Result and step3Result and \
+ step4Result
+ utilities.assert_equals( expect=main.TRUE,
+ actual=case25Result,
+ onpass="Add host intent successful",
+ onfail="Add host intent failed" )
diff --git a/TestON/tests/IpOpticalMulti/IpOpticalMulti.topo b/TestON/tests/IpOpticalMulti/IpOpticalMulti.topo
new file mode 100755
index 0000000..4b1ab12
--- /dev/null
+++ b/TestON/tests/IpOpticalMulti/IpOpticalMulti.topo
@@ -0,0 +1,118 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli3>
+
+ <ONOS1>
+ <host>10.128.10.11</host>
+ <user>sdn</user>
+ <password>sdn</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.10.11</host>
+ <user>sdn</user>
+ <password>sdn</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.10.11</host>
+ <user>sdn</user>
+ <password>sdn</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+
+ <Mininet1>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> --switch ovs,protocols=OpenFlow13 </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> --switch ovs,protocols=OpenFlow13 </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet2>
+
+ <LincOE1>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>LincOEDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </LincOE1>
+
+ <LincOE2>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </LincOE2>
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/IpOpticalMulti/IpOpticalMultiOld.py b/TestON/tests/IpOpticalMulti/IpOpticalMultiOld.py
new file mode 100644
index 0000000..d00410f
--- /dev/null
+++ b/TestON/tests/IpOpticalMulti/IpOpticalMultiOld.py
@@ -0,0 +1,572 @@
+
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
+
+import time
+import sys
+import os
+import re
+import time
+import json
+
+time.sleep( 1 )
+
+class IpOpticalMulti:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ """
+ Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-logs
+ git pull
+ mvn clean install
+ onos-package
+ onos-install -f
+ onos-wait-for-start
+ """
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+
+ main.case( "Setting up test environment" )
+ main.log.report(
+ "This testcase is testing setting up test environment" )
+ main.log.report( "__________________________________" )
+
+ main.step( "Applying cell variable to environment" )
+ cellResult1 = main.ONOSbench.setCell( cellName )
+ # cellResult2 = main.ONOScli1.setCell( cellName )
+ # cellResult3 = main.ONOScli2.setCell( cellName )
+ # cellResult4 = main.ONOScli3.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ cellResult = cellResult1
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ removeLogResult = main.ONOSbench.onosRemoveRaftLogs()
+
+ main.step( "Git checkout, pull and get version" )
+ #main.ONOSbench.gitCheckout( "master" )
+ gitPullResult = main.ONOSbench.gitPull()
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
+ versionResult = main.ONOSbench.getVersion( report=True )
+
+ if gitPullResult == 1:
+ main.step( "Using mvn clean & install" )
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ # cleanInstallResult = main.TRUE
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ # main.step( "Creating a cell" )
+ # cellCreateResult = main.ONOSbench.createCellFile( **************
+ # )
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS1Ip )
+ onos2InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS2Ip )
+ onos3InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS3Ip )
+ onosInstallResult = onos1InstallResult and onos2InstallResult and\
+ onos3InstallResult
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Installing ONOS package successful" )
+ else:
+ main.log.report( "Installing ONOS package failed" )
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ onos2Isup = main.ONOSbench.isup( ONOS2Ip )
+ onos3Isup = main.ONOSbench.isup( ONOS3Ip )
+ onosIsup = onos1Isup and onos2Isup and onos3Isup
+ if onosIsup == main.TRUE:
+ main.log.report( "ONOS instances are up and ready" )
+ else:
+ main.log.report( "ONOS instances may not be up" )
+
+ main.step( "Starting ONOS service" )
+ startResult = main.TRUE
+ # startResult = main.ONOSbench.onosStart( ONOS1Ip )
+ startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
+ startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
+ startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
+ print startcli1
+ print startcli2
+ print startcli3
+
+ case1Result = ( packageResult and
+ cellResult and verifyResult and onosInstallResult and
+ onosIsup and startResult )
+ utilities.assertEquals( expect=main.TRUE, actual=case1Result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ def CASE10( self ):
+ import time
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOScli1.apps() )
+ main.log.warn( main.ONOScli1.appIDs() )
+ main.log.info( "onos-app-fwd uninstalled" )
+
+ # After reactive forwarding is disabled,
+ # the reactive flows on switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
+
+ hosts = main.ONOScli1.hosts()
+ main.log.info( hosts )
+ case10Result = appInstallResult
+ utilities.assertEquals(
+ expect=main.TRUE,
+ actual=case10Result,
+ onpass="Reactive forwarding app uninstallation successful",
+ onfail="Reactive forwarding app uninstallation failed" )
+
+ def CASE20( self ):
+ """
+ Exit from mininet cli
+ reinstall ONOS
+ """
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+
+ main.log.report( "This testcase exits the mininet cli and reinstalls" +
+ "ONOS to switch over to Packet Optical topology" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Disconnecting mininet and restarting ONOS" )
+ main.step( "Disconnecting mininet and restarting ONOS" )
+ mininetDisconnect = main.Mininet1.disconnect()
+ print "mininetDisconnect = ", mininetDisconnect
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ main.ONOSbench.onosRemoveRaftLogs()
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS1Ip )
+ onos2InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS2Ip )
+ onos3InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS3Ip )
+ onosInstallResult = onos1InstallResult and onos2InstallResult and\
+ onos3InstallResult
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Installing ONOS package successful" )
+ else:
+ main.log.report( "Installing ONOS package failed" )
+
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ onos2Isup = main.ONOSbench.isup( ONOS2Ip )
+ onos3Isup = main.ONOSbench.isup( ONOS3Ip )
+ onosIsup = onos1Isup and onos2Isup and onos3Isup
+ if onosIsup == main.TRUE:
+ main.log.report( "ONOS instances are up and ready" )
+ else:
+ main.log.report( "ONOS instances may not be up" )
+
+ main.step( "Starting ONOS service" )
+ startResult = main.TRUE
+ # startResult = main.ONOSbench.onosStart( ONOS1Ip )
+ startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
+ startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
+ startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
+ startResult = startcli1 and startcli2 and startcli3
+ if startResult == main.TRUE:
+ main.log.report( "ONOS cli starts properly" )
+ case20Result = mininetDisconnect and cellResult and verifyResult \
+ and onosInstallResult and onosIsup and startResult
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case20Result,
+ onpass= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS successful",
+ onfail= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS failed" )
+
+ def CASE21( self, main ):
+ """
+ On ONOS bench, run this command:
+ sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls>
+ which spawns packet optical topology and copies the links
+ json file to the onos instance.
+ Note that in case of Packet Optical, the links are not learnt
+ from the topology, instead the links are learnt
+ from the json config file
+ """
+ main.log.report(
+ "This testcase starts the packet layer topology and REST" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Starting LINC-OE and other components" )
+ main.step( "Starting LINC-OE and other components" )
+ main.log.info( "Activate optical app" )
+ appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ appCheck = appCheck and main.ONOScli2.appToIDCheck()
+ appCheck = appCheck and main.ONOScli3.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( "Checking ONOS application unsuccesful" )
+
+ ctrllerIP = []
+ ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] )
+ #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] )
+ #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] )
+ opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP )
+ case21Result = opticalMnScript and appInstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case21Result,
+ onpass="Packet optical topology spawned successsfully",
+ onfail="Packet optical topology spawning failed" )
+
+ def CASE22( self, main ):
+ """
+ Curretly we use, 10 optical switches(ROADM's) and
+ 6 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 10,
+ packetLayerSWCount variable = 6, hostCount=6 and
+ links=42.
+ All this is hardcoded in the testcase. If the topology changes,
+ these hardcoded values need to be changed
+ """
+ main.log.report(
+ "This testcase compares the optical+packet topology against what" +
+ " is expected" )
+ main.case( "Topology comparision" )
+ main.step( "Topology comparision" )
+ devicesResult = main.ONOScli3.devices( jsonFormat=False )
+
+ print "devices_result = ", devicesResult
+ devicesLinewise = devicesResult.split( "\n" )
+ roadmCount = 0
+ packetLayerSWCount = 0
+ for line in devicesLinewise:
+ components = line.split( "," )
+ availability = components[ 1 ].split( "=" )[ 1 ]
+ type = components[ 3 ].split( "=" )[ 1 ]
+ if availability == 'true' and type == 'ROADM':
+ roadmCount += 1
+ elif availability == 'true' and type == 'SWITCH':
+ packetLayerSWCount += 1
+ if roadmCount == 10:
+ print "Number of Optical Switches = %d and is" % roadmCount +\
+ " correctly detected"
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is correctly detected" )
+ opticalSWResult = main.TRUE
+ else:
+ print "Number of Optical Switches = %d and is wrong" % roadmCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is wrong" )
+ opticalSWResult = main.FALSE
+
+ if packetLayerSWCount == 6:
+ print "Number of Packet layer or mininet Switches = %d "\
+ % packetLayerSWCount + "and is correctly detected"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is correctly detected" )
+ packetSWResult = main.TRUE
+ else:
+ print "Number of Packet layer or mininet Switches = %d and"\
+ % packetLayerSWCount + " is wrong"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is wrong" )
+ packetSWResult = main.FALSE
+ print "_________________________________"
+
+ linksResult = main.ONOScli3.links( jsonFormat=False )
+ print "links_result = ", linksResult
+ print "_________________________________"
+ linkActiveCount = linksResult.count("state=ACTIVE")
+ main.log.info( "linkActiveCount = " + str( linkActiveCount ))
+ if linkActiveCount == 42:
+ linkActiveResult = main.TRUE
+ main.log.info(
+ "Number of links in ACTIVE state are correct")
+ else:
+ linkActiveResult = main.FALSE
+ main.log.info(
+ "Number of links in ACTIVE state are wrong")
+
+ case22Result = opticalSWResult and packetSWResult and \
+ linkActiveResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case22Result,
+ onpass="Packet optical topology discovery successful",
+ onfail="Packet optical topology discovery failed" )
+
+ def CASE23( self, main ):
+ import time
+ """
+ Add bidirectional point intents between 2 packet layer( mininet )
+ devices and
+ ping mininet hosts
+ """
+ main.log.report(
+ "This testcase adds bidirectional point intents between 2 " +
+ "packet layer( mininet ) devices and ping mininet hosts" )
+ main.case( "Topology comparision" )
+ main.step( "Adding point intents" )
+ ptpIntentResult = main.ONOScli1.addPointIntent(
+ "of:0000ffffffff0001/1",
+ "of:0000ffffffff0005/1" )
+ if ptpIntentResult == main.TRUE:
+ main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "Point to point intent install successful" )
+
+ ptpIntentResult = main.ONOScli1.addPointIntent(
+ "of:0000ffffffff0005/1",
+ "of:0000ffffffff0001/1" )
+ if ptpIntentResult == main.TRUE:
+ main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "Point to point intent install successful" )
+
+ time.sleep( 30 )
+ flowHandle = main.ONOScli1.flows()
+ main.log.info( "flows :" + flowHandle )
+
+ # Sleep for 30 seconds to provide time for the intent state to change
+ time.sleep( 60 )
+ intentHandle = main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "intents :" + intentHandle )
+
+ PingResult = main.TRUE
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ # ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count < 5:
+ count += 1
+ PingResult = main.FALSE
+ main.log.info(
+ "Ping between h1 and h5 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h5 passed!" )
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Point intents for packet optical have not ben installed" +
+ " correctly. Cleaning up" )
+ if PingResult == main.TRUE:
+ main.log.report(
+ "Point Intents for packet optical have been " +
+ "installed correctly" )
+
+ case23Result = PingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case23Result,
+ onpass= "Point intents addition for packet optical and" +
+ "Pingall Test successful",
+ onfail= "Point intents addition for packet optical and" +
+ "Pingall Test NOT successful" )
+
+ def CASE24( self, main ):
+ import time
+ import json
+ """
+ LINC uses its own switch IDs. You can use the following
+ command on the LINC console to find the mapping between
+ DPIDs and LINC IDs.
+ rp(application:get_all_key(linc)).
+
+ Test Rerouting of Packet Optical by bringing a port down
+ ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
+ so that link
+ ( between switch1 port20 - switch5 port50 ) is inactive
+ and do a ping test. If rerouting is successful,
+ ping should pass. also check the flows
+ """
+ main.log.report(
+ "This testcase tests rerouting and pings mininet hosts" )
+ main.case( "Test rerouting and pings mininet hosts" )
+ main.step( "Attach to the Linc-OE session" )
+ attachConsole = main.LincOE1.attachLincOESession()
+ print "attachConsole = ", attachConsole
+
+ main.step( "Bring a port down and verify the link state" )
+ main.LincOE1.portDown( swId="9", ptId="20" )
+ linksNonjson = main.ONOScli3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+
+ linkInactiveCount = linksNonjson.count("state=INACTIVE")
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 2:
+ main.log.info(
+ "Number of links in INACTIVE state are correct")
+ else:
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+
+ links = main.ONOScli3.links()
+ main.log.info( "links = " + links )
+
+ linksResult = json.loads( links )
+ linksStateResult = main.FALSE
+ for item in linksResult:
+ if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
+ 'src' ][ 'port' ] == "20":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
+ 'dst' ][ 'port' ] == "50":
+ linksState = item[ 'state' ]
+ if linksState == "INACTIVE":
+ main.log.info(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ main.log.report(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ linksStateResult = main.TRUE
+ break
+ else:
+ main.log.info(
+ "Links state is not inactive as expected" )
+ main.log.report(
+ "Links state is not inactive as expected" )
+ linksStateResult = main.FALSE
+
+ print "links_state_result = ", linksStateResult
+ time.sleep( 10 )
+ flowHandle = main.ONOScli3.flows()
+ main.log.info( "flows :" + flowHandle )
+
+ main.step( "Verify Rerouting by a ping test" )
+ PingResult = main.TRUE
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ # ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count < 5:
+ count += 1
+ PingResult = main.FALSE
+ main.log.info(
+ "Ping between h1 and h5 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h5 passed!" )
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.TRUE:
+ main.log.report( "Ping test successful " )
+ if PingResult == main.FALSE:
+ main.log.report( "Ping test failed" )
+
+ case24Result = PingResult and linksStateResult
+ utilities.assert_equals( expect=main.TRUE, actual=case24Result,
+ onpass="Packet optical rerouting successful",
+ onfail="Packet optical rerouting failed" )
+
+ def CASE25( self ):
+ """
+ Add host intents between 2 packet layer host
+ """
+ import time
+ import json
+ main.log.report( "Adding host intents between 2 packet layer host" )
+ main.hostMACs = []
+ main.hostId = []
+ #Listing host MAC addresses
+ for i in range( 1 , 7 ):
+ main.hostMACs.append( "00:00:00:00:00:" +
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
+ for macs in main.hostMACs:
+ main.hostId.append( macs + "/-1" )
+
+ host1 = main.hostId[ 0 ]
+ host2 = main.hostId[ 1 ]
+ intentsId = []
+ # Use arping to discover the hosts
+ main.LincOE2.arping( host = "h1" )
+ main.LincOE2.arping( host = "h2" )
+ # Adding host intent
+ main.log.step( "Adding host intents to h1 and h2" )
+ intent1 = main.ONOScli1.addHostIntent( hostIdOne = host1,
+ hostIdTwo = host2 )
+ intentsId.append( intent1 )
+ time.sleep( 5 )
+ intent2 = main.ONOScli1.addHostIntent( hostIdOne = host2,
+ hostIdTwo = host1 )
+ intentsId.append( intent2 )
+ # Checking intents state before pinging
+ main.log.step( "Checking intents state" )
+ time.sleep( 10 )
+ intentResult = main.ONOScli1.checkIntentState( intentsId = intentsId )
+ utilities.assert_equals( expect=main.TRUE, actual=intentResult,
+ onpass="All intents are in INSTALLED state ",
+ onfail="Some of the intents are not in " +
+ "INSTALLED state " )
+
+ # pinging h1 to h2 and then ping h2 to h1
+ main.log.step( "Pinging h1 and h2" )
+ pingResult = main.TRUE
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2",
+ target="h1" )
+
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+ onpass="Pinged successfully between h1 and h2",
+ onfail="Pinged failed between h1 and h2" )
+
+ case25Result = pingResult
+ utilities.assert_equals( expect=main.TRUE, actual=case25Result,
+ onpass="Add host intent successful",
+ onfail="Add host intent failed" )
diff --git a/TestON/tests/IpOpticalMulti/__init__.py b/TestON/tests/IpOpticalMulti/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/IpOpticalMulti/__init__.py
diff --git a/TestON/tests/MultiProd/MultiProd.params b/TestON/tests/MultiProd/MultiProd.params
index 4818d09..3767ab9 100755
--- a/TestON/tests/MultiProd/MultiProd.params
+++ b/TestON/tests/MultiProd/MultiProd.params
@@ -1,15 +1,19 @@
<PARAMS>
-
- <testcases>1,4,10,5,6,7,8,6,8,9,8,31,32,8,33,8</testcases>
+
+ <testcases>1,4,10,5,6,7,8,6,8,9,8,31,32,8,33,8,20,21,22,10,23,24</testcases>
#Environment variables
<ENV>
<cellName>multi_test</cellName>
</ENV>
+ <GIT>
+ <pull>False</pull>
+ </GIT>
+
<CTRL>
<ip1>10.128.20.11</ip1>
- <ip2>10.128.20.12</ip2>
- <ip3>10.128.20.13</ip3>
+ <ip2>10.128.20.12</ip2>
+ <ip3>10.128.20.13</ip3>
<port1>6633</port1>
<port2>6633</port2>
<port3>6633</port3>
diff --git a/TestON/tests/MultiProd/MultiProd.py b/TestON/tests/MultiProd/MultiProd.py
index aac631f..6bf405b 100644
--- a/TestON/tests/MultiProd/MultiProd.py
+++ b/TestON/tests/MultiProd/MultiProd.py
@@ -35,6 +35,7 @@
ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+ gitPull = main.params[ 'GIT' ][ 'pull' ]
main.case( "Setting up test environment" )
main.log.report(
@@ -52,19 +53,25 @@
main.step( "Removing raft logs before a clen installation of ONOS" )
removeLogResult = main.ONOSbench.onosRemoveRaftLogs()
- main.step( "Git checkout, pull and get version" )
- #main.ONOSbench.gitCheckout( "master" )
- gitPullResult = main.ONOSbench.gitPull()
- main.log.info( "git_pull_result = " + str( gitPullResult ))
- versionResult = main.ONOSbench.getVersion( report=True )
-
- if gitPullResult == 1:
- main.step( "Using mvn clean & install" )
- cleanInstallResult = main.ONOSbench.cleanInstall()
- # cleanInstallResult = main.TRUE
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.onosPackage()
+ main.step( "Git checkout and get version" )
+ main.ONOSbench.gitCheckout( "master" )
+ if gitPull == 'True':
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == 1:
+ main.step( "Using mvn clean & install" )
+ main.ONOSbench.cleanInstall()
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+ elif gitPullResult == 0:
+ main.log.report(
+ "Git Pull Failed, look into logs for detailed reason" )
+ main.cleanup()
+ main.exit()
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
+ else:
+ main.log.info( "Skipping git pull" )
+ main.ONOSbench.getVersion( report=True )
+ packageResult = main.TRUE
# main.step( "Creating a cell" )
# cellCreateResult = main.ONOSbench.createCellFile( **************
@@ -215,6 +222,14 @@
main.log.report( "Controller assignment successfull" )
else:
main.log.report( "Controller assignment failed" )
+ appInstallResult = main.TRUE
+ main.log.info( "Activating reactive forwarding app" )
+ appInstallResult = main.ONOScli1.activateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOScli1.apps() )
+ main.log.warn( main.ONOScli1.appIDs() )
+ time.sleep( 30 )
# REACTIVE FWD test
main.step( "Pingall" )
pingResult = main.FALSE
@@ -371,7 +386,6 @@
onpass="ONOS3 Switches view is correct",
onfail="ONOS3 Switches view is incorrect" )
- """
portsResults1 = main.Mininet1.comparePorts( MNTopo,
json.loads( ports1 ) )
utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
@@ -389,7 +403,7 @@
utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
onpass="ONOS3 Ports view is correct",
onfail="ONOS3 Ports view is incorrect" )
- """
+
linksResults1 = main.Mininet1.compareLinks(
MNTopo,
json.loads( links1 ) )
@@ -433,17 +447,17 @@
onfail="Topology Check Test NOT successful" )
def CASE10( self ):
+ import time
main.log.report(
"This testcase uninstalls the reactive forwarding app" )
main.log.report( "__________________________________" )
main.case( "Uninstalling reactive forwarding app" )
# Unistall onos-app-fwd app to disable reactive forwarding
- appUninstallResult1 = main.ONOScli1.featureUninstall(
- "onos-app-fwd" )
- appUninstallResult2 = main.ONOScli2.featureUninstall(
- "onos-app-fwd" )
- appUninstallResult3 = main.ONOScli3.featureUninstall(
- "onos-app-fwd" )
+ appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOScli1.apps() )
+ main.log.warn( main.ONOScli1.appIDs() )
main.log.info( "onos-app-fwd uninstalled" )
# After reactive forwarding is disabled,
@@ -453,9 +467,7 @@
hosts = main.ONOScli1.hosts()
main.log.info( hosts )
-
- case10Result = appUninstallResult1 and\
- appUninstallResult2 and appUninstallResult3
+ case10Result = appInstallResult
utilities.assertEquals(
expect=main.TRUE,
actual=case10Result,
@@ -504,6 +516,7 @@
hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
"00:00:00:00:00:1B/-1" )
"""
+ intentsId = []
for i in range( 8, 18 ):
main.log.info(
"Adding host intent between h" + str( i ) +
@@ -517,8 +530,14 @@
host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
+ intentsId.append( tmpResult )
+
+ checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
+ checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
+ checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
flowHandle = main.ONOScli1.flows()
+
main.log.info( "flows:" + flowHandle )
count = 1
@@ -571,6 +590,10 @@
if PingResult == main.TRUE:
main.log.report( "Host intents have been installed correctly" )
+ checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
+ checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
+ checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
+
case6Result = PingResult
utilities.assertEquals(
expect=main.TRUE,
@@ -637,8 +660,8 @@
main.step( "Determine the current number of switches and links" )
topologyOutput = main.ONOScli1.topology()
topologyResult = main.ONOSbench.getTopology( topologyOutput )
- activeSwitches = topologyResult[ 'deviceCount' ]
- links = topologyResult[ 'linkCount' ]
+ activeSwitches = topologyResult[ 'devices' ]
+ links = topologyResult[ 'links' ]
main.log.info(
"Currently there are %s switches and %s links" %
( str( activeSwitches ), str( links ) ) )
@@ -881,14 +904,20 @@
main.step(
"Iterate through the intentids list and remove each intent" )
for id in intentids:
- main.ONOScli1.removeIntent( intentId=id )
+ main.ONOScli1.removeIntent( intentId=id ,purge=True )
- intentResult = main.ONOScli1.intents( jsonFormat=False )
- main.log.info( "intent_result = " + intentResult )
+ remainingIntent = main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "Remaining intents " + remainingIntent )
+
case8Result = main.TRUE
-
+ intentResult = main.TRUE
+ if remainingIntent:
+ main.log.error( "There are still remaining intent" )
+ intentResult = main.FALSE
i = 8
+
PingResult = main.TRUE
+ """
while i < 18:
main.log.info(
"\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
@@ -903,7 +932,6 @@
else:
main.log.info( "Unknown error" )
PingResult = main.ERROR
-
# Note: If the ping result failed, that means the intents have been
# withdrawn correctly.
if PingResult == main.TRUE:
@@ -912,17 +940,17 @@
# main.exit()
if PingResult == main.FALSE:
main.log.report( "Host intents have been withdrawn correctly" )
+ """
+ case8Result = intentResult
- case8Result = case8Result and PingResult
-
- if case8Result == main.FALSE:
+ if case8Result == main.TRUE:
main.log.report( "Intent removal successful" )
else:
main.log.report( "Intent removal failed" )
- utilities.assertEquals( expect=main.FALSE, actual=case8Result,
- onpass="Intent removal test failed",
- onfail="Intent removal test successful" )
+ utilities.assertEquals( expect=main.TRUE, actual=case8Result,
+ onpass="Intent removal test successful",
+ onfail="Intent removal test failed" )
def CASE9( self ):
"""
@@ -941,28 +969,38 @@
main.step(
"Add point-to-point intents for mininet hosts" +
" h8 and h18 or ONOS hosts h8 and h12" )
+ macsDict = {}
+ for i in range( 1,29 ):
+ macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
+ print macsDict
+ # main.step(var1)
ptpIntentResult = main.ONOScli1.addPointIntent(
- "of:0000000000003008/1",
- "of:0000000000006018/1" )
+ ingressDevice="of:0000000000003008/1",
+ egressDevice="of:0000000000006018/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h8' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
ptpIntentResult = main.ONOScli1.addPointIntent(
- "of:0000000000006018/1",
- "of:0000000000003008/1" )
+ ingressDevice="of:0000000000006018/1",
+ egressDevice="of:0000000000003008/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h18' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts" +
- " h9 and h19 or ONOS hosts h9 and h13" )
+ var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
+ main.step(var2)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003009/1",
- "of:0000000000006019/1" )
+ "of:0000000000006019/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h9' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -970,18 +1008,22 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006019/1",
- "of:0000000000003009/1" )
+ "of:0000000000003009/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h19' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet" +
- " hosts h10 and h20 or ONOS hosts hA and h14" )
+ var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
+ main.step(var3)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003010/1",
- "of:0000000000006020/1" )
+ "of:0000000000006020/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h10' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -989,18 +1031,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006020/1",
- "of:0000000000003010/1" )
+ "of:0000000000003010/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h20' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet" +
- " hosts h11 and h21 or ONOS hosts hB and h15" )
+ var4 = "Add point intents for mininet hosts h11 and h21 or" +\
+ " ONOS hosts hB and h15"
+ main.case(var4)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003011/1",
- "of:0000000000006021/1" )
+ "of:0000000000006021/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h11' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1008,18 +1056,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006021/1",
- "of:0000000000003011/1" )
+ "of:0000000000003011/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h21' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet" +
- " hosts h12 and h22 or ONOS hosts hC and h16" )
+ var5 = "Add point intents for mininet hosts h12 and h22 " +\
+ "ONOS hosts hC and h16"
+ main.case(var5)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003012/1",
- "of:0000000000006022/1" )
+ "of:0000000000006022/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h12' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1027,18 +1081,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006022/1",
- "of:0000000000003012/1" )
+ "of:0000000000003012/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h22' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet " +
- "hosts h13 and h23 or ONOS hosts hD and h17" )
+ var6 = "Add point intents for mininet hosts h13 and h23 or" +\
+ " ONOS hosts hD and h17"
+ main.case(var6)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003013/1",
- "of:0000000000006023/1" )
+ "of:0000000000006023/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h13' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1046,18 +1106,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006023/1",
- "of:0000000000003013/1" )
+ "of:0000000000003013/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h23' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts" +
- " h14 and h24 or ONOS hosts hE and h18" )
+ var7 = "Add point intents for mininet hosts h14 and h24 or" +\
+ " ONOS hosts hE and h18"
+ main.case(var7)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003014/1",
- "of:0000000000006024/1" )
+ "of:0000000000006024/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h14' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1065,18 +1131,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006024/1",
- "of:0000000000003014/1" )
+ "of:0000000000003014/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h24' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts" +
- " h15 and h25 or ONOS hosts hF and h19" )
+ var8 = "Add point intents for mininet hosts h15 and h25 or" +\
+ " ONOS hosts hF and h19"
+ main.case(var8)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003015/1",
- "of:0000000000006025/1" )
+ "of:0000000000006025/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h15' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1084,18 +1156,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006025/1",
- "of:0000000000003015/1" )
+ "of:0000000000003015/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h25' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts" +
- " h16 and h26 or ONOS hosts h10 and h1A" )
+ var9 = "Add intents for mininet hosts h16 and h26 or" +\
+ " ONOS hosts h10 and h1A"
+ main.case(var9)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003016/1",
- "of:0000000000006026/1" )
+ "of:0000000000006026/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h16' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1103,37 +1181,41 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006026/1",
- "of:0000000000003016/1" )
+ "of:0000000000003016/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h26' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h17" +
- " and h27 or ONOS hosts h11 and h1B" )
+ var10 = "Add point intents for mininet hosts h17 and h27 or" +\
+ " ONOS hosts h11 and h1B"
+ main.case(var10)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003017/1",
- "of:0000000000006027/1" )
+ "of:0000000000006027/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h17' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
+ #main.log.info( getIntentResult )
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006027/1",
- "of:0000000000003017/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
+ "of:0000000000003017/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h27' ))
print(
"_______________________________________________________" +
"________________________________" )
flowHandle = main.ONOScli1.flows()
- # print "flowHandle = ", flowHandle
+ print "flowHandle = ", flowHandle
main.log.info( "flows :" + flowHandle )
count = 1
@@ -1226,13 +1308,13 @@
host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
for host in hostsJson:
if host[ 'id' ] == host1Id:
- ip1 = host[ 'ips' ][ 0 ]
+ ip1 = host[ 'ipAddresses' ][ 0 ]
ip1 = str( ip1 + "/32" )
- device1 = host[ 'location' ][ 'device' ]
+ device1 = host[ 'location' ][ 'elementId' ]
device1 = str( device1 + "/1" )
elif host[ 'id' ] == host2Id:
- ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
- device2 = host[ 'location' ][ "device" ]
+ ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
+ device2 = host[ 'location' ][ 'elementId' ]
device2 = str( device2 + "/1" )
pIntentResult1 = main.ONOScli1.addPointIntent(
@@ -1241,7 +1323,7 @@
ipSrc=ip1,
ipDst=ip2,
ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
+ ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ], )
getIntentResult = main.ONOScli1.intents( jsonFormat=False )
main.log.info( getIntentResult )
@@ -1256,7 +1338,7 @@
getIntentResult = main.ONOScli1.intents( jsonFormat=False )
main.log.info( getIntentResult )
- if ( pIntentResult1 and pIntentResult2 ) == main.TRUE:
+ if ( pIntentResult1 and pIntentResult2 ) :
# getIntentResult = main.ONOScli1.intents()
# main.log.info( getIntentResult )
main.log.info(
@@ -1322,7 +1404,7 @@
"Ping all test after Point intents related to" +
" SDN-IP matching on ICMP successful" )
- case31Result = PingResult and pIntentResult1 and pIntentResult2
+ case31Result = PingResult
utilities.assertEquals(
expect=main.TRUE,
actual=case31Result,
@@ -1378,13 +1460,13 @@
host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
for host in hostsJson:
if host[ 'id' ] == host1Id:
- ip1 = host[ 'ips' ][ 0 ]
+ ip1 = host[ 'ipAddresses' ][ 0 ]
ip1 = str( ip1 + "/32" )
- device1 = host[ 'location' ][ 'device' ]
+ device1 = host[ 'location' ][ 'elementId' ]
device1 = str( device1 + "/1" )
elif host[ 'id' ] == host2Id:
- ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
- device2 = host[ 'location' ][ "device" ]
+ ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
+ device2 = host[ 'location' ][ 'elementId' ]
device2 = str( device2 + "/1" )
pIntentResult1 = main.ONOScli1.addPointIntent(
@@ -1421,11 +1503,10 @@
ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
- pIntentResult = pIntentResult1 and pIntentResult2 and\
- pIntentResult3 and pIntentResult4
- if pIntentResult == main.TRUE:
- getIntentResult = main.ONOScli1.intents( jsonFormat=False )
- main.log.info( getIntentResult )
+ getIntentResult = main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( getIntentResult )
+ pIntentResult = main.TRUE
+ if getIntentResult:
main.log.report(
"Point intent related to SDN-IP matching" +
" on TCP install successful" )
@@ -1433,6 +1514,7 @@
main.log.report(
"Point intent related to SDN-IP matching" +
" on TCP install failed" )
+ pIntentResult = main.FALSE
iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
if iperfResult == main.TRUE:
@@ -1481,14 +1563,14 @@
"Installing multipoint to single point " +
"intent with rewrite mac address" )
main.step( "Uninstalling proxy arp app" )
- # Unistall onos-app-proxyarp app to disable reactive forwarding
- appUninstallResult1 = main.ONOScli1.featureUninstall(
- "onos-app-proxyarp" )
- appUninstallResult2 = main.ONOScli2.featureUninstall(
- "onos-app-proxyarp" )
- appUninstallResult3 = main.ONOScli3.featureUninstall(
- "onos-app-proxyarp" )
- main.log.info( "onos-app-proxyarp uninstalled" )
+ # deactivating proxyarp app
+ appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.proxyarp" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOScli1.apps() )
+ main.log.warn( main.ONOScli1.appIDs() )
+ time.sleep( 30 )
+ main.log.info( "onos-app-proxyarp deactivated" )
main.step( "Changing ipaddress of hosts h8,h9 and h18" )
main.Mininet1.changeIP(
@@ -1603,7 +1685,7 @@
" and h" +
str( i +
2 ) +
- "passed!" )
+ " passed!" )
PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
@@ -1629,3 +1711,388 @@
" intent addition with rewrite mac address successful",
onfail="Ping all test after multipoint to single point intent" +
" addition with rewrite mac address failed" )
+
+ def CASE20( self ):
+ """
+ Exit from mininet cli
+ reinstall ONOS
+ """
+ import time
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+
+ main.log.report( "This testcase exits the mininet cli and reinstalls" +
+ "ONOS to switch over to Packet Optical topology" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Disconnecting mininet and restarting ONOS" )
+ main.step( "Disconnecting mininet and restarting ONOS" )
+ mininetDisconnect = main.Mininet1.disconnect()
+ print "mininetDisconnect = ", mininetDisconnect
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ main.ONOSbench.onosRemoveRaftLogs()
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ time.sleep( 5 )
+ main.step( "Uninstalling ONOS package" )
+ onos1UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS1Ip)
+ onos2UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS2Ip)
+ onos3UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS3Ip)
+ onosUninstallResult = onos1UninstallResult and onos2UninstallResult \
+ and onos3UninstallResult
+ time.sleep( 15 )
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS1Ip )
+ onos2InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS2Ip )
+ onos3InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS3Ip )
+ onosInstallResult = onos1InstallResult and onos2InstallResult and\
+ onos3InstallResult
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Installing ONOS package successful" )
+ else:
+ main.log.report( "Installing ONOS package failed" )
+
+ time.sleep( 10 )
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ onos2Isup = main.ONOSbench.isup( ONOS2Ip )
+ onos3Isup = main.ONOSbench.isup( ONOS3Ip )
+ onosIsup = onos1Isup and onos2Isup and onos3Isup
+ if onosIsup == main.TRUE:
+ main.log.report( "ONOS instances are up and ready" )
+ else:
+ main.log.report( "ONOS instances may not be up" )
+
+ main.step( "Starting ONOS service" )
+ time.sleep( 10 )
+ startResult = main.TRUE
+ # startResult = main.ONOSbench.onosStart( ONOS1Ip )
+ startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
+ startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
+ startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
+ startResult = startcli1 and startcli2 and startcli3
+ if startResult == main.TRUE:
+ main.log.report( "ONOS cli starts properly" )
+ case20Result = mininetDisconnect and cellResult and verifyResult \
+ and onosInstallResult and onosIsup and startResult
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case20Result,
+ onpass= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS successful",
+ onfail= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS failed" )
+
+ def CASE21( self, main ):
+ """
+ On ONOS bench, run this command:
+ sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls>
+ which spawns packet optical topology and copies the links
+ json file to the onos instance.
+ Note that in case of Packet Optical, the links are not learnt
+ from the topology, instead the links are learnt
+ from the json config file
+ """
+ main.log.report(
+ "This testcase starts the packet layer topology and REST" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Starting LINC-OE and other components" )
+ main.step( "Starting LINC-OE and other components" )
+ main.log.info( "Activate optical app" )
+ appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ appCheck = appCheck and main.ONOScli2.appToIDCheck()
+ appCheck = appCheck and main.ONOScli3.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( "Checking ONOS application unsuccesful" )
+
+ ctrllerIP = []
+ ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] )
+ #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] )
+ #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] )
+ opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP )
+ case21Result = opticalMnScript and appInstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case21Result,
+ onpass="Packet optical topology spawned successsfully",
+ onfail="Packet optical topology spawning failed" )
+
+ def CASE22( self, main ):
+ """
+ Curretly we use, 10 optical switches(ROADM's) and
+ 6 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 10,
+ packetLayerSWCount variable = 6, hostCount=6 and
+ links=46.
+ All this is hardcoded in the testcase. If the topology changes,
+ these hardcoded values need to be changed
+ """
+ import time
+ main.log.report(
+ "This testcase compares the optical+packet topology against what" +
+ " is expected" )
+ main.case( "Topology comparision" )
+ main.step( "Topology comparision" )
+ devicesResult = main.ONOScli3.devices( jsonFormat=False )
+ time.sleep( 15 )
+ print "devices_result = ", devicesResult
+ devicesLinewise = devicesResult.split( "\n" )
+ roadmCount = 0
+ packetLayerSWCount = 0
+ for line in devicesLinewise:
+ components = line.split( "," )
+ availability = components[ 1 ].split( "=" )[ 1 ]
+ type = components[ 3 ].split( "=" )[ 1 ]
+ if availability == 'true' and type == 'ROADM':
+ roadmCount += 1
+ elif availability == 'true' and type == 'SWITCH':
+ packetLayerSWCount += 1
+ if roadmCount == 10:
+ print "Number of Optical Switches = %d and is" % roadmCount +\
+ " correctly detected"
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is correctly detected" )
+ opticalSWResult = main.TRUE
+ else:
+ print "Number of Optical Switches = %d and is wrong" % roadmCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is wrong" )
+ opticalSWResult = main.FALSE
+
+ if packetLayerSWCount == 6:
+ print "Number of Packet layer or mininet Switches = %d "\
+ % packetLayerSWCount + "and is correctly detected"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is correctly detected" )
+ packetSWResult = main.TRUE
+ else:
+ print "Number of Packet layer or mininet Switches = %d and"\
+ % packetLayerSWCount + " is wrong"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is wrong" )
+ packetSWResult = main.FALSE
+ print "_________________________________"
+
+ linksResult = main.ONOScli3.links( jsonFormat=False )
+ print "links_result = ", linksResult
+ print "_________________________________"
+ linkActiveCount = linksResult.count("state=ACTIVE")
+ main.log.info( "linkActiveCount = " + str( linkActiveCount ))
+ if linkActiveCount == 46:
+ linkActiveResult = main.TRUE
+ main.log.info(
+ "Number of links in ACTIVE state are correct")
+ else:
+ linkActiveResult = main.FALSE
+ main.log.info(
+ "Number of links in ACTIVE state are wrong")
+
+ case22Result = opticalSWResult and packetSWResult and \
+ linkActiveResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case22Result,
+ onpass="Packet optical topology discovery successful",
+ onfail="Packet optical topology discovery failed" )
+
+ def CASE23( self, main ):
+ import time
+ """
+ Add bidirectional point intents between 2 packet layer( mininet )
+ devices and
+ ping mininet hosts
+ """
+ main.log.report(
+ "This testcase adds bidirectional point intents between 2 " +
+ "packet layer( mininet ) devices and ping mininet hosts" )
+ main.case( "Topology comparision" )
+ main.step( "Adding point intents" )
+ ptpIntentResult = main.ONOScli1.addPointIntent(
+ "of:0000ffffffff0001/1",
+ "of:0000ffffffff0005/1" )
+ if ptpIntentResult == main.TRUE:
+ main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "Point to point intent install successful" )
+
+ ptpIntentResult = main.ONOScli1.addPointIntent(
+ "of:0000ffffffff0005/1",
+ "of:0000ffffffff0001/1" )
+ if ptpIntentResult == main.TRUE:
+ main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "Point to point intent install successful" )
+
+ time.sleep( 30 )
+ #flowHandle = main.ONOScli1.flows()
+ #main.log.info( "flows :" + flowHandle )
+
+ # Sleep for 30 seconds to provide time for the intent state to change
+ time.sleep( 60 )
+ intentHandle = main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "intents :" + intentHandle )
+
+ PingResult = main.TRUE
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ # ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count < 5:
+ count += 1
+ PingResult = main.FALSE
+ main.log.info(
+ "Ping between h1 and h5 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h5 passed!" )
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Point intents for packet optical have not ben installed" +
+ " correctly. Cleaning up" )
+ if PingResult == main.TRUE:
+ main.log.report(
+ "Point Intents for packet optical have been " +
+ "installed correctly" )
+
+ case23Result = PingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case23Result,
+ onpass= "Point intents addition for packet optical and" +
+ "Pingall Test successful",
+ onfail= "Point intents addition for packet optical and" +
+ "Pingall Test NOT successful" )
+
+ def CASE24( self, main ):
+ import time
+ import json
+ """
+ LINC uses its own switch IDs. You can use the following
+ command on the LINC console to find the mapping between
+ DPIDs and LINC IDs.
+ rp(application:get_all_key(linc)).
+
+ Test Rerouting of Packet Optical by bringing a port down
+ ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
+ so that link
+ ( between switch1 port20 - switch5 port50 ) is inactive
+ and do a ping test. If rerouting is successful,
+ ping should pass. also check the flows
+ """
+ main.log.report(
+ "This testcase tests rerouting and pings mininet hosts" )
+ main.case( "Test rerouting and pings mininet hosts" )
+ main.step( "Attach to the Linc-OE session" )
+ attachConsole = main.LincOE1.attachLincOESession()
+ print "attachConsole = ", attachConsole
+
+ main.step( "Bring a port down and verify the link state" )
+ main.LincOE1.portDown( swId="9", ptId="20" )
+ linksNonjson = main.ONOScli3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+
+ linkInactiveCount = linksNonjson.count("state=INACTIVE")
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 2:
+ main.log.info(
+ "Number of links in INACTIVE state are correct")
+ else:
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+
+ links = main.ONOScli3.links()
+ main.log.info( "links = " + links )
+
+ linksResult = json.loads( links )
+ linksStateResult = main.FALSE
+ for item in linksResult:
+ if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
+ 'src' ][ 'port' ] == "20":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
+ 'dst' ][ 'port' ] == "50":
+ linksState = item[ 'state' ]
+ if linksState == "INACTIVE":
+ main.log.info(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ main.log.report(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ linksStateResult = main.TRUE
+ break
+ else:
+ main.log.info(
+ "Links state is not inactive as expected" )
+ main.log.report(
+ "Links state is not inactive as expected" )
+ linksStateResult = main.FALSE
+
+ print "links_state_result = ", linksStateResult
+ time.sleep( 10 )
+ #flowHandle = main.ONOScli3.flows()
+ #main.log.info( "flows :" + flowHandle )
+
+ main.step( "Verify Rerouting by a ping test" )
+ PingResult = main.TRUE
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ # ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count < 5:
+ count += 1
+ PingResult = main.FALSE
+ main.log.info(
+ "Ping between h1 and h5 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h5 passed!" )
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.TRUE:
+ main.log.report( "Ping test successful " )
+ if PingResult == main.FALSE:
+ main.log.report( "Ping test failed" )
+
+ case24Result = PingResult and linksStateResult
+ utilities.assert_equals( expect=main.TRUE, actual=case24Result,
+ onpass="Packet optical rerouting successful",
+ onfail="Packet optical rerouting failed" )
diff --git a/TestON/tests/MultiProd/MultiProd.topo b/TestON/tests/MultiProd/MultiProd.topo
index 28dfa92..040ec67 100755
--- a/TestON/tests/MultiProd/MultiProd.topo
+++ b/TestON/tests/MultiProd/MultiProd.topo
@@ -94,5 +94,25 @@
<controller> remote </controller>
</COMPONENTS>
</Mininet2>
+
+ <LincOE1>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>LincOEDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </LincOE1>
+
+ <LincOE2>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </LincOE2>
</COMPONENT>
</TOPOLOGY>
diff --git a/TestON/tests/MultiProd13/MultiProd13.params b/TestON/tests/MultiProd13/MultiProd13.params
index 6e5c85e..3767ab9 100755
--- a/TestON/tests/MultiProd13/MultiProd13.params
+++ b/TestON/tests/MultiProd13/MultiProd13.params
@@ -1,16 +1,19 @@
<PARAMS>
-
- <testcases>1,4,10,5,6,7,8,6,8,9,8,31,32,8,33,8</testcases>
+ <testcases>1,4,10,5,6,7,8,6,8,9,8,31,32,8,33,8,20,21,22,10,23,24</testcases>
#Environment variables
<ENV>
<cellName>multi_test</cellName>
</ENV>
+ <GIT>
+ <pull>False</pull>
+ </GIT>
+
<CTRL>
<ip1>10.128.20.11</ip1>
- <ip2>10.128.20.12</ip2>
- <ip3>10.128.20.13</ip3>
+ <ip2>10.128.20.12</ip2>
+ <ip3>10.128.20.13</ip3>
<port1>6633</port1>
<port2>6633</port2>
<port3>6633</port3>
diff --git a/TestON/tests/MultiProd13/MultiProd13.py b/TestON/tests/MultiProd13/MultiProd13.py
index 6c0b8d7..ee62ce7 100644
--- a/TestON/tests/MultiProd13/MultiProd13.py
+++ b/TestON/tests/MultiProd13/MultiProd13.py
@@ -35,6 +35,7 @@
ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+ gitPull = main.params[ 'GIT' ][ 'pull' ]
main.case( "Setting up test environment" )
main.log.report(
@@ -52,19 +53,25 @@
main.step( "Removing raft logs before a clen installation of ONOS" )
removeLogResult = main.ONOSbench.onosRemoveRaftLogs()
- main.step( "Git checkout, pull and get version" )
- #main.ONOSbench.gitCheckout( "master" )
- gitPullResult = main.ONOSbench.gitPull()
- main.log.info( "git_pull_result = " + str( gitPullResult ))
- versionResult = main.ONOSbench.getVersion( report=True )
-
- if gitPullResult == 1:
- main.step( "Using mvn clean & install" )
- cleanInstallResult = main.ONOSbench.cleanInstall()
- # cleanInstallResult = main.TRUE
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.onosPackage()
+ main.step( "Git checkout and get version" )
+ main.ONOSbench.gitCheckout( "master" )
+ if gitPull == 'True':
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == 1:
+ main.step( "Using mvn clean & install" )
+ main.ONOSbench.cleanInstall()
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+ elif gitPullResult == 0:
+ main.log.report(
+ "Git Pull Failed, look into logs for detailed reason" )
+ main.cleanup()
+ main.exit()
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
+ else:
+ main.log.info( "Skipping git pull" )
+ main.ONOSbench.getVersion( report=True )
+ packageResult = main.TRUE
# main.step( "Creating a cell" )
# cellCreateResult = main.ONOSbench.createCellFile( **************
@@ -215,6 +222,14 @@
main.log.report( "Controller assignment successfull" )
else:
main.log.report( "Controller assignment failed" )
+ appInstallResult = main.TRUE
+ main.log.info( "Activating reactive forwarding app" )
+ appInstallResult = main.ONOScli1.activateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOScli1.apps() )
+ main.log.warn( main.ONOScli1.appIDs() )
+ time.sleep( 30 )
# REACTIVE FWD test
main.step( "Pingall" )
pingResult = main.FALSE
@@ -248,7 +263,7 @@
ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
main.log.report(
- "This testcase is testing if all ONOS nodes are in topologyi" +
+ "This testcase is testing if all ONOS nodes are in topology" +
" sync with mininet and its peer ONOS nodes" )
main.log.report( "__________________________________" )
main.case(
@@ -371,7 +386,6 @@
onpass="ONOS3 Switches view is correct",
onfail="ONOS3 Switches view is incorrect" )
- """
portsResults1 = main.Mininet1.comparePorts( MNTopo,
json.loads( ports1 ) )
utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
@@ -389,7 +403,7 @@
utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
onpass="ONOS3 Ports view is correct",
onfail="ONOS3 Ports view is incorrect" )
- """
+
linksResults1 = main.Mininet1.compareLinks(
MNTopo,
json.loads( links1 ) )
@@ -433,17 +447,17 @@
onfail="Topology Check Test NOT successful" )
def CASE10( self ):
+ import time
main.log.report(
"This testcase uninstalls the reactive forwarding app" )
main.log.report( "__________________________________" )
main.case( "Uninstalling reactive forwarding app" )
# Unistall onos-app-fwd app to disable reactive forwarding
- appUninstallResult1 = main.ONOScli1.featureUninstall(
- "onos-app-fwd" )
- appUninstallResult2 = main.ONOScli2.featureUninstall(
- "onos-app-fwd" )
- appUninstallResult3 = main.ONOScli3.featureUninstall(
- "onos-app-fwd" )
+ appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOScli1.apps() )
+ main.log.warn( main.ONOScli1.appIDs() )
main.log.info( "onos-app-fwd uninstalled" )
# After reactive forwarding is disabled,
@@ -453,9 +467,7 @@
hosts = main.ONOScli1.hosts()
main.log.info( hosts )
-
- case10Result = appUninstallResult1 and\
- appUninstallResult2 and appUninstallResult3
+ case10Result = appInstallResult
utilities.assertEquals(
expect=main.TRUE,
actual=case10Result,
@@ -504,6 +516,7 @@
hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
"00:00:00:00:00:1B/-1" )
"""
+ intentsId = []
for i in range( 8, 18 ):
main.log.info(
"Adding host intent between h" + str( i ) +
@@ -517,8 +530,14 @@
host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
+ intentsId.append( tmpResult )
+
+ checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
+ checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
+ checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
flowHandle = main.ONOScli1.flows()
+
main.log.info( "flows:" + flowHandle )
count = 1
@@ -571,6 +590,10 @@
if PingResult == main.TRUE:
main.log.report( "Host intents have been installed correctly" )
+ checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
+ checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
+ checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
+
case6Result = PingResult
utilities.assertEquals(
expect=main.TRUE,
@@ -637,8 +660,8 @@
main.step( "Determine the current number of switches and links" )
topologyOutput = main.ONOScli1.topology()
topologyResult = main.ONOSbench.getTopology( topologyOutput )
- activeSwitches = topologyResult[ 'deviceCount' ]
- links = topologyResult[ 'linkCount' ]
+ activeSwitches = topologyResult[ 'devices' ]
+ links = topologyResult[ 'links' ]
main.log.info(
"Currently there are %s switches and %s links" %
( str( activeSwitches ), str( links ) ) )
@@ -881,14 +904,20 @@
main.step(
"Iterate through the intentids list and remove each intent" )
for id in intentids:
- main.ONOScli1.removeIntent( intentId=id )
+ main.ONOScli1.removeIntent( intentId=id ,purge=True )
- intentResult = main.ONOScli1.intents( jsonFormat=False )
- main.log.info( "intent_result = " + intentResult )
+ remainingIntent = main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "Remaining intents " + remainingIntent )
+
case8Result = main.TRUE
-
+ intentResult = main.TRUE
+ if remainingIntent:
+ main.log.error( "There are still remaining intent" )
+ intentResult = main.FALSE
i = 8
+
PingResult = main.TRUE
+ """
while i < 18:
main.log.info(
"\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
@@ -903,7 +932,6 @@
else:
main.log.info( "Unknown error" )
PingResult = main.ERROR
-
# Note: If the ping result failed, that means the intents have been
# withdrawn correctly.
if PingResult == main.TRUE:
@@ -912,17 +940,17 @@
# main.exit()
if PingResult == main.FALSE:
main.log.report( "Host intents have been withdrawn correctly" )
+ """
+ case8Result = intentResult
- case8Result = case8Result and PingResult
-
- if case8Result == main.FALSE:
+ if case8Result == main.TRUE:
main.log.report( "Intent removal successful" )
else:
main.log.report( "Intent removal failed" )
- utilities.assertEquals( expect=main.FALSE, actual=case8Result,
- onpass="Intent removal test failed",
- onfail="Intent removal test successful" )
+ utilities.assertEquals( expect=main.TRUE, actual=case8Result,
+ onpass="Intent removal test successful",
+ onfail="Intent removal test failed" )
def CASE9( self ):
"""
@@ -941,28 +969,38 @@
main.step(
"Add point-to-point intents for mininet hosts" +
" h8 and h18 or ONOS hosts h8 and h12" )
+ macsDict = {}
+ for i in range( 1,29 ):
+ macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
+ print macsDict
+ # main.step(var1)
ptpIntentResult = main.ONOScli1.addPointIntent(
- "of:0000000000003008/1",
- "of:0000000000006018/1" )
+ ingressDevice="of:0000000000003008/1",
+ egressDevice="of:0000000000006018/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h8' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
ptpIntentResult = main.ONOScli1.addPointIntent(
- "of:0000000000006018/1",
- "of:0000000000003008/1" )
+ ingressDevice="of:0000000000006018/1",
+ egressDevice="of:0000000000003008/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h18' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts" +
- " h9 and h19 or ONOS hosts h9 and h13" )
+ var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
+ main.step(var2)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003009/1",
- "of:0000000000006019/1" )
+ "of:0000000000006019/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h9' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -970,18 +1008,22 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006019/1",
- "of:0000000000003009/1" )
+ "of:0000000000003009/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h19' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet" +
- " hosts h10 and h20 or ONOS hosts hA and h14" )
+ var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
+ main.step(var3)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003010/1",
- "of:0000000000006020/1" )
+ "of:0000000000006020/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h10' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -989,18 +1031,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006020/1",
- "of:0000000000003010/1" )
+ "of:0000000000003010/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h20' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet" +
- " hosts h11 and h21 or ONOS hosts hB and h15" )
+ var4 = "Add point intents for mininet hosts h11 and h21 or" +\
+ " ONOS hosts hB and h15"
+ main.case(var4)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003011/1",
- "of:0000000000006021/1" )
+ "of:0000000000006021/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h11' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1008,18 +1056,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006021/1",
- "of:0000000000003011/1" )
+ "of:0000000000003011/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h21' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet" +
- " hosts h12 and h22 or ONOS hosts hC and h16" )
+ var5 = "Add point intents for mininet hosts h12 and h22 " +\
+ "ONOS hosts hC and h16"
+ main.case(var5)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003012/1",
- "of:0000000000006022/1" )
+ "of:0000000000006022/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h12' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1027,18 +1081,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006022/1",
- "of:0000000000003012/1" )
+ "of:0000000000003012/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h22' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet " +
- "hosts h13 and h23 or ONOS hosts hD and h17" )
+ var6 = "Add point intents for mininet hosts h13 and h23 or" +\
+ " ONOS hosts hD and h17"
+ main.case(var6)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003013/1",
- "of:0000000000006023/1" )
+ "of:0000000000006023/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h13' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1046,18 +1106,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006023/1",
- "of:0000000000003013/1" )
+ "of:0000000000003013/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h23' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts" +
- " h14 and h24 or ONOS hosts hE and h18" )
+ var7 = "Add point intents for mininet hosts h14 and h24 or" +\
+ " ONOS hosts hE and h18"
+ main.case(var7)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003014/1",
- "of:0000000000006024/1" )
+ "of:0000000000006024/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h14' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1065,18 +1131,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006024/1",
- "of:0000000000003014/1" )
+ "of:0000000000003014/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h24' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts" +
- " h15 and h25 or ONOS hosts hF and h19" )
+ var8 = "Add point intents for mininet hosts h15 and h25 or" +\
+ " ONOS hosts hF and h19"
+ main.case(var8)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003015/1",
- "of:0000000000006025/1" )
+ "of:0000000000006025/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h15' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1084,18 +1156,24 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006025/1",
- "of:0000000000003015/1" )
+ "of:0000000000003015/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h25' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts" +
- " h16 and h26 or ONOS hosts h10 and h1A" )
+ var9 = "Add intents for mininet hosts h16 and h26 or" +\
+ " ONOS hosts h10 and h1A"
+ main.case(var9)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003016/1",
- "of:0000000000006026/1" )
+ "of:0000000000006026/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h16' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
@@ -1103,37 +1181,41 @@
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006026/1",
- "of:0000000000003016/1" )
+ "of:0000000000003016/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h26' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h17" +
- " and h27 or ONOS hosts h11 and h1B" )
+ var10 = "Add point intents for mininet hosts h17 and h27 or" +\
+ " ONOS hosts h11 and h1B"
+ main.case(var10)
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000003017/1",
- "of:0000000000006027/1" )
+ "of:0000000000006027/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h17' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOScli1.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
+ #main.log.info( getIntentResult )
ptpIntentResult = main.ONOScli1.addPointIntent(
"of:0000000000006027/1",
- "of:0000000000003017/1" )
- if ptpIntentResult == main.TRUE:
- getIntentResult = main.ONOScli1.intents()
- main.log.info( "Point to point intent install successful" )
- # main.log.info( getIntentResult )
+ "of:0000000000003017/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h27' ))
print(
"_______________________________________________________" +
"________________________________" )
flowHandle = main.ONOScli1.flows()
- # print "flowHandle = ", flowHandle
+ print "flowHandle = ", flowHandle
main.log.info( "flows :" + flowHandle )
count = 1
@@ -1226,13 +1308,13 @@
host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
for host in hostsJson:
if host[ 'id' ] == host1Id:
- ip1 = host[ 'ips' ][ 0 ]
+ ip1 = host[ 'ipAddresses' ][ 0 ]
ip1 = str( ip1 + "/32" )
- device1 = host[ 'location' ][ 'device' ]
+ device1 = host[ 'location' ][ 'elementId' ]
device1 = str( device1 + "/1" )
elif host[ 'id' ] == host2Id:
- ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
- device2 = host[ 'location' ][ "device" ]
+ ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
+ device2 = host[ 'location' ][ 'elementId' ]
device2 = str( device2 + "/1" )
pIntentResult1 = main.ONOScli1.addPointIntent(
@@ -1241,7 +1323,7 @@
ipSrc=ip1,
ipDst=ip2,
ethType=main.params[ 'SDNIP' ][ 'ethType' ],
- ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
+ ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ], )
getIntentResult = main.ONOScli1.intents( jsonFormat=False )
main.log.info( getIntentResult )
@@ -1256,7 +1338,7 @@
getIntentResult = main.ONOScli1.intents( jsonFormat=False )
main.log.info( getIntentResult )
- if ( pIntentResult1 and pIntentResult2 ) == main.TRUE:
+ if ( pIntentResult1 and pIntentResult2 ) :
# getIntentResult = main.ONOScli1.intents()
# main.log.info( getIntentResult )
main.log.info(
@@ -1322,7 +1404,7 @@
"Ping all test after Point intents related to" +
" SDN-IP matching on ICMP successful" )
- case31Result = PingResult and pIntentResult1 and pIntentResult2
+ case31Result = PingResult
utilities.assertEquals(
expect=main.TRUE,
actual=case31Result,
@@ -1378,13 +1460,13 @@
host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
for host in hostsJson:
if host[ 'id' ] == host1Id:
- ip1 = host[ 'ips' ][ 0 ]
+ ip1 = host[ 'ipAddresses' ][ 0 ]
ip1 = str( ip1 + "/32" )
- device1 = host[ 'location' ][ 'device' ]
+ device1 = host[ 'location' ][ 'elementId' ]
device1 = str( device1 + "/1" )
elif host[ 'id' ] == host2Id:
- ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
- device2 = host[ 'location' ][ "device" ]
+ ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
+ device2 = host[ 'location' ][ 'elementId' ]
device2 = str( device2 + "/1" )
pIntentResult1 = main.ONOScli1.addPointIntent(
@@ -1421,11 +1503,10 @@
ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
- pIntentResult = pIntentResult1 and pIntentResult2 and\
- pIntentResult3 and pIntentResult4
- if pIntentResult == main.TRUE:
- getIntentResult = main.ONOScli1.intents( jsonFormat=False )
- main.log.info( getIntentResult )
+ getIntentResult = main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( getIntentResult )
+ pIntentResult = main.TRUE
+ if getIntentResult:
main.log.report(
"Point intent related to SDN-IP matching" +
" on TCP install successful" )
@@ -1433,6 +1514,7 @@
main.log.report(
"Point intent related to SDN-IP matching" +
" on TCP install failed" )
+ pIntentResult = main.FALSE
iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
if iperfResult == main.TRUE:
@@ -1481,14 +1563,14 @@
"Installing multipoint to single point " +
"intent with rewrite mac address" )
main.step( "Uninstalling proxy arp app" )
- # Unistall onos-app-proxyarp app to disable reactive forwarding
- appUninstallResult1 = main.ONOScli1.featureUninstall(
- "onos-app-proxyarp" )
- appUninstallResult2 = main.ONOScli2.featureUninstall(
- "onos-app-proxyarp" )
- appUninstallResult3 = main.ONOScli3.featureUninstall(
- "onos-app-proxyarp" )
- main.log.info( "onos-app-proxyarp uninstalled" )
+ # deactivating proxyarp app
+ appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.proxyarp" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOScli1.apps() )
+ main.log.warn( main.ONOScli1.appIDs() )
+ time.sleep( 30 )
+ main.log.info( "onos-app-proxyarp deactivated" )
main.step( "Changing ipaddress of hosts h8,h9 and h18" )
main.Mininet1.changeIP(
@@ -1603,7 +1685,7 @@
" and h" +
str( i +
2 ) +
- "passed!" )
+ " passed!" )
PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
@@ -1629,3 +1711,388 @@
" intent addition with rewrite mac address successful",
onfail="Ping all test after multipoint to single point intent" +
" addition with rewrite mac address failed" )
+
+ def CASE20( self ):
+ """
+ Exit from mininet cli
+ reinstall ONOS
+ """
+ import time
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
+ ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
+ ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
+
+ main.log.report( "This testcase exits the mininet cli and reinstalls" +
+ "ONOS to switch over to Packet Optical topology" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Disconnecting mininet and restarting ONOS" )
+ main.step( "Disconnecting mininet and restarting ONOS" )
+ mininetDisconnect = main.Mininet1.disconnect()
+ print "mininetDisconnect = ", mininetDisconnect
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ main.ONOSbench.onosRemoveRaftLogs()
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ time.sleep( 5 )
+ main.step( "Uninstalling ONOS package" )
+ onos1UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS1Ip)
+ onos2UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS2Ip)
+ onos3UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS3Ip)
+ onosUninstallResult = onos1UninstallResult and onos2UninstallResult \
+ and onos3UninstallResult
+ time.sleep( 15 )
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS1Ip )
+ onos2InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS2Ip )
+ onos3InstallResult = main.ONOSbench.onosInstall(
+ options="-f",
+ node=ONOS3Ip )
+ onosInstallResult = onos1InstallResult and onos2InstallResult and\
+ onos3InstallResult
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Installing ONOS package successful" )
+ else:
+ main.log.report( "Installing ONOS package failed" )
+
+ time.sleep( 10 )
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ onos2Isup = main.ONOSbench.isup( ONOS2Ip )
+ onos3Isup = main.ONOSbench.isup( ONOS3Ip )
+ onosIsup = onos1Isup and onos2Isup and onos3Isup
+ if onosIsup == main.TRUE:
+ main.log.report( "ONOS instances are up and ready" )
+ else:
+ main.log.report( "ONOS instances may not be up" )
+
+ main.step( "Starting ONOS service" )
+ time.sleep( 10 )
+ startResult = main.TRUE
+ # startResult = main.ONOSbench.onosStart( ONOS1Ip )
+ startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
+ startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
+ startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
+ startResult = startcli1 and startcli2 and startcli3
+ if startResult == main.TRUE:
+ main.log.report( "ONOS cli starts properly" )
+ case20Result = mininetDisconnect and cellResult and verifyResult \
+ and onosInstallResult and onosIsup and startResult
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case20Result,
+ onpass= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS successful",
+ onfail= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS failed" )
+
+ def CASE21( self, main ):
+ """
+ On ONOS bench, run this command:
+ sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls>
+ which spawns packet optical topology and copies the links
+ json file to the onos instance.
+ Note that in case of Packet Optical, the links are not learnt
+ from the topology, instead the links are learnt
+ from the json config file
+ """
+ main.log.report(
+ "This testcase starts the packet layer topology and REST" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Starting LINC-OE and other components" )
+ main.step( "Starting LINC-OE and other components" )
+ main.log.info( "Activate optical app" )
+ appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ appCheck = appCheck and main.ONOScli2.appToIDCheck()
+ appCheck = appCheck and main.ONOScli3.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( "Checking ONOS application unsuccesful" )
+
+ ctrllerIP = []
+ ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] )
+ #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] )
+ #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] )
+ opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP )
+ case21Result = opticalMnScript and appInstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case21Result,
+ onpass="Packet optical topology spawned successsfully",
+ onfail="Packet optical topology spawning failed" )
+
+ def CASE22( self, main ):
+ """
+ Curretly we use, 10 optical switches(ROADM's) and
+ 6 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 10,
+ packetLayerSWCount variable = 6, hostCount=6 and
+ links=46.
+ All this is hardcoded in the testcase. If the topology changes,
+ these hardcoded values need to be changed
+ """
+ import time
+ main.log.report(
+ "This testcase compares the optical+packet topology against what" +
+ " is expected" )
+ main.case( "Topology comparision" )
+ main.step( "Topology comparision" )
+ devicesResult = main.ONOScli3.devices( jsonFormat=False )
+ time.sleep( 15 )
+ print "devices_result = ", devicesResult
+ devicesLinewise = devicesResult.split( "\n" )
+ roadmCount = 0
+ packetLayerSWCount = 0
+ for line in devicesLinewise:
+ components = line.split( "," )
+ availability = components[ 1 ].split( "=" )[ 1 ]
+ type = components[ 3 ].split( "=" )[ 1 ]
+ if availability == 'true' and type == 'ROADM':
+ roadmCount += 1
+ elif availability == 'true' and type == 'SWITCH':
+ packetLayerSWCount += 1
+ if roadmCount == 10:
+ print "Number of Optical Switches = %d and is" % roadmCount +\
+ " correctly detected"
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is correctly detected" )
+ opticalSWResult = main.TRUE
+ else:
+ print "Number of Optical Switches = %d and is wrong" % roadmCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is wrong" )
+ opticalSWResult = main.FALSE
+
+ if packetLayerSWCount == 6:
+ print "Number of Packet layer or mininet Switches = %d "\
+ % packetLayerSWCount + "and is correctly detected"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is correctly detected" )
+ packetSWResult = main.TRUE
+ else:
+ print "Number of Packet layer or mininet Switches = %d and"\
+ % packetLayerSWCount + " is wrong"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is wrong" )
+ packetSWResult = main.FALSE
+ print "_________________________________"
+
+ linksResult = main.ONOScli3.links( jsonFormat=False )
+ print "links_result = ", linksResult
+ print "_________________________________"
+ linkActiveCount = linksResult.count("state=ACTIVE")
+ main.log.info( "linkActiveCount = " + str( linkActiveCount ))
+ if linkActiveCount == 46:
+ linkActiveResult = main.TRUE
+ main.log.info(
+ "Number of links in ACTIVE state are correct")
+ else:
+ linkActiveResult = main.FALSE
+ main.log.info(
+ "Number of links in ACTIVE state are wrong")
+
+ case22Result = opticalSWResult and packetSWResult and \
+ linkActiveResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case22Result,
+ onpass="Packet optical topology discovery successful",
+ onfail="Packet optical topology discovery failed" )
+
+ def CASE23( self, main ):
+ import time
+ """
+ Add bidirectional point intents between 2 packet layer( mininet )
+ devices and
+ ping mininet hosts
+ """
+ main.log.report(
+ "This testcase adds bidirectional point intents between 2 " +
+ "packet layer( mininet ) devices and ping mininet hosts" )
+ main.case( "Topology comparision" )
+ main.step( "Adding point intents" )
+ ptpIntentResult = main.ONOScli1.addPointIntent(
+ "of:0000ffffffff0001/1",
+ "of:0000ffffffff0005/1" )
+ if ptpIntentResult == main.TRUE:
+ main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "Point to point intent install successful" )
+
+ ptpIntentResult = main.ONOScli1.addPointIntent(
+ "of:0000ffffffff0005/1",
+ "of:0000ffffffff0001/1" )
+ if ptpIntentResult == main.TRUE:
+ main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "Point to point intent install successful" )
+
+ time.sleep( 30 )
+ #flowHandle = main.ONOScli1.flows()
+ #main.log.info( "flows :" + flowHandle )
+
+ # Sleep for 30 seconds to provide time for the intent state to change
+ time.sleep( 60 )
+ intentHandle = main.ONOScli1.intents( jsonFormat=False )
+ main.log.info( "intents :" + intentHandle )
+
+ PingResult = main.TRUE
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ # ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count < 5:
+ count += 1
+ PingResult = main.FALSE
+ main.log.info(
+ "Ping between h1 and h5 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h5 passed!" )
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Point intents for packet optical have not ben installed" +
+ " correctly. Cleaning up" )
+ if PingResult == main.TRUE:
+ main.log.report(
+ "Point Intents for packet optical have been " +
+ "installed correctly" )
+
+ case23Result = PingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case23Result,
+ onpass= "Point intents addition for packet optical and" +
+ "Pingall Test successful",
+ onfail= "Point intents addition for packet optical and" +
+ "Pingall Test NOT successful" )
+
+ def CASE24( self, main ):
+ import time
+ import json
+ """
+ LINC uses its own switch IDs. You can use the following
+ command on the LINC console to find the mapping between
+ DPIDs and LINC IDs.
+ rp(application:get_all_key(linc)).
+
+ Test Rerouting of Packet Optical by bringing a port down
+ ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
+ so that link
+ ( between switch1 port20 - switch5 port50 ) is inactive
+ and do a ping test. If rerouting is successful,
+ ping should pass. also check the flows
+ """
+ main.log.report(
+ "This testcase tests rerouting and pings mininet hosts" )
+ main.case( "Test rerouting and pings mininet hosts" )
+ main.step( "Attach to the Linc-OE session" )
+ attachConsole = main.LincOE1.attachLincOESession()
+ print "attachConsole = ", attachConsole
+
+ main.step( "Bring a port down and verify the link state" )
+ main.LincOE1.portDown( swId="9", ptId="20" )
+ linksNonjson = main.ONOScli3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+
+ linkInactiveCount = linksNonjson.count("state=INACTIVE")
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 2:
+ main.log.info(
+ "Number of links in INACTIVE state are correct")
+ else:
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+
+ links = main.ONOScli3.links()
+ main.log.info( "links = " + links )
+
+ linksResult = json.loads( links )
+ linksStateResult = main.FALSE
+ for item in linksResult:
+ if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
+ 'src' ][ 'port' ] == "20":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
+ 'dst' ][ 'port' ] == "50":
+ linksState = item[ 'state' ]
+ if linksState == "INACTIVE":
+ main.log.info(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ main.log.report(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ linksStateResult = main.TRUE
+ break
+ else:
+ main.log.info(
+ "Links state is not inactive as expected" )
+ main.log.report(
+ "Links state is not inactive as expected" )
+ linksStateResult = main.FALSE
+
+ print "links_state_result = ", linksStateResult
+ time.sleep( 10 )
+ #flowHandle = main.ONOScli3.flows()
+ #main.log.info( "flows :" + flowHandle )
+
+ main.step( "Verify Rerouting by a ping test" )
+ PingResult = main.TRUE
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ # ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count < 5:
+ count += 1
+ PingResult = main.FALSE
+ main.log.info(
+ "Ping between h1 and h5 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h5 passed!" )
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.TRUE:
+ main.log.report( "Ping test successful " )
+ if PingResult == main.FALSE:
+ main.log.report( "Ping test failed" )
+
+ case24Result = PingResult and linksStateResult
+ utilities.assert_equals( expect=main.TRUE, actual=case24Result,
+ onpass="Packet optical rerouting successful",
+ onfail="Packet optical rerouting failed" )
diff --git a/TestON/tests/MultiProd13/MultiProd13.topo b/TestON/tests/MultiProd13/MultiProd13.topo
index a4fad91..4b1ab12 100755
--- a/TestON/tests/MultiProd13/MultiProd13.topo
+++ b/TestON/tests/MultiProd13/MultiProd13.topo
@@ -94,5 +94,25 @@
<controller> remote </controller>
</COMPONENTS>
</Mininet2>
+
+ <LincOE1>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>LincOEDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </LincOE1>
+
+ <LincOE2>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </LincOE2>
</COMPONENT>
</TOPOLOGY>
diff --git a/TestON/tests/ProdFunc/ProdFunc.params b/TestON/tests/ProdFunc/ProdFunc.params
index 4367bf4..c8e125b 100755
--- a/TestON/tests/ProdFunc/ProdFunc.params
+++ b/TestON/tests/ProdFunc/ProdFunc.params
@@ -1,11 +1,13 @@
<PARAMS>
-
+ #1,4,10,5,6,7,8,9,8,11,8,20,21,22,10,23,24
<testcases>1,4,10,5,6,7,8,9,8,11,8,2,20,21,22,10,23,24</testcases>
#Environment variables
<ENV>
<cellName>driver_test</cellName>
</ENV>
-
+ <GIT>
+ <pull>True</pull>
+ </GIT>
<CTRL>
<ip1>10.128.20.11</ip1>
<port1>6633</port1>
diff --git a/TestON/tests/ProdFunc/ProdFunc.py b/TestON/tests/ProdFunc/ProdFunc.py
index f779b6b..adbdb24 100644
--- a/TestON/tests/ProdFunc/ProdFunc.py
+++ b/TestON/tests/ProdFunc/ProdFunc.py
@@ -31,6 +31,7 @@
"""
cellName = main.params[ 'ENV' ][ 'cellName' ]
ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ gitPull = main.params[ 'GIT' ][ 'pull' ]
main.case( "Setting up test environment" )
main.log.report(
@@ -41,44 +42,54 @@
cellResult = main.ONOSbench.setCell( cellName )
verifyResult = main.ONOSbench.verifyCell()
- main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onosRemoveRaftLogs()
-
main.step( "Git checkout and get version" )
- #main.ONOSbench.gitCheckout( "master" )
- gitPullResult = main.ONOSbench.gitPull()
- main.log.info( "git_pull_result = " + str( gitPullResult ))
+ main.ONOSbench.gitCheckout( "master" )
+ if gitPull == 'True':
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == 1:
+ main.step( "Using mvn clean & install" )
+ main.ONOSbench.cleanInstall()
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+ elif gitPullResult == 0:
+ main.log.report(
+ "Git Pull Failed, look into logs for detailed reason" )
+ main.cleanup()
+ main.exit()
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
+ else:
+ main.log.info( "Skipping git pull" )
main.ONOSbench.getVersion( report=True )
+ packageResult = main.TRUE
- if gitPullResult == 1:
- main.step( "Using mvn clean & install" )
- main.ONOSbench.cleanInstall()
- elif gitPullResult == 0:
- main.log.report(
- "Git Pull Failed, look into logs for detailed reason" )
- main.cleanup()
- main.exit()
+ main.step( "Uninstalling ONOS package" )
+ onosInstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Uninstalling ONOS package successful" )
+ else:
+ main.log.report( "Uninstalling ONOS package failed" )
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.onosPackage()
-
+ time.sleep( 20 )
main.step( "Installing ONOS package" )
- onosInstallResult = main.ONOSbench.onosInstall()
+ onosInstallResult = main.ONOSbench.onosInstall( ONOS1Ip )
+ print onosInstallResult
if onosInstallResult == main.TRUE:
main.log.report( "Installing ONOS package successful" )
else:
main.log.report( "Installing ONOS package failed" )
+ time.sleep( 20 )
onos1Isup = main.ONOSbench.isup()
if onos1Isup == main.TRUE:
main.log.report( "ONOS instance is up and ready" )
else:
main.log.report( "ONOS instance may not be up" )
- main.step( "Starting ONOS service" )
- startResult = main.ONOSbench.onosStart( ONOS1Ip )
+ startResult = main.TRUE
+ #main.step( "Starting ONOS service" )
+ #startResult = main.ONOSbench.onosStart( ONOS1Ip )
- main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.ONOS2.startOnosCli( ONOS1Ip )
main.step( "Starting Mininet CLI..." )
# Starting the mininet using the old way
@@ -183,6 +194,7 @@
Exit from mininet cli
reinstall ONOS
"""
+ import time
cellName = main.params[ 'ENV' ][ 'cellName' ]
ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
@@ -190,22 +202,60 @@
"ONOS to switch over to Packet Optical topology" )
main.log.report( "_____________________________________________" )
main.case( "Disconnecting mininet and restarting ONOS" )
+
main.step( "Disconnecting mininet and restarting ONOS" )
+ step1Result = main.TRUE
mininetDisconnect = main.Mininet1.disconnect()
- print "mininetDisconnect = ", mininetDisconnect
-
- main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onosRemoveRaftLogs()
-
+ print "mininetDisconnect = ", mininetDisconnect
+ step1Result = mininetDisconnect
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Mininet disconnect successfully",
+ onfail="Mininet failed to disconnect")
+ """
+ main.step( "Removing raft logs before a clean installation of ONOS" )
+ step2Result = main.TRUE
+ removeRaftLogsResult = main.ONOSbench.onosRemoveRaftLogs()
+ step2Result = removeRaftLogsResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Raft logs removed successfully",
+ onfail="Failed to remove raft logs")
+ """
main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- verifyResult = main.ONOSbench.verifyCell()
+ step3Result = main.TRUE
+ setCellResult = main.ONOSbench.setCell( cellName )
+ verifyCellResult = main.ONOSbench.verifyCell()
+ step3Result = setCellResult and verifyCellResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step3Result,
+ onpass="Cell applied successfully",
+ onfail="Failed to apply cell")
- onosInstallResult = main.ONOSbench.onosInstall()
- if onosInstallResult == main.TRUE:
- main.log.report( "Installing ONOS package successful" )
- else:
- main.log.report( "Installing ONOS package failed" )
+ main.step( "Uninstalling ONOS package" )
+ step4Result = main.TRUE
+ ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ]
+ onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1)
+ step4Result = onosUninstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully uninstalled ONOS",
+ onfail="Failed to uninstall ONOS")
+
+ time.sleep( 5 )
+ main.step( "Installing ONOS package" )
+ step5Result = main.TRUE
+ onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 )
+ step5Result = onosInstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step5Result,
+ onpass="Successfully installed ONOS",
+ onfail="Failed to install ONOS")
onos1Isup = main.ONOSbench.isup()
if onos1Isup == main.TRUE:
@@ -214,19 +264,24 @@
main.log.report( "ONOS instance may not be up" )
main.step( "Starting ONOS service" )
+ step6Result = main.TRUE
startResult = main.ONOSbench.onosStart( ONOS1Ip )
-
- main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- case20Result = mininetDisconnect and cellResult and verifyResult \
- and onosInstallResult and onos1Isup and \
- startResult
+ step6Result = startResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case20Result,
- onpass= "Exiting functionality mininet topology and reinstalling" +
- " ONOS successful",
- onfail= "Exiting functionality mininet topology and reinstalling" +
- " ONOS failed" )
+ actual=step6Result,
+ onpass="Successfully started ONOS",
+ onfail="Failed to start ONOS")
+
+ main.step( "Starting ONOS cli" )
+ step7Result = main.TRUE
+ cliResult = main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ step7Result = cliResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step7Result,
+ onpass="Successfully started ONOS cli",
+ onfail="Failed to start ONOS cli")
def CASE21( self, main ):
"""
@@ -238,20 +293,37 @@
from the topology, instead the links are learnt
from the json config file
"""
+ import time
main.log.report(
"This testcase starts the packet layer topology and REST" )
main.log.report( "_____________________________________________" )
main.case( "Starting LINC-OE and other components" )
- main.step( "Starting LINC-OE and other components" )
- appInstallResult = main.ONOS2.featureInstall( "onos-app-optical" )
- opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
- case21Result = opticalMnScript and appInstallResult
+ main.step( "Activate optical app" )
+ step1Result = main.TRUE
+ activateOpticalResult = main.ONOS2.activateApp( "org.onosproject.optical" )
+ step1Result = activateOpticalResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case21Result,
- onpass="Packet optical topology spawned successsfully",
- onfail="Packet optical topology spawning failed" )
+ actual=step1Result,
+ onpass="Successfully activated optical app",
+ onfail="Failed to activate optical app")
+
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
+
+ main.step( "Starting mininet and LINC-OE" )
+ step2Result = main.TRUE
+ time.sleep( 10 )
+ opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
+ step2Result = opticalMnScript
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Started the topology successfully ",
+ onfail="Failed to start the topology")
def CASE22( self, main ):
"""
@@ -259,21 +331,32 @@
6 packet layer mininet switches each with one host.
Therefore, the roadmCount variable = 10,
packetLayerSWCount variable = 6, hostCount=6 and
- links=42.
+ links=46.
All this is hardcoded in the testcase. If the topology changes,
these hardcoded values need to be changed
"""
+ import time
main.log.report(
"This testcase compares the optical+packet topology against what" +
" is expected" )
main.case( "Topology comparision" )
- main.step( "Topology comparision" )
- main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- devicesResult = main.ONOS3.devices( jsonFormat=False )
- print "devices_result = ", devicesResult
+ main.step( "Starts new ONOS cli" )
+ step1Result = main.TRUE
+ cliResult = main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ]\
+ [ 'ip1' ] )
+ step1Result = cliResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully starts a new cli",
+ onfail="Failed to start new cli" )
+
+ main.step( "Compare topology" )
+ step2Result = main.TRUE
+ devicesResult = main.ONOS3.devices( jsonFormat=False )
+ print "devices_result :\n", devicesResult
devicesLinewise = devicesResult.split( "\n" )
- devicesLinewise = devicesLinewise[ 1: ]
roadmCount = 0
packetLayerSWCount = 0
for line in devicesLinewise:
@@ -299,7 +382,6 @@
str( roadmCount ) +
" and is wrong" )
opticalSWResult = main.FALSE
-
if packetLayerSWCount == 6:
print "Number of Packet layer or mininet Switches = %d "\
% packetLayerSWCount + "and is correctly detected"
@@ -316,14 +398,15 @@
str( packetLayerSWCount ) +
" and is wrong" )
packetSWResult = main.FALSE
+ # sleeps for sometime so the state of the switches will be active
+ time.sleep( 30 )
print "_________________________________"
-
linksResult = main.ONOS3.links( jsonFormat=False )
print "links_result = ", linksResult
print "_________________________________"
- linkActiveCount = linksResult.count("state=ACTIVE")
+ linkActiveCount = linksResult.count("state=ACTIVE")
main.log.info( "linkActiveCount = " + str( linkActiveCount ))
- if linkActiveCount == 42:
+ if linkActiveCount == 46:
linkActiveResult = main.TRUE
main.log.info(
"Number of links in ACTIVE state are correct")
@@ -331,41 +414,13 @@
linkActiveResult = main.FALSE
main.log.info(
"Number of links in ACTIVE state are wrong")
-
- # NOTE:Since only point intents are added, there is no
- # requirement to discover the hosts
- # Therfore, the below portion of the code is commented.
- """
- #Discover hosts using pingall
- pingallResult = main.LincOE2.pingall()
-
- hostsResult = main.ONOS3.hosts( jsonFormat=False )
- main.log.info( "hosts_result = "+hostsResult )
- main.log.info( "_________________________________" )
- hostsLinewise = hostsResult.split( "\n" )
- hostsLinewise = hostsLinewise[ 1:-1 ]
- hostCount = 0
- for line in hostsLinewise:
- hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
- hostCount +=1
- if hostCount ==2:
- print "Number of hosts = %d and is correctly detected" %hostCount
- main.log.info( "Number of hosts = " + str( hostCount ) +" and \
- is correctly detected" )
- hostDiscovery = main.TRUE
- else:
- print "Number of hosts = %d and is wrong" %hostCount
- main.log.info( "Number of hosts = " + str( hostCount ) +" and \
- is wrong" )
- hostDiscovery = main.FALSE
- """
- case22Result = opticalSWResult and packetSWResult and \
+ step2Result = opticalSWResult and packetSWResult and \
linkActiveResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case22Result,
- onpass="Packet optical topology discovery successful",
- onfail="Packet optical topology discovery failed" )
+ actual=step2Result,
+ onpass="Successfully loaded packet optical topology",
+ onfail="Failed to load packet optical topology" )
def CASE23( self, main ):
import time
@@ -377,71 +432,50 @@
main.log.report(
"This testcase adds bidirectional point intents between 2 " +
"packet layer( mininet ) devices and ping mininet hosts" )
- main.case( "Topology comparision" )
+ main.case( "Install point intents between 2 packet layer device and " +
+ "ping the hosts" )
+
main.step( "Adding point intents" )
- ptpIntentResult = main.ONOS3.addPointIntent(
+ checkFlowResult = main.TRUE
+ step1Result = main.TRUE
+ main.pIntentsId = []
+ pIntent1 = main.ONOS3.addPointIntent(
"of:0000ffffffff0001/1",
"of:0000ffffffff0005/1" )
- if ptpIntentResult == main.TRUE:
- main.ONOS3.intents( jsonFormat=False )
- main.log.info( "Point to point intent install successful" )
-
- ptpIntentResult = main.ONOS3.addPointIntent(
+ pIntent2 = main.ONOS3.addPointIntent(
"of:0000ffffffff0005/1",
"of:0000ffffffff0001/1" )
- if ptpIntentResult == main.TRUE:
- main.ONOS3.intents( jsonFormat=False )
- main.log.info( "Point to point intent install successful" )
-
- time.sleep( 30 )
- flowHandle = main.ONOS3.flows()
- main.log.info( "flows :" + flowHandle )
-
+ main.pIntentsId.append( pIntent1 )
+ main.pIntentsId.append( pIntent2 )
+ time.sleep( 10 )
+ main.log.info( "Checking intents state")
+ checkStateResult = main.ONOS3.checkIntentState(
+ intentsId = main.pIntentsId )
+ time.sleep( 10 )
+ main.log.info( "Checking flows state")
+ checkFlowResult = main.ONOS3.checkFlowsState()
# Sleep for 30 seconds to provide time for the intent state to change
- time.sleep( 60 )
- intentHandle = main.ONOS3.intents( jsonFormat=False )
- main.log.info( "intents :" + intentHandle )
-
- PingResult = main.TRUE
- count = 1
- main.log.info( "\n\nh1 is Pinging h5" )
- ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
- # ping = main.LincOE2.pinghost()
- if ping == main.FALSE and count < 5:
- count += 1
- PingResult = main.FALSE
- main.log.info(
- "Ping between h1 and h5 failed. Making attempt number " +
- str( count ) +
- " in 2 seconds" )
- time.sleep( 2 )
- elif ping == main.FALSE:
- main.log.info( "All ping attempts between h1 and h5 have failed" )
- PingResult = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h1 and h5 passed!" )
- PingResult = main.TRUE
- else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
-
- if PingResult == main.FALSE:
- main.log.report(
- "Point intents for packet optical have not ben installed" +
- " correctly. Cleaning up" )
- if PingResult == main.TRUE:
- main.log.report(
- "Point Intents for packet optical have been " +
- "installed correctly" )
-
- case23Result = PingResult
+ time.sleep( 10 )
+ main.log.info( "Checking intents state one more time")
+ checkStateResult = main.ONOS3.checkIntentState(
+ intentsId = main.pIntentsId )
+ step1Result = checkStateResult and checkFlowResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case23Result,
- onpass= "Point intents addition for packet optical and" +
- "Pingall Test successful",
- onfail= "Point intents addition for packet optical and" +
- "Pingall Test NOT successful" )
+ actual=step1Result,
+ onpass="Successfully added point intents",
+ onfail="Failed to add point intents")
+
+ main.step( "Ping h1 and h5" )
+ step2Result = main.TRUE
+ main.log.info( "\n\nh1 is Pinging h5" )
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ step2Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Successfully pinged h1 and h5",
+ onfail="Failed to ping between h1 and h5")
def CASE24( self, main ):
import time
@@ -462,16 +496,23 @@
main.log.report(
"This testcase tests rerouting and pings mininet hosts" )
main.case( "Test rerouting and pings mininet hosts" )
+
main.step( "Attach to the Linc-OE session" )
- attachConsole = main.LincOE1.attachLincOESession()
- print "attachConsole = ", attachConsole
+ step1Result = main.TRUE
+ attachConsole = main.LincOE1.attachLincOESession()
+ step1Result = attachConsole
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully attached Linc-OE session",
+ onfail="Failed to attached Linc-OE session")
main.step( "Bring a port down and verify the link state" )
+ step2Result = main.TRUE
main.LincOE1.portDown( swId="9", ptId="20" )
linksNonjson = main.ONOS3.links( jsonFormat=False )
main.log.info( "links = " + linksNonjson )
-
- linkInactiveCount = linksNonjson.count("state=INACTIVE")
+ linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
if linkInactiveCount == 2:
main.log.info(
@@ -479,10 +520,8 @@
else:
main.log.info(
"Number of links in INACTIVE state are wrong")
-
links = main.ONOS3.links()
main.log.info( "links = " + links )
-
linksResult = json.loads( links )
linksStateResult = main.FALSE
for item in linksResult:
@@ -506,45 +545,184 @@
main.log.report(
"Links state is not inactive as expected" )
linksStateResult = main.FALSE
-
- print "links_state_result = ", linksStateResult
time.sleep( 10 )
- flowHandle = main.ONOS3.flows()
- main.log.info( "flows :" + flowHandle )
+ checkFlowsState = main.ONOS3.checkFlowsState()
+ step2Result = linksStateResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Successfuly brought down a link",
+ onfail="Failed to bring down a link")
main.step( "Verify Rerouting by a ping test" )
- PingResult = main.TRUE
- count = 1
+ step3Result = main.TRUE
main.log.info( "\n\nh1 is Pinging h5" )
- ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
- # ping = main.LincOE2.pinghost()
- if ping == main.FALSE and count < 5:
- count += 1
- PingResult = main.FALSE
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ step3Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step3Result,
+ onpass="Successfully pinged h1 and h5",
+ onfail="Failed to ping between h1 and h5")
+
+ main.step( "Bring the downed port up and verify the link state" )
+ step4Result = main.TRUE
+ main.LincOE1.portUp( swId="9", ptId="20" )
+ linksNonjson = main.ONOS3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+ linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 0:
main.log.info(
- "Ping between h1 and h5 failed. Making attempt number " +
- str( count ) +
- " in 2 seconds" )
- time.sleep( 2 )
- elif ping == main.FALSE:
- main.log.info( "All ping attempts between h1 and h5 have failed" )
- PingResult = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h1 and h5 passed!" )
- PingResult = main.TRUE
+ "Number of links in INACTIVE state are correct")
else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+ step4Result = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully brought the port up",
+ onfail="Failed to bring the port up")
+ """
+ main.step( "Removing host intents" )
+ step5Result = main.TRUE
+ removeResult = main.TRUE
+ # Check remaining intents
+ intentsJson = json.loads( main.ONOS3.intents() )
+ main.ONOS3.removeIntent( intentId=intent1, purge=True )
+ main.ONOS3.removeIntent( intentId=intent2, purge=True )
+ for intents in intentsJson:
+ main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
+ app='org.onosproject.optical',
+ purge=True )
+ print json.loads( main.ONOS3.intents() )
+ if len( json.loads( main.ONOS3.intents() ) ):
+ removeResult = main.FALSE
+ step5Result = removeResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step5Result,
+ onpass="Successfully removed host intents",
+ onfail="Failed to remove host intents" )
+ """
+ def CASE10( self ):
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ main.step( "Uninstalling reactive forwarding app" )
+ step1Result = main.TRUE
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ main.log.info( "deactivate reactive forwarding app" )
+ appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
+ step1Result = appUninstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully deactivate reactive forwarding app",
+ onfail="Failed to deactivate reactive forwarding app")
+ # After reactive forwarding is disabled, the reactive flows on
+ # switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
+ flows = main.ONOS2.flows()
+ main.log.info( flows )
- if PingResult == main.TRUE:
- main.log.report( "Ping test successful " )
- if PingResult == main.FALSE:
- main.log.report( "Ping test failed" )
+ def CASE25( self ):
+ """
+ Add host intents between 2 packet layer host
+ """
+ import time
+ import json
+ main.log.report( "Adding host intents between 2 optical layer host" )
+ main.case( "Test add host intents between optical layer host" )
- case24Result = PingResult and linksStateResult
- utilities.assert_equals( expect=main.TRUE, actual=case24Result,
- onpass="Packet optical rerouting successful",
- onfail="Packet optical rerouting failed" )
+ main.step( "Discover host using arping" )
+ step1Result = main.TRUE
+ main.hostMACs = []
+ main.hostId = []
+ #Listing host MAC addresses
+ for i in range( 1 , 7 ):
+ main.hostMACs.append( "00:00:00:00:00:" +
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
+ for macs in main.hostMACs:
+ main.hostId.append( macs + "/-1" )
+ host1 = main.hostId[ 0 ]
+ host2 = main.hostId[ 1 ]
+ # Use arping to discover the hosts
+ main.LincOE2.arping( host = "h1" )
+ main.LincOE2.arping( host = "h2" )
+ time.sleep( 5 )
+ hostsDict = main.ONOS3.hosts()
+ if not len( hostsDict ):
+ step1Result = main.FALSE
+ # Adding host intent
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Hosts discovered",
+ onfail="Failed to discover hosts")
+
+ main.step( "Adding host intents to h1 and h2" )
+ step2Result = main.TRUE
+ intentsId = []
+ intent1 = main.ONOS3.addHostIntent( hostIdOne = host1,
+ hostIdTwo = host2 )
+ intentsId.append( intent1 )
+ time.sleep( 5 )
+ intent2 = main.ONOS3.addHostIntent( hostIdOne = host2,
+ hostIdTwo = host1 )
+ intentsId.append( intent2 )
+ # Checking intents state before pinging
+ main.log.info( "Checking intents state" )
+ time.sleep( 15 )
+ intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
+ #check intent state again if intents are not in installed state
+ if not intentResult:
+ intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
+ step2Result = intentResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step2Result,
+ onpass="All intents are in INSTALLED state ",
+ onfail="Some of the intents are not in " +
+ "INSTALLED state " )
+
+ # pinging h1 to h2 and then ping h2 to h1
+ main.step( "Pinging h1 and h2" )
+ step3Result = main.TRUE
+ pingResult = main.TRUE
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2",
+ target="h1" )
+ step3Result = pingResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step3Result,
+ onpass="Pinged successfully between h1 and h2",
+ onfail="Pinged failed between h1 and h2" )
+ # Removed all added host intents
+ main.step( "Removing host intents" )
+ step4Result = main.TRUE
+ removeResult = main.TRUE
+ # Check remaining intents
+ intentsJson = json.loads( main.ONOS3.intents() )
+ main.ONOS3.removeIntent( intentId=intent1, purge=True )
+ main.ONOS3.removeIntent( intentId=intent2, purge=True )
+ for intents in intentsJson:
+ main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
+ app='org.onosproject.optical',
+ purge=True )
+ print json.loads( main.ONOS3.intents() )
+ if len( json.loads( main.ONOS3.intents() ) ):
+ removeResult = main.FALSE
+ step4Result = removeResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully removed host intents",
+ onfail="Failed to remove host intents" )
def CASE4( self, main ):
import re
@@ -553,6 +731,7 @@
" all the switches to all the controllers and" +
" discovering the hosts in reactive mode" )
main.log.report( "__________________________________" )
+
main.case( "Pingall Test" )
main.step( "Assigning switches to controllers" )
ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
@@ -651,6 +830,13 @@
ip5=ONOS5Ip,port5=ONOS5Port )
"""
# REACTIVE FWD test
+ main.log.info( "Activate fwd app" )
+ appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
+ time.sleep( 10 )
main.step( "Get list of hosts from Mininet" )
hostList = main.Mininet1.getHosts()
@@ -687,31 +873,6 @@
onpass="Controller assignment and Pingall Test successful",
onfail="Controller assignment and Pingall Test NOT successful" )
- def CASE10( self ):
- main.log.report(
- "This testcase uninstalls the reactive forwarding app" )
- main.log.report( "__________________________________" )
- main.case( "Uninstalling reactive forwarding app" )
- # Unistall onos-app-fwd app to disable reactive forwarding
- appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
- main.log.info( "onos-app-fwd uninstalled" )
-
- # After reactive forwarding is disabled, the reactive flows on
- # switches timeout in 10-15s
- # So sleep for 15s
- time.sleep( 15 )
-
- flows = main.ONOS2.flows()
- main.log.info( flows )
-
- case10Result = appUninstallResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case10Result,
- onpass="Reactive forwarding app uninstallation successful",
- onfail="Reactive forwarding app uninstallation failed" )
-
-
def CASE11( self ):
# NOTE: This testcase require reactive forwarding mode enabled
# NOTE: in the beginning and then uninstall it before adding
@@ -727,26 +888,40 @@
main.step( "Moving host h9 from device s9 and attach it to s8" )
main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
- time.sleep(15) #Time delay to have all the flows ready
+ main.log.info( "Activate fwd app" )
+ appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
+
+ time.sleep(25) #Time delay to have all the flows ready
main.step( "Pingall" )
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingall()
+ pingResult = main.Mininet1.pingall( timeout=120,
+ shortCircuit=True,
+ acceptableFailed=20 )
time2 = time.time()
print "Time for pingall: %2f seconds" % ( time2 - time1 )
hosts = main.ONOS2.hosts( jsonFormat = False )
main.log.info( hosts )
- main.case( "Uninstalling reactive forwarding app" )
- # Unistall onos-app-fwd app to disable reactive forwarding
- appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
- main.log.info( "onos-app-fwd uninstalled" )
+ main.log.info( "deactivate reactive forwarding app" )
+ appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
main.step( "Add point intents between hosts on the same device")
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003008/1",
- "of:0000000000003008/3" )
+ "of:0000000000003008/3",
+ ethType='IPV4',
+ ethSrc='00:00:00:00:00:08',
+ ethDst='00:00:00:00:00:09' )
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -754,7 +929,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003008/3",
- "of:0000000000003008/1" )
+ "of:0000000000003008/1",
+ ethType='IPV4',
+ ethSrc='00:00:00:00:00:09',
+ ethDst='00:00:00:00:00:08' )
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -779,7 +957,7 @@
"Point intents for hosts on same devices" +
"installed correctly. Cleaning up" )
- case11Result = ping and pingResult
+ case11Result = ping
utilities.assert_equals(
expect = main.TRUE,
actual = case11Result,
@@ -788,7 +966,6 @@
onfail = "Point intents for hosts on same devices" +
"Ping Test NOT successful" )
-
def CASE12( self ):
"""
Verify the default flows on each switch in proactive mode
@@ -855,6 +1032,7 @@
"00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
print "______________________________________________________"
"""
+ intentsId = []
for i in range( 8, 18 ):
main.log.info(
"Adding host intent between h" + str( i ) +
@@ -869,8 +1047,9 @@
if host2:
host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
if host1Id and host2Id:
- main.ONOS2.addHostIntent( host1Id, host2Id )
+ intentsId.append( main.ONOS2.addHostIntent( host1Id, host2Id ) )
+ checkIntentResult = main.ONOS2.checkIntentState( intentsId )
time.sleep( 10 )
hIntents = main.ONOS2.intents( jsonFormat=False )
main.log.info( "intents:" + hIntents )
@@ -929,6 +1108,8 @@
main.log.report(
"Ping all test after Host intent addition successful" )
+ checkIntentResult = main.ONOS2.checkIntentState( intentsId )
+
case6Result = PingResult
utilities.assert_equals(
expect=main.TRUE,
@@ -1016,7 +1197,7 @@
main.step( "Compare ONOS Topology to MN Topology" )
devicesJson = main.ONOS2.devices()
linksJson = main.ONOS2.links()
- # portsJson = main.ONOS2.ports()
+ portsJson = main.ONOS2.ports()
result1 = main.Mininet1.compareSwitches(
MNTopo,
@@ -1024,9 +1205,8 @@
result2 = main.Mininet1.compareLinks(
MNTopo,
json.loads( linksJson ) )
- # result3 = main.Mininet1.comparePorts(
- # MNTopo, json.loads( portsJson ) )
+ result3 = main.Mininet1.comparePorts( MNTopo, json.loads( portsJson ) )
# result = result1 and result2 and result3
result = result1 and result2
@@ -1105,8 +1285,8 @@
main.step( "Determine the current number of switches and links" )
topologyOutput = main.ONOS2.topology()
topologyResult = main.ONOS1.getTopology( topologyOutput )
- activeSwitches = topologyResult[ 'deviceCount' ]
- links = topologyResult[ 'linkCount' ]
+ activeSwitches = topologyResult[ 'devices' ]
+ links = topologyResult[ 'links' ]
print "activeSwitches = ", type( activeSwitches )
print "links = ", type( links )
main.log.info(
@@ -1169,8 +1349,7 @@
result2 = main.Mininet1.compareLinks(
MNTopo,
json.loads( linksJson ) )
- # result3 = main.Mininet1.comparePorts(
- # MNTopo, json.loads( portsJson ) )
+ result3 = main.Mininet1.comparePorts( MNTopo, json.loads( portsJson ) )
# result = result1 and result2 and result3
result = result1 and result2
@@ -1209,9 +1388,9 @@
main.log.info( "intent removal" )
main.case( "Removing installed intents" )
main.step( "Obtain the intent id's" )
- intentResult = main.ONOS2.intents( jsonFormat=False )
- main.log.info( "intent_result = " + intentResult )
- intentLinewise = intentResult.split( "\n" )
+ currentIntents = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + currentIntents )
+ intentLinewise = currentIntents.split( "\n" )
intentList = [line for line in intentLinewise \
if line.startswith( "id=")]
@@ -1223,30 +1402,31 @@
main.step(
"Iterate through the intentids list and remove each intent" )
for id in intentids:
- main.ONOS2.removeIntent( intentId=id )
+ main.ONOS2.removeIntent( intentId=id ,purge=True)
- intentResult = main.ONOS2.intents( jsonFormat=False )
- main.log.info( "intent_result = " + intentResult )
-
- intentList = [line for line in intentResult.split( "\n" ) \
+ remainingIntents = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + remainingIntents )
+ if remainingIntents:
+ main.log.info( "There are still remaining intents " )
+ intentResult = main.FALSE
+ else:
+ intentResult = main.TRUE
+
+ intentList = [line for line in remainingIntents.split( "\n" ) \
if line.startswith( "id=")]
intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
intentList]
for state in intentState:
print state
- case8Result = main.TRUE
+ case8Result = main.TRUE
for state in intentState:
if state != 'WITHDRAWN':
case8Result = main.FALSE
break
-
- if case8Result == main.TRUE:
- main.log.report( "Intent removal successful" )
- else:
- main.log.report( "Intent removal failed" )
PingResult = main.TRUE
+ """
if case8Result == main.TRUE:
i = 8
while i < 18:
@@ -1263,7 +1443,7 @@
else:
main.log.info( "Unknown error" )
PingResult = main.ERROR
-
+
# Note: If the ping result failed, that means the intents have been
# withdrawn correctly.
if PingResult == main.TRUE:
@@ -1272,15 +1452,14 @@
# main.exit()
if PingResult == main.FALSE:
main.log.report( "Installed intents have been withdrawn correctly" )
+ """
- case8Result = case8Result and PingResult
-
- if case8Result == main.FALSE:
+ if case8Result:
main.log.report( "Intent removal successful" )
else:
main.log.report( "Intent removal failed" )
- utilities.assert_equals( expect=main.FALSE, actual=case8Result,
+ utilities.assert_equals( expect=main.TRUE, actual=case8Result,
onpass="Intent removal test passed",
onfail="Intent removal test failed" )
@@ -1296,21 +1475,28 @@
"Adding bidirectional point for mn hosts" +
"( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
"h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
-
+ macsDict = {}
+ for i in range( 1,29 ):
+ macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
+ print macsDict
main.step( "Add point intents for mn hosts h8 and h18 or" +
"ONOS hosts h8 and h12" )
# main.step(var1)
ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003008/1",
- "of:0000000000006018/1" )
+ ingressDevice="of:0000000000003008/1",
+ egressDevice="of:0000000000006018/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h8' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006018/1",
- "of:0000000000003008/1" )
+ ingressDevice="of:0000000000006018/1",
+ egressDevice="of:0000000000003008/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h18' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1320,7 +1506,9 @@
main.step(var2)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003009/1",
- "of:0000000000006019/1" )
+ "of:0000000000006019/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h9' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1328,7 +1516,9 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006019/1",
- "of:0000000000003009/1" )
+ "of:0000000000003009/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h19' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1338,7 +1528,10 @@
main.step(var3)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003010/1",
- "of:0000000000006020/1" )
+ "of:0000000000006020/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h10' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1346,7 +1539,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006020/1",
- "of:0000000000003010/1" )
+ "of:0000000000003010/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h20' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1357,7 +1553,10 @@
main.case(var4)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003011/1",
- "of:0000000000006021/1" )
+ "of:0000000000006021/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h11' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1365,7 +1564,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006021/1",
- "of:0000000000003011/1" )
+ "of:0000000000003011/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h21' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1376,7 +1578,10 @@
main.case(var5)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003012/1",
- "of:0000000000006022/1" )
+ "of:0000000000006022/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h12' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1384,7 +1589,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006022/1",
- "of:0000000000003012/1" )
+ "of:0000000000003012/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h22' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1395,7 +1603,10 @@
main.case(var6)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003013/1",
- "of:0000000000006023/1" )
+ "of:0000000000006023/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h13' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1403,7 +1614,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006023/1",
- "of:0000000000003013/1" )
+ "of:0000000000003013/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h23' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1414,7 +1628,10 @@
main.case(var7)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003014/1",
- "of:0000000000006024/1" )
+ "of:0000000000006024/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h14' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1422,7 +1639,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006024/1",
- "of:0000000000003014/1" )
+ "of:0000000000003014/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h24' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1433,7 +1653,10 @@
main.case(var8)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003015/1",
- "of:0000000000006025/1" )
+ "of:0000000000006025/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h15' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1441,7 +1664,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006025/1",
- "of:0000000000003015/1" )
+ "of:0000000000003015/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h25' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1452,7 +1678,10 @@
main.case(var9)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003016/1",
- "of:0000000000006026/1" )
+ "of:0000000000006026/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h16' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1460,7 +1689,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006026/1",
- "of:0000000000003016/1" )
+ "of:0000000000003016/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h26' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1471,7 +1703,10 @@
main.case(var10)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003017/1",
- "of:0000000000006027/1" )
+ "of:0000000000006027/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h17' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1479,7 +1714,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006027/1",
- "of:0000000000003017/1" )
+ "of:0000000000003017/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h27' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
diff --git a/TestON/tests/ProdFunc/ProdFunc.py.save b/TestON/tests/ProdFunc/ProdFunc.py.save
new file mode 100644
index 0000000..00b895c
--- /dev/null
+++ b/TestON/tests/ProdFunc/ProdFunc.py.save
@@ -0,0 +1,1518 @@
+
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
+
+import time
+# import sys
+# import os
+# import re
+import json
+
+time.sleep( 1 )
+
+
+class ProdFunc:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ import time
+ """
+ Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-log
+ git pull
+ mvn clean install
+ onos-package
+ onos-install -f
+ onos-wait-for-start
+ """
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.case( "Setting up test environment" )
+ main.log.report(
+ "This testcase is testing setting up test environment" )
+ main.log.report( "__________________________________" )
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ main.ONOSbench.onosRemoveRaftLogs()
+
+ main.step( "Git checkout and get version" )
+ #main.ONOSbench.gitCheckout( "master" )
+ gitPullResult = main.ONOSbench.gitPull()
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
+ main.ONOSbench.getVersion( report=True )
+
+ if gitPullResult == 1:
+ main.step( "Using mvn clean & install" )
+ main.ONOSbench.cleanInstall()
+ elif gitPullResult == 0:
+ main.log.report(
+ "Git Pull Failed, look into logs for detailed reason" )
+ main.cleanup()
+ main.exit()
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onosInstallResult = main.ONOSbench.onosInstall()
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Installing ONOS package successful" )
+ else:
+ main.log.report( "Installing ONOS package failed" )
+
+ onos1Isup = main.ONOSbench.isup()
+ if onos1Isup == main.TRUE:
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up" )
+
+ main.step( "Starting ONOS service" )
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
+
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.step( "Starting Mininet CLI..." )
+
+ # Starting the mininet using the old way
+ main.step( "Starting Mininet ..." )
+ netIsUp = main.Mininet1.startNet()
+ if netIsUp:
+ main.log.info("Mininet CLI is up")
+
+ case1Result = ( packageResult and
+ cellResult and verifyResult
+ and onosInstallResult and
+ onos1Isup and startResult )
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ def CASE2( self, main ):
+ """
+ Switch Down
+ """
+ # NOTE: You should probably run a topology check after this
+ import time
+
+ main.case( "Switch down discovery" )
+ main.log.report( "This testcase is testing a switch down discovery" )
+ main.log.report( "__________________________________" )
+
+ switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
+
+ description = "Killing a switch to ensure it is discovered correctly"
+ main.log.report( description )
+ main.case( description )
+
+ # TODO: Make this switch parameterizable
+ main.step( "Kill s28 " )
+ main.log.report( "Deleting s28" )
+ # FIXME: use new dynamic topo functions
+ main.Mininet1.delSwitch( "s28" )
+ main.log.info(
+ "Waiting " +
+ str( switchSleep ) +
+ " seconds for switch down to be discovered" )
+ time.sleep( switchSleep )
+ # Peek at the deleted switch
+ device = main.ONOS2.getDevice( dpid="0028" )
+ print "device = ", device
+ if device[ u'available' ] == 'False':
+ case2Result = main.FALSE
+ else:
+ case2Result = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=case2Result,
+ onpass="Switch down discovery successful",
+ onfail="Switch down discovery failed" )
+
+ def CASE101( self, main ):
+ """
+ Cleanup sequence:
+ onos-service <nodeIp> stop
+ onos-uninstall
+
+ TODO: Define rest of cleanup
+
+ """
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.case( "Cleaning up test environment" )
+
+ main.step( "Testing ONOS kill function" )
+ killResult = main.ONOSbench.onosKill( ONOS1Ip )
+
+ main.step( "Stopping ONOS service" )
+ stopResult = main.ONOSbench.onosStop( ONOS1Ip )
+
+ main.step( "Uninstalling ONOS service" )
+ uninstallResult = main.ONOSbench.onosUninstall()
+
+ case11Result = killResult and stopResult and uninstallResult
+ utilities.assert_equals( expect=main.TRUE, actual=case11Result,
+ onpass="Cleanup successful",
+ onfail="Cleanup failed" )
+
+ def CASE3( self, main ):
+ """
+ Test 'onos' command and its functionality in driver
+ """
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.case( "Testing 'onos' command" )
+
+ main.step( "Sending command 'onos -w <onos-ip> system:name'" )
+ cmdstr1 = "system:name"
+ cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmdResult1 )
+
+ main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
+ cmdstr2 = "onos:topology"
+ cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmdResult2 )
+
+ def CASE20( self ):
+ """
+ Exit from mininet cli
+ reinstall ONOS
+ """
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.log.report( "This testcase exits the mininet cli and reinstalls" +
+ "ONOS to switch over to Packet Optical topology" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Disconnecting mininet and restarting ONOS" )
+ main.step( "Disconnecting mininet and restarting ONOS" )
+ mininetDisconnect = main.Mininet1.disconnect()
+ print "mininetDisconnect = ", mininetDisconnect
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ main.ONOSbench.onosRemoveRaftLogs()
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ onosInstallResult = main.ONOSbench.onosInstall()
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Installing ONOS package successful" )
+ else:
+ main.log.report( "Installing ONOS package failed" )
+
+ onos1Isup = main.ONOSbench.isup()
+ if onos1Isup == main.TRUE:
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up" )
+
+ main.step( "Starting ONOS service" )
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
+
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ case20Result = mininetDisconnect and cellResult and verifyResult \
+ and onosInstallResult and onos1Isup and \
+ startResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case20Result,
+ onpass= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS successful",
+ onfail= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS failed" )
+
+ def CASE21( self, main ):
+ """
+ On ONOS bench, run this command:
+ ./~/ONOS/tools/test/bin/onos-topo-cfg
+ which starts the rest and copies the links
+ json file to the onos instance.
+ Note that in case of Packet Optical, the links are not learnt
+ from the topology, instead the links are learnt
+ from the json config file
+ """
+ main.log.report(
+ "This testcase starts the packet layer topology and REST" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Starting LINC-OE and other components" )
+ main.step( "Starting LINC-OE and other components" )
+ startConsoleResult = main.LincOE1.startConsole()
+ opticalMnScript = main.LincOE2.runOpticalMnScript()
+ onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
+ instanceName=main.params[ 'CTRL' ][ 'ip1' ],
+ jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
+
+ print "start_console_result =", startConsoleResult
+ print "optical_mn_script = ", opticalMnScript
+ print "onos_topo_cfg_result =", onosTopoCfgResult
+
+ case21Result = startConsoleResult and opticalMnScript and \
+ onosTopoCfgResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case21Result,
+ onpass="Packet optical topology spawned successsfully",
+ onfail="Packet optical topology spawning failed" )
+
+ def CASE22( self, main ):
+ """
+ Curretly we use, 4 linear switch optical topology and
+ 2 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 4,
+ packetLayerSWCount variable = 2 and hostCount = 2
+ and this is hardcoded in the testcase. If the topology changes,
+ these hardcoded values need to be changed
+ """
+ main.log.report(
+ "This testcase compares the optical+packet topology against what" +
+ " is expected" )
+ main.case( "Topology comparision" )
+ main.step( "Topology comparision" )
+ main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ devicesResult = main.ONOS3.devices( jsonFormat=False )
+
+ print "devices_result = ", devicesResult
+ devicesLinewise = devicesResult.split( "\n" )
+ devicesLinewise = devicesLinewise[ 1: ]
+ roadmCount = 0
+ packetLayerSWCount = 0
+ for line in devicesLinewise:
+ components = line.split( "," )
+ availability = components[ 1 ].split( "=" )[ 1 ]
+ type = components[ 3 ].split( "=" )[ 1 ]
+ if availability == 'true' and type == 'ROADM':
+ roadmCount += 1
+ elif availability == 'true' and type == 'SWITCH':
+ packetLayerSWCount += 1
+ if roadmCount == 4:
+ print "Number of Optical Switches = %d and is" % roadmCount +\
+ " correctly detected"
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is correctly detected" )
+ opticalSWResult = main.TRUE
+ else:
+ print "Number of Optical Switches = %d and is wrong" % roadmCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is wrong" )
+ opticalSWResult = main.FALSE
+
+ if packetLayerSWCount == 2:
+ print "Number of Packet layer or mininet Switches = %d "\
+ % packetLayerSWCount + "and is correctly detected"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is correctly detected" )
+ packetSWResult = main.TRUE
+ else:
+ print "Number of Packet layer or mininet Switches = %d and"\
+ % packetLayerSWCount + " is wrong"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is wrong" )
+ packetSWResult = main.FALSE
+ print "_________________________________"
+
+ linksResult = main.ONOS3.links( jsonFormat=False )
+ print "links_result = ", linksResult
+ print "_________________________________"
+
+ # NOTE:Since only point intents are added, there is no
+ # requirement to discover the hosts
+ # Therfore, the below portion of the code is commented.
+ """
+ #Discover hosts using pingall
+ pingallResult = main.LincOE2.pingall()
+
+ hostsResult = main.ONOS3.hosts( jsonFormat=False )
+ main.log.info( "hosts_result = "+hostsResult )
+ main.log.info( "_________________________________" )
+ hostsLinewise = hostsResult.split( "\n" )
+ hostsLinewise = hostsLinewise[ 1:-1 ]
+ hostCount = 0
+ for line in hostsLinewise:
+ hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
+ hostCount +=1
+ if hostCount ==2:
+ print "Number of hosts = %d and is correctly detected" %hostCount
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and \
+ is correctly detected" )
+ hostDiscovery = main.TRUE
+ else:
+ print "Number of hosts = %d and is wrong" %hostCount
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and \
+ is wrong" )
+ hostDiscovery = main.FALSE
+ """
+ case22Result = opticalSWResult and packetSWResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case22Result,
+ onpass="Packet optical topology discovery successful",
+ onfail="Packet optical topology discovery failed" )
+
+ def CASE23( self, main ):
+ import time
+ """
+ Add bidirectional point intents between 2 packet layer( mininet )
+ devices and
+ ping mininet hosts
+ """
+ main.log.report(
+ "This testcase adds bidirectional point intents between 2 " +
+ "packet layer( mininet ) devices and ping mininet hosts" )
+ main.case( "Topology comparision" )
+ main.step( "Adding point intents" )
+ ptpIntentResult = main.ONOS3.addPointIntent(
+ "of:0000ffffffff0001/1",
+ "of:0000ffffffff0002/1" )
+ if ptpIntentResult == main.TRUE:
+ main.ONOS3.intents( jsonFormat=False )
+ main.log.info( "Point to point intent install successful" )
+
+ ptpIntentResult = main.ONOS3.addPointIntent(
+ "of:0000ffffffff0002/1",
+ "of:0000ffffffff0001/1" )
+ if ptpIntentResult == main.TRUE:
+ main.ONOS3.intents( jsonFormat=False )
+ main.log.info( "Point to point intent install successful" )
+
+ time.sleep( 10 )
+ flowHandle = main.ONOS3.flows()
+ main.log.info( "flows :" + flowHandle )
+
+ # Sleep for 30 seconds to provide time for the intent state to change
+ time.sleep( 30 )
+ intentHandle = main.ONOS3.intents( jsonFormat=False )
+ main.log.info( "intents :" + intentHandle )
+
+ PingResult = main.TRUE
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h2" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ # ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count < 5:
+ count += 1
+ PingResult = main.FALSE
+ main.log.info(
+ "Ping between h1 and h2 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h2 have failed" )
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h2 passed!" )
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Point intents for packet optical have not ben installed" +
+ " correctly. Cleaning up" )
+ if PingResult == main.TRUE:
+ main.log.report(
+ "Point Intents for packet optical have been " +
+ "installed correctly" )
+
+ case23Result = PingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case23Result,
+ onpass= "Point intents addition for packet optical and" +
+ "Pingall Test successful",
+ onfail= "Point intents addition for packet optical and" +
+ "Pingall Test NOT successful" )
+
+ def CASE24( self, main ):
+ import time
+ import json
+ """
+ Test Rerouting of Packet Optical by bringing a port down
+ ( port 22 ) of a switch( switchID=1 ), so that link
+ ( between switch1 port22 - switch4-port30 ) is inactive
+ and do a ping test. If rerouting is successful,
+ ping should pass. also check the flows
+ """
+ main.log.report(
+ "This testcase tests rerouting and pings mininet hosts" )
+ main.case( "Test rerouting and pings mininet hosts" )
+ main.step( "Bring a port down and verify the link state" )
+ main.LincOE1.portDown( swId="1", ptId="22" )
+ linksNonjson = main.ONOS3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+
+ links = main.ONOS3.links()
+ main.log.info( "links = " + links )
+
+ linksResult = json.loads( links )
+ linksStateResult = main.FALSE
+ for item in linksResult:
+ if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
+ 'src' ][ 'port' ] == "22":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
+ 'dst' ][ 'port' ] == "30":
+ linksState = item[ 'state' ]
+ if linksState == "INACTIVE":
+ main.log.info(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ main.log.report(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ linksStateResult = main.TRUE
+ break
+ else:
+ main.log.info(
+ "Links state is not inactive as expected" )
+ main.log.report(
+ "Links state is not inactive as expected" )
+ linksStateResult = main.FALSE
+
+ print "links_state_result = ", linksStateResult
+ time.sleep( 10 )
+ flowHandle = main.ONOS3.flows()
+ main.log.info( "flows :" + flowHandle )
+
+ main.step( "Verify Rerouting by a ping test" )
+ PingResult = main.TRUE
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h2" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ # ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count < 5:
+ count += 1
+ PingResult = main.FALSE
+ main.log.info(
+ "Ping between h1 and h2 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h2 have failed" )
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h2 passed!" )
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.TRUE:
+ main.log.report( "Ping test successful " )
+ if PingResult == main.FALSE:
+ main.log.report( "Ping test failed" )
+
+ case24Result = PingResult and linksStateResult
+ utilities.assert_equals( expect=main.TRUE, actual=case24Result,
+ onpass="Packet optical rerouting successful",
+ onfail="Packet optical rerouting failed" )
+
+ def CASE4( self, main ):
+ import re
+ import time
+ main.log.report( "This testcase is testing the assignment of" +
+ " all the switches to all the controllers and" +
+ " discovering the hosts in reactive mode" )
+ main.log.report( "__________________________________" )
+ main.case( "Pingall Test" )
+ main.step( "Assigning switches to controllers" )
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ for i in range( 1, 29 ):
+ if i == 1:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ elif i >= 2 and i < 5:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ elif i >= 5 and i < 8:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ elif i >= 8 and i < 18:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ elif i >= 18 and i < 28:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ else:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ SwitchMastership = main.TRUE
+ for i in range( 1, 29 ):
+ if i == 1:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+ elif i >= 2 and i < 5:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+ elif i >= 5 and i < 8:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+ elif i >= 8 and i < 18:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+ elif i >= 18 and i < 28:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+ else:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is" + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+
+ if SwitchMastership == main.TRUE:
+ main.log.report( "Controller assignmnet successful" )
+ else:
+ main.log.report( "Controller assignmnet failed" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=SwitchMastership,
+ onpass="MasterControllers assigned correctly" )
+ """
+ for i in range ( 1,29 ):
+ main.Mininet1.assignSwController( sw=str( i ),count=5,
+ ip1=ONOS1Ip,port1=ONOS1Port,
+ ip2=ONOS2Ip,port2=ONOS2Port,
+ ip3=ONOS3Ip,port3=ONOS3Port,
+ ip4=ONOS4Ip,port4=ONOS4Port,
+ ip5=ONOS5Ip,port5=ONOS5Port )
+ """
+ # REACTIVE FWD test
+
+ main.step( "Get list of hosts from Mininet" )
+ hostList = main.Mininet1.getHosts()
+ main.log.info( hostList )
+
+ main.step( "Get host list in ONOS format" )
+ hostOnosList = main.ONOS2.getHostsId( hostList )
+ main.log.info( hostOnosList )
+ # time.sleep( 5 )
+
+ main.step( "Pingall" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ time2 = time.time()
+ print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
+ # Start onos cli again because u might have dropped out of
+ # onos prompt to the shell prompt
+ # if there was no activity
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+
+ case4Result = SwitchMastership and pingResult
+ if pingResult == main.TRUE:
+ main.log.report( "Pingall Test in reactive mode to" +
+ " discover the hosts successful" )
+ else:
+ main.log.report( "Pingall Test in reactive mode to" +
+ " discover the hosts failed" )
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case4Result,
+ onpass="Controller assignment and Pingall Test successful",
+ onfail="Controller assignment and Pingall Test NOT successful" )
+
+ def CASE10( self ):
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd uninstalled" )
+
+ # After reactive forwarding is disabled, the reactive flows on
+ # switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
+
+ flows = main.ONOS2.flows()
+ main.log.info( flows )
+
+ case10Result = appUninstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case10Result,
+ onpass="Reactive forwarding app uninstallation successful",
+ onfail="Reactive forwarding app uninstallation failed" )
+
+
+ def CASE11( self ):
+ # NOTE: This testcase require reactive forwarding mode enabled
+ # NOTE: in the beginning and then uninstall it before adding
+ # NOTE: point intents. Again the app is installed so that
+ # NOTE: testcase 10 can be ran successively
+ import time
+ main.log.report(
+ "This testcase moves a host from one switch to another to add" +
+ "point intents between them and then perform ping" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Moving host from one switch to another" )
+ main.case( "Moving host from a device and attach it to another device" )
+ main.step( "Moving host h9 from device s9 and attach it to s8" )
+ main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
+
+ time.sleep(15) #Time delay to have all the flows ready
+ main.step( "Pingall" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ time2 = time.time()
+ print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
+ hosts = main.ONOS2.hosts( jsonFormat = False )
+ main.log.info( hosts )
+
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd uninstalled" )
+
+ main.step( "Add point intents between hosts on the same device")
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003008/1",
+ "of:0000000000003008/3" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003008/3",
+ "of:0000000000003008/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ main.case( "Ping hosts on the same devices" )
+ ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
+
+ '''
+ main.case( "Installing reactive forwarding app" )
+ # Install onos-app-fwd app to enable reactive forwarding
+ appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd installed" )
+ '''
+
+ if ping == main.FALSE:
+ main.log.report(
+ "Point intents for hosts on same devices haven't" +
+ " been installed correctly. Cleaning up" )
+ if ping == main.TRUE:
+ main.log.report(
+ "Point intents for hosts on same devices" +
+ "installed correctly. Cleaning up" )
+
+ case11Result = ping and pingResult
+ utilities.assert_equals(
+ expect = main.TRUE,
+ actual = case11Result,
+ onpass = "Point intents for hosts on same devices" +
+ "Ping Test successful",
+ onfail = "Point intents for hosts on same devices" +
+ "Ping Test NOT successful" )
+
+
+ def CASE12( self ):
+ """
+ Verify the default flows on each switch in proactive mode
+ """
+ main.log.report( "This testcase is verifying num of default" +
+ " flows on each switch" )
+ main.log.report( "__________________________________" )
+ main.case( "Verify num of default flows on each switch" )
+ main.step( "Obtaining the device id's and flowrule count on them" )
+
+ case12Result = main.TRUE
+ idList = main.ONOS2.getAllDevicesId()
+ for id in idList:
+ count = main.ONOS2.FlowAddedCount( id )
+ main.log.info("count = " +count)
+ if int(count) != 3:
+ case12Result = main.FALSE
+ break
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case12Result,
+ onpass = "Expected default num of flows exist",
+ onfail = "Expected default num of flows do not exist")
+
+
+
+
+ def CASE6( self ):
+ import time
+ main.log.report( "This testcase is testing the addition of" +
+ " host intents and then does pingall" )
+ main.log.report( "__________________________________" )
+ main.case( "Obtaining host id's" )
+ main.step( "Get hosts" )
+ hosts = main.ONOS2.hosts()
+ main.log.info( hosts )
+
+ main.step( "Get all devices id" )
+ devicesIdList = main.ONOS2.getAllDevicesId()
+ main.log.info( devicesIdList )
+
+ # ONOS displays the hosts in hex format unlike mininet which does
+ # in decimal format
+ # So take care while adding intents
+ """
+ main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
+ ONOS hosts h8 and h12" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+ print "______________________________________________________"
+ """
+ for i in range( 8, 18 ):
+ main.log.info(
+ "Adding host intent between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ # NOTE: get host can return None
+ # TODO: handle this
+ host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
+
+ host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
+ main.ONOS2.addHostIntent( host1Id, host2Id )
+
+ time.sleep( 10 )
+ hIntents = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intents:" + hIntents )
+ flows = main.ONOS2.flows()
+ main.log.info( "flows:" + flows )
+
+ count = 1
+ i = 8
+ PingResult = main.TRUE
+ # while i<10:
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
+ # i = 8
+ PingResult = main.FALSE
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Ping all test after Host intent addition failed.Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if PingResult == main.TRUE:
+ main.log.report(
+ "Ping all test after Host intent addition successful" )
+
+ case6Result = PingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case6Result,
+ onpass="Pingall Test after Host intents addition successful",
+ onfail="Pingall Test after Host intents addition failed" )
+
+ def CASE5( self, main ):
+ import json
+ # assumes that sts is already in you PYTHONPATH
+ from sts.topology.teston_topology import TestONTopology
+ # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.log.report( "This testcase is testing if all ONOS nodes" +
+ " are in topology sync with mininet" )
+ main.log.report( "__________________________________" )
+ main.case( "Comparing Mininet topology with the topology of ONOS" )
+ main.step( "Start continuous pings" )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
+
+ main.step( "Create TestONTopology object" )
+ global ctrls
+ ctrls = []
+ count = 1
+ while True:
+ temp = ()
+ if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+ temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+ temp = temp + ( "ONOS" + str( count ), )
+ temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+ temp = temp + \
+ ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+ ctrls.append( temp )
+ count = count + 1
+ else:
+ break
+ global MNTopo
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
+ MNTopo = Topo
+
+ TopologyCheck = main.TRUE
+ main.step( "Compare ONOS Topology to MN Topology" )
+ devicesJson = main.ONOS2.devices()
+ linksJson = main.ONOS2.links()
+ # portsJson = main.ONOS2.ports()
+
+ result1 = main.Mininet1.compareSwitches(
+ MNTopo,
+ json.loads( devicesJson ) )
+ result2 = main.Mininet1.compareLinks(
+ MNTopo,
+ json.loads( linksJson ) )
+ # result3 = main.Mininet1.comparePorts(
+ # MNTopo, json.loads( portsJson ) )
+
+ # result = result1 and result2 and result3
+ result = result1 and result2
+
+ print "***********************"
+pr if result == main.TRUE:
+ main.log.report( "ONOS" + " Topology matches MN Topology" )
+ else:
+ main.log.report( "ONOS" + " Topology does not match MN Topology" )
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=result,
+ onpass="ONOS" +
+ " Topology matches MN Topology",
+ onfail="ONOS" +
+ " Topology does not match MN Topology" )
+
+ TopologyCheck = TopologyCheck and result
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=TopologyCheck,
+ onpass="Topology checks passed",
+ onfail="Topology checks failed" )
+
+ def CASE7( self, main ):
+ from sts.topology.teston_topology import TestONTopology
+
+ linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+ main.log.report( "This testscase is killing a link to ensure that" +
+ " link discovery is consistent" )
+ main.log.report( "__________________________________" )
+ main.log.report( "Killing a link to ensure that link discovery" +
+ " is consistent" )
+ main.case( "Killing a link to Ensure that Link Discovery" +
+ "is Working Properly" )
+ """
+ main.step( "Start continuous pings" )
+
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
+ """
+ main.step( "Determine the current number of switches and links" )
+ topologyOutput = main.ONOS2.topology()
+ topologyResult = main.ONOS1.getTopology( topologyOutput )
+ activeSwitches = topologyResult[ 'deviceCount' ]
+ links = topologyResult[ 'linkCount' ]
+ print "activeSwitches = ", type( activeSwitches )
+ print "links = ", type( links )
+ main.log.info(
+ "Currently there are %s switches and %s links" %
+ ( str( activeSwitches ), str( links ) ) )
+
+ main.step( "Kill Link between s3 and s28" )
+ main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
+ time.sleep( linkSleep )
+ topologyOutput = main.ONOS2.topology()
+ LinkDown = main.ONOS1.checkStatus(
+ topologyOutput, activeSwitches, str(
+ int( links ) - 2 ) )
+ if LinkDown == main.TRUE:
+ main.log.report( "Link Down discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=LinkDown,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( linkSleep ) +
+ " seconds" )
+
+ # Check ping result here..add code for it
+
+ main.step( "Bring link between s3 and s28 back up" )
+ LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+ time.sleep( linkSleep )
+ topologyOutput = main.ONOS2.topology()
+ LinkUp = main.ONOS1.checkStatus(
+ topologyOutput,
+ activeSwitches,
+ str( links ) )
+ if LinkUp == main.TRUE:
+ main.log.report( "Link up discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=LinkUp,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( linkSleep ) +
+ " seconds" )
+
+ # NOTE Check ping result here..add code for it
+
+ main.step( "Compare ONOS Topology to MN Topology" )
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
+ MNTopo = Topo
+ TopologyCheck = main.TRUE
+
+ devicesJson = main.ONOS2.devices()
+ linksJson = main.ONOS2.links()
+ portsJson = main.ONOS2.ports()
+
+ result1 = main.Mininet1.compareSwitches(
+ MNTopo,
+ json.loads( devicesJson ) )
+ result2 = main.Mininet1.compareLinks(
+ MNTopo,
+ json.loads( linksJson ) )
+ # result3 = main.Mininet1.comparePorts(
+ # MNTopo, json.loads( portsJson ) )
+
+ # result = result1 and result2 and result3
+ result = result1 and result2
+ print "***********************"
+
+ if result == main.TRUE:
+ main.log.report( "ONOS" + " Topology matches MN Topology" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=result,
+ onpass="ONOS" +
+ " Topology matches MN Topology",
+ onfail="ONOS" +
+ " Topology does not match MN Topology" )
+
+ TopologyCheck = TopologyCheck and result
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=TopologyCheck,
+ onpass="Topology checks passed",
+ onfail="Topology checks failed" )
+
+ result = LinkDown and LinkUp and TopologyCheck
+ utilities.assert_equals( expect=main.TRUE, actual=result,
+ onpass="Link failure is discovered correctly",
+ onfail="Link Discovery failed" )
+
+ def CASE8( self ):
+ """
+ Intent removal
+ """
+ import time
+ main.log.report( "This testcase removes any previously added intents" +
+ " before adding any new set of intents" )
+ main.log.report( "__________________________________" )
+ main.log.info( "intent removal" )
+ main.case( "Removing installed intents" )
+ main.step( "Obtain the intent id's" )
+ intentResult = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + intentResult )
+ intentLinewise = intentResult.split( "\n" )
+
+ intentList = [line for line in intentLinewise \
+ if line.startswith( "id=")]
+ intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
+ intentList]
+ for id in intentids:
+ print "id = ", id
+
+ main.step(
+ "Iterate through the intentids list and remove each intent" )
+ for id in intentids:
+ main.ONOS2.removeIntent( intentId=id )
+
+ intentResult = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + intentResult )
+
+ intentList = [line for line in intentResult.split( "\n" ) \
+ if line.startswith( "id=")]
+ intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
+ intentList]
+ for state in intentState:
+ print state
+
+ case8Result = main.TRUE
+ for state in intentState:
+ if state != 'WITHDRAWN':
+ case8Result = main.FALSE
+ break
+
+ if case8Result == main.TRUE:
+ main.log.report( "Intent removal successful" )
+ else:
+ main.log.report( "Intent removal failed" )
+
+ PingResult = main.TRUE
+ if case8Result == main.TRUE:
+ i = 8
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.TRUE:
+ i = 19
+ PingResult = PingResult and main.TRUE
+ elif ping == main.FALSE:
+ i += 1
+ PingResult = PingResult and main.FALSE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ # Note: If the ping result failed, that means the intents have been
+ # withdrawn correctly.
+ if PingResult == main.TRUE:
+ main.log.report( "Installed intents have not been withdrawn correctly" )
+ # main.cleanup()
+ # main.exit()
+ if PingResult == main.FALSE:
+ main.log.report( "Installed intents have been withdrawn correctly" )
+
+ case8Result = case8Result and PingResult
+
+ if case8Result == main.FALSE:
+ main.log.report( "Intent removal successful" )
+ else:
+ main.log.report( "Intent removal failed" )
+
+ utilities.assert_equals( expect=main.FALSE, actual=case8Result,
+ onpass="Intent removal test passed",
+ onfail="Intent removal test failed" )
+
+ def CASE9( self ):
+ main.log.report(
+ "This testcase adds point intents and then does pingall" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Adding point intents" )
+ main.case(
+ "Adding bidirectional point for mn hosts" +
+ "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
+ "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
+
+ main.step( "Add point intents for mn hosts h8 and h18 or" +
+ "ONOS hosts h8 and h12" )
+ # main.step(var1)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003008/1",
+ "of:0000000000006018/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006018/1",
+ "of:0000000000003008/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
+ main.step(var2)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003009/1",
+ "of:0000000000006019/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006019/1",
+ "of:0000000000003009/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
+ main.step(var3)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003010/1",
+ "of:0000000000006020/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006020/1",
+ "of:0000000000003010/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var4 = "Add point intents for mininet hosts h11 and h21 or" +\
+ " ONOS hosts hB and h15"
+ main.case(var4)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003011/1",
+ "of:0000000000006021/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006021/1",
+ "of:0000000000003011/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var5 = "Add point intents for mininet hosts h12 and h22 " +\
+ "ONOS hosts hC and h16"
+ main.case(var5)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003012/1",
+ "of:0000000000006022/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006022/1",
+ "of:0000000000003012/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var6 = "Add point intents for mininet hosts h13 and h23 or" +\
+ " ONOS hosts hD and h17"
+ main.case(var6)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003013/1",
+ "of:0000000000006023/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006023/1",
+ "of:0000000000003013/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var7 = "Add point intents for mininet hosts h14 and h24 or" +\
+ " ONOS hosts hE and h18"
+ main.case(var7)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003014/1",
+ "of:0000000000006024/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006024/1",
+ "of:0000000000003014/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var8 = "Add point intents for mininet hosts h15 and h25 or" +\
+ " ONOS hosts hF and h19"
+ main.case(var8)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003015/1",
+ "of:0000000000006025/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006025/1",
+ "of:0000000000003015/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var9 = "Add intents for mininet hosts h16 and h26 or" +\
+ " ONOS hosts h10 and h1A"
+ main.case(var9)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003016/1",
+ "of:0000000000006026/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006026/1",
+ "of:0000000000003016/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var10 = "Add point intents for mininet hosts h17 and h27 or" +\
+ " ONOS hosts h11 and h1B"
+ main.case(var10)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003017/1",
+ "of:0000000000006027/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ #main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006027/1",
+ "of:0000000000003017/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ #main.log.info( getIntentResult )
+
+ print(
+ "___________________________________________________________" )
+
+ flowHandle = main.ONOS2.flows()
+ #main.log.info( "flows :" + flowHandle )
+
+ count = 1
+ i = 8
+ PingResult = main.TRUE
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
+ # i = 8
+ PingResult = main.FALSE
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Point intents have not ben installed correctly. Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if PingResult == main.TRUE:
+ main.log.report( "Point Intents have been installed correctly" )
+
+ case9Result = PingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case9Result,
+ onpass="Point intents addition and Pingall Test successful",
+ onfail="Point intents addition and Pingall Test NOT successful" )
diff --git a/TestON/tests/ProdFunc/ProdFunc.topo b/TestON/tests/ProdFunc/ProdFunc.topo
index 3f3323e..292a8a4 100755
--- a/TestON/tests/ProdFunc/ProdFunc.topo
+++ b/TestON/tests/ProdFunc/ProdFunc.topo
@@ -64,6 +64,7 @@
<arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
<arg2> --topo mytopo </arg2>
<arg3> --switch ovs,protocols=OpenFlow10 </arg3>
+ <arg4> --mac </arg4>
<controller> remote </controller>
</COMPONENTS>
</Mininet2>
diff --git a/TestON/tests/ProdFunc/ProdFunc2.py b/TestON/tests/ProdFunc/ProdFunc2.py
new file mode 100644
index 0000000..2cd04c1
--- /dev/null
+++ b/TestON/tests/ProdFunc/ProdFunc2.py
@@ -0,0 +1,1542 @@
+
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
+
+import time
+# import sys
+# import os
+# import re
+import json
+
+time.sleep( 1 )
+
+
+class ProdFunc:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ import time
+ """
+ Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-log
+ git pull
+ mvn clean install
+ onos-package
+ onos-install -f
+ onos-wait-for-start
+ """
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.case( "Setting up test environment" )
+ main.log.report(
+ "This testcase is testing setting up test environment" )
+ main.log.report( "__________________________________" )
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ main.ONOSbench.onosRemoveRaftLogs()
+
+ main.step( "Git checkout and get version" )
+ #main.ONOSbench.gitCheckout( "master" )
+ gitPullResult = main.ONOSbench.gitPull()
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
+ main.ONOSbench.getVersion( report=True )
+
+ if gitPullResult == 1:
+ main.step( "Using mvn clean & install" )
+ main.ONOSbench.cleanInstall()
+ elif gitPullResult == 0:
+ main.log.report(
+ "Git Pull Failed, look into logs for detailed reason" )
+ main.cleanup()
+ main.exit()
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onosInstallResult = main.ONOSbench.onosInstall()
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Installing ONOS package successful" )
+ else:
+ main.log.report( "Installing ONOS package failed" )
+
+ onos1Isup = main.ONOSbench.isup()
+ if onos1Isup == main.TRUE:
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up" )
+
+ main.step( "Starting ONOS service" )
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
+
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.step( "Starting Mininet CLI..." )
+
+ # Starting the mininet using the old way
+ main.step( "Starting Mininet ..." )
+ netIsUp = main.Mininet1.startNet()
+ if netIsUp:
+ main.log.info("Mininet CLI is up")
+
+ case1Result = ( packageResult and
+ cellResult and verifyResult
+ and onosInstallResult and
+ onos1Isup and startResult )
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ def CASE2( self, main ):
+ """
+ Switch Down
+ """
+ # NOTE: You should probably run a topology check after this
+ import time
+
+ main.case( "Switch down discovery" )
+ main.log.report( "This testcase is testing a switch down discovery" )
+ main.log.report( "__________________________________" )
+
+ switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
+
+ description = "Killing a switch to ensure it is discovered correctly"
+ main.log.report( description )
+ main.case( description )
+
+ # TODO: Make this switch parameterizable
+ main.step( "Kill s28 " )
+ main.log.report( "Deleting s28" )
+ # FIXME: use new dynamic topo functions
+ main.Mininet1.delSwitch( "s28" )
+ main.log.info(
+ "Waiting " +
+ str( switchSleep ) +
+ " seconds for switch down to be discovered" )
+ time.sleep( switchSleep )
+ # Peek at the deleted switch
+ device = main.ONOS2.getDevice( dpid="0028" )
+ print "device = ", device
+ if device[ u'available' ] == 'False':
+ case2Result = main.FALSE
+ else:
+ case2Result = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=case2Result,
+ onpass="Switch down discovery successful",
+ onfail="Switch down discovery failed" )
+
+ def CASE101( self, main ):
+ """
+ Cleanup sequence:
+ onos-service <nodeIp> stop
+ onos-uninstall
+
+ TODO: Define rest of cleanup
+
+ """
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.case( "Cleaning up test environment" )
+
+ main.step( "Testing ONOS kill function" )
+ killResult = main.ONOSbench.onosKill( ONOS1Ip )
+
+ main.step( "Stopping ONOS service" )
+ stopResult = main.ONOSbench.onosStop( ONOS1Ip )
+
+ main.step( "Uninstalling ONOS service" )
+ uninstallResult = main.ONOSbench.onosUninstall()
+
+ case11Result = killResult and stopResult and uninstallResult
+ utilities.assert_equals( expect=main.TRUE, actual=case11Result,
+ onpass="Cleanup successful",
+ onfail="Cleanup failed" )
+
+ def CASE3( self, main ):
+ """
+ Test 'onos' command and its functionality in driver
+ """
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.case( "Testing 'onos' command" )
+
+ main.step( "Sending command 'onos -w <onos-ip> system:name'" )
+ cmdstr1 = "system:name"
+ cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmdResult1 )
+
+ main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
+ cmdstr2 = "onos:topology"
+ cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmdResult2 )
+
+ def CASE20( self ):
+ """
+ Exit from mininet cli
+ reinstall ONOS
+ """
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.log.report( "This testcase exits the mininet cli and reinstalls" +
+ "ONOS to switch over to Packet Optical topology" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Disconnecting mininet and restarting ONOS" )
+ main.step( "Disconnecting mininet and restarting ONOS" )
+ mininetDisconnect = main.Mininet1.disconnect()
+ print "mininetDisconnect = ", mininetDisconnect
+
+ main.step( "Removing raft logs before a clen installation of ONOS" )
+ main.ONOSbench.onosRemoveRaftLogs()
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ onosInstallResult = main.ONOSbench.onosInstall()
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Installing ONOS package successful" )
+ else:
+ main.log.report( "Installing ONOS package failed" )
+
+ onos1Isup = main.ONOSbench.isup()
+ if onos1Isup == main.TRUE:
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up" )
+
+ main.step( "Starting ONOS service" )
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
+
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ case20Result = mininetDisconnect and cellResult and verifyResult \
+ and onosInstallResult and onos1Isup and \
+ startResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case20Result,
+ onpass= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS successful",
+ onfail= "Exiting functionality mininet topology and reinstalling" +
+ " ONOS failed" )
+
+ def CASE21( self, main ):
+ """
+ On ONOS bench, run this command:
+ sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
+ which spawns packet optical topology and copies the links
+ json file to the onos instance.
+ Note that in case of Packet Optical, the links are not learnt
+ from the topology, instead the links are learnt
+ from the json config file
+ """
+ main.log.report(
+ "This testcase starts the packet layer topology and REST" )
+ main.log.report( "_____________________________________________" )
+ main.case( "Starting LINC-OE and other components" )
+ main.step( "Starting LINC-OE and other components" )
+ appInstallResult = main.ONOS2.featureInstall( "onos-app-optical" )
+ opticalMnScript = main.LincOE2.runOpticalMnScript()
+
+ case21Result = opticalMnScript and appInstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case21Result,
+ onpass="Packet optical topology spawned successsfully",
+ onfail="Packet optical topology spawning failed" )
+
+ def CASE22( self, main ):
+ """
+ Curretly we use, 10 optical switches(ROADM's) and
+ 6 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 10,
+ packetLayerSWCount variable = 6, hostCount=6 and
+ links=42.
+ All this is hardcoded in the testcase. If the topology changes,
+ these hardcoded values need to be changed
+ """
+ main.log.report(
+ "This testcase compares the optical+packet topology against what" +
+ " is expected" )
+ main.case( "Topology comparision" )
+ main.step( "Topology comparision" )
+ main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ devicesResult = main.ONOS3.devices( jsonFormat=False )
+
+ print "devices_result = ", devicesResult
+ devicesLinewise = devicesResult.split( "\n" )
+ devicesLinewise = devicesLinewise[ 1: ]
+ roadmCount = 0
+ packetLayerSWCount = 0
+ for line in devicesLinewise:
+ components = line.split( "," )
+ availability = components[ 1 ].split( "=" )[ 1 ]
+ type = components[ 3 ].split( "=" )[ 1 ]
+ if availability == 'true' and type == 'ROADM':
+ roadmCount += 1
+ elif availability == 'true' and type == 'SWITCH':
+ packetLayerSWCount += 1
+ if roadmCount == 10:
+ print "Number of Optical Switches = %d and is" % roadmCount +\
+ " correctly detected"
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is correctly detected" )
+ opticalSWResult = main.TRUE
+ else:
+ print "Number of Optical Switches = %d and is wrong" % roadmCount
+ main.log.info(
+ "Number of Optical Switches = " +
+ str( roadmCount ) +
+ " and is wrong" )
+ opticalSWResult = main.FALSE
+
+ if packetLayerSWCount == 6:
+ print "Number of Packet layer or mininet Switches = %d "\
+ % packetLayerSWCount + "and is correctly detected"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is correctly detected" )
+ packetSWResult = main.TRUE
+ else:
+ print "Number of Packet layer or mininet Switches = %d and"\
+ % packetLayerSWCount + " is wrong"
+ main.log.info(
+ "Number of Packet layer or mininet Switches = " +
+ str( packetLayerSWCount ) +
+ " and is wrong" )
+ packetSWResult = main.FALSE
+ print "_________________________________"
+
+ linksResult = main.ONOS3.links( jsonFormat=False )
+ print "links_result = ", linksResult
+ print "_________________________________"
+ linkActiveCount = linksResult.count("state=ACTIVE")
+ main.log.info( "linkActiveCount = " + str( linkActiveCount ))
+ if linkActiveCount == 42:
+ linkActiveResult = main.TRUE
+ main.log.info(
+ "Number of links in ACTIVE state are correct")
+ else:
+ linkActiveResult = main.FALSE
+ main.log.info(
+ "Number of links in ACTIVE state are wrong")
+
+ # NOTE:Since only point intents are added, there is no
+ # requirement to discover the hosts
+ # Therfore, the below portion of the code is commented.
+ """
+ #Discover hosts using pingall
+ pingallResult = main.LincOE2.pingall()
+
+ hostsResult = main.ONOS3.hosts( jsonFormat=False )
+ main.log.info( "hosts_result = "+hostsResult )
+ main.log.info( "_________________________________" )
+ hostsLinewise = hostsResult.split( "\n" )
+ hostsLinewise = hostsLinewise[ 1:-1 ]
+ hostCount = 0
+ for line in hostsLinewise:
+ hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
+ hostCount +=1
+ if hostCount ==2:
+ print "Number of hosts = %d and is correctly detected" %hostCount
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and \
+ is correctly detected" )
+ hostDiscovery = main.TRUE
+ else:
+ print "Number of hosts = %d and is wrong" %hostCount
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and \
+ is wrong" )
+ hostDiscovery = main.FALSE
+ """
+ case22Result = opticalSWResult and packetSWResult and \
+ linkActiveResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case22Result,
+ onpass="Packet optical topology discovery successful",
+ onfail="Packet optical topology discovery failed" )
+
+ def CASE23( self, main ):
+ import time
+ """
+ Add bidirectional point intents between 2 packet layer( mininet )
+ devices and
+ ping mininet hosts
+ """
+ main.log.report(
+ "This testcase adds bidirectional point intents between 2 " +
+ "packet layer( mininet ) devices and ping mininet hosts" )
+ main.case( "Topology comparision" )
+ main.step( "Adding point intents" )
+ ptpIntentResult = main.ONOS3.addPointIntent(
+ "of:0000ffffffff0001/1",
+ "of:0000ffffffff0005/1" )
+ if ptpIntentResult == main.TRUE:
+ main.ONOS3.intents( jsonFormat=False )
+ main.log.info( "Point to point intent install successful" )
+
+ ptpIntentResult = main.ONOS3.addPointIntent(
+ "of:0000ffffffff0005/1",
+ "of:0000ffffffff0001/1" )
+ if ptpIntentResult == main.TRUE:
+ main.ONOS3.intents( jsonFormat=False )
+ main.log.info( "Point to point intent install successful" )
+
+ time.sleep( 30 )
+ flowHandle = main.ONOS3.flows()
+ main.log.info( "flows :" + flowHandle )
+
+ # Sleep for 30 seconds to provide time for the intent state to change
+ time.sleep( 60 )
+ intentHandle = main.ONOS3.intents( jsonFormat=False )
+ main.log.info( "intents :" + intentHandle )
+
+ PingResult = main.TRUE
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ # ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count < 5:
+ count += 1
+ PingResult = main.FALSE
+ main.log.info(
+ "Ping between h1 and h5 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h5 passed!" )
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Point intents for packet optical have not ben installed" +
+ " correctly. Cleaning up" )
+ if PingResult == main.TRUE:
+ main.log.report(
+ "Point Intents for packet optical have been " +
+ "installed correctly" )
+
+ case23Result = PingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case23Result,
+ onpass= "Point intents addition for packet optical and" +
+ "Pingall Test successful",
+ onfail= "Point intents addition for packet optical and" +
+ "Pingall Test NOT successful" )
+
+ def CASE24( self, main ):
+ import time
+ import json
+ """
+ LINC uses its own switch IDs. You can use the following
+ command on the LINC console to find the mapping between
+ DPIDs and LINC IDs.
+ rp(application:get_all_key(linc)).
+
+ Test Rerouting of Packet Optical by bringing a port down
+ ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
+ so that link
+ ( between switch1 port20 - switch5 port50 ) is inactive
+ and do a ping test. If rerouting is successful,
+ ping should pass. also check the flows
+ """
+ main.log.report(
+ "This testcase tests rerouting and pings mininet hosts" )
+ main.case( "Test rerouting and pings mininet hosts" )
+ main.step( "Attach to the Linc-OE session" )
+ attachConsole = main.LincOE1.attachLincOESession()
+ print "attachConsole = ", attachConsole
+
+ main.step( "Bring a port down and verify the link state" )
+ main.LincOE1.portDown( swId="9", ptId="20" )
+ linksNonjson = main.ONOS3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+
+ linkInactiveCount = linksNonjson.count("state=INACTIVE")
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 2:
+ main.log.info(
+ "Number of links in INACTIVE state are correct")
+ else:
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+
+ links = main.ONOS3.links()
+ main.log.info( "links = " + links )
+
+ linksResult = json.loads( links )
+ linksStateResult = main.FALSE
+ for item in linksResult:
+ if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
+ 'src' ][ 'port' ] == "20":
+ if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
+ 'dst' ][ 'port' ] == "50":
+ linksState = item[ 'state' ]
+ if linksState == "INACTIVE":
+ main.log.info(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ main.log.report(
+ "Links state is inactive as expected due to one" +
+ " of the ports being down" )
+ linksStateResult = main.TRUE
+ break
+ else:
+ main.log.info(
+ "Links state is not inactive as expected" )
+ main.log.report(
+ "Links state is not inactive as expected" )
+ linksStateResult = main.FALSE
+
+ print "links_state_result = ", linksStateResult
+ time.sleep( 10 )
+ flowHandle = main.ONOS3.flows()
+ main.log.info( "flows :" + flowHandle )
+
+ main.step( "Verify Rerouting by a ping test" )
+ PingResult = main.TRUE
+ count = 1
+ main.log.info( "\n\nh1 is Pinging h5" )
+ ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ # ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count < 5:
+ count += 1
+ PingResult = main.FALSE
+ main.log.info(
+ "Ping between h1 and h5 failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.info( "All ping attempts between h1 and h5 have failed" )
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h1 and h5 passed!" )
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.TRUE:
+ main.log.report( "Ping test successful " )
+ if PingResult == main.FALSE:
+ main.log.report( "Ping test failed" )
+
+ case24Result = PingResult and linksStateResult
+ utilities.assert_equals( expect=main.TRUE, actual=case24Result,
+ onpass="Packet optical rerouting successful",
+ onfail="Packet optical rerouting failed" )
+
+ def CASE4( self, main ):
+ import re
+ import time
+ main.log.report( "This testcase is testing the assignment of" +
+ " all the switches to all the controllers and" +
+ " discovering the hosts in reactive mode" )
+ main.log.report( "__________________________________" )
+ main.case( "Pingall Test" )
+ main.step( "Assigning switches to controllers" )
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+ for i in range( 1, 29 ):
+ if i == 1:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ elif i >= 2 and i < 5:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ elif i >= 5 and i < 8:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ elif i >= 8 and i < 18:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ elif i >= 18 and i < 28:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ else:
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ SwitchMastership = main.TRUE
+ for i in range( 1, 29 ):
+ if i == 1:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+ elif i >= 2 and i < 5:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+ elif i >= 5 and i < 8:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+ elif i >= 8 and i < 18:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+ elif i >= 18 and i < 28:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+ else:
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is" + str( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
+ else:
+ SwitchMastership = main.FALSE
+
+ if SwitchMastership == main.TRUE:
+ main.log.report( "Controller assignmnet successful" )
+ else:
+ main.log.report( "Controller assignmnet failed" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=SwitchMastership,
+ onpass="MasterControllers assigned correctly" )
+ """
+ for i in range ( 1,29 ):
+ main.Mininet1.assignSwController( sw=str( i ),count=5,
+ ip1=ONOS1Ip,port1=ONOS1Port,
+ ip2=ONOS2Ip,port2=ONOS2Port,
+ ip3=ONOS3Ip,port3=ONOS3Port,
+ ip4=ONOS4Ip,port4=ONOS4Port,
+ ip5=ONOS5Ip,port5=ONOS5Port )
+ """
+ # REACTIVE FWD test
+
+ main.step( "Get list of hosts from Mininet" )
+ hostList = main.Mininet1.getHosts()
+ main.log.info( hostList )
+
+ main.step( "Get host list in ONOS format" )
+ hostOnosList = main.ONOS2.getHostsId( hostList )
+ main.log.info( hostOnosList )
+ # time.sleep( 5 )
+
+ main.step( "Pingall" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ time2 = time.time()
+ print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
+ # Start onos cli again because u might have dropped out of
+ # onos prompt to the shell prompt
+ # if there was no activity
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+
+ case4Result = SwitchMastership and pingResult
+ if pingResult == main.TRUE:
+ main.log.report( "Pingall Test in reactive mode to" +
+ " discover the hosts successful" )
+ else:
+ main.log.report( "Pingall Test in reactive mode to" +
+ " discover the hosts failed" )
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case4Result,
+ onpass="Controller assignment and Pingall Test successful",
+ onfail="Controller assignment and Pingall Test NOT successful" )
+
+ def CASE10( self ):
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd uninstalled" )
+
+ # After reactive forwarding is disabled, the reactive flows on
+ # switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
+
+ flows = main.ONOS2.flows()
+ main.log.info( flows )
+
+ case10Result = appUninstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case10Result,
+ onpass="Reactive forwarding app uninstallation successful",
+ onfail="Reactive forwarding app uninstallation failed" )
+
+
+ def CASE11( self ):
+ # NOTE: This testcase require reactive forwarding mode enabled
+ # NOTE: in the beginning and then uninstall it before adding
+ # NOTE: point intents. Again the app is installed so that
+ # NOTE: testcase 10 can be ran successively
+ import time
+ main.log.report(
+ "This testcase moves a host from one switch to another to add" +
+ "point intents between them and then perform ping" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Moving host from one switch to another" )
+ main.case( "Moving host from a device and attach it to another device" )
+ main.step( "Moving host h9 from device s9 and attach it to s8" )
+ main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
+
+ time.sleep(15) #Time delay to have all the flows ready
+ main.step( "Pingall" )
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ time2 = time.time()
+ print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
+ hosts = main.ONOS2.hosts( jsonFormat = False )
+ main.log.info( hosts )
+
+ main.case( "Uninstalling reactive forwarding app" )
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd uninstalled" )
+
+ main.step( "Add point intents between hosts on the same device")
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003008/1",
+ "of:0000000000003008/3" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003008/3",
+ "of:0000000000003008/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ main.case( "Ping hosts on the same devices" )
+ ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
+
+ '''
+ main.case( "Installing reactive forwarding app" )
+ # Install onos-app-fwd app to enable reactive forwarding
+ appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
+ main.log.info( "onos-app-fwd installed" )
+ '''
+
+ if ping == main.FALSE:
+ main.log.report(
+ "Point intents for hosts on same devices haven't" +
+ " been installed correctly. Cleaning up" )
+ if ping == main.TRUE:
+ main.log.report(
+ "Point intents for hosts on same devices" +
+ "installed correctly. Cleaning up" )
+
+ case11Result = ping and pingResult
+ utilities.assert_equals(
+ expect = main.TRUE,
+ actual = case11Result,
+ onpass = "Point intents for hosts on same devices" +
+ "Ping Test successful",
+ onfail = "Point intents for hosts on same devices" +
+ "Ping Test NOT successful" )
+
+
+ def CASE12( self ):
+ """
+ Verify the default flows on each switch in proactive mode
+ """
+ main.log.report( "This testcase is verifying num of default" +
+ " flows on each switch" )
+ main.log.report( "__________________________________" )
+ main.case( "Verify num of default flows on each switch" )
+ main.step( "Obtaining the device id's and flowrule count on them" )
+
+ case12Result = main.TRUE
+ idList = main.ONOS2.getAllDevicesId()
+ for id in idList:
+ count = main.ONOS2.FlowAddedCount( id )
+ main.log.info("count = " +count)
+ if int(count) != 3:
+ case12Result = main.FALSE
+ break
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case12Result,
+ onpass = "Expected default num of flows exist",
+ onfail = "Expected default num of flows do not exist")
+
+
+
+
+ def CASE6( self ):
+ import time
+ main.log.report( "This testcase is testing the addition of" +
+ " host intents and then does pingall" )
+ main.log.report( "__________________________________" )
+ main.case( "Obtaining host id's" )
+ main.step( "Get hosts" )
+ hosts = main.ONOS2.hosts()
+ main.log.info( hosts )
+
+ main.step( "Get all devices id" )
+ devicesIdList = main.ONOS2.getAllDevicesId()
+ main.log.info( devicesIdList )
+
+ # ONOS displays the hosts in hex format unlike mininet which does
+ # in decimal format
+ # So take care while adding intents
+ """
+ main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
+ ONOS hosts h8 and h12" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+ print "______________________________________________________"
+ """
+ for i in range( 8, 18 ):
+ main.log.info(
+ "Adding host intent between h" + str( i ) +
+ " and h" + str( i + 10 ) )
+ host1 = "00:00:00:00:00:" + \
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+ host2 = "00:00:00:00:00:" + \
+ str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+ # NOTE: get host can return None
+ if host1:
+ host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
+ if host2:
+ host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
+ if host1Id and host2Id:
+ main.ONOS2.addHostIntent( host1Id, host2Id )
+
+ time.sleep( 10 )
+ hIntents = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intents:" + hIntents )
+ flows = main.ONOS2.flows()
+ main.log.info( "flows:" + flows )
+
+ count = 1
+ i = 8
+ PingResult = main.TRUE
+ # while i<10:
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
+ # i = 8
+ PingResult = main.FALSE
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Ping all test after Host intent addition failed.Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if PingResult == main.TRUE:
+ main.log.report(
+ "Ping all test after Host intent addition successful" )
+
+ case6Result = PingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case6Result,
+ onpass="Pingall Test after Host intents addition successful",
+ onfail="Pingall Test after Host intents addition failed" )
+
+ def CASE5( self, main ):
+ import json
+ # assumes that sts is already in you PYTHONPATH
+ from sts.topology.teston_topology import TestONTopology
+ # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.log.report( "This testcase is testing if all ONOS nodes" +
+ " are in topology sync with mininet" )
+ main.log.report( "__________________________________" )
+ main.case( "Comparing Mininet topology with the topology of ONOS" )
+ main.step( "Start continuous pings" )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong(
+ src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
+
+ main.step( "Create TestONTopology object" )
+ global ctrls
+ ctrls = []
+ count = 1
+ while True:
+ temp = ()
+ if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+ temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+ temp = temp + ( "ONOS" + str( count ), )
+ temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+ temp = temp + \
+ ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+ ctrls.append( temp )
+ count = count + 1
+ else:
+ break
+ global MNTopo
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
+ MNTopo = Topo
+
+ TopologyCheck = main.TRUE
+ main.step( "Compare ONOS Topology to MN Topology" )
+ devicesJson = main.ONOS2.devices()
+ linksJson = main.ONOS2.links()
+ # portsJson = main.ONOS2.ports()
+
+ result1 = main.Mininet1.compareSwitches(
+ MNTopo,
+ json.loads( devicesJson ) )
+ result2 = main.Mininet1.compareLinks(
+ MNTopo,
+ json.loads( linksJson ) )
+ # result3 = main.Mininet1.comparePorts(
+ # MNTopo, json.loads( portsJson ) )
+
+ # result = result1 and result2 and result3
+ result = result1 and result2
+
+ print "***********************"
+ if result == main.TRUE:
+ main.log.report( "ONOS" + " Topology matches MN Topology" )
+ else:
+ main.log.report( "ONOS" + " Topology does not match MN Topology" )
+
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=result,
+ onpass="ONOS" +
+ " Topology matches MN Topology",
+ onfail="ONOS" +
+ " Topology does not match MN Topology" )
+
+ TopologyCheck = TopologyCheck and result
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=TopologyCheck,
+ onpass="Topology checks passed",
+ onfail="Topology checks failed" )
+
+ def CASE7( self, main ):
+ from sts.topology.teston_topology import TestONTopology
+
+ linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+ main.log.report( "This testscase is killing a link to ensure that" +
+ " link discovery is consistent" )
+ main.log.report( "__________________________________" )
+ main.log.report( "Killing a link to ensure that link discovery" +
+ " is consistent" )
+ main.case( "Killing a link to Ensure that Link Discovery" +
+ "is Working Properly" )
+ """
+ main.step( "Start continuous pings" )
+
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
+ main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
+ """
+ main.step( "Determine the current number of switches and links" )
+ topologyOutput = main.ONOS2.topology()
+ topologyResult = main.ONOS1.getTopology( topologyOutput )
+ activeSwitches = topologyResult[ 'deviceCount' ]
+ links = topologyResult[ 'linkCount' ]
+ print "activeSwitches = ", type( activeSwitches )
+ print "links = ", type( links )
+ main.log.info(
+ "Currently there are %s switches and %s links" %
+ ( str( activeSwitches ), str( links ) ) )
+
+ main.step( "Kill Link between s3 and s28" )
+ main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
+ time.sleep( linkSleep )
+ topologyOutput = main.ONOS2.topology()
+ LinkDown = main.ONOS1.checkStatus(
+ topologyOutput, activeSwitches, str(
+ int( links ) - 2 ) )
+ if LinkDown == main.TRUE:
+ main.log.report( "Link Down discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=LinkDown,
+ onpass="Link Down discovered properly",
+ onfail="Link down was not discovered in " +
+ str( linkSleep ) +
+ " seconds" )
+
+ # Check ping result here..add code for it
+
+ main.step( "Bring link between s3 and s28 back up" )
+ LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+ time.sleep( linkSleep )
+ topologyOutput = main.ONOS2.topology()
+ LinkUp = main.ONOS1.checkStatus(
+ topologyOutput,
+ activeSwitches,
+ str( links ) )
+ if LinkUp == main.TRUE:
+ main.log.report( "Link up discovered properly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=LinkUp,
+ onpass="Link up discovered properly",
+ onfail="Link up was not discovered in " +
+ str( linkSleep ) +
+ " seconds" )
+
+ # NOTE Check ping result here..add code for it
+
+ main.step( "Compare ONOS Topology to MN Topology" )
+ Topo = TestONTopology(
+ main.Mininet1,
+ ctrls ) # can also add Intent API info for intent operations
+ MNTopo = Topo
+ TopologyCheck = main.TRUE
+
+ devicesJson = main.ONOS2.devices()
+ linksJson = main.ONOS2.links()
+ portsJson = main.ONOS2.ports()
+
+ result1 = main.Mininet1.compareSwitches(
+ MNTopo,
+ json.loads( devicesJson ) )
+ result2 = main.Mininet1.compareLinks(
+ MNTopo,
+ json.loads( linksJson ) )
+ # result3 = main.Mininet1.comparePorts(
+ # MNTopo, json.loads( portsJson ) )
+
+ # result = result1 and result2 and result3
+ result = result1 and result2
+ print "***********************"
+
+ if result == main.TRUE:
+ main.log.report( "ONOS" + " Topology matches MN Topology" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=result,
+ onpass="ONOS" +
+ " Topology matches MN Topology",
+ onfail="ONOS" +
+ " Topology does not match MN Topology" )
+
+ TopologyCheck = TopologyCheck and result
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=TopologyCheck,
+ onpass="Topology checks passed",
+ onfail="Topology checks failed" )
+
+ result = LinkDown and LinkUp and TopologyCheck
+ utilities.assert_equals( expect=main.TRUE, actual=result,
+ onpass="Link failure is discovered correctly",
+ onfail="Link Discovery failed" )
+
+ def CASE8( self ):
+ """
+ Intent removal
+ """
+ import time
+ main.log.report( "This testcase removes any previously added intents" +
+ " before adding any new set of intents" )
+ main.log.report( "__________________________________" )
+ main.log.info( "intent removal" )
+ main.case( "Removing installed intents" )
+ main.step( "Obtain the intent id's" )
+ intentResult = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + intentResult )
+ intentLinewise = intentResult.split( "\n" )
+
+ intentList = [line for line in intentLinewise \
+ if line.startswith( "id=")]
+ intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
+ intentList]
+ for id in intentids:
+ print "id = ", id
+
+ main.step(
+ "Iterate through the intentids list and remove each intent" )
+ for id in intentids:
+ main.ONOS2.removeIntent( intentId=id )
+
+ intentResult = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + intentResult )
+
+ intentList = [line for line in intentResult.split( "\n" ) \
+ if line.startswith( "id=")]
+ intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
+ intentList]
+ for state in intentState:
+ print state
+
+ case8Result = main.TRUE
+ for state in intentState:
+ if state != 'WITHDRAWN':
+ case8Result = main.FALSE
+ break
+
+ if case8Result == main.TRUE:
+ main.log.report( "Intent removal successful" )
+ else:
+ main.log.report( "Intent removal failed" )
+
+ PingResult = main.TRUE
+ if case8Result == main.TRUE:
+ i = 8
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.TRUE:
+ i = 19
+ PingResult = PingResult and main.TRUE
+ elif ping == main.FALSE:
+ i += 1
+ PingResult = PingResult and main.FALSE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ # Note: If the ping result failed, that means the intents have been
+ # withdrawn correctly.
+ if PingResult == main.TRUE:
+ main.log.report( "Installed intents have not been withdrawn correctly" )
+ # main.cleanup()
+ # main.exit()
+ if PingResult == main.FALSE:
+ main.log.report( "Installed intents have been withdrawn correctly" )
+
+ case8Result = case8Result and PingResult
+
+ if case8Result == main.FALSE:
+ main.log.report( "Intent removal successful" )
+ else:
+ main.log.report( "Intent removal failed" )
+
+ utilities.assert_equals( expect=main.FALSE, actual=case8Result,
+ onpass="Intent removal test passed",
+ onfail="Intent removal test failed" )
+
+ def CASE9( self ):
+ main.log.report(
+ "This testcase adds point intents and then does pingall" )
+ main.log.report( "__________________________________" )
+ main.log.info( "Adding point intents" )
+ main.case(
+ "Adding bidirectional point for mn hosts" +
+ "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
+ "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
+
+ main.step( "Add point intents for mn hosts h8 and h18 or" +
+ "ONOS hosts h8 and h12" )
+ # main.step(var1)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003008/1",
+ "of:0000000000006018/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006018/1",
+ "of:0000000000003008/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
+ main.step(var2)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003009/1",
+ "of:0000000000006019/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006019/1",
+ "of:0000000000003009/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
+ main.step(var3)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003010/1",
+ "of:0000000000006020/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006020/1",
+ "of:0000000000003010/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var4 = "Add point intents for mininet hosts h11 and h21 or" +\
+ " ONOS hosts hB and h15"
+ main.case(var4)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003011/1",
+ "of:0000000000006021/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006021/1",
+ "of:0000000000003011/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var5 = "Add point intents for mininet hosts h12 and h22 " +\
+ "ONOS hosts hC and h16"
+ main.case(var5)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003012/1",
+ "of:0000000000006022/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006022/1",
+ "of:0000000000003012/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var6 = "Add point intents for mininet hosts h13 and h23 or" +\
+ " ONOS hosts hD and h17"
+ main.case(var6)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003013/1",
+ "of:0000000000006023/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006023/1",
+ "of:0000000000003013/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var7 = "Add point intents for mininet hosts h14 and h24 or" +\
+ " ONOS hosts hE and h18"
+ main.case(var7)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003014/1",
+ "of:0000000000006024/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006024/1",
+ "of:0000000000003014/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var8 = "Add point intents for mininet hosts h15 and h25 or" +\
+ " ONOS hosts hF and h19"
+ main.case(var8)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003015/1",
+ "of:0000000000006025/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006025/1",
+ "of:0000000000003015/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var9 = "Add intents for mininet hosts h16 and h26 or" +\
+ " ONOS hosts h10 and h1A"
+ main.case(var9)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003016/1",
+ "of:0000000000006026/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006026/1",
+ "of:0000000000003016/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ # main.log.info( getIntentResult )
+
+ var10 = "Add point intents for mininet hosts h17 and h27 or" +\
+ " ONOS hosts h11 and h1B"
+ main.case(var10)
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000003017/1",
+ "of:0000000000006027/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ #main.log.info( getIntentResult )
+
+ ptpIntentResult = main.ONOS2.addPointIntent(
+ "of:0000000000006027/1",
+ "of:0000000000003017/1" )
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
+ main.log.info( "Point to point intent install successful" )
+ #main.log.info( getIntentResult )
+
+ print(
+ "___________________________________________________________" )
+
+ flowHandle = main.ONOS2.flows()
+ #main.log.info( "flows :" + flowHandle )
+
+ count = 1
+ i = 8
+ PingResult = main.TRUE
+ while i < 18:
+ main.log.info(
+ "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+ ping = main.Mininet1.pingHost(
+ src="h" + str( i ), target="h" + str( i + 10 ) )
+ if ping == main.FALSE and count < 5:
+ count += 1
+ # i = 8
+ PingResult = main.FALSE
+ main.log.report( "Ping between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ " failed. Making attempt number " +
+ str( count ) +
+ " in 2 seconds" )
+ time.sleep( 2 )
+ elif ping == main.FALSE:
+ main.log.report( "All ping attempts between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "have failed" )
+ i = 19
+ PingResult = main.FALSE
+ elif ping == main.TRUE:
+ main.log.info( "Ping test between h" +
+ str( i ) +
+ " and h" +
+ str( i +
+ 10 ) +
+ "passed!" )
+ i += 1
+ PingResult = main.TRUE
+ else:
+ main.log.info( "Unknown error" )
+ PingResult = main.ERROR
+
+ if PingResult == main.FALSE:
+ main.log.report(
+ "Point intents have not ben installed correctly. Cleaning up" )
+ # main.cleanup()
+ # main.exit()
+ if PingResult == main.TRUE:
+ main.log.report( "Point Intents have been installed correctly" )
+
+ case9Result = PingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=case9Result,
+ onpass="Point intents addition and Pingall Test successful",
+ onfail="Point intents addition and Pingall Test NOT successful" )
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.params b/TestON/tests/ProdFunc13/ProdFunc13.params
index 4367bf4..b926dad 100755
--- a/TestON/tests/ProdFunc13/ProdFunc13.params
+++ b/TestON/tests/ProdFunc13/ProdFunc13.params
@@ -1,11 +1,13 @@
<PARAMS>
-
+ #1,4,10,5,6,7,8,9,8,11,8,20,21,22,10,23,24
<testcases>1,4,10,5,6,7,8,9,8,11,8,2,20,21,22,10,23,24</testcases>
#Environment variables
<ENV>
<cellName>driver_test</cellName>
</ENV>
-
+ <GIT>
+ <pull>False</pull>
+ </GIT>
<CTRL>
<ip1>10.128.20.11</ip1>
<port1>6633</port1>
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.py b/TestON/tests/ProdFunc13/ProdFunc13.py
index a4d819c..ade6d07 100644
--- a/TestON/tests/ProdFunc13/ProdFunc13.py
+++ b/TestON/tests/ProdFunc13/ProdFunc13.py
@@ -31,6 +31,7 @@
"""
cellName = main.params[ 'ENV' ][ 'cellName' ]
ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ gitPull = main.params[ 'GIT' ][ 'pull' ]
main.case( "Setting up test environment" )
main.log.report(
@@ -41,44 +42,54 @@
cellResult = main.ONOSbench.setCell( cellName )
verifyResult = main.ONOSbench.verifyCell()
- main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onosRemoveRaftLogs()
-
main.step( "Git checkout and get version" )
- #main.ONOSbench.gitCheckout( "master" )
- gitPullResult = main.ONOSbench.gitPull()
- main.log.info( "git_pull_result = " + str( gitPullResult ))
+ main.ONOSbench.gitCheckout( "master" )
+ if gitPull == 'True':
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == 1:
+ main.step( "Using mvn clean & install" )
+ main.ONOSbench.cleanInstall()
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+ elif gitPullResult == 0:
+ main.log.report(
+ "Git Pull Failed, look into logs for detailed reason" )
+ main.cleanup()
+ main.exit()
+ main.log.info( "git_pull_result = " + str( gitPullResult ))
+ else:
+ main.log.info( "Skipping git pull" )
main.ONOSbench.getVersion( report=True )
+ packageResult = main.TRUE
- if gitPullResult == 1:
- main.step( "Using mvn clean & install" )
- main.ONOSbench.cleanInstall()
- elif gitPullResult == 0:
- main.log.report(
- "Git Pull Failed, look into logs for detailed reason" )
- main.cleanup()
- main.exit()
+ main.step( "Uninstalling ONOS package" )
+ onosInstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
+ if onosInstallResult == main.TRUE:
+ main.log.report( "Uninstalling ONOS package successful" )
+ else:
+ main.log.report( "Uninstalling ONOS package failed" )
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.onosPackage()
-
+ time.sleep( 20 )
main.step( "Installing ONOS package" )
- onosInstallResult = main.ONOSbench.onosInstall()
+ onosInstallResult = main.ONOSbench.onosInstall( ONOS1Ip )
+ print onosInstallResult
if onosInstallResult == main.TRUE:
main.log.report( "Installing ONOS package successful" )
else:
main.log.report( "Installing ONOS package failed" )
+ time.sleep( 20 )
onos1Isup = main.ONOSbench.isup()
if onos1Isup == main.TRUE:
main.log.report( "ONOS instance is up and ready" )
else:
main.log.report( "ONOS instance may not be up" )
- main.step( "Starting ONOS service" )
- startResult = main.ONOSbench.onosStart( ONOS1Ip )
+ startResult = main.TRUE
+ #main.step( "Starting ONOS service" )
+ #startResult = main.ONOSbench.onosStart( ONOS1Ip )
- main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.ONOS2.startOnosCli( ONOS1Ip )
main.step( "Starting Mininet CLI..." )
# Starting the mininet using the old way
@@ -183,6 +194,7 @@
Exit from mininet cli
reinstall ONOS
"""
+ import time
cellName = main.params[ 'ENV' ][ 'cellName' ]
ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
@@ -190,22 +202,60 @@
"ONOS to switch over to Packet Optical topology" )
main.log.report( "_____________________________________________" )
main.case( "Disconnecting mininet and restarting ONOS" )
+
main.step( "Disconnecting mininet and restarting ONOS" )
+ step1Result = main.TRUE
mininetDisconnect = main.Mininet1.disconnect()
- print "mininetDisconnect = ", mininetDisconnect
-
- main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onosRemoveRaftLogs()
-
+ print "mininetDisconnect = ", mininetDisconnect
+ step1Result = mininetDisconnect
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Mininet disconnect successfully",
+ onfail="Mininet failed to disconnect")
+ """
+ main.step( "Removing raft logs before a clean installation of ONOS" )
+ step2Result = main.TRUE
+ removeRaftLogsResult = main.ONOSbench.onosRemoveRaftLogs()
+ step2Result = removeRaftLogsResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Raft logs removed successfully",
+ onfail="Failed to remove raft logs")
+ """
main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- verifyResult = main.ONOSbench.verifyCell()
+ step3Result = main.TRUE
+ setCellResult = main.ONOSbench.setCell( cellName )
+ verifyCellResult = main.ONOSbench.verifyCell()
+ step3Result = setCellResult and verifyCellResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step3Result,
+ onpass="Cell applied successfully",
+ onfail="Failed to apply cell")
- onosInstallResult = main.ONOSbench.onosInstall()
- if onosInstallResult == main.TRUE:
- main.log.report( "Installing ONOS package successful" )
- else:
- main.log.report( "Installing ONOS package failed" )
+ main.step( "Uninstalling ONOS package" )
+ step4Result = main.TRUE
+ ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ]
+ onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1)
+ step4Result = onosUninstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully uninstalled ONOS",
+ onfail="Failed to uninstall ONOS")
+
+ time.sleep( 5 )
+ main.step( "Installing ONOS package" )
+ step5Result = main.TRUE
+ onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 )
+ step5Result = onosInstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step5Result,
+ onpass="Successfully installed ONOS",
+ onfail="Failed to install ONOS")
onos1Isup = main.ONOSbench.isup()
if onos1Isup == main.TRUE:
@@ -214,19 +264,24 @@
main.log.report( "ONOS instance may not be up" )
main.step( "Starting ONOS service" )
+ step6Result = main.TRUE
startResult = main.ONOSbench.onosStart( ONOS1Ip )
-
- main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- case20Result = mininetDisconnect and cellResult and verifyResult \
- and onosInstallResult and onos1Isup and \
- startResult
+ step6Result = startResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case20Result,
- onpass= "Exiting functionality mininet topology and reinstalling" +
- " ONOS successful",
- onfail= "Exiting functionality mininet topology and reinstalling" +
- " ONOS failed" )
+ actual=step6Result,
+ onpass="Successfully started ONOS",
+ onfail="Failed to start ONOS")
+
+ main.step( "Starting ONOS cli" )
+ step7Result = main.TRUE
+ cliResult = main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ step7Result = cliResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step7Result,
+ onpass="Successfully started ONOS cli",
+ onfail="Failed to start ONOS cli")
def CASE21( self, main ):
"""
@@ -238,20 +293,37 @@
from the topology, instead the links are learnt
from the json config file
"""
+ import time
main.log.report(
"This testcase starts the packet layer topology and REST" )
main.log.report( "_____________________________________________" )
main.case( "Starting LINC-OE and other components" )
- main.step( "Starting LINC-OE and other components" )
- appInstallResult = main.ONOS2.featureInstall( "onos-app-optical" )
- opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
- case21Result = opticalMnScript and appInstallResult
+ main.step( "Activate optical app" )
+ step1Result = main.TRUE
+ activateOpticalResult = main.ONOS2.activateApp( "org.onosproject.optical" )
+ step1Result = activateOpticalResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case21Result,
- onpass="Packet optical topology spawned successsfully",
- onfail="Packet optical topology spawning failed" )
+ actual=step1Result,
+ onpass="Successfully activated optical app",
+ onfail="Failed to activate optical app")
+
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
+
+ main.step( "Starting mininet and LINC-OE" )
+ step2Result = main.TRUE
+ time.sleep( 10 )
+ opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
+ step2Result = opticalMnScript
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Started the topology successfully ",
+ onfail="Failed to start the topology")
def CASE22( self, main ):
"""
@@ -259,21 +331,32 @@
6 packet layer mininet switches each with one host.
Therefore, the roadmCount variable = 10,
packetLayerSWCount variable = 6, hostCount=6 and
- links=42.
+ links=46.
All this is hardcoded in the testcase. If the topology changes,
these hardcoded values need to be changed
"""
+ import time
main.log.report(
"This testcase compares the optical+packet topology against what" +
" is expected" )
main.case( "Topology comparision" )
- main.step( "Topology comparision" )
- main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- devicesResult = main.ONOS3.devices( jsonFormat=False )
- print "devices_result = ", devicesResult
+ main.step( "Starts new ONOS cli" )
+ step1Result = main.TRUE
+ cliResult = main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ]\
+ [ 'ip1' ] )
+ step1Result = cliResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully starts a new cli",
+ onfail="Failed to start new cli" )
+
+ main.step( "Compare topology" )
+ step2Result = main.TRUE
+ devicesResult = main.ONOS3.devices( jsonFormat=False )
+ print "devices_result :\n", devicesResult
devicesLinewise = devicesResult.split( "\n" )
- devicesLinewise = devicesLinewise[ 1: ]
roadmCount = 0
packetLayerSWCount = 0
for line in devicesLinewise:
@@ -299,7 +382,6 @@
str( roadmCount ) +
" and is wrong" )
opticalSWResult = main.FALSE
-
if packetLayerSWCount == 6:
print "Number of Packet layer or mininet Switches = %d "\
% packetLayerSWCount + "and is correctly detected"
@@ -316,14 +398,15 @@
str( packetLayerSWCount ) +
" and is wrong" )
packetSWResult = main.FALSE
+ # sleeps for sometime so the state of the switches will be active
+ time.sleep( 30 )
print "_________________________________"
-
linksResult = main.ONOS3.links( jsonFormat=False )
print "links_result = ", linksResult
print "_________________________________"
- linkActiveCount = linksResult.count("state=ACTIVE")
+ linkActiveCount = linksResult.count("state=ACTIVE")
main.log.info( "linkActiveCount = " + str( linkActiveCount ))
- if linkActiveCount == 42:
+ if linkActiveCount == 46:
linkActiveResult = main.TRUE
main.log.info(
"Number of links in ACTIVE state are correct")
@@ -331,41 +414,13 @@
linkActiveResult = main.FALSE
main.log.info(
"Number of links in ACTIVE state are wrong")
-
- # NOTE:Since only point intents are added, there is no
- # requirement to discover the hosts
- # Therfore, the below portion of the code is commented.
- """
- #Discover hosts using pingall
- pingallResult = main.LincOE2.pingall()
-
- hostsResult = main.ONOS3.hosts( jsonFormat=False )
- main.log.info( "hosts_result = "+hostsResult )
- main.log.info( "_________________________________" )
- hostsLinewise = hostsResult.split( "\n" )
- hostsLinewise = hostsLinewise[ 1:-1 ]
- hostCount = 0
- for line in hostsLinewise:
- hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
- hostCount +=1
- if hostCount ==2:
- print "Number of hosts = %d and is correctly detected" %hostCount
- main.log.info( "Number of hosts = " + str( hostCount ) +" and \
- is correctly detected" )
- hostDiscovery = main.TRUE
- else:
- print "Number of hosts = %d and is wrong" %hostCount
- main.log.info( "Number of hosts = " + str( hostCount ) +" and \
- is wrong" )
- hostDiscovery = main.FALSE
- """
- case22Result = opticalSWResult and packetSWResult and \
+ step2Result = opticalSWResult and packetSWResult and \
linkActiveResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case22Result,
- onpass="Packet optical topology discovery successful",
- onfail="Packet optical topology discovery failed" )
+ actual=step2Result,
+ onpass="Successfully loaded packet optical topology",
+ onfail="Failed to load packet optical topology" )
def CASE23( self, main ):
import time
@@ -377,71 +432,50 @@
main.log.report(
"This testcase adds bidirectional point intents between 2 " +
"packet layer( mininet ) devices and ping mininet hosts" )
- main.case( "Topology comparision" )
+ main.case( "Install point intents between 2 packet layer device and " +
+ "ping the hosts" )
+
main.step( "Adding point intents" )
- ptpIntentResult = main.ONOS3.addPointIntent(
+ checkFlowResult = main.TRUE
+ step1Result = main.TRUE
+ main.pIntentsId = []
+ pIntent1 = main.ONOS3.addPointIntent(
"of:0000ffffffff0001/1",
"of:0000ffffffff0005/1" )
- if ptpIntentResult == main.TRUE:
- main.ONOS3.intents( jsonFormat=False )
- main.log.info( "Point to point intent install successful" )
-
- ptpIntentResult = main.ONOS3.addPointIntent(
+ pIntent2 = main.ONOS3.addPointIntent(
"of:0000ffffffff0005/1",
"of:0000ffffffff0001/1" )
- if ptpIntentResult == main.TRUE:
- main.ONOS3.intents( jsonFormat=False )
- main.log.info( "Point to point intent install successful" )
-
- time.sleep( 30 )
- flowHandle = main.ONOS3.flows()
- main.log.info( "flows :" + flowHandle )
-
+ main.pIntentsId.append( pIntent1 )
+ main.pIntentsId.append( pIntent2 )
+ time.sleep( 10 )
+ main.log.info( "Checking intents state")
+ checkStateResult = main.ONOS3.checkIntentState(
+ intentsId = main.pIntentsId )
+ time.sleep( 10 )
+ main.log.info( "Checking flows state")
+ checkFlowResult = main.ONOS3.checkFlowsState()
# Sleep for 30 seconds to provide time for the intent state to change
- time.sleep( 60 )
- intentHandle = main.ONOS3.intents( jsonFormat=False )
- main.log.info( "intents :" + intentHandle )
-
- PingResult = main.TRUE
- count = 1
- main.log.info( "\n\nh1 is Pinging h5" )
- ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
- # ping = main.LincOE2.pinghost()
- if ping == main.FALSE and count < 5:
- count += 1
- PingResult = main.FALSE
- main.log.info(
- "Ping between h1 and h5 failed. Making attempt number " +
- str( count ) +
- " in 2 seconds" )
- time.sleep( 2 )
- elif ping == main.FALSE:
- main.log.info( "All ping attempts between h1 and h5 have failed" )
- PingResult = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h1 and h5 passed!" )
- PingResult = main.TRUE
- else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
-
- if PingResult == main.FALSE:
- main.log.report(
- "Point intents for packet optical have not ben installed" +
- " correctly. Cleaning up" )
- if PingResult == main.TRUE:
- main.log.report(
- "Point Intents for packet optical have been " +
- "installed correctly" )
-
- case23Result = PingResult
+ time.sleep( 10 )
+ main.log.info( "Checking intents state one more time")
+ checkStateResult = main.ONOS3.checkIntentState(
+ intentsId = main.pIntentsId )
+ step1Result = checkStateResult and checkFlowResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case23Result,
- onpass= "Point intents addition for packet optical and" +
- "Pingall Test successful",
- onfail= "Point intents addition for packet optical and" +
- "Pingall Test NOT successful" )
+ actual=step1Result,
+ onpass="Successfully added point intents",
+ onfail="Failed to add point intents")
+
+ main.step( "Ping h1 and h5" )
+ step2Result = main.TRUE
+ main.log.info( "\n\nh1 is Pinging h5" )
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ step2Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Successfully pinged h1 and h5",
+ onfail="Failed to ping between h1 and h5")
def CASE24( self, main ):
import time
@@ -462,16 +496,23 @@
main.log.report(
"This testcase tests rerouting and pings mininet hosts" )
main.case( "Test rerouting and pings mininet hosts" )
+
main.step( "Attach to the Linc-OE session" )
- attachConsole = main.LincOE1.attachLincOESession()
- print "attachConsole = ", attachConsole
+ step1Result = main.TRUE
+ attachConsole = main.LincOE1.attachLincOESession()
+ step1Result = attachConsole
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully attached Linc-OE session",
+ onfail="Failed to attached Linc-OE session")
main.step( "Bring a port down and verify the link state" )
+ step2Result = main.TRUE
main.LincOE1.portDown( swId="9", ptId="20" )
linksNonjson = main.ONOS3.links( jsonFormat=False )
main.log.info( "links = " + linksNonjson )
-
- linkInactiveCount = linksNonjson.count("state=INACTIVE")
+ linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
if linkInactiveCount == 2:
main.log.info(
@@ -479,10 +520,8 @@
else:
main.log.info(
"Number of links in INACTIVE state are wrong")
-
links = main.ONOS3.links()
main.log.info( "links = " + links )
-
linksResult = json.loads( links )
linksStateResult = main.FALSE
for item in linksResult:
@@ -506,45 +545,184 @@
main.log.report(
"Links state is not inactive as expected" )
linksStateResult = main.FALSE
-
- print "links_state_result = ", linksStateResult
time.sleep( 10 )
- flowHandle = main.ONOS3.flows()
- main.log.info( "flows :" + flowHandle )
+ checkFlowsState = main.ONOS3.checkFlowsState()
+ step2Result = linksStateResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step2Result,
+ onpass="Successfuly brought down a link",
+ onfail="Failed to bring down a link")
main.step( "Verify Rerouting by a ping test" )
- PingResult = main.TRUE
- count = 1
+ step3Result = main.TRUE
main.log.info( "\n\nh1 is Pinging h5" )
- ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
- # ping = main.LincOE2.pinghost()
- if ping == main.FALSE and count < 5:
- count += 1
- PingResult = main.FALSE
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
+ step3Result = pingResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step3Result,
+ onpass="Successfully pinged h1 and h5",
+ onfail="Failed to ping between h1 and h5")
+
+ main.step( "Bring the downed port up and verify the link state" )
+ step4Result = main.TRUE
+ main.LincOE1.portUp( swId="9", ptId="20" )
+ linksNonjson = main.ONOS3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
+ linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
+ main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
+ if linkInactiveCount == 0:
main.log.info(
- "Ping between h1 and h5 failed. Making attempt number " +
- str( count ) +
- " in 2 seconds" )
- time.sleep( 2 )
- elif ping == main.FALSE:
- main.log.info( "All ping attempts between h1 and h5 have failed" )
- PingResult = main.FALSE
- elif ping == main.TRUE:
- main.log.info( "Ping test between h1 and h5 passed!" )
- PingResult = main.TRUE
+ "Number of links in INACTIVE state are correct")
else:
- main.log.info( "Unknown error" )
- PingResult = main.ERROR
+ main.log.info(
+ "Number of links in INACTIVE state are wrong")
+ step4Result = main.FALSE
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully brought the port up",
+ onfail="Failed to bring the port up")
+ """
+ main.step( "Removing host intents" )
+ step5Result = main.TRUE
+ removeResult = main.TRUE
+ # Check remaining intents
+ intentsJson = json.loads( main.ONOS3.intents() )
+ main.ONOS3.removeIntent( intentId=intent1, purge=True )
+ main.ONOS3.removeIntent( intentId=intent2, purge=True )
+ for intents in intentsJson:
+ main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
+ app='org.onosproject.optical',
+ purge=True )
+ print json.loads( main.ONOS3.intents() )
+ if len( json.loads( main.ONOS3.intents() ) ):
+ removeResult = main.FALSE
+ step5Result = removeResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step5Result,
+ onpass="Successfully removed host intents",
+ onfail="Failed to remove host intents" )
+ """
+ def CASE10( self ):
+ main.log.report(
+ "This testcase uninstalls the reactive forwarding app" )
+ main.log.report( "__________________________________" )
+ main.case( "Uninstalling reactive forwarding app" )
+ main.step( "Uninstalling reactive forwarding app" )
+ step1Result = main.TRUE
+ # Unistall onos-app-fwd app to disable reactive forwarding
+ main.log.info( "deactivate reactive forwarding app" )
+ appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
+ step1Result = appUninstallResult
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Successfully deactivate reactive forwarding app",
+ onfail="Failed to deactivate reactive forwarding app")
+ # After reactive forwarding is disabled, the reactive flows on
+ # switches timeout in 10-15s
+ # So sleep for 15s
+ time.sleep( 15 )
+ flows = main.ONOS2.flows()
+ main.log.info( flows )
- if PingResult == main.TRUE:
- main.log.report( "Ping test successful " )
- if PingResult == main.FALSE:
- main.log.report( "Ping test failed" )
+ def CASE25( self ):
+ """
+ Add host intents between 2 packet layer host
+ """
+ import time
+ import json
+ main.log.report( "Adding host intents between 2 optical layer host" )
+ main.case( "Test add host intents between optical layer host" )
- case24Result = PingResult and linksStateResult
- utilities.assert_equals( expect=main.TRUE, actual=case24Result,
- onpass="Packet optical rerouting successful",
- onfail="Packet optical rerouting failed" )
+ main.step( "Discover host using arping" )
+ step1Result = main.TRUE
+ main.hostMACs = []
+ main.hostId = []
+ #Listing host MAC addresses
+ for i in range( 1 , 7 ):
+ main.hostMACs.append( "00:00:00:00:00:" +
+ str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
+ for macs in main.hostMACs:
+ main.hostId.append( macs + "/-1" )
+ host1 = main.hostId[ 0 ]
+ host2 = main.hostId[ 1 ]
+ # Use arping to discover the hosts
+ main.LincOE2.arping( host = "h1" )
+ main.LincOE2.arping( host = "h2" )
+ time.sleep( 5 )
+ hostsDict = main.ONOS3.hosts()
+ if not len( hostsDict ):
+ step1Result = main.FALSE
+ # Adding host intent
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=step1Result,
+ onpass="Hosts discovered",
+ onfail="Failed to discover hosts")
+
+ main.step( "Adding host intents to h1 and h2" )
+ step2Result = main.TRUE
+ intentsId = []
+ intent1 = main.ONOS3.addHostIntent( hostIdOne = host1,
+ hostIdTwo = host2 )
+ intentsId.append( intent1 )
+ time.sleep( 5 )
+ intent2 = main.ONOS3.addHostIntent( hostIdOne = host2,
+ hostIdTwo = host1 )
+ intentsId.append( intent2 )
+ # Checking intents state before pinging
+ main.log.info( "Checking intents state" )
+ time.sleep( 15 )
+ intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
+ #check intent state again if intents are not in installed state
+ if not intentResult:
+ intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
+ step2Result = intentResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step2Result,
+ onpass="All intents are in INSTALLED state ",
+ onfail="Some of the intents are not in " +
+ "INSTALLED state " )
+
+ # pinging h1 to h2 and then ping h2 to h1
+ main.step( "Pinging h1 and h2" )
+ step3Result = main.TRUE
+ pingResult = main.TRUE
+ pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" )
+ pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2",
+ target="h1" )
+ step3Result = pingResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step3Result,
+ onpass="Pinged successfully between h1 and h2",
+ onfail="Pinged failed between h1 and h2" )
+ # Removed all added host intents
+ main.step( "Removing host intents" )
+ step4Result = main.TRUE
+ removeResult = main.TRUE
+ # Check remaining intents
+ intentsJson = json.loads( main.ONOS3.intents() )
+ main.ONOS3.removeIntent( intentId=intent1, purge=True )
+ main.ONOS3.removeIntent( intentId=intent2, purge=True )
+ for intents in intentsJson:
+ main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
+ app='org.onosproject.optical',
+ purge=True )
+ print json.loads( main.ONOS3.intents() )
+ if len( json.loads( main.ONOS3.intents() ) ):
+ removeResult = main.FALSE
+ step4Result = removeResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=step4Result,
+ onpass="Successfully removed host intents",
+ onfail="Failed to remove host intents" )
def CASE4( self, main ):
import re
@@ -553,6 +731,7 @@
" all the switches to all the controllers and" +
" discovering the hosts in reactive mode" )
main.log.report( "__________________________________" )
+
main.case( "Pingall Test" )
main.step( "Assigning switches to controllers" )
ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
@@ -651,6 +830,13 @@
ip5=ONOS5Ip,port5=ONOS5Port )
"""
# REACTIVE FWD test
+ main.log.info( "Activate fwd app" )
+ appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
+ time.sleep( 10 )
main.step( "Get list of hosts from Mininet" )
hostList = main.Mininet1.getHosts()
@@ -687,31 +873,6 @@
onpass="Controller assignment and Pingall Test successful",
onfail="Controller assignment and Pingall Test NOT successful" )
- def CASE10( self ):
- main.log.report(
- "This testcase uninstalls the reactive forwarding app" )
- main.log.report( "__________________________________" )
- main.case( "Uninstalling reactive forwarding app" )
- # Unistall onos-app-fwd app to disable reactive forwarding
- appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
- main.log.info( "onos-app-fwd uninstalled" )
-
- # After reactive forwarding is disabled, the reactive flows on
- # switches timeout in 10-15s
- # So sleep for 15s
- time.sleep( 15 )
-
- flows = main.ONOS2.flows()
- main.log.info( flows )
-
- case10Result = appUninstallResult
- utilities.assert_equals(
- expect=main.TRUE,
- actual=case10Result,
- onpass="Reactive forwarding app uninstallation successful",
- onfail="Reactive forwarding app uninstallation failed" )
-
-
def CASE11( self ):
# NOTE: This testcase require reactive forwarding mode enabled
# NOTE: in the beginning and then uninstall it before adding
@@ -727,26 +888,40 @@
main.step( "Moving host h9 from device s9 and attach it to s8" )
main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
- time.sleep(15) #Time delay to have all the flows ready
+ main.log.info( "Activate fwd app" )
+ appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
+
+ time.sleep(25) #Time delay to have all the flows ready
main.step( "Pingall" )
pingResult = main.FALSE
time1 = time.time()
- pingResult = main.Mininet1.pingall()
+ pingResult = main.Mininet1.pingall( timeout=120,
+ shortCircuit=True,
+ acceptableFailed=20 )
time2 = time.time()
print "Time for pingall: %2f seconds" % ( time2 - time1 )
hosts = main.ONOS2.hosts( jsonFormat = False )
main.log.info( hosts )
- main.case( "Uninstalling reactive forwarding app" )
- # Unistall onos-app-fwd app to disable reactive forwarding
- appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
- main.log.info( "onos-app-fwd uninstalled" )
+ main.log.info( "deactivate reactive forwarding app" )
+ appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
+ appCheck = main.ONOS2.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.ONOS2.apps() )
+ main.log.warn( main.ONOS2.appIDs() )
main.step( "Add point intents between hosts on the same device")
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003008/1",
- "of:0000000000003008/3" )
+ "of:0000000000003008/3",
+ ethType='IPV4',
+ ethSrc='00:00:00:00:00:08',
+ ethDst='00:00:00:00:00:09' )
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -754,7 +929,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003008/3",
- "of:0000000000003008/1" )
+ "of:0000000000003008/1",
+ ethType='IPV4',
+ ethSrc='00:00:00:00:00:09',
+ ethDst='00:00:00:00:00:08' )
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -779,7 +957,7 @@
"Point intents for hosts on same devices" +
"installed correctly. Cleaning up" )
- case11Result = ping and pingResult
+ case11Result = ping
utilities.assert_equals(
expect = main.TRUE,
actual = case11Result,
@@ -788,7 +966,6 @@
onfail = "Point intents for hosts on same devices" +
"Ping Test NOT successful" )
-
def CASE12( self ):
"""
Verify the default flows on each switch in proactive mode
@@ -812,9 +989,6 @@
actual=case12Result,
onpass = "Expected default num of flows exist",
onfail = "Expected default num of flows do not exist")
-
-
-
def CASE6( self ):
import time
@@ -858,6 +1032,7 @@
"00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
print "______________________________________________________"
"""
+ intentsId = []
for i in range( 8, 18 ):
main.log.info(
"Adding host intent between h" + str( i ) +
@@ -872,8 +1047,9 @@
if host2:
host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
if host1Id and host2Id:
- main.ONOS2.addHostIntent( host1Id, host2Id )
+ intentsId.append( main.ONOS2.addHostIntent( host1Id, host2Id ) )
+ checkIntentResult = main.ONOS2.checkIntentState( intentsId )
time.sleep( 10 )
hIntents = main.ONOS2.intents( jsonFormat=False )
main.log.info( "intents:" + hIntents )
@@ -932,6 +1108,8 @@
main.log.report(
"Ping all test after Host intent addition successful" )
+ checkIntentResult = main.ONOS2.checkIntentState( intentsId )
+
case6Result = PingResult
utilities.assert_equals(
expect=main.TRUE,
@@ -940,6 +1118,9 @@
onfail="Pingall Test after Host intents addition failed" )
def CASE5( self, main ):
+ """
+ Check ONOS topology matches with mininet
+ """
import json
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
@@ -1016,7 +1197,7 @@
main.step( "Compare ONOS Topology to MN Topology" )
devicesJson = main.ONOS2.devices()
linksJson = main.ONOS2.links()
- # portsJson = main.ONOS2.ports()
+ portsJson = main.ONOS2.ports()
result1 = main.Mininet1.compareSwitches(
MNTopo,
@@ -1024,9 +1205,8 @@
result2 = main.Mininet1.compareLinks(
MNTopo,
json.loads( linksJson ) )
- # result3 = main.Mininet1.comparePorts(
- # MNTopo, json.loads( portsJson ) )
+ result3 = main.Mininet1.comparePorts( MNTopo, json.loads( portsJson ) )
# result = result1 and result2 and result3
result = result1 and result2
@@ -1052,6 +1232,11 @@
onfail="Topology checks failed" )
def CASE7( self, main ):
+ """
+ Link discovery test case. Checks if ONOS can discover a link
+ down or up properly.
+ """
+
from sts.topology.teston_topology import TestONTopology
linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
@@ -1100,8 +1285,8 @@
main.step( "Determine the current number of switches and links" )
topologyOutput = main.ONOS2.topology()
topologyResult = main.ONOS1.getTopology( topologyOutput )
- activeSwitches = topologyResult[ 'deviceCount' ]
- links = topologyResult[ 'linkCount' ]
+ activeSwitches = topologyResult[ 'devices' ]
+ links = topologyResult[ 'links' ]
print "activeSwitches = ", type( activeSwitches )
print "links = ", type( links )
main.log.info(
@@ -1164,8 +1349,7 @@
result2 = main.Mininet1.compareLinks(
MNTopo,
json.loads( linksJson ) )
- # result3 = main.Mininet1.comparePorts(
- # MNTopo, json.loads( portsJson ) )
+ result3 = main.Mininet1.comparePorts( MNTopo, json.loads( portsJson ) )
# result = result1 and result2 and result3
result = result1 and result2
@@ -1204,9 +1388,9 @@
main.log.info( "intent removal" )
main.case( "Removing installed intents" )
main.step( "Obtain the intent id's" )
- intentResult = main.ONOS2.intents( jsonFormat=False )
- main.log.info( "intent_result = " + intentResult )
- intentLinewise = intentResult.split( "\n" )
+ currentIntents = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + currentIntents )
+ intentLinewise = currentIntents.split( "\n" )
intentList = [line for line in intentLinewise \
if line.startswith( "id=")]
@@ -1218,30 +1402,31 @@
main.step(
"Iterate through the intentids list and remove each intent" )
for id in intentids:
- main.ONOS2.removeIntent( intentId=id )
+ main.ONOS2.removeIntent( intentId=id ,purge=True)
- intentResult = main.ONOS2.intents( jsonFormat=False )
- main.log.info( "intent_result = " + intentResult )
-
- intentList = [line for line in intentResult.split( "\n" ) \
+ remainingIntents = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + remainingIntents )
+ if remainingIntents:
+ main.log.info( "There are still remaining intents " )
+ intentResult = main.FALSE
+ else:
+ intentResult = main.TRUE
+
+ intentList = [line for line in remainingIntents.split( "\n" ) \
if line.startswith( "id=")]
intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
intentList]
for state in intentState:
print state
- case8Result = main.TRUE
+ case8Result = main.TRUE
for state in intentState:
if state != 'WITHDRAWN':
case8Result = main.FALSE
break
-
- if case8Result == main.TRUE:
- main.log.report( "Intent removal successful" )
- else:
- main.log.report( "Intent removal failed" )
PingResult = main.TRUE
+ """
if case8Result == main.TRUE:
i = 8
while i < 18:
@@ -1258,7 +1443,7 @@
else:
main.log.info( "Unknown error" )
PingResult = main.ERROR
-
+
# Note: If the ping result failed, that means the intents have been
# withdrawn correctly.
if PingResult == main.TRUE:
@@ -1267,42 +1452,51 @@
# main.exit()
if PingResult == main.FALSE:
main.log.report( "Installed intents have been withdrawn correctly" )
+ """
- case8Result = case8Result and PingResult
-
- if case8Result == main.FALSE:
+ if case8Result:
main.log.report( "Intent removal successful" )
else:
main.log.report( "Intent removal failed" )
- utilities.assert_equals( expect=main.FALSE, actual=case8Result,
+ utilities.assert_equals( expect=main.TRUE, actual=case8Result,
onpass="Intent removal test passed",
onfail="Intent removal test failed" )
def CASE9( self ):
+ """
+ Testing Point intents
+ """
main.log.report(
- "This testcase adds point intents and then does pingall" )
+ "This test case adds point intents and then does pingall" )
main.log.report( "__________________________________" )
main.log.info( "Adding point intents" )
main.case(
"Adding bidirectional point for mn hosts" +
"( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
"h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
-
+ macsDict = {}
+ for i in range( 1,29 ):
+ macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
+ print macsDict
main.step( "Add point intents for mn hosts h8 and h18 or" +
"ONOS hosts h8 and h12" )
# main.step(var1)
ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000003008/1",
- "of:0000000000006018/1" )
+ ingressDevice="of:0000000000003008/1",
+ egressDevice="of:0000000000006018/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h8' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
# main.log.info( getIntentResult )
ptpIntentResult = main.ONOS2.addPointIntent(
- "of:0000000000006018/1",
- "of:0000000000003008/1" )
+ ingressDevice="of:0000000000006018/1",
+ egressDevice="of:0000000000003008/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h18' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1312,7 +1506,9 @@
main.step(var2)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003009/1",
- "of:0000000000006019/1" )
+ "of:0000000000006019/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h9' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1320,7 +1516,9 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006019/1",
- "of:0000000000003009/1" )
+ "of:0000000000003009/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h19' ))
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1330,7 +1528,10 @@
main.step(var3)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003010/1",
- "of:0000000000006020/1" )
+ "of:0000000000006020/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h10' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1338,7 +1539,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006020/1",
- "of:0000000000003010/1" )
+ "of:0000000000003010/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h20' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1349,7 +1553,10 @@
main.case(var4)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003011/1",
- "of:0000000000006021/1" )
+ "of:0000000000006021/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h11' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1357,7 +1564,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006021/1",
- "of:0000000000003011/1" )
+ "of:0000000000003011/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h21' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1368,7 +1578,10 @@
main.case(var5)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003012/1",
- "of:0000000000006022/1" )
+ "of:0000000000006022/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h12' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1376,7 +1589,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006022/1",
- "of:0000000000003012/1" )
+ "of:0000000000003012/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h22' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1387,7 +1603,10 @@
main.case(var6)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003013/1",
- "of:0000000000006023/1" )
+ "of:0000000000006023/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h13' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1395,7 +1614,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006023/1",
- "of:0000000000003013/1" )
+ "of:0000000000003013/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h23' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1406,7 +1628,10 @@
main.case(var7)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003014/1",
- "of:0000000000006024/1" )
+ "of:0000000000006024/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h14' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1414,7 +1639,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006024/1",
- "of:0000000000003014/1" )
+ "of:0000000000003014/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h24' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1425,7 +1653,10 @@
main.case(var8)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003015/1",
- "of:0000000000006025/1" )
+ "of:0000000000006025/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h15' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1433,7 +1664,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006025/1",
- "of:0000000000003015/1" )
+ "of:0000000000003015/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h25' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1444,7 +1678,10 @@
main.case(var9)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003016/1",
- "of:0000000000006026/1" )
+ "of:0000000000006026/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h16' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1452,7 +1689,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006026/1",
- "of:0000000000003016/1" )
+ "of:0000000000003016/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h26' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1463,7 +1703,10 @@
main.case(var10)
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003017/1",
- "of:0000000000006027/1" )
+ "of:0000000000006027/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h17' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
@@ -1471,7 +1714,10 @@
ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006027/1",
- "of:0000000000003017/1" )
+ "of:0000000000003017/1",
+ ethType='IPV4',
+ ethSrc=macsDict.get( 'h27' ))
+
if ptpIntentResult == main.TRUE:
getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.topo b/TestON/tests/ProdFunc13/ProdFunc13.topo
index 9cef3f7..2605b2e 100755
--- a/TestON/tests/ProdFunc13/ProdFunc13.topo
+++ b/TestON/tests/ProdFunc13/ProdFunc13.topo
@@ -49,6 +49,7 @@
<arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
<arg2> --topo mytopo </arg2>
<arg3> --switch ovs,protocols=OpenFlow13 </arg3>
+ <arg4> --mac </arg4>
<controller> remote </controller>
</COMPONENTS>
</Mininet1>
diff --git a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.py b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.py
deleted file mode 100644
index 4400262..0000000
--- a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# ScaleOutTemplate
-#
-# CASE1 starts number of nodes specified in param file
-#
-# cameron@onlab.us
-
-import sys
-import os.path
-
-
-class ScaleOutTemplate:
-
- def __init__( self ):
- self.default = ''
-
- def CASE1( self, main ):
-
- import time
- global init
- try:
- if type(init) is not bool:
- init = False
- except NameError:
- init = False
-
- #Load values from params file
- checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
- gitPull = main.params[ 'GIT' ][ 'autopull' ]
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- Apps = main.params[ 'ENV' ][ 'cellApps' ]
- BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
- BENCHUser = main.params[ 'BENCH' ][ 'user' ]
- MN1Ip = main.params[ 'MN' ][ 'ip1' ]
- maxNodes = int(main.params[ 'availableNodes' ])
- skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
- cellName = main.params[ 'ENV' ][ 'cellName' ]
-
- # -- INIT SECTION, ONLY RUNS ONCE -- #
- if init == False:
- init = True
- global clusterCount #number of nodes running
- global ONOSIp #list of ONOS IP addresses
- global scale
-
- clusterCount = 0
- ONOSIp = [ 0 ]
- scale = (main.params[ 'SCALE' ]).split(",")
- clusterCount = int(scale[0])
-
- #Populate ONOSIp with ips from params
- for i in range(1, maxNodes + 1):
- ipString = 'ip' + str(i)
- ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
-
- #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
- if skipMvn != "yes":
- mvnResult = main.ONOSbench.cleanInstall()
-
- #git
- main.step( "Git checkout and pull " + checkoutBranch )
- if gitPull == 'on':
- checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
- pullResult = main.ONOSbench.gitPull()
-
- else:
- checkoutResult = main.TRUE
- pullResult = main.TRUE
- main.log.info( "Skipped git checkout and pull" )
-
- # -- END OF INIT SECTION --#
-
- clusterCount = int(scale[0])
- scale.remove(scale[0])
-
- #kill off all onos processes
- main.log.step("Safety check, killing all ONOS processes")
- main.log.step("before initiating enviornment setup")
- for node in range(1, maxNodes + 1):
- main.ONOSbench.onosDie(ONOSIp[node])
-
- #Uninstall everywhere
- main.log.step( "Cleaning Enviornment..." )
- for i in range(1, maxNodes + 1):
- main.log.info(" Uninstalling ONOS " + str(i) )
- main.ONOSbench.onosUninstall( ONOSIp[i] )
-
- #construct the cell file
- main.log.info("Creating cell file")
- cellIp = []
- for node in range (1, clusterCount + 1):
- cellIp.append(ONOSIp[node])
-
- main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
-
- main.step( "Set Cell" )
- main.ONOSbench.setCell(cellName)
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.onosPackage()
-
- main.step( "verify cells" )
- verifyCellResult = main.ONOSbench.verifyCell()
-
- main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
- for node in range(1, clusterCount + 1):
- main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
- main.ONOSbench.onosInstall( ONOSIp[node])
-
- for node in range(1, clusterCount + 1):
- for i in range( 2 ):
- isup = main.ONOSbench.isup( ONOSIp[node] )
- if isup:
- main.log.info("ONOS " + str(node) + " is up\n")
- break
- if not isup:
- main.log.report( "ONOS " + str(node) + " didn't start!" )
- main.log.info("Startup sequence complete")
-
- def CASE2( self, main ):
-
- print ("clusterCount: " + str(clusterCount))
- print ("scale: " + str(scale))
- print ("ONOSIp: " + str(ONOSIp))
- print ("INIT: " + str(init))
-
diff --git a/TestON/tests/SdnIpTest/SdnIpTest.params b/TestON/tests/SdnIpTest/SdnIpTest.params
index 7f7ef2d..c84af17 100755
--- a/TestON/tests/SdnIpTest/SdnIpTest.params
+++ b/TestON/tests/SdnIpTest/SdnIpTest.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>4</testcases>
+ <testcases>100, [4]*5</testcases>
#Environment variables
<ENV>
@@ -8,13 +8,15 @@
</ENV>
<CTRL>
+ <numCtrl>1</numCtrl>
<ip1>10.128.4.52</ip1>
<port1>6633</port1>
</CTRL>
<GIT>
- <autoPull>off</autoPull>
- <checkout>master</checkout>
+ <autoPull>on</autoPull>
+ <branch1>master</branch1>
+ <branch2>onos-1.2</branch2>
</GIT>
<JSON>
diff --git a/TestON/tests/SdnIpTest/SdnIpTest.py b/TestON/tests/SdnIpTest/SdnIpTest.py
index 85ac21e..43bf580 100644
--- a/TestON/tests/SdnIpTest/SdnIpTest.py
+++ b/TestON/tests/SdnIpTest/SdnIpTest.py
@@ -1,22 +1,86 @@
-# from cupshelpers.config import prefix
-# Testing the basic functionality of SDN-IP
-
-
+# Testing the functionality of SDN-IP with single ONOS instance
class SdnIpTest:
def __init__( self ):
self.default = ''
+ global branchName
-# from cupshelpers.config import prefix
+ # This case is to setup ONOS
+ def CASE100( self, main ):
+ """
+ CASE100 is to compile ONOS and push it to the test machines
+ Startup sequence:
+ git pull
+ mvn clean install
+ onos-package
+ cell <name>
+ onos-verify-cell
+ onos-install -f
+ onos-wait-for-start
+ """
+ import time
+ main.case( "Setting up test environment" )
-# Testing the basic functionality of SDN-IP
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
-class SdnIpTest:
+ branchName = main.ONOSbench.getBranchName()
+ main.log.info( "ONOS is on branch: " + branchName )
- def __init__( self ):
- self.default = ''
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ cleanInstallResult = main.TRUE
+ gitPullResult = main.TRUE
+
+ main.step( "Git pull" )
+ gitPullResult = main.ONOSbench.gitPull()
+
+ main.step( "Using mvn clean & install" )
+ cleanInstallResult = main.TRUE
+# if gitPullResult == main.TRUE:
+# cleanInstallResult = main.ONOSbench.cleanInstall()
+# else:
+# main.log.warn( "Did not pull new code so skipping mvn " +
+# "clean install" )
+ cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout= 1000 )
+ main.ONOSbench.getVersion( report=True )
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage( opTimeout=500 )
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS1Ip )
+
+ 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!" )
+
+ cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
+ commandlineTimeout=100, onosStartTimeout=600)
+
+ case1Result = ( cleanInstallResult and packageResult and
+ cellResult and verifyResult and
+ onos1InstallResult and
+ onos1Isup and cliResult )
+
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ onpass="ONOS startup successful",
+ onfail="ONOS startup NOT successful" )
+
+ if case1Result == main.FALSE:
+ main.cleanup()
+ main.exit()
def CASE4( self, main ):
"""
@@ -33,14 +97,12 @@
import time
import json
from operator import eq
- # from datetime import datetime
from time import localtime, strftime
- main.case("The test case is to help to setup the TestON environment \
- and test new drivers" )
- # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
+ main.case("This case is to testing the functionality of SDN-IP with \
+ single ONOS instance" )
SDNIPJSONFILEPATH = \
- "/home/admin/workspace/onos/tools/package/config/sdnip.json"
+ "/home/admin/ONOS/tools/package/config/sdnip.json"
# all expected routes for all BGP peers
allRoutesExpected = []
main.step( "Start to generate routes for all BGP peers" )
@@ -79,37 +141,12 @@
routeIntentsExpected = routeIntentsExpectedHost3 + \
routeIntentsExpectedHost4 + routeIntentsExpectedHost5
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- main.step( "Set cell for ONOS-cli environment" )
- main.ONOScli.setCell( cellName )
- verifyResult = main.ONOSbench.verifyCell()
-
- main.log.report( "Removing raft logs" )
- main.ONOSbench.onosRemoveRaftLogs()
- main.log.report( "Uninstalling ONOS" )
- main.ONOSbench.onosUninstall( ONOS1Ip )
-
- main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall(
- options="-f", node=ONOS1Ip )
-
- main.step( "Checking if ONOS is up yet" )
- time.sleep( 150 )
- onos1Isup = main.ONOSbench.isup( ONOS1Ip )
- if not onos1Isup:
- main.log.report( "ONOS1 didn't start!" )
-
- main.step( "Start ONOS-cli" )
-
- main.ONOScli.startOnosCli( ONOS1Ip )
-
main.step( "Get devices in the network" )
listResult = main.ONOScli.devices( jsonFormat=False )
main.log.info( listResult )
time.sleep( 10 )
- main.log.info( "Installing sdn-ip feature" )
- main.ONOScli.featureInstall( "onos-app-sdnip" )
+ main.log.info( "Activate sdn-ip application" )
+ main.ONOScli.activateApp( "org.onosproject.sdnip" )
time.sleep( 10 )
main.step( "Login all BGP peers and add routes into peers" )
@@ -138,8 +175,8 @@
prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
main.log.info( prefixesHostX )
for prefix in prefixesHostX:
- allRoutesExpected.append(
- prefix + "/" + "192.168.40." + str( i - 100 ) )
+ allRoutesExpected.append( prefix + "/" + "192.168.40."
+ + str( i - 100 ) )
routeIntentsExpectedHostX = \
main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
@@ -158,13 +195,11 @@
QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
time.sleep( 60 )
-
# get routes inside SDN-IP
getRoutesResult = main.ONOScli.routes( jsonFormat=True )
- # parse routes from ONOS CLI
allRoutesActual = \
- main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+ main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
allRoutesStrExpected = str( sorted( allRoutesExpected ) )
allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
@@ -189,7 +224,281 @@
main.step( "Check MultiPointToSinglePointIntent intents installed" )
# routeIntentsExpected are generated when generating routes
- # get rpoute intents from ONOS CLI
+ # get route intents from ONOS CLI
+ routeIntentsActualNum = \
+ main.QuaggaCliHost3.extractActualRouteIntentNum( getIntentsResult )
+ routeIntentsExpectedNum = 1030
+ main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
+ main.log.info( routeIntentsExpectedNum )
+ main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
+ main.log.info( routeIntentsActualNum )
+ 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!***" )
+
+ if( eq( routeIntentsExpectedNum, routeIntentsActualNum ) ):
+ main.log.report( "***MultiPointToSinglePoint Intents before \
+ deleting routes correct!***" )
+ else:
+ main.log.report( "***MultiPointToSinglePoint Intents before \
+ deleting routes wrong!***" )
+
+ main.step( "Check BGP PointToPointIntent intents installed" )
+
+ bgpIntentsActualNum = \
+ main.QuaggaCliHost3.extractActualBgpIntentNum( getIntentsResult )
+ bgpIntentsExpectedNum = 624
+ main.log.info( "bgpIntentsExpected num is:" )
+ main.log.info( bgpIntentsExpectedNum )
+ main.log.info( "bgpIntentsActual num is:" )
+ main.log.info( bgpIntentsActualNum)
+ 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!***" )
+ if ( eq( bgpIntentsExpectedNum, bgpIntentsActualNum ) ):
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are correct!***" )
+ else:
+ main.log.report(
+ "***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+ #============================= Ping Test ========================
+ # Wait until all MultiPointToSinglePoint intents are in system
+ time.sleep( 20 )
+ pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
+ pingTestResultsFile = \
+ "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-before-delete-routes-"\
+ + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ pingTestResults = main.QuaggaCliHost.pingTest(
+ "1.168.30.100", pingTestScript, pingTestResultsFile )
+ main.log.info( pingTestResults )
+ time.sleep( 20 )
+
+ #============================= Deleting Routes ==================
+ main.step( "Check deleting routes installed" )
+ main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+ main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+ main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
+
+ for i in range( 101, 201 ):
+ prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
+ main.log.info( prefixesHostX )
+ QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
+ QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
+
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
+ main.log.info( "allRoutes_actual = " )
+ main.log.info( allRoutesActual )
+
+ utilities.assertEquals(
+ expect="[]", actual=str( allRoutesActual ),
+ onpass="***Route number in SDN-IP is 0, correct!***",
+ onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report( "***Routes in SDN-IP after deleting correct!***" )
+ else:
+ main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
+
+ main.step( "Check intents after deleting routes" )
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+ routeIntentsActualNum = \
+ main.QuaggaCliHost3.extractActualRouteIntentNum(
+ getIntentsResult )
+ main.log.info( "route Intents Actual Num is: " )
+ main.log.info( routeIntentsActualNum )
+ utilities.assertEquals(
+ expect=0, actual=routeIntentsActualNum,
+ onpass="***MultiPointToSinglePoint Intent Num in SDN-IP is 0, \
+ correct!***",
+ onfail="***MultiPointToSinglePoint Intent Num in SDN-IP is not 0, \
+ wrong!***" )
+
+ if( eq( 0, routeIntentsActualNum ) ):
+ main.log.report( "***MultiPointToSinglePoint Intents after \
+ deleting routes correct!***" )
+ else:
+ main.log.report( "***MultiPointToSinglePoint Intents after \
+ deleting routes wrong!***" )
+
+ time.sleep( 20 )
+ pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
+ pingTestResultsFile = \
+ "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-after-delete-routes-"\
+ + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+ pingTestResults = main.QuaggaCliHost.pingTest(
+ "1.168.30.100", pingTestScript, pingTestResultsFile )
+ main.log.info( pingTestResults )
+ time.sleep( 100 )
+
+ def CASE_4_origin( self, main ):
+ """
+ Test the SDN-IP functionality
+ allRoutesExpected: all expected routes for all BGP peers
+ routeIntentsExpected: all expected MultiPointToSinglePointIntent \
+ intents
+ bgpIntentsExpected: expected PointToPointIntent intents
+ allRoutesActual: all routes from ONOS LCI
+ routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
+ ONOS CLI
+ bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
+ """
+ import time
+ import json
+ from operator import eq
+ from time import localtime, strftime
+
+ main.case("This case is to testing the functionality of SDN-IP with \
+ single ONOS instance" )
+ SDNIPJSONFILEPATH = \
+ "/home/admin/ONOS/tools/package/config/sdnip.json"
+ # all expected routes for all BGP peers
+ allRoutesExpected = []
+ main.step( "Start to generate routes for all BGP peers" )
+ main.log.info( "Generate prefixes for host3" )
+ prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+ main.log.info( prefixesHost3 )
+ # generate route with next hop
+ for prefix in prefixesHost3:
+ allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+ routeIntentsExpectedHost3 = \
+ main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+ prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host4" )
+ prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+ main.log.info( prefixesHost4 )
+ # generate route with next hop
+ for prefix in prefixesHost4:
+ allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+ routeIntentsExpectedHost4 = \
+ main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+ prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+ SDNIPJSONFILEPATH )
+
+ main.log.info( "Generate prefixes for host5" )
+ prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
+ main.log.info( prefixesHost5 )
+ for prefix in prefixesHost5:
+ allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+ routeIntentsExpectedHost5 = \
+ main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+ prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+ SDNIPJSONFILEPATH )
+
+ routeIntentsExpected = routeIntentsExpectedHost3 + \
+ routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+ main.step( "Get devices in the network" )
+ listResult = main.ONOScli.devices( jsonFormat=False )
+ main.log.info( listResult )
+ time.sleep( 10 )
+ if branchName == "onos-1.1":
+ main.log.info( "Installing sdn-ip feature" )
+ main.ONOScli.featureInstall( "onos-app-sdnip" )
+ else:
+ main.log.info( "Activate sdn-ip application" )
+ main.ONOScli.activateApp( "org.onosproject.sdnip" )
+ #main.log.info( "Installing sdn-ip feature" )
+ #main.ONOScli.featureInstall( "onos-app-sdnip" )
+ time.sleep( 10 )
+ main.step( "Login all BGP peers and add routes into peers" )
+
+ main.log.info( "Login Quagga CLI on host3" )
+ main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+ main.log.info( "Enter configuration model of Quagga CLI on host3" )
+ main.QuaggaCliHost3.enterConfig( 64514 )
+ main.log.info( "Add routes to Quagga on host3" )
+ main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
+
+ main.log.info( "Login Quagga CLI on host4" )
+ main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+ main.log.info( "Enter configuration model of Quagga CLI on host4" )
+ main.QuaggaCliHost4.enterConfig( 64516 )
+ main.log.info( "Add routes to Quagga on host4" )
+ main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+ main.log.info( "Login Quagga CLI on host5" )
+ main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+ main.log.info( "Enter configuration model of Quagga CLI on host5" )
+ main.QuaggaCliHost5.enterConfig( 64521 )
+ main.log.info( "Add routes to Quagga on host5" )
+ main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+ for i in range( 101, 201 ):
+ prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
+ main.log.info( prefixesHostX )
+ for prefix in prefixesHostX:
+ allRoutesExpected.append( prefix + "/" + "192.168.40."
+ + str( i - 100 ) )
+
+ routeIntentsExpectedHostX = \
+ main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
+ prefixesHostX, "192.168.40." + str( i - 100 ),
+ "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
+ routeIntentsExpected = routeIntentsExpected + \
+ routeIntentsExpectedHostX
+
+ main.log.info( "Login Quagga CLI on host" + str( i ) )
+ QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
+ QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
+ main.log.info(
+ "Enter configuration model of Quagga CLI on host" + str( i ) )
+ QuaggaCliHostX.enterConfig( 65000 + i - 100 )
+ main.log.info( "Add routes to Quagga on host" + str( i ) )
+ QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
+
+ time.sleep( 60 )
+ # get routes inside SDN-IP
+ getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+ # parse routes from ONOS CLI
+ #if branchName == "master":
+ # allRoutesActual = \
+ # main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
+ #elif branchName == "onos-1.0":
+ # allRoutesActual = \
+ # main.QuaggaCliHost3.extractActualRoutesOneDotZero( getRoutesResult )
+ #else:
+ # main.log("ONOS is on wrong branch")
+ # exit
+
+ allRoutesActual = \
+ main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
+
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals(
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="***Routes in SDN-IP are correct!***",
+ onfail="***Routes in SDN-IP are wrong!***" )
+ if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are correct!***" )
+ else:
+ main.log.report(
+ "***Routes in SDN-IP after adding routes are wrong!***" )
+
+ time.sleep( 20 )
+ getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+
+ main.step( "Check MultiPointToSinglePointIntent intents installed" )
+ # routeIntentsExpected are generated when generating routes
+ # get route intents from ONOS CLI
routeIntentsActual = \
main.QuaggaCliHost3.extractActualRouteIntents(
getIntentsResult )
@@ -243,7 +552,7 @@
"***PointToPointIntent Intents in SDN-IP are wrong!***" )
#============================= Ping Test ========================
- # wait until all MultiPointToSinglePoint
+ # Wait until all MultiPointToSinglePoint intents are in system
time.sleep( 20 )
pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
pingTestResultsFile = \
@@ -306,22 +615,19 @@
time.sleep( 20 )
pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
pingTestResultsFile = \
- "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-after-delete-routes-" \
+ "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-after-delete-routes-"\
+ strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
pingTestResults = main.QuaggaCliHost.pingTest(
"1.168.30.100", pingTestScript, pingTestResultsFile )
main.log.info( pingTestResults )
time.sleep( 100 )
- # main.step( "Test whether Mininet is started" )
- # main.Mininet2.handle.sendline( "xterm host1" )
- # main.Mininet2.handle.expect( "mininet>" )
-
def CASE3( self, main ):
"""
Test the SDN-IP functionality
allRoutesExpected: all expected routes for all BGP peers
- routeIntentsExpected: all expected MultiPointToSinglePointIntent intents
+ routeIntentsExpected: all expected MultiPointToSinglePointIntent \
+ intents
bgpIntentsExpected: expected PointToPointIntent intents
allRoutesActual: all routes from ONOS LCI
routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
@@ -338,7 +644,7 @@
environment and test new drivers" )
# SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
SDNIPJSONFILEPATH = \
- "/home/admin/workspace/onos/tools/package/config/sdnip.json"
+ "/home/admin/ONOS/tools/package/config/sdnip.json"
# all expected routes for all BGP peers
allRoutesExpected = []
main.step( "Start to generate routes for all BGP peers" )
@@ -396,8 +702,12 @@
listResult = main.ONOScli.devices( jsonFormat=False )
main.log.info( listResult )
time.sleep( 10 )
- main.log.info( "Installing sdn-ip feature" )
- main.ONOScli.featureInstall( "onos-app-sdnip" )
+ if branchName == "onos-1.1":
+ main.log.info( "Installing sdn-ip feature" )
+ main.ONOScli.featureInstall( "onos-app-sdnip" )
+ else:
+ main.log.info( "Activate sdn-ip application" )
+ main.ONOScli.activateApp( "org.onosproject.sdnip" )
time.sleep( 10 )
main.step( "Login all BGP peers and add routes into peers" )