diff --git a/core/server/master/src/test/java/alluxio/master/AlluxioMasterProcessTest.java b/core/server/master/src/test/java/alluxio/master/AlluxioMasterProcessTest.java
index <HASH>..<HASH> 100644
--- a/core/server/master/src/test/java/alluxio/master/AlluxioMasterProcessTest.java
+++ b/core/server/master/src/test/java/alluxio/master/AlluxioMasterProcessTest.java
@@ -230,6 +230,10 @@ public final class AlluxioMasterProcessTest {
     waitForServing(ServiceType.MASTER_WEB);
     assertTrue(isBound(mRpcPort));
     assertTrue(isBound(mWebPort));
+    boolean testMode = ServerConfiguration.getBoolean(PropertyKey.TEST_MODE);
+    ServerConfiguration.set(PropertyKey.TEST_MODE, false);
+    master.waitForReady(5000);
+    ServerConfiguration.set(PropertyKey.TEST_MODE, testMode);
     master.stop();
     assertFalse(isBound(mRpcPort));
     assertFalse(isBound(mWebPort));
Fix test startStopPrimary failure from time to time

Fix test startStopPrimary failure from time to time

pr-link: Alluxio/alluxio#<I>
change-id: cid-<I>fa<I>be<I>d5f9dd<I>c<I>f<I>d<I>ca<I>b2