diff options
Diffstat (limited to 'functest/opnfv_tests/sdn/odl/odl.py')
-rwxr-xr-x | functest/opnfv_tests/sdn/odl/odl.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py index f92cb95d..6f586b7a 100755 --- a/functest/opnfv_tests/sdn/odl/odl.py +++ b/functest/opnfv_tests/sdn/odl/odl.py @@ -16,6 +16,8 @@ Example: $ python odl.py """ +from __future__ import division + import argparse import errno import fileinput @@ -23,12 +25,12 @@ import logging import os import re import sys -import urlparse import robot.api from robot.errors import RobotError import robot.run from robot.utils.robottime import timestamp_to_secs +from six.moves import urllib from functest.core import testcase import functest.utils.openstack_utils as op_utils @@ -85,10 +87,10 @@ class ODLTests(testcase.TestCase): try: for line in fileinput.input(odl_variables_files, inplace=True): - print re.sub("AUTH = .*", + print(re.sub("AUTH = .*", ("AUTH = [u'" + odlusername + "', u'" + odlpassword + "']"), - line.rstrip()) + line.rstrip())) return True except Exception as ex: # pylint: disable=broad-except cls.__logger.error("Cannot set ODL creds: %s", str(ex)) @@ -100,7 +102,12 @@ class ODLTests(testcase.TestCase): result = robot.api.ExecutionResult(xml_file) visitor = ODLResultVisitor() result.visit(visitor) - self.result = result.suite.status + try: + self.result = 100 * ( + result.suite.statistics.critical.passed / + result.suite.statistics.critical.total) + except ZeroDivisionError: + self.__logger.error("No test has been ran") self.start_time = timestamp_to_secs(result.suite.starttime) self.stop_time = timestamp_to_secs(result.suite.endtime) self.details = {} @@ -143,7 +150,7 @@ class ODLTests(testcase.TestCase): odlusername = kwargs['odlusername'] odlpassword = kwargs['odlpassword'] osauthurl = kwargs['osauthurl'] - keystoneip = urlparse.urlparse(osauthurl).hostname + keystoneip = urllib.parse.urlparse(osauthurl).hostname variables = ['KEYSTONE:' + keystoneip, 'NEUTRON:' + kwargs['neutronip'], 'OS_AUTH_URL:"' + osauthurl + '"', @@ -211,7 +218,7 @@ class ODLTests(testcase.TestCase): except KeyError: pass neutron_url = op_utils.get_endpoint(service_type='network') - kwargs = {'neutronip': urlparse.urlparse(neutron_url).hostname} + kwargs = {'neutronip': urllib.parse.urlparse(neutron_url).hostname} kwargs['odlip'] = kwargs['neutronip'] kwargs['odlwebport'] = '8080' kwargs['odlrestconfport'] = '8181' |