geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject [geode] branch develop updated: GEODE-1920 Addition of more logs to the test
Date Thu, 16 Nov 2017 18:20:20 GMT
This is an automated email from the ASF dual-hosted git repository.

nnag pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7f0d5f5  GEODE-1920 Addition of more logs to the test
7f0d5f5 is described below

commit 7f0d5f529c1dc44fecb970a099eb307dd1824235
Author: nabarun <nnag@pivotal.io>
AuthorDate: Wed Oct 25 15:22:09 2017 -0700

    GEODE-1920 Addition of more logs to the test
    
    	* More logs were added at the failure points to figure out what caused a failure.
    	* Refactored by simplifying the code and removing deprecated function calls.
    	* Removed the flaky tag
---
 .../cache/wan/misc/WanAutoDiscoveryDUnitTest.java  | 74 +++++++++++++++-------
 1 file changed, 52 insertions(+), 22 deletions(-)

diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
index 7c13087..9f4dee2 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
@@ -14,16 +14,17 @@
  */
 package org.apache.geode.internal.cache.wan.misc;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.IntStream;
 
 import org.junit.Ignore;
 import org.junit.Test;
@@ -39,10 +40,7 @@ import org.apache.geode.test.dunit.AsyncInvocation;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.LogWriterUtils;
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
 
 @Category(DistributedTest.class)
 public class WanAutoDiscoveryDUnitTest extends WANTestBase {
@@ -234,7 +232,6 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
     vm2.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
   }
 
-  @Category(FlakyTest.class) // GEODE-1920
   @Test
   public void test_NY_Recognises_TK_AND_HK_Simultaneously() {
     Map<Integer, Set<InetSocketAddress>> dsVsPort = new HashMap<>();
@@ -261,27 +258,14 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
     dsVsPort.put(4, locatorPortshk);
     async[1] = vm3.invokeAsync(() -> WANTestBase.createFirstRemoteLocator(4, nyLocPort1));
 
-    ArrayList<Integer> locatorPortsln2 = new ArrayList<Integer>();
     async[2] = vm4.invokeAsync(() -> WANTestBase.createSecondLocator(1, lnLocPort1));
 
-    ArrayList<Integer> locatorPortsny2 = new ArrayList<Integer>();
     async[3] = vm5.invokeAsync(() -> WANTestBase.createSecondLocator(2, nyLocPort1));
 
+    waitForAsyncInvokesToComplete(async);
 
-    try {
-      async[0].join();
-      async[1].join();
-      async[2].join();
-      async[3].join();
-    } catch (InterruptedException e) {
-      e.printStackTrace();
-      fail();
-    }
-
-    locatorPortstk.add(new InetSocketAddress("localhost", (Integer) async[0].getReturnValue()));
-    locatorPortshk.add(new InetSocketAddress("localhost", (Integer) async[1].getReturnValue()));
-    locatorPortsln.add(new InetSocketAddress("localhost", (Integer) async[2].getReturnValue()));
-    locatorPortsny.add(new InetSocketAddress("localhost", (Integer) async[3].getReturnValue()));
+    addPortNumbersToDSPortNumCollection(locatorPortsln, locatorPortsny, async, locatorPortstk,
+        locatorPortshk);
 
     vm0.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
     vm1.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
@@ -289,6 +273,52 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
     vm3.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
   }
 
+  private void addPortNumbersToDSPortNumCollection(Set<InetSocketAddress> locatorPortsln,
+      Set<InetSocketAddress> locatorPortsny, AsyncInvocation[] async,
+      Set<InetSocketAddress> locatorPortstk, Set<InetSocketAddress> locatorPortshk)
{
+    IntStream.range(0, 4).forEach(i -> {
+      Integer portNumber = null;
+      try {
+        portNumber = (Integer) async[i].get();
+        switch (i) {
+          case 0:
+            locatorPortstk.add(new InetSocketAddress("localhost", portNumber));
+            break;
+          case 1:
+            locatorPortshk.add(new InetSocketAddress("localhost", portNumber));
+            break;
+          case 2:
+            locatorPortsln.add(new InetSocketAddress("localhost", portNumber));
+            break;
+          case 3:
+            locatorPortsny.add(new InetSocketAddress("localhost", portNumber));
+            break;
+        }
+      } catch (Exception e) {
+        e.printStackTrace();
+        if (portNumber == null) {
+          fail("No port number was returned for async invocation #" + i);
+        }
+        fail();
+      }
+    });
+  }
+
+  private void waitForAsyncInvokesToComplete(AsyncInvocation[] async) {
+    IntStream.range(0, 4).forEach(i -> {
+      try {
+        async[i].join();
+      } catch (InterruptedException e) {
+        e.printStackTrace();
+        if (async[i].getException() != null) {
+          fail(
+              "Failed in async invocation : " + i + " with Exception : " + async[i].getException());
+        }
+        fail();
+      }
+    });
+  }
+
 
   @Test
   public void test_LN_Sender_recognises_ALL_NY_Locators() {

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message