Repository: ambari Updated Branches: refs/heads/branch-2.2.2 e2634cde5 -> 900b4fc63
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/900b4fc6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/900b4fc6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/900b4fc6 Branch: refs/heads/branch-2.2.2 Commit: 900b4fc633d0d9bca1f4e30cb97edec37e824b3d Parents: e2634cd Author: Siddharth Wagle <swa...@hortonworks.com> Authored: Fri Apr 15 10:34:50 2016 -0700 Committer: Siddharth Wagle <swa...@hortonworks.com> Committed: Fri Apr 15 10:34:50 2016 -0700 ---------------------------------------------------------------------- .../TimelineMetricMetadataManager.java | 1 - .../timeline/AbstractMiniHBaseClusterTest.java | 56 +++++++++++++------- .../timeline/ITPhoenixHBaseAccessor.java | 32 ----------- .../timeline/discovery/TestMetadataManager.java | 2 +- 4 files changed, 38 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/900b4fc6/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 8e58203..50f7518 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 @@ -24,7 +24,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.Collection; import java.util.HashSet; http://git-wip-us.apache.org/repos/asf/ambari/blob/900b4fc6/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/900b4fc6/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 f8e4c94..c729162 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/900b4fc6/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 bf887be..92e4dfc 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 @@ -72,7 +72,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();