Merge "Updated vims to support keystone v3"
[functest.git] / functest / ci / run_tests.py
old mode 100644 (file)
new mode 100755 (executable)
index 3f02c87..7aac9d2
@@ -8,24 +8,23 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 #
 
+import argparse
 import datetime
 import importlib
 import os
 import re
 import sys
 
-import argparse
-
 import functest.ci.generate_report as generate_report
 import functest.ci.tier_builder as tb
 import functest.core.testcase_base as testcase_base
+import functest.utils.functest_constants as ft_constants
 import functest.utils.functest_logger as ft_logger
 import functest.utils.functest_utils as ft_utils
-import functest.utils.functest_constants as ft_constants
 import functest.utils.openstack_clean as os_clean
 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',
@@ -44,7 +43,7 @@ logger = ft_logger.Logger("run_tests").getLogger()
 
 
 """ global variables """
-EXEC_SCRIPT = ("%s/functest/ci/exec_test.sh" % ft_constants.FUNCTEST_REPO_DIR)
+EXEC_SCRIPT = ("%s/functest/ci/exec_test.sh" % CONST.dir_repo_functest)
 
 # This will be the return code of this script. If any of the tests fails,
 # this variable will change to -1
@@ -65,7 +64,7 @@ def print_separator(str, count=45):
 
 
 def source_rc_file():
-    rc_file = ft_constants.OPENSTACK_CREDS
+    rc_file = CONST.openstack_creds
     if not os.path.isfile(rc_file):
         logger.error("RC file %s does not exist..." % rc_file)
         sys.exit(1)
@@ -75,16 +74,20 @@ def source_rc_file():
         if re.search("OS_", key):
             if key == 'OS_AUTH_URL':
                 ft_constants.OS_AUTH_URL = value
+                CONST.OS_AUTH_URL = value
             elif key == 'OS_USERNAME':
                 ft_constants.OS_USERNAME = value
+                CONST.OS_USERNAME = value
             elif key == 'OS_TENANT_NAME':
                 ft_constants.OS_TENANT_NAME = value
+                CONST.OS_TENANT_NAME = value
             elif key == 'OS_PASSWORD':
                 ft_constants.OS_PASSWORD = value
-    logger.debug("OS_AUTH_URL:%s" % ft_constants.OS_AUTH_URL)
-    logger.debug("OS_USERNAME:%s" % ft_constants.OS_USERNAME)
-    logger.debug("OS_TENANT_NAME:%s" % ft_constants.OS_TENANT_NAME)
-    logger.debug("OS_PASSWORD:%s" % ft_constants.OS_PASSWORD)
+                CONST.OS_PASSWORD = value
+    logger.debug("OS_AUTH_URL:%s" % CONST.OS_AUTH_URL)
+    logger.debug("OS_USERNAME:%s" % CONST.OS_USERNAME)
+    logger.debug("OS_TENANT_NAME:%s" % CONST.OS_TENANT_NAME)
+    logger.debug("OS_PASSWORD:%s" % CONST.OS_PASSWORD)
 
 
 def generate_os_snapshot():
@@ -124,6 +127,7 @@ def run_test(test, tier_name):
     logger.info("Running test case '%s'..." % test_name)
     print_separator("=")
     logger.debug("\n%s" % test)
+    source_rc_file()
 
     if GlobalVariables.CLEAN_FLAG:
         generate_os_snapshot()
@@ -140,9 +144,10 @@ def run_test(test, tier_name):
             cls = getattr(module, run_dict['class'])
             test_case = cls()
             result = test_case.run()
-            if (result == testcase_base.TestcaseBase.EX_OK and
-                    GlobalVariables.REPORT_FLAG):
-                test_case.push_to_db()
+            if result == testcase_base.TestcaseBase.EX_OK:
+                if GlobalVariables.REPORT_FLAG:
+                    test_case.push_to_db()
+                result = test_case.check_criteria()
         except ImportError:
             logger.exception("Cannot import module {}".format(
                 run_dict['module']))
@@ -199,17 +204,11 @@ def run_tier(tier):
 
 def run_all(tiers):
     summary = ""
-    BUILD_TAG = ft_constants.CI_BUILD_TAG
-    if BUILD_TAG is not None and re.search("daily", BUILD_TAG) is not None:
-        CI_LOOP = "daily"
-    else:
-        CI_LOOP = "weekly"
-
     tiers_to_run = []
 
     for tier in tiers.get_tiers():
         if (len(tier.get_tests()) != 0 and
-                re.search(CI_LOOP, tier.get_ci_loop()) is not None):
+                re.search(CONST.CI_LOOP, tier.get_ci_loop()) is not None):
             tiers_to_run.append(tier)
             summary += ("\n    - %s:\n\t   %s"
                         % (tier.get_name(),
@@ -225,10 +224,10 @@ def run_all(tiers):
 
 def main():
 
-    CI_INSTALLER_TYPE = ft_constants.CI_INSTALLER_TYPE
-    CI_SCENARIO = ft_constants.CI_SCENARIO
+    CI_INSTALLER_TYPE = CONST.INSTALLER_TYPE
+    CI_SCENARIO = CONST.DEPLOY_SCENARIO
 
-    file = ft_constants.FUNCTEST_TESTCASES_YAML
+    file = CONST.functest_testcases_yaml
     _tiers = tb.TierBuilder(CI_INSTALLER_TYPE, CI_SCENARIO, file)
 
     if args.noclean: