Skip to content

Commit

Permalink
Fix HaClusterStartupIT with new cluster dirs
Browse files Browse the repository at this point in the history
Make sure this test uses the same store dirs through all of the
test method (note that each testMethod gets unique test dirs
via ClusterManager, because it is generated before every
test method)
  • Loading branch information
spacecowboy committed Mar 30, 2016
1 parent e48421b commit 8ce1b45
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions integrationtests/src/test/java/org/neo4j/ha/HAClusterStartupIT.java
Expand Up @@ -26,6 +26,7 @@
import java.io.File;
import java.io.IOException;

import org.neo4j.cluster.client.Cluster;
import org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException;
import org.neo4j.graphdb.Transaction;
import org.neo4j.io.fs.FileUtils;
Expand All @@ -43,39 +44,39 @@ public class HAClusterStartupIT
{
@Rule
public final TestDirectory dir = TargetDirectory.testDirForTest( getClass() );

private Cluster cluster;
private ClusterManager clusterManager;
private ClusterManager.ManagedCluster cluster;
private ClusterManager.ManagedCluster managedCluster;
private HighlyAvailableGraphDatabase master;
private HighlyAvailableGraphDatabase slave1;
private HighlyAvailableGraphDatabase slave2;

@Before
public void instantiateClusterManager()
{
clusterManager = new ClusterManager.Builder( dir.directory() ).build();
}

@Before
public void setup() throws Throwable
{
// Re-use the same cluster instances, so that the same store dirs are used throughout the entire test-method
cluster = clusterOfSize( 3 ).get();
clusterManager = new ClusterManager.Builder( dir.directory() ).withCluster( () -> cluster ).build();

// setup a cluster with some data and entries in log files in fully functional and shutdown state
clusterManager.start();

cluster = clusterManager.getCluster();
managedCluster = clusterManager.getCluster();
try
{
cluster.await( allSeesAllAsAvailable() );
managedCluster.await( allSeesAllAsAvailable() );

master = cluster.getMaster();
master = managedCluster.getMaster();
try ( Transaction tx = master.beginTx() )
{
master.createNode();
tx.success();
}
cluster.sync();
managedCluster.sync();

slave1 = cluster.getAnySlave();
slave2 = cluster.getAnySlave( slave1 );
slave1 = managedCluster.getAnySlave();
slave2 = managedCluster.getAnySlave( slave1 );
}
finally
{
Expand All @@ -97,10 +98,10 @@ public void aSlaveWithoutAnyGraphDBFilesShouldBeAbleToJoinACluster() throws Thro
clusterManager.start();

// THEN the cluster should work
cluster = clusterManager.getCluster();
managedCluster = clusterManager.getCluster();
try
{
cluster.await( allSeesAllAsAvailable() );
managedCluster.await( allSeesAllAsAvailable() );
}
finally
{
Expand All @@ -123,10 +124,10 @@ public void bothSlavesWithoutAnyGraphDBFilesShouldBeAbleToJoinACluster() throws
clusterManager.start();

// THEN the cluster should work
cluster = clusterManager.getCluster();
managedCluster = clusterManager.getCluster();
try
{
cluster.await( allSeesAllAsAvailable() );
managedCluster.await( allSeesAllAsAvailable() );
}
finally
{
Expand All @@ -148,10 +149,10 @@ public void theMasterWithoutAnyGraphDBFilesShouldBeAbleToJoinACluster() throws T
clusterManager.start();

// THEN the cluster should work
cluster = clusterManager.getCluster();
managedCluster = clusterManager.getCluster();
try
{
cluster.await( allSeesAllAsAvailable(), 120 );
managedCluster.await( allSeesAllAsAvailable(), 120 );
}
finally
{
Expand All @@ -172,10 +173,10 @@ public void aSlaveWithoutLogicalLogFilesShouldBeAbleToJoinACluster() throws Thro
clusterManager.start();

// THEN the cluster should work
cluster = clusterManager.getCluster();
managedCluster = clusterManager.getCluster();
try
{
cluster.await( allSeesAllAsAvailable() );
managedCluster.await( allSeesAllAsAvailable() );
}
finally
{
Expand All @@ -197,10 +198,10 @@ public void bothSlaveWithoutLogicalLogFilesShouldBeAbleToJoinACluster() throws T
clusterManager.start();

// THEN the cluster should work
cluster = clusterManager.getCluster();
managedCluster = clusterManager.getCluster();
try
{
cluster.await( allSeesAllAsAvailable() );
managedCluster.await( allSeesAllAsAvailable() );
}
finally
{
Expand Down

0 comments on commit 8ce1b45

Please sign in to comment.