diff --git a/.gitignore b/.gitignore index 2b930f3..af45817 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ *.pyc *.pyo +/*.egg-info /virtualenv config.yml diff --git a/bootstrap b/bootstrap index cd3d81a..3ad528f 100755 --- a/bootstrap +++ b/bootstrap @@ -1,4 +1,28 @@ #!/bin/sh set -e + +for package in python-pip python-virtualenv python-dev libevent-dev; do + if [ "$(dpkg --status -- $package|sed -n 's/^Status: //p')" != "install ok installed" ]; then + # add a space after old values + missing="${missing:+$missing }$package" + fi +done +if [ -n "$missing" ]; then + echo "$0: missing required packages, please install them:" 1>&2 + echo "sudo apt-get install $missing" + exit 1 +fi + virtualenv --no-site-packages --distribute virtualenv + +# avoid pip bugs +./virtualenv/bin/pip install --upgrade pip + ./virtualenv/bin/pip install -r requirements.txt + +# forbid setuptools from using the network because it'll try to use +# easy_install, and we really wanted pip; next line will fail if pip +# requirements.txt does not match setup.py requirements -- sucky but +# good enough for now +./virtualenv/bin/python setup.py develop \ + --allow-hosts None diff --git a/requirements.txt b/requirements.txt index 75d18c2..f9cb448 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,5 @@ PyYAML nose >=1.0.0 boto >=2.0b4 bunch >=1.0.0 +# 0.14 switches to libev, that means bootstrap needs to change too +gevent ==0.13.6 diff --git a/common.py b/s3tests/common.py similarity index 100% rename from common.py rename to s3tests/common.py diff --git a/generate_objects.py b/s3tests/generate_objects.py old mode 100755 new mode 100644 similarity index 97% rename from generate_objects.py rename to s3tests/generate_objects.py index 23b370f..b3c0b65 --- a/generate_objects.py +++ b/s3tests/generate_objects.py @@ -2,10 +2,10 @@ from boto.s3.key import Key from optparse import OptionParser -import realistic +from . import realistic import traceback import random -import common +from . import common import sys @@ -54,7 +54,7 @@ def upload_objects(bucket, files, seed): return keys -def main(): +def _main(): '''To run the static content load test, make sure you've bootstrapped your test environment and set up your config.yml file, then run the following: S3TEST_CONF=config.yml virtualenv/bin/python generate_objects.py -O urls.txt --seed 1234 @@ -106,10 +106,10 @@ def main(): print >> sys.stderr, 'done' -if __name__ == '__main__': +def main(): common.setup() try: - main() + _main() except Exception as e: traceback.print_exc() common.teardown() diff --git a/rand_readwrite.py b/s3tests/rand_readwrite.py old mode 100755 new mode 100644 similarity index 99% rename from rand_readwrite.py rename to s3tests/rand_readwrite.py index 1c4d0d3..d22cc23 --- a/rand_readwrite.py +++ b/s3tests/rand_readwrite.py @@ -194,6 +194,3 @@ def main(): # cleanup if options.cleanup: common.teardown() - -if __name__ == "__main__": - main() diff --git a/realistic.py b/s3tests/realistic.py similarity index 100% rename from realistic.py rename to s3tests/realistic.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..de01ab6 --- /dev/null +++ b/setup.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +from setuptools import setup, find_packages + +setup( + name='s3tests', + version='0.0.1', + packages=find_packages(), + + author='Tommi Virtanen', + author_email='tommi.virtanen@dreamhost.com', + description='Unofficial Amazon AWS S3 compatibility tests', + license='MIT', + keywords='s3 web testing', + + install_requires=[ + 'boto >=2.0b4', + 'PyYAML', + 'bunch >=1.0.0', + 'gevent ==0.13.6', + ], + + entry_points={ + 'console_scripts': [ + 's3tests-generate-objects = s3tests.generate_objects:main', + 's3tests-test-readwrite = s3tests.rand_readwrite:main', + ], + }, + + )