geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kh...@apache.org
Subject [01/35] geode git commit: GEODE-2593: add port range to AvailablePortHelper to fix testUDPPortRange
Date Tue, 28 Mar 2017 16:46:29 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2420 f3a5374f0 -> 704fdbcb6


GEODE-2593: add port range to AvailablePortHelper to fix testUDPPortRange


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

Branch: refs/heads/feature/GEODE-2420
Commit: a90094862d2b485b08bec6283476d5e6c7ecdc8d
Parents: f3a5374
Author: Kirk Lund <klund@apache.org>
Authored: Fri Mar 3 17:36:07 2017 -0800
Committer: Ken Howe <khowe@pivotal.io>
Committed: Mon Mar 27 13:57:31 2017 -0700

----------------------------------------------------------------------
 .../distributed/DistributedSystemDUnitTest.java | 79 +++++++++-----------
 1 file changed, 37 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/a9009486/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
index 9a64f53..8b669f3 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
@@ -14,32 +14,9 @@
  */
 package org.apache.geode.distributed;
 
-import static java.lang.Integer.parseInt;
-import static java.net.NetworkInterface.getNetworkInterfaces;
 import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.distributed.internal.DistributionConfig.*;
-import static org.apache.geode.distributed.internal.DistributionManager.*;
 import static org.apache.geode.internal.AvailablePort.*;
-import static org.apache.geode.internal.AvailablePortHelper.*;
-import static org.apache.geode.internal.net.SocketCreator.getLocalHost;
-import static org.apache.geode.test.dunit.DistributedTestUtils.getDUnitLocatorPort;
-import static org.apache.geode.test.dunit.Host.getHost;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-import static org.assertj.core.api.Assertions.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-import java.util.Properties;
+import static org.junit.Assert.*;
 
 import org.apache.geode.CancelException;
 import org.apache.geode.GemFireConfigException;
@@ -47,6 +24,9 @@ import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
+import org.apache.geode.cache30.CacheSerializableRunnable;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.DistributionException;
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.SerialDistributionMessage;
@@ -55,33 +35,40 @@ import org.apache.geode.distributed.internal.membership.InternalDistributedMembe
 import org.apache.geode.distributed.internal.membership.gms.MembershipManagerHelper;
 import org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger;
 import org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager;
+import org.apache.geode.internal.AvailablePort;
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.net.SocketCreator;
+import org.apache.geode.test.dunit.DistributedTestUtils;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.LogWriterUtils;
+import org.apache.geode.test.dunit.RMIException;
+import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.MembershipTest;
 
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.concurrent.TimeoutException;
+
 /**
  * Tests the functionality of the {@link DistributedSystem} class.
  */
 @Category({DistributedTest.class, MembershipTest.class})
 public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
 
-  private int mcastPort;
-  private int locatorPort;
-  private int tcpPort;
-  private int lowerBoundOfPortRange;
-  private int upperBoundOfPortRange;
-
   @Before
   public void before() throws Exception {
     disconnectAllFromDS();
-
-    this.mcastPort = getRandomAvailablePort(MULTICAST);
-    this.locatorPort = getRandomAvailablePort(SOCKET);
-    this.tcpPort = getRandomAvailablePort(SOCKET);
-
-    int[] portRange = getRandomAvailableTCPPortRange(3, true);
-    this.lowerBoundOfPortRange = portRange[0];
-    this.upperBoundOfPortRange = portRange[portRange.length - 1];
   }
 
   @After
@@ -248,14 +235,22 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase
{
 
   @Test
   public void testUDPPortRange() throws Exception {
+    int[] unicastPort = AvailablePortHelper.getRandomAvailableTCPPortRange(3, true);
+
     Properties config = new Properties();
-    config.put(LOCATORS, "localhost[" + getDUnitLocatorPort() + "]");
-    config.setProperty(MEMBERSHIP_PORT_RANGE,
-        this.lowerBoundOfPortRange + "-" + this.upperBoundOfPortRange);
+    config.put(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
+    // Minimum 3 ports required in range for UDP, FD_SOCK and TcpConduit.
+    config.setProperty(MEMBERSHIP_PORT_RANGE, unicastPort[0] + "-" + unicastPort[2]);
 
     InternalDistributedSystem system = getSystem(config);
     DistributionManager dm = (DistributionManager) system.getDistributionManager();
-    InternalDistributedMember member = dm.getDistributionManagerId();
+    InternalDistributedMember idm = dm.getDistributionManagerId();
+
+    assertTrue(unicastPort[0] <= idm.getPort() && idm.getPort() <= unicastPort[2]);
+    assertTrue(unicastPort[0] <= idm.getPort() && idm.getDirectChannelPort() <=
unicastPort[2]);
+
+    system.disconnect();
+  }
 
     verifyMembershipPortsInRange(member, this.lowerBoundOfPortRange, this.upperBoundOfPortRange);
   }


Mime
View raw message