Why not create a JUnit rule that returns available ports and keep track of ports being used ?
I've cloned this gist from somewhere (don't remember now) but I've planning to send it for discussion... https://gist.github.com/markito/b5be3fc570c7c7c84e6d09e064a6e898 Still talking about rules, I've played a bit with the TemporaryFolder rule and that's very useful as well, specially to clean up after test runs and to avoid conflicts. http://junit.org/junit4/javadoc/4.12/org/junit/rules/TemporaryFolder.html Just my 2c On Fri, Jul 29, 2016 at 1:54 PM, Hitesh Khamesra < hitesh...@yahoo.com.invalid> wrote: > Is there any possibility of running multiple test same time on that > machine? > > -Hitesh > > > From: Kirk Lund <kl...@pivotal.io> > To: geode <dev@geode.incubator.apache.org> > Sent: Friday, July 29, 2016 1:21 PM > Subject: Flaky tests failing with BindException > > Many of our flaky tests are flaky because they use AvailablePort or > AvailablePortHelper to find randomly available ports. They then later fail > with a BindException because the port is already in use by the time the > test uses it. > > Here's a proposal for a temporary fix: > > The module geode-junit contains a JUnit 4 rule called RetryRule. We could > modify RetryRule to only retry if a BindException (or configurable > exception/s) is detected. This rule would then be dropped into every test > that uses AvailablePort or AvailablePortHelper. Then if the test fails with > a BindException, it would automatically retry (once or twice or whatever we > decide to configure RetryRule with). If the test fails without any detected > BindException, then it would just fail without retrying. > > Opinions on this? > > Thanks, > Kirk > > > > -- ~/William