From 9ed44ae20c10c292c50f06dd80fcd74fe9da8a98 Mon Sep 17 00:00:00 2001 From: Jacky <18255193+kthui@users.noreply.github.com> Date: Mon, 22 May 2023 16:00:18 -0700 Subject: [PATCH] Add error message test on S3 access decline (#5825) * Add test on access decline * Fix typo * Add MinIO S3 access decline test * Make sure bucket exists during access decline test --- qa/L0_storage_S3/test.sh | 32 +++++++++++++++++++++++++++++++- qa/L0_storage_S3_local/test.sh | 22 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/qa/L0_storage_S3/test.sh b/qa/L0_storage_S3/test.sh index 49484c7204..f3ce96cd1d 100755 --- a/qa/L0_storage_S3/test.sh +++ b/qa/L0_storage_S3/test.sh @@ -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 @@ -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}" diff --git a/qa/L0_storage_S3_local/test.sh b/qa/L0_storage_S3_local/test.sh index 906700718d..5ab79f15ee 100755 --- a/qa/L0_storage_S3_local/test.sh +++ b/qa/L0_storage_S3_local/test.sh @@ -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 "*" && \