Commit 663e4975 authored by Jérome Perrin's avatar Jérome Perrin

testing: adjust logged messages by framework

Respect semantics of "verbose" vs "debug", to make it possible to run tests in
debug mode but without verbose messages.

Also adjust "Starting", this message was not clear
parent 167404e8
...@@ -129,7 +129,7 @@ def makeModuleSetUpAndTestCaseClass( ...@@ -129,7 +129,7 @@ def makeModuleSetUpAndTestCaseClass(
logger = logging.getLogger() logger = logging.getLogger()
console_handler = logging.StreamHandler() console_handler = logging.StreamHandler()
console_handler.setLevel( console_handler.setLevel(
logging.DEBUG if (verbose or debug) else logging.WARNING) logging.DEBUG if verbose else logging.WARNING)
logger.addHandler(console_handler) logger.addHandler(console_handler)
if debug: if debug:
...@@ -414,7 +414,7 @@ def installSoftwareUrlList(cls, software_url_list, max_retry=10, debug=False): ...@@ -414,7 +414,7 @@ def installSoftwareUrlList(cls, software_url_list, max_retry=10, debug=False):
cls._copySnapshot(path, name) cls._copySnapshot(path, name)
try: try:
cls.logger.debug("Starting") cls.logger.debug("Starting SlapOS")
cls.slap.start() cls.slap.start()
for software_url in software_url_list: for software_url in software_url_list:
cls.logger.debug("Supplying %s", software_url) cls.logger.debug("Supplying %s", software_url)
...@@ -570,7 +570,7 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -570,7 +570,7 @@ class SlapOSInstanceTestCase(unittest.TestCase):
snapshot_name = "{}.{}.setUpClass".format(cls.__module__, cls.__name__) snapshot_name = "{}.{}.setUpClass".format(cls.__module__, cls.__name__)
try: try:
cls.logger.debug("Starting") cls.logger.debug("Starting setUpClass %s", cls)
cls.slap.start() cls.slap.start()
cls.logger.debug( cls.logger.debug(
"Formatting to remove old partitions XXX should not be needed because we delete ..." "Formatting to remove old partitions XXX should not be needed because we delete ..."
...@@ -736,7 +736,15 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -736,7 +736,15 @@ class SlapOSInstanceTestCase(unittest.TestCase):
cls._storeSystemSnapshot( cls._storeSystemSnapshot(
"{}._cleanup request destroy".format(snapshot_name)) "{}._cleanup request destroy".format(snapshot_name))
try: try:
# To make debug usable, we tolerate report_max_retry-1 errors and
# only debug the last.
for _ in range(3): for _ in range(3):
if cls._debug and cls.report_max_retry:
try:
cls.slap.waitForReport(max_retry=cls.report_max_retry - 1)
except SlapOSNodeCommandError:
cls.slap.waitForReport(debug=True)
else:
cls.slap.waitForReport(max_retry=cls.report_max_retry, debug=cls._debug) cls.slap.waitForReport(max_retry=cls.report_max_retry, debug=cls._debug)
except: except:
cls.logger.exception("Error during actual destruction") cls.logger.exception("Error during actual destruction")
...@@ -768,7 +776,15 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -768,7 +776,15 @@ class SlapOSInstanceTestCase(unittest.TestCase):
"{}._cleanup leaked_partitions request destruction".format( "{}._cleanup leaked_partitions request destruction".format(
snapshot_name)) snapshot_name))
try: try:
# To make debug usable, we tolerate report_max_retry-1 errors and
# only debug the last.
for _ in range(3): for _ in range(3):
if cls._debug and cls.report_max_retry:
try:
cls.slap.waitForReport(max_retry=cls.report_max_retry - 1)
except SlapOSNodeCommandError:
cls.slap.waitForReport(debug=True)
else:
cls.slap.waitForReport(max_retry=cls.report_max_retry, debug=cls._debug) cls.slap.waitForReport(max_retry=cls.report_max_retry, debug=cls._debug)
except: except:
cls.logger.exception( cls.logger.exception(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment