From 074c36baab6c796254717add2f5237a9586bdd6b Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Thu, 22 Jan 2015 16:25:49 -0800 Subject: [PATCH] Add test harness to execute s3-tests Also add Travis configuration. --- .travis.yml | 4 +++ src/test/resources/run-s3-tests.sh | 41 ++++++++++++++++++++++++++++++ src/test/resources/s3-tests.conf | 40 +++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100755 src/test/resources/run-s3-tests.sh create mode 100644 src/test/resources/s3-tests.conf diff --git a/.travis.yml b/.travis.yml index dff5f3a..9ceec99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,5 @@ language: java +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq python-pip python-virtualenv libevent-dev +after_script: src/test/resources/run-s3-tests.sh diff --git a/src/test/resources/run-s3-tests.sh b/src/test/resources/run-s3-tests.sh new file mode 100755 index 0000000..fd705dc --- /dev/null +++ b/src/test/resources/run-s3-tests.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +set -o errexit +set -o nounset + +S3PROXY_BIN="${PWD}/target/s3proxy" +S3PROXY_PORT="8081" +export S3TEST_CONF="${PWD}/src/test/resources/s3-tests.conf" + +# configure s3-tests +pushd s3-tests +./bootstrap +popd + +# launch S3Proxy using HTTP and a fixed port +sed "s,^\(s3proxy.endpoint\)=.*,\1=http://127.0.0.1:${S3PROXY_PORT}," \ + < src/test/resources/s3proxy.conf > target/s3proxy.conf +$S3PROXY_BIN --properties target/s3proxy.conf & +S3PROXY_PID=$! + +# wait for S3Proxy to start +for i in $(seq 30); +do + if exec 3<>"/dev/tcp/localhost/${S3PROXY_PORT}"; + then + exec 3<&- # Close for read + exec 3>&- # Close for write + break + fi + sleep 1 +done + +# execute s3-tests +pushd s3-tests +./virtualenv/bin/nosetests -a '!fails_on_s3proxy' +EXIT_CODE=$? +popd + +# clean up and return s3-tests exit code +kill $S3PROXY_PID +exit $EXIT_CODE diff --git a/src/test/resources/s3-tests.conf b/src/test/resources/s3-tests.conf new file mode 100644 index 0000000..973ac3e --- /dev/null +++ b/src/test/resources/s3-tests.conf @@ -0,0 +1,40 @@ +[DEFAULT] +## this section is just used as default for all the "s3 *" +## sections, you can place these variables also directly there + +## replace with e.g. "localhost" to run against local software +host = 127.0.0.1 + +## uncomment the port to use something other than 80 +port = 8081 + +## say "no" to disable TLS +is_secure = no + +[fixtures] +## all the buckets created will start with this prefix; +## {random} will be filled with random characters to pad +## the prefix to 30 characters long, and avoid collisions +bucket prefix = s3proxy-{random}- + +[s3 main] +## the tests assume two accounts are defined, "main" and "alt". + +## user_id is a 64-character hexstring +user_id = 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef + +## display name typically looks more like a unix login, "jdoe" etc +display_name = youruseridhere + +## replace these with your access keys +access_key = local-identity +secret_key = local-credential + +[s3 alt] +## another user account, used for ACL-related tests +user_id = 56789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01234 +display_name = john.doe +## the "alt" user needs to have email set, too +email = john.doe@example.com +access_key = local-identity +secret_key = local-credential