diff --git hbase-native-client/Makefile hbase-native-client/Makefile index 143c00c..708e907 100644 --- hbase-native-client/Makefile +++ hbase-native-client/Makefile @@ -38,7 +38,7 @@ LINKFLAG := -shared #define list of source files and object files ALLSRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cc)) -EXCLUDE_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*-test.cc)) core/simple-client.cc +EXCLUDE_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*-test.cc)) core/simple-client.cc core/load-client.cc SRC := $(filter-out $(EXCLUDE_SRC), $(ALLSRC)) PROTOSRC := $(patsubst %.proto, $(addprefix $(BUILD_PATH)/,%.pb.cc),$(wildcard if/*.proto)) PROTOHDR := $(patsubst %.proto, $(addprefix $(BUILD_PATH)/,%.pb.h),$(wildcard if/*.proto)) diff --git hbase-native-client/core/async-batch-rpc-retrying-test.cc hbase-native-client/core/async-batch-rpc-retrying-test.cc index c186276..0d186b4 100644 --- hbase-native-client/core/async-batch-rpc-retrying-test.cc +++ hbase-native-client/core/async-batch-rpc-retrying-test.cc @@ -296,7 +296,6 @@ void runMultiTest(std::shared_ptr region_locator, // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; for (uint64_t i = 0; i < num_rows; i++) { table->Put(Put{"test" + std::to_string(i)}.AddColumn("d", std::to_string(i), diff --git hbase-native-client/core/async-rpc-retrying-test.cc hbase-native-client/core/async-rpc-retrying-test.cc index f887815..95b7143 100644 --- hbase-native-client/core/async-rpc-retrying-test.cc +++ hbase-native-client/core/async-rpc-retrying-test.cc @@ -304,7 +304,6 @@ void runTest(std::shared_ptr region_locator, std::string // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; table->Put(Put{"test2"}.AddColumn("d", "2", "value2")); table->Put(Put{"test2"}.AddColumn("d", "extra", "value for extra")); diff --git hbase-native-client/core/client-test.cc hbase-native-client/core/client-test.cc index 9efe0b6..1c9b709 100644 --- hbase-native-client/core/client-test.cc +++ hbase-native-client/core/client-test.cc @@ -42,6 +42,7 @@ using hbase::RetriesExhaustedException; using hbase::Put; using hbase::Table; using hbase::TestUtil; +using std::experimental::nullopt; class ClientTest : public ::testing::Test { public: @@ -134,7 +135,7 @@ TEST_F(ClientTest, Append) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; std::string val1 = "a"; auto result = table->Append(hbase::Append{row}.Add("d", "1", val1)); @@ -164,7 +165,7 @@ TEST_F(ClientTest, PutGetDelete) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; // Perform Puts std::string valExtra = "value for extra"; @@ -201,7 +202,7 @@ TEST_F(ClientTest, PutGetDelete) { result = table->Get(get); ASSERT_TRUE(!result->IsEmpty()) << "Result shouldn't be empty."; ASSERT_FALSE(result->Value("d", "1")) << "Column 1 should be gone"; - ASSERT_TRUE(result->Value("d", "extra")) << "Column extra should have value"; + ASSERT_TRUE(result->Value("d", "extra") != nullopt) << "Column extra should have value"; EXPECT_EQ(valExt, *(result->Value("d", "ext"))) << "Column ext should have value"; // delete all cells from "extra" column @@ -234,7 +235,7 @@ TEST_F(ClientTest, Increment) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; int64_t incr1 = 1235; auto result = table->Increment(hbase::Increment{row}.AddColumn("d", "1", incr1)); EXPECT_EQ(row, result->Row()); @@ -262,7 +263,7 @@ TEST_F(ClientTest, CheckAndPut) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; // Perform Puts table->Put(Put{row}.AddColumn("d", "1", "value1")); @@ -291,7 +292,7 @@ TEST_F(ClientTest, CheckAndDelete) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; auto val1 = "value1"; @@ -321,7 +322,7 @@ TEST_F(ClientTest, PutGet) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; // Perform Puts table->Put(Put{"test1"}.AddColumn("d", "1", "value1")); @@ -355,7 +356,7 @@ TEST_F(ClientTest, GetForNonExistentTable) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; // Perform the Get try { @@ -387,7 +388,7 @@ TEST_F(ClientTest, GetForNonExistentRow) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; // Perform the Get auto result = table->Get(get); @@ -410,7 +411,7 @@ TEST_F(ClientTest, PutsWithTimestamp) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; int64_t ts = 42; // Perform Puts @@ -446,7 +447,7 @@ void PerformPuts(uint64_t num_rows, std::shared_ptr client, const std::string &table_name) { auto tn = folly::to(table_name); auto table = client->Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; // Perform Puts for (uint64_t i = 0; i < num_rows; i++) { table->Put(Put{"test" + std::to_string(i)}.AddColumn("d", std::to_string(i), @@ -501,7 +502,7 @@ TEST_F(ClientTest, MultiGets) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; std::vector gets; MakeGets(num_rows, "test", gets); @@ -534,7 +535,7 @@ TEST_F(ClientTest, MultiGetsWithRegionSplits) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; + ASSERT_TRUE(table != nullptr) << "Unable to get connection to Table."; std::vector gets; MakeGets(num_rows, "test", gets); diff --git hbase-native-client/core/filter-test.cc hbase-native-client/core/filter-test.cc index f401698..7276dfb 100644 --- hbase-native-client/core/filter-test.cc +++ hbase-native-client/core/filter-test.cc @@ -75,7 +75,6 @@ TEST_F(FilterTest, GetWithColumnPrefixFilter) { // Create a client hbase::Client client(*(FilterTest::test_util_->conf())); auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; table->Put(Put{"row1"}.AddColumn("d", "column_1", "value1")); table->Put(Put{"row1"}.AddColumn("d", "column_2", "value2")); @@ -122,7 +121,6 @@ TEST_F(FilterTest, GetWithQualifierFilter) { // Get connection to HBase Table auto table = client.Table(tn); - ASSERT_TRUE(table) << "Unable to get connection to Table."; table->Put(Put{"row1"}.AddColumn("d", "a", "value1")); table->Put(Put{"row1"}.AddColumn("d", "b", "value2")); diff --git hbase-native-client/core/hbase-configuration-test.cc hbase-native-client/core/hbase-configuration-test.cc index ebf0817..56b4463 100644 --- hbase-native-client/core/hbase-configuration-test.cc +++ hbase-native-client/core/hbase-configuration-test.cc @@ -27,6 +27,7 @@ #include "core/hbase-configuration-loader.h" using namespace hbase; +using std::experimental::nullopt; const std::string kDefHBaseConfPath("./build/test-data/hbase-configuration-test/conf/"); const std::string kHBaseConfPath("./build/test-data/hbase-configuration-test/custom-conf/"); @@ -149,7 +150,7 @@ TEST(Configuration, LoadConfFromDefaultLocation) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_STREQ((*conf).Get("custom-prop", "Set this value").c_str(), "custom-value"); EXPECT_STREQ((*conf).Get("default-prop", "Set this value").c_str(), "default-value"); } @@ -166,7 +167,7 @@ TEST(Configuration, LoadConfFromCustomLocation) { HBaseConfigurationLoader loader; std::vector resources{kHBaseSiteXml}; hbase::optional conf = loader.LoadResources(kHBaseConfPath, resources); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_STREQ((*conf).Get("custom-prop", "").c_str(), "custom-value"); EXPECT_STRNE((*conf).Get("custom-prop", "").c_str(), "some-value"); } @@ -187,7 +188,7 @@ TEST(Configuration, LoadConfFromMultipleLocatons) { std::string conf_paths = kDefHBaseConfPath + ":" + kHBaseConfPath; std::vector resources{kHBaseDefaultXml, kHBaseSiteXml}; hbase::optional conf = loader.LoadResources(conf_paths, resources); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_STREQ((*conf).Get("default-prop", "From hbase-default.xml").c_str(), "default-value"); EXPECT_STREQ((*conf).Get("custom-prop", "").c_str(), "custom-value"); EXPECT_STRNE((*conf).Get("custom-prop", "").c_str(), "some-value"); @@ -206,7 +207,7 @@ TEST(Configuration, DefaultValues) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_STREQ((*conf).Get("default-prop", "Set this value.").c_str(), "default-value"); EXPECT_STREQ((*conf).Get("custom-prop", "Set this value.").c_str(), "custom-value"); } @@ -218,7 +219,7 @@ TEST(Configuration, FinalValues) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_STREQ((*conf).Get("hbase.rootdir", "").c_str(), "/root/hbase-docker/apps/hbase/data"); EXPECT_STREQ((*conf).Get("hbase.zookeeper.property.datadir", "").c_str(), "/root/hbase-docker/zookeeper"); @@ -240,7 +241,7 @@ TEST(Configuration, EnvVars) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_STREQ((*conf).Get("hbase-client.user.name", "").c_str(), "${user.name}"); EXPECT_STRNE((*conf).Get("hbase-client.user.name", "root").c_str(), "test-user"); } @@ -252,7 +253,7 @@ TEST(Configuration, SelfRef) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_STREQ((*conf).Get("selfRef", "${selfRef}").c_str(), "${selfRef}"); } @@ -263,7 +264,7 @@ TEST(Configuration, VarExpansion) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_STREQ((*conf).Get("foo.substs", "foo-value").c_str(), "bar-value,bar-value,bar-value,bar-value,bar-value,bar-value," "bar-value,bar-value,bar-value,bar-value,"); @@ -277,7 +278,7 @@ TEST(Configuration, VarExpansionException) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; ASSERT_THROW((*conf).Get("foo.substs.exception", "foo-value").c_str(), std::runtime_error); } @@ -288,7 +289,7 @@ TEST(Configuration, GetInt) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_EQ(16000, (*conf).GetInt("int", 0)); EXPECT_EQ(2147483646, (*conf).GetInt("int.largevalue", 0)); } @@ -300,7 +301,7 @@ TEST(Configuration, GetLong) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_EQ(2147483850, (*conf).GetLong("long", 0)); EXPECT_EQ(9223372036854775807, (*conf).GetLong("long.largevalue", 0)); } @@ -312,7 +313,7 @@ TEST(Configuration, GetDouble) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_DOUBLE_EQ(17.9769e+100, (*conf).GetDouble("double", 0.0)); EXPECT_DOUBLE_EQ(170.769e+200, (*conf).GetDouble("double.largevalue", 0.0)); } @@ -324,7 +325,7 @@ TEST(Configuration, GetBool) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; EXPECT_EQ(true, (*conf).GetBool("bool.true", true)); EXPECT_EQ(false, (*conf).GetBool("bool.false", false)); } @@ -336,7 +337,7 @@ TEST(Configuration, GetIntException) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; ASSERT_THROW((*conf).GetInt("int.exception", 0), std::runtime_error); } @@ -347,7 +348,7 @@ TEST(Configuration, GetLongException) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; ASSERT_THROW((*conf).GetLong("long.exception", 0), std::runtime_error); } @@ -358,7 +359,7 @@ TEST(Configuration, GetDoubleException) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; ASSERT_THROW((*conf).GetDouble("double.exception", 0), std::runtime_error); } @@ -369,6 +370,6 @@ TEST(Configuration, GetBoolException) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf) << "No configuration object present."; + ASSERT_TRUE(conf != nullopt) << "No configuration object present."; ASSERT_THROW((*conf).GetBool("bool.exception", false), std::runtime_error); } diff --git hbase-native-client/core/location-cache-retry-test.cc hbase-native-client/core/location-cache-retry-test.cc index 988f994..f154b69 100644 --- hbase-native-client/core/location-cache-retry-test.cc +++ hbase-native-client/core/location-cache-retry-test.cc @@ -45,7 +45,7 @@ using hbase::Put; using hbase::Table; using hbase::TestUtil; -using std::chrono_literals::operator""s; +using std::chrono_literals::operator"" s; class LocationCacheRetryTest : public ::testing::Test { public: diff --git hbase-native-client/core/result-test.cc hbase-native-client/core/result-test.cc index 3299ffc..dd60aeb 100644 --- hbase-native-client/core/result-test.cc +++ hbase-native-client/core/result-test.cc @@ -30,6 +30,7 @@ using hbase::Cell; using hbase::CellType; using hbase::Result; +using std::experimental::nullopt; void PopulateCells(std::vector > &cells) { // Populate some Results @@ -111,7 +112,7 @@ TEST(Result, FilledResult) { // Value will be nullptr as no such family and qualifier is present ASSERT_FALSE(result.Value("family-4", "qualifier")); // Value will be present as family and qualifier is present - ASSERT_TRUE(result.Value("family-4", "column-4")); + ASSERT_TRUE(result.Value("family-4", "column-4") != nullopt); // Value should be present and match. EXPECT_EQ(latest_cell->Value(), (*result.ColumnLatestCell("family-4", "column-4")).Value()); EXPECT_EQ("value-5", (*result.ColumnLatestCell("family-5", "column-5")).Value());