You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by av...@apache.org on 2016/03/07 22:14:09 UTC
ambari git commit: AMBARI-15323 : Fix AbstractTimelineAggregatorTest
intermittent unit test failure (avijayan)
Repository: ambari
Updated Branches:
refs/heads/branch-2.2 768e93666 -> 5eee18fd3
AMBARI-15323 : Fix AbstractTimelineAggregatorTest intermittent unit test failure (avijayan)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/5eee18fd
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5eee18fd
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5eee18fd
Branch: refs/heads/branch-2.2
Commit: 5eee18fd3c185c7cb0a9b7934d5682bf28045da2
Parents: 768e936
Author: Aravindan Vijayan <av...@hortonworks.com>
Authored: Mon Mar 7 13:14:00 2016 -0800
Committer: Aravindan Vijayan <av...@hortonworks.com>
Committed: Mon Mar 7 13:14:00 2016 -0800
----------------------------------------------------------------------
.../AbstractTimelineAggregatorTest.java | 22 +++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/5eee18fd/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/AbstractTimelineAggregatorTest.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/AbstractTimelineAggregatorTest.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/AbstractTimelineAggregatorTest.java
index 8f7320b..21b9839 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/AbstractTimelineAggregatorTest.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/AbstractTimelineAggregatorTest.java
@@ -43,7 +43,7 @@ public class AbstractTimelineAggregatorTest {
@Before
public void setUp() throws Exception {
- sleepIntervalMillis = 2*2*30000l; //2 minutes
+ sleepIntervalMillis = 5*60*1000l; //5 minutes
checkpointCutOffMultiplier = 2;
Configuration metricsConf = new Configuration();
@@ -112,10 +112,12 @@ public class AbstractTimelineAggregatorTest {
public void testDoWorkOnZeroDelay() throws Exception {
long currentTime = System.currentTimeMillis();
- long roundedOffAggregatorTime = AbstractTimelineAggregator.getRoundedAggregateTimeMillis(currentTime);
-
+ long roundedOffAggregatorTime = AbstractTimelineAggregator.getRoundedCheckPointTimeMillis(currentTime,
+ sleepIntervalMillis);
+
//Test first run of aggregator with no checkpoint
- agg.setLastAggregatedEndTime(roundedOffAggregatorTime);
+ checkPoint.set(-1);
+ agg.setLastAggregatedEndTime(-1l);
agg.runOnce(sleepIntervalMillis);
assertEquals("startTime should be zero", 0, startTimeInDoWork.get());
assertEquals("endTime should be zero", 0, endTimeInDoWork.get());
@@ -123,7 +125,9 @@ public class AbstractTimelineAggregatorTest {
assertEquals("Do not aggregate on first run", 0, actualRuns);
//Test first run with Too Old checkpoint
- checkPoint.set(currentTime - 5*60*1000); //Old checkpoint
+ currentTime = System.currentTimeMillis();
+ checkPoint.set(currentTime - 16*60*1000); //Old checkpoint
+ agg.setLastAggregatedEndTime(-1l);
agg.runOnce(sleepIntervalMillis);
assertEquals("startTime should be zero", 0, startTimeInDoWork.get());
assertEquals("endTime should be zero", 0, endTimeInDoWork.get());
@@ -132,7 +136,7 @@ public class AbstractTimelineAggregatorTest {
//Test first run with too "recent" checkpoint
currentTime = System.currentTimeMillis();
- checkPoint.set(currentTime - 30000);
+ checkPoint.set(currentTime);
agg.setLastAggregatedEndTime(-1l);
agg.setSleepIntervalMillis(sleepIntervalMillis);
agg.runOnce(sleepIntervalMillis);
@@ -142,6 +146,9 @@ public class AbstractTimelineAggregatorTest {
assertEquals("Do not aggregate on first run", 0, actualRuns);
//Test first run with perfect checkpoint (sleepIntervalMillis back)
+ currentTime = System.currentTimeMillis();
+ roundedOffAggregatorTime = AbstractTimelineAggregator.getRoundedCheckPointTimeMillis(currentTime,
+ sleepIntervalMillis);
long checkPointTime = roundedOffAggregatorTime - sleepIntervalMillis;
long expectedCheckPoint = AbstractTimelineAggregator.getRoundedCheckPointTimeMillis(checkPointTime, sleepIntervalMillis);
checkPoint.set(checkPointTime);
@@ -166,7 +173,8 @@ public class AbstractTimelineAggregatorTest {
expectedCheckPoint + sleepIntervalMillis, endTimeInDoWork.get());
assertEquals(expectedCheckPoint + sleepIntervalMillis,
checkPoint.get());
- assertEquals("Do not aggregate on first run", 2, actualRuns);
+ assertEquals("Aggregate on second run", 2, actualRuns);
+
}
}
\ No newline at end of file