From 7095c28148fed2f4b74208691829efd3151858ae Mon Sep 17 00:00:00 2001 From: Mattias Persson Date: Thu, 3 Mar 2016 15:50:26 +0100 Subject: [PATCH] 6 minutes faster server enterprise tests by properly shutting down the standalone cluster client as to not wait for the semaphore for 60 seconds for shutting down, for every one of the 6 tests in StandaloneClusterClientIT --- .../enterprise/StandaloneClusterClient.java | 29 ++++++++++++------- .../enterprise/StandaloneClusterClientIT.java | 13 +++++++-- .../StandaloneClusterClientTestProxy.java | 9 ++++-- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/enterprise/server-enterprise/src/main/java/org/neo4j/server/enterprise/StandaloneClusterClient.java b/enterprise/server-enterprise/src/main/java/org/neo4j/server/enterprise/StandaloneClusterClient.java index fbbd6a2166192..7e27ee426b47a 100644 --- a/enterprise/server-enterprise/src/main/java/org/neo4j/server/enterprise/StandaloneClusterClient.java +++ b/enterprise/server-enterprise/src/main/java/org/neo4j/server/enterprise/StandaloneClusterClient.java @@ -58,14 +58,15 @@ * * @author Mattias Persson */ -public class StandaloneClusterClient +public class StandaloneClusterClient implements AutoCloseable { - private final LifeSupport life; + private final LifeSupport life = new LifeSupport(); private final Timer timer; - private StandaloneClusterClient( LifeSupport life ) + public StandaloneClusterClient( Config config ) throws IOException { - this.life = life; + start( config ); + timer = new Timer( true ); addShutdownHook(); life.start(); @@ -95,22 +96,19 @@ public void run() } ); } - public static void main( String[] args ) throws IOException + private void start( Config config ) throws IOException { try { - LifeSupport life = new LifeSupport(); life.add( new Neo4jJobScheduler() ); new ClusterClientModule( life, new Dependencies(), new Monitors(), - getConfig( args ), + config, logService( new DefaultFileSystemAbstraction() ), new NotElectableElectionCredentialsProvider() ); - - new StandaloneClusterClient( life ); } catch ( LifecycleException e ) { @@ -129,7 +127,18 @@ public static void main( String[] args ) throws IOException } } - private static Config getConfig( String[] args ) throws IOException + public static void main( String[] args ) throws IOException + { + new StandaloneClusterClient( getConfig( args ) ); + } + + @Override + public void close() + { + life.shutdown(); + } + + public static Config getConfig( String[] args ) throws IOException { Map config = new HashMap<>(); String configPath = System.getProperty( ServerSettings.SERVER_CONFIG_FILE_KEY ); diff --git a/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/StandaloneClusterClientIT.java b/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/StandaloneClusterClientIT.java index 130c0d1aef3bb..6cfcf35fdb020 100644 --- a/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/StandaloneClusterClientIT.java +++ b/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/StandaloneClusterClientIT.java @@ -28,6 +28,7 @@ import java.io.File; import java.io.IOException; +import java.io.OutputStream; import java.lang.reflect.AccessibleObject; import java.net.URI; import java.nio.file.Files; @@ -286,8 +287,16 @@ private boolean startStandaloneClusterClient( File configFile, Map