Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
51 changes: 51 additions & 0 deletions tests/s3_data_plane_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down