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

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

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



##########
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:
       In this case you changed from "0" to using getRandomAvailableTCPPorts. I 
would have thought "0" is even better because using getRandomAvailableTCPPorts 
has a small race in which the port it hands back could end up being used by 
another before this thread can bind to it. I thought "0" was better because we 
are telling the operating system to give us an available port at the time we 
bind to it so we get rid of the race window. It can be hard to do in some tests 
when they need to know ahead of time what the actual port is. Do you know using 
"0" causes test issues?




----------------------------------------------------------------
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