Skip to content

Commit f38b053

Browse files
test
1 parent 823cf4f commit f38b053

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

source/s3_auto_ranged_get.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ static bool s_s3_auto_ranged_get_update(
252252
AWS_S3_REQUEST_TYPE_GET_OBJECT,
253253
1 /*part_number*/,
254254
AWS_S3_REQUEST_FLAG_RECORD_RESPONSE_HEADERS |
255-
AWS_S3_REQUEST_FLAG_ALLOCATE_BUFFER_FROM_POOL |
256-
AWS_S3_REQUEST_FLAG_RESPONSE_ALLOCATED_FROM_POOL);
255+
AWS_S3_REQUEST_FLAG_ALLOCATE_BUFFER_FROM_POOL |
256+
AWS_S3_REQUEST_FLAG_RESPONSE_ALLOCATED_FROM_POOL);
257257
++auto_ranged_get->synced_data.num_parts_requested;
258258

259259
break;
@@ -294,8 +294,8 @@ static bool s_s3_auto_ranged_get_update(
294294
AWS_S3_REQUEST_TYPE_GET_OBJECT,
295295
1 /*part_number*/,
296296
AWS_S3_REQUEST_FLAG_RECORD_RESPONSE_HEADERS |
297-
AWS_S3_REQUEST_FLAG_ALLOCATE_BUFFER_FROM_POOL |
298-
AWS_S3_REQUEST_FLAG_RESPONSE_ALLOCATED_FROM_POOL);
297+
AWS_S3_REQUEST_FLAG_ALLOCATE_BUFFER_FROM_POOL |
298+
AWS_S3_REQUEST_FLAG_RESPONSE_ALLOCATED_FROM_POOL);
299299
request->part_range_start = part_range_start;
300300
request->part_range_end = part_range_start + first_part_size - 1; /* range-end is inclusive */
301301
++auto_ranged_get->synced_data.num_parts_requested;

source/s3_meta_request.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,15 +1428,16 @@ static int s_s3_meta_request_incoming_body(
14281428
}
14291429

14301430
if (request->send_data.response_body.capacity == 0) {
1431-
if (/*request->has_buffer_ticket_for_response &&*/ request->ticket != NULL) {
1431+
if (request->has_buffer_ticket_for_response && request->ticket != NULL) {
14321432
request->send_data.response_body = aws_s3_buffer_ticket_claim(request->ticket);
14331433
} else {
14341434
size_t buffer_size = s_dynamic_body_initial_buf_size;
14351435
aws_byte_buf_init(&request->send_data.response_body, meta_request->allocator, buffer_size);
14361436
}
14371437
}
14381438

1439-
AWS_FATAL_ASSERT(request->send_data.response_body.len == 0);
1439+
/* Sanity checking that we somehow haven't reused the same buffer for both upload and download*/
1440+
AWS_FATAL_ASSERT(request->send_data.response_body.buffer != request->request_body.buffer);
14401441

14411442
/* Note: not having part sized response body means the buffer is dynamic and
14421443
* can grow. */
@@ -2370,8 +2371,8 @@ struct aws_s3_meta_request_poll_write_result aws_s3_meta_request_poll_write(
23702371

23712372
struct aws_future_s3_buffer_ticket *buffered_ticket_future;
23722373
/* NOTE: we acquire a forced-buffer because there's a risk of deadlock if we
2373-
* waited for a normal ticket reservation, respecting the pool's memory limit.
2374-
* (See "test_s3_many_async_uploads_without_data" for description of deadlock scenario) */
2374+
* waited for a normal ticket reservation, respecting the pool's memory limit.
2375+
* (See "test_s3_many_async_uploads_without_data" for description of deadlock scenario) */
23752376

23762377
struct aws_s3_buffer_pool_reserve_meta meta = {
23772378
.size = meta_request->part_size,
@@ -2394,7 +2395,6 @@ struct aws_s3_meta_request_poll_write_result aws_s3_meta_request_poll_write(
23942395

23952396
meta_request->synced_data.async_write.buffered_data =
23962397
aws_s3_buffer_ticket_claim(meta_request->synced_data.async_write.buffered_data_ticket);
2397-
23982398
}
23992399
} else {
24002400
AWS_LOGF_TRACE(
@@ -2404,7 +2404,7 @@ struct aws_s3_meta_request_poll_write_result aws_s3_meta_request_poll_write(
24042404
illegal_usage_terminate_meta_request = true;
24052405
aws_future_s3_buffer_ticket_release(buffered_ticket_future);
24062406
}
2407-
}
2407+
}
24082408

24092409
if (!illegal_usage_terminate_meta_request) {
24102410
/* Copy as much data as we can into the buffer */

tests/s3_mock_server_tests.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,20 @@ TEST_CASE(multipart_upload_checksum_with_retry_mock_server) {
466466
.mock_server = true,
467467
};
468468

469-
ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(&tester, &put_options, NULL));
469+
struct aws_s3_meta_request_test_results meta_request_test_results;
470+
aws_s3_meta_request_test_results_init(&meta_request_test_results, allocator);
471+
472+
ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(&tester, &put_options, &meta_request_test_results));
473+
474+
ASSERT_INT_EQUALS(meta_request_test_results.upload_review.part_count, 2);
475+
/* Note: the data we currently generate is always the same,
476+
* so make sure that retry does not mangle the data by checking the checksum value */
477+
ASSERT_STR_EQUALS("7/xUXw==", aws_string_c_str(meta_request_test_results.upload_review.part_checksums_array[0]));
478+
ASSERT_STR_EQUALS("PCOjcw==", aws_string_c_str(meta_request_test_results.upload_review.part_checksums_array[1]));
470479

471480
aws_s3_client_release(client);
472481
aws_s3_tester_clean_up(&tester);
482+
aws_s3_meta_request_test_results_clean_up(&meta_request_test_results);
473483

474484
return AWS_OP_SUCCESS;
475485
}

0 commit comments

Comments
 (0)