summaryrefslogtreecommitdiffstats
path: root/cli/commands/cli_tier.py
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-05-06 01:36:30 +0200
committerjose.lausuch <jose.lausuch@ericsson.com>2016-05-09 16:58:04 +0200
commitbd00e6f289a69badf7beea827b20764ed3252c7a (patch)
tree77cfd39903e5ebf9ea492737a499ef57346cd3f1 /cli/commands/cli_tier.py
parent073ca5525f38d7a7c9c67252d1b996e895ff9917 (diff)
CLI implementation
JIRA: FUNCTEST-243 Change-Id: Ibf0ef9bcc5f3aeda96b050827b954ce060317613 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'cli/commands/cli_tier.py')
-rw-r--r--cli/commands/cli_tier.py54
1 files changed, 50 insertions, 4 deletions
diff --git a/cli/commands/cli_tier.py b/cli/commands/cli_tier.py
index efb8ad5f2..a872eb76f 100644
--- a/cli/commands/cli_tier.py
+++ b/cli/commands/cli_tier.py
@@ -8,17 +8,63 @@
#
import click
+import os
+import yaml
+
+import functest.ci.tier_builder as tb
+import functest.utils.functest_utils as ft_utils
+
+""" global variables """
+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"
class CliTier:
def __init__(self):
- pass
+ CI_INSTALLER_TYPE = os.getenv('INSTALLER_TYPE')
+ CI_SCENARIO = os.getenv('DEPLOY_SCENARIO')
+ testcases = FUNCTEST_REPO + "/ci/testcases.yaml"
+ self.tiers = tb.TierBuilder(CI_INSTALLER_TYPE, CI_SCENARIO, testcases)
def list(self):
- click.echo("tier list")
+ summary = ""
+ for tier in self.tiers.get_tiers():
+ summary += (" - %s. %s:\n\t %s\n"
+ % (tier.get_order(),
+ tier.get_name(),
+ tier.get_test_names()))
+ click.echo(summary)
def show(self, tiername):
- click.echo("tier show %s" % tiername)
+ tier = self.tiers.get_tier(tiername)
+ if tier is None:
+ tier_names = self.tiers.get_tier_names()
+ click.echo("The tier with name '%s' does not exist. "
+ "Available tiers are:\n %s\n" % (tiername, tier_names))
+ else:
+ click.echo(self.tiers.get_tier(tiername))
+
+ def gettests(self, tiername):
+ tier = self.tiers.get_tier(tiername)
+ if tier is None:
+ tier_names = self.tiers.get_tier_names()
+ click.echo("The tier with name '%s' does not exist. "
+ "Available tiers are:\n %s\n" % (tiername, tier_names))
+ else:
+ tests = tier.get_test_names()
+ click.echo("Test cases in tier '%s':\n %s\n" % (tiername, tests))
def run(self, tiername):
- click.echo("tier run %s" % tiername)
+ if not os.path.isfile(ENV_FILE):
+ click.echo("Functest environment is not ready. "
+ "Run first 'functest env prepare'")
+ else:
+ cmd = ("python /home/opnfv/repos/functest/ci/run_tests.py -t %s"
+ % tiername)
+ ft_utils.execute_command(cmd)