Skip to content

Commit

Permalink
3.4 Added fix for broken addresses in IT in backup
Browse files Browse the repository at this point in the history
Some backup integration tests (BackupCoreIT,ClusterSeedingIT) are using
incorrect addresses for backups. Applying corrects wrong addresses to be
cluster leaders.
  • Loading branch information
phughk committed Oct 10, 2017
1 parent 61414fb commit 65b6dbe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Expand Up @@ -31,6 +31,7 @@


import org.neo4j.causalclustering.core.CausalClusteringSettings; import org.neo4j.causalclustering.core.CausalClusteringSettings;
import org.neo4j.causalclustering.core.CoreGraphDatabase; import org.neo4j.causalclustering.core.CoreGraphDatabase;
import org.neo4j.causalclustering.core.consensus.roles.Role;
import org.neo4j.causalclustering.discovery.Cluster; import org.neo4j.causalclustering.discovery.Cluster;
import org.neo4j.causalclustering.discovery.CoreClusterMember; import org.neo4j.causalclustering.discovery.CoreClusterMember;
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
Expand Down Expand Up @@ -74,7 +75,7 @@ public void makeSureBackupCanBePerformedFromAnyInstance() throws Throwable
{ {
// Run backup // Run backup
DbRepresentation beforeChange = DbRepresentation.of( createSomeData( cluster ) ); DbRepresentation beforeChange = DbRepresentation.of( createSomeData( cluster ) );
String[] args = backupArguments( backupAddress( db.database() ), backupsDir, "" + db.serverId() ); String[] args = backupArguments( backupAddress( cluster ), backupsDir, "" + db.serverId() );
assertEquals( 0, runBackupToolFromOtherJvmToGetExitCode( clusterRule.clusterDirectory(), args ) ); assertEquals( 0, runBackupToolFromOtherJvmToGetExitCode( clusterRule.clusterDirectory(), args ) );


// Add some new data // Add some new data
Expand All @@ -97,9 +98,9 @@ static CoreGraphDatabase createSomeData( Cluster cluster ) throws Exception
} ).database(); } ).database();
} }


static String backupAddress( GraphDatabaseFacade db ) static String backupAddress( Cluster cluster )
{ {
return ":" + PortAuthority.allocatePort(); return cluster.getDbWithRole( Role.LEADER ).settingValue( "causal_clustering.transaction_listen_address" );
} }


static String[] backupArguments( String from, File backupsDir, String name ) static String[] backupArguments( String from, File backupsDir, String name )
Expand Down
Expand Up @@ -92,15 +92,15 @@ private File createBackupUsingAnotherCluster() throws Exception
backupCluster.start(); backupCluster.start();
CoreGraphDatabase db = BackupCoreIT.createSomeData( backupCluster ); CoreGraphDatabase db = BackupCoreIT.createSomeData( backupCluster );


File backup = createBackup( db, "some-backup" ); File backup = createBackup( backupCluster, "some-backup" );
backupCluster.shutdown(); backupCluster.shutdown();


return backup; return backup;
} }


private File createBackup( CoreGraphDatabase db, String backupName ) throws Exception private File createBackup( Cluster cluster, String backupName ) throws Exception
{ {
String[] args = BackupCoreIT.backupArguments( backupAddress( db ), baseBackupDir, backupName ); String[] args = BackupCoreIT.backupArguments( backupAddress( cluster ), baseBackupDir, backupName );
assertEquals( 0, runBackupToolFromOtherJvmToGetExitCode( testDir.absolutePath(), args ) ); assertEquals( 0, runBackupToolFromOtherJvmToGetExitCode( testDir.absolutePath(), args ) );
return new File( baseBackupDir, backupName ); return new File( baseBackupDir, backupName );
} }
Expand Down Expand Up @@ -132,7 +132,7 @@ public void shouldSeedNewMemberFromEmptyIdleCluster() throws Throwable
cluster.start(); cluster.start();


// when: creating a backup // when: creating a backup
File backupDir = createBackup( cluster.getCoreMemberById( 0 ).database(), "the-backup" ); File backupDir = createBackup( cluster, "the-backup" );


// and: seeding new member with said backup // and: seeding new member with said backup
CoreClusterMember newMember = cluster.addCoreMemberWithId( 3 ); CoreClusterMember newMember = cluster.addCoreMemberWithId( 3 );
Expand All @@ -154,7 +154,7 @@ public void shouldSeedNewMemberFromNonEmptyIdleCluster() throws Throwable
createEmptyNodes( cluster, 100 ); createEmptyNodes( cluster, 100 );


// when: creating a backup // when: creating a backup
File backupDir = createBackup( cluster.getCoreMemberById( 0 ).database(), "the-backup" ); File backupDir = createBackup( cluster, "the-backup" );


// and: seeding new member with said backup // and: seeding new member with said backup
CoreClusterMember newMember = cluster.addCoreMemberWithId( 3 ); CoreClusterMember newMember = cluster.addCoreMemberWithId( 3 );
Expand Down

0 comments on commit 65b6dbe

Please sign in to comment.