unify testcases.yaml obtain process 87/19987/1
authorSerenaFeng <feng.xiaowei@zte.com.cn>
Wed, 31 Aug 2016 03:07:40 +0000 (11:07 +0800)
committerMorgan Richomme <morgan.richomme@orange.com>
Wed, 31 Aug 2016 12:13:51 +0000 (12:13 +0000)
hardcoded "''FUNCTEST_REPO + "/ci/testcases.yaml"''' appears wherever
testcases.yaml is needed, abstract a method to provide unified interface

JIRA: FUNCTEST-449

Change-Id: Ida8e3d90926d3e2245883a29f577ecb121bd5d6c
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
(cherry picked from commit f5afb93a4a2ed9547757655c1405ef27fabed11b)

ci/run_tests.py
cli/commands/cli_testcase.py
cli/commands/cli_tier.py
utils/functest_utils.py

index f2a1199..d8f4883 100755 (executable)
@@ -187,7 +187,7 @@ def main():
     CI_INSTALLER_TYPE = os.getenv('INSTALLER_TYPE')
     CI_SCENARIO = os.getenv('DEPLOY_SCENARIO')
 
-    file = FUNCTEST_REPO + "/ci/testcases.yaml"
+    file = ft_utils.get_testcases_file()
     _tiers = tb.TierBuilder(CI_INSTALLER_TYPE, CI_SCENARIO, file)
 
     if args.noclean:
index abf67d1..d1b2482 100644 (file)
@@ -21,8 +21,6 @@ import yaml
 with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
     functest_yaml = yaml.safe_load(f)
 
-REPOS_DIR = os.getenv('repos_dir')
-FUNCTEST_REPO = ("%s/functest/" % REPOS_DIR)
 FUNCTEST_CONF_DIR = functest_yaml.get("general").get(
     "directories").get("dir_functest_conf")
 ENV_FILE = FUNCTEST_CONF_DIR + "/env_active"
@@ -33,7 +31,7 @@ class CliTestcase:
     def __init__(self):
         CI_INSTALLER_TYPE = os.getenv('INSTALLER_TYPE')
         CI_SCENARIO = os.getenv('DEPLOY_SCENARIO')
-        testcases = FUNCTEST_REPO + "/ci/testcases.yaml"
+        testcases = ft_utils.get_testcases_file()
         self.tiers = tb.TierBuilder(CI_INSTALLER_TYPE, CI_SCENARIO, testcases)
 
     def list(self):
index 8e031cc..7797e9b 100644 (file)
@@ -20,8 +20,6 @@ import yaml
 with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
     functest_yaml = yaml.safe_load(f)
 
-REPOS_DIR = os.getenv('repos_dir')
-FUNCTEST_REPO = ("%s/functest/" % REPOS_DIR)
 FUNCTEST_CONF_DIR = functest_yaml.get("general").get(
     "directories").get("dir_functest_conf")
 ENV_FILE = FUNCTEST_CONF_DIR + "/env_active"
@@ -32,7 +30,7 @@ class CliTier:
     def __init__(self):
         CI_INSTALLER_TYPE = os.getenv('INSTALLER_TYPE')
         CI_SCENARIO = os.getenv('DEPLOY_SCENARIO')
-        testcases = FUNCTEST_REPO + "/ci/testcases.yaml"
+        testcases = ft_utils.get_testcases_file()
         self.tiers = tb.TierBuilder(CI_INSTALLER_TYPE, CI_SCENARIO, testcases)
 
     def list(self):
index 199088b..fb4d756 100644 (file)
@@ -381,7 +381,7 @@ def get_deployment_dir(logger=None):
 
 def get_criteria_by_test(testname):
     criteria = ""
-    file = FUNCTEST_REPO + "/ci/testcases.yaml"
+    file = get_testcases_file()
     tiers = tb.TierBuilder("", "", file)
     for tier in tiers.get_tiers():
         for test in tier.get_tests():
@@ -463,3 +463,7 @@ def check_test_result(test_name, ret, start_time, stop_time):
     }
 
     return status, details
+
+
+def get_testcases_file():
+    return FUNCTEST_REPO + "/ci/testcases.yaml"