Skip to content

Commit

Permalink
make endpoint url configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke McCrone authored and Luke McCrone committed Jan 26, 2024
1 parent f6a3fe4 commit 0816bf5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion tests/.env.default
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ AWS_REGION=us-west-2
AWS_PROFILE=versity
VERSITY_EXE=./versitygw
BACKEND=posix
LOCAL_FOLDER=/tmp/gw
LOCAL_FOLDER=/tmp/gw
AWS_ENDPOINT_URL=http://127.0.0.1:7070
3 changes: 2 additions & 1 deletion tests/.env.versitygw
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ AWS_REGION=us-east-1
AWS_PROFILE=versity
VERSITY_EXE=./versitygw
BACKEND=posix
LOCAL_FOLDER=/tmp/gw
LOCAL_FOLDER=/tmp/gw
AWS_ENDPOINT_URL=http://127.0.0.1:7070
16 changes: 8 additions & 8 deletions tests/s3_bucket_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ create_bucket() {
fi
local exit_code=0
local error
error=$(aws --endpoint-url http://127.0.0.1:7070 s3 mb s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code=$?
error=$(aws --endpoint-url "$AWS_ENDPOINT_URL" s3 mb s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "error creating bucket: $error"
return 1
Expand All @@ -24,7 +24,7 @@ delete_bucket() {
fi
local exit_code=0
local error
error=$(aws --endpoint-url http://127.0.0.1:7070 s3 rb s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code="$?"
error=$(aws --endpoint-url "$AWS_ENDPOINT_URL" s3 rb s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code="$?"
if [ $exit_code -ne 0 ]; then
if [[ "$error" == *"The specified bucket does not exist"* ]]; then
return 0
Expand All @@ -44,7 +44,7 @@ bucket_exists() {
fi
local exit_code=0
local error
error=$(aws --endpoint-url http://127.0.0.1:7070 s3 ls s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code="$?"
error=$(aws --endpoint-url "$AWS_ENDPOINT_URL" s3 ls s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code="$?"
if [ $exit_code -ne 0 ]; then
if [[ "$error" == *"The specified bucket does not exist"* ]] || [[ "$error" == *"Access Denied"* ]]; then
return 1
Expand Down Expand Up @@ -86,7 +86,7 @@ object_exists() {
fi
local exit_code=0
local error
error=$(aws --endpoint-url http://127.0.0.1:7070 s3 ls s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code="$?"
error=$(aws --endpoint-url "$AWS_ENDPOINT_URL" s3 ls s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code="$?"
if [ $exit_code -ne 0 ]; then
if [[ "$error" == "" ]]; then
return 1
Expand All @@ -105,7 +105,7 @@ put_object() {
fi
local exit_code=0
local error
error=$(aws --endpoint-url http://127.0.0.1:7070 s3 cp "$1" s3://"$2" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code=$?
error=$(aws --endpoint-url "$AWS_ENDPOINT_URL" s3 cp "$1" s3://"$2" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "error copying object to bucket: $error"
return 1
Expand Down Expand Up @@ -140,7 +140,7 @@ delete_object() {
fi
local exit_code=0
local error
error=$(aws --endpoint-url http://127.0.0.1:7070 s3 rm s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code=$?
error=$(aws --endpoint-url "$AWS_ENDPOINT_URL" s3 rm s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "error deleting object: $error"
return 1
Expand All @@ -151,7 +151,7 @@ delete_object() {
list_buckets() {
local exit_code=0
local output
output=$(aws --endpoint-url http://127.0.0.1:7070 s3 ls --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code=$?
output=$(aws --endpoint-url "$AWS_ENDPOINT_URL" s3 ls --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "error listing buckets: $output"
return 1
Expand All @@ -173,7 +173,7 @@ list_objects() {
fi
local exit_code=0
local output
output=$(aws --endpoint-url http://127.0.0.1:7070 s3 ls s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code=$?
output=$(aws --endpoint-url "$AWS_ENDPOINT_URL" s3 ls s3://"$1" --region "$AWS_REGION" --profile "$AWS_PROFILE" 2>&1) || exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "error listing objects: $output"
return 1
Expand Down
3 changes: 3 additions & 0 deletions tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ setup() {
elif [ -z "$LOCAL_FOLDER" ]; then
echo "No local storage folder set"
return 1
elif [ -z "$AWS_ENDPOINT_URL" ]; then
echo "No AWS endpoint URL set"
return 1
fi
ROOT_ACCESS_KEY="$AWS_ACCESS_KEY_ID" ROOT_SECRET_KEY="$AWS_SECRET_ACCESS_KEY" "$VERSITY_EXE" "$BACKEND" "$LOCAL_FOLDER" &
versitygw_pid=$!
Expand Down

0 comments on commit 0816bf5

Please sign in to comment.