diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | CONTRIBUTING.md | 1 | ||||
-rw-r--r-- | DEVELOP.md | 101 | ||||
-rw-r--r-- | opt/servers/dev.yml | 10 | ||||
-rw-r--r-- | opt/servers/inventory | 4 | ||||
-rw-r--r-- | opt/servers/test.yml | 6 | ||||
-rw-r--r-- | qtip/api/cmd/server.py | 2 | ||||
-rw-r--r-- | qtip/api/handler/job_handler.py | 4 | ||||
-rw-r--r-- | qtip/api/model/job_model.py | 4 | ||||
-rw-r--r-- | qtip/cli/entry.py | 69 | ||||
-rw-r--r-- | tests/unit/cli/test_module.py | 31 | ||||
-rw-r--r-- | tests/unit/cli/test_options.py | 32 |
12 files changed, 213 insertions, 55 deletions
@@ -66,3 +66,7 @@ target/ /docs_build/ /docs_output/ .idea + +# setup.py cache +AUTHORS +ChangeLog diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 93c8bc9d..a3e56317 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,7 @@ Active Reviewers Current list of active reviewers in gerrit group `qtip-reviewers` +* Akhil Batra <akhil.batra@research.iiit.ac.in> * Serena Feng <feng.xiaowei@zte.com.cn> * Taseer Ahmed <taseer94@gmail.com> * Yujun Zhang <zhang.yujunz@zte.com.cn> diff --git a/DEVELOP.md b/DEVELOP.md new file mode 100644 index 00000000..9ec3a93d --- /dev/null +++ b/DEVELOP.md @@ -0,0 +1,101 @@ +# QTIP Developer Guide + +This guide is about how to **develop** QTIP. + +If you just want to use it for performance benchmark, check the user guide +instead. + +## Getting Started + +### Source code + +```bash +~$ git clone https://gerrit.opnfv.org/gerrit/qtip +``` + +### VirtualEnv + +It is recommended to use [virtualenv](https://virtualenv.pypa.io) to isolate +your development environment from system, especially when you are working on +several different projects. + +### Testing + +QTIP use [tox](https://tox.readthedocs.io) to automate the testing tasks + +```bash +$ pip install tox +$ tox +``` + +## Architecture + +**TODO**: move to design spec + +QTIP has a flexible architecture to allow different deployment mode + +- **Standalone**: full feature performance benchmark platform. +- **Agent**: minimal agent driven by external test runners. + +### Standalone Mode (Solo) + +QTIP instance deployed in container, VM or host generate benchmark report and +push data to Indices Hub for storage and visualization. + + + +### Agent Mode (Melody) + +QTIP Collector and Reporter driven by external test framework or runner such as +[yardstick](https://wiki.opnfv.org/display/yardstick), +[pytest](http://doc.pytest.org/) and etc. + + + +## Core Modules + +TBD + +- loader +- runner +- collector +- reporter + +## Drivers + +TBD + +- ansible +- yardstick + +## Interfaces + +### Agent + +TBD + +### CLI + +TBD + +### API + +TBD + +## Assets + +**TODO**: move to user guide + +- benchmark plan +- QPI spec +- metric spec + +## Docker Image + +TBD + +## Annex + +### Directories + +TBD diff --git a/opt/servers/dev.yml b/opt/servers/dev.yml deleted file mode 100644 index 2e0cca93..00000000 --- a/opt/servers/dev.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- hosts: development - roles: - - user - - docker - - elk - - mongo - - nginx - - qtip - - testapi diff --git a/opt/servers/inventory b/opt/servers/inventory index 0a862caa..1ba1dc45 100644 --- a/opt/servers/inventory +++ b/opt/servers/inventory @@ -1,8 +1,4 @@ -desk ansible_host=desk.qtip.io # 2vCPU/4GiB/16GiB (AWS us-east-1a) table ansible_host=table.qtip.io # 1vCPU/1024MB/100Mbps/40GB (Aliyun Hongkong B) -[development] -desk - [testing] table diff --git a/opt/servers/test.yml b/opt/servers/test.yml index 549b7255..ee3ded13 100644 --- a/opt/servers/test.yml +++ b/opt/servers/test.yml @@ -2,3 +2,9 @@ - hosts: testing roles: - user + - docker + - elk + - mongo + - nginx + - qtip + - testapi diff --git a/qtip/api/cmd/server.py b/qtip/api/cmd/server.py index 852073a7..3b89af1e 100644 --- a/qtip/api/cmd/server.py +++ b/qtip/api/cmd/server.py @@ -13,7 +13,7 @@ from flask_restful_swagger import swagger import qtip.api.router.mapper as mapper app = Flask(__name__) -api = swagger.docs(Api(app), apiVersion='0.1') +api = swagger.docs(Api(app), apiVersion='0.1', description='QTIP API specs') def add_routers(): diff --git a/qtip/api/handler/job_handler.py b/qtip/api/handler/job_handler.py index f230e596..eade9df7 100644 --- a/qtip/api/handler/job_handler.py +++ b/qtip/api/handler/job_handler.py @@ -1,8 +1,8 @@ import threading from copy import copy -from flask.ext.restful import Resource, reqparse -from flask.ext.restful_swagger import swagger +from flask_restful import Resource, reqparse +from flask_restful_swagger import swagger from werkzeug.exceptions import abort from qtip.api.handler import db, result_handler diff --git a/qtip/api/model/job_model.py b/qtip/api/model/job_model.py index eef771b0..f7eb9fda 100644 --- a/qtip/api/model/job_model.py +++ b/qtip/api/model/job_model.py @@ -1,5 +1,5 @@ -from flask.ext.restful import fields -from flask.ext.restful_swagger import swagger +from flask_restful import fields +from flask_restful_swagger import swagger @swagger.model diff --git a/qtip/cli/entry.py b/qtip/cli/entry.py index c3ebf96a..0ecb06cd 100644 --- a/qtip/cli/entry.py +++ b/qtip/cli/entry.py @@ -7,13 +7,72 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import os +import sys import click -from qtip.cli.commands import cmd_perftest -from qtip.cli.commands import cmd_suite + CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) -cli = click.CommandCollection(sources=[cmd_perftest.cli, cmd_suite.cli]) -if __name__ == '__main__': - cli() +class Context(object): + + ''' TODO(taseer) implementation''' + + def __init__(self): + self.verbose = False + self.debug = False + self.version = 'qtip-1.0.0' + + def log(self, msg, *args): + ''' Log message to stderr ''' + pass + + def verbose(self, msg, *args): + ''' Log message to stderr when verbose ''' + pass + + def version(self): + ''' Display programs version ''' + pass + + def debug(self, msg, *args): + ''' Log message to debug ''' + pass + + +pass_context = click.make_pass_decorator(Context, ensure=True) +cmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), + 'commands')) + + +class QtipCli(click.MultiCommand): + + def list_commands(self, ctx): + rv = [] + for filename in os.listdir(cmd_folder): + if filename.endswith('.py') and \ + filename.startswith('cmd_'): + rv.append(filename[4:-3]) + rv.sort() + return rv + + def get_command(self, ctx, name): + try: + if sys.version_info[0] == 2: + name = name.encode('ascii', 'replace') + mod = __import__('qtip.cli.commands.cmd_' + name, + None, None, ['cli']) + except ImportError: + return + return mod.cli + + +@click.command(cls=QtipCli, context_settings=CONTEXT_SETTINGS, + 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.') +@pass_context +def cli(ctx, verbose, version, debug): + pass diff --git a/tests/unit/cli/test_module.py b/tests/unit/cli/test_module.py deleted file mode 100644 index a8900684..00000000 --- a/tests/unit/cli/test_module.py +++ /dev/null @@ -1,31 +0,0 @@ -import os -import pytest -import sys -import yaml - -from click.testing import CliRunner -from qtip.cli.entry import cli - - -class TestClass(object): - '''TODO(taseer) Remove hardcoded behaviour ''' - - @pytest.fixture() - def runner(self): - return CliRunner() - - def test(self, runner): - unit = 'perftest' - test_file = 'data/helper/' + unit + '.yaml' - path = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, test_file) - - with open(path) as trial: - content = trial.read() - data = yaml.safe_load(content)['tests'] - if data is None: - print("Unit Test does not exist") - sys.exit(1) - else: - for i in range(0, len(data)): - result = runner.invoke(cli, data[i]['command']) - assert result.output == data[i]['output'] diff --git a/tests/unit/cli/test_options.py b/tests/unit/cli/test_options.py new file mode 100644 index 00000000..5129b5cc --- /dev/null +++ b/tests/unit/cli/test_options.py @@ -0,0 +1,32 @@ +############################################################### +# 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 pytest +from click.testing import CliRunner + +from qtip.cli.entry import cli + + +class TestClass(object): + + @pytest.fixture() + def runner(self): + return CliRunner() + + def test_verbose(self, runner): + result = runner.invoke(cli, ['-v']) + assert result.output == '' + + def test_version(self, runner): + result = runner.invoke(cli, ['--version']) + assert '' in result.output + + def test_debug(self, runner): + result = runner.invoke(cli, ['-d']) + assert '' in result.output |