summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2016-08-22 11:06:12 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2016-08-22 11:11:29 +0200
commit5f450302301af5f19e4fee7cf37d2c724e098dea (patch)
treee3b805ad3bd242a038bd486167d868c671a8be1f
parent8c979f22b592f38569fccef115d1f8036909722f (diff)
Catch exception if output.xml failed
It protects against a direct call to push_to_db without a previous run even if it can not happen in the current implementation. Change-Id: Ifa00aed60912fa8b96b80d581067548ac6727fb5 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rwxr-xr-xtestcases/Controllers/ODL/OpenDaylightTesting.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/testcases/Controllers/ODL/OpenDaylightTesting.py b/testcases/Controllers/ODL/OpenDaylightTesting.py
index 0e38d04d8..74e3157dc 100755
--- a/testcases/Controllers/ODL/OpenDaylightTesting.py
+++ b/testcases/Controllers/ODL/OpenDaylightTesting.py
@@ -9,6 +9,7 @@ import sys
from robot import run
from robot.api import ExecutionResult, ResultVisitor
+from robot.errors import RobotError
from robot.utils.robottime import timestamp_to_secs
import functest.utils.functest_logger as ft_logger
@@ -118,21 +119,24 @@ class ODLTestCases:
@classmethod
def push_to_db(cls):
- result = ExecutionResult(cls.res_dir + 'output.xml')
- visitor = ODLResultVisitor()
- result.visit(visitor)
- start_time = timestamp_to_secs(result.suite.starttime)
- stop_time = timestamp_to_secs(result.suite.endtime)
- details = {}
- details['description'] = result.suite.name
- details['tests'] = visitor.get_data()
- if not ft_utils.push_results_to_db(
- "functest", "odl", None, start_time, stop_time,
- result.suite.status, details):
- cls.logger.error("Cannot push ODL results to DB")
- return False
- else:
- return True
+ try:
+ result = ExecutionResult(cls.res_dir + 'output.xml')
+ visitor = ODLResultVisitor()
+ result.visit(visitor)
+ start_time = timestamp_to_secs(result.suite.starttime)
+ stop_time = timestamp_to_secs(result.suite.endtime)
+ details = {}
+ details['description'] = result.suite.name
+ details['tests'] = visitor.get_data()
+ if not ft_utils.push_results_to_db(
+ "functest", "odl", None, start_time, stop_time,
+ result.suite.status, details):
+ cls.logger.error("Cannot push ODL results to DB")
+ return False
+ else:
+ return True
+ except RobotError as e:
+ cls.logger.error("Run tests before publishing: %s" % e.message)
if __name__ == '__main__':