aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfunctest/ci/prepare_env.py31
-rwxr-xr-xfunctest/ci/run_tests.py61
-rwxr-xr-xfunctest/opnfv_tests/sdn/odl/odl.py2
-rw-r--r--functest/tests/unit/odl/test_odl.py2
4 files changed, 59 insertions, 37 deletions
diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py
index 45e19a466..74c751af9 100755
--- a/functest/ci/prepare_env.py
+++ b/functest/ci/prepare_env.py
@@ -29,12 +29,6 @@ import functest.utils.openstack_utils as os_utils
from functest.utils.constants import CONST
actions = ['start', 'check']
-parser = argparse.ArgumentParser()
-parser.add_argument("action", help="Possible actions are: "
- "'{d[0]}|{d[1]}' ".format(d=actions))
-parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
-args = parser.parse_args()
-
""" logging configuration """
logger = ft_logger.Logger("prepare_env").getLogger()
@@ -48,6 +42,19 @@ with open(CONFIG_PATCH_PATH) as f:
functest_patch_yaml = yaml.safe_load(f)
+class PrepareEnvParser():
+
+ def __init__(self):
+ self.parser = argparse.ArgumentParser()
+ self.parser.add_argument("action", help="Possible actions are: "
+ "'{d[0]}|{d[1]}' ".format(d=actions))
+ self.parser.add_argument("-d", "--debug", help="Debug mode",
+ action="store_true")
+
+ def parse_args(self, argv=[]):
+ return vars(self.parser.parse_args(argv))
+
+
def print_separator():
logger.info("==============================================")
@@ -274,12 +281,12 @@ def check_environment():
logger.info("Functest environment is installed.")
-def main():
- if not (args.action in actions):
+def main(**kwargs):
+ if not (kwargs['action'] in actions):
logger.error('Argument not valid.')
sys.exit()
- if args.action == "start":
+ if kwargs['action'] == "start":
logger.info("######### Preparing Functest environment #########\n")
check_env_variables()
create_directories()
@@ -294,11 +301,13 @@ def main():
check_environment()
- if args.action == "check":
+ if kwargs['action'] == "check":
check_environment()
exit(0)
if __name__ == '__main__':
- main()
+ parser = PrepareEnvParser()
+ args = parser.parse_args(sys.argv[1:])
+ main(**args)
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index 35345fee5..10f1ac9a1 100755
--- a/functest/ci/run_tests.py
+++ b/functest/ci/run_tests.py
@@ -26,17 +26,6 @@ import functest.utils.openstack_snapshot as os_snapshot
import functest.utils.openstack_utils as os_utils
from functest.utils.constants import CONST
-parser = argparse.ArgumentParser()
-parser.add_argument("-t", "--test", dest="test", action='store',
- help="Test case or tier (group of tests) to be executed. "
- "It will run all the test if not specified.")
-parser.add_argument("-n", "--noclean", help="Do not clean OpenStack resources"
- " after running each test (default=false).",
- action="store_true")
-parser.add_argument("-r", "--report", help="Push results to database "
- "(default=false).", action="store_true")
-args = parser.parse_args()
-
""" logging configuration """
logger = ft_logger.Logger("run_tests").getLogger()
@@ -49,6 +38,26 @@ EXEC_SCRIPT = ("%s/functest/ci/exec_test.sh" % CONST.dir_repo_functest)
# this variable will change to -1
+class RunTestsParser():
+
+ def __init__(self):
+ self.parser = argparse.ArgumentParser()
+ self.parser.add_argument("-t", "--test", dest="test", action='store',
+ help="Test case or tier (group of tests) "
+ "to be executed. It will run all the test "
+ "if not specified.")
+ self.parser.add_argument("-n", "--noclean", help="Do not clean "
+ "OpenStack resources after running each "
+ "test (default=false).",
+ action="store_true")
+ self.parser.add_argument("-r", "--report", help="Push results to "
+ "database (default=false).",
+ action="store_true")
+
+ def parse_args(self, argv=[]):
+ return vars(self.parser.parse_args(argv))
+
+
class GlobalVariables:
EXECUTED_TEST_CASES = []
OVERALL_RESULT = 0
@@ -118,7 +127,7 @@ def get_run_dict_if_defined(testname):
return None
-def run_test(test, tier_name):
+def run_test(test, tier_name, testcases=None):
result_str = "PASS"
start = datetime.datetime.now()
test_name = test.get_name()
@@ -174,7 +183,7 @@ def run_test(test, tier_name):
result_str = "FAIL"
if test.is_blocking():
- if not args.test or args.test == "all":
+ if not testcases or testcases == "all":
logger.info("This test case is blocking. Aborting overall "
"execution.")
# if it is a single test we don't print the whole results table
@@ -223,7 +232,7 @@ def run_all(tiers):
generate_report.main(GlobalVariables.EXECUTED_TEST_CASES)
-def main():
+def main(**kwargs):
CI_INSTALLER_TYPE = CONST.INSTALLER_TYPE
CI_SCENARIO = CONST.DEPLOY_SCENARIO
@@ -231,27 +240,29 @@ def main():
file = CONST.functest_testcases_yaml
_tiers = tb.TierBuilder(CI_INSTALLER_TYPE, CI_SCENARIO, file)
- if args.noclean:
+ if kwargs['noclean']:
GlobalVariables.CLEAN_FLAG = False
- if args.report:
+ if kwargs['report']:
GlobalVariables.REPORT_FLAG = True
- if args.test:
+ if kwargs['test']:
source_rc_file()
- if _tiers.get_tier(args.test):
- run_tier(_tiers.get_tier(args.test))
+ if _tiers.get_tier(kwargs['test']):
+ run_tier(_tiers.get_tier(kwargs['test']))
- elif _tiers.get_test(args.test):
- run_test(_tiers.get_test(args.test), _tiers.get_tier(args.test))
+ elif _tiers.get_test(kwargs['test']):
+ run_test(_tiers.get_test(kwargs['test']),
+ _tiers.get_tier(kwargs['test']),
+ kwargs['test'])
- elif args.test == "all":
+ elif kwargs['test'] == "all":
run_all(_tiers)
else:
logger.error("Unknown test case or tier '%s', or not supported by "
"the given scenario '%s'."
- % (args.test, CI_SCENARIO))
+ % (kwargs['test'], CI_SCENARIO))
logger.debug("Available tiers are:\n\n%s"
% _tiers)
else:
@@ -262,4 +273,6 @@ def main():
if __name__ == '__main__':
- main()
+ parser = RunTestsParser()
+ args = parser.parse_args(sys.argv[1:])
+ main(**args)
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index 45b313d52..606d59a11 100755
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -161,7 +161,7 @@ class ODLTests(testcase_base.TestcaseBase):
kwargs['odlwebport'] = '8282'
elif installer_type == 'apex':
kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP']
- kwargs['odlwebport'] = '8181'
+ kwargs['odlwebport'] = '8081'
elif installer_type == 'joid':
kwargs['odlip'] = os.environ['SDN_CONTROLLER']
elif installer_type == 'compass':
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index d45d5628e..8a52a9f63 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -410,7 +410,7 @@ class ODLTesting(unittest.TestCase):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
os.environ["INSTALLER_TYPE"] = "apex"
self._test_run(testcase_base.TestcaseBase.EX_OK,
- odlip=self._sdn_controller_ip, odlwebport='8181')
+ odlip=self._sdn_controller_ip, odlwebport='8081')
def test_run_joid_missing_sdn_controller(self):
with mock.patch('functest.utils.openstack_utils.get_endpoint',