Skip to content

Commit 2d3982f

Browse files
add presigned range GET test (#1447)
1 parent adb2409 commit 2d3982f

File tree

2 files changed

+67
-27
lines changed

2 files changed

+67
-27
lines changed

run_functional_tests.sh

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,35 @@
1616
#
1717

1818
function run_minio_server() {
19-
if [ ! -f tests/functional/minio ]; then
20-
wget --quiet --output-document tests/functional/minio https://dl.min.io/server/minio/release/linux-amd64/minio
21-
chmod +x tests/functional/minio
22-
fi
19+
if [ ! -f tests/functional/minio ]; then
20+
wget --quiet --output-document tests/functional/minio https://dl.min.io/server/minio/release/linux-amd64/minio
21+
chmod +x tests/functional/minio
22+
fi
2323

24-
export MINIO_ACCESS_KEY=minio
25-
export MINIO_SECRET_KEY=minio123
26-
export MINIO_KMS_KES_ENDPOINT=https://play.min.io:7373
27-
export MINIO_KMS_KES_KEY_FILE=tests/functional/play.min.io.kes.root.key
28-
export MINIO_KMS_KES_CERT_FILE=tests/functional/play.min.io.kes.root.cert
29-
export MINIO_KMS_KES_KEY_NAME=my-minio-key
30-
export MINIO_NOTIFY_WEBHOOK_ENABLE_miniopytest=on
31-
export MINIO_NOTIFY_WEBHOOK_ENDPOINT_miniopytest=http://example.org/
32-
export SQS_ARN="arn:minio:sqs::miniopytest:webhook"
33-
export MINIO_CI_CD=1
34-
tests/functional/minio server --config-dir tests/functional/.cfg tests/functional/.d{1...4} >tests/functional/minio.log 2>&1 &
24+
export MINIO_KMS_KES_ENDPOINT=https://play.min.io:7373
25+
export MINIO_KMS_KES_KEY_FILE=tests/functional/play.min.io.kes.root.key
26+
export MINIO_KMS_KES_CERT_FILE=tests/functional/play.min.io.kes.root.cert
27+
export MINIO_KMS_KES_KEY_NAME=my-minio-key
28+
export MINIO_NOTIFY_WEBHOOK_ENABLE_miniopytest=on
29+
export MINIO_NOTIFY_WEBHOOK_ENDPOINT_miniopytest=http://example.org/
30+
export SQS_ARN="arn:minio:sqs::miniopytest:webhook"
31+
export MINIO_CI_CD=1
32+
tests/functional/minio server --config-dir tests/functional/.cfg tests/functional/.d{1...4} >tests/functional/minio.log 2>&1 &
3533
}
3634

3735
if [ -z ${SERVER_ENDPOINT+x} ]; then
38-
run_minio_server
39-
MINIO_PID=$!
40-
trap 'kill -9 ${MINIO_PID} 2>/dev/null' INT
36+
run_minio_server
37+
MINIO_PID=$!
38+
trap 'kill -9 ${MINIO_PID} 2>/dev/null' INT
4139

42-
export MINT_MODE=full
43-
export SERVER_ENDPOINT=localhost:9000
44-
export ACCESS_KEY=minio
45-
export SECRET_KEY=minio123
46-
export ENABLE_HTTPS=0
40+
export MINT_MODE=full
41+
export SERVER_ENDPOINT=localhost:9000
42+
export ACCESS_KEY=minioadmin
43+
export SECRET_KEY=minioadmin
44+
export ENABLE_HTTPS=0
4745
fi
4846

4947
PYTHONPATH=$PWD python tests/functional/tests.py
5048
if [ -n "$MINIO_PID" ]; then
51-
kill -9 "$MINIO_PID" 2>/dev/null
49+
kill -9 "$MINIO_PID" 2>/dev/null
5250
fi

tests/functional/tests.py

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,9 +1379,6 @@ def test_presigned_get_object_response_headers( # pylint: disable=invalid-name
13791379
size = 1 * KB
13801380
_CLIENT.put_object(bucket_name, object_name, LimitedRandomReader(size),
13811381
size)
1382-
presigned_get_object_url = _CLIENT.presigned_get_object(
1383-
bucket_name, object_name, timedelta(seconds=120))
1384-
13851382
response_headers = {
13861383
'response-content-type': content_type,
13871384
'response-content-language': content_language
@@ -1418,6 +1415,51 @@ def test_presigned_get_object_response_headers( # pylint: disable=invalid-name
14181415
_CLIENT.remove_bucket(bucket_name)
14191416

14201417

1418+
def test_presigned_get_object_range( # pylint: disable=invalid-name
1419+
log_entry):
1420+
"""Test presigned_get_object() with headers."""
1421+
1422+
# Get a unique bucket_name and object_name
1423+
bucket_name = _gen_bucket_name()
1424+
object_name = f"{uuid4()}"
1425+
1426+
log_entry["args"] = {
1427+
"bucket_name": bucket_name,
1428+
"object_name": object_name,
1429+
}
1430+
1431+
_CLIENT.make_bucket(bucket_name)
1432+
try:
1433+
size = 556433 # on purpose its unaligned
1434+
_CLIENT.put_object(bucket_name, object_name, LimitedRandomReader(size),
1435+
size)
1436+
1437+
presigned_get_object_url = _CLIENT.presigned_get_object(
1438+
bucket_name, object_name, timedelta(seconds=120))
1439+
1440+
log_entry["args"]["presigned_get_object_url"] = (
1441+
presigned_get_object_url)
1442+
1443+
response = HTTP.urlopen('GET', presigned_get_object_url,
1444+
headers={'Range': 'bytes=490897-556432'})
1445+
1446+
log_entry["args"]['response.status'] = response.status
1447+
log_entry["args"]['response.reason'] = response.reason
1448+
log_entry["args"]['response.headers'] = json.dumps(
1449+
response.headers.__dict__)
1450+
# pylint: disable=protected-access
1451+
log_entry["args"]['response._body'] = response._body.decode('utf-8')
1452+
1453+
if response.status != 200:
1454+
raise Exception(
1455+
"Presigned GET object URL {presigned_get_object_url} failed; "
1456+
"code: {response.code}, error: {response.data}"
1457+
)
1458+
finally:
1459+
_CLIENT.remove_object(bucket_name, object_name)
1460+
_CLIENT.remove_bucket(bucket_name)
1461+
1462+
14211463
def test_presigned_get_object_version( # pylint: disable=invalid-name
14221464
log_entry):
14231465
"""Test presigned_get_object() of versioned object."""

0 commit comments

Comments
 (0)