From 64b976e139ecfeafa83889a9c6d6615d30ba5635 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Thu, 21 Nov 2013 17:59:47 +0100 Subject: [PATCH] Add plumbing. - Update .gitignore to ignore all testrunners. - Move swift-bench to swiftbench. - Move tests to tests/ - Add some simple {test-,}requirements (more works needs to be done to get proper versioning) Change-Id: Iab4d65f02cbce8c99ecafa30d15c4cb11f0b4293 --- .gitignore | 27 +++++----- .testr.conf | 4 ++ .unittests | 8 +++ README.rst | 1 + bin/swift-bench | 6 +-- requirements.txt | 2 + setup.cfg | 12 +++++ setup.py | 53 +++++++++++++++++++ swiftbench/__init__.py | 1 + {swift-bench => swiftbench}/bench.py | 0 test-requirements.txt | 8 +++ tests/__init__.py | 0 .../unit => tests}/test_bench.py | 0 tox.ini | 32 +++++++++++ 14 files changed, 139 insertions(+), 15 deletions(-) create mode 100644 .testr.conf create mode 100755 .unittests create mode 100644 README.rst create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 swiftbench/__init__.py rename {swift-bench => swiftbench}/bench.py (100%) create mode 100644 test-requirements.txt create mode 100644 tests/__init__.py rename {test-swift-bench/unit => tests}/test_bench.py (100%) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index ee73d89..d75f3fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,19 @@ -*.py[co] -*.sw? -*~ -doc/build/* -dist -build -cover +AUTHORS ChangeLog -.coverage +*.swp +dist/ +.tox *.egg *.egg-info +*.py[co] .DS_Store -.tox -pycscope.* -.idea -MANIFEST +*.log +.testrepository +subunit.log +build +swiftclient/versioninfo +.autogenerated +.coverage +cover/ +coverage.xml +doc/source/api/ diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..081907d --- /dev/null +++ b/.testr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_command=${PYTHON:-python} -m subunit.run discover -t ./ ./tests $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/.unittests b/.unittests new file mode 100755 index 0000000..bf5b027 --- /dev/null +++ b/.unittests @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +python setup.py testr --coverage +RET=$? +coverage report -m +rm -f .coverage +exit $RET diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..ed29499 --- /dev/null +++ b/README.rst @@ -0,0 +1 @@ +Swift Benchmarking tool. diff --git a/bin/swift-bench b/bin/swift-bench index ecdf5f5..d2c41d0 100755 --- a/bin/swift-bench +++ b/bin/swift-bench @@ -21,9 +21,9 @@ import signal import uuid from optparse import OptionParser -from swift.common.bench import (BenchController, DistributedBenchController, - create_containers, delete_containers) -from swift.common.utils import readconf, LogAdapter, config_true_value +from swiftbench.bench import (BenchController, DistributedBenchController, + create_containers, delete_containers) +from swiftbench.utils import readconf, LogAdapter, config_true_value # The defaults should be sufficient to run swift-bench on a SAIO CONF_DEFAULTS = { diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ad5af74 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +python-swiftclient +eventlet>=0.9.15 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..fa7e27d --- /dev/null +++ b/setup.cfg @@ -0,0 +1,12 @@ +[egg_info] +tag_build = +tag_date = 0 +tag_svn_revision = 0 + +[nosetests] +exe = 1 +verbosity = 2 +detailed-errors = 1 +cover-package = swiftbench +cover-html = true +cover-erase = true diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..345ea38 --- /dev/null +++ b/setup.py @@ -0,0 +1,53 @@ +#!/usr/bin/python +# Copyright (c) 2010-2012 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from setuptools import setup, find_packages + +from swiftbench import __version__ as version + + +name = 'swift-bench' + +with open('requirements.txt', 'r') as f: + requires = [x.strip() for x in f if x.strip()] + + +setup( + name=name, + version=version, + description='Benchmark tool for OpenStack Swift', + license='Apache License (2.0)', + author='OpenStack', + author_email='openstack-dev@lists.openstack.org', + url='http://openstack.org', + packages=find_packages(exclude=['test', 'bin']), + test_suite='nose.collector', + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Environment :: No Input/Output (Daemon)', + 'Environment :: OpenStack', + ], + install_requires=requires, + scripts=[ + 'bin/swift-bench', + 'bin/swift-bench-client', + ], +) diff --git a/swiftbench/__init__.py b/swiftbench/__init__.py new file mode 100644 index 0000000..b203ff7 --- /dev/null +++ b/swiftbench/__init__.py @@ -0,0 +1 @@ +__version__ = '1.0-dev' diff --git a/swift-bench/bench.py b/swiftbench/bench.py similarity index 100% rename from swift-bench/bench.py rename to swiftbench/bench.py diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..e0b2483 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,8 @@ +hacking>=0.5.6,<0.8 + +coverage>=3.6 +discover +mock>=1.0 +sphinx>=1.1.2 +testrepository>=0.0.17 +testtools>=0.9.32 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test-swift-bench/unit/test_bench.py b/tests/test_bench.py similarity index 100% rename from test-swift-bench/unit/test_bench.py rename to tests/test_bench.py diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..dd97529 --- /dev/null +++ b/tox.ini @@ -0,0 +1,32 @@ +[tox] +envlist = py26,py27,py33,pypy,pep8 + +[testenv] +setenv = VIRTUAL_ENV={envdir} + LANG=en_US.UTF-8 + LANGUAGE=en_US:en + LC_ALL=C + +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = python setup.py testr --testr-args="{posargs}" + +[testenv:pep8] +commands = + flake8 + flake8 bin/swift-bench + flake8 bin/swift-bench-client + +[testenv:venv] +commands = {posargs} + +[testenv:cover] +commands = python setup.py testr --coverage + +[tox:jenkins] +downloadcache = ~/cache/pip + +[flake8] +ignore = H +show-source = True +exclude = .venv,.tox,dist,doc,test,*egg