Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions google/cloud/bigtable/tests/table_admin_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
#include "google/cloud/bigtable/instance_config.h"
#include "google/cloud/bigtable/table_config.h"
#include "google/cloud/bigtable/testing/table_integration_test.h"
#include "google/cloud/location/locations.pb.h"
#include "google/cloud/common_options.h"
#include "google/cloud/internal/getenv.h"
#include "google/cloud/internal/random.h"
#include "google/cloud/location.h"
#include "google/cloud/testing_util/chrono_literals.h"
#include "google/cloud/testing_util/scoped_environment.h"
#include "google/cloud/testing_util/scoped_log.h"
Expand All @@ -40,6 +42,8 @@ using ::testing::HasSubstr;
using ::testing::IsSupersetOf;
using ::testing::Not;

using ::google::cloud::bigtable::testing::TableTestEnvironment;

namespace btadmin = ::google::bigtable::admin::v2;

class TableAdminIntegrationTest
Expand Down Expand Up @@ -252,7 +256,7 @@ TEST_F(TableAdminIntegrationTest, CreateListGetDeleteTable) {
TEST_F(TableAdminIntegrationTest, WaitForConsistencyCheck) {
// WaitForConsistencyCheck() only makes sense on a replicated table, we need
// to create an instance with at least 2 clusters to test it.
auto const id = bigtable::testing::TableTestEnvironment::RandomInstanceId();
auto const id = TableTestEnvironment::RandomInstanceId();
auto const random_table_id = RandomTableId();

// Create a bigtable::InstanceAdmin and a bigtable::TableAdmin to create the
Expand All @@ -270,12 +274,14 @@ TEST_F(TableAdminIntegrationTest, WaitForConsistencyCheck) {
// they must be in different zones. Also, the display name cannot be longer
// than 30 characters.
auto display_name = ("IT " + id).substr(0, 30);
auto cluster_config_1 =
bigtable::ClusterConfig(bigtable::testing::TableTestEnvironment::zone_a(),
3, bigtable::ClusterConfig::HDD);
auto cluster_config_2 =
bigtable::ClusterConfig(bigtable::testing::TableTestEnvironment::zone_b(),
3, bigtable::ClusterConfig::HDD);
auto location_1 = Location(Project(TableTestEnvironment::project_id()),
TableTestEnvironment::zone_a());
auto location_2 = Location(Project(TableTestEnvironment::project_id()),
TableTestEnvironment::zone_b());
auto cluster_config_1 = bigtable::ClusterConfig(location_1.FullName(), 3,
bigtable::ClusterConfig::HDD);
auto cluster_config_2 = bigtable::ClusterConfig(location_2.FullName(), 3,
bigtable::ClusterConfig::HDD);
Comment on lines +277 to +284

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve conciseness and avoid repeating Project(TableTestEnvironment::project_id()), you could create a project variable and then construct the ClusterConfig objects directly without intermediate location_1 and location_2 variables.

  auto const project = Project(TableTestEnvironment::project_id());
  auto cluster_config_1 = bigtable::ClusterConfig(
      Location(project, TableTestEnvironment::zone_a()).FullName(), 3,
      bigtable::ClusterConfig::HDD);
  auto cluster_config_2 = bigtable::ClusterConfig(
      Location(project, TableTestEnvironment::zone_b()).FullName(), 3,
      bigtable::ClusterConfig::HDD);

bigtable::InstanceConfig config(
id, display_name,
{{id + "-c1", cluster_config_1}, {id + "-c2", cluster_config_2}});
Expand Down