Skip to content

Commit

Permalink
Add error message test on S3 access decline (#5825)
Browse files Browse the repository at this point in the history
* Add test on access decline

* Fix typo

* Add MinIO S3 access decline test

* Make sure bucket exists during access decline test
  • Loading branch information
kthui authored May 22, 2023
1 parent 43a27a3 commit 9ed44ae
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
32 changes: 31 additions & 1 deletion qa/L0_storage_S3/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ aws configure set default.region $AWS_DEFAULT_REGION && \
# Copy models into S3 bucket
aws s3 cp tmp_cred_test_models/ "${BUCKET_URL_SLASH}" --recursive --include "*"

SERVER_ARGS="--model-repository=$ROOT_REPO --exit-timeout-secs=120"
SERVER_ARGS="--model-repository=$BUCKET_URL --exit-timeout-secs=120"

run_server
if [ "$SERVER_PID" == "0" ]; then
Expand Down Expand Up @@ -386,6 +386,36 @@ set -e
kill $SERVER_PID
wait $SERVER_PID

# Test access decline
export AWS_SECRET_ACCESS_KEY="[Invalid]" && export AWS_SESSION_TOKEN=""
SERVER_ARGS="--model-repository=$BUCKET_URL --exit-timeout-secs=120"
run_server
if [ "$SERVER_PID" != "0" ]; then
echo -e "\n***\n*** Unexpected server start $SERVER\n***"
cat $SERVER_LOG
kill $SERVER_PID
wait $SERVER_PID
RET=1
else
# AWS S3 does not appear to reply on access decline, but other implementations
# might provide extra messages, so make sure Triton will print the messages.
EXPECTED_MSG="Unable to create S3 filesystem client. Check account credentials. Exception: '' Message: 'No response body.'"
if ! grep "$EXPECTED_MSG" $SERVER_LOG; then
echo -e "\n***\n*** Expected error message not found\n***"
cat $SERVER_LOG
RET=1
fi
fi

# Restore S3 credentials
rm ~/.aws/credentials && rm ~/.aws/config
export AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION_BACKUP
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID_BACKUP
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY_BACKUP
aws configure set default.region $AWS_DEFAULT_REGION && \
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY

# Clean up bucket contents and delete bucket
aws s3 rm "${BUCKET_URL_SLASH}" --recursive --include "*"
aws s3 rb "${BUCKET_URL}"
Expand Down
22 changes: 22 additions & 0 deletions qa/L0_storage_S3_local/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,28 @@ set -e
kill $SERVER_PID
wait $SERVER_PID

# Test access decline
export AWS_SECRET_ACCESS_KEY="[Invalid]"
SERVER_ARGS="--model-repository=s3://localhost:4572/${BUCKET_NAME}1 --exit-timeout-secs=120"
SERVER_LOG="./inference_server.access_decline.log"
run_server
if [ "$SERVER_PID" != "0" ]; then
echo -e "\n***\n*** Unexpected server start $SERVER\n***"
cat $SERVER_LOG
kill $SERVER_PID
wait $SERVER_PID
RET=1
else
# MinIO does not appear to reply on access decline, but other implementations
# might provide extra messages, so make sure Triton will print the messages.
EXPECTED_MSG="Unable to create S3 filesystem client. Check account credentials. Exception: '' Message: 'No response body.'"
if ! grep "$EXPECTED_MSG" $SERVER_LOG; then
echo -e "\n***\n*** Expected error message not found\n***"
cat $SERVER_LOG
RET=1
fi
fi

# Destroy buckets
for BUCKET_SUFFIX in 1 2; do
awslocal $ENDPOINT_FLAG s3 rm s3://$BUCKET_NAME$BUCKET_SUFFIX --recursive --include "*" && \
Expand Down

0 comments on commit 9ed44ae

Please sign in to comment.