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

ASF subversion and git services commented on GEODE-7165:
--------------------------------------------------------

Commit 802687154131af16d350bf39d152feb4685ba7e6 in geode's branch 
refs/heads/develop from Kirk Lund
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=8026871 ]

GEODE-7165: Remove networking dependency from GatewayReceiverImplTest (#4071)

The test was failing on machines with ports 2000 or 2001 in use.

This change replaces GatewayReceiverImpl's dependency on AvailablePort
with functions that are now injected by the unit tests.


> GatewayReceiverImplTest may fail if a port in the test is in use
> ----------------------------------------------------------------
>
>                 Key: GEODE-7165
>                 URL: https://issues.apache.org/jira/browse/GEODE-7165
>             Project: Geode
>          Issue Type: Bug
>          Components: tests
>            Reporter: Kirk Lund
>            Assignee: Kirk Lund
>            Priority: Major
>          Time Spent: 2h
>  Remaining Estimate: 0h
>
> GatewayReceiverImplTest may fail with a call stack like:
> {noformat}
> org.apache.geode.internal.cache.wan.GatewayReceiverImplTest > 
> startShouldTryAllPortsInPortRangeIfIOExceptionIsThrown FAILED
>     org.mockito.exceptions.verification.TooLittleActualInvocations:
>     internalCacheServer.start();
>     Wanted 101 times:
>     -> at 
> org.apache.geode.internal.cache.wan.GatewayReceiverImplTest.startShouldTryAllPortsInPortRangeIfIOExceptionIsThrown(GatewayReceiverImplTest.java:167)
>     But was 100 times:
>     -> at 
> org.apache.geode.internal.cache.wan.GatewayReceiverImpl.tryToStart(GatewayReceiverImpl.java:157)
>     -> at 
> org.apache.geode.internal.cache.wan.GatewayReceiverImpl.tryToStart(GatewayReceiverImpl.java:157)
>     -> at 
> org.apache.geode.internal.cache.wan.GatewayReceiverImpl.tryToStart(GatewayReceiverImpl.java:157)
>     -> at 
> org.apache.geode.internal.cache.wan.GatewayReceiverImpl.tryToStart(GatewayReceiverImpl.java:157)
>     -> at 
> org.apache.geode.internal.cache.wan.GatewayReceiverImpl.tryToStart(GatewayReceiverImpl.java:157)
> {noformat}
> The test is assuming that only the underlying CacheServer will try the ports 
> in the start-end port range. However, I just found this line of code in 
> GatewayReceiverImpl:
> {noformat}
>   private boolean tryToStart(int port) {
>     if (!AvailablePort.isPortAvailable(port, SOCKET, getAddress(SOCKET))) {
>       return false;
>     }
> {noformat}
> The above early-out will test the availability of the port and exit without 
> interacting with the mock CacheServer provided by the test. Thus, if any of 
> the ports in the range are actually in use on the machine running the test, 
> it will fail.



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

Reply via email to