Merge "added main.cases and main.steps added README file change checking cbench result to ensure valid; add assertions in test steps Change-Id: Ia9beb6d8e9c4a3a286b4fb2e83766782b637a6bb"
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 8eea845..e4dbf9d 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -93,6 +93,7 @@
self.Thread = Thread
self.cleanupFlag = False
self.cleanupLock = threading.Lock()
+ self.initiated = False
self.configparser()
verifyOptions(options)
@@ -151,6 +152,7 @@
This method will initialize specified component
'''
global driver_options
+ self.initiated = False
self.log.info("Creating component Handle: "+component)
driver_options = {}
if 'COMPONENTS' in self.componentDictionary[component].keys():
@@ -176,6 +178,7 @@
self.exit()
vars(self)[component] = driverObject
+ self.initiated = True
def run(self):
'''
@@ -353,7 +356,8 @@
try:
if self.cleanupFlag is False: # First thread to run this
self.cleanupFlag = True
- self.logger.testSummary(self)
+ if self.initiated:
+ self.logger.testSummary(self)
for component in self.componentDictionary.keys():
try :
tempObject = vars(self)[component]
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 870293d..2f8bd47 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -2578,14 +2578,6 @@
Optional argument:
* jsonFormat - boolean indicating if you want output in json
"""
- # FIXME: add json output
- # Sample JSON
- # {
- # "electedTime": "13m ago",
- # "epoch": 4,
- # "leader": "10.128.30.17",
- # "topic": "intent-partition-3"
- # },
try:
cmdStr = "onos:leaders"
if jsonFormat:
@@ -2605,6 +2597,63 @@
main.cleanup()
main.exit()
+ def leaderCandidates( self, jsonFormat=True ):
+ """
+ Returns the output of the leaders -c command.
+ Optional argument:
+ * jsonFormat - boolean indicating if you want output in json
+ """
+ try:
+ cmdStr = "onos:leaders -c"
+ if jsonFormat:
+ cmdStr += " -j"
+ output = self.sendline( cmdStr )
+ return output
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def specificLeaderCandidate(self,topic):
+ """
+ Returns a list in format [leader,candidate1,candidate2,...] for a given
+ topic parameter and an empty list if the topic doesn't exist
+ If no leader is elected leader in the returned list will be "none"
+ Returns None if there is a type error processing the json object
+ """
+ try:
+ cmdStr = "onos:leaders -c -j"
+ output = self.sendline( cmdStr )
+ output = json.loads(output)
+ results = []
+ for dict in output:
+ if dict["topic"] == topic:
+ leader = dict["leader"]
+ candidates = re.split(", ",dict["candidates"][1:-1])
+ results.append(leader)
+ results.extend(candidates)
+ return results
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
def pendingMap( self, jsonFormat=True ):
"""
Returns the output of the intent Pending map.
@@ -3511,7 +3560,7 @@
except AssertionError:
main.log.error( "Error in processing 'set-test-get' command: " +
str( output ) )
- return None
+ return None
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return None
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 8a87a49..37d55fe 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -115,15 +115,13 @@
pwd=self.pwd,
home=self.home )
- self.handle.sendline( "cd " + self.home )
- self.handle.expect( "\$" )
-
if self.handle:
+ self.handle.sendline( "cd " + self.home )
+ self.handle.expect( "\$" )
return self.handle
else:
- main.log.info( "NO ONOS HANDLE" )
+ main.log.info( "Failed to create ONOS handle" )
return main.FALSE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
diff --git a/TestON/drivers/component.py b/TestON/drivers/component.py
index f05be55..9199a4e 100644
--- a/TestON/drivers/component.py
+++ b/TestON/drivers/component.py
@@ -45,9 +45,8 @@
return getattr( self.wrapped, name )
except AttributeError as error:
# NOTE: The first time we load a driver module we get this error
- if "'module' object has no attribute '__path__'" in error\
- and self.count == 0:
- self.count += 1
+ if "'module' object has no attribute '__path__'" in error:
+ pass
else:
main.log.error( str(error.__class__) + " " + str(error) )
try: