From b4fbb8c5019ff3e47966b88459310382ac40538c Mon Sep 17 00:00:00 2001 From: Soumava Bera Date: Thu, 9 Jan 2025 16:30:25 -0500 Subject: [PATCH 1/3] test --- crt/aws-crt-cpp | 2 +- .../BucketAndObjectOperationTest.cpp | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/crt/aws-crt-cpp b/crt/aws-crt-cpp index b5577fa39c3..281a7caff7e 160000 --- a/crt/aws-crt-cpp +++ b/crt/aws-crt-cpp @@ -1 +1 @@ -Subproject commit b5577fa39c3a11f09c06db10ac6eaaca3910cbe2 +Subproject commit 281a7caff7e10f68a5422d8fca8acf0b48e4215f diff --git a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp index 3665ec3c8e5..5db65a24b4b 100644 --- a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp +++ b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp @@ -2580,4 +2580,58 @@ namespace AWS_EXPECT_SUCCESS(headOutcome); EXPECT_EQ(headOutcome.GetResult().GetContentEncoding(), "gzip"); } + + +void DownloadFile(const Aws::String& bucket_name, const Aws::String& object_key, const Aws::String& destination_file) +{ + Aws::S3::S3Client s3_client; + auto Limiter = Aws::MakeShared>(ALLOCATION_TAG, 50000000); + + ClientConfiguration config; + config.region = Aws::Region::US_EAST_1; + //config.scheme = Scheme::HTTPS; + config.connectTimeoutMs = 30000; + config.requestTimeoutMs = 30000; + config.readRateLimiter = Limiter; + config.writeRateLimiter = Limiter; + config.executor = Aws::MakeShared(ALLOCATION_TAG, 4); + config.enableHttpClientTrace = true; + + // Open the destination file for writing + std::ofstream output_file(destination_file.c_str(), std::ios::binary); + + if (!output_file) { + std::cerr << "Failed to open destination file." << std::endl; + return; + } + + // Create a GetObjectRequest with the byte range + Aws::S3::Model::GetObjectRequest get_object_request; + get_object_request.SetBucket(bucket_name); + get_object_request.SetKey(object_key); + auto start = std::chrono::high_resolution_clock::now(); + auto get_object_outcome = s3_client.GetObject(get_object_request); + auto stop = std::chrono::high_resolution_clock::now(); + auto duration = std::chrono::duration_cast(stop - start); + + if (get_object_outcome.IsSuccess()) { + // Write the part to the destination file + auto& retrieved_file = get_object_outcome.GetResultWithOwnership().GetBody(); + std::ofstream output_file(destination_file, std::ios::binary); + output_file << retrieved_file.rdbuf(); // Write the stream content to the file + std::cout << "File downloaded to " << destination_file << std::endl; + + } else { + std::cerr << "Failed to download file: " << get_object_outcome.GetError().GetMessage() << std::endl; + } + + std::cout<<"took "< Date: Thu, 9 Jan 2025 20:08:12 -0500 Subject: [PATCH 2/3] test --- .../source/http/curl/CurlHttpClient.cpp | 1 + .../BucketAndObjectOperationTest.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp b/src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp index abd0361945d..c9875f7e846 100644 --- a/src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp +++ b/src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp @@ -953,6 +953,7 @@ std::shared_ptr CurlHttpClient::MakeRequest(const std::shared_ptr< response->SetClientErrorMessage(ss.str()); AWS_LOGSTREAM_ERROR(CURL_HTTP_CLIENT_TAG, ss.str()); } + std::cout<<"curl transmission time="<<(DateTime::Now() - startTransmissionTime).count()<AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::RequestLatency), (DateTime::Now() - startTransmissionTime).count()); } diff --git a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp index 5db65a24b4b..56cc3685805 100644 --- a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp +++ b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp @@ -2584,12 +2584,11 @@ namespace void DownloadFile(const Aws::String& bucket_name, const Aws::String& object_key, const Aws::String& destination_file) { - Aws::S3::S3Client s3_client; auto Limiter = Aws::MakeShared>(ALLOCATION_TAG, 50000000); ClientConfiguration config; - config.region = Aws::Region::US_EAST_1; - //config.scheme = Scheme::HTTPS; + config.region = Aws::Region::US_WEST_2; + config.scheme = Scheme::HTTPS; config.connectTimeoutMs = 30000; config.requestTimeoutMs = 30000; config.readRateLimiter = Limiter; @@ -2597,6 +2596,9 @@ void DownloadFile(const Aws::String& bucket_name, const Aws::String& object_key, config.executor = Aws::MakeShared(ALLOCATION_TAG, 4); config.enableHttpClientTrace = true; + Aws::S3::S3Client s3_client(config); + + // Open the destination file for writing std::ofstream output_file(destination_file.c_str(), std::ios::binary); @@ -2629,9 +2631,12 @@ void DownloadFile(const Aws::String& bucket_name, const Aws::String& object_key, } TEST_F(BucketAndObjectOperationTest, MeasureTier) { - DownloadFile("cpp-sdk-bucket-intelligent-tier", "sample_test_file.txt", "sample_test_file_intelligent.txt"); + for(int i = 0; i < 10; i++) + { + DownloadFile("cpp-sdk-bucket-intelligent-tier", "sample_test_file.txt", "sample_test_file_intelligent.txt"); - DownloadFile("cpp-sdk-bucket-standard-tier", "sample_test_file.txt", "sample_test_file_standard.txt"); + DownloadFile("cpp-sdk-bucket-standard-tier", "sample_test_file.txt", "sample_test_file_standard.txt"); + } } } From c6a937be0671d050d69dad8053690077a02d8185 Mon Sep 17 00:00:00 2001 From: Soumava Bera Date: Fri, 10 Jan 2025 14:17:35 -0500 Subject: [PATCH 3/3] test --- .../BucketAndObjectOperationTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp index 56cc3685805..c0e2267dc54 100644 --- a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp +++ b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp @@ -2631,7 +2631,7 @@ void DownloadFile(const Aws::String& bucket_name, const Aws::String& object_key, } TEST_F(BucketAndObjectOperationTest, MeasureTier) { - for(int i = 0; i < 10; i++) + for(int i = 0; i < 20; i++) { DownloadFile("cpp-sdk-bucket-intelligent-tier", "sample_test_file.txt", "sample_test_file_intelligent.txt");