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 java.util.stream.Collectors;


import org.neo4j.coreedge.discovery.Cluster; 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.CoreEdgeClusterSettings;
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
import org.neo4j.io.fs.DefaultFileSystemAbstraction; import org.neo4j.io.fs.DefaultFileSystemAbstraction;
Expand All @@ -58,8 +58,8 @@ public class ClusterIdentityIT


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


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


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


cluster.shutdown(); cluster.shutdown();


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


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


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


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


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


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


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


createSomeData( 100, cluster ); createSomeData( 100, cluster );


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


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


cluster.awaitLeader(); cluster.awaitLeader();


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


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


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


createSomeData( 100, cluster ); createSomeData( 100, cluster );


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


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


createSomeData( 100, cluster ); createSomeData( 100, cluster );


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


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


cluster.awaitLeader(); cluster.awaitLeader();


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


List<File> coreStoreDirs = storeDirs( cluster.coreServers() ); List<File> coreStoreDirs = storeDirs( cluster.coreMembers() );
cluster.shutdown(); cluster.shutdown();
assertAllStoresHaveTheSameStoreId( coreStoreDirs, fs ); 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 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.backup.OnlineBackupSettings;
import org.neo4j.coreedge.TestStoreId; import org.neo4j.coreedge.TestStoreId;
import org.neo4j.coreedge.discovery.Cluster; 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.CoreEdgeClusterSettings;
import org.neo4j.coreedge.server.StoreId; import org.neo4j.coreedge.server.StoreId;
import org.neo4j.coreedge.server.core.CoreGraphDatabase; import org.neo4j.coreedge.server.core.CoreGraphDatabase;
Expand Down Expand Up @@ -72,8 +72,8 @@ public class BackupCoreIT


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


cluster.shutdown(); cluster.shutdown();
Expand All @@ -149,27 +149,27 @@ public void makeSureCoreClusterCanBeRestoredFromABackup() throws Throwable
StringBuilder output = new StringBuilder(); StringBuilder output = new StringBuilder();
PrintStream sysout = new PrintStream( new RestoreClusterUtils.MyOutputStream( output ) ); 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 ) new RestoreNewClusterCli( homeDir, homeDir, sysout ).execute(toArray( args().from( backupPath )
.database( "graph.db" ).force().build() )); .database( "graph.db" ).force().build() ));


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


for ( int i = 1; i < numberOfCoreServers; i++ ) 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( new RestoreExistingClusterCli( homeDir, homeDir ).execute(
toArray( args().from( backupPath ).database( "graph.db" ).seed( seed ).force().build() ) ); toArray( args().from( backupPath ).database( "graph.db" ).seed( seed ).force().build() ) );
} }


cluster.start(); cluster.start();


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


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


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


Expand Down

0 comments on commit 6048071

Please sign in to comment.