def __init__(self, filename, excinfo=None):
self.filename = filename
self.excinfo = excinfo
+ self.message = "Invalid content in {0}".format(filename)
class NotFoundError(BaseError):
def __init__(self, needle, heystack='qtip'):
self.needle = needle
self.heystack = heystack
+ self.message = "{0} not found in {1}".format(needle[0:-5], heystack)
class ToBeDoneError(BaseError):
##############################################################################
import click
+from colorama import Fore
import os
+from qtip.base.error import InvalidContentError
+from qtip.base.error import NotFoundError
from qtip.cli import utils
from qtip.cli.entry import Context
from qtip.loader.metric import MetricSpec
@click.argument('name')
@pass_context
def show(ctx, name):
- metric = MetricSpec('{}.yaml'.format(name))
- cnt = metric.content
- output = utils.render('metric', cnt)
- click.echo(output)
+ try:
+ metric = MetricSpec('{}.yaml'.format(name))
+ except NotFoundError as nf:
+ click.echo(Fore.RED + "ERROR: metric spec: " + nf.message)
+ except InvalidContentError as ice:
+ click.echo(Fore.RED + "ERROR: metric spec " + ice.message)
+ else:
+ cnt = metric.content
+ output = utils.render('metric', cnt)
+ click.echo(output)
@cli.command('run', help='Run performance test')
import click
+from colorama import Fore
import os
+from qtip.base.error import InvalidContentError
+from qtip.base.error import NotFoundError
from qtip.cli import utils
from qtip.cli.entry import Context
from qtip.loader.plan import Plan
@click.argument('name')
@pass_context
def show(ctx, name):
- plan = Plan('{}.yaml'.format(name))
- cnt = plan.content
- output = utils.render('plan', cnt)
- click.echo(output)
+ try:
+ plan = Plan('{}.yaml'.format(name))
+ except NotFoundError as nf:
+ click.echo(Fore.RED + "ERROR: plan spec: " + nf.message)
+ except InvalidContentError as ice:
+ click.echo(Fore.RED + "ERROR: plan spec: " + ice.message)
+ else:
+ cnt = plan.content
+ output = utils.render('plan', cnt)
+ click.echo(output)
@cli.command('run', help='Execute a Plan')
import click
+from colorama import Fore
import os
+from qtip.base.error import InvalidContentError
+from qtip.base.error import NotFoundError
from qtip.cli import utils
from qtip.cli.entry import Context
from qtip.loader.qpi import QPISpec
@click.argument('name')
@pass_context
def show(ctx, name):
- qpi = QPISpec('{}.yaml'.format(name))
- cnt = qpi.content
- output = utils.render('qpi', cnt)
- click.echo(output)
+ try:
+ qpi = QPISpec('{}.yaml'.format(name))
+ except NotFoundError as nf:
+ click.echo(Fore.RED + "ERROR: qpi spec: " + nf.message)
+ except InvalidContentError as ice:
+ click.echo(Fore.RED + "ERROR: qpi spec: " + ice.message)
+ else:
+ cnt = qpi.content
+ output = utils.render('qpi', cnt)
+ click.echo(output)
@cli.command('run', help='Run performance tests for the specified QPI')
+colorama
ansible
click
connexion
result = runner.invoke(cli, ['metric', 'show'])
assert 'Missing argument "name".' in result.output
+
+ result = runner.invoke(cli, ['metric', 'show', 'xyz'])
+ assert "ERROR: metric spec: xyz not found" in result.output
result = runner.invoke(cli, ['plan', 'show'])
assert 'Missing argument "name".' in result.output
+
+ result = runner.invoke(cli, ['plan', 'show', 'xyz'])
+ assert "ERROR: plan spec: xyz not found" in result.output
result = runner.invoke(cli, ['qpi', 'show'])
assert 'Missing argument "name".' in result.output
+
+ result = runner.invoke(cli, ['qpi', 'show', 'xyz'])
+ assert "ERROR: qpi spec: xyz not found" in result.output