You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by kh...@apache.org on 2016/10/06 00:18:51 UTC

[22/38] hive git commit: HIVE-14810. Fix failing test: TestMetaStoreMetrics.testMetaDataCounts. (Barna Zsombor Klara, reviewed by Siddharth Seth)

HIVE-14810. Fix failing test: TestMetaStoreMetrics.testMetaDataCounts. (Barna Zsombor Klara, reviewed by Siddharth Seth)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/b86342f0
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/b86342f0
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/b86342f0

Branch: refs/heads/repl2
Commit: b86342f0d44be9655c2d44b8cf666e540969afca
Parents: 84e4974
Author: Siddharth Seth <ss...@apache.org>
Authored: Mon Oct 3 11:06:07 2016 -0700
Committer: Siddharth Seth <ss...@apache.org>
Committed: Mon Oct 3 11:06:07 2016 -0700

----------------------------------------------------------------------
 .../metastore/TestHiveMetaStoreStatsMerge.java  |  2 +-
 .../hive/metastore/TestMetaStoreMetrics.java    | 21 +++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/b86342f0/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreStatsMerge.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreStatsMerge.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreStatsMerge.java
index d6df32b..600aef4 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreStatsMerge.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreStatsMerge.java
@@ -66,7 +66,7 @@ public class TestHiveMetaStoreStatsMerge extends TestCase {
   private final Database db = new Database();
   private Table table = new Table();
 
-  private static final String dbName = "hive3252";
+  private static final String dbName = "hive3253";
   private static final String tblName = "tmptbl";
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b86342f0/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java
index f231af7..b462b2a 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java
@@ -77,6 +77,16 @@ public class TestMetaStoreMetrics {
 
   @Test
   public void testMetaDataCounts() throws Exception {
+    CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance();
+    String json = metrics.dumpJson();
+
+    int initDbCount = (new Integer((MetricsTestUtils.getJsonNode(json, MetricsTestUtils.GAUGE,
+        MetricsConstant.INIT_TOTAL_DATABASES)).asText())).intValue();
+    int initTblCount = (new Integer((MetricsTestUtils.getJsonNode(json, MetricsTestUtils.GAUGE,
+        MetricsConstant.INIT_TOTAL_TABLES)).asText())).intValue();
+    int initPartCount = (new Integer((MetricsTestUtils.getJsonNode(json, MetricsTestUtils.GAUGE,
+        MetricsConstant.INIT_TOTAL_PARTITIONS)).asText())).intValue();
+
     //1 databases created
     driver.run("create database testdb1");
 
@@ -113,9 +123,7 @@ public class TestMetaStoreMetrics {
     driver.run("use default");
     driver.run("drop database tempdb cascade");
 
-    //give timer thread a chance to print the metrics
-    CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance();
-    String json = metrics.dumpJson();
+    json = metrics.dumpJson();
     MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_DATABASES, 2);
     MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_TABLES, 7);
     MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_PARTITIONS, 9);
@@ -130,11 +138,10 @@ public class TestMetaStoreMetrics {
     baseHandler.init();
     baseHandler.updateMetrics();
 
-    //1 new db + default
     json = metrics.dumpJson();
-    MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.GAUGE, MetricsConstant.INIT_TOTAL_DATABASES, 2);
-    MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.GAUGE, MetricsConstant.INIT_TOTAL_TABLES, 4);
-    MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.GAUGE, MetricsConstant.INIT_TOTAL_PARTITIONS, 6);
+    MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.GAUGE, MetricsConstant.INIT_TOTAL_DATABASES, initDbCount + 1);
+    MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.GAUGE, MetricsConstant.INIT_TOTAL_TABLES, initTblCount + 4);
+    MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.GAUGE, MetricsConstant.INIT_TOTAL_PARTITIONS, initPartCount + 6);
   }