You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2016/04/15 19:22:48 UTC

ambari git commit: AMBARI-15923. Metrics Unit Tests Failing on b.a.o. (swagle)

Repository: ambari
Updated Branches:
  refs/heads/trunk f2cf51706 -> eb4a4e080


AMBARI-15923. Metrics Unit Tests Failing on b.a.o. (swagle)


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

Branch: refs/heads/trunk
Commit: eb4a4e080860fb12a64614340f0390f926adb551
Parents: f2cf517
Author: Siddharth Wagle <sw...@hortonworks.com>
Authored: Fri Apr 15 10:23:01 2016 -0700
Committer: Siddharth Wagle <sw...@hortonworks.com>
Committed: Fri Apr 15 10:23:08 2016 -0700

----------------------------------------------------------------------
 .../TimelineMetricMetadataManager.java          |  3 --
 .../timeline/AbstractMiniHBaseClusterTest.java  | 56 +++++++++++++-------
 .../timeline/ITPhoenixHBaseAccessor.java        | 32 -----------
 .../TimelineMetricHAControllerTest.java         |  2 +-
 .../timeline/discovery/TestMetadataManager.java |  5 +-
 5 files changed, 39 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/eb4a4e08/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/discovery/TimelineMetricMetadataManager.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/discovery/TimelineMetricMetadataManager.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/discovery/TimelineMetricMetadataManager.java
index a39fcb6..3d28c27 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/discovery/TimelineMetricMetadataManager.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/discovery/TimelineMetricMetadataManager.java
@@ -25,7 +25,6 @@ import org.apache.hadoop.metrics2.sink.timeline.MetadataException;
 import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric;
 import org.apache.hadoop.metrics2.sink.timeline.TimelineMetricMetadata;
 import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.PhoenixHBaseAccessor;
-
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -39,8 +38,6 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.regex.Matcher;
-
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.DISABLE_METRIC_METADATA_MGMT;
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.METRICS_METADATA_SYNC_INIT_DELAY;
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.METRICS_METADATA_SYNC_SCHEDULE_DELAY;

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb4a4e08/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/AbstractMiniHBaseClusterTest.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/AbstractMiniHBaseClusterTest.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/AbstractMiniHBaseClusterTest.java
index 7410e9d..b0dba17 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/AbstractMiniHBaseClusterTest.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/AbstractMiniHBaseClusterTest.java
@@ -99,40 +99,58 @@ public abstract class AbstractMiniHBaseClusterTest extends BaseTest {
     hdb.initMetricSchema();
   }
 
+  private void deleteTableIgnoringExceptions(Statement stmt, String tableName) {
+    try {
+      stmt.execute("delete from " + tableName);
+    } catch (Exception e) {
+      LOG.warn("Exception on delete table " + tableName, e);
+    }
+  }
+
   @After
-  public void tearDown() throws Exception {
+  public void tearDown() {
     Connection conn = null;
     Statement stmt = null;
     try {
       conn = getConnection(getUrl());
       stmt = conn.createStatement();
 
-      stmt.execute("delete from METRIC_AGGREGATE");
-      stmt.execute("delete from METRIC_AGGREGATE_MINUTE");
-      stmt.execute("delete from METRIC_AGGREGATE_HOURLY");
-      stmt.execute("delete from METRIC_AGGREGATE_DAILY");
-      stmt.execute("delete from METRIC_RECORD");
-      stmt.execute("delete from METRIC_RECORD_MINUTE");
-      stmt.execute("delete from METRIC_RECORD_HOURLY");
-      stmt.execute("delete from METRIC_RECORD_DAILY");
-      stmt.execute("delete from METRICS_METADATA");
-      stmt.execute("delete from HOSTED_APPS_METADATA");
+      deleteTableIgnoringExceptions(stmt, "METRIC_AGGREGATE");
+      deleteTableIgnoringExceptions(stmt, "METRIC_AGGREGATE_MINUTE");
+      deleteTableIgnoringExceptions(stmt, "METRIC_AGGREGATE_HOURLY");
+      deleteTableIgnoringExceptions(stmt, "METRIC_AGGREGATE_DAILY");
+      deleteTableIgnoringExceptions(stmt, "METRIC_RECORD");
+      deleteTableIgnoringExceptions(stmt, "METRIC_RECORD_MINUTE");
+      deleteTableIgnoringExceptions(stmt, "METRIC_RECORD_HOURLY");
+      deleteTableIgnoringExceptions(stmt, "METRIC_RECORD_DAILY");
+      deleteTableIgnoringExceptions(stmt, "METRICS_METADATA");
+      deleteTableIgnoringExceptions(stmt, "HOSTED_APPS_METADATA");
 
       conn.commit();
-    } finally {
+    } catch (Exception e) {
+      LOG.warn("Error on deleting HBase schema.", e);
+    }  finally {
       if (stmt != null) {
-        stmt.close();
+        try {
+          stmt.close();
+        } catch (SQLException e) {
+          // Ignore
+        }
       }
 
       if (conn != null) {
-        conn.close();
+        try {
+          conn.close();
+        } catch (SQLException e) {
+          // Ignore
+        }
       }
     }
-  }
-
-  @After
-  public void cleanUpAfterTest() throws Exception {
-    deletePriorTables(HConstants.LATEST_TIMESTAMP, getUrl());
+    try {
+      deletePriorTables(HConstants.LATEST_TIMESTAMP, getUrl());
+    } catch (Exception e) {
+      LOG.warn("Failed in delete prior tables.", e);
+    }
   }
 
   public static Map<String, String> getDefaultProps() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb4a4e08/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITPhoenixHBaseAccessor.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITPhoenixHBaseAccessor.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITPhoenixHBaseAccessor.java
index e6a360a..f61d619 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITPhoenixHBaseAccessor.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITPhoenixHBaseAccessor.java
@@ -35,15 +35,11 @@ import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.
 import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.discovery.TimelineMetricMetadataManager;
 import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.Condition;
 import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.DefaultCondition;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 import java.io.IOException;
 import java.lang.reflect.Field;
-import java.sql.Connection;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -61,38 +57,10 @@ import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.ti
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.PhoenixTransactSQL.METRICS_AGGREGATE_MINUTE_TABLE_NAME;
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.PhoenixTransactSQL.METRICS_RECORD_TABLE_NAME;
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.PhoenixTransactSQL.PHOENIX_TABLES;
-import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.TIMELINE_METRICS_TABLES_DURABILITY;
 
 
 
 public class ITPhoenixHBaseAccessor extends AbstractMiniHBaseClusterTest {
-  private Connection conn;
-  private PhoenixHBaseAccessor hdb;
-
-  @Before
-  public void setUp() throws Exception {
-    hdb = createTestableHBaseAccessor();
-    // inits connection, starts mini cluster
-    conn = getConnection(getUrl());
-
-    hdb.initMetricSchema();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    Connection conn = getConnection(getUrl());
-    Statement stmt = conn.createStatement();
-
-    stmt.execute("delete from METRIC_AGGREGATE");
-    stmt.execute("delete from METRIC_AGGREGATE_HOURLY");
-    stmt.execute("delete from METRIC_RECORD");
-    stmt.execute("delete from METRIC_RECORD_HOURLY");
-    stmt.execute("delete from METRIC_RECORD_MINUTE");
-    conn.commit();
-
-    stmt.close();
-    conn.close();
-  }
 
   @Test
   public void testGetMetricRecordsSeconds() throws IOException, SQLException {

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb4a4e08/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/availability/TimelineMetricHAControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/availability/TimelineMetricHAControllerTest.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/availability/TimelineMetricHAControllerTest.java
index 04e8909..ecfa6bd 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/availability/TimelineMetricHAControllerTest.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/availability/TimelineMetricHAControllerTest.java
@@ -58,7 +58,7 @@ public class TimelineMetricHAControllerTest extends AbstractMiniHBaseClusterTest
     replay(configuration);
   }
 
-  @Test(timeout = 150000)
+  @Test(timeout = 180000)
   public void testHAControllerDistributedAggregation() throws Exception {
     TimelineMetricHAController haController = new TimelineMetricHAController(configuration);
     haController.initializeHAController();

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb4a4e08/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/discovery/TestMetadataManager.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/discovery/TestMetadataManager.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/discovery/TestMetadataManager.java
index 2b33cb95..06c71c5 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/discovery/TestMetadataManager.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/discovery/TestMetadataManager.java
@@ -50,9 +50,6 @@ import static org.easymock.EasyMock.verify;
 public class TestMetadataManager extends AbstractMiniHBaseClusterTest {
   TimelineMetricMetadataManager metadataManager;
 
-
-
-
   @Before
   public void insertDummyRecords() throws IOException, SQLException {
     // Initialize new manager
@@ -90,7 +87,7 @@ public class TestMetadataManager extends AbstractMiniHBaseClusterTest {
     hdb.insertMetricRecordsWithMetadata(metadataManager, timelineMetrics);
   }
 
-  @Test
+  @Test(timeout = 180000)
   public void testSaveMetricsMetadata() throws Exception {
     Map<TimelineMetricMetadataKey, TimelineMetricMetadata> cachedData = metadataManager.getMetadataCache();