This is an automated email from the ASF dual-hosted git repository.

stack pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase-native-client.git


The following commit(s) were added to refs/heads/master by this push:
     new 11be99a  HBASE-22201 Fixing a number of issues with test cases (#1)
11be99a is described below

commit 11be99a19713206b70a3367ee25758f4b08924b2
Author: Ian Buss <[email protected]>
AuthorDate: Tue Apr 23 13:52:49 2019 -0400

    HBASE-22201 Fixing a number of issues with test cases (#1)
    
    * fix classpath and meta region spec
    * fix result-test failing on EstimatedSize assertion
    * allow classpath to be set through env var
    * update building instructions
    * use correct classpath file for makefile test execution
    * cleanup env between tests
    * fix cell-tests which don't take string capacity into account with size 
estimates
---
 BUILDING.md                         | 17 +++++++++++++----
 src/hbase/client/meta-utils.cc      |  2 +-
 src/hbase/test-util/mini-cluster.cc |  4 +++-
 src/test/cell-test.cc               |  4 ++--
 src/test/client-test.cc             |  4 ++++
 src/test/result-test.cc             |  2 +-
 6 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/BUILDING.md b/BUILDING.md
index 035af4b..ece6f32 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -41,14 +41,17 @@ However none of them is a must.
 
 # Building using docker
 
+Go into the hbase-native-client directory and run `./bin/start-docker.sh`
+that will build the docker development environment and when complete will
+drop you into a shell on a linux vm with all the dependencies needed installed.
+
 To start with make sure that you have built the java project using
 `mvn package -DskipTests`. That will allow all tests to spin up a standalone
 hbase instance from the jar's created.
 
-Then go into the hbase-native-client directory and run `./bin/start-docker.sh`
-that will build the docker development environment and when complete will
-drop you into a shell on a linux vm with all the dependencies needed installed.
-
+*Note*: you can run the HBase Maven build outside of docker but the cached
+classpath used by the unit tests may not reflect the paths from within the
+docker container.
 
 # CMake
 
@@ -57,3 +60,9 @@ cmake .
 make
 make install
 ```
+
+# Running tests
+
+To run the tests, you can use `make test` or run each compiled test 
individually
+as they are built in the top level directory of the module. For example from 
the
+hbase-native-client directory you can execute `./client-test`.
diff --git a/src/hbase/client/meta-utils.cc b/src/hbase/client/meta-utils.cc
index 338c43e..1d1a631 100644
--- a/src/hbase/client/meta-utils.cc
+++ b/src/hbase/client/meta-utils.cc
@@ -66,7 +66,7 @@ std::unique_ptr<Request> MetaUtil::MetaRequest(const 
TableName tn, const std::st
 
   // Set the region this scan goes to
   auto region = msg->mutable_region();
-  region->set_value(MetaUtil::kMetaRegion);
+  region->set_value(MetaUtil::kMetaRegionName);
   region->set_type(
       
RegionSpecifier_RegionSpecifierType::RegionSpecifier_RegionSpecifierType_ENCODED_REGION_NAME);
 
diff --git a/src/hbase/test-util/mini-cluster.cc 
b/src/hbase/test-util/mini-cluster.cc
index 98a4e7e..0e749c6 100644
--- a/src/hbase/test-util/mini-cluster.cc
+++ b/src/hbase/test-util/mini-cluster.cc
@@ -34,7 +34,7 @@ JNIEnv *MiniCluster::CreateVM(JavaVM **jvm) {
   char *classpath = getenv("CLASSPATH");
   std::string clspath;
   if (classpath == NULL || strstr(classpath, "-tests.jar") == NULL) {
-    std::string clsPathFilePath("../target/cached_classpath.txt");
+    std::string 
clsPathFilePath("../../../hbase-build-configuration/target/cached_classpath.txt");
     std::ifstream fd(clsPathFilePath);
     std::string prefix("");
     if (fd.is_open()) {
@@ -58,6 +58,8 @@ JNIEnv *MiniCluster::CreateVM(JavaVM **jvm) {
       exit(-1);
     }
     fd.close();
+  } else {
+    clspath.assign(classpath, strlen(classpath));
   }
 
   auto options = std::string{"-Djava.class.path="} + clspath;
diff --git a/src/test/cell-test.cc b/src/test/cell-test.cc
index 8a65aa5..d943aaf 100644
--- a/src/test/cell-test.cc
+++ b/src/test/cell-test.cc
@@ -186,10 +186,10 @@ TEST(CellTest, CellEstimatedSize) {
   LOG(INFO) << cell1.EstimatedSize();
 
   EXPECT_TRUE(empty.EstimatedSize() > sizeof(Cell));
-  EXPECT_TRUE(cell1.EstimatedSize() > empty.EstimatedSize());
+  EXPECT_TRUE(cell1.EstimatedSize() >= empty.EstimatedSize());
   EXPECT_EQ(cell1.EstimatedSize(), cell2.EstimatedSize());
   EXPECT_EQ(cell2.EstimatedSize(), cell3.EstimatedSize());
   EXPECT_EQ(cell3.EstimatedSize(), cell4.EstimatedSize());
   EXPECT_EQ(cell4.EstimatedSize(), cell5.EstimatedSize());
-  EXPECT_TRUE(cell6.EstimatedSize() > cell1.EstimatedSize());
+  EXPECT_TRUE(cell6.EstimatedSize() >= cell1.EstimatedSize());
 }
diff --git a/src/test/client-test.cc b/src/test/client-test.cc
index b1d5180..03a6788 100644
--- a/src/test/client-test.cc
+++ b/src/test/client-test.cc
@@ -47,6 +47,10 @@ using hbase::Table;
 using hbase::TestUtil;
 
 class ClientTest : public ::testing::Test {
+ protected:
+  ~ClientTest() override {
+    unsetenv("HBASE_CONF");
+  }
  public:
   static const constexpr char *kDefHBaseConfPath = 
"./build/test-data/client-test/conf/";
   static const constexpr char *kHBaseDefaultXml = "hbase-default.xml";
diff --git a/src/test/result-test.cc b/src/test/result-test.cc
index 3857d7b..81bc1c2 100644
--- a/src/test/result-test.cc
+++ b/src/test/result-test.cc
@@ -307,7 +307,7 @@ TEST(Result, ResultEstimatedSize) {
   std::vector<std::shared_ptr<Cell> > cells;
   Result empty(cells, true, false, false);
 
-  EXPECT_EQ(empty.EstimatedSize(), sizeof(Result));
+  EXPECT_EQ(empty.EstimatedSize(), sizeof(Result) + empty.Row().capacity());
 
   cells.push_back(std::make_shared<Cell>("a", "a", "", timestamp, "", 
cell_type));
   Result result1(cells, true, false, false);

Reply via email to