Skip to content

Commit

Permalink
test(storage): skip some gRPC integration tests
Browse files Browse the repository at this point in the history
The testbench does not support the features used by these tests. We may
consider removing the tests, the unit tests are enough for gRPC, and we
could (now) write unit tests for JSON too.
  • Loading branch information
coryan committed Jun 27, 2024
1 parent 964ef1f commit 2ab1e6b
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 67 deletions.
29 changes: 21 additions & 8 deletions google/cloud/storage/tests/bucket_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,18 @@ TEST_F(BucketIntegrationTest, BasicCRUD) {
EXPECT_EQ(1, patched->lifecycle().rule.size());

// Patch the metadata again, this time remove billing and website settings.
patched = client->PatchBucket(
bucket_name, BucketMetadataPatchBuilder().ResetWebsite().ResetBilling());
ASSERT_STATUS_OK(patched);
// It does not matter if the `billing` compound is set. Only that it has the
// same effect as-if it was not set, i.e., it has the default value.
EXPECT_EQ(patched->billing_as_optional().value_or(BucketBilling{false}),
BucketBilling{false});
EXPECT_FALSE(patched->has_website());
// The emulator does not support this feature for gRPC.
if (!UsingEmulator() || !UsingGrpc()) {
patched = client->PatchBucket(
bucket_name,
BucketMetadataPatchBuilder().ResetWebsite().ResetBilling());
ASSERT_STATUS_OK(patched);
// It does not matter if the `billing` compound is set. Only that it has the
// same effect as-if it was not set, i.e., it has the default value.
EXPECT_EQ(patched->billing_as_optional().value_or(BucketBilling{false}),
BucketBilling{false});
EXPECT_FALSE(patched->has_website());
}

auto status = client->DeleteBucket(bucket_name);
ASSERT_STATUS_OK(status);
Expand Down Expand Up @@ -565,6 +569,8 @@ TEST_F(BucketIntegrationTest, GetMetadata) {
}

TEST_F(BucketIntegrationTest, GetMetadataFields) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();
StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);

Expand Down Expand Up @@ -698,6 +704,8 @@ TEST_F(BucketIntegrationTest, AccessControlCRUD) {
}

TEST_F(BucketIntegrationTest, DefaultObjectAccessControlCRUD) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();
std::string bucket_name = MakeRandomBucketName();
StatusOr<Client> client = MakeBucketIntegrationTestClient();
ASSERT_STATUS_OK(client);
Expand Down Expand Up @@ -767,6 +775,8 @@ TEST_F(BucketIntegrationTest, DefaultObjectAccessControlCRUD) {
}

TEST_F(BucketIntegrationTest, NotificationsCRUD) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (!UsingEmulator() && UsingGrpc()) GTEST_SKIP();
std::string bucket_name = MakeRandomBucketName();
StatusOr<Client> client = MakeBucketIntegrationTestClient();
ASSERT_STATUS_OK(client);
Expand Down Expand Up @@ -1176,6 +1186,9 @@ TEST_F(BucketIntegrationTest, DeleteDefaultAccessControlFailure) {
}

TEST_F(BucketIntegrationTest, NativeIamWithRequestedPolicyVersion) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();

std::string bucket_name = MakeRandomBucketName();
StatusOr<Client> client = MakeBucketIntegrationTestClient();
ASSERT_STATUS_OK(client);
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/storage/tests/curl_sign_blob_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class CurlSignBlobIntegrationTest
};

TEST_F(CurlSignBlobIntegrationTest, Simple) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();
StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);

Expand Down
62 changes: 43 additions & 19 deletions google/cloud/storage/tests/object_checksum_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ namespace {

using ::google::cloud::testing_util::IsOk;
using ::google::cloud::testing_util::StatusIs;
using ::testing::_;
using ::testing::Contains;
using ::testing::HasSubstr;
using ::testing::Not;
using ::testing::Pair;

class ObjectChecksumIntegrationTest
: public google::cloud::storage::testing::StorageIntegrationTest,
Expand Down Expand Up @@ -112,6 +115,9 @@ TEST_P(ObjectChecksumIntegrationTest, InsertObjectWithValueSuccess) {
}

TEST_P(ObjectChecksumIntegrationTest, InsertObjectWithValueFailure) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();

StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
auto object_name = MakeRandomObjectName();
Expand Down Expand Up @@ -140,9 +146,14 @@ TEST_F(ObjectChecksumIntegrationTest, WriteObjectDefault) {
EXPECT_THAT(os.computed_hash(),
HasSubstr(ComputeCrc32cChecksum(LoremIpsum())));
if (meta->has_metadata("x_emulator_upload")) {
// Streaming uploads over REST cannot include checksums
EXPECT_TRUE(meta->has_metadata("x_emulator_no_crc32c")) << *meta;
EXPECT_TRUE(meta->has_metadata("x_emulator_no_md5")) << *meta;
if (UsingGrpc()) {
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_crc32c", _)));
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_md5", _)));
} else {
// Streaming uploads over REST cannot include checksums
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_crc32c", _)));
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_md5", _)));
}
}
}

Expand All @@ -166,9 +177,8 @@ TEST_F(ObjectChecksumIntegrationTest, WriteObjectExplicitDisable) {
EXPECT_THAT(os.computed_hash(),
Not(HasSubstr(ComputeCrc32cChecksum(LoremIpsum()))));
if (meta->has_metadata("x_emulator_upload")) {
// Streaming uploads over REST cannot include checksums
EXPECT_TRUE(meta->has_metadata("x_emulator_no_crc32c")) << *meta;
EXPECT_TRUE(meta->has_metadata("x_emulator_no_md5")) << *meta;
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_crc32c", _)));
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_md5", _)));
}
}

Expand All @@ -192,9 +202,14 @@ TEST_F(ObjectChecksumIntegrationTest, WriteObjectExplicitEnable) {
EXPECT_THAT(os.computed_hash(),
HasSubstr(ComputeCrc32cChecksum(LoremIpsum())));
if (meta->has_metadata("x_emulator_upload")) {
// Streaming uploads over REST cannot include checksums
EXPECT_TRUE(meta->has_metadata("x_emulator_no_crc32c")) << *meta;
EXPECT_TRUE(meta->has_metadata("x_emulator_no_md5")) << *meta;
if (UsingGrpc()) {
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_crc32c", _)));
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_md5", _)));
} else {
// Streaming uploads over REST cannot include checksums
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_crc32c", _)));
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_md5", _)));
}
}
}

Expand All @@ -214,15 +229,16 @@ TEST_F(ObjectChecksumIntegrationTest, WriteObjectWithValueSuccess) {
ScheduleForDelete(*meta);

if (meta->has_metadata("x_emulator_upload")) {
// Streaming uploads over REST cannot include checksums unless provided by
// the application when the upload begins.
EXPECT_TRUE(meta->has_metadata("x_emulator_crc32c")) << *meta;
EXPECT_TRUE(meta->has_metadata("x_emulator_no_md5")) << *meta;
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_crc32c", _)));
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_md5", _)));
}
}

/// @test Verify that incorrect CRC32C checksums values work in WriteObject().
TEST_F(ObjectChecksumIntegrationTest, WriteObjectWithValueFailure) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();

StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
auto object_name = MakeRandomObjectName();
Expand All @@ -239,8 +255,9 @@ TEST_F(ObjectChecksumIntegrationTest, WriteObjectWithValueFailure) {
/// receives bad data.
TEST_F(ObjectChecksumIntegrationTest, WriteObjectReceiveBadChecksum) {
// This test is disabled when not using the emulator as it relies on the
// emulator to inject faults.
if (!UsingEmulator()) GTEST_SKIP();
// emulator to inject faults. The emulator does not support this type of fault
// injection for gRPC either.
if (!UsingEmulator() || UsingGrpc()) GTEST_SKIP();
StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);

Expand All @@ -261,6 +278,8 @@ TEST_F(ObjectChecksumIntegrationTest, WriteObjectReceiveBadChecksum) {

/// @test Verify that CRC32C checksum mismatches are reported by default.
TEST_F(ObjectChecksumIntegrationTest, WriteObjectUploadBadChecksum) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();
StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);

Expand All @@ -278,6 +297,9 @@ TEST_F(ObjectChecksumIntegrationTest, WriteObjectUploadBadChecksum) {

/// @test Verify that CRC32C checksums are computed by default on downloads.
TEST_P(ObjectChecksumIntegrationTest, ReadObjectDefault) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();

StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
auto object_name = MakeRandomObjectName();
Expand All @@ -298,8 +320,9 @@ TEST_P(ObjectChecksumIntegrationTest, ReadObjectDefault) {
/// downloads.
TEST_P(ObjectChecksumIntegrationTest, ReadObjectCorruptedByServerGetc) {
// This test is disabled when not using the emulator as it relies on the
// emulator to inject faults.
if (!UsingEmulator()) GTEST_SKIP();
// emulator to inject faults. The emulator does not support this type of fault
// injection for gRPC either.
if (!UsingEmulator() || UsingGrpc()) GTEST_SKIP();
StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
auto object_name = MakeRandomObjectName();
Expand Down Expand Up @@ -336,8 +359,9 @@ TEST_P(ObjectChecksumIntegrationTest, ReadObjectCorruptedByServerGetc) {
/// downloads.
TEST_P(ObjectChecksumIntegrationTest, ReadObjectCorruptedByServerRead) {
// This test is disabled when not using the emulator as it relies on the
// emulator to inject faults.
if (!UsingEmulator()) GTEST_SKIP();
// emulator to inject faults. The emulator does not support this type of fault
// injection for gRPC either.
if (!UsingEmulator() || UsingGrpc()) GTEST_SKIP();
StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
auto object_name = MakeRandomObjectName();
Expand Down
10 changes: 6 additions & 4 deletions google/cloud/storage/tests/object_file_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,9 @@ TEST_F(ObjectFileIntegrationTest, UploadPortionRegularFile) {
}

TEST_F(ObjectFileIntegrationTest, ResumableUploadFileCustomHeader) {
// Test relies on emulator for capturing custom header
if (!UsingEmulator()) GTEST_SKIP();
// Test relies on emulator for capturing custom header. The emulator does not
// support this behavior with gRPC, so we need to skip the test in this case.
if (!UsingEmulator() || UsingGrpc()) GTEST_SKIP();

StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
Expand Down Expand Up @@ -551,8 +552,9 @@ TEST_F(ObjectFileIntegrationTest, ResumableUploadFileCustomHeader) {
auto expected_str = expected.str();
ASSERT_EQ(expected_str.size(), meta->size());

ASSERT_TRUE(meta->has_metadata("x_emulator_custom_header"));
EXPECT_EQ(custom_header.value(), meta->metadata("x_emulator_custom_header"));
EXPECT_THAT(meta->metadata(),
::testing::Contains(::testing::Pair("x_emulator_custom_header",
"custom_header_value")));

// Create an iostream to read the object back.
auto stream = client->ReadObject(bucket_name_, object_name);
Expand Down
47 changes: 37 additions & 10 deletions google/cloud/storage/tests/object_hash_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ namespace {

using ::google::cloud::testing_util::IsOk;
using ::google::cloud::testing_util::StatusIs;
using ::testing::_;
using ::testing::Contains;
using ::testing::HasSubstr;
using ::testing::Not;
using ::testing::Pair;

class ObjectHashIntegrationTest
: public google::cloud::storage::testing::StorageIntegrationTest,
Expand Down Expand Up @@ -120,6 +124,9 @@ TEST_P(ObjectHashIntegrationTest, InsertObjectWithValueSuccess) {

/// @test Verify that incorrect MD5 hash values work in InsertObject().
TEST_P(ObjectHashIntegrationTest, InsertObjectWithValueFailure) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();

StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
auto object_name = MakeRandomObjectName();
Expand Down Expand Up @@ -192,8 +199,13 @@ TEST_F(ObjectHashIntegrationTest, WriteObjectExplicitEnable) {
EXPECT_THAT(os.computed_hash(), HasSubstr(ComputeMD5Hash(LoremIpsum())));
EXPECT_THAT(os.received_hash(), HasSubstr(ComputeMD5Hash(LoremIpsum())));
if (meta->has_metadata("x_emulator_upload")) {
ASSERT_TRUE(meta->has_metadata("x_emulator_no_crc32c"));
ASSERT_TRUE(meta->has_metadata("x_emulator_no_md5"));
ASSERT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_crc32c", _)));
if (UsingGrpc()) {
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_md5", _)));
} else {
// REST cannot send the checksums computed at the end of the upload.
ASSERT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_md5", _)));
}
}
}

Expand All @@ -212,13 +224,19 @@ TEST_F(ObjectHashIntegrationTest, WriteObjectWithValueSuccess) {
ScheduleForDelete(*meta);

if (meta->has_metadata("x_emulator_upload")) {
ASSERT_TRUE(meta->has_metadata("x_emulator_no_crc32c"));
ASSERT_TRUE(meta->has_metadata("x_emulator_md5"));
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_crc32c", _)));
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (!(UsingEmulator() && UsingGrpc())) {
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_md5", _)));
}
}
}

/// @test Verify that incorrect MD5 hash values work in WriteObject().
TEST_F(ObjectHashIntegrationTest, WriteObjectWithValueFailure) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();

StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
auto object_name = MakeRandomObjectName();
Expand All @@ -235,8 +253,9 @@ TEST_F(ObjectHashIntegrationTest, WriteObjectWithValueFailure) {
/// receives bad data.
TEST_F(ObjectHashIntegrationTest, WriteObjectReceiveBadChecksum) {
// This test is disabled when not using the emulator as it relies on the
// emulator to inject faults.
if (!UsingEmulator()) GTEST_SKIP();
// emulator to inject faults. The emulator does not support this type of fault
// injection for gRPC either.
if (!UsingEmulator() || UsingGrpc()) GTEST_SKIP();
StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);

Expand All @@ -258,6 +277,9 @@ TEST_F(ObjectHashIntegrationTest, WriteObjectReceiveBadChecksum) {

/// @test Verify that MD5 hash mismatches are reported by default.
TEST_F(ObjectHashIntegrationTest, WriteObjectUploadBadChecksum) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();

StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);

Expand All @@ -275,6 +297,9 @@ TEST_F(ObjectHashIntegrationTest, WriteObjectUploadBadChecksum) {

/// @test Verify that MD5 hashes are disabled by default on downloads.
TEST_P(ObjectHashIntegrationTest, ReadObjectDefault) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();

StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
auto object_name = MakeRandomObjectName();
Expand All @@ -295,8 +320,9 @@ TEST_P(ObjectHashIntegrationTest, ReadObjectDefault) {
/// downloads.
TEST_P(ObjectHashIntegrationTest, ReadObjectCorruptedByServerGetc) {
// This test is disabled when not using the emulator as it relies on the
// emulator to inject faults.
if (!UsingEmulator()) GTEST_SKIP();
// emulator to inject faults. The emulator does not support this type of fault
// injection for gRPC either.
if (!UsingEmulator() || UsingGrpc()) GTEST_SKIP();
StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
auto object_name = MakeRandomObjectName();
Expand Down Expand Up @@ -333,8 +359,9 @@ TEST_P(ObjectHashIntegrationTest, ReadObjectCorruptedByServerGetc) {
/// downloads.
TEST_P(ObjectHashIntegrationTest, ReadObjectCorruptedByServerRead) {
// This test is disabled when not using the emulator as it relies on the
// emulator to inject faults.
if (!UsingEmulator()) GTEST_SKIP();
// emulator to inject faults. The emulator does not support this type of fault
// injection for gRPC either.
if (!UsingEmulator() || UsingGrpc()) GTEST_SKIP();
StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);
auto object_name = MakeRandomObjectName();
Expand Down
3 changes: 3 additions & 0 deletions google/cloud/storage/tests/object_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ TEST_F(ObjectIntegrationTest, BasicReadWriteBinary) {
}

TEST_F(ObjectIntegrationTest, EncryptedReadWrite) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();

StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);

Expand Down
9 changes: 7 additions & 2 deletions google/cloud/storage/tests/object_media_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ TEST_F(ObjectMediaIntegrationTest, ReadFromSpill) {

/// @test Read the last chunk of an object by setting ReadLast option.
TEST_F(ObjectMediaIntegrationTest, ReadLastChunkReadLast) {
// TODO(#14385) - the emulator does not support this feature for gRPC.
if (UsingEmulator() && UsingGrpc()) GTEST_SKIP();

StatusOr<Client> client = MakeIntegrationTestClient();
ASSERT_STATUS_OK(client);

Expand Down Expand Up @@ -523,7 +526,8 @@ TEST_F(ObjectMediaIntegrationTest, ConnectionFailureUploadFile) {
}

TEST_F(ObjectMediaIntegrationTest, StreamingReadTimeout) {
if (!UsingEmulator()) GTEST_SKIP();
// The emulator does not support this type of fault injection for gRPC.
if (!UsingEmulator() || UsingGrpc()) GTEST_SKIP();
auto options = ClientOptions::CreateDefaultClientOptions();
ASSERT_STATUS_OK(options);

Expand Down Expand Up @@ -555,7 +559,8 @@ TEST_F(ObjectMediaIntegrationTest, StreamingReadTimeout) {
}

TEST_F(ObjectMediaIntegrationTest, StreamingReadTimeoutContinues) {
if (!UsingEmulator()) GTEST_SKIP();
// The emulator does not support this type of fault injection for gRPC.
if (!UsingEmulator() || UsingGrpc()) GTEST_SKIP();

Client client(
Options{}
Expand Down
Loading

0 comments on commit 2ab1e6b

Please sign in to comment.