[ 
https://issues.apache.org/jira/browse/GEODE-8772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17269805#comment-17269805
 ] 

ASF GitHub Bot commented on GEODE-8772:
---------------------------------------

demery-pivotal commented on a change in pull request #5935:
URL: https://github.com/apache/geode/pull/5935#discussion_r562164054



##########
File path: 
geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java
##########
@@ -168,15 +169,18 @@ private CacheServer 
createRegionAndStartCacheServer(String[] regions, Cache cach
   }
 
   private int startManager(final String locators, final String[] regions) 
throws IOException {
+    int[] ports = getRandomAvailableTCPPorts(2);
+    int jmxManagerPort = ports[0];
+    int httpPort = ports[1];
+
     Properties props = new Properties();
     props.setProperty(MCAST_PORT, String.valueOf(0));
     props.setProperty(LOCATORS, locators);
 
     props.setProperty(JMX_MANAGER, "true");
     props.setProperty(JMX_MANAGER_START, "true");
-    props.setProperty(JMX_MANAGER_PORT, "0");
+    props.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxManagerPort));

Review comment:
       That edit might be a mistake. My intention in this PR was to fix only 
uses of default ports.
   
   Note: For this property (according to the docs) 0 means don't allow remote 
client connections. I'll have to look closer at what happens when 0 is 
specified here.
   
   Other note: Using ephemeral ports can reduce the frequency of the race, but 
it doesn't eliminate it, because Geode's membership port range overlaps the 
ephemeral port range. So here's a troubling sequence:
   
   1. Component A "reserves" a port in the membership port range.
   2. Component B (perhaps running in a separate test, a separate member, or 
even a non-Geode process) binds an ephemeral port, and gets the "reserved" port.
   3. Component A tries to bind the port it "reserved" and fails.
   
   I'm not sure how often this troubling sequence happens, but it does happen. 
Requesting a non-membership port (via AvailablePortHelper) helps by assigning 
ports outside the ephemeral port range.

##########
File path: 
geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java
##########
@@ -168,15 +169,18 @@ private CacheServer 
createRegionAndStartCacheServer(String[] regions, Cache cach
   }
 
   private int startManager(final String locators, final String[] regions) 
throws IOException {
+    int[] ports = getRandomAvailableTCPPorts(2);
+    int jmxManagerPort = ports[0];
+    int httpPort = ports[1];
+
     Properties props = new Properties();
     props.setProperty(MCAST_PORT, String.valueOf(0));
     props.setProperty(LOCATORS, locators);
 
     props.setProperty(JMX_MANAGER, "true");
     props.setProperty(JMX_MANAGER_START, "true");
-    props.setProperty(JMX_MANAGER_PORT, "0");
+    props.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxManagerPort));

Review comment:
       I think this change is unnecessary and I've reverted it. Thanks for 
catching that.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


> Avoid using default ports in tests [PERMANENT]
> ----------------------------------------------
>
>                 Key: GEODE-8772
>                 URL: https://issues.apache.org/jira/browse/GEODE-8772
>             Project: Geode
>          Issue Type: Test
>          Components: tests
>    Affects Versions: 1.14.0
>            Reporter: Dale Emery
>            Assignee: Dale Emery
>            Priority: Major
>              Labels: GeodeOperationAPI, pull-request-available
>
> Many distributed tests and upgrade tests (and sometimes others) launch 
> members with default ports, especially for JMX (1099) and HTTP service 
> (7070). When run in parallel outside of docker, these tests often fail 
> because the default port is already in use in another test.
> Except when specifically testing the product's use of the defaults, every 
> test should assign ports known to be available. For many tests, we can 
> accomplish this by changing the test framework to assign available ports. 
> Other tests may require changes in the test code.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to