Fixed Thread in teston core to include the module, Fixed OnosCHO case6 and 10 code
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 0925edd..27ddea7 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -46,6 +46,7 @@
sys.path.append(tests_path)
from core.utilities import Utilities
+from core.Thread import Thread
class TestON:
@@ -87,6 +88,7 @@
self.loggerClass = "Logger"
self.logs_path = logs_path
self.driver = ''
+ self.Thread = Thread
self.configparser()
@@ -146,7 +148,6 @@
'''
This method will initialize specified component
'''
- import importlib
global driver_options
self.log.info("Creating component Handle: "+component)
driver_options = {}
@@ -158,7 +159,7 @@
driver_options ['type'] = driverName
classPath = self.getDriverPath(driverName.lower())
- driverModule = importlib.import_module(classPath)
+ driverModule = __import__(classPath, globals(), locals(), [driverName.lower()], -1)
driverClass = getattr(driverModule, driverName)
driverObject = driverClass()
@@ -241,10 +242,8 @@
exec code[testCaseNumber][step] in module.__dict__
self.stepCount = self.stepCount + 1
except TypeError,e:
- print "Exception in the following section of code:"
- print code[testCaseNumber][step]
self.stepCount = self.stepCount + 1
- self.log.exception(e)
+ self.log.error(e)
return main.TRUE
if cli.stop:
@@ -445,8 +444,8 @@
try :
import json
response_dict = json.loads(response)
- except Exception, e:
- main.log.exception(e)
+ except Exception , e :
+ print e
main.log.error("Json Parser is unable to parse the string")
return response_dict
@@ -464,7 +463,7 @@
try :
response_dict = xmldict.xml_to_dict("<response> "+str(response)+" </response>")
except Exception, e:
- main.log.exception(e)
+ main.log.error(e)
return response_dict
def dict_to_return_format(self,response,return_format,response_dict):
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 991f203..a72ee28 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -19,12 +19,10 @@
import sys
import pexpect
import re
-import json
sys.path.append( "../" )
from drivers.common.clidriver import CLI
-
class OnosCliDriver( CLI ):
def __init__( self ):
@@ -45,9 +43,9 @@
if key == "home":
self.home = self.options[ 'home' ]
break
- if self.home == None or self.home == "":
+ if self.home is None or self.home == "":
self.home = "~/ONOS"
-
+
self.name = self.options[ 'name' ]
self.handle = super( OnosCliDriver, self ).connect(
user_name=self.user_name,
@@ -271,7 +269,7 @@
self.handle.expect( "onos>" )
self.handle.sendline( "log:log " + lvlStr + " " + cmdStr )
self.handle.expect( "onos>" )
-
+
response = self.handle.before
if re.search( "Error", response ):
return main.FALSE
@@ -283,9 +281,7 @@
main.cleanup()
main.exit()
except:
- main.log.info( self.name + " ::::::" )
- main.log.error( traceback.print_exc() )
- main.log.info( self.name + " ::::::" )
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -299,25 +295,21 @@
sent using this method.
"""
try:
-
logStr = "\"Sending CLI command: '" + cmdStr + "'\""
self.log( logStr )
self.handle.sendline( cmdStr )
self.handle.expect( "onos>" )
main.log.info( "Command '" + str( cmdStr ) + "' sent to "
+ self.name + "." )
-
handle = self.handle.before
# Remove control strings from output
ansiEscape = re.compile( r'\x1b[^m]*m' )
handle = ansiEscape.sub( '', handle )
- #Remove extra return chars that get added
+ # Remove extra return chars that get added
handle = re.sub( r"\s\r", "", handle )
handle = handle.strip()
# parse for just the output, remove the cmd from handle
output = handle.split( cmdStr, 1 )[1]
-
-
return output
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
@@ -480,14 +472,9 @@
by issuing command: 'onos> feature:uninstall <feature_str>'
"""
try:
- cmdStr = 'feature:list -i | grep "' + featureStr + '"'
- handle = self.sendline( cmdStr )
- if handle != '':
- cmdStr = "feature:uninstall " + str( featureStr )
- self.sendline( cmdStr )
- # TODO: Check for possible error responses from karaf
- else:
- main.log.info( "Feature needs to be installed before uninstalling it" )
+ cmdStr = "feature:uninstall " + str( featureStr )
+ self.sendline( cmdStr )
+ # TODO: Check for possible error responses from karaf
return main.TRUE
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
@@ -929,6 +916,8 @@
Description:
Adds a host-to-host intent ( bidrectional ) by
specifying the two hosts.
+ Returns:
+ A string of the intent id or None on Error
"""
try:
cmdStr = "add-host-intent " + str( hostIdOne ) +\
@@ -936,16 +925,19 @@
handle = self.sendline( cmdStr )
if re.search( "Error", handle ):
main.log.error( "Error in adding Host intent" )
- return handle
+ return None
else:
main.log.info( "Host intent installed between " +
- str( hostIdOne ) + " and " + str( hostIdTwo ) )
- return main.TRUE
-
+ str( hostIdOne ) + " and " + str( hostIdTwo ) )
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return None
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -963,6 +955,10 @@
* egressDevice: device id of egress device
Optional:
TODO: Still needs to be implemented via dev side
+ Description:
+ Adds an optical intent by specifying an ingress and egress device
+ Returns:
+ A string of the intent id or None on error
"""
try:
cmdStr = "add-optical-intent " + str( ingressDevice ) +\
@@ -970,9 +966,18 @@
handle = self.sendline( cmdStr )
# If error, return error message
if re.search( "Error", handle ):
- return handle
+ main.log.error( "Error in adding Optical intent" )
+ return None
else:
- return main.TRUE
+ main.log.info( "Optical intent installed between " +
+ str( ingressDevice ) + " and " +
+ str( egressDevice ) )
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return None
@@ -1021,6 +1026,8 @@
Description:
Adds a point-to-point intent ( uni-directional ) by
specifying device id's and optional fields
+ Returns:
+ A string of the intent id or None on error
NOTE: This function may change depending on the
options developers provide for point-to-point
@@ -1066,10 +1073,11 @@
cmd += " " + str( ingressDevice )
else:
if not portIngress:
- main.log.error( "You must specify " +
- "the ingress port" )
+ main.log.error( "You must specify the ingress port" )
# TODO: perhaps more meaningful return
- return main.FALSE
+ # Would it make sense to throw an exception and exit
+ # the test?
+ return None
cmd += " " + \
str( ingressDevice ) + "/" +\
@@ -1079,20 +1087,29 @@
cmd += " " + str( egressDevice )
else:
if not portEgress:
- main.log.error( "You must specify " +
- "the egress port" )
- return main.FALSE
+ main.log.error( "You must specify the egress port" )
+ return None
cmd += " " +\
str( egressDevice ) + "/" +\
str( portEgress )
handle = self.sendline( cmd )
+ # If error, return error message
if re.search( "Error", handle ):
main.log.error( "Error in adding point-to-point intent" )
- return main.FALSE
+ return None
else:
- return main.TRUE
+ # TODO: print out all the options in this message?
+ main.log.info( "Point-to-point intent installed between " +
+ str( ingressDevice ) + " and " +
+ str( egressDevice ) )
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return None
@@ -1111,7 +1128,8 @@
ingressDevice1,
ingressDevice2,
egressDevice,
- portIngress="",
+ portIngress1="",
+ portIngress2="",
portEgress="",
ethType="",
ethSrc="",
@@ -1151,6 +1169,8 @@
Description:
Adds a multipoint-to-singlepoint intent ( uni-directional ) by
specifying device id's and optional fields
+ Returns:
+ A string of the intent id or None on error
NOTE: This function may change depending on the
options developers provide for multipointpoint-to-singlepoint
@@ -1204,7 +1224,7 @@
main.log.error( "You must specify " +
"the ingress port1" )
# TODO: perhaps more meaningful return
- return main.FALSE
+ return None
cmd += " " + \
str( ingressDevice1 ) + "/" +\
@@ -1217,7 +1237,7 @@
main.log.error( "You must specify " +
"the ingress port2" )
# TODO: perhaps more meaningful return
- return main.FALSE
+ return None
cmd += " " + \
str( ingressDevice2 ) + "/" +\
@@ -1236,11 +1256,23 @@
str( portEgress )
print "cmd= ", cmd
handle = self.sendline( cmd )
+ # If error, return error message
if re.search( "Error", handle ):
- main.log.error( "Error in adding point-to-point intent" )
- return self.handle
+ main.log.error( "Error in adding multipoint-to-singlepoint " +
+ "intent" )
+ return None
else:
- return main.TRUE
+ # TODO: print out all the options in this message?
+ main.log.info( "Multipoint-to-singlepoint intent installed" +
+ " between " + str( ingressDevice1 ) + ", " +
+ str( ingressDevice2 ) + " and " +
+ str( egressDevice ) )
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return None
@@ -1254,6 +1286,7 @@
main.cleanup()
main.exit()
+
def removeIntent( self, intentId, app = 'org.onosproject.cli',
purge = False, sync = False ):
"""
@@ -1358,7 +1391,6 @@
def getIntentState(self, intentsId, intentsJson=None):
"""
- Description:
Check intent state.
Accepts a single intent ID (string type) or a list of intent IDs.
Returns the state(string type) of the id if a single intent ID is
@@ -1366,7 +1398,7 @@
Returns a dictionary with intent IDs as the key and its corresponding
states as the values
values
- Required:
+ Parameters:
intentId: intent ID (string type)
intentsJson: parsed json object from the onos:intents api
Returns:
@@ -1583,29 +1615,16 @@
"""
try:
# Obtain output of intents function
- intentsStr = self.intents()
- allIntentList = []
+ intentsStr = self.intents(jsonFormat=False)
intentIdList = []
# Parse the intents output for ID's
intentsList = [ s.strip() for s in intentsStr.splitlines() ]
for intents in intentsList:
- if "onos>" in intents:
- continue
- elif "intents" in intents:
- continue
- else:
- lineList = intents.split( " " )
- allIntentList.append( lineList[ 0 ] )
-
- allIntentList = allIntentList[ 1:-2 ]
-
- for intents in allIntentList:
- if not intents:
- continue
- else:
- intentIdList.append( intents )
-
+ match = re.search('id=0x([\da-f]+),', intents)
+ if match:
+ tmpId = match.group()[3:-1]
+ intentIdList.append( tmpId )
return intentIdList
except TypeError:
@@ -1621,27 +1640,6 @@
main.cleanup()
main.exit()
-
- def FlowAddedCount( self, id ):
- """
- Determine the number of flow rules for the given device id that are
- in the added state
- """
- try:
- cmdStr = "flows any " + id + " | grep 'state=ADDED' | wc -l"
- handle = self.sendline( cmdStr )
- return handle
- except pexpect.EOF:
- main.log.error( self.name + ": EOF exception found" )
- main.log.error( self.name + ": " + self.handle.before )
- main.cleanup()
- main.exit()
- except:
- main.log.exception( self.name + ": Uncaught exception!" )
- main.cleanup()
- main.exit()
-
-
def getAllDevicesId( self ):
"""
Use 'devices' function to obtain list of all devices
@@ -1787,7 +1785,7 @@
# Is the number of switches is what we expected
devices = topology.get( 'devices', False )
links = topology.get( 'links', False )
- if devices == False or links == False:
+ if devices is False or links is False:
return main.ERROR
switchCheck = ( int( devices ) == int( numoswitch ) )
# Is the number of links is what we expected
@@ -2123,19 +2121,14 @@
main.cleanup()
main.exit()
- def intentSummary( self ):
+ def testExceptions( self, obj ):
"""
- Returns a dictonary containing the current intent states and the count
+ Test exception logging
"""
+ # FIXME: Remove this before you commit
+
try:
- intents = self.intents( )
- intentStates = []
- out = []
- for intent in json.loads( intents ):
- intentStates.append( intent.get( 'state', None ) )
- for i in set( intentStates ):
- out.append( (i, intentStates.count( i ) ) )
- return dict( out )
+ return obj[ 'dedf' ]
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return None
diff --git a/TestON/tests/OnosCHO/OnosCHO.params b/TestON/tests/OnosCHO/OnosCHO.params
index edc7540..f3a89f5 100644
--- a/TestON/tests/OnosCHO/OnosCHO.params
+++ b/TestON/tests/OnosCHO/OnosCHO.params
@@ -13,7 +13,7 @@
# 1,2,3,[4,5,6,5,70,80,5,10,5,9,5,71,81,5,10,5]*100
# 1,2,3,4,5,6,10,12,3,4,5,6,10,13,3,4,5,6,10
- <testcases>1,2,3,4,5,6,10</testcases>
+ <testcases>1,2,3,4,5,6,70,80,10</testcases>
<ENV>
<cellName>fiveNodes</cellName>
</ENV>
diff --git a/TestON/tests/OnosCHO/OnosCHO.py b/TestON/tests/OnosCHO/OnosCHO.py
index 16f2b5d..b7fa855 100644
--- a/TestON/tests/OnosCHO/OnosCHO.py
+++ b/TestON/tests/OnosCHO/OnosCHO.py
@@ -1027,7 +1027,7 @@
print "Removing intent id (round 1) :", intentIdList[ i ]
t = main.Thread(target=cli,threadID=main.threadID,
name="removeIntent",
- args=[intentIdList[i]])
+ args=[intentIdList[i],'org.onosproject.cli',True,False])
pool.append(t)
t.start()
i = i + 1