Repository: ambari
Updated Branches:
  refs/heads/trunk be6cd59af -> 8335312d0


AMBARI-18845 TestHeartbeatHandler.testRegistrationRecoveryConfig is Flaky (dsen)


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

Branch: refs/heads/trunk
Commit: 8335312d0527582bdb6701cfb1709a35b553b682
Parents: be6cd59
Author: Dmytro Sen <[email protected]>
Authored: Thu Nov 10 16:49:53 2016 +0200
Committer: Dmytro Sen <[email protected]>
Committed: Thu Nov 10 16:49:53 2016 +0200

----------------------------------------------------------------------
 .../ambari/server/agent/TestHeartbeatHandler.java  | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8335312d/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
index e50b8c9..a50a116 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
@@ -374,13 +374,7 @@ public class TestHeartbeatHandler {
   }
 
   @Test
-  public void testRegistrationRecoveryConfig() throws Exception,
-      InvalidStateTransitionException {
-    ActionManager am = actionManagerTestHelper.getMockActionManager();
-    replay(am);
-    Clusters fsm = clusters;
-    HeartBeatHandler handler = new HeartBeatHandler(fsm, new ActionQueue(), am,
-                                                    injector);
+  public void testRegistrationRecoveryConfig() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
 
@@ -395,6 +389,15 @@ public class TestHeartbeatHandler {
     hdfs.addServiceComponent(HDFS_CLIENT);
     
hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1);
 
+    // Create helper after creating service to avoid race condition caused by 
asynchronous recovery configs
+    // timestamp invalidation 
(RecoveryConfigHelper.handleServiceComponentInstalledEvent())
+    ActionManager am = actionManagerTestHelper.getMockActionManager();
+    replay(am);
+    Clusters fsm = clusters;
+    HeartBeatHandler handler = new HeartBeatHandler(fsm, new ActionQueue(), am,
+        injector);
+    handler.start();
+
     Host hostObject = clusters.getHost(DummyHostname1);
     hostObject.setIPv4("ipv4");
     hostObject.setIPv6("ipv6");

Reply via email to