geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hiteshkhame...@apache.org
Subject [11/50] [abbrv] geode git commit: [GEODE-1407] Change a FlakyTest to distributedTest.
Date Tue, 14 Feb 2017 19:31:44 GMT
[GEODE-1407] Change a FlakyTest to distributedTest.

* remove `FlakyTest` from `ReconnectDUnitTest.testReconnectALocator`.
* use Awaitility instead of Wait.


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

Branch: refs/heads/master
Commit: 5604f2b91a7cff1e7d9a2c3754a6f581620b0e45
Parents: 4eb6129
Author: Galen O'Sullivan <gosullivan@pivotal.io>
Authored: Tue Dec 13 14:49:25 2016 -0800
Committer: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Committed: Tue Jan 24 09:52:19 2017 -0800

----------------------------------------------------------------------
 .../geode/cache30/ReconnectDUnitTest.java       | 34 ++++++++------------
 1 file changed, 13 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/5604f2b9/geode-core/src/test/java/org/apache/geode/cache30/ReconnectDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/ReconnectDUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache30/ReconnectDUnitTest.java
index d0ca831..7f422d7 100755
--- a/geode-core/src/test/java/org/apache/geode/cache30/ReconnectDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache30/ReconnectDUnitTest.java
@@ -14,10 +14,12 @@
  */
 package org.apache.geode.cache30;
 
+import com.jayway.awaitility.Awaitility;
 import org.junit.Ignore;
 import org.junit.experimental.categories.Category;
 import org.junit.Test;
 
+import static org.hamcrest.Matchers.notNullValue;
 import static org.junit.Assert.*;
 
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
@@ -42,7 +44,6 @@ import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
 import org.apache.geode.test.dunit.*;
-import org.apache.geode.test.junit.categories.FlakyTest;
 
 import java.io.File;
 import java.io.FileWriter;
@@ -476,8 +477,6 @@ public class ReconnectDUnitTest extends JUnit4CacheTestCase {
         });
   }
 
-
-  @Category(FlakyTest.class) // GEODE-1407
   @Test
   public void testReconnectALocator() throws Exception {
     Host host = Host.getHost(0);
@@ -524,7 +523,6 @@ public class ReconnectDUnitTest extends JUnit4CacheTestCase {
     SerializableCallable create1 =
         new SerializableCallable("Create Cache and Regions from cache.xml") {
           public Object call() throws CacheException {
-            // DebuggerSupport.waitForJavaDebugger(getLogWriter(), " about to create region");
             locatorPort = locPort;
             Properties props = getDistributedSystemProperties();
             props.put(CACHE_XML_FILE, xmlFileLoc + fileSeparator + "MyDisconnect-cache.xml");
@@ -534,41 +532,35 @@ public class ReconnectDUnitTest extends JUnit4CacheTestCase {
             Cache cache = getCache();
             Region myRegion = cache.getRegion("root/myRegion");
             myRegion.put("MyKey1", "MyValue1");
-            // myRegion.put("Mykey2", "MyValue2");
             return savedSystem.getDistributedMember();
           }
         };
     vm1.invoke(create1);
 
-
     try {
-
       dm = getDMID(vm0);
       createGfshWaitingThread(vm0);
       forceDisconnect(vm0);
       newdm = waitForReconnect(vm0);
       assertGfshWaitingThreadAlive(vm0);
 
-      vm0.invoke(new SerializableRunnable("check for running locator") {
-        public void run() {
-          WaitCriterion wc = new WaitCriterion() {
-            public boolean done() {
-              return Locator.getLocator() != null;
-            }
-
-            public String description() {
-              return "waiting for locator to restart";
-            }
-          };
-          Wait.waitForCriterion(wc, 30000, 1000, false);
+      boolean running = (Boolean) vm0.invoke(new SerializableCallable("check for running
locator") {
+        public Object call() {
+          Awaitility.await("waiting for locator to restart").atMost(30, TimeUnit.SECONDS)
+              .until(Locator::getLocator, notNullValue());
           if (Locator.getLocator() == null) {
-            fail("expected to find a running locator but getLocator() returns null");
+            LogWriterUtils.getLogWriter()
+                .error("expected to find a running locator but getLocator() returns null");
+            return false;
           }
           if (((InternalLocator) Locator.getLocator()).isStopped()) {
-            fail("found a stopped locator");
+            LogWriterUtils.getLogWriter().error("found a stopped locator");
+            return false;
           }
+          return true;
         }
       });
+      assertTrue("Expected the restarted member to be hosting a running locator", running);
 
       assertNotSame("expected a reconnect to occur in the locator", dm, newdm);
 


Mime
View raw message