Skip to content

Commit

Permalink
cleanup(storage): simplify test initialization (#14500)
Browse files Browse the repository at this point in the history
  • Loading branch information
coryan authored Jul 19, 2024
1 parent a404691 commit 93cbfdb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
12 changes: 5 additions & 7 deletions google/cloud/storage/benchmarks/throughput_experiment_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ TEST_P(ThroughputExperimentIntegrationTest, Upload) {
if (UsingEmulator() && ProductionOnly(GetParam())) GTEST_SKIP();

auto client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);

ThroughputOptions options;
options.minimum_write_buffer_size = 1 * kMiB;
options.libs = {GetParam().library};
options.transports = {GetParam().transport};

auto provider = [&](ExperimentTransport) { return *client; };
auto provider = [&](ExperimentTransport) { return client; };
auto experiments = CreateUploadExperiments(options, provider);
for (auto& e : experiments) {
auto object_name = MakeRandomObjectName();
Expand All @@ -72,7 +71,7 @@ TEST_P(ThroughputExperimentIntegrationTest, Upload) {
/*enable_md5=*/false, absl::nullopt};
auto result = e->Run(bucket_name_, object_name, config);
ASSERT_STATUS_OK(result.status);
auto status = client->DeleteObject(bucket_name_, object_name);
auto status = client.DeleteObject(bucket_name_, object_name);
EXPECT_THAT(status,
StatusIs(AnyOf(StatusCode::kOk, StatusCode::kNotFound)));
}
Expand All @@ -82,14 +81,13 @@ TEST_P(ThroughputExperimentIntegrationTest, Download) {
if (UsingEmulator() && ProductionOnly(GetParam())) GTEST_SKIP();

auto client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);

ThroughputOptions options;
options.minimum_write_buffer_size = 1 * kMiB;
options.libs = {GetParam().library};
options.transports = {GetParam().transport};

auto provider = [&](ExperimentTransport) { return *client; };
auto provider = [&](ExperimentTransport) { return client; };
auto experiments =
CreateDownloadExperiments(options, provider, /*thread_id=*/0);
for (auto& e : experiments) {
Expand All @@ -105,14 +103,14 @@ TEST_P(ThroughputExperimentIntegrationTest, Download) {

auto contents = MakeRandomData(kObjectSize);
auto insert =
client->InsertObject(bucket_name_, object_name, std::move(contents));
client.InsertObject(bucket_name_, object_name, std::move(contents));
ASSERT_STATUS_OK(insert);

// With the raw protocols this might fail, that is fine, we just want the
// code to not crash and return the result (including failures).
(void)e->Run(bucket_name_, object_name, config);

auto status = client->DeleteObject(bucket_name_, object_name);
auto status = client.DeleteObject(bucket_name_, object_name);
EXPECT_THAT(status,
StatusIs(AnyOf(StatusCode::kOk, StatusCode::kNotFound)));
}
Expand Down
5 changes: 0 additions & 5 deletions google/cloud/storage/testing/storage_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ StorageIntegrationTest::MakeIntegrationTestClient(google::cloud::Options opts) {
return Client(std::move(opts));
}

google::cloud::StatusOr<google::cloud::storage::Client>
StorageIntegrationTest::MakeIntegrationTestClient() {
return MakeIntegrationTestClient(Options{});
}

google::cloud::storage::Client
StorageIntegrationTest::MakeBucketIntegrationTestClient() {
if (UsingEmulator()) return MakeIntegrationTestClient(Options{});
Expand Down
5 changes: 1 addition & 4 deletions google/cloud/storage/testing/storage_integration_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ class StorageIntegrationTest
* should use short backoff and retry periods. This returns a client so
* configured.
*/
static google::cloud::StatusOr<google::cloud::storage::Client>
MakeIntegrationTestClient();

static google::cloud::storage::Client MakeIntegrationTestClient(
google::cloud::Options opts);
google::cloud::Options opts = {});

/**
* Return a client with retry policies suitable for CreateBucket() class.
Expand Down

0 comments on commit 93cbfdb

Please sign in to comment.