+1

I am dealing with the same issue on some tests on the C++ side that do the
same thing. I had planned to fix it the same way that you proposed.

Given that there are lots of ports to configure in Geode maybe as those
ports are activated they should be written to a properties file in the
working directory next to the stats, logs, etc. After the server is started
any script or executable should be able to parse that file to find the
ports it needs.

-Jake




On Tue, Feb 9, 2016 at 1:09 PM Kirk Lund <kl...@pivotal.io> wrote:

> I'm seeing more and more CI failures caused by our use of
> AvailablePort.getRandomAvailablePort. When the test calls
> AvailablePort.getRandomAvailablePort, a random port is found. But by the
> time the test actually goes to use the port it's already in use.
>
> It doesn't really make sense to fix this one test at a time since we have a
> very large number of tests doing this and hitting this failure in CI.
>
> I believe the correct fix would be to sweep through the tests to get rid of
> our use of AvailablePort.getRandomAvailablePort, use zero for the port and
> then ask the server what port it ended up using if we need the port for
> something.
>
> Trying to determine a randomly available port up front before using it is
> just a race condition waiting to happen.
>
> Thoughts?
>
> Caused by: java.net.BindException: Address already in use
>   at java.net.PlainSocketImpl.socketBind(Native Method)
>   at java.net
> .AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
>   at java.net.ServerSocket.bind(ServerSocket.java:375)
>   at
>
> com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:835)
>   ... 27 more
>
>   at junit.framework.Assert.fail(Assert.java:57)
>   at junit.framework.TestCase.fail(TestCase.java:227)
>   at dunit.DistributedTestCase.fail(DistributedTestCase.java:970)
>   at
>
> com.gemstone.gemfire.security.SecurityTestUtil.createCacheServer(SecurityTestUtil.java:341)
>   at
>
> com.gemstone.gemfire.security.ClientAuthorizationTestBase.createCacheServer(ClientAuthorizationTestBase.java:135)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>   at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:497)
>   at hydra.MethExecutor.execute(MethExecutor.java:198)
>   at
> dunit.standalone.RemoteDUnitVM.executeMethodOnClass(RemoteDUnitVM.java:117)
>   at sun.reflect.GeneratedMethodAccessor210.invoke(Unknown Source)
>   at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:497)
>   at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
>   at sun.rmi.transport.Transport$1.run(Transport.java:200)
>   at sun.rmi.transport.Transport$1.run(Transport.java:197)
>   at java.security.AccessController.doPrivileged(Native Method)
>   at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
>   at
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
>   at
>
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
>   at
>
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$95(TCPTransport.java:683)
>   at java.security.AccessController.doPrivileged(Native Method)
>   at
>
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
>   ... 3 more
>

Reply via email to