From 0816bf579bd4da1d33340e7dd208c10ee0df9897 Mon Sep 17 00:00:00 2001 From: Luke McCrone Date: Fri, 26 Jan 2024 13:53:26 -0300 Subject: [PATCH] make endpoint url configurable --- tests/.env.default | 3 ++- tests/.env.versitygw | 3 ++- tests/s3_bucket_tests.sh | 16 ++++++++-------- tests/tests.sh | 3 +++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/.env.default b/tests/.env.default index 6adb2c671..cdf12fb05 100644 --- a/tests/.env.default +++ b/tests/.env.default @@ -2,4 +2,5 @@ AWS_REGION=us-west-2 AWS_PROFILE=versity VERSITY_EXE=./versitygw BACKEND=posix -LOCAL_FOLDER=/tmp/gw \ No newline at end of file +LOCAL_FOLDER=/tmp/gw +AWS_ENDPOINT_URL=http://127.0.0.1:7070 \ No newline at end of file diff --git a/tests/.env.versitygw b/tests/.env.versitygw index 132927b66..a11be2396 100644 --- a/tests/.env.versitygw +++ b/tests/.env.versitygw @@ -2,4 +2,5 @@ AWS_REGION=us-east-1 AWS_PROFILE=versity VERSITY_EXE=./versitygw BACKEND=posix -LOCAL_FOLDER=/tmp/gw \ No newline at end of file +LOCAL_FOLDER=/tmp/gw +AWS_ENDPOINT_URL=http://127.0.0.1:7070 \ No newline at end of file diff --git a/tests/s3_bucket_tests.sh b/tests/s3_bucket_tests.sh index 52ca2be45..6801dec80 100755 --- a/tests/s3_bucket_tests.sh +++ b/tests/s3_bucket_tests.sh @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/tests/tests.sh b/tests/tests.sh index bfe73235d..1da2bd489 100644 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -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=$!