Skip to content

Commit f68606b

Browse files
committed
Do not start both CC and single db in tests
1 parent 450135d commit f68606b

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

driver/src/test/java/org/neo4j/driver/v1/integration/CausalClusteringIT.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.neo4j.driver.v1.integration;
2020

21+
import org.junit.AfterClass;
2122
import org.junit.Rule;
2223
import org.junit.Test;
2324

@@ -85,6 +86,12 @@ public class CausalClusteringIT
8586
@Rule
8687
public final ClusterRule clusterRule = new ClusterRule();
8788

89+
@AfterClass
90+
public static void stopSharedCluster()
91+
{
92+
ClusterRule.stopSharedCluster();
93+
}
94+
8895
@Test
8996
public void shouldExecuteReadAndWritesWhenDriverSuppliedWithAddressOfLeader() throws Exception
9097
{

driver/src/test/java/org/neo4j/driver/v1/stress/CausalClusteringStressIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.neo4j.driver.v1.stress;
2020

21+
import org.junit.AfterClass;
2122
import org.junit.Rule;
2223

2324
import java.net.URI;
@@ -40,6 +41,7 @@
4041
import org.neo4j.driver.v1.exceptions.SessionExpiredException;
4142
import org.neo4j.driver.v1.summary.ResultSummary;
4243
import org.neo4j.driver.v1.util.cc.ClusterMemberRole;
44+
import org.neo4j.driver.v1.util.cc.ClusterRule;
4345
import org.neo4j.driver.v1.util.cc.LocalOrRemoteClusterRule;
4446

4547
import static org.hamcrest.Matchers.both;
@@ -54,6 +56,12 @@ public class CausalClusteringStressIT extends AbstractStressTestBase<CausalClust
5456
@Rule
5557
public final LocalOrRemoteClusterRule clusterRule = new LocalOrRemoteClusterRule();
5658

59+
@AfterClass
60+
public static void stopSharedCluster()
61+
{
62+
ClusterRule.stopSharedCluster();
63+
}
64+
5765
@Override
5866
URI databaseUri()
5967
{

driver/src/test/java/org/neo4j/driver/v1/util/Neo4jRunner.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ public static synchronized Neo4jRunner getOrCreateGlobalRunner() throws IOExcept
8080
return globalInstance;
8181
}
8282

83+
public static synchronized boolean globalRunnerExists()
84+
{
85+
return globalInstance != null;
86+
}
87+
8388
private Neo4jRunner() throws IOException
8489
{
8590
try

driver/src/test/java/org/neo4j/driver/v1/util/cc/ClusterRule.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.junit.rules.ExternalResource;
2222

23+
import java.io.IOException;
2324
import java.nio.file.Path;
2425
import java.nio.file.Paths;
2526

@@ -52,11 +53,28 @@ public AuthToken getDefaultAuthToken()
5253
return AuthTokens.basic( "neo4j", PASSWORD );
5354
}
5455

56+
public static void stopSharedCluster()
57+
{
58+
if ( SharedCluster.exists() )
59+
{
60+
try
61+
{
62+
SharedCluster.stop();
63+
}
64+
finally
65+
{
66+
SharedCluster.remove();
67+
}
68+
}
69+
}
70+
5571
@Override
5672
protected void before() throws Throwable
5773
{
5874
assumeTrue( "BoltKit cluster support unavailable", boltKitAvailable() );
5975

76+
stopSingleInstanceDatabase();
77+
6078
if ( !SharedCluster.exists() )
6179
{
6280
SharedCluster.install( parseNeo4jVersion(),
@@ -109,6 +127,14 @@ private static String parseNeo4jVersion()
109127
return version;
110128
}
111129

130+
private static void stopSingleInstanceDatabase() throws IOException
131+
{
132+
if ( Neo4jRunner.globalRunnerExists() )
133+
{
134+
Neo4jRunner.getOrCreateGlobalRunner().stopNeo4j();
135+
}
136+
}
137+
112138
private static void addShutdownHookToStopCluster()
113139
{
114140
Runtime.getRuntime().addShutdownHook( new Thread()
@@ -118,7 +144,10 @@ public void run()
118144
{
119145
try
120146
{
121-
SharedCluster.kill();
147+
if ( SharedCluster.exists() )
148+
{
149+
SharedCluster.kill();
150+
}
122151
}
123152
catch ( Throwable t )
124153
{

0 commit comments

Comments
 (0)