Skip to content

Commit

Permalink
Merge pull request #392 from basho/feature/bch/tox
Browse files Browse the repository at this point in the history
CLIENTS-115: Use pyenv for multiple Python versions and tox to test them

Reviewed-by: christophermancini
  • Loading branch information
borshop committed Jan 21, 2015
2 parents c9a4771 + ede2838 commit 2810cea
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 4 deletions.
16 changes: 12 additions & 4 deletions buildbot/Makefile
Expand Up @@ -11,7 +11,6 @@ configure:
@../setup.py configure --riak-admin=${RIAK_ADMIN}

compile:
-@yes y | pip uninstall riak-pb protobuf pyOpenSSL
@../setup.py develop

lint:
Expand All @@ -21,14 +20,23 @@ lint:
@openssl verify -CAfile ${CERTS_DIR}/ca.crt ${CERTS_DIR}/client.crt
@openssl verify -CAfile ${CERTS_DIR}/ca.crt ${CERTS_DIR}/server.crt

test: test_normal test_security
test: setup test_normal test_security

test_normal:
@echo "Testing Riak Python Client (without security)"
@../setup.py disable_security --riak-admin=${RIAK_ADMIN}
@RUN_YZ=1 SKIP_DATATYPES=0 SKIP_INDEXES=0 ../setup.py test
@RUN_YZ=1 SKIP_DATATYPES=0 SKIP_INDEXES=0 ./tox_runner.sh ..

test_security:
@echo "Testing Riak Python Client (with security)"
@../setup.py enable_security --riak-admin=${RIAK_ADMIN}
(cd ..; RUN_YZ=1 SKIP_INDEXES=0 RUN_SECURITY=1 SKIP_POOL=1 SKIP_RESOLVE=1 RIAK_TEST_HTTP_PORT=18098 ./setup.py test)
@RUN_YZ=1 SKIP_INDEXES=0 RUN_SECURITY=1 SKIP_POOL=1 SKIP_RESOLVE=1 RIAK_TEST_HTTP_PORT=18098 ./tox_runner.sh ..

# These are required to actually build all the Python versions:
# * pip install tox
# * pyenv - https://github.com/yyuu/pyenv
# And two pyenv plugins:
# * pyenv virtualenv - https://github.com/yyuu/pyenv-virtualenv
# * pyenv alias - https://github.com/s1341/pyenv-alias
setup:
./tox_setup.sh
17 changes: 17 additions & 0 deletions buildbot/tox_runner.sh
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# pyenv root
export PYENV_ROOT="$HOME/.pyenv"

# Add pyenv root to PATH
# and initialize pyenv
PATH="$PYENV_ROOT/bin:$PATH"
# initialize pyenv
eval "$(pyenv init -)"
# initialize pyenv virtualenv
eval "$(pyenv virtualenv-init -)"

# Change directory if an argument is passed in
if [[ ! -z "$1" ]]; then
cd "$1"
fi
tox
46 changes: 46 additions & 0 deletions buildbot/tox_setup.sh
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# pyenv root
export PYENV_ROOT="$HOME/.pyenv"

# Install pyenv if it's missing
if [[ ! -d $PYENV_ROOT ]]; then
git clone git://github.com/yyuu/pyenv.git ${PYENV_ROOT}
cd ${PYENV_ROOT}
# Get the latest tagged version
git checkout `git tag | tail -1`
git clone https://github.com/yyuu/pyenv-virtualenv.git ${PYENV_ROOT}/plugins/pyenv-virtualenv
cd plugins/pyenv-virtualenv
git checkout `git tag | tail -1`
git clone https://github.com/s1341/pyenv-alias.git ${PYENV_ROOT}/plugins/pyenv-alias

# Add pyenv root to PATH
# and initialize pyenv
PATH="$PYENV_ROOT/bin:$PATH"
# initialize pyenv
eval "$(pyenv init -)"
# initialize pyenv virtualenv
eval "$(pyenv virtualenv-init -)"

# Now load up (allthethings)
VERSION_ALIAS="riak_2.6.9" pyenv install 2.6.9
VERSION_ALIAS="riak_2.7.9" pyenv install 2.7.9
VERSION_ALIAS="riak_3.3.6" pyenv install 3.3.6
VERSION_ALIAS="riak_3.4.2" pyenv install 3.4.2

pyenv virtualenv riak_2.6.9 riak-py26
pyenv virtualenv riak_2.7.9 riak-py27
pyenv virtualenv riak_3.3.6 riak-py33
pyenv virtualenv riak_3.4.2 riak-py34
pyenv global riak-py26 riak-py27 riak-py33 riak-py34
pyenv versions
fi

# Now install tox
if [ -z "`pip show tox`" ]; then
pip install tox
if [ -z "`pip show tox`" ]; then
echo "ERROR: Install of tox failed"
exit 1
fi
pyenv rehash
fi
3 changes: 3 additions & 0 deletions commands.py
Expand Up @@ -421,6 +421,9 @@ def _update_riak_conf(self):
r'listener.protobuf.internal = ' + pb_host,
conf)
conf += 'check_crl = off\n'
# Older versions of OpenSSL client library need to match on the server
conf += 'tls_protocols.tlsv1 = on\n'
conf += 'tls_protocols.tlsv1.1 = on\n'
f = open(self.riak_conf, 'w', buffering=1)
f.write(conf)
f.close()
Expand Down
11 changes: 11 additions & 0 deletions tox.ini
@@ -0,0 +1,11 @@
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py26, py27, py33, py34

[testenv]
commands = {envpython} setup.py test
deps = six

0 comments on commit 2810cea

Please sign in to comment.