diff options
65 files changed, 416 insertions, 139 deletions
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 6350a862..d10f1393 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -15,9 +15,26 @@ Peer review is the most important communication channel between developers. Every subtle change to the code or document **MUST** be reviewed before submission. +Add group ``qtip-reviewers`` in `gerrit`_ when you consider a patch set is ready. + Please make sure there is at least one ``+1`` or ``+2`` from others before submitting[#f1] a patch set. +Active Reviewers +================ + +Current list of active reviewers in gerrit group ``qtip-reviewers`` + +* Serena Feng <feng.xiaowei@zte.com.cn> +* Taseer Ahmed <taseer94@gmail.com> +* Yujun Zhang <zhang.yujunz@zte.com.cn> +* Zhifeng Jiang <jiang.zhifeng@zte.com.cn> +* Zhihui Wu <wu.zhihui1@zte.com.cn> + +By becoming an active reviewer, you agree to allow others to invite you as +reviewers in QTIP project freely. Any one in OPNFV community can apply to join +QTIP reviewers group or leave by submitting a patch on this document. + **************** Tasks and Issues **************** @@ -88,6 +105,7 @@ to submit. The current members are listed in `INFO`_. .. rubric:: Reference .. _Developer Getting Started: https://wiki.opnfv.org/display/DEV/Developer+Getting+Started +.. _gerrit: https://gerrit.opnfv.org/gerrit/#/q/project:+qtip .. _JIRA: https://jira.opnfv.org/browse/QTIP .. _OPNFV Releases: https://wiki.opnfv.org/display/SWREL .. _Issue Types: https://jira.opnfv.org/secure/ShowConstantsHelp.jspa?decorator=popup#IssueTypes diff --git a/docker/run_qtip.sh b/docker/run_qtip.sh index a7a20501..c2cf8c7b 100755 --- a/docker/run_qtip.sh +++ b/docker/run_qtip.sh @@ -1,20 +1,22 @@ #! /bin/bash +QTIP=scripts/qtip.py + run_test_suite() { if [ "$TEST_CASE" == "compute" ]; then - cd ${QTIP_DIR} && python qtip.py -l default -f compute + cd ${QTIP_DIR} && python ${QTIP} -l default -f compute cd ${QTIP_DIR} && python scripts/ref_results/suite_result.py compute elif [ "$TEST_CASE" == "storage" ]; then - cd ${QTIP_DIR} && python qtip.py -l default -f storage + cd ${QTIP_DIR} && python ${QTIP} -l default -f storage cd ${QTIP_DIR} && python scripts/ref_results/suite_result.py storage elif [ "$TEST_CASE" == "network" ]; then - cd ${QTIP_DIR} && python qtip.py -l default -f network + cd ${QTIP_DIR} && python ${QTIP} -l default -f network cd ${QTIP_DIR} && python scripts/ref_results/suite_result.py network elif [ "$TEST_CASE" == "all" ]; then - cd ${QTIP_DIR} && python qtip.py -l default -f compute - cd ${QTIP_DIR} && python qtip.py -l default -f storage - cd ${QTIP_DIR} && python qtip.py -l default -f network + cd ${QTIP_DIR} && python ${QTIP} -l default -f compute + cd ${QTIP_DIR} && python ${QTIP} -l default -f storage + cd ${QTIP_DIR} && python ${QTIP} -l default -f network cd ${QTIP_DIR} && python scripts/ref_results/suite_result.py compute cd ${QTIP_DIR} && python scripts/ref_results/suite_result.py storage diff --git a/docker/supervisord.conf b/docker/supervisord.conf index 35d16c7e..a6d457dd 100644 --- a/docker/supervisord.conf +++ b/docker/supervisord.conf @@ -2,7 +2,7 @@ nodaemon=true [program:qtip_server] -command=bash -c "cd $REPOS_DIR/qtip&&python restful_server/qtip_server.py" +command=bash -c "cd $REPOS_DIR/qtip&&python qtip/api/qtip_server.py" numprocs=1 autostart=true autorestart=true diff --git a/docs/userguide/_02-network.rst b/docs/userguide/_02-network.rst index 18f328ae..60604bf3 100644 --- a/docs/userguide/_02-network.rst +++ b/docs/userguide/_02-network.rst @@ -25,7 +25,7 @@ One of the compute nodes is used as a server and the other as a client. The client pushes traffic to the server for a duration specified by the user in the configuration file for Iperf3. -These files can be found in the "test_plan/{POD}/network/" directory. +These files can be found in the "benchmarks/test_plan/{POD}/network/" directory. The bandwidth is limited by the physical link layer speed connecting the two compute nodes. The result file includes the b/s bandwidth and the CPU usage for both the client and server. diff --git a/docs/userguide/introduction.rst b/docs/userguide/introduction.rst index 0c8e1665..46bd37e4 100644 --- a/docs/userguide/introduction.rst +++ b/docs/userguide/introduction.rst @@ -18,7 +18,7 @@ QTIP Directory structure The QTIP directory has been sectioned off into multiple folders to facilitate segmenting information into relevant categories. The folders that concern - the end user are `test_plan/` and `benchmarks/suite/`. + the end user are `benchmarks/test_plan/` and `benchmarks/suite/`. **test_plan/:** @@ -315,7 +315,7 @@ Commands to run the Framework: ------------------------------ In order to start QTIP on the default lab please use the following commands (asssuming your installer -is 'fuel' or 'compass', you use the config files in the test_plan/default/ directory and listed the +is 'fuel' or 'compass', you use the config files in the benchmarks/test_plan/default/ directory and listed the intended suite in the benchmarks/suite/<RELEVANT-SUITE-FILE>): First step is to export the necessary information to the environment and generate QTIP key pair. diff --git a/opnfv-creds.sh b/opnfv-creds.sh deleted file mode 100644 index 54d5aa3a..00000000 --- a/opnfv-creds.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -export LC_ALL=C -export OS_NO_CACHE='true' -export OS_TENANT_NAME='admin' -export OS_USERNAME='admin' -export OS_PASSWORD='admin' -export OS_AUTH_URL='http://172.18.1.5:5000/v2.0' -export OS_AUTH_STRATEGY='keystone' -export OS_REGION_NAME='RegionOne' -export CINDER_ENDPOINT_TYPE='internalURL' -export GLANCE_ENDPOINT_TYPE='internalURL' -export KEYSTONE_ENDPOINT_TYPE='internalURL' -export NOVA_ENDPOINT_TYPE='internalURL' -export NEUTRON_ENDPOINT_TYPE='internalURL' -export OS_ENDPOINT_TYPE='internalURL' -export MURANO_REPO_URL='http://storage.apps.openstack.org/' diff --git a/opt/servers/inventory b/opt/servers/inventory index 74c04c42..65c6c35d 100644 --- a/opt/servers/inventory +++ b/opt/servers/inventory @@ -1,4 +1,5 @@ -qtip-dev ansible_host=qtip.openzero.net +qtip-dev ansible_host=dev.qtip.io +qtip-test ansible_host=test.qtip.io [elk-servers] qtip-dev @@ -8,3 +9,9 @@ qtip-dev [qtip-servers] qtip-dev + +[testapi-servers] +qtip-dev + +[mongo-servers] +qtip-dev diff --git a/opt/servers/mongo.yml b/opt/servers/mongo.yml new file mode 100644 index 00000000..e64c0c69 --- /dev/null +++ b/opt/servers/mongo.yml @@ -0,0 +1,4 @@ +--- +- hosts: mongo-servers + roles: + - mongo diff --git a/opt/servers/roles/mongo/tasks/main.yml b/opt/servers/roles/mongo/tasks/main.yml new file mode 100644 index 00000000..81fb49b5 --- /dev/null +++ b/opt/servers/roles/mongo/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- name: pulling mongo + become: true + docker_image: name=mongo:3.2.1 state=present + +- name: setting up mongo + become: true + docker_container: + name: mongo + image: mongo:3.2.1 diff --git a/opt/servers/roles/ngnix/defaults/main.yml b/opt/servers/roles/ngnix/defaults/main.yml index cb3b3934..cdd1d773 100644 --- a/opt/servers/roles/ngnix/defaults/main.yml +++ b/opt/servers/roles/ngnix/defaults/main.yml @@ -5,3 +5,6 @@ services: qtip_services: - { name: restful_api, upstream: 'http://127.0.0.1:5000' } + +testapi_services: + - { name: testapi, upstream: 'http://127.0.0.1:8000' } diff --git a/opt/servers/roles/ngnix/tasks/main.yml b/opt/servers/roles/ngnix/tasks/main.yml index ec146850..5c78166c 100644 --- a/opt/servers/roles/ngnix/tasks/main.yml +++ b/opt/servers/roles/ngnix/tasks/main.yml @@ -8,5 +8,6 @@ with_items: - elk - qtip + - testapi notify: - restart nginx diff --git a/opt/servers/roles/ngnix/templates/testapi.conf.j2 b/opt/servers/roles/ngnix/templates/testapi.conf.j2 new file mode 100644 index 00000000..6a4d388b --- /dev/null +++ b/opt/servers/roles/ngnix/templates/testapi.conf.j2 @@ -0,0 +1,17 @@ +# {{ ansible_managed }} + +# servers +# +{% for service in testapi_services %} +server { + listen 80; + listen 443 ssl; + server_name {{ service.name }}.qtip.openzero.net; + location / { + proxy_pass {{ service.upstream }}; + sub_filter {{ service.upstream }} 'http://{{ service.name }}.qtip.openzero.net'; + sub_filter_once off; + sub_filter_types text/html application/json; + } +} +{% endfor %} diff --git a/opt/servers/roles/ssh/tasks/main.yml b/opt/servers/roles/ssh/tasks/main.yml index 7de1e208..48318485 100644 --- a/opt/servers/roles/ssh/tasks/main.yml +++ b/opt/servers/roles/ssh/tasks/main.yml @@ -1,3 +1,6 @@ +- name: add group qtip + become: true + group: name=qtip state=present - name: add users for ssh access become: true user: @@ -23,4 +26,4 @@ owner: "{{ item.name }}" group: "{{ item.name }}" mode: 0600 - with_items: "{{ users }}"
\ No newline at end of file + with_items: "{{ users }}" diff --git a/opt/servers/roles/testapi/files/run_testapi.sh b/opt/servers/roles/testapi/files/run_testapi.sh new file mode 100644 index 00000000..f9ba8387 --- /dev/null +++ b/opt/servers/roles/testapi/files/run_testapi.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +envs="mongodb_url=mongodb://mongo:27017/ -e api_port=8000 -e swagger_url=http://testapi.qtip.openzero.net" +docker run --name testapi --link mongo:mongo -p 8000:8000 -e $envs -d opnfv/testapi diff --git a/opt/servers/roles/testapi/tasks/main.yml b/opt/servers/roles/testapi/tasks/main.yml new file mode 100644 index 00000000..8ca91396 --- /dev/null +++ b/opt/servers/roles/testapi/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- name: setting up testapi + become: true + script: ../files/run_testapi.sh diff --git a/opt/servers/ssh.yml b/opt/servers/ssh.yml index bd74ab3b..a7fbb1c0 100644 --- a/opt/servers/ssh.yml +++ b/opt/servers/ssh.yml @@ -1,4 +1,4 @@ --- -- hosts: elk-servers +- hosts: all roles: - ssh diff --git a/opt/servers/testapi.yml b/opt/servers/testapi.yml new file mode 100644 index 00000000..556284db --- /dev/null +++ b/opt/servers/testapi.yml @@ -0,0 +1,4 @@ +--- +- hosts: testapi-servers + roles: + - testapi diff --git a/qtip/__init__.py b/qtip/__init__.py new file mode 100644 index 00000000..228d036f --- /dev/null +++ b/qtip/__init__.py @@ -0,0 +1,14 @@ +############################################################################## +# 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 pbr.version + + +__version__ = pbr.version.VersionInfo( + 'qtip').version_string() diff --git a/qtip/api/qtip_server.py b/qtip/api/qtip_server.py index 537b2c05..9b9dd633 100644 --- a/qtip/api/qtip_server.py +++ b/qtip/api/qtip_server.py @@ -12,8 +12,8 @@ from flask_restful_swagger import swagger import threading from copy import copy import db -import utils.args_handler as args_handler -import restful_server.result_handler as result_handler +import qtip.utils.args_handler as args_handler +import qtip.api.result_handler as result_handler app = Flask(__name__) diff --git a/qtip/api/result_handler.py b/qtip/api/result_handler.py index 200330cb..de91cd2c 100644 --- a/qtip/api/result_handler.py +++ b/qtip/api/result_handler.py @@ -8,7 +8,7 @@ ############################################################################## import json import scripts.ref_results.suite_result as suite_result -import dashboard.pushtoDB as push_to_db +import qtip.utils.dashboard.pushtoDB as push_to_db def dump_suite_result(suite_name): diff --git a/qtip/cli/commands/cmd_ansible.py b/qtip/cli/commands/cmd_ansible.py new file mode 100644 index 00000000..857e68e2 --- /dev/null +++ b/qtip/cli/commands/cmd_ansible.py @@ -0,0 +1,61 @@ +############################################################################## +# 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 os + +import click + +ANSIBLE_CONF = '{}/conf/ansible.cfg'.format(os.environ['HOME']) + + +class Ansible: + + def __init__(self): + pass + + def show(self): + click.echo("show ansible configuration") + pass + + def prepare(self): + click.echo("prepare ansible env") + pass + + def status(self): + click.echo("check connectivity") + pass + + +@click.group() +def cli(): + pass + +_ansible = Ansible() + + +@cli.group() +@click.pass_context +def ansible(ctx): + pass + + +@ansible.command('prepare', help="Prepares the ansible environment. " + "This step is needed run benchmarks.") +def ansible_prepare(): + _ansible.prepare() + + +@ansible.command('show', help="Shows the current ansible configuration.") +def ansible_show(): + _ansible.show() + + +@ansible.command('status', help="Checks if ansible still connects to hosts.") +def ansible_status(): + _ansible.status() diff --git a/qtip/cli/commands/perftest.py b/qtip/cli/commands/cmd_perftest.py index 0eb6d062..5cfe4110 100644 --- a/qtip/cli/commands/perftest.py +++ b/qtip/cli/commands/cmd_perftest.py @@ -11,7 +11,7 @@ from prettytable import PrettyTable import yaml import click import os -from cli import helper +from qtip.cli import helper class PerfTest: diff --git a/qtip/cli/commands/suite.py b/qtip/cli/commands/cmd_suite.py index 757f11a1..f6c839ba 100644 --- a/qtip/cli/commands/suite.py +++ b/qtip/cli/commands/cmd_suite.py @@ -10,12 +10,13 @@ from prettytable import PrettyTable import os import click +from qtip.cli import helper class Suite: def __init__(self): - self.path = os.path.join(os.path.dirname(__file__), '..', '..', 'benchmarks/suite') + self.path = os.path.join(helper.fetch_root(), 'suite') def list(self): table = PrettyTable(["Name"]) diff --git a/qtip/cli/commands/cmd_version.py b/qtip/cli/commands/cmd_version.py new file mode 100644 index 00000000..b8779a72 --- /dev/null +++ b/qtip/cli/commands/cmd_version.py @@ -0,0 +1,54 @@ +############################################################################## +# 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 + + +class Version: + + def __init__(self): + pass + + def list(self): + click.echo("Lists all the different versions") + + def install(self, tag): + click.echo("Install: %s" % tag) + + def uninstall(self, tag): + click.echo("Uninstall: %s" % tag) + + +@click.group() +def cli(): + pass + + +@cli.group() +def version(): + pass + +_version = Version() + + +@version.command('list', help="List all the available QTIP versions.") +def list(): + _version.list() + + +@version.command('install', help="Install the specified QTIP version.") +@click.argument('tag') +def install(tag): + _version.install(tag) + + +@version.command('uninstall', help="Install the specified QTIP version.") +@click.argument('tag') +def uninstall(tag): + _version.uninstall(tag) diff --git a/qtip/cli/entry.py b/qtip/cli/entry.py index f9dc440c..66e45ddc 100644 --- a/qtip/cli/entry.py +++ b/qtip/cli/entry.py @@ -8,37 +8,13 @@ ############################################################################## import click - -from cli.commands.ansible import Ansible +from qtip.cli.commands import cmd_perftest +from qtip.cli.commands import cmd_suite +from qtip.cli.commands import cmd_ansible CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) +cli = click.CommandCollection(sources=[cmd_perftest.cli, cmd_suite.cli, cmd_ansible.cli]) -@click.group(context_settings=CONTEXT_SETTINGS) -@click.version_option(version='0.1.dev0') -def cli(): - pass - -_ansible = Ansible() - - -@cli.group() -@click.pass_context -def ansible(ctx): - pass - - -@ansible.command('prepare', help="Prepares the ansible environment. " - "This step is needed run benchmarks.") -def ansible_prepare(): - _ansible.prepare() - - -@ansible.command('show', help="Shows the current ansible configuration.") -def ansible_show(): - _ansible.show() - - -@ansible.command('status', help="Checks if ansible still connects to hosts.") -def ansible_status(): - _ansible.status() +if __name__ == '__main__': + cli() diff --git a/qtip/cli/helper.py b/qtip/cli/helper.py index a5865bce..acfecf8d 100644 --- a/qtip/cli/helper.py +++ b/qtip/cli/helper.py @@ -11,4 +11,4 @@ import os def fetch_root(): - return os.path.join(os.path.dirname(__file__), os.pardir, 'benchmarks/') + return os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'benchmarks/') diff --git a/__init__.py b/qtip/runner/__init__.py index e69de29b..e69de29b 100644 --- a/__init__.py +++ b/qtip/runner/__init__.py diff --git a/qtip/cli/commands/ansible.py b/qtip/runner/perftest.py index 001185a3..835f2a81 100644 --- a/qtip/cli/commands/ansible.py +++ b/qtip/runner/perftest.py @@ -7,26 +7,21 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import os -import click - -ANSIBLE_CONF = '{}/conf/ansible.cfg'.format(os.environ['HOME']) - - -class Ansible: +class PerfTest: + """A perf test collects raw performance metrics by running test tools""" def __init__(self): pass - def show(self): - click.echo("show ansible configuration") + @staticmethod + def list_all(): + """list all available perf tests""" pass - def prepare(self): - click.echo("prepare ansible env") + def desc(self): + """description of the perf test""" pass - def status(self): - click.echo("check connectivity") + def run(self): pass diff --git a/qtip/runner/suite.py b/qtip/runner/suite.py new file mode 100644 index 00000000..f0f2f63e --- /dev/null +++ b/qtip/runner/suite.py @@ -0,0 +1,28 @@ +############################################################################## +# 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 +############################################################################## + + +class Suite: + """A suite is consist of one or several perf tests and produces one QPI""" + + def __init__(self): + pass + + @staticmethod + def list_all(): + """list all available suites""" + pass + + def desc(self): + """description of the suite""" + pass + + def run(self): + """run included perftests in the suite""" + pass diff --git a/qtip/runner/test_plan.py b/qtip/runner/test_plan.py new file mode 100644 index 00000000..d20221df --- /dev/null +++ b/qtip/runner/test_plan.py @@ -0,0 +1,28 @@ +############################################################################## +# 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 +############################################################################## + + +class TestPlan: + """A test plan is consist of test configuration and selected test suites""" + + def __init__(self): + pass + + @staticmethod + def list_all(): + """list all available test plans""" + pass + + def desc(self): + """description of the test plan""" + pass + + def run(self): + """run included suites""" + pass diff --git a/qtip/utils/args_handler.py b/qtip/utils/args_handler.py index 879fd204..513309ab 100644 --- a/qtip/utils/args_handler.py +++ b/qtip/utils/args_handler.py @@ -21,13 +21,13 @@ def get_files_in_suite(suite_name, case_type='all'): def get_files_in_test_plan(lab, suite_name, case_type='all'): - test_case_all = os.listdir('./test_plan/{0}/{1}'.format(lab, suite_name)) + test_case_all = os.listdir('benchmarks/test_plan/{0}/{1}'.format(lab, suite_name)) return test_case_all if case_type == 'all' else \ filter(lambda x: case_type in x, test_case_all) def get_benchmark_path(lab, suit, benchmark): - return './test_plan/{0}/{1}/{2}'.format(lab, suit, benchmark) + return 'benchmarks/test_plan/{0}/{1}/{2}'.format(lab, suit, benchmark) def check_suite(suite_name): @@ -35,11 +35,11 @@ def check_suite(suite_name): def check_lab_name(lab_name): - return True if os.path.isdir('test_plan/' + lab_name) else False + return True if os.path.isdir('benchmarks/test_plan/' + lab_name) else False def check_benchmark_name(lab, file, benchmark): - return os.path.isfile('test_plan/' + lab + '/' + file + '/' + benchmark) + return os.path.isfile('benchmarks/test_plan/' + lab + '/' + file + '/' + benchmark) def _get_f_name(test_case_path): diff --git a/qtip/utils/cli.py b/qtip/utils/cli.py index def70061..c0a14214 100644 --- a/qtip/utils/cli.py +++ b/qtip/utils/cli.py @@ -23,7 +23,7 @@ class Cli: parser = argparse.ArgumentParser() parser.add_argument('-l ', '--lab', required=True, help='Name of Lab ' 'on which being tested, These can' - 'be found in the test_plan/ directory. Please ' + 'be found in the benchmarks/test_plan/ directory. Please ' 'ensure that you have edited the respective files ' 'before using them. For testing other than through Jenkins' ' The user should list default after -l . all the fields in' @@ -49,7 +49,7 @@ class Cli: sys.exit(1) if not args_handler.check_lab_name(args.lab): - logger.error("You have specified a lab that is not present under test_plan/.\ + logger.error("You have specified a lab that is not present under benchmarks/test_plan/.\ Please enter correct file. If unsure how to proceed, use -l default.") sys.exit(1) suite = args.file diff --git a/qtip/utils/dashboard/pushtoDB.py b/qtip/utils/dashboard/pushtoDB.py index e6a4d239..427d39c4 100644 --- a/qtip/utils/dashboard/pushtoDB.py +++ b/qtip/utils/dashboard/pushtoDB.py @@ -3,7 +3,7 @@ import json import datetime import os import sys -from utils import logger_utils +from qtip.utils import logger_utils logger = logger_utils.QtipLogger('push_db').get @@ -28,6 +28,14 @@ def push_results_to_db(db_url, case_name, payload, installer, pod_name): logger.info('pod_name:{0},installer:{1},creation_data:{2}'.format(pod_name, installer, creation_date)) + # temporary code, will be deleted after Bigergia dashboard is ready + try: + qtip_testapi_url = "http://testapi.qtip.openzero.net/results" + qtip_testapi_r = requests.post(qtip_testapi_url, data=json.dumps(params), headers=headers) + logger.info('Pushing Results to qtip_testapi: %s'.format(qtip_testapi_r)) + except: + logger.info("Pushing Results to qtip_testapi Error:{0}".format(sys.exc_info()[0])) + try: r = requests.post(url, data=json.dumps(params), headers=headers) logger.info(r) diff --git a/qtip.py b/scripts/qtip.py index a2c26eda..66ff674f 100644 --- a/qtip.py +++ b/scripts/qtip.py @@ -7,7 +7,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -from utils.cli import Cli +from qtip.utils.cli import Cli def main(): diff --git a/scripts/ref_results/suite_result.py b/scripts/ref_results/suite_result.py index 217181f9..66213391 100644 --- a/scripts/ref_results/suite_result.py +++ b/scripts/ref_results/suite_result.py @@ -9,7 +9,7 @@ import json import importlib import sys -from utils import logger_utils +from qtip.utils import logger_utils from os.path import expanduser logger = logger_utils.QtipLogger('suite_result').get diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..42f8a61d --- /dev/null +++ b/setup.cfg @@ -0,0 +1,22 @@ +[metadata] +name = qtip +summary = Platform Performance Benchmarking +description-file = + README.md +author = OPNFV +author-email = opnfv-tech-discuss@lists.opnfv.org +home-page = https://wiki.opnfv.org/display/qtip + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[entry_points] +console_scripts = + qtip = qti.cli:entry + +[files] +packages = + qtip +data_files = + etc/qtip = benchmarks/* @@ -2,19 +2,7 @@ from setuptools import setup - setup( - name='qtip-cli', - version='0.1.dev0', - description='Platform Performance Benchmarking for OPNFV', - author='OPNFV', - author_email='zhang.yujunz@zte.com.cn', - install_requires=['click', 'pyyaml', 'prettytable'], - packages=['cli'], - entry_points={ - 'console_scripts': ['qtip=cli.entry:cli'] - }, - license='Apache-2.0', - keywords="performance benchmark opnfv", - url="https://wiki.opnfv.org/display/qtip" + setup_requires=['pbr>=1.9', 'setuptools>=17.1'], + pbr=True, ) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/__init__.py diff --git a/tests/output/hosts b/tests/data/output/hosts index 9b47df0e..9b47df0e 100644 --- a/tests/output/hosts +++ b/tests/data/output/hosts diff --git a/tests/schema/test_bm_schema.yaml b/tests/data/schema/test_bm_schema.yaml index a7c27e3f..a7c27e3f 100644 --- a/tests/schema/test_bm_schema.yaml +++ b/tests/data/schema/test_bm_schema.yaml diff --git a/tests/schema/test_vm_schema.yaml b/tests/data/schema/test_vm_schema.yaml index 524f8fe4..524f8fe4 100644 --- a/tests/schema/test_vm_schema.yaml +++ b/tests/data/schema/test_vm_schema.yaml diff --git a/tests/test_case/bm_ping.yaml b/tests/data/test_plan/bm_ping.yaml index 41d696e2..41d696e2 100644 --- a/tests/test_case/bm_ping.yaml +++ b/tests/data/test_plan/bm_ping.yaml diff --git a/tests/test_case/bm_with_proxy.yaml b/tests/data/test_plan/bm_with_proxy.yaml index 1d73300b..1d73300b 100644 --- a/tests/test_case/bm_with_proxy.yaml +++ b/tests/data/test_plan/bm_with_proxy.yaml diff --git a/tests/test_case/bm_without_proxy.yaml b/tests/data/test_plan/bm_without_proxy.yaml index a9ae3b71..a9ae3b71 100644 --- a/tests/test_case/bm_without_proxy.yaml +++ b/tests/data/test_plan/bm_without_proxy.yaml diff --git a/tests/test_case/vm.yaml b/tests/data/test_plan/vm.yaml index 4c8453ca..4c8453ca 100644 --- a/tests/test_case/vm.yaml +++ b/tests/data/test_plan/vm.yaml diff --git a/tests/test_case/vm_error.yaml b/tests/data/test_plan/vm_error.yaml index f13d3a00..f13d3a00 100644 --- a/tests/test_case/vm_error.yaml +++ b/tests/data/test_plan/vm_error.yaml diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/functional/__init__.py diff --git a/tests/yaml_schema_test.py b/tests/functional/yaml_schema_test.py index a975dca6..a975dca6 100644 --- a/tests/yaml_schema_test.py +++ b/tests/functional/yaml_schema_test.py diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/unit/__init__.py diff --git a/tests/unit/api/__init__.py b/tests/unit/api/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/unit/api/__init__.py diff --git a/tests/qtip_server_test.py b/tests/unit/api/qtip_server_test.py index 81bb302b..96544c95 100644 --- a/tests/qtip_server_test.py +++ b/tests/unit/api/qtip_server_test.py @@ -1,4 +1,4 @@ -import restful_server.qtip_server as server +import qtip.api.qtip_server as server import pytest import json import mock @@ -66,7 +66,7 @@ class TestClass: 'state_detail': [{u'state': u'finished', u'benchmark': u'dhrystone_vm.yaml'}], 'result': 0}) ]) - @mock.patch('restful_server.qtip_server.args_handler.prepare_and_run_benchmark') + @mock.patch('qtip.api.qtip_server.args_handler.prepare_and_run_benchmark') def test_post_get_delete_job_successful(self, mock_args_handler, app_client, body, expected): mock_args_handler.return_value = {'result': 0, 'detail': {'host': [(u'10.20.6.14', {'unreachable': 0, @@ -107,7 +107,7 @@ class TestClass: ['job_id', 'It already has one job running now!']) ]) - @mock.patch('restful_server.qtip_server.args_handler.prepare_and_run_benchmark', + @mock.patch('qtip.api.qtip_server.args_handler.prepare_and_run_benchmark', side_effect=[side_effect_sleep(0.5), side_effect_pass]) def test_post_two_jobs_unsuccessful(self, mock_args_hanler, app_client, body, expected): reply_1 = app_client.post("/api/v1.0/jobs", data=body[0]) diff --git a/tests/unit/cli/__init__.py b/tests/unit/cli/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/unit/cli/__init__.py diff --git a/tests/unit/runner/__init__.py b/tests/unit/runner/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/unit/runner/__init__.py diff --git a/tests/unit/runner/perftest_test.py b/tests/unit/runner/perftest_test.py new file mode 100644 index 00000000..798afadd --- /dev/null +++ b/tests/unit/runner/perftest_test.py @@ -0,0 +1,13 @@ +############################################################################## +# 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 +############################################################################## + + +class TestPerfTest: + def test_list(self): + assert True diff --git a/tests/unit/runner/suite_test.py b/tests/unit/runner/suite_test.py new file mode 100644 index 00000000..a2023cf8 --- /dev/null +++ b/tests/unit/runner/suite_test.py @@ -0,0 +1,13 @@ +############################################################################## +# 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 +############################################################################## + + +class TestSuite: + def test_list(self): + assert True diff --git a/tests/unit/runner/test_plan_test.py b/tests/unit/runner/test_plan_test.py new file mode 100644 index 00000000..81f618c7 --- /dev/null +++ b/tests/unit/runner/test_plan_test.py @@ -0,0 +1,13 @@ +############################################################################## +# 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 +############################################################################## + + +class TestTestPlan: + def test_list(self): + assert True diff --git a/tests/unit/utils/__init__.py b/tests/unit/utils/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/unit/utils/__init__.py diff --git a/tests/ansible_api_test.py b/tests/unit/utils/ansible_api_test.py index a259c422..6b1afb44 100644 --- a/tests/ansible_api_test.py +++ b/tests/unit/utils/ansible_api_test.py @@ -6,7 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -from utils.ansible_api import AnsibleApi +from qtip.utils.ansible_api import AnsibleApi class TestClass: diff --git a/tests/args_handler_test.py b/tests/unit/utils/args_handler_test.py index 625a42f5..b67fd993 100644 --- a/tests/args_handler_test.py +++ b/tests/unit/utils/args_handler_test.py @@ -8,28 +8,28 @@ ############################################################################## import pytest import mock -import utils.args_handler +import qtip.utils.args_handler class TestClass: @pytest.mark.parametrize("test_input, expected", [ - (['fuel', '/home', './test_plan/default/network/iperf_bm.yaml'], + (['fuel', '/home', 'benchmarks/test_plan/default/network/iperf_bm.yaml'], ['fuel', '/home', "iperf", [('1-server', ['10.20.0.23']), ('2-host', ['10.20.0.24'])], "iperf_bm.yaml", [('duration', 20), ('protocol', 'tcp'), ('bandwidthGbps', 10)], [("10.20.0.24", [None]), ("10.20.0.23", [None])], {}]) ]) - @mock.patch('utils.args_handler.Env_setup.call_ping_test') - @mock.patch('utils.args_handler.Env_setup.call_ssh_test') - @mock.patch('utils.args_handler.Env_setup.update_ansible') - @mock.patch('utils.args_handler.SpawnVM') - @mock.patch('utils.args_handler.Driver.drive_bench') + @mock.patch('qtip.utils.args_handler.Env_setup.call_ping_test') + @mock.patch('qtip.utils.args_handler.Env_setup.call_ssh_test') + @mock.patch('qtip.utils.args_handler.Env_setup.update_ansible') + @mock.patch('qtip.utils.args_handler.SpawnVM') + @mock.patch('qtip.utils.args_handler.Driver.drive_bench') def test_prepare_and_run_benchmark_successful(self, mock_driver, mock_sqawn_vm, mock_env_setup_ping, mock_env_setup_ssh, mock_update_ansible, test_input, expected): mock_ips = mock.Mock(return_value=["10.20.0.23", "10.20.0.24"]) - utils.args_handler.Env_setup.fetch_compute_ips = mock_ips - utils.args_handler.prepare_and_run_benchmark(test_input[0], test_input[1], test_input[2]) + qtip.utils.args_handler.Env_setup.fetch_compute_ips = mock_ips + qtip.utils.args_handler.prepare_and_run_benchmark(test_input[0], test_input[1], test_input[2]) call = mock_driver.call_args call_args, call_kwargs = call assert sorted(map(sorted, call_args)) == sorted(map(sorted, expected)) diff --git a/tests/cli_test.py b/tests/unit/utils/cli_test.py index 255c2a37..86dd6b98 100644 --- a/tests/cli_test.py +++ b/tests/unit/utils/cli_test.py @@ -1,7 +1,7 @@ import pytest import mock import os -from func.cli import Cli +from qtip.utils.cli import Cli from os.path import expanduser @@ -10,7 +10,7 @@ class TestClass: (['-l', 'zte', '-f', - 'compute'], "You have specified a lab that is not present under test_plan"), + 'compute'], "You have specified a lab that is not present under benchmarks/test_plan"), (['-l', 'default', '-f', @@ -30,10 +30,10 @@ class TestClass: (['-l', 'default', '-f', - 'storage'], [('fuel', '/home', './test_plan/default/storage/fio_bm.yaml'), - ('fuel', '/home', './test_plan/default/storage/fio_vm.yaml')]) + 'storage'], [('fuel', '/home', 'benchmarks/test_plan/default/storage/fio_bm.yaml'), + ('fuel', '/home', 'benchmarks/test_plan/default/storage/fio_vm.yaml')]) ]) - @mock.patch('func.cli.args_handler.prepare_and_run_benchmark') + @mock.patch('qtip.utils.cli.args_handler.prepare_and_run_benchmark') def test_cli_successful(self, mock_args_handler, test_input, expected): k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel', 'PWD': '/home'}) k.start() diff --git a/tests/create_zones_test.py b/tests/unit/utils/create_zones_test.py index 0f57581d..8b1e97cc 100644 --- a/tests/create_zones_test.py +++ b/tests/unit/utils/create_zones_test.py @@ -2,7 +2,7 @@ import pytest import mock from mock import Mock, MagicMock import os -from utils.create_zones import AvailabilityZone +from qtip.utils.create_zones import AvailabilityZone return_list = [] @@ -57,13 +57,13 @@ class TestClass: 'add_host:compute1:10.20.0.4', 'create:compute2:compute2', 'add_host:compute2:10.20.0.5']), - (['compute1', 'compute1'], + (['compute1'], ['create:compute1:compute1', 'add_host:compute1:10.20.0.4']), ]) - @mock.patch('utils.create_zones.client', autospec=True) - @mock.patch('utils.create_zones.v2', autospec=True) - @mock.patch('utils.create_zones.session') + @mock.patch('qtip.utils.create_zones.client', autospec=True) + @mock.patch('qtip.utils.create_zones.v2', autospec=True) + @mock.patch('qtip.utils.create_zones.session') def test_create_zones_success(self, mock_keystone_session, mock_keystone_v2, mock_nova_client, test_input, expected, capfd): nova_obj = NovaMock() mock_nova_client.Client.return_value = nova_obj() @@ -88,9 +88,9 @@ class TestClass: ([], []), ]) - @mock.patch('utils.create_zones.client', autospec=True) - @mock.patch('utils.create_zones.v2', autospec=True) - @mock.patch('utils.create_zones.session') + @mock.patch('qtip.utils.create_zones.client', autospec=True) + @mock.patch('qtip.utils.create_zones.v2', autospec=True) + @mock.patch('qtip.utils.create_zones.session') def test_clean_all_aggregates(self, mock_keystone_session, mock_keystone_v2, mock_nova_client, test_input, expected, capfd): global return_list return_list = test_input diff --git a/tests/driver_test.py b/tests/unit/utils/driver_test.py index d3025bd2..432ce1ae 100644 --- a/tests/driver_test.py +++ b/tests/unit/utils/driver_test.py @@ -1,6 +1,6 @@ import pytest import mock -from utils.driver import Driver +from qtip.utils.driver import Driver from os.path import expanduser HOME_DIR = expanduser('~') @@ -65,8 +65,8 @@ class TestClass: 'bandwidthGbps': 0, "role": "2-host"}]) ]) - @mock.patch('utils.driver.AnsibleApi.execute_playbook') - @mock.patch('utils.driver.AnsibleApi.get_detail_playbook_stats') + @mock.patch('qtip.utils.driver.AnsibleApi.execute_playbook') + @mock.patch('qtip.utils.driver.AnsibleApi.get_detail_playbook_stats') def test_driver_success(self, mock_stats, mock_ansible, test_input, expected): mock_ansible.return_value = True mock_stats.return_value = [(u'10.20.6.14', {'unreachable': 0, diff --git a/tests/env_setup_test.py b/tests/unit/utils/env_setup_test.py index 07f426e1..e28c6a18 100644 --- a/tests/env_setup_test.py +++ b/tests/unit/utils/env_setup_test.py @@ -9,7 +9,7 @@ import pytest import filecmp -from utils.env_setup import Env_setup +from qtip.utils.env_setup import Env_setup import mock diff --git a/tests/spawn_vm_test.py b/tests/unit/utils/spawn_vm_test.py index c0d87cac..ba237378 100644 --- a/tests/spawn_vm_test.py +++ b/tests/unit/utils/spawn_vm_test.py @@ -2,7 +2,7 @@ import pytest import mock from mock import Mock, MagicMock import os -from utils.spawn_vm import SpawnVM +from qtip.utils.spawn_vm import SpawnVM class KeystoneMock(MagicMock): @@ -40,10 +40,10 @@ class TestClass: 'role': ['1-server', '2-host']}, [('172.10.0.154', '')]), ]) - @mock.patch('utils.spawn_vm.Env_setup') - @mock.patch('utils.spawn_vm.AvailabilityZone') - @mock.patch('utils.spawn_vm.keystoneclient.v2_0', autospec=True) - @mock.patch('utils.spawn_vm.heatclient.client', autospec=True) + @mock.patch('qtip.utils.spawn_vm.Env_setup') + @mock.patch('qtip.utils.spawn_vm.AvailabilityZone') + @mock.patch('qtip.utils.spawn_vm.keystoneclient.v2_0', autospec=True) + @mock.patch('qtip.utils.spawn_vm.heatclient.client', autospec=True) def test_create_zones_success(self, mock_heat, mock_keystone, mock_zone, mock_setup, test_input, expected): open('./config/QtipKey.pub', 'a').close() @@ -10,17 +10,19 @@ skipsdist = True [testenv] usedevelop = True install_command = pip install -U {opts} {packages} -deps = +deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands= py.test \ --basetemp={envtmpdir} \ - {posargs} tests + {posargs} +setenv= + PYTHONPATH = {toxinidir} [testenv:pep8] deps = flake8 -commands = flake8 {toxinidir} +commands = flake8 {toxinidir} [flake8] # H803 skipped on purpose per list discussion. |