Skip to content

Commit 2ceb8aa

Browse files
committed
feat(bigtable): set peer_info to true in FeatureFlags
Adds `peer_info` to the Google Cloud Bigtable `FeatureFlags`, indicating that the client supports peer information. Updates all `FeatureFlags` unit tests to exhaustively check all set `FeatureFlags` fields in the decoded metadata.
1 parent 1735f56 commit 2ceb8aa

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

google/cloud/bigtable/internal/bigtable_stub_factory.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ std::string CreateFeaturesMetadata(bool is_direct_path) {
5656
proto.set_mutate_rows_rate_limit2(true);
5757
proto.set_routing_cookie(true);
5858
proto.set_retry_info(true);
59+
proto.set_peer_info(true);
5960
if (is_direct_path) {
6061
proto.set_traffic_director_enabled(true);
6162
proto.set_direct_access_requested(true);

google/cloud/bigtable/internal/bigtable_stub_factory_test.cc

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ using ::testing::IsEmpty;
5454
using ::testing::MockFunction;
5555
using ::testing::Not;
5656
using ::testing::Optional;
57-
using ::testing::Pair;
5857
using ::testing::ResultOf;
5958
using ::testing::Return;
6059

@@ -300,12 +299,21 @@ TEST(BigtableStubFactory, FeaturesFlagsCloudDirectPath) {
300299
auto headers = fixture.GetMetadata(context);
301300
auto it = headers.find("bigtable-features");
302301
EXPECT_NE(it, headers.end());
302+
if (it == headers.end())
303+
return internal::AbortedError("header not found");
303304
auto decoded = internal::UrlsafeBase64Decode(it->second);
304305
EXPECT_STATUS_OK(decoded);
305306
if (!decoded) return internal::AbortedError("fail to decode");
306307
google::bigtable::v2::FeatureFlags proto;
307308
EXPECT_TRUE(proto.ParseFromArray(
308309
decoded->data(), static_cast<int>(decoded->size())));
310+
EXPECT_TRUE(proto.reverse_scans());
311+
EXPECT_TRUE(proto.last_scanned_row_responses());
312+
EXPECT_TRUE(proto.mutate_rows_rate_limit());
313+
EXPECT_TRUE(proto.mutate_rows_rate_limit2());
314+
EXPECT_TRUE(proto.routing_cookie());
315+
EXPECT_TRUE(proto.retry_info());
316+
EXPECT_TRUE(proto.peer_info());
309317
EXPECT_TRUE(proto.traffic_director_enabled());
310318
EXPECT_TRUE(proto.direct_access_requested());
311319
return internal::AbortedError("fail");
@@ -341,11 +349,20 @@ TEST(BigtableStubFactory, FeaturesFlagsBigtableDirectPath) {
341349
auto it = headers.find("bigtable-features");
342350
EXPECT_NE(it, headers.end());
343351
auto decoded = internal::UrlsafeBase64Decode(it->second);
352+
if (it == headers.end())
353+
return internal::AbortedError("header not found");
344354
EXPECT_STATUS_OK(decoded);
345355
if (!decoded) return internal::AbortedError("fail to decode");
346356
google::bigtable::v2::FeatureFlags proto;
347357
EXPECT_TRUE(proto.ParseFromArray(
348358
decoded->data(), static_cast<int>(decoded->size())));
359+
EXPECT_TRUE(proto.reverse_scans());
360+
EXPECT_TRUE(proto.last_scanned_row_responses());
361+
EXPECT_TRUE(proto.mutate_rows_rate_limit());
362+
EXPECT_TRUE(proto.mutate_rows_rate_limit2());
363+
EXPECT_TRUE(proto.routing_cookie());
364+
EXPECT_TRUE(proto.retry_info());
365+
EXPECT_TRUE(proto.peer_info());
349366
EXPECT_TRUE(proto.traffic_director_enabled());
350367
EXPECT_TRUE(proto.direct_access_requested());
351368
return internal::AbortedError("fail");
@@ -378,10 +395,25 @@ TEST(BigtableStubFactory, FeaturesFlags) {
378395
google::bigtable::v2::MutateRowRequest const&) {
379396
ValidateMetadataFixture fixture;
380397
auto headers = fixture.GetMetadata(context);
381-
EXPECT_THAT(
382-
headers,
383-
Contains(Pair("bigtable-features",
384-
AllOf(Not(IsEmpty()), IsWebSafeBase64()))));
398+
auto it = headers.find("bigtable-features");
399+
EXPECT_NE(it, headers.end());
400+
if (it == headers.end())
401+
return internal::AbortedError("header not found");
402+
auto decoded = internal::UrlsafeBase64Decode(it->second);
403+
EXPECT_STATUS_OK(decoded);
404+
if (!decoded) return internal::AbortedError("fail to decode");
405+
google::bigtable::v2::FeatureFlags proto;
406+
EXPECT_TRUE(proto.ParseFromArray(
407+
decoded->data(), static_cast<int>(decoded->size())));
408+
EXPECT_TRUE(proto.reverse_scans());
409+
EXPECT_TRUE(proto.last_scanned_row_responses());
410+
EXPECT_TRUE(proto.mutate_rows_rate_limit());
411+
EXPECT_TRUE(proto.mutate_rows_rate_limit2());
412+
EXPECT_TRUE(proto.routing_cookie());
413+
EXPECT_TRUE(proto.retry_info());
414+
EXPECT_TRUE(proto.peer_info());
415+
EXPECT_FALSE(proto.traffic_director_enabled());
416+
EXPECT_FALSE(proto.direct_access_requested());
385417
return internal::AbortedError("fail");
386418
});
387419
return mock;

0 commit comments

Comments
 (0)