You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Kirk Lund (Jira)" <ji...@apache.org> on 2019/09/05 17:27:00 UTC

[jira] [Created] (GEODE-7165) GatewayReceiverImplTest may fail if a port in the test is in use

Kirk Lund created GEODE-7165:
--------------------------------

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


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.2#803003)