Skip to content

Commit

Permalink
Cleanup integration test configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
coryan committed Jul 24, 2024
1 parent 941df0f commit 5b28ff3
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions google/cloud/storage/tests/async_client_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<storage_experimental::EnableGrpcMetricsOption>(false);
}

auto AlwaysRetry() {
return Options{}.set<IdempotencyPolicyOption>(
return TestOptions().set<IdempotencyPolicyOption>(
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,
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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.
Expand All @@ -189,7 +195,6 @@ TEST_F(AsyncClientIntegrationTest, StreamingRead) {
insert_data.begin(), insert_data.end(), static_cast<std::size_t>(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();
Expand Down Expand Up @@ -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.
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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<std::int64_t>(256 * 1024);
auto const block = MakeRandomData(kBlockSize);

auto client = AsyncClient();
auto w = client.StartUnbufferedUpload(BucketName(bucket_name()), object_name)
.get();
ASSERT_STATUS_OK(w);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5b28ff3

Please sign in to comment.