Merge pull request #132 from andrewgaul/s3proxy-integration-test

Use S3Proxy to run integration tests
This commit is contained in:
Takeshi Nakatani 2015-02-27 00:17:46 +09:00
commit 53083202ba
5 changed files with 60 additions and 3 deletions

View File

@ -114,6 +114,7 @@ static bool is_s3fs_uid = false;// default does not set.
static bool is_s3fs_gid = false;// default does not set. static bool is_s3fs_gid = false;// default does not set.
static bool is_s3fs_umask = false;// default does not set. static bool is_s3fs_umask = false;// default does not set.
static bool is_remove_cache = false; static bool is_remove_cache = false;
static bool create_bucket = false;
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Static functions : prototype // Static functions : prototype
@ -782,6 +783,16 @@ static int s3fs_readlink(const char* path, char* buf, size_t size)
return 0; return 0;
} }
static int do_create_bucket(void)
{
FPRNNN("/");
headers_t meta;
S3fsCurl s3fscurl(true);
return s3fscurl.PutRequest("/", meta, -1); // fd=-1 means for creating zero byte object.
}
// common function for creation of a plain object // common function for creation of a plain object
static int create_file_object(const char* path, mode_t mode, uid_t uid, gid_t gid) static int create_file_object(const char* path, mode_t mode, uid_t uid, gid_t gid)
{ {
@ -2682,6 +2693,10 @@ static void* s3fs_init(struct fuse_conn_info* conn)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (create_bucket){
do_create_bucket();
}
// Check Bucket // Check Bucket
// If the network is up, check for valid credentials and if the bucket // If the network is up, check for valid credentials and if the bucket
// exists. skip check if mounting a public bucket // exists. skip check if mounting a public bucket
@ -3862,6 +3877,10 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
S3fsCurl::SetSignatureV4(false); S3fsCurl::SetSignatureV4(false);
return 0; return 0;
} }
if(0 == strcmp(arg, "createbucket")){
create_bucket = true;
return 0;
}
if(0 == STR2NCMP(arg, "endpoint=")){ if(0 == STR2NCMP(arg, "endpoint=")){
endpoint = strchr(arg, '=') + sizeof(char); endpoint = strchr(arg, '=') + sizeof(char);
is_specified_endpoint = true; is_specified_endpoint = true;

View File

@ -2,9 +2,9 @@
S3FS=../src/s3fs S3FS=../src/s3fs
S3FS_CREDENTIALS_FILE=$(eval echo ~${SUDO_USER}/.passwd-s3fs) S3FS_CREDENTIALS_FILE="passwd-s3fs"
TEST_BUCKET_1=${SUDO_USER}-s3fs-integration-test TEST_BUCKET_1="s3fs-integration-test"
TEST_BUCKET_MOUNT_POINT_1=${TEST_BUCKET_1} TEST_BUCKET_MOUNT_POINT_1=${TEST_BUCKET_1}
if [ ! -f "$S3FS_CREDENTIALS_FILE" ] if [ ! -f "$S3FS_CREDENTIALS_FILE" ]
@ -12,3 +12,9 @@ then
echo "Missing credentials file: $S3FS_CREDENTIALS_FILE" echo "Missing credentials file: $S3FS_CREDENTIALS_FILE"
exit 1 exit 1
fi fi
S3PROXY_VERSION="1.3.0"
S3PROXY_BINARY="s3proxy-${S3PROXY_VERSION}-jar-with-dependencies.jar"
if [ ! -e "${S3PROXY_BINARY}" ]; then
wget "http://repo1.maven.org/maven2/org/gaul/s3proxy/${S3PROXY_VERSION}/${S3PROXY_BINARY}"
fi

1
test/passwd-s3fs Normal file
View File

@ -0,0 +1 @@
local-identity:local-credential

8
test/s3proxy.conf Normal file
View File

@ -0,0 +1,8 @@
s3proxy.endpoint=http://127.0.0.1:8080
s3proxy.authorization=aws-v2
s3proxy.identity=local-identity
s3proxy.credential=local-credential
jclouds.provider=transient
jclouds.identity=remote-identity
jclouds.credential=remote-credential

View File

@ -3,16 +3,39 @@
# Require root # Require root
REQUIRE_ROOT=require-root.sh REQUIRE_ROOT=require-root.sh
#source $REQUIRE_ROOT #source $REQUIRE_ROOT
source integration-test-common.sh
java -jar "$S3PROXY_BINARY" --properties s3proxy.conf &
S3PROXY_PID="$?"
# wait for S3Proxy to start
for i in $(seq 30);
do
if exec 3<>"/dev/tcp/localhost/8080";
then
exec 3<&- # Close for read
exec 3>&- # Close for write
break
fi
sleep 1
done
# Mount the bucket # Mount the bucket
if [ ! -d $TEST_BUCKET_MOUNT_POINT_1 ] if [ ! -d $TEST_BUCKET_MOUNT_POINT_1 ]
then then
mkdir -p $TEST_BUCKET_MOUNT_POINT_1 mkdir -p $TEST_BUCKET_MOUNT_POINT_1
fi fi
$S3FS $TEST_BUCKET_1 $TEST_BUCKET_MOUNT_POINT_1 -o passwd_file=$S3FS_CREDENTIALS_FILE $S3FS $TEST_BUCKET_1 $TEST_BUCKET_MOUNT_POINT_1 \
-o createbucket \
-o passwd_file=$S3FS_CREDENTIALS_FILE \
-o sigv2 \
-o url=http://127.0.0.1:8080 \
-o use_path_request_style
./integration-test-main.sh $TEST_BUCKET_MOUNT_POINT_1 ./integration-test-main.sh $TEST_BUCKET_MOUNT_POINT_1
umount $TEST_BUCKET_MOUNT_POINT_1 umount $TEST_BUCKET_MOUNT_POINT_1
kill $S3PROXY_PID
echo "All tests complete." echo "All tests complete."