Skip to content

Commit

Permalink
Rename "server" to "member" in integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
apcj committed Jul 22, 2016
1 parent 69700ff commit 6048071
Show file tree
Hide file tree
Showing 21 changed files with 328 additions and 336 deletions.
Expand Up @@ -31,7 +31,7 @@
import java.util.stream.Collectors;

import org.neo4j.coreedge.discovery.Cluster;
import org.neo4j.coreedge.discovery.CoreServer;
import org.neo4j.coreedge.discovery.CoreClusterMember;
import org.neo4j.coreedge.server.CoreEdgeClusterSettings;
import org.neo4j.graphdb.Node;
import org.neo4j.io.fs.DefaultFileSystemAbstraction;
Expand All @@ -58,8 +58,8 @@ public class ClusterIdentityIT

@Rule
public ClusterRule clusterRule = new ClusterRule( ClusterIdentityIT.class )
.withNumberOfCoreServers( 3 )
.withNumberOfEdgeServers( 0 )
.withNumberOfCoreMembers( 3 )
.withNumberOfEdgeMembers( 0 )
.withSharedCoreParam( CoreEdgeClusterSettings.raft_log_pruning_strategy, "3 entries" )
.withSharedCoreParam( CoreEdgeClusterSettings.raft_log_rotation_size, "1K" );

Expand All @@ -83,7 +83,7 @@ public void allServersShouldHaveTheSameStoreId() throws Throwable
tx.success();
} );

List<File> coreStoreDirs = storeDirs( cluster.coreServers() );
List<File> coreStoreDirs = storeDirs( cluster.coreMembers() );

cluster.shutdown();

Expand All @@ -106,7 +106,7 @@ public void whenWeRestartTheClusterAllServersShouldStillHaveTheSameStoreId() thr
// WHEN
cluster.start();

List<File> coreStoreDirs = storeDirs( cluster.coreServers() );
List<File> coreStoreDirs = storeDirs( cluster.coreMembers() );

cluster.coreTx( ( db, tx ) ->
{
Expand All @@ -132,15 +132,15 @@ public void shouldNotJoinClusterIfHasDataWithDifferentStoreId() throws Exception
tx.success();
} );

File storeDir = cluster.getCoreServerById( 0 ).storeDir();
File storeDir = cluster.getCoreMemberById( 0 ).storeDir();

cluster.removeCoreServerWithServerId( 0 );
cluster.removeCoreMemberWithMemberId( 0 );
changeStoreId( storeDir );

// WHEN
try
{
cluster.addCoreServerWithServerId( 0, 3 ).start();
cluster.addCoreMemberWithId( 0, 3 ).start();
fail( "Should not have joined the cluster" );
}
catch ( RuntimeException e )
Expand All @@ -160,24 +160,24 @@ public void laggingFollowerShouldDownloadSnapshot() throws Exception
tx.success();
} );

cluster.removeCoreServerWithServerId( 0 );
cluster.removeCoreMemberWithMemberId( 0 );

createSomeData( 100, cluster );

for ( CoreServer db : cluster.coreServers() )
for ( CoreClusterMember db : cluster.coreMembers() )
{
db.coreState().compact();
}

// WHEN
cluster.addCoreServerWithServerId( 0, 3 ).start();
cluster.addCoreMemberWithId( 0, 3 ).start();

cluster.awaitLeader();

// THEN
assertEquals( 3, cluster.healthyCoreMembers().size() );

List<File> coreStoreDirs = storeDirs( cluster.coreServers() );
List<File> coreStoreDirs = storeDirs( cluster.coreMembers() );
cluster.shutdown();
assertAllStoresHaveTheSameStoreId( coreStoreDirs, fs );
}
Expand All @@ -193,21 +193,21 @@ public void badFollowerShouldNotJoinCluster() throws Exception
tx.success();
} );

File storeDir = cluster.getCoreServerById( 0 ).storeDir();
cluster.removeCoreServerWithServerId( 0 );
File storeDir = cluster.getCoreMemberById( 0 ).storeDir();
cluster.removeCoreMemberWithMemberId( 0 );
changeStoreId( storeDir );

createSomeData( 100, cluster );

for ( CoreServer db : cluster.coreServers() )
for ( CoreClusterMember db : cluster.coreMembers() )
{
db.coreState().compact();
}

// WHEN
try
{
cluster.addCoreServerWithServerId( 0, 3 ).start();
cluster.addCoreMemberWithId( 0, 3 ).start();
fail( "Should not have joined the cluster" );
}
catch ( RuntimeException e )
Expand All @@ -229,27 +229,27 @@ public void aNewServerShouldJoinTheClusterByDownloadingASnapshot() throws Except

createSomeData( 100, cluster );

for ( CoreServer db : cluster.coreServers() )
for ( CoreClusterMember db : cluster.coreMembers() )
{
db.coreState().compact();
}

// WHEN
cluster.addCoreServerWithServerId( 4, 4 ).start();
cluster.addCoreMemberWithId( 4, 4 ).start();

cluster.awaitLeader();

// THEN
assertEquals( 4, cluster.healthyCoreMembers().size() );

List<File> coreStoreDirs = storeDirs( cluster.coreServers() );
List<File> coreStoreDirs = storeDirs( cluster.coreMembers() );
cluster.shutdown();
assertAllStoresHaveTheSameStoreId( coreStoreDirs, fs );
}

private List<File> storeDirs( Collection<CoreServer> dbs )
private List<File> storeDirs( Collection<CoreClusterMember> dbs )
{
return dbs.stream().map( CoreServer::storeDir ).collect( Collectors.toList() );
return dbs.stream().map( CoreClusterMember::storeDir ).collect( Collectors.toList() );
}

private void createSomeData( int items, Cluster cluster ) throws TimeoutException, InterruptedException
Expand Down
Expand Up @@ -37,7 +37,7 @@
import org.neo4j.backup.OnlineBackupSettings;
import org.neo4j.coreedge.TestStoreId;
import org.neo4j.coreedge.discovery.Cluster;
import org.neo4j.coreedge.discovery.CoreServer;
import org.neo4j.coreedge.discovery.CoreClusterMember;
import org.neo4j.coreedge.server.CoreEdgeClusterSettings;
import org.neo4j.coreedge.server.StoreId;
import org.neo4j.coreedge.server.core.CoreGraphDatabase;
Expand Down Expand Up @@ -72,8 +72,8 @@ public class BackupCoreIT

@Rule
public ClusterRule clusterRule = new ClusterRule( BackupCoreIT.class )
.withNumberOfCoreServers( 3 )
.withNumberOfEdgeServers( 0 )
.withNumberOfCoreMembers( 3 )
.withNumberOfEdgeMembers( 0 )
.withSharedCoreParam( OnlineBackupSettings.online_backup_enabled, Settings.TRUE )
.withInstanceCoreParam( OnlineBackupSettings.online_backup_server, serverId -> (":" + (8000 + serverId) ) );
private Cluster cluster;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void makeSureBackupCanBePerformed() throws Throwable
@Test
public void makeSureBackupCanBePerformedFromAnyInstance() throws Throwable
{
for ( CoreServer db : cluster.coreServers() )
for ( CoreClusterMember db : cluster.coreMembers() )
{
// Run backup
DbRepresentation beforeChange = DbRepresentation.of(createSomeData( cluster ));
Expand Down Expand Up @@ -137,7 +137,7 @@ public void makeSureCoreClusterCanBeRestoredFromABackup() throws Throwable

// when we shutdown the cluster we lose the number of core servers so we won't go through the for loop unless
// we capture the count beforehand
List<File> dbPaths = cluster.coreServers().stream().map( CoreServer::storeDir ).collect( toList() );
List<File> dbPaths = cluster.coreMembers().stream().map( CoreClusterMember::storeDir ).collect( toList() );
int numberOfCoreServers = dbPaths.size();

cluster.shutdown();
Expand All @@ -149,27 +149,27 @@ public void makeSureCoreClusterCanBeRestoredFromABackup() throws Throwable
StringBuilder output = new StringBuilder();
PrintStream sysout = new PrintStream( new RestoreClusterUtils.MyOutputStream( output ) );

Path homeDir = Paths.get(cluster.getCoreServerById( 0 ).homeDir().getPath());
Path homeDir = Paths.get(cluster.getCoreMemberById( 0 ).homeDir().getPath());
new RestoreNewClusterCli( homeDir, homeDir, sysout ).execute(toArray( args().from( backupPath )
.database( "graph.db" ).force().build() ));

String seed = RestoreClusterCliTest.extractSeed( output.toString() );

for ( int i = 1; i < numberOfCoreServers; i++ )
{
homeDir = Paths.get(cluster.getCoreServerById( i ).homeDir().getPath());
homeDir = Paths.get(cluster.getCoreMemberById( i ).homeDir().getPath());
new RestoreExistingClusterCli( homeDir, homeDir ).execute(
toArray( args().from( backupPath ).database( "graph.db" ).seed( seed ).force().build() ) );
}

cluster.start();

// then
Collection<CoreServer> coreGraphDatabases = cluster.coreServers();
Collection<CoreClusterMember> coreGraphDatabases = cluster.coreMembers();
Stream<DbRepresentation> dbRepresentations = coreGraphDatabases.stream().map( x -> DbRepresentation.of(x.database()) );
dbRepresentations.forEach( afterReSeed -> assertEquals( beforeBackup, afterReSeed ) );

List<File> afterRestoreDbPaths = coreGraphDatabases.stream().map( CoreServer::storeDir ).collect( toList() );
List<File> afterRestoreDbPaths = coreGraphDatabases.stream().map( CoreClusterMember::storeDir ).collect( toList() );
cluster.shutdown();

assertAllStoresHaveTheSameStoreId( afterRestoreDbPaths, fs );
Expand Down
Expand Up @@ -41,9 +41,9 @@ public class BackupEdgeIT

@Rule
public ClusterRule clusterRule = new ClusterRule( BackupCoreIT.class )
.withNumberOfCoreServers( 3 )
.withNumberOfCoreMembers( 3 )
.withSharedCoreParam( OnlineBackupSettings.online_backup_enabled, Settings.FALSE )
.withNumberOfEdgeServers( 1 )
.withNumberOfEdgeMembers( 1 )
.withSharedEdgeParam( OnlineBackupSettings.online_backup_enabled, Settings.TRUE )
.withInstanceEdgeParam( OnlineBackupSettings.online_backup_server, serverId -> ":8000" );

Expand Down

0 comments on commit 6048071

Please sign in to comment.