aboutsummaryrefslogtreecommitdiffstats
path: root/functest/cli
diff options
context:
space:
mode:
Diffstat (limited to 'functest/cli')
-rw-r--r--functest/cli/__init__.py0
-rw-r--r--functest/cli/cli_base.py127
-rw-r--r--functest/cli/commands/__init__.py0
-rw-r--r--functest/cli/commands/cli_env.py60
-rw-r--r--functest/cli/commands/cli_os.py66
-rw-r--r--functest/cli/commands/cli_testcase.py73
-rw-r--r--functest/cli/commands/cli_tier.py90
-rw-r--r--functest/cli/functest-complete.sh8
8 files changed, 0 insertions, 424 deletions
diff --git a/functest/cli/__init__.py b/functest/cli/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/functest/cli/__init__.py
+++ /dev/null
diff --git a/functest/cli/cli_base.py b/functest/cli/cli_base.py
deleted file mode 100644
index 5890e0a35..000000000
--- a/functest/cli/cli_base.py
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/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
-#
-
-import click
-import logging.config
-import pkg_resources
-
-from functest.cli.commands.cli_env import CliEnv
-from functest.cli.commands.cli_os import CliOpenStack
-from functest.cli.commands.cli_testcase import CliTestcase
-from functest.cli.commands.cli_tier import CliTier
-
-
-CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
-
-
-@click.group(context_settings=CONTEXT_SETTINGS)
-@click.version_option(version='opnfv colorado.0.1 ')
-def cli():
- logging.config.fileConfig(pkg_resources.resource_filename(
- 'functest', 'ci/logging.ini'))
- logging.captureWarnings(True)
-
-
-_env = CliEnv()
-_openstack = CliOpenStack()
-_testcase = CliTestcase()
-_tier = CliTier()
-
-
-@cli.group()
-@click.pass_context
-def env(ctx):
- pass
-
-
-@cli.group()
-@click.pass_context
-def openstack(ctx):
- pass
-
-
-@cli.group()
-@click.pass_context
-def testcase(ctx):
- pass
-
-
-@cli.group()
-@click.pass_context
-def tier(ctx):
- pass
-
-
-@openstack.command('check', help="Checks connectivity and status "
- "to the OpenStack deployment.")
-def os_check():
- _openstack.check()
-
-
-@openstack.command('show-credentials',
- help="Prints the OpenStack credentials.")
-def os_show_credentials():
- _openstack.show_credentials()
-
-
-@env.command('show', help="Shows information about the current environment.")
-def env_show():
- _env.show()
-
-
-@testcase.command('list', help="Lists the available testcases.")
-def testcase_list():
- _testcase.list()
-
-
-@testcase.command('show', help="Shows information about a test case.")
-@click.argument('testname', type=click.STRING, required=True)
-def testcase_show(testname):
- _testcase.show(testname)
-
-
-@testcase.command('run', help="Executes a test case.")
-@click.argument('testname', type=click.STRING, required=True)
-@click.option('-n', '--noclean', is_flag=True, default=False,
- help='The created openstack resources by the test'
- 'will not be cleaned after the execution.')
-@click.option('-r', '--report', is_flag=True, default=False,
- help='Push results to the results DataBase. Only CI Pods'
- 'have rights to do that.')
-def testcase_run(testname, noclean, report):
- _testcase.run(testname, noclean, report)
-
-
-@tier.command('list', help="Lists the available tiers.")
-def tier_list():
- _tier.list()
-
-
-@tier.command('show', help="Shows information about a tier.")
-@click.argument('tiername', type=click.STRING, required=True)
-def tier_show(tiername):
- _tier.show(tiername)
-
-
-@tier.command('get-tests', help="Prints the tests in a tier.")
-@click.argument('tiername', type=click.STRING, required=True)
-def tier_gettests(tiername):
- _tier.gettests(tiername)
-
-
-@tier.command('run', help="Executes all the tests within a tier.")
-@click.argument('tiername', type=click.STRING, required=True)
-@click.option('-n', '--noclean', is_flag=True, default=False,
- help='The created openstack resources by the tests'
- 'will not be cleaned after the execution.')
-@click.option('-r', '--report', is_flag=True, default=False,
- help='Push results to the results DataBase. Only CI Pods'
- 'have rights to do that.')
-def tier_run(tiername, noclean, report):
- _tier.run(tiername, noclean, report)
diff --git a/functest/cli/commands/__init__.py b/functest/cli/commands/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/functest/cli/commands/__init__.py
+++ /dev/null
diff --git a/functest/cli/commands/cli_env.py b/functest/cli/commands/cli_env.py
deleted file mode 100644
index c41f8f340..000000000
--- a/functest/cli/commands/cli_env.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/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
-#
-
-import click
-import prettytable
-
-from functest.utils.constants import CONST
-
-import six
-
-
-class Env(object):
-
- def __init__(self):
- pass
-
- def show(self):
- def _get_value(attr, default='Unknown'):
- return attr if attr else default
-
- install_type = _get_value(CONST.__getattribute__('INSTALLER_TYPE'))
- installer_ip = _get_value(CONST.__getattribute__('INSTALLER_IP'))
- installer_info = ("%s, %s" % (install_type, installer_ip))
- scenario = _get_value(CONST.__getattribute__('DEPLOY_SCENARIO'))
- node = _get_value(CONST.__getattribute__('NODE_NAME'))
- is_debug = _get_value(CONST.__getattribute__('CI_DEBUG'), 'false')
- build_tag = CONST.__getattribute__('BUILD_TAG')
- if build_tag is not None:
- build_tag = build_tag.lstrip(
- "jenkins-").lstrip("functest").lstrip("-")
-
- env_info = {'INSTALLER': installer_info,
- 'SCENARIO': scenario,
- 'POD': node,
- 'DEBUG FLAG': is_debug,
- 'BUILD_TAG': build_tag}
-
- return env_info
-
-
-class CliEnv(Env):
-
- def __init__(self):
- super(CliEnv, self).__init__()
-
- def show(self):
- env_info = super(CliEnv, self).show()
- msg = prettytable.PrettyTable(
- header_style='upper', padding_width=5,
- field_names=['Functest Environment', 'value'])
- for key, value in six.iteritems(env_info):
- if key is not None:
- msg.add_row([key, value])
- click.echo(msg.get_string())
diff --git a/functest/cli/commands/cli_os.py b/functest/cli/commands/cli_os.py
deleted file mode 100644
index 9057da84b..000000000
--- a/functest/cli/commands/cli_os.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/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
-#
-
-
-import os
-
-import click
-from six.moves.urllib.parse import urlparse
-
-from functest.ci import check_deployment
-from functest.utils.constants import CONST
-
-
-class OpenStack(object):
-
- def __init__(self):
- self.os_auth_url = CONST.__getattribute__('OS_AUTH_URL')
- self.endpoint_ip = None
- self.endpoint_port = None
- self.openstack_creds = CONST.__getattribute__('openstack_creds')
- if self.os_auth_url:
- self.endpoint_ip = urlparse(self.os_auth_url).hostname
- self.endpoint_port = urlparse(self.os_auth_url).port
-
- def ping_endpoint(self):
- if self.os_auth_url is None:
- click.echo("Source the OpenStack credentials first '. $creds'")
- exit(0)
- response = os.system("ping -c 1 " + self.endpoint_ip + ">/dev/null")
- if response == 0:
- return 0
- else:
- click.echo("Cannot talk to the endpoint %s\n" % self.endpoint_ip)
- exit(0)
-
- @staticmethod
- def show_credentials():
- dic_credentials = {}
- for key, value in os.environ.items():
- if key.startswith('OS_'):
- dic_credentials.update({key: value})
- return dic_credentials
-
- def check(self):
- self.ping_endpoint()
- deployment = check_deployment.CheckDeployment()
- deployment.check_all()
-
-
-class CliOpenStack(OpenStack):
-
- def __init__(self):
- super(CliOpenStack, self).__init__()
-
- @staticmethod
- def show_credentials():
- dic_credentials = OpenStack.show_credentials()
- for key, value in dic_credentials.items():
- if key.startswith('OS_'):
- click.echo("{}={}".format(key, value))
diff --git a/functest/cli/commands/cli_testcase.py b/functest/cli/commands/cli_testcase.py
deleted file mode 100644
index ee7afa5a8..000000000
--- a/functest/cli/commands/cli_testcase.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/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 pkg_resources
-
-import click
-
-import functest.ci.tier_builder as tb
-from functest.utils.constants import CONST
-import functest.utils.functest_utils as ft_utils
-import functest.utils.functest_vacation as vacation
-
-
-class Testcase(object):
-
- def __init__(self):
- self.tiers = tb.TierBuilder(
- CONST.__getattribute__('INSTALLER_TYPE'),
- CONST.__getattribute__('DEPLOY_SCENARIO'),
- pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
-
- def list(self):
- summary = ""
- for tier in self.tiers.get_tiers():
- for test in tier.get_tests():
- summary += (" %s\n" % test.get_name())
- return summary
-
- def show(self, testname):
- description = self.tiers.get_test(testname)
- return description
-
- @staticmethod
- def run(testname, noclean=False, report=False):
-
- flags = ""
- if noclean:
- flags += "-n "
- if report:
- flags += "-r "
-
- if testname == 'vacation':
- vacation.main()
- else:
- tests = testname.split(",")
- for test in tests:
- cmd = "run_tests {}-t {}".format(flags, test)
- ft_utils.execute_command(cmd)
-
-
-class CliTestcase(Testcase):
-
- def __init__(self):
- super(CliTestcase, self).__init__()
-
- def list(self):
- click.echo(super(CliTestcase, self).list())
-
- def show(self, testname):
- testcase_show = super(CliTestcase, self).show(testname)
- if testcase_show:
- click.echo(testcase_show)
- else:
- click.echo("The test case '%s' does not exist or is not supported."
- % testname)
diff --git a/functest/cli/commands/cli_tier.py b/functest/cli/commands/cli_tier.py
deleted file mode 100644
index 104cf10b5..000000000
--- a/functest/cli/commands/cli_tier.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/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 pkg_resources
-
-import click
-
-import functest.ci.tier_builder as tb
-from functest.utils.constants import CONST
-import functest.utils.functest_utils as ft_utils
-
-
-class Tier(object):
-
- def __init__(self):
- self.tiers = tb.TierBuilder(
- CONST.__getattribute__('INSTALLER_TYPE'),
- CONST.__getattribute__('DEPLOY_SCENARIO'),
- pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
-
- 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()))
- return summary
-
- def show(self, tiername):
- tier = self.tiers.get_tier(tiername)
- if tier is None:
- return None
- else:
- tier_info = self.tiers.get_tier(tiername)
- return tier_info
-
- def gettests(self, tiername):
- tier = self.tiers.get_tier(tiername)
- if tier is None:
- return None
- else:
- tests = tier.get_test_names()
- return tests
-
- @staticmethod
- def run(tiername, noclean=False, report=False):
- flags = ""
- if noclean:
- flags += "-n "
- if report:
- flags += "-r "
-
- cmd = "run_tests {}-t {}".format(flags, tiername)
- ft_utils.execute_command(cmd)
-
-
-class CliTier(Tier):
-
- def __init__(self):
- super(CliTier, self).__init__()
-
- def list(self):
- click.echo(super(CliTier, self).list())
-
- def show(self, tiername):
- tier_info = super(CliTier, self).show(tiername)
- if tier_info:
- click.echo(tier_info)
- else:
- 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))
-
- def gettests(self, tiername):
- tests = super(CliTier, self).gettests(tiername)
- if tests:
- click.echo("Test cases in tier '%s':\n %s\n" % (tiername, tests))
- else:
- 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))
diff --git a/functest/cli/functest-complete.sh b/functest/cli/functest-complete.sh
deleted file mode 100644
index f01490713..000000000
--- a/functest/cli/functest-complete.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-_functest_completion() {
- COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
- COMP_CWORD=$COMP_CWORD \
- _FUNCTEST_COMPLETE=complete $1 ) )
- return 0
-}
-
-complete -F _functest_completion -o default functest;