1
0
Selaa lähdekoodia

HADOOP-8257. TestZKFailoverControllerStress occasionally fails with Mockito error. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-3042@1310616 13f79535-47bb-0310-9956-ffa450edef68
Todd Lipcon 13 vuotta sitten
vanhempi
commit
c42a90bd9e

+ 2 - 0
hadoop-common-project/hadoop-common/CHANGES.HDFS-3042.txt

@@ -11,3 +11,5 @@ HADOOP-8228. Auto HA: Refactor tests and add stress tests. (todd)
 HADOOP-8215. Security support for ZK Failover controller (todd)
 
 HADOOP-8245. Fix flakiness in TestZKFailoverController (todd)
+
+HADOOP-8257. TestZKFailoverControllerStress occasionally fails with Mockito error (todd)

+ 7 - 1
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestZKFailoverControllerStress.java

@@ -47,7 +47,6 @@ public class TestZKFailoverControllerStress extends ClientBaseWithFixes {
     conf = new Configuration();
     conf.set(ZKFailoverController.ZK_QUORUM_KEY, hostPort);
     this.cluster = new MiniZKFCCluster(conf, getServer(serverFactory));
-    cluster.start();
   }
   
   @After
@@ -61,6 +60,7 @@ public class TestZKFailoverControllerStress extends ClientBaseWithFixes {
    */
   @Test(timeout=(STRESS_RUNTIME_SECS + EXTRA_TIMEOUT_SECS) * 1000)
   public void testExpireBackAndForth() throws Exception {
+    cluster.start();
     long st = System.currentTimeMillis();
     long runFor = STRESS_RUNTIME_SECS * 1000;
 
@@ -86,6 +86,7 @@ public class TestZKFailoverControllerStress extends ClientBaseWithFixes {
    */
   @Test(timeout=(STRESS_RUNTIME_SECS + EXTRA_TIMEOUT_SECS) * 1000)
   public void testRandomExpirations() throws Exception {
+    cluster.start();
     long st = System.currentTimeMillis();
     long runFor = STRESS_RUNTIME_SECS * 1000;
 
@@ -119,6 +120,11 @@ public class TestZKFailoverControllerStress extends ClientBaseWithFixes {
         .when(cluster.getService(1).proxy).monitorHealth();
     ActiveStandbyElector.NUM_RETRIES = 100;
     
+    // Don't start until after the above mocking. Otherwise we can get
+    // Mockito errors if the HM calls the proxy in the middle of
+    // setting up the mock.
+    cluster.start();
+    
     long st = System.currentTimeMillis();
     while (System.currentTimeMillis() - st < runFor) {
       cluster.getTestContext().checkException();