3 # jose.lausuch@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
10 """ global variables """
17 import functest.ci.tier_builder as tb
18 from functest.utils.constants import CONST
19 import functest.utils.functest_utils as ft_utils
22 class CliTier(object):
25 self.tiers = tb.TierBuilder(
26 CONST.__getattribute__('INSTALLER_TYPE'),
27 CONST.__getattribute__('DEPLOY_SCENARIO'),
28 pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
32 for tier in self.tiers.get_tiers():
33 summary += (" - %s. %s:\n\t %s\n"
36 tier.get_test_names()))
39 def show(self, tiername):
40 tier = self.tiers.get_tier(tiername)
42 tier_names = self.tiers.get_tier_names()
43 click.echo("The tier with name '%s' does not exist. "
44 "Available tiers are:\n %s\n" % (tiername, tier_names))
46 click.echo(self.tiers.get_tier(tiername))
48 def gettests(self, tiername):
49 tier = self.tiers.get_tier(tiername)
51 tier_names = self.tiers.get_tier_names()
52 click.echo("The tier with name '%s' does not exist. "
53 "Available tiers are:\n %s\n" % (tiername, tier_names))
55 tests = tier.get_test_names()
56 click.echo("Test cases in tier '%s':\n %s\n" % (tiername, tests))
59 def run(tiername, noclean=False, report=False):
67 if not os.path.isfile(CONST.__getattribute__('env_active')):
68 click.echo("Functest environment is not ready. "
69 "Run first 'functest env prepare'")
71 cmd = "run_tests {}-t {}".format(flags, tiername)
72 ft_utils.execute_command(cmd)