From b04cf7485cd9cc62a5006e4aa47ef35158eaa8f6 Mon Sep 17 00:00:00 2001 From: MishaDemianenko Date: Fri, 7 Jul 2017 15:51:58 +0200 Subject: [PATCH] Allow execution of shell IT tests in parallel in forked VMs Try 100 ties to find free port for remote server during execution of IT tests in shell to allow them to run in parallel and avoid port conflicts. --- community/shell/pom.xml | 6 ---- .../java/org/neo4j/shell/AbstractShellIT.java | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/community/shell/pom.xml b/community/shell/pom.xml index 38e0067d6981..a843081495c8 100644 --- a/community/shell/pom.xml +++ b/community/shell/pom.xml @@ -59,12 +59,6 @@ the relevant Commercial Agreement. - - maven-failsafe-plugin - - 1 - - maven-jar-plugin diff --git a/community/shell/src/test/java/org/neo4j/shell/AbstractShellIT.java b/community/shell/src/test/java/org/neo4j/shell/AbstractShellIT.java index 8dd25ec9725a..c63a65ec8bd0 100644 --- a/community/shell/src/test/java/org/neo4j/shell/AbstractShellIT.java +++ b/community/shell/src/test/java/org/neo4j/shell/AbstractShellIT.java @@ -132,17 +132,29 @@ protected void makeServerRemotelyAvailable() throws RemoteException { if ( remotelyAvailableOnPort == null ) { - remotelyAvailableOnPort = findFreePort(); - shellServer.makeRemotelyAvailable( remotelyAvailableOnPort, SimpleAppServer.DEFAULT_NAME ); + int attempts = 0; + int port = SimpleAppServer.DEFAULT_PORT; + do + { + try + { + shellServer.makeRemotelyAvailable( port, SimpleAppServer.DEFAULT_NAME ); + remotelyAvailableOnPort = port; + } + catch ( Throwable error ) + { + port++; + attempts++; + if ( attempts == 100 ) + { + throw new RuntimeException( "Not able to find free port more them 100 times.", error ); + } + } + } + while ( remotelyAvailableOnPort == null ); } } - private int findFreePort() - { - // TODO - return SimpleAppServer.DEFAULT_PORT; - } - protected void restartServer() throws Exception { shellServer.shutdown();