ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject ambari git commit: AMBARI-8946. Fix non-deterministic unit test in Flume sink. (swagle)
Date Mon, 29 Dec 2014 22:35:38 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 19e972cf9 -> cbbd413c9


AMBARI-8946. Fix non-deterministic unit test in Flume sink. (swagle)


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

Branch: refs/heads/trunk
Commit: cbbd413c9d11449fdc87cb664931272da225003b
Parents: 19e972c
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Mon Dec 29 14:31:04 2014 -0800
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Mon Dec 29 14:31:04 2014 -0800

----------------------------------------------------------------------
 .../sink/flume/FlumeTimelineMetricsSink.java    |  2 +-
 .../flume/FlumeTimelineMetricsSinkTest.java     | 38 +++++++-------------
 .../common-services/AMS/0.1.0/metainfo.xml      |  2 +-
 3 files changed, 15 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/cbbd413c/ambari-metrics/ambari-metrics-flume-sink/src/main/java/org/apache/hadoop/metrics2/sink/flume/FlumeTimelineMetricsSink.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-flume-sink/src/main/java/org/apache/hadoop/metrics2/sink/flume/FlumeTimelineMetricsSink.java
b/ambari-metrics/ambari-metrics-flume-sink/src/main/java/org/apache/hadoop/metrics2/sink/flume/FlumeTimelineMetricsSink.java
index 87c4ab8..d28b345 100644
--- a/ambari-metrics/ambari-metrics-flume-sink/src/main/java/org/apache/hadoop/metrics2/sink/flume/FlumeTimelineMetricsSink.java
+++ b/ambari-metrics/ambari-metrics-flume-sink/src/main/java/org/apache/hadoop/metrics2/sink/flume/FlumeTimelineMetricsSink.java
@@ -116,7 +116,7 @@ public class FlumeTimelineMetricsSink extends AbstractTimelineMetricsSink
implem
    * org.apache.flume. All attributes of such beans are sent
    * to the metrics collector service.
    */
-  private class TimelineMetricsCollector implements Runnable {
+  class TimelineMetricsCollector implements Runnable {
     @Override
     public void run() {
       LOG.debug("Collecting Metrics for Flume");

http://git-wip-us.apache.org/repos/asf/ambari/blob/cbbd413c/ambari-metrics/ambari-metrics-flume-sink/src/test/java/org/apache/hadoop/metrics2/sink/flume/FlumeTimelineMetricsSinkTest.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-flume-sink/src/test/java/org/apache/hadoop/metrics2/sink/flume/FlumeTimelineMetricsSinkTest.java
b/ambari-metrics/ambari-metrics-flume-sink/src/test/java/org/apache/hadoop/metrics2/sink/flume/FlumeTimelineMetricsSinkTest.java
index ad59576..90831bf 100644
--- a/ambari-metrics/ambari-metrics-flume-sink/src/test/java/org/apache/hadoop/metrics2/sink/flume/FlumeTimelineMetricsSinkTest.java
+++ b/ambari-metrics/ambari-metrics-flume-sink/src/test/java/org/apache/hadoop/metrics2/sink/flume/FlumeTimelineMetricsSinkTest.java
@@ -38,34 +38,26 @@ public class FlumeTimelineMetricsSinkTest {
   @Test
   public void testNonNumericMetricMetricExclusion() throws InterruptedException {
     FlumeTimelineMetricsSink flumeTimelineMetricsSink = new FlumeTimelineMetricsSink();
-    TimelineMetricsCache timelineMetricsCache = getTimelineMetricsCache(flumeTimelineMetricsSink);
-    flumeTimelineMetricsSink.setPollFrequency(1);
-    HttpClient httpClient = EasyMock.createNiceMock(HttpClient.class);
-    flumeTimelineMetricsSink.setHttpClient(httpClient);
+    FlumeTimelineMetricsSink.TimelineMetricsCollector collector =
+      flumeTimelineMetricsSink.new TimelineMetricsCollector();
     mockStatic(JMXPollUtil.class);
     EasyMock.expect(JMXPollUtil.getAllMBeans()).andReturn(
         Collections.singletonMap("component1", Collections.singletonMap("key1", "value1"))).once();
-    replay(JMXPollUtil.class, timelineMetricsCache, httpClient);
-    flumeTimelineMetricsSink.start();
-    Thread.sleep(5);
-    flumeTimelineMetricsSink.stop();
+    replay(JMXPollUtil.class);
+    collector.run();
     verifyAll();
   }
 
   @Test
-  public void testNumericMetricMetricSubmission() throws InterruptedException {
+  public void testNumericMetricSubmission() throws InterruptedException {
     FlumeTimelineMetricsSink flumeTimelineMetricsSink = new FlumeTimelineMetricsSink();
-    TimelineMetricsCache timelineMetricsCache = getTimelineMetricsCache(flumeTimelineMetricsSink);
-    flumeTimelineMetricsSink.setPollFrequency(1);
-    HttpClient httpClient = EasyMock.createNiceMock(HttpClient.class);
-    flumeTimelineMetricsSink.setHttpClient(httpClient);
+    FlumeTimelineMetricsSink.TimelineMetricsCollector collector =
+      flumeTimelineMetricsSink.new TimelineMetricsCollector();
     mockStatic(JMXPollUtil.class);
     EasyMock.expect(JMXPollUtil.getAllMBeans()).andReturn(
         Collections.singletonMap("component1", Collections.singletonMap("key1", "42"))).once();
-    replay(JMXPollUtil.class, timelineMetricsCache, httpClient);
-    flumeTimelineMetricsSink.start();
-    Thread.sleep(5);
-    flumeTimelineMetricsSink.stop();
+    replay(JMXPollUtil.class);
+    collector.run();
     verifyAll();
   }
 
@@ -101,17 +93,13 @@ public class FlumeTimelineMetricsSinkTest {
   @Test
   public void testMetricsRetrievalExceptionTolerance() throws InterruptedException {
     FlumeTimelineMetricsSink flumeTimelineMetricsSink = new FlumeTimelineMetricsSink();
-    TimelineMetricsCache timelineMetricsCache = getTimelineMetricsCache(flumeTimelineMetricsSink);
-    flumeTimelineMetricsSink.setPollFrequency(1);
-    HttpClient httpClient = EasyMock.createNiceMock(HttpClient.class);
-    flumeTimelineMetricsSink.setHttpClient(httpClient);
+    FlumeTimelineMetricsSink.TimelineMetricsCollector collector =
+      flumeTimelineMetricsSink.new TimelineMetricsCollector();
     mockStatic(JMXPollUtil.class);
     EasyMock.expect(JMXPollUtil.getAllMBeans()).
         andThrow(new RuntimeException("Failed to retrieve Flume Properties")).once();
-    replay(JMXPollUtil.class, timelineMetricsCache, httpClient);
-    flumeTimelineMetricsSink.start();
-    Thread.sleep(5);
-    flumeTimelineMetricsSink.stop();
+    replay(JMXPollUtil.class);
+    collector.run();
     verifyAll();
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/cbbd413c/ambari-server/src/main/resources/common-services/AMS/0.1.0/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/AMS/0.1.0/metainfo.xml b/ambari-server/src/main/resources/common-services/AMS/0.1.0/metainfo.xml
index 3c87fd7..3551da8 100644
--- a/ambari-server/src/main/resources/common-services/AMS/0.1.0/metainfo.xml
+++ b/ambari-server/src/main/resources/common-services/AMS/0.1.0/metainfo.xml
@@ -31,7 +31,7 @@
           <name>METRIC_COLLECTOR</name>
           <displayName>Metric Collector</displayName>
           <category>MASTER</category>
-          <cardinality>1+</cardinality>
+          <cardinality>1</cardinality>
           <dependencies>
             <dependency>
               <name>ZOOKEEPER/ZOOKEEPER_SERVER</name>


Mime
View raw message