import click
import functest.ci.tier_builder as tb
+from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
-FUNCTEST_CONF_DIR = \
- ft_utils.get_functest_config('general.directories.dir_functest_conf')
-ENV_FILE = FUNCTEST_CONF_DIR + "/env_active"
-FUNCTEST_REPO = ft_utils.FUNCTEST_REPO
-
-
-class CliTier:
+class CliTier(object):
def __init__(self):
- CI_INSTALLER_TYPE = os.getenv('INSTALLER_TYPE')
- CI_SCENARIO = os.getenv('DEPLOY_SCENARIO')
- testcases = ft_utils.get_testcases_file()
- self.tiers = tb.TierBuilder(CI_INSTALLER_TYPE, CI_SCENARIO, testcases)
+ self.tiers = tb.TierBuilder(
+ CONST.__getattribute__('INSTALLER_TYPE'),
+ CONST.__getattribute__('DEPLOY_SCENARIO'),
+ CONST.__getattribute__('functest_testcases_yaml'))
def list(self):
summary = ""
tests = tier.get_test_names()
click.echo("Test cases in tier '%s':\n %s\n" % (tiername, tests))
- def run(self, tiername, noclean=False):
- if not os.path.isfile(ENV_FILE):
+ @staticmethod
+ def run(tiername, noclean=False, report=False):
+
+ flags = ""
+ if noclean:
+ flags += "-n "
+ if report:
+ flags += "-r "
+
+ if not os.path.isfile(CONST.__getattribute__('env_active')):
click.echo("Functest environment is not ready. "
"Run first 'functest env prepare'")
else:
- if noclean:
- cmd = ("python %s/functest/ci/run_tests.py "
- "-n -t %s" % (FUNCTEST_REPO, tiername))
- else:
- cmd = ("python %s/functest/ci/run_tests.py "
- "-t %s" % (FUNCTEST_REPO, tiername))
+ cmd = ("python %s/functest/ci/run_tests.py "
+ "%s -t %s" %
+ (CONST.__getattribute__('dir_repo_functest'),
+ flags, tiername))
ft_utils.execute_command(cmd)