Skip to content

Commit 1b1b973

Browse files
committed
Stop shared CC cluster when it's not needed in tests
It consumes a lot of memory and causes single instance database used by other tests to crash.
1 parent a6de376 commit 1b1b973

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
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
@@ -19,6 +19,7 @@
1919
package org.neo4j.driver.v1.integration;
2020

2121
import org.junit.After;
22+
import org.junit.AfterClass;
2223
import org.junit.Rule;
2324
import org.junit.Test;
2425

@@ -96,6 +97,12 @@ public void tearDown()
9697
}
9798
}
9899

100+
@AfterClass
101+
public static void stopSharedCluster()
102+
{
103+
ClusterRule.stopSharedCluster();
104+
}
105+
99106
@Test
100107
public void shouldExecuteReadAndWritesWhenDriverSuppliedWithAddressOfLeader() throws Exception
101108
{

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
@@ -19,6 +19,7 @@
1919
package org.neo4j.driver.v1.stress;
2020

2121
import org.junit.After;
22+
import org.junit.AfterClass;
2223
import org.junit.Before;
2324
import org.junit.Rule;
2425
import org.junit.Test;
@@ -57,6 +58,7 @@
5758
import org.neo4j.driver.v1.exceptions.SecurityException;
5859
import org.neo4j.driver.v1.types.Node;
5960
import org.neo4j.driver.v1.util.DaemonThreadFactory;
61+
import org.neo4j.driver.v1.util.cc.ClusterRule;
6062
import org.neo4j.driver.v1.util.cc.LocalOrRemoteClusterRule;
6163

6264
import static java.util.Collections.newSetFromMap;
@@ -108,6 +110,12 @@ public void tearDown() throws Exception
108110
}
109111
}
110112

113+
@AfterClass
114+
public static void stopSharedCluster()
115+
{
116+
ClusterRule.stopSharedCluster();
117+
}
118+
111119
@Test
112120
public void basicStressTest() throws Throwable
113121
{

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ public AuthToken getDefaultAuthToken()
5252
return AuthTokens.basic( "neo4j", PASSWORD );
5353
}
5454

55+
public static void stopSharedCluster()
56+
{
57+
if ( SharedCluster.exists() )
58+
{
59+
try
60+
{
61+
SharedCluster.stop();
62+
}
63+
finally
64+
{
65+
SharedCluster.remove();
66+
}
67+
}
68+
}
69+
5570
@Override
5671
protected void before() throws Throwable
5772
{

0 commit comments

Comments
 (0)