aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py
diff options
context:
space:
mode:
authorhelenyao <yaohelan@huawei.com>2016-11-21 06:50:06 -0500
committerjose.lausuch <jose.lausuch@ericsson.com>2016-11-24 15:14:45 +0100
commit3e3c96b2aa15d7757f281ce00518a67e2a1225a9 (patch)
tree9b15e0ceab33a9301ca7cde1a0a36e05f2347584 /functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py
parent7a776398ef8b17bd9af5367d712707a903c1c86a (diff)
Extracted all global parameters into functest_constants.py
JIRA: FUNCTEST-533 1. Extracted all global variables into functest_constants.py and updated all affected areas accordingly 2. Used os.path.join to replace '/' to come up with the path for better cross-platform support and improve the path accuracy 3. Removed unused variables 4. Updated the hardcoded path in Dockerfile by using variable reference 5. Removed "/" ending from all path variables 6. Updated the unit test Change-Id: Ib30a81d1f0c83fbaef042d63c187c27bd18301bb Signed-off-by: helenyao <yaohelan@huawei.com>
Diffstat (limited to 'functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py')
-rwxr-xr-xfunctest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py50
1 files changed, 32 insertions, 18 deletions
diff --git a/functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py b/functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py
index 8c003abf..0ddb58cd 100755
--- a/functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py
+++ b/functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py
@@ -23,6 +23,7 @@ from robot.utils.robottime import timestamp_to_secs
from functest.core import TestCasesBase
import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as op_utils
+import functest.utils.functest_constants as ft_constants
class ODLResultVisitor(ResultVisitor):
@@ -48,11 +49,14 @@ class ODLResultVisitor(ResultVisitor):
class ODLTestCases(TestCasesBase.TestCasesBase):
- repos = "/home/opnfv/repos/"
- odl_test_repo = repos + "odl_test/"
- neutron_suite_dir = odl_test_repo + "csit/suites/openstack/neutron/"
- basic_suite_dir = odl_test_repo + "csit/suites/integration/basic/"
- res_dir = '/home/opnfv/functest/results/odl/'
+ repos = ft_constants.REPOS_DIR
+ odl_test_repo = os.path.join(repos, "odl_test")
+ neutron_suite_dir = os.path.join(odl_test_repo,
+ "csit/suites/openstack/neutron")
+ basic_suite_dir = os.path.join(odl_test_repo,
+ "csit/suites/integration/basic")
+ res_dir = os.path.join(ft_constants.FUNCTEST_RESULTS_DIR, "odl")
+
logger = ft_logger.Logger("opendaylight").getLogger()
def __init__(self):
@@ -60,7 +64,8 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
@classmethod
def set_robotframework_vars(cls, odlusername="admin", odlpassword="admin"):
- odl_variables_files = cls.odl_test_repo + 'csit/variables/Variables.py'
+ odl_variables_files = os.path.join(cls.odl_test_repo,
+ 'csit/variables/Variables.py')
try:
for line in fileinput.input(odl_variables_files,
inplace=True):
@@ -74,7 +79,8 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
return False
def parse_results(self):
- result = ExecutionResult(self.res_dir + 'output.xml')
+ output_dir = os.path.join(self.res_dir, 'output.xml')
+ result = ExecutionResult(output_dir)
visitor = ODLResultVisitor()
result.visit(visitor)
self.criteria = result.suite.status
@@ -109,10 +115,11 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
self.logger.exception(
"Cannot create {}".format(self.res_dir))
return self.EX_RUN_ERROR
- stdout_file = self.res_dir + 'stdout.txt'
+ stdout_file = os.path.join(self.res_dir, 'stdout.txt')
+ output_dir = os.path.join(self.res_dir, 'output.xml')
with open(stdout_file, 'w+') as stdout:
robot.run(*dirs, variable=variables,
- output=self.res_dir + 'output.xml',
+ output=output_dir,
log='NONE',
report='NONE',
stdout=stdout)
@@ -148,23 +155,29 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
kwargs['odlrestconfport'] = '8181'
kwargs['odlusername'] = 'admin'
kwargs['odlpassword'] = 'admin'
- installer_type = None
- if 'INSTALLER_TYPE' in os.environ:
- installer_type = os.environ['INSTALLER_TYPE']
- kwargs['osusername'] = os.environ['OS_USERNAME']
- kwargs['ostenantname'] = os.environ['OS_TENANT_NAME']
- kwargs['ospassword'] = os.environ['OS_PASSWORD']
+
+ installer_type = ft_constants.CI_INSTALLER_TYPE
+ kwargs['osusername'] = ft_constants.OS_USERNAME
+ kwargs['ostenantname'] = ft_constants.OS_TENANT_NAME
+ kwargs['ospassword'] = ft_constants.OS_PASSWORD
+
if installer_type == 'fuel':
kwargs['odlwebport'] = '8282'
elif installer_type == 'apex':
- kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP']
+ if ft_constants.SDN_CONTROLLER_IP is None:
+ return self.EX_RUN_ERROR
+ kwargs['odlip'] = ft_constants.SDN_CONTROLLER_IP
kwargs['odlwebport'] = '8181'
elif installer_type == 'joid':
- kwargs['odlip'] = os.environ['SDN_CONTROLLER']
+ if ft_constants.SDN_CONTROLLER is None:
+ return self.EX_RUN_ERROR
+ kwargs['odlip'] = ft_constants.SDN_CONTROLLER
elif installer_type == 'compass':
kwargs['odlwebport'] = '8181'
else:
- kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP']
+ if ft_constants.SDN_CONTROLLER_IP is None:
+ return self.EX_RUN_ERROR
+ kwargs['odlip'] = ft_constants.SDN_CONTROLLER_IP
except KeyError as e:
self.logger.error("Cannot run ODL testcases. "
"Please check env var: "
@@ -176,6 +189,7 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
return self.main(**kwargs)
+
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-k', '--keystoneip',