diff options
Diffstat (limited to 'qtip/cli')
-rw-r--r-- | qtip/cli/commands/cmd_metric.py | 34 | ||||
-rw-r--r-- | qtip/cli/commands/cmd_perftest.py | 58 | ||||
-rw-r--r-- | qtip/cli/commands/cmd_plan.py | 45 | ||||
-rw-r--r-- | qtip/cli/commands/cmd_qpi.py | 35 | ||||
-rw-r--r-- | qtip/cli/commands/cmd_suite.py | 54 | ||||
-rw-r--r-- | qtip/cli/entry.py | 9 |
6 files changed, 94 insertions, 141 deletions
diff --git a/qtip/cli/commands/cmd_metric.py b/qtip/cli/commands/cmd_metric.py new file mode 100644 index 00000000..d2fbd58f --- /dev/null +++ b/qtip/cli/commands/cmd_metric.py @@ -0,0 +1,34 @@ +############################################################################## +# Copyright (c) 2016 ZTE Corp and others. +# +# 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 + +from qtip.cli.entry import Context + +pass_context = click.make_pass_decorator(Context, ensure=False) + + +@click.group() +@pass_context +def cli(ctx): + ''' Performance Metrics Group ''' + pass + + +@cli.command('list', help='List all the Metric Groups') +@pass_context +def cmd_list(ctx): + pass + + +@cli.command('run', help='Run tests to collect Performance Metrics') +@click.argument('name') +@pass_context +def cmd_run(ctx, name): + pass diff --git a/qtip/cli/commands/cmd_perftest.py b/qtip/cli/commands/cmd_perftest.py deleted file mode 100644 index 129ee2d9..00000000 --- a/qtip/cli/commands/cmd_perftest.py +++ /dev/null @@ -1,58 +0,0 @@ -############################################################################## -# Copyright (c) 2016 ZTE Corp and others. -# -# 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 -############################################################################## - -from prettytable import PrettyTable -import yaml -import click -import os -from qtip.cli import helper - - -class PerfTest: - - def __init__(self): - self.path = os.path.join(helper.fetch_root(), 'perftest/summary') - - def list(self): - table = PrettyTable(["Name", "Description"]) - table.align = 'l' - with open(self.path) as tests: - line = tests.read() - data = yaml.safe_load(line)['test_cases'] - for i in range(0, len(data)): - points = data[i] - table.add_row([points['name'], points['description']]) - click.echo(table) - - def run(self): - click.echo("Run a perftest") - - -@click.group() -def cli(): - pass - - -@cli.group() -@click.pass_context -def perftest(ctx): - pass - - -_perftest = PerfTest() - - -@perftest.command("list", help="Lists all perftest benchmarks.") -def list(): - _perftest.list() - - -@perftest.command("run", help="Executes a single perftest benchmark.") -def execute(): - _perftest.run() diff --git a/qtip/cli/commands/cmd_plan.py b/qtip/cli/commands/cmd_plan.py index 6f622e5a..0c0a3c12 100644 --- a/qtip/cli/commands/cmd_plan.py +++ b/qtip/cli/commands/cmd_plan.py @@ -1,4 +1,4 @@ -############################################################################# +############################################################################## # Copyright (c) 2016 ZTE Corp and others. # # All rights reserved. This program and the accompanying materials @@ -7,38 +7,39 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## + import click -from prettytable import PrettyTable -from qtip.loader.plan import Plan +from qtip.cli.entry import Context + + +pass_context = click.make_pass_decorator(Context, ensure=False) @click.group() -def cli(): +@pass_context +def cli(ctx): + ''' Bechmarking Plan ''' pass -@cli.group() -def plan_cmd(): +@cli.command('init', help='Initialize Environment') +@click.option('--inst_type', prompt='Installer Type') +@click.option('--inst_ip', prompt='Installer IP') +@click.option('--ext_net', prompt='Openstack External Network') +@pass_context +def init(ctx, inst_type, inst_ip, ext_net): pass -@plan_cmd.command('list', help='List the different TestPlans.') -def list_all(): - plans = Plan.list_all() - table = PrettyTable(["Testplans"]) - table.align = 'l' - for plan in plans: - table.add_row([plan['name']]) - click.echo(table) +@cli.command('list', help='List the Plans') +@pass_context +def list(ctx): + pass -@plan_cmd.command('show', help='Show details of specified TestPlan.') +@cli.command('run', help='Execute a Plan') @click.argument('name') -def show(name): - plan = Plan(name) - results = plan.content() - table = PrettyTable(["Name", "Description"]) - table.align = 'l' - table.add_row([results['name'], results['description']]) - click.echo(table) +@pass_context +def run(ctx, name): + pass diff --git a/qtip/cli/commands/cmd_qpi.py b/qtip/cli/commands/cmd_qpi.py new file mode 100644 index 00000000..f33f0104 --- /dev/null +++ b/qtip/cli/commands/cmd_qpi.py @@ -0,0 +1,35 @@ +############################################################################## +# Copyright (c) 2016 ZTE Corp and others. +# +# 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 + +from qtip.cli.entry import Context + +pass_context = click.make_pass_decorator(Context, ensure=False) + + +@click.group() +@pass_context +def cli(ctx): + ''' Collection of performance tests ''' + pass + + +@cli.command('list', help='List all the QPI specs') +@pass_context +def cmd_list(ctx): + pass + + +@cli.command('run', help='Run performance tests for the specified QPI') +@click.argument('name') +@pass_context +def run(ctx, name): + pass diff --git a/qtip/cli/commands/cmd_suite.py b/qtip/cli/commands/cmd_suite.py deleted file mode 100644 index 45c739df..00000000 --- a/qtip/cli/commands/cmd_suite.py +++ /dev/null @@ -1,54 +0,0 @@ -############################################################################## -# Copyright (c) 2016 ZTE Corp and others. -# -# 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 -############################################################################## - -from prettytable import PrettyTable -import os -import click -from qtip.cli import helper - - -class Suite: - - def __init__(self): - self.path = os.path.join(helper.fetch_root(), 'suite') - - def list(self): - table = PrettyTable(["Name"]) - table.align = 'l' - suites = os.listdir(self.path) - for suite in suites: - table.add_row([suite]) - click.echo(table) - - def run(self): - print("Run a suite") - - -@click.group() -def cli(): - pass - - -@cli.group() -@click.pass_context -def suite(ctx): - pass - - -_suite = Suite() - - -@suite.command("list", help="Lists all the available suites") -def list(): - _suite.list() - - -@suite.command("run", help="Execute one complete suite") -def execute(): - _suite.run() diff --git a/qtip/cli/entry.py b/qtip/cli/entry.py index 0ecb06cd..9f51f25e 100644 --- a/qtip/cli/entry.py +++ b/qtip/cli/entry.py @@ -22,7 +22,6 @@ class Context(object): def __init__(self): self.verbose = False self.debug = False - self.version = 'qtip-1.0.0' def log(self, msg, *args): ''' Log message to stderr ''' @@ -32,10 +31,6 @@ class Context(object): ''' Log message to stderr when verbose ''' pass - def version(self): - ''' Display programs version ''' - pass - def debug(self, msg, *args): ''' Log message to debug ''' pass @@ -72,7 +67,7 @@ class QtipCli(click.MultiCommand): invoke_without_command=True) @click.option('-v', '--verbose', is_flag=True, help='Enable verbose mode.') @click.option('-d', '--debug', is_flag=True, help='Enable debug mode.') -@click.option('--version', is_flag=True, help='Shows program current version.') +@click.version_option('dev') @pass_context -def cli(ctx, verbose, version, debug): +def cli(ctx, verbose, debug): pass |