Skip to content

Commit 25ca7a5

Browse files
authored
regression test for wrong assertion (#605)
1 parent 3f81fc9 commit 25ca7a5

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ add_net_test_case(test_s3_auto_ranged_get_sending_user_agent)
234234
add_net_test_case(test_s3_auto_ranged_put_sending_user_agent)
235235
add_net_test_case(test_s3_default_sending_meta_request_user_agent)
236236
add_net_test_case(test_s3_range_requests)
237+
add_net_test_case(test_s3_range_requests_less_than_a_part)
237238
add_net_test_case(test_s3_not_satisfiable_range)
238239
add_net_test_case(test_s3_invalid_start_range_greator_than_end_range)
239240
add_net_test_case(test_s3_empty_file_edge_case)

tests/s3_data_plane_tests.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6937,6 +6937,9 @@ static int s_test_s3_range_requests(struct aws_allocator *allocator, void *ctx)
69376937

69386938
// Last 8K
69396939
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("bytes=-8192"),
6940+
6941+
// 1MiB - 8K to the end.
6942+
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("bytes=1040384-"),
69406943
};
69416944

69426945
/* 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)
71307133
return 0;
71317134
}
71327135

7136+
/* Using the range to fetch the object that has less than 1 part. */
7137+
AWS_TEST_CASE(test_s3_range_requests_less_than_a_part, s_test_s3_range_requests_less_than_a_part)
7138+
static int s_test_s3_range_requests_less_than_a_part(struct aws_allocator *allocator, void *ctx) {
7139+
(void)ctx;
7140+
7141+
struct aws_s3_tester tester;
7142+
ASSERT_SUCCESS(aws_s3_tester_init(allocator, &tester));
7143+
7144+
struct aws_s3_tester_client_options client_options = {
7145+
.part_size = MB_TO_BYTES(1), // Use 1 MiB as the part.
7146+
};
7147+
7148+
struct aws_s3_client *client = NULL;
7149+
ASSERT_SUCCESS(aws_s3_tester_client_new(&tester, &client_options, &client));
7150+
const struct aws_byte_cursor ranges[] = {
7151+
// 0.5 MB - 2 MB range. This overlaps and goes beyond the 1 MB test file size.
7152+
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("bytes=524288-2097151"),
7153+
7154+
// Get everything after the first 0.5 MB
7155+
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("bytes=524288-"),
7156+
};
7157+
const size_t num_ranges = AWS_ARRAY_SIZE(ranges);
7158+
7159+
for (size_t range_index = 0; range_index < num_ranges; ++range_index) {
7160+
struct aws_s3_tester_meta_request_options options = {
7161+
.allocator = allocator,
7162+
.client = client,
7163+
.meta_request_type = AWS_S3_META_REQUEST_TYPE_GET_OBJECT,
7164+
.validate_type = AWS_S3_TESTER_VALIDATE_TYPE_EXPECT_SUCCESS,
7165+
.get_options =
7166+
{
7167+
.object_path = g_pre_existing_object_1MB,
7168+
.object_range = ranges[range_index],
7169+
},
7170+
};
7171+
struct aws_s3_meta_request_test_results results;
7172+
aws_s3_meta_request_test_results_init(&results, allocator);
7173+
7174+
ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(&tester, &options, &results));
7175+
aws_s3_meta_request_test_results_clean_up(&results);
7176+
}
7177+
7178+
aws_s3_client_release(client);
7179+
aws_s3_tester_clean_up(&tester);
7180+
7181+
return 0;
7182+
}
7183+
71337184
AWS_TEST_CASE(test_s3_not_satisfiable_range, s_test_s3_not_satisfiable_range)
71347185
static int s_test_s3_not_satisfiable_range(struct aws_allocator *allocator, void *ctx) {
71357186
(void)ctx;

0 commit comments

Comments
 (0)