From 5b28ff37e69ef003b30bc10c9961d6fcc3e9589c Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Wed, 24 Jul 2024 14:17:44 +0000 Subject: [PATCH] Cleanup integration test configuration --- .../tests/async_client_integration_test.cc | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/google/cloud/storage/tests/async_client_integration_test.cc b/google/cloud/storage/tests/async_client_integration_test.cc index 8021b931ea12c..17c5d4b79fbbb 100644 --- a/google/cloud/storage/tests/async_client_integration_test.cc +++ b/google/cloud/storage/tests/async_client_integration_test.cc @@ -17,6 +17,7 @@ #include "google/cloud/storage/async/bucket_name.h" #include "google/cloud/storage/async/client.h" #include "google/cloud/storage/async/idempotency_policy.h" +#include "google/cloud/storage/grpc_plugin.h" #include "google/cloud/storage/testing/storage_integration_test.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/is_proto_equal.h" @@ -68,15 +69,19 @@ class AsyncClientIntegrationTest std::string bucket_name_; }; +auto TestOptions() { + // Disable metrics in the test, they just make the logs harder to grok. + return Options{}.set(false); +} + auto AlwaysRetry() { - return Options{}.set( + return TestOptions().set( MakeAlwaysRetryIdempotencyPolicy); } TEST_F(AsyncClientIntegrationTest, ObjectCRUD) { - auto client = MakeIntegrationTestClient(); + auto async = AsyncClient(TestOptions()); auto object_name = MakeRandomObjectName(); - auto async = AsyncClient(); auto insert = async .InsertObject(BucketName(bucket_name()), object_name, @@ -123,16 +128,16 @@ TEST_F(AsyncClientIntegrationTest, ObjectCRUD) { .get(); EXPECT_STATUS_OK(status); + auto client = MakeIntegrationTestClient(); auto get = client.GetObjectMetadata(bucket_name(), object_name); EXPECT_THAT(get, StatusIs(StatusCode::kNotFound)); } TEST_F(AsyncClientIntegrationTest, ComposeObject) { - auto client = MakeIntegrationTestClient(); + auto async = AsyncClient(TestOptions()); auto o1 = MakeRandomObjectName(); auto o2 = MakeRandomObjectName(); auto destination = MakeRandomObjectName(); - auto async = AsyncClient(); auto insert1 = async.InsertObject(BucketName(bucket_name()), o1, LoremIpsum(), AlwaysRetry()); @@ -175,6 +180,7 @@ TEST_F(AsyncClientIntegrationTest, ComposeObject) { } TEST_F(AsyncClientIntegrationTest, StreamingRead) { + auto async = AsyncClient(TestOptions()); auto object_name = MakeRandomObjectName(); // Create a relatively large object so the streaming read makes sense. We // aim for something around 5MiB, enough for 3 `Read()` calls. @@ -189,7 +195,6 @@ TEST_F(AsyncClientIntegrationTest, StreamingRead) { insert_data.begin(), insert_data.end(), static_cast(0), [](auto a, auto const& b) { return a + b.size(); }); - auto async = AsyncClient(); auto insert = async.InsertObject(BucketName(bucket_name()), object_name, insert_data) .get(); @@ -223,6 +228,7 @@ TEST_F(AsyncClientIntegrationTest, StreamingRead) { } TEST_F(AsyncClientIntegrationTest, StreamingReadRange) { + auto async = AsyncClient(TestOptions()); auto object_name = MakeRandomObjectName(); // Create a relatively large object so the streaming read makes sense. We // aim for something around 5MiB, enough for 3 `Read()` calls. @@ -234,7 +240,6 @@ TEST_F(AsyncClientIntegrationTest, StreamingReadRange) { for (int i = 0; i != kLineCount; ++i) contents += block; auto const expected_insert_size = contents.size(); - auto async = AsyncClient(); auto insert = async.InsertObject(BucketName(bucket_name()), object_name, contents) .get(); @@ -268,9 +273,9 @@ TEST_F(AsyncClientIntegrationTest, StreamingReadRange) { } TEST_F(AsyncClientIntegrationTest, StartUnbufferedUploadEmpty) { + auto client = AsyncClient(TestOptions()); auto object_name = MakeRandomObjectName(); - auto client = AsyncClient(); auto w = client.StartUnbufferedUpload(BucketName(bucket_name()), object_name) .get(); ASSERT_STATUS_OK(w); @@ -288,13 +293,13 @@ TEST_F(AsyncClientIntegrationTest, StartUnbufferedUploadEmpty) { } TEST_F(AsyncClientIntegrationTest, StartUnbufferedUploadMultiple) { + auto client = AsyncClient(TestOptions()); auto object_name = MakeRandomObjectName(); // Create a small block to send over and over. auto constexpr kBlockSize = 256 * 1024; auto constexpr kBlockCount = 16; auto const block = MakeRandomData(kBlockSize); - auto client = AsyncClient(); auto w = client.StartUnbufferedUpload(BucketName(bucket_name()), object_name) .get(); ASSERT_STATUS_OK(w); @@ -317,6 +322,7 @@ TEST_F(AsyncClientIntegrationTest, StartUnbufferedUploadMultiple) { } TEST_F(AsyncClientIntegrationTest, StartUnbufferedUploadResume) { + auto client = AsyncClient(TestOptions()); auto object_name = MakeRandomObjectName(); // Create a small block to send over and over. auto constexpr kBlockSize = 256 * 1024; @@ -325,7 +331,6 @@ TEST_F(AsyncClientIntegrationTest, StartUnbufferedUploadResume) { auto constexpr kDesiredSize = kBlockSize * kTotalBlockCount; auto const block = MakeRandomData(kBlockSize); - auto client = AsyncClient(); auto w = client.StartUnbufferedUpload(BucketName(bucket_name()), object_name) .get(); ASSERT_STATUS_OK(w); @@ -379,12 +384,12 @@ TEST_F(AsyncClientIntegrationTest, StartUnbufferedUploadResume) { } TEST_F(AsyncClientIntegrationTest, StartUnbufferedUploadResumeFinalized) { + auto client = AsyncClient(TestOptions()); auto object_name = MakeRandomObjectName(); // Create a small block to send over and over. auto constexpr kBlockSize = static_cast(256 * 1024); auto const block = MakeRandomData(kBlockSize); - auto client = AsyncClient(); auto w = client.StartUnbufferedUpload(BucketName(bucket_name()), object_name) .get(); ASSERT_STATUS_OK(w); @@ -410,9 +415,9 @@ TEST_F(AsyncClientIntegrationTest, StartUnbufferedUploadResumeFinalized) { } TEST_F(AsyncClientIntegrationTest, StartBufferedUploadEmpty) { + auto client = AsyncClient(TestOptions()); auto object_name = MakeRandomObjectName(); - auto client = AsyncClient(); auto w = client.StartBufferedUpload(BucketName(bucket_name()), object_name).get(); ASSERT_STATUS_OK(w); @@ -430,13 +435,13 @@ TEST_F(AsyncClientIntegrationTest, StartBufferedUploadEmpty) { } TEST_F(AsyncClientIntegrationTest, StartBufferedUploadMultiple) { + auto client = AsyncClient(TestOptions()); auto object_name = MakeRandomObjectName(); // Create a small block to send over and over. auto constexpr kBlockSize = 256 * 1024; auto constexpr kBlockCount = 16; auto const block = MakeRandomData(kBlockSize); - auto client = AsyncClient(); auto w = client.StartBufferedUpload(BucketName(bucket_name()), object_name).get(); ASSERT_STATUS_OK(w); @@ -459,10 +464,10 @@ TEST_F(AsyncClientIntegrationTest, StartBufferedUploadMultiple) { } TEST_F(AsyncClientIntegrationTest, RewriteObject) { + auto async = AsyncClient(TestOptions()); auto o1 = MakeRandomObjectName(); auto o2 = MakeRandomObjectName(); - auto async = AsyncClient(); auto constexpr kBlockSize = 4 * 1024 * 1024; auto insert = async .InsertObject(BucketName(bucket_name()), o1, @@ -500,11 +505,11 @@ TEST_F(AsyncClientIntegrationTest, RewriteObject) { } TEST_F(AsyncClientIntegrationTest, RewriteObjectResume) { + auto async = AsyncClient(TestOptions()); auto destination = GetEnv("GOOGLE_CLOUD_CPP_STORAGE_TEST_DESTINATION_BUCKET_NAME"); if (!destination || destination->empty()) GTEST_SKIP(); - auto async = AsyncClient(); auto constexpr kBlockSize = 4 * 1024 * 1024; auto source = async