From 107e61635c2ab1feb5263380ea63e21cf2e6e65b Mon Sep 17 00:00:00 2001 From: Morgan Richomme Date: Tue, 8 Nov 2016 14:18:12 +0100 Subject: Repo structure modification - create functest subdirectory - rename unit tests - adapt path in exec and config files JIRA: FUNCTEST-525 Change-Id: Ifd5c6edfb5bda1b09f82848e2269ad5fbeb84d0a Signed-off-by: Morgan Richomme --- functest/cli/commands/cli_tier.py | 73 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 functest/cli/commands/cli_tier.py (limited to 'functest/cli/commands/cli_tier.py') diff --git a/functest/cli/commands/cli_tier.py b/functest/cli/commands/cli_tier.py new file mode 100644 index 00000000..aa054198 --- /dev/null +++ b/functest/cli/commands/cli_tier.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# +# jose.lausuch@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +# + +""" global variables """ + +import os + +import click + +import functest.ci.tier_builder as tb +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: + + 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) + + def list(self): + 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): + 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, noclean=False): + if not os.path.isfile(ENV_FILE): + click.echo("Functest environment is not ready. " + "Run first 'functest env prepare'") + else: + if noclean: + cmd = ("python %s/ci/run_tests.py " + "-n -t %s" % (FUNCTEST_REPO, tiername)) + else: + cmd = ("python %s/ci/run_tests.py " + "-t %s" % (FUNCTEST_REPO, tiername)) + ft_utils.execute_command(cmd) -- cgit 1.2.3-korg