spin up rethinkdb in docker, run tests in there

This commit is contained in:
Noah Levitt 2015-09-22 20:57:00 +00:00
parent 69d641cd50
commit 28d213fb18
2 changed files with 43 additions and 0 deletions

21
tests/Dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM phusion/baseimage
MAINTAINER Noah Levitt <nlevitt@archive.org>
# see https://github.com/stuartpb/rethinkdb-dockerfiles/blob/master/trusty/2.1.3/Dockerfile
ENV LANG=C.UTF-8
RUN apt-get update && apt-get --auto-remove -y dist-upgrade
# Add the RethinkDB repository and public key
# "RethinkDB Packaging <packaging@rethinkdb.com>" http://download.rethinkdb.com/apt/pubkey.gpg
RUN apt-key adv --keyserver pgp.mit.edu --recv-keys 1614552E5765227AEC39EFCFA7E00EF33A8F2399 \
&& echo "deb http://download.rethinkdb.com/apt trusty main" > /etc/apt/sources.list.d/rethinkdb.list \
&& apt-get update && apt-get -y install rethinkdb
RUN mkdir -vp /etc/service/rethinkdb \
&& echo "#!/bin/sh\nrethinkdb --bind 0.0.0.0 --directory /tmp/rethink-data --runuser rethinkdb --rungroup rethinkdb\n" > /etc/service/rethinkdb/run \
&& chmod a+x /etc/service/rethinkdb/run
RUN apt-get -y install python-virtualenv git
RUN apt-get -y install python-gdbm python3-gdbm libpython2.7-dev libpython3.4-dev libffi-dev libssl-dev

22
tests/run-tests.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
docker build -t internetarchive/rethinkdb $script_dir || exit 1
uid=$(id -u)
user=$(id -un)
for python in python2.7 python3.4
do
docker run --rm -i -t --volume="$script_dir/..:/warcprox" internetarchive/rethinkdb /sbin/my_init -- \
bash -x -c "adduser --gecos=$user --disabled-password --quiet --uid=$uid $user \
&& sudo -u $user bash -x -c 'cd /warcprox \
&& virtualenv -p $python /tmp/venv \
&& source /tmp/venv/bin/activate \
&& pip --log-file /tmp/pip.log install -r requirements.txt . pytest requests \
&& py.test tests \
&& py.test --rethinkdb-servers=localhost tests \
&& py.test --rethinkdb-servers=localhost --rethinkdb-big-table tests'"
done