Stop catching non error throwables such as SystemExit
* Convert "except:" to "except Exception:"
* Use log.exception instead of directly calling traceback
* Remove unused imports
* Fix a typos
* Replace tabs with spaces for combatibility issues
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.py b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
index e9beb0c..72a9c14 100644
--- a/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
@@ -243,7 +243,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response )\
and re.search( "tcp:" + ONOS2Ip, response )\
@@ -1362,7 +1362,7 @@
print json.dumps( json.loads( ONOS1Intents ),
sort_keys=True, indent=4,
separators=( ',', ': ' ) )
- except:
+ except Exception:
pass
sameIntents = main.FALSE
utilities.assert_equals(
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
index de26e67..8649f98 100644
--- a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
@@ -243,7 +243,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response )\
and re.search( "tcp:" + ONOS2Ip, response )\
@@ -401,6 +401,7 @@
Assign intents
"""
import time
+ import json
main.log.report( "Adding host intents" )
main.case( "Adding host Intents" )
@@ -493,6 +494,7 @@
"""
Ping across added host intents
"""
+ import json
description = " Ping across added host intents"
main.log.report( description )
main.case( description )
@@ -1136,6 +1138,7 @@
Check state after ONOS failure
"""
import json
+ import time
main.case( "Running ONOS Constant State Tests" )
# Assert that each device has a master
@@ -1363,7 +1366,7 @@
print json.dumps( json.loads( ONOS1Intents ),
sort_keys=True, indent=4,
separators=( ',', ': ' ) )
- except:
+ except Exception:
pass
sameIntents = main.FALSE
utilities.assert_equals(
@@ -1475,8 +1478,8 @@
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" )
+ onpass="Constant State Tests Passed",
+ onfail="Constant state tests failed" )
def CASE8( self, main ):
"""
diff --git a/TestON/tests/HATestSanity/HATestSanity.py b/TestON/tests/HATestSanity/HATestSanity.py
index 590ff56..96d0858 100644
--- a/TestON/tests/HATestSanity/HATestSanity.py
+++ b/TestON/tests/HATestSanity/HATestSanity.py
@@ -243,7 +243,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response )\
and re.search( "tcp:" + ONOS2Ip, response )\
@@ -1325,7 +1325,7 @@
print json.dumps( json.loads( ONOS1Intents ),
sort_keys=True, indent=4,
separators=( ',', ': ' ) )
- except:
+ except Exception:
pass
sameIntents = main.FALSE
utilities.assert_equals(
diff --git a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
index 44ce741..81b3afd 100644
--- a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
+++ b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
@@ -180,7 +180,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response ):
mastershipCheck = mastershipCheck and main.TRUE
@@ -198,6 +198,7 @@
"""
Assign intents
"""
+ import json
# FIXME: we must reinstall intents until we have a persistant
# datastore!
import time
@@ -280,6 +281,7 @@
"""
Ping across added host intents
"""
+ import json
description = " Ping across added host intents"
main.log.report( description )
main.case( description )
@@ -499,9 +501,9 @@
utilities.assert_equals( expect=main.TRUE, actual=caseResults,
onpass="ONOS restart successful",
onfail="ONOS restart NOT successful" )
- main.log.info(
- "ESTIMATE: ONOS took %s seconds to restart" %
- str( elapsed ) )
+ if elapsed:
+ main.log.info( "ESTIMATE: ONOS took %s seconds to restart" %
+ str( elapsed ) )
time.sleep( 5 )
def CASE7( self, main ):
@@ -613,7 +615,7 @@
print json.dumps( json.loads( ONOS1Intents ),
sort_keys=True, indent=4,
separators=( ',', ': ' ) )
- except:
+ except Exception:
pass
sameIntents = main.FALSE
utilities.assert_equals(
diff --git a/TestON/tests/PingallExample/PingallExample.py b/TestON/tests/PingallExample/PingallExample.py
index 653397e..dab380f 100644
--- a/TestON/tests/PingallExample/PingallExample.py
+++ b/TestON/tests/PingallExample/PingallExample.py
@@ -127,7 +127,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response ):
mastershipCheck = mastershipCheck and main.TRUE