From 9dd8f8c5717dfdec417c2ca38fff7efb6aaadcc1 Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Wed, 3 Dec 2025 10:15:09 -0800 Subject: [PATCH 1/2] regression test --- source/s3_meta_request.c | 1 + tests/CMakeLists.txt | 1 + tests/s3_data_plane_tests.c | 51 +++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/source/s3_meta_request.c b/source/s3_meta_request.c index 486975f5..524b997f 100644 --- a/source/s3_meta_request.c +++ b/source/s3_meta_request.c @@ -1426,6 +1426,7 @@ static int s_s3_meta_request_incoming_headers( if (request->part_range_end != object_range_end) { /* In the case where the object size is less than the range requested. It must be return the * last part to the end of the object. */ + AWS_FATAL_ASSERT(object_range_start + object_size - 1 == object_range_end); if (object_size != object_range_end + 1 || request->part_range_end < object_range_end) { /* Something went wrong if it's matching. Log the error. */ AWS_LOGF_ERROR( diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cee3cb5e..c6e72935 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -234,6 +234,7 @@ add_net_test_case(test_s3_auto_ranged_get_sending_user_agent) add_net_test_case(test_s3_auto_ranged_put_sending_user_agent) add_net_test_case(test_s3_default_sending_meta_request_user_agent) add_net_test_case(test_s3_range_requests) +add_net_test_case(test_s3_range_requests_less_than_a_part) add_net_test_case(test_s3_not_satisfiable_range) add_net_test_case(test_s3_invalid_start_range_greator_than_end_range) add_net_test_case(test_s3_empty_file_edge_case) diff --git a/tests/s3_data_plane_tests.c b/tests/s3_data_plane_tests.c index ade775cc..f0143a61 100644 --- a/tests/s3_data_plane_tests.c +++ b/tests/s3_data_plane_tests.c @@ -6937,6 +6937,9 @@ static int s_test_s3_range_requests(struct aws_allocator *allocator, void *ctx) // Last 8K AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("bytes=-8192"), + + // 1MiB - 8K to the end. + AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("bytes=1040384-"), }; /* List of headers that should have matching values between the auto_ranged_get and default (which sends the HTTP @@ -7130,6 +7133,54 @@ static int s_test_s3_range_requests(struct aws_allocator *allocator, void *ctx) return 0; } +/* Using the range to fetch the object that has less than 1 part. */ +AWS_TEST_CASE(test_s3_range_requests_less_than_a_part, s_test_s3_range_requests_less_than_a_part) +static int s_test_s3_range_requests_less_than_a_part(struct aws_allocator *allocator, void *ctx) { + (void)ctx; + + struct aws_s3_tester tester; + ASSERT_SUCCESS(aws_s3_tester_init(allocator, &tester)); + + struct aws_s3_tester_client_options client_options = { + .part_size = MB_TO_BYTES(1), // Use 1 MiB as the part. + }; + + struct aws_s3_client *client = NULL; + ASSERT_SUCCESS(aws_s3_tester_client_new(&tester, &client_options, &client)); + const struct aws_byte_cursor ranges[] = { + // 0.5 MB - 2 MB range. This overlaps and goes beyond the 1 MB test file size. + AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("bytes=524288-2097151"), + + // Get everything after the first 0.5 MB + AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("bytes=524288-"), + }; + const size_t num_ranges = AWS_ARRAY_SIZE(ranges); + + for (size_t range_index = 0; range_index < num_ranges; ++range_index) { + struct aws_s3_tester_meta_request_options options = { + .allocator = allocator, + .client = client, + .meta_request_type = AWS_S3_META_REQUEST_TYPE_GET_OBJECT, + .validate_type = AWS_S3_TESTER_VALIDATE_TYPE_EXPECT_SUCCESS, + .get_options = + { + .object_path = g_pre_existing_object_1MB, + .object_range = ranges[range_index], + }, + }; + struct aws_s3_meta_request_test_results results; + aws_s3_meta_request_test_results_init(&results, allocator); + + ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(&tester, &options, &results)); + aws_s3_meta_request_test_results_clean_up(&results); + } + + aws_s3_client_release(client); + aws_s3_tester_clean_up(&tester); + + return 0; +} + AWS_TEST_CASE(test_s3_not_satisfiable_range, s_test_s3_not_satisfiable_range) static int s_test_s3_not_satisfiable_range(struct aws_allocator *allocator, void *ctx) { (void)ctx; From bcb0d1d046767c9dca25b492fb7b2fbedda85ee3 Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Wed, 3 Dec 2025 10:24:31 -0800 Subject: [PATCH 2/2] removing the wrong fatal assert fixed it. --- source/s3_meta_request.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/s3_meta_request.c b/source/s3_meta_request.c index 524b997f..486975f5 100644 --- a/source/s3_meta_request.c +++ b/source/s3_meta_request.c @@ -1426,7 +1426,6 @@ static int s_s3_meta_request_incoming_headers( if (request->part_range_end != object_range_end) { /* In the case where the object size is less than the range requested. It must be return the * last part to the end of the object. */ - AWS_FATAL_ASSERT(object_range_start + object_size - 1 == object_range_end); if (object_size != object_range_end + 1 || request->part_range_end < object_range_end) { /* Something went wrong if it's matching. Log the error. */ AWS_LOGF_ERROR(