Skip to content

Commit e29d64a

Browse files
committed
make sure we really get the first run without checksum
1 parent b1c8f33 commit e29d64a

File tree

1 file changed

+9
-35
lines changed

1 file changed

+9
-35
lines changed

tests/s3_mock_server_tests.c

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ TEST_CASE(multipart_upload_with_network_interface_names_mock_server) {
437437
/* Total hack to flip the bytes. */
438438
static void s_after_prepare_upload_part_finish(struct aws_s3_request *request, struct aws_http_message *message) {
439439
(void)message;
440-
if (request->num_times_prepared > 1) {
440+
if (request->num_times_prepared > 0) {
441441
/* mock that the body buffer was messed up in memory */
442442
request->request_body.buffer[1]++;
443443
}
@@ -458,6 +458,10 @@ static void s_after_prepare_upload_part_finish_retry_before_finish_sending(
458458
};
459459
aws_http_message_add_header(message, throttle_header);
460460
}
461+
if (request->num_times_prepared > 0) {
462+
/* mock that the body buffer was messed up in memory */
463+
request->request_body.buffer[1]++;
464+
}
461465
}
462466

463467
/**
@@ -503,42 +507,12 @@ TEST_CASE(multipart_upload_checksum_with_retry_before_finish_mock_server) {
503507

504508
ASSERT_INT_EQUALS(meta_request_test_results.upload_review.part_count, 2);
505509
/* Note: the data we currently generate is always the same,
506-
* so make sure that retry does not mangle the data by checking the checksum value */
510+
* The retry got the messed up data, while the first run never actually finish reading the bytes, so the messed
511+
* up data checksum got to be sent. */
507512
ASSERT_STR_EQUALS(
508-
"7/xUXw==", aws_string_c_str(meta_request_test_results.upload_review.part_checksums_array[0]));
513+
"dKYRxA==", aws_string_c_str(meta_request_test_results.upload_review.part_checksums_array[0]));
509514
ASSERT_STR_EQUALS(
510-
"PCOjcw==", aws_string_c_str(meta_request_test_results.upload_review.part_checksums_array[1]));
511-
aws_s3_meta_request_test_results_clean_up(&meta_request_test_results);
512-
}
513-
{
514-
/* 2. header checksum */
515-
struct aws_s3_tester_meta_request_options put_options = {
516-
.allocator = allocator,
517-
.meta_request_type = AWS_S3_META_REQUEST_TYPE_PUT_OBJECT,
518-
.client = client,
519-
.checksum_algorithm = AWS_SCA_CRC32,
520-
.checksum_via_header = true,
521-
.validate_get_response_checksum = false,
522-
.put_options =
523-
{
524-
.object_size_mb = 10,
525-
.object_path_override = object_path,
526-
},
527-
.mock_server = true,
528-
};
529-
530-
struct aws_s3_meta_request_test_results meta_request_test_results;
531-
aws_s3_meta_request_test_results_init(&meta_request_test_results, allocator);
532-
533-
ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(&tester, &put_options, &meta_request_test_results));
534-
535-
ASSERT_INT_EQUALS(meta_request_test_results.upload_review.part_count, 2);
536-
/* Note: the data we currently generate is always the same,
537-
* so make sure that retry does not mangle the data by checking the checksum value */
538-
ASSERT_STR_EQUALS(
539-
"7/xUXw==", aws_string_c_str(meta_request_test_results.upload_review.part_checksums_array[0]));
540-
ASSERT_STR_EQUALS(
541-
"PCOjcw==", aws_string_c_str(meta_request_test_results.upload_review.part_checksums_array[1]));
515+
"dxV2Sw==", aws_string_c_str(meta_request_test_results.upload_review.part_checksums_array[1]));
542516
aws_s3_meta_request_test_results_clean_up(&meta_request_test_results);
543517
}
544518
aws_s3_client_release(client);

0 commit comments

Comments
 (0)