From 02a4c82dfab53bba48313b11b4eb0db80c11eae5 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Wed, 13 Jul 2011 13:52:54 -0700 Subject: [PATCH] Make generate_objects.py and rand_readwrite.py inside the package. Handle dependencies properly. Now e.g. "./bootstrap && ./virtualenv/bin/s3tests-test-readwrite" should just work. --- .gitignore | 1 + bootstrap | 24 +++++++++++++++ requirements.txt | 2 ++ common.py => s3tests/common.py | 0 .../generate_objects.py | 10 +++---- .../rand_readwrite.py | 3 -- realistic.py => s3tests/realistic.py | 0 setup.py | 29 +++++++++++++++++++ 8 files changed, 61 insertions(+), 8 deletions(-) rename common.py => s3tests/common.py (100%) rename generate_objects.py => s3tests/generate_objects.py (97%) mode change 100755 => 100644 rename rand_readwrite.py => s3tests/rand_readwrite.py (99%) mode change 100755 => 100644 rename realistic.py => s3tests/realistic.py (100%) create mode 100644 setup.py 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', + ], + }, + + )