Skip to content

Commit

Permalink
fix(bigtable): use FQDN
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolduc committed Dec 13, 2023
1 parent f4b0970 commit 4a9b3eb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions google/cloud/bigtable/client_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ ClientOptions::ClientOptions(std::shared_ptr<grpc::ChannelCredentials> creds) {

// This constructor ignores the emulator environment variables, which might be
// set by `internal::DefaultOptions()`.
opts_.set<DataEndpointOption>("bigtable.googleapis.com");
opts_.set<AdminEndpointOption>("bigtableadmin.googleapis.com");
opts_.set<InstanceAdminEndpointOption>("bigtableadmin.googleapis.com");
opts_.set<DataEndpointOption>("bigtable.googleapis.com.");
opts_.set<AdminEndpointOption>("bigtableadmin.googleapis.com.");
opts_.set<InstanceAdminEndpointOption>("bigtableadmin.googleapis.com.");
}

// NOLINTNEXTLINE(readability-identifier-naming)
Expand Down
22 changes: 11 additions & 11 deletions google/cloud/bigtable/client_options_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ using ::testing::HasSubstr;

TEST(ClientOptionsTest, ClientOptionsDefaultSettings) {
ClientOptions client_options;
EXPECT_EQ("bigtable.googleapis.com", client_options.data_endpoint());
EXPECT_EQ("bigtableadmin.googleapis.com", client_options.admin_endpoint());
EXPECT_EQ("bigtable.googleapis.com.", client_options.data_endpoint());
EXPECT_EQ("bigtableadmin.googleapis.com.", client_options.admin_endpoint());
EXPECT_EQ(typeid(grpc::GoogleDefaultCredentials()),
typeid(client_options.credentials()));

Expand Down Expand Up @@ -173,8 +173,8 @@ TEST_F(ClientOptionsDefaultEndpointTest, Default) {
TEST_F(ClientOptionsDefaultEndpointTest, WithCredentials) {
auto credentials = grpc::GoogleDefaultCredentials();
ClientOptions tested(credentials);
EXPECT_EQ("bigtable.googleapis.com", tested.data_endpoint());
EXPECT_EQ("bigtableadmin.googleapis.com", tested.admin_endpoint());
EXPECT_EQ("bigtable.googleapis.com.", tested.data_endpoint());
EXPECT_EQ("bigtableadmin.googleapis.com.", tested.admin_endpoint());
EXPECT_EQ(credentials.get(), tested.credentials().get());
}

Expand All @@ -183,9 +183,9 @@ TEST_F(ClientOptionsDefaultEndpointTest, DefaultNoEmulator) {

auto credentials = grpc::GoogleDefaultCredentials();
ClientOptions tested(credentials);
EXPECT_EQ("bigtable.googleapis.com", tested.data_endpoint());
EXPECT_EQ("bigtableadmin.googleapis.com", tested.admin_endpoint());
EXPECT_EQ("bigtableadmin.googleapis.com", GetInstanceAdminEndpoint(tested));
EXPECT_EQ("bigtable.googleapis.com.", tested.data_endpoint());
EXPECT_EQ("bigtableadmin.googleapis.com.", tested.admin_endpoint());
EXPECT_EQ("bigtableadmin.googleapis.com.", GetInstanceAdminEndpoint(tested));
}

TEST_F(ClientOptionsDefaultEndpointTest, SeparateEmulators) {
Expand All @@ -201,12 +201,12 @@ TEST_F(ClientOptionsDefaultEndpointTest, SeparateEmulators) {

TEST_F(ClientOptionsDefaultEndpointTest, DataNoEnv) {
ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", {});
EXPECT_EQ("bigtable.googleapis.com", ClientOptions{}.data_endpoint());
EXPECT_EQ("bigtable.googleapis.com.", ClientOptions{}.data_endpoint());
}

TEST_F(ClientOptionsDefaultEndpointTest, AdminNoEnv) {
ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", {});
EXPECT_EQ("bigtableadmin.googleapis.com", ClientOptions{}.admin_endpoint());
EXPECT_EQ("bigtableadmin.googleapis.com.", ClientOptions{}.admin_endpoint());
}

TEST_F(ClientOptionsDefaultEndpointTest, AdminEmulatorOverrides) {
Expand All @@ -219,12 +219,12 @@ TEST_F(ClientOptionsDefaultEndpointTest, AdminInstanceAdminNoEffect) {
ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", {});
ScopedEnvironment bigtable_instance_admin_emulator_host(
"BIGTABLE_INSTANCE_ADMIN_EMULATOR_HOST", "127.0.0.1:1234");
EXPECT_EQ("bigtableadmin.googleapis.com", ClientOptions{}.admin_endpoint());
EXPECT_EQ("bigtableadmin.googleapis.com.", ClientOptions{}.admin_endpoint());
}

TEST_F(ClientOptionsDefaultEndpointTest, InstanceAdminNoEnv) {
ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", {});
EXPECT_EQ("bigtableadmin.googleapis.com",
EXPECT_EQ("bigtableadmin.googleapis.com.",
GetInstanceAdminEndpoint(ClientOptions()));
}

Expand Down
6 changes: 3 additions & 3 deletions google/cloud/bigtable/internal/defaults.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ Options DefaultOptions(Options opts) {
// Fill any missing default values.
auto defaults =
Options{}
.set<DataEndpointOption>("bigtable.googleapis.com")
.set<AdminEndpointOption>("bigtableadmin.googleapis.com")
.set<InstanceAdminEndpointOption>("bigtableadmin.googleapis.com")
.set<DataEndpointOption>("bigtable.googleapis.com.")
.set<AdminEndpointOption>("bigtableadmin.googleapis.com.")
.set<InstanceAdminEndpointOption>("bigtableadmin.googleapis.com.")
.set<GrpcCredentialOption>(emulator
? grpc::InsecureChannelCredentials()
: grpc::GoogleDefaultCredentials())
Expand Down
16 changes: 8 additions & 8 deletions google/cloud/bigtable/internal/defaults_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ TEST(OptionsTest, Defaults) {
"BIGTABLE_INSTANCE_ADMIN_EMULATOR_HOST", absl::nullopt);

auto opts = DefaultOptions();
EXPECT_EQ("bigtable.googleapis.com", opts.get<DataEndpointOption>());
EXPECT_EQ("bigtableadmin.googleapis.com", opts.get<AdminEndpointOption>());
EXPECT_EQ("bigtableadmin.googleapis.com",
EXPECT_EQ("bigtable.googleapis.com.", opts.get<DataEndpointOption>());
EXPECT_EQ("bigtableadmin.googleapis.com.", opts.get<AdminEndpointOption>());
EXPECT_EQ("bigtableadmin.googleapis.com.",
opts.get<InstanceAdminEndpointOption>());
EXPECT_EQ(typeid(grpc::GoogleDefaultCredentials()),
typeid(opts.get<GrpcCredentialOption>()));
Expand Down Expand Up @@ -230,8 +230,8 @@ TEST(EndpointEnvTest, InstanceEmulatorEnvOnly) {
"instance-emulator-host:9000");

auto opts = DefaultOptions();
EXPECT_EQ("bigtable.googleapis.com", opts.get<DataEndpointOption>());
EXPECT_EQ("bigtableadmin.googleapis.com", opts.get<AdminEndpointOption>());
EXPECT_EQ("bigtable.googleapis.com.", opts.get<DataEndpointOption>());
EXPECT_EQ("bigtableadmin.googleapis.com.", opts.get<AdminEndpointOption>());
EXPECT_EQ("instance-emulator-host:9000",
opts.get<InstanceAdminEndpointOption>());
}
Expand Down Expand Up @@ -304,8 +304,8 @@ TEST(EndpointEnvTest, DirectPathEnabled) {
opts.get<DataEndpointOption>());
EXPECT_EQ("directpath-bigtable.googleapis.com", opts.get<AuthorityOption>());
// Admin endpoints are not affected.
EXPECT_EQ("bigtableadmin.googleapis.com", opts.get<AdminEndpointOption>());
EXPECT_EQ("bigtableadmin.googleapis.com",
EXPECT_EQ("bigtableadmin.googleapis.com.", opts.get<AdminEndpointOption>());
EXPECT_EQ("bigtableadmin.googleapis.com.",
opts.get<InstanceAdminEndpointOption>());
EXPECT_EQ(1, opts.get<GrpcNumChannelsOption>());
}
Expand All @@ -316,7 +316,7 @@ TEST(EndpointEnvTest, DirectPathNoMatch) {
"bigtable-not,almost-bigtable");

auto opts = DefaultDataOptions(Options{});
EXPECT_EQ("bigtable.googleapis.com", opts.get<EndpointOption>());
EXPECT_EQ("bigtable.googleapis.com.", opts.get<EndpointOption>());
EXPECT_EQ("bigtable.googleapis.com", opts.get<AuthorityOption>());
}

Expand Down

0 comments on commit 4a9b3eb

Please sign in to comment.