Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test for object modified #247

Merged
merged 4 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
24 changes: 8 additions & 16 deletions source/s3_meta_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ void aws_s3_meta_request_set_fail_synced(

meta_request->synced_data.finish_result_set = true;

if ((error_code == AWS_ERROR_S3_INVALID_RESPONSE_STATUS ||
error_code == AWS_ERROR_S3_NON_RECOVERABLE_ASYNC_ERROR) &&
if ((error_code == AWS_ERROR_S3_INVALID_RESPONSE_STATUS || error_code == AWS_ERROR_S3_NON_RECOVERABLE_ASYNC_ERROR ||
error_code == AWS_ERROR_S3_OBJECT_MODIFIED) &&
failed_request != NULL) {
aws_s3_meta_request_result_setup(
meta_request,
Expand Down Expand Up @@ -413,19 +413,18 @@ static void s_s3_meta_request_destroy(void *user_data) {
aws_priority_queue_clean_up(&meta_request->synced_data.pending_body_streaming_requests);
aws_s3_meta_request_result_clean_up(meta_request, &meta_request->synced_data.finish_result);

AWS_LOGF_DEBUG(
AWS_LOGF_TRACE(
AWS_LS_S3_META_REQUEST, "id=%p Calling virtual meta request destroy function.", (void *)meta_request);

meta_request->vtable->destroy(meta_request);
meta_request = NULL;

AWS_LOGF_DEBUG(AWS_LS_S3_META_REQUEST, "id=%p Calling meta request shutdown callback.", (void *)meta_request);

if (shutdown_callback != NULL) {
AWS_LOGF_TRACE(AWS_LS_S3_META_REQUEST, "id=%p Calling meta request shutdown callback.", (void *)meta_request);
shutdown_callback(meta_request_user_data);
}

AWS_LOGF_DEBUG(AWS_LS_S3_META_REQUEST, "id=%p Meta request clean up finished.", (void *)meta_request);
AWS_LOGF_TRACE(AWS_LS_S3_META_REQUEST, "id=%p Meta request clean up finished.", (void *)meta_request);
}

static int s_s3_request_priority_queue_pred(const void *a, const void *b) {
Expand Down Expand Up @@ -676,7 +675,7 @@ void aws_s3_meta_request_sign_request_default(

request->send_data.signable = aws_signable_new_http_request(meta_request->allocator, request->send_data.message);

AWS_LOGF_DEBUG(
AWS_LOGF_TRACE(
AWS_LS_S3_META_REQUEST,
"id=%p Created signable %p for request %p with message %p",
(void *)meta_request,
Expand Down Expand Up @@ -803,7 +802,7 @@ void aws_s3_meta_request_send_request(struct aws_s3_meta_request *meta_request,
goto error_finish;
}

AWS_LOGF_DEBUG(AWS_LS_S3_META_REQUEST, "id=%p: Sending request %p", (void *)meta_request, (void *)request);
AWS_LOGF_TRACE(AWS_LS_S3_META_REQUEST, "id=%p: Sending request %p", (void *)meta_request, (void *)request);

if (aws_http_stream_activate(stream) != AWS_OP_SUCCESS) {
aws_http_stream_release(stream);
Expand Down Expand Up @@ -944,13 +943,6 @@ static int s_s3_meta_request_incoming_headers(
struct aws_s3_meta_request *meta_request = request->meta_request;
AWS_PRECONDITION(meta_request);

AWS_LOGF_DEBUG(
AWS_LS_S3_META_REQUEST,
"id=%p Incoming headers for request %p on connection %p.",
(void *)meta_request,
(void *)request,
(void *)connection);

if (aws_http_stream_get_incoming_response_status(stream, &request->send_data.response_status)) {
AWS_LOGF_ERROR(
AWS_LS_S3_META_REQUEST,
Expand Down Expand Up @@ -1002,7 +994,7 @@ static int s_s3_meta_request_incoming_body(
AWS_PRECONDITION(meta_request);
AWS_PRECONDITION(meta_request->vtable);

AWS_LOGF_DEBUG(
AWS_LOGF_TRACE(
AWS_LS_S3_META_REQUEST,
"id=%p Incoming body for request %p. Response status: %d. Data Size: %" PRIu64 ". connection: %p.",
(void *)meta_request,
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ if (ENABLE_MOCK_SERVER_TESTS)
add_net_test_case(multipart_upload_mock_server)
add_net_test_case(async_internal_error_from_complete_multipart_mock_server)
add_net_test_case(async_access_denied_from_complete_multipart_mock_server)
add_net_test_case(get_object_modified_mock_server)
endif()

set(TEST_BINARY_NAME ${PROJECT_NAME}-tests)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"status": 400,
"headers": {},
"body": [
"bad_request"
]
}
14 changes: 14 additions & 0 deletions tests/mock_s3_server/GetObject/get_object_modified_first_part.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"status": 206,
"headers": {
"ETag": "b54357faf0632cce46e942fa68356b38",
"Date": "Thu, 12 Jan 2023 00:04:21 GMT",
"Last-Modified": "Tue, 10 Jan 2023 23:39:32 GMT",
"Accept-Ranges": "bytes",
"Content-Range": "bytes 0-65535/1048576",
"Content-Type": "binary/octet-stream"
},
"body": [
"<data-to-send>"
]
}
10 changes: 10 additions & 0 deletions tests/mock_s3_server/GetObject/get_object_modified_success.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"status": 412,
"headers": {
"Date": "Thu, 12 Jan 2023 00:04:21 GMT",
"Last-Modified": "Tue, 10 Jan 2023 23:39:32 GMT"
},
"body": [
"precondition failed"
]
}
Loading