From 552d0b08ae4f53da345a4cdb75c111f39755f26b Mon Sep 17 00:00:00 2001 From: Lasse Westh-Nielsen Date: Fri, 11 Aug 2017 15:54:21 +0200 Subject: [PATCH] disabling backup extension when it is not needed --- .../causalclustering/backup/BackupCoreIT.java | 10 +++- .../backup/ClusterSeedingIT.java | 6 ++- .../backup/RestoreClusterUtils.java | 2 + .../ClusterCommunityToEnterpriseIT.java | 10 +++- .../test/java/org/neo4j/ha/BackupHaIT.java | 16 +++++-- .../java/org/neo4j/ha/BranchedDataIT.java | 2 + .../java/org/neo4j/ha/ForeignStoreIdIT.java | 11 ++++- .../org/neo4j/ha/PullUpdatesAppliedIT.java | 2 + .../test/java/org/neo4j/ha/PullUpdatesIT.java | 22 ++++++--- .../ha/ConcurrentInstanceStartupIT.java | 46 ++++++++++-------- .../kernel/ha/ConflictingServerIdIT.java | 10 ++-- ...onTest.java => HaIPv6ConfigurationIT.java} | 28 +++++++---- .../java/org/neo4j/kernel/ha/HardKillIT.java | 47 ++++++++++++++----- ...va => HighlyAvailableEditionModuleIT.java} | 2 +- .../neo4j/kernel/impl/ha/ClusterManager.java | 43 ++++++++++------- ...ernelDataTest.java => HaKernelDataIT.java} | 12 ++++- .../java/org/neo4j/test/ha/ClusterIT.java | 17 +++++-- .../test/java/slavetest/InstanceJoinIT.java | 2 + 18 files changed, 204 insertions(+), 84 deletions(-) rename enterprise/ha/src/test/java/org/neo4j/kernel/ha/{HaIPv6ConfigurationTest.java => HaIPv6ConfigurationIT.java} (81%) rename enterprise/ha/src/test/java/org/neo4j/kernel/ha/factory/{HighlyAvailableEditionModuleIntegrationTest.java => HighlyAvailableEditionModuleIT.java} (98%) rename enterprise/ha/src/test/java/org/neo4j/kernel/internal/{HaKernelDataTest.java => HaKernelDataIT.java} (80%) diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/BackupCoreIT.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/BackupCoreIT.java index 8025e102af7c5..c0f6a4079523b 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/BackupCoreIT.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/BackupCoreIT.java @@ -27,15 +27,18 @@ import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.causalclustering.core.CausalClusteringSettings; import org.neo4j.causalclustering.core.CoreGraphDatabase; import org.neo4j.causalclustering.discovery.Cluster; import org.neo4j.causalclustering.discovery.CoreClusterMember; +import org.neo4j.com.ports.allocation.PortAuthority; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.helpers.HostnamePort; +import org.neo4j.helpers.collection.MapUtil; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.factory.GraphDatabaseFacade; import org.neo4j.kernel.impl.store.format.standard.Standard; @@ -121,6 +124,11 @@ static String[] backupArguments( String from, File backupsDir, String name ) static Config getConfig() { - return Config.defaults( GraphDatabaseSettings.record_format, Standard.LATEST_NAME ); + Map config = MapUtil.stringMap( + GraphDatabaseSettings.record_format.name(), Standard.LATEST_NAME, + OnlineBackupSettings.online_backup_server.name(), "127.0.0.1:" + PortAuthority.allocatePort() + ); + + return Config.defaults( config ); } } diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/ClusterSeedingIT.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/ClusterSeedingIT.java index c740e9f978375..84daf91a9075f 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/ClusterSeedingIT.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/ClusterSeedingIT.java @@ -27,18 +27,21 @@ import java.io.File; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.causalclustering.core.CoreGraphDatabase; import org.neo4j.causalclustering.discovery.Cluster; import org.neo4j.causalclustering.discovery.CoreClusterMember; import org.neo4j.causalclustering.discovery.IpFamily; import org.neo4j.causalclustering.discovery.SharedDiscoveryService; import org.neo4j.io.fs.FileSystemAbstraction; +import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.store.format.standard.Standard; import org.neo4j.test.DbRepresentation; import org.neo4j.test.rule.TestDirectory; import org.neo4j.test.rule.fs.DefaultFileSystemRule; import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonMap; import static org.junit.Assert.assertEquals; import static org.neo4j.backup.OnlineBackupCommandIT.runBackupToolFromOtherJvmToGetExitCode; import static org.neo4j.causalclustering.backup.BackupCoreIT.backupAddress; @@ -107,7 +110,8 @@ public void shouldRestoreBySeedingAllMembers() throws Throwable { // given File backupDir = createBackupUsingAnotherCluster(); - DbRepresentation before = DbRepresentation.of( backupDir ); + Config config = Config.defaults( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ); + DbRepresentation before = DbRepresentation.of( backupDir, config ); // when fsa.copyRecursively( backupDir, cluster.getCoreMemberById( 0 ).storeDir() ); diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/RestoreClusterUtils.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/RestoreClusterUtils.java index e9800a0ea56b7..94c26fdc91958 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/RestoreClusterUtils.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/backup/RestoreClusterUtils.java @@ -21,6 +21,7 @@ import java.io.File; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Label; import org.neo4j.graphdb.Node; @@ -43,6 +44,7 @@ public static File createClassicNeo4jStore( File base, FileSystemAbstraction fil .setFileSystem( fileSystem ) .newEmbeddedDatabaseBuilder( existingDbDir ) .setConfig( GraphDatabaseSettings.record_format, recordFormat ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ) .newGraphDatabase(); for ( int i = 0; i < (nodesToCreate / 2); i++ ) diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/scenarios/ClusterCommunityToEnterpriseIT.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/scenarios/ClusterCommunityToEnterpriseIT.java index 2e5384f787f9d..1137f760d0ba8 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/scenarios/ClusterCommunityToEnterpriseIT.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/scenarios/ClusterCommunityToEnterpriseIT.java @@ -26,6 +26,7 @@ import org.junit.Rule; import org.junit.Test; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.causalclustering.discovery.Cluster; import org.neo4j.causalclustering.discovery.IpFamily; import org.neo4j.causalclustering.discovery.SharedDiscoveryService; @@ -33,6 +34,7 @@ import org.neo4j.graphdb.factory.GraphDatabaseFactory; import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.io.fs.FileSystemAbstraction; +import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Settings; import org.neo4j.kernel.impl.store.format.highlimit.HighLimit; import org.neo4j.test.DbRepresentation; @@ -41,6 +43,7 @@ import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonMap; import static org.neo4j.causalclustering.discovery.Cluster.dataMatchesEventually; public class ClusterCommunityToEnterpriseIT @@ -78,9 +81,12 @@ public void shouldRestoreBySeedingAllMembers() throws Throwable File storeDir = testDir.makeGraphDbDir(); GraphDatabaseService database = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir ) .setConfig( GraphDatabaseSettings.allow_store_upgrade, Settings.TRUE ) - .setConfig( GraphDatabaseSettings.record_format, HighLimit.NAME ).newGraphDatabase(); + .setConfig( GraphDatabaseSettings.record_format, HighLimit.NAME ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ) + .newGraphDatabase(); database.shutdown(); - DbRepresentation before = DbRepresentation.of( storeDir ); + Config config = Config.defaults( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ); + DbRepresentation before = DbRepresentation.of( storeDir, config ); // when fsa.copyRecursively( storeDir, cluster.getCoreMemberById( 0 ).storeDir() ); diff --git a/enterprise/ha/src/test/java/org/neo4j/ha/BackupHaIT.java b/enterprise/ha/src/test/java/org/neo4j/ha/BackupHaIT.java index 37c67a8793ce5..101eaaa0499f6 100644 --- a/enterprise/ha/src/test/java/org/neo4j/ha/BackupHaIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/ha/BackupHaIT.java @@ -28,7 +28,10 @@ import java.util.List; import org.neo4j.backup.OnlineBackupSettings; +import org.neo4j.com.ports.allocation.PortAuthority; +import org.neo4j.helpers.HostnamePort; import org.neo4j.kernel.configuration.Settings; +import org.neo4j.kernel.ha.HighlyAvailableGraphDatabase; import org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster; import org.neo4j.test.DbRepresentation; import org.neo4j.test.ha.ClusterRule; @@ -44,7 +47,7 @@ public class BackupHaIT @Rule public ClusterRule clusterRule = new ClusterRule( getClass() ) .withSharedSetting( OnlineBackupSettings.online_backup_enabled, Settings.TRUE ) - .withInstanceSetting( OnlineBackupSettings.online_backup_server, serverId -> ":" + (4444 + serverId) ); + .withInstanceSetting( OnlineBackupSettings.online_backup_server, serverId -> ":" + PortAuthority.allocatePort() ); @Rule public final SuppressOutput suppressOutput = SuppressOutput.suppressAll(); @@ -63,7 +66,9 @@ public void makeSureBackupCanBePerformed() throws Throwable // Run backup ManagedCluster cluster = clusterRule.startCluster(); DbRepresentation beforeChange = DbRepresentation.of( cluster.getMaster() ); - assertEquals( 0, runBackupToolFromOtherJvmToGetExitCode( backupPath, backupArguments( "localhost:4445", + HighlyAvailableGraphDatabase hagdb = cluster.getAllMembers().iterator().next(); + HostnamePort address = cluster.getBackupAddress(hagdb); + assertEquals( 0, runBackupToolFromOtherJvmToGetExitCode( backupPath, backupArguments( address.toString(), backupPath, "basic" ) ) ); // Add some new data @@ -80,13 +85,14 @@ public void makeSureBackupCanBePerformed() throws Throwable public void makeSureBackupCanBePerformedFromAnyInstance() throws Throwable { ManagedCluster cluster = clusterRule.startCluster(); - Integer[] backupPorts = {4445, 4446, 4447}; - for ( Integer port : backupPorts ) + for ( HighlyAvailableGraphDatabase hagdb : cluster.getAllMembers() ) { + HostnamePort address = cluster.getBackupAddress(hagdb); + // Run backup DbRepresentation beforeChange = DbRepresentation.of( cluster.getMaster() ); - assertEquals( 0, runBackupToolFromOtherJvmToGetExitCode( backupPath, backupArguments( "localhost:" + port, + assertEquals( 0, runBackupToolFromOtherJvmToGetExitCode( backupPath, backupArguments( address.toString(), backupPath, "anyinstance" ) ) ); // Add some new data diff --git a/enterprise/ha/src/test/java/org/neo4j/ha/BranchedDataIT.java b/enterprise/ha/src/test/java/org/neo4j/ha/BranchedDataIT.java index 0c950c7e49316..d7a304e7452ce 100644 --- a/enterprise/ha/src/test/java/org/neo4j/ha/BranchedDataIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/ha/BranchedDataIT.java @@ -31,6 +31,7 @@ import java.util.Set; import java.util.function.Consumer; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.cluster.ClusterSettings; import org.neo4j.com.ports.allocation.PortAuthority; import org.neo4j.com.storecopy.StoreUtil; @@ -101,6 +102,7 @@ public void migrationOfBranchedDataDirectories() throws Exception .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort ) .setConfig( ClusterSettings.initial_hosts, "localhost:" + clusterPort ) .setConfig( HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ) .newGraphDatabase().shutdown(); // It should have migrated those to the new location. Verify that. for ( long timestamp : timestamps ) diff --git a/enterprise/ha/src/test/java/org/neo4j/ha/ForeignStoreIdIT.java b/enterprise/ha/src/test/java/org/neo4j/ha/ForeignStoreIdIT.java index 31e8a9b2c02af..5526c76e4fe46 100644 --- a/enterprise/ha/src/test/java/org/neo4j/ha/ForeignStoreIdIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/ha/ForeignStoreIdIT.java @@ -25,12 +25,14 @@ import java.io.File; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.com.ports.allocation.PortAuthority; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory; import org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory; +import org.neo4j.kernel.configuration.Settings; import org.neo4j.test.rule.TestDirectory; import static org.junit.Assert.assertEquals; @@ -73,6 +75,7 @@ public void emptyForeignDbShouldJoinAfterHavingItsEmptyDbDeleted() throws Except .setConfig( cluster_server, "127.0.0.1:" + firstInstanceClusterPort ) .setConfig( ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) .setConfig( initial_hosts, "127.0.0.1:" + firstInstanceClusterPort ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ) .newGraphDatabase(); // -- another instance preparing to join with a store with a different store ID File foreignDbStoreDir = createAnotherStore( testDirectory.directory( "2" ), 0 ); @@ -85,6 +88,7 @@ public void emptyForeignDbShouldJoinAfterHavingItsEmptyDbDeleted() throws Except .setConfig( initial_hosts, "127.0.0.1:" + firstInstanceClusterPort ) .setConfig( cluster_server, "127.0.0.1:" + PortAuthority.allocatePort() ) .setConfig( ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ) .newGraphDatabase(); // -- and creates a node long foreignNode = createNode( foreignInstance, "foreigner" ); @@ -106,6 +110,7 @@ public void nonEmptyForeignDbShouldNotBeAbleToJoin() throws Exception .setConfig( initial_hosts, "127.0.0.1:" + firstInstanceClusterPort ) .setConfig( cluster_server, "127.0.0.1:" + firstInstanceClusterPort ) .setConfig( ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ) .newGraphDatabase(); createNodes( firstInstance, 3, "first" ); // -- another instance preparing to join with a store with a different store ID @@ -120,6 +125,7 @@ public void nonEmptyForeignDbShouldNotBeAbleToJoin() throws Exception .setConfig( cluster_server, "127.0.0.1:" + PortAuthority.allocatePort() ) .setConfig( ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) .setConfig( state_switch_timeout, "5s" ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ) .newGraphDatabase(); try @@ -153,7 +159,10 @@ private long findNode( GraphDatabaseService db, String name ) private File createAnotherStore( File directory, int transactions ) { - GraphDatabaseService db = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabase( directory ); + GraphDatabaseService db = new EnterpriseGraphDatabaseFactory() + .newEmbeddedDatabaseBuilder( directory ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ) + .newGraphDatabase(); createNodes( db, transactions, "node" ); db.shutdown(); return directory; diff --git a/enterprise/ha/src/test/java/org/neo4j/ha/PullUpdatesAppliedIT.java b/enterprise/ha/src/test/java/org/neo4j/ha/PullUpdatesAppliedIT.java index 8815e04aad793..79d7dd7033492 100644 --- a/enterprise/ha/src/test/java/org/neo4j/ha/PullUpdatesAppliedIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/ha/PullUpdatesAppliedIT.java @@ -40,6 +40,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.cluster.ClusterSettings; import org.neo4j.cluster.InstanceId; import org.neo4j.cluster.client.ClusterClient; @@ -258,6 +259,7 @@ private static HighlyAvailableGraphDatabase database( int serverId, int clusterP .setConfig( ClusterSettings.server_id, Integer.toString( serverId ) ) .setConfig( HaSettings.ha_server, "localhost:" + haPort ) .setConfig( HaSettings.pull_interval, "0ms" ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ) .newGraphDatabase(); } diff --git a/enterprise/ha/src/test/java/org/neo4j/ha/PullUpdatesIT.java b/enterprise/ha/src/test/java/org/neo4j/ha/PullUpdatesIT.java index ab25f467fb3fd..e7bd925fd7acc 100644 --- a/enterprise/ha/src/test/java/org/neo4j/ha/PullUpdatesIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/ha/PullUpdatesIT.java @@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.cluster.ClusterSettings; import org.neo4j.cluster.InstanceId; import org.neo4j.cluster.client.ClusterClient; @@ -42,6 +43,7 @@ import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.TransientTransactionFailureException; import org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory; +import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Settings; import org.neo4j.kernel.ha.HaSettings; import org.neo4j.kernel.ha.HighlyAvailableGraphDatabase; @@ -70,7 +72,6 @@ public class PullUpdatesIT { private static final int PULL_INTERVAL = 100; - private static final int SHELL_PORT = 6370; @Rule public final ClusterRule clusterRule = new ClusterRule( getClass() ); @@ -172,15 +173,19 @@ public void pullUpdatesShellAppPullsUpdates() throws Throwable withSharedSetting( HaSettings.pull_interval, "0" ). withSharedSetting( HaSettings.tx_push_factor, "0" ). withSharedSetting( ShellSettings.remote_shell_enabled, Settings.TRUE ). - withInstanceSetting( ShellSettings.remote_shell_port, - oneBasedServerId -> oneBasedServerId >= 1 && oneBasedServerId <= 2 ? - "" + (SHELL_PORT + oneBasedServerId) : null ). + withInstanceSetting( ShellSettings.remote_shell_port, i -> String.valueOf( PortAuthority.allocatePort() ) ). startCluster(); long commonNodeId = createNodeOnMaster( cluster ); setProperty( cluster.getMaster(), commonNodeId, 1 ); - callPullUpdatesViaShell( 2 ); + + int shellPort = cluster.getAnySlave() + .getDependencyResolver().resolveDependency( Config.class ) + .get( ShellSettings.remote_shell_port ); + + callPullUpdatesViaShell( shellPort ); + HighlyAvailableGraphDatabase slave = cluster.getAnySlave(); try ( Transaction tx = slave.beginTx() ) { @@ -205,6 +210,7 @@ public void shouldPullUpdatesOnStartupNoMatterWhat() throws Exception .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + masterClusterPort ) .setConfig( ClusterSettings.initial_hosts, "localhost:" + masterClusterPort ) .setConfig( HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ) .newGraphDatabase(); // Copy the store, then shutdown, so update pulling later makes sense @@ -215,6 +221,7 @@ public void shouldPullUpdatesOnStartupNoMatterWhat() throws Exception .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + PortAuthority.allocatePort() ) .setConfig( ClusterSettings.initial_hosts, "localhost:" + masterClusterPort ) .setConfig( HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ) .newGraphDatabase(); // Required to block until the slave has left for sure @@ -256,6 +263,7 @@ public void leftCluster( InstanceId instanceId, URI member ) .setConfig( ClusterSettings.initial_hosts, "localhost:" + masterClusterPort ) .setConfig( HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) .setConfig( HaSettings.pull_interval, "0" ) // no pull updates, should pull on startup + .setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ) .newGraphDatabase(); slave.beginTx().close(); // Make sure switch to slave completes and so does the update pulling on startup @@ -302,9 +310,9 @@ private static long createNodeOn( GraphDatabaseService db ) } } - private void callPullUpdatesViaShell( int i ) throws ShellException + private void callPullUpdatesViaShell( int port ) throws ShellException { - ShellClient client = ShellLobby.newClient( SHELL_PORT + i ); + ShellClient client = ShellLobby.newClient( port ); client.evaluate( "pullupdates" ); } diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/ConcurrentInstanceStartupIT.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/ConcurrentInstanceStartupIT.java index 6f9595478f8b0..38e73980df9b7 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/ConcurrentInstanceStartupIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/ConcurrentInstanceStartupIT.java @@ -19,26 +19,27 @@ */ package org.neo4j.kernel.ha; -import org.junit.Rule; -import org.junit.Test; +import static org.junit.Assert.assertTrue; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CyclicBarrier; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import org.junit.Rule; +import org.junit.Test; import org.neo4j.cluster.ClusterSettings; +import org.neo4j.com.ports.allocation.PortAuthority; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.factory.GraphDatabaseBuilder; import org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory; import org.neo4j.test.rule.TestDirectory; -import static org.junit.Assert.assertTrue; - public class ConcurrentInstanceStartupIT { - public static final int INSTANCE_COUNT = 3; @Rule public TestDirectory testDirectory = TestDirectory.testDirectory(); @@ -47,17 +48,17 @@ public void concurrentStartupShouldWork() throws Exception { // Ensures that the instances don't race to create the test's base directory and only care about their own. testDirectory.directory( "nothingToSeeHereMoveAlong" ); - StringBuffer initialHostsBuffer = new StringBuffer( "127.0.0.1:5001" ); - for ( int i = 2; i <= INSTANCE_COUNT; i++ ) - { - initialHostsBuffer.append( ",127.0.0.1:500" + i ); - } - final String initialHosts = initialHostsBuffer.toString(); - final CyclicBarrier barrier = new CyclicBarrier( INSTANCE_COUNT ); - final List daThreads = new ArrayList( INSTANCE_COUNT ); - final HighlyAvailableGraphDatabase[] dbs = new HighlyAvailableGraphDatabase[INSTANCE_COUNT]; + int[] clusterPorts = new int[]{ + PortAuthority.allocatePort(), + PortAuthority.allocatePort(), + PortAuthority.allocatePort() + }; + final String initialHosts = initialHosts( clusterPorts ); + final CyclicBarrier barrier = new CyclicBarrier( clusterPorts.length ); + final List daThreads = new ArrayList<>( clusterPorts.length ); + final HighlyAvailableGraphDatabase[] dbs = new HighlyAvailableGraphDatabase[clusterPorts.length]; - for ( int i = 1; i <= INSTANCE_COUNT; i++ ) + for ( int i = 0; i < clusterPorts.length; i++ ) { final int finalI = i; @@ -66,7 +67,7 @@ public void concurrentStartupShouldWork() throws Exception try { barrier.await(); - dbs[finalI - 1] = startDbAtBase( finalI, initialHosts ); + dbs[finalI] = startDbAtBase( finalI, initialHosts, clusterPorts[finalI] ); } catch ( InterruptedException | BrokenBarrierException e ) { @@ -109,14 +110,21 @@ public void concurrentStartupShouldWork() throws Exception } } - private HighlyAvailableGraphDatabase startDbAtBase( int i, String initialHosts ) + private String initialHosts( int[] clusterPorts ) + { + return IntStream.of( clusterPorts ) + .mapToObj( i -> "127.0.0.1:" + i ) + .collect( Collectors.joining( "," ) ); + } + + private HighlyAvailableGraphDatabase startDbAtBase( int i, String initialHosts, int clusterPort ) { GraphDatabaseBuilder masterBuilder = new TestHighlyAvailableGraphDatabaseFactory() .newEmbeddedDatabaseBuilder( path( i ).getAbsoluteFile() ) .setConfig( ClusterSettings.initial_hosts, initialHosts ) - .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + ( 5000 + i ) ) + .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort ) .setConfig( ClusterSettings.server_id, "" + i ) - .setConfig( HaSettings.ha_server, ":" + ( 8000 + i ) ) + .setConfig( HaSettings.ha_server, ":" + PortAuthority.allocatePort() ) .setConfig( HaSettings.tx_push_factor, "0" ); return (HighlyAvailableGraphDatabase) masterBuilder.newGraphDatabase(); } diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/ConflictingServerIdIT.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/ConflictingServerIdIT.java index 691b12e04599d..a2d85227d945f 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/ConflictingServerIdIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/ConflictingServerIdIT.java @@ -24,6 +24,7 @@ import java.io.File; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.cluster.ClusterSettings; import org.neo4j.com.ports.allocation.PortAuthority; import org.neo4j.graphdb.Transaction; @@ -56,7 +57,8 @@ public void testConflictingIdDoesNotSilentlyFail() throws Exception .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + masterClusterPort ) .setConfig( ClusterSettings.server_id, "" + 1 ) .setConfig( HaSettings.ha_server, ":" + PortAuthority.allocatePort() ) - .setConfig( HaSettings.tx_push_factor, "0" ); + .setConfig( HaSettings.tx_push_factor, "0" ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ); master = (HighlyAvailableGraphDatabase) masterBuilder.newGraphDatabase(); GraphDatabaseBuilder db21Builder = new TestHighlyAvailableGraphDatabaseFactory() @@ -65,7 +67,8 @@ public void testConflictingIdDoesNotSilentlyFail() throws Exception .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + PortAuthority.allocatePort() ) .setConfig( ClusterSettings.server_id, "" + 2 ) .setConfig( HaSettings.ha_server, ":" + PortAuthority.allocatePort() ) - .setConfig( HaSettings.tx_push_factor, "0" ); + .setConfig( HaSettings.tx_push_factor, "0" ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ); dbWithId21 = (HighlyAvailableGraphDatabase) db21Builder.newGraphDatabase(); GraphDatabaseBuilder db22Builder = new TestHighlyAvailableGraphDatabaseFactory() @@ -74,7 +77,8 @@ public void testConflictingIdDoesNotSilentlyFail() throws Exception .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + PortAuthority.allocatePort() ) .setConfig( ClusterSettings.server_id, "" + 2 ) // Conflicting with the above .setConfig( HaSettings.ha_server, ":" + PortAuthority.allocatePort() ) - .setConfig( HaSettings.tx_push_factor, "0" ); + .setConfig( HaSettings.tx_push_factor, "0" ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ); try { diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaIPv6ConfigurationTest.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaIPv6ConfigurationIT.java similarity index 81% rename from enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaIPv6ConfigurationTest.java rename to enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaIPv6ConfigurationIT.java index 6cf053defdc8e..a3bf48c81bb07 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaIPv6ConfigurationTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaIPv6ConfigurationIT.java @@ -28,7 +28,9 @@ import java.net.NetworkInterface; import java.util.Enumeration; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.cluster.ClusterSettings; +import org.neo4j.com.ports.allocation.PortAuthority; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.factory.HighlyAvailableGraphDatabaseFactory; @@ -37,7 +39,7 @@ /** * Test various IPv6 configuration options on a single HA instance. */ -public class HaIPv6ConfigurationTest +public class HaIPv6ConfigurationIT { @Rule public TestDirectory dir = TestDirectory.testDirectory(); @@ -45,12 +47,14 @@ public class HaIPv6ConfigurationTest @Test public void testClusterWithLocalhostAddresses() throws Throwable { + int clusterPort = PortAuthority.allocatePort(); GraphDatabaseService db = new HighlyAvailableGraphDatabaseFactory() .newEmbeddedDatabaseBuilder( dir.makeGraphDbDir() ) - .setConfig( ClusterSettings.cluster_server, ipv6HostPortSetting( "::1", 5000 ) ) - .setConfig( ClusterSettings.initial_hosts, ipv6HostPortSetting( "::1", 5000 ) ) - .setConfig( HaSettings.ha_server, ipv6HostPortSetting( "::1", 6000 ) ) + .setConfig( ClusterSettings.cluster_server, ipv6HostPortSetting( "::1", clusterPort ) ) + .setConfig( ClusterSettings.initial_hosts, ipv6HostPortSetting( "::1", clusterPort ) ) + .setConfig( HaSettings.ha_server, ipv6HostPortSetting( "::1", PortAuthority.allocatePort() ) ) .setConfig( ClusterSettings.server_id, "1" ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ) .newGraphDatabase(); try ( Transaction tx = db.beginTx() ) @@ -95,12 +99,14 @@ public void testClusterWithLinkLocalAddress() throws Throwable private void testWithAddress( InetAddress inetAddress ) throws Exception { + int clusterPort = PortAuthority.allocatePort(); GraphDatabaseService db = new HighlyAvailableGraphDatabaseFactory() .newEmbeddedDatabaseBuilder( dir.makeGraphDbDir() ) - .setConfig( ClusterSettings.cluster_server, ipv6HostPortSetting( inetAddress.getHostAddress(), 5000 ) ) - .setConfig( ClusterSettings.initial_hosts, ipv6HostPortSetting( inetAddress.getHostAddress(), 5000 ) ) - .setConfig( HaSettings.ha_server, ipv6HostPortSetting( "::", 6000 ) ) + .setConfig( ClusterSettings.cluster_server, ipv6HostPortSetting( inetAddress.getHostAddress(), clusterPort ) ) + .setConfig( ClusterSettings.initial_hosts, ipv6HostPortSetting( inetAddress.getHostAddress(), clusterPort ) ) + .setConfig( HaSettings.ha_server, ipv6HostPortSetting( "::", PortAuthority.allocatePort() ) ) .setConfig( ClusterSettings.server_id, "1" ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ) .newGraphDatabase(); try ( Transaction tx = db.beginTx() ) @@ -115,12 +121,14 @@ private void testWithAddress( InetAddress inetAddress ) throws Exception @Test public void testClusterWithWildcardAddresses() throws Throwable { + int clusterPort = PortAuthority.allocatePort(); GraphDatabaseService db = new HighlyAvailableGraphDatabaseFactory() .newEmbeddedDatabaseBuilder( dir.makeGraphDbDir() ) - .setConfig( ClusterSettings.cluster_server, ipv6HostPortSetting( "::", 5000 ) ) - .setConfig( ClusterSettings.initial_hosts, ipv6HostPortSetting( "::1", 5000 ) ) - .setConfig( HaSettings.ha_server, ipv6HostPortSetting( "::", 6000 ) ) + .setConfig( ClusterSettings.cluster_server, ipv6HostPortSetting( "::", clusterPort ) ) + .setConfig( ClusterSettings.initial_hosts, ipv6HostPortSetting( "::1", clusterPort ) ) + .setConfig( HaSettings.ha_server, ipv6HostPortSetting( "::", PortAuthority.allocatePort() ) ) .setConfig( ClusterSettings.server_id, "1" ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ) .newGraphDatabase(); try ( Transaction tx = db.beginTx() ) diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HardKillIT.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HardKillIT.java index bcaaaa037e408..16fbf48aafc6b 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HardKillIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HardKillIT.java @@ -31,16 +31,17 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.cluster.ClusterSettings; import org.neo4j.cluster.client.ClusterClient; import org.neo4j.cluster.member.paxos.MemberIsAvailable; -import org.neo4j.cluster.protocol.atomicbroadcast.AtomicBroadcastListener; import org.neo4j.cluster.protocol.atomicbroadcast.AtomicBroadcastSerializer; import org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory; -import org.neo4j.cluster.protocol.atomicbroadcast.Payload; +import org.neo4j.com.ports.allocation.PortAuthority; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory; +import org.neo4j.kernel.configuration.Settings; import org.neo4j.kernel.ha.cluster.member.ClusterMember; import org.neo4j.kernel.ha.cluster.member.ClusterMembers; import org.neo4j.kernel.ha.cluster.modeswitch.HighAvailabilityModeSwitcher; @@ -70,11 +71,20 @@ public void testMasterSwitchHappensOnKillMinus9() throws Exception HighlyAvailableGraphDatabase dbWithId2 = null; HighlyAvailableGraphDatabase dbWithId3 = null; HighlyAvailableGraphDatabase oldMaster = null; + + int clusterPort1 = PortAuthority.allocatePort(); + int clusterPort2 = PortAuthority.allocatePort(); + int clusterPort3 = PortAuthority.allocatePort(); + + int haPort1 = PortAuthority.allocatePort(); + int haPort2 = PortAuthority.allocatePort(); + int haPort3 = PortAuthority.allocatePort(); + try { - proc = run( 1 ); - dbWithId2 = startDb( 2, path( 2 ) ); - dbWithId3 = startDb( 3, path( 3 ) ); + proc = run( 1, clusterPort1, haPort1, clusterPort1, clusterPort2 ); + dbWithId2 = startDb( 2, path( 2 ), clusterPort2, haPort2, clusterPort1, clusterPort2 ); + dbWithId3 = startDb( 3, path( 3 ), clusterPort3, haPort3, clusterPort1, clusterPort2 ); waitUntilAllProperlyAvailable( dbWithId2, 1, MASTER, 2, SLAVE, 3, SLAVE ); waitUntilAllProperlyAvailable( dbWithId3, 1, MASTER, 2, SLAVE, 3, SLAVE ); @@ -113,7 +123,7 @@ public void testMasterSwitchHappensOnKillMinus9() throws Exception waitUntilAllProperlyAvailable( dbWithId2, 1, UNKNOWN, 2, MASTER, 3, SLAVE ); waitUntilAllProperlyAvailable( dbWithId3, 1, UNKNOWN, 2, MASTER, 3, SLAVE ); - oldMaster = startDb( 1, path( 1 ) ); + oldMaster = startDb( 1, path( 1 ), clusterPort1, haPort1, clusterPort1, clusterPort2 ); long oldMasterNode = createNamedNode( oldMaster, "Old master" ); assertEquals( oldMasterNode, getNamedNode( dbWithId2, "Old master" ) ); } @@ -166,12 +176,16 @@ private long createNamedNode( HighlyAvailableGraphDatabase db, String name ) } } - private Process run( int machineId ) throws IOException + private Process run( int machineId, int clusterPort, int haPort, int initialHost1, int initialHost2 ) throws IOException { List allArgs = new ArrayList<>( Arrays.asList( "java", "-cp", System.getProperty( "java.class.path" ), "-Djava.awt.headless=true", HardKillIT.class.getName() ) ); allArgs.add( "" + machineId ); allArgs.add( path( machineId ).getAbsolutePath() ); + allArgs.add( String.valueOf( clusterPort ) ); + allArgs.add( String.valueOf( haPort ) ); + allArgs.add( String.valueOf( initialHost1 ) ); + allArgs.add( String.valueOf( initialHost2 ) ); Process process = Runtime.getRuntime().exec( allArgs.toArray( new String[allArgs.size()] ) ); processHandler = new ProcessStreamHandler( process, false ); @@ -184,7 +198,13 @@ private Process run( int machineId ) throws IOException */ public static void main( String[] args ) throws InterruptedException { - HighlyAvailableGraphDatabase db = startDb( Integer.parseInt( args[0] ), new File( args[1] ) ); + int serverId = Integer.parseInt( args[0] ); + File path = new File( args[1] ); + int clusterPort = Integer.parseInt( args[2] ); + int haPort = Integer.parseInt( args[3] ); + int initialHost1 = Integer.parseInt( args[4] ); + int initialHost2 = Integer.parseInt( args[5] ); + HighlyAvailableGraphDatabase db = startDb( serverId, path, clusterPort, haPort, initialHost1, initialHost2 ); waitUntilAllProperlyAvailable( db, 1, MASTER, 2, SLAVE, 3, SLAVE ); } @@ -192,7 +212,7 @@ private static void waitUntilAllProperlyAvailable( HighlyAvailableGraphDatabase throws InterruptedException { ClusterMembers members = db.getDependencyResolver().resolveDependency( ClusterMembers.class ); - long endTime = currentTimeMillis() + SECONDS.toMillis( 60 ); + long endTime = currentTimeMillis() + SECONDS.toMillis( 120 ); Map expectedStates = toExpectedStatesMap( expected ); while ( currentTimeMillis() < endTime && !allMembersAreAsExpected( members, expectedStates ) ) { @@ -232,17 +252,18 @@ private static Map toExpectedStatesMap( Object[] expected ) return expectedStates; } - private static HighlyAvailableGraphDatabase startDb( int serverId, File path ) + private static HighlyAvailableGraphDatabase startDb( int serverId, File path, int clusterPort, int haPort, int initialHost1, int initialHost2 ) { return (HighlyAvailableGraphDatabase) new TestHighlyAvailableGraphDatabaseFactory() .newEmbeddedDatabaseBuilder( path ) - .setConfig( ClusterSettings.initial_hosts, "127.0.0.1:7102,127.0.0.1:7103" ) - .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + (7101 + serverId) ) + .setConfig( ClusterSettings.initial_hosts, String.format( "127.0.0.1:%d,127.0.0.1:%d", initialHost1, initialHost2 ) ) + .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort ) .setConfig( ClusterSettings.server_id, "" + serverId ) .setConfig( ClusterSettings.heartbeat_timeout, "5s" ) .setConfig( ClusterSettings.default_timeout, "1s" ) - .setConfig( HaSettings.ha_server, ":" + (7501 + serverId) ) + .setConfig( HaSettings.ha_server, ":" + haPort ) .setConfig( HaSettings.tx_push_factor, "0" ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ) .newGraphDatabase(); } diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/factory/HighlyAvailableEditionModuleIntegrationTest.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/factory/HighlyAvailableEditionModuleIT.java similarity index 98% rename from enterprise/ha/src/test/java/org/neo4j/kernel/ha/factory/HighlyAvailableEditionModuleIntegrationTest.java rename to enterprise/ha/src/test/java/org/neo4j/kernel/ha/factory/HighlyAvailableEditionModuleIT.java index da1e4f0d0a2e5..5f9b10a37969b 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/factory/HighlyAvailableEditionModuleIntegrationTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/factory/HighlyAvailableEditionModuleIT.java @@ -43,7 +43,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -public class HighlyAvailableEditionModuleIntegrationTest +public class HighlyAvailableEditionModuleIT { @Rule public ClusterRule clusterRule = new ClusterRule( getClass() ); diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/impl/ha/ClusterManager.java b/enterprise/ha/src/test/java/org/neo4j/kernel/impl/ha/ClusterManager.java index 127ccec06d2d1..25240f9cae2ef 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/impl/ha/ClusterManager.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/impl/ha/ClusterManager.java @@ -19,6 +19,16 @@ */ package org.neo4j.kernel.impl.ha; +import static java.lang.String.format; +import static java.util.Arrays.asList; +import static java.util.Collections.unmodifiableMap; +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.neo4j.helpers.ArrayUtil.contains; +import static org.neo4j.helpers.collection.Iterables.asList; +import static org.neo4j.helpers.collection.Iterables.count; +import static org.neo4j.helpers.collection.MapUtil.stringMap; +import static org.neo4j.io.fs.FileUtils.copyRecursively; + import java.io.File; import java.io.IOException; import java.net.InetAddress; @@ -61,6 +71,7 @@ import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.HighlyAvailableGraphDatabaseFactory; import org.neo4j.helpers.AdvertisedSocketAddress; +import org.neo4j.helpers.HostnamePort; import org.neo4j.helpers.collection.Iterables; import org.neo4j.helpers.collection.MapUtil; import org.neo4j.io.pagecache.IOLimiter; @@ -86,16 +97,6 @@ import org.neo4j.logging.Log; import org.neo4j.storageengine.api.StorageEngine; -import static java.lang.String.format; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableMap; -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.neo4j.helpers.ArrayUtil.contains; -import static org.neo4j.helpers.collection.Iterables.asList; -import static org.neo4j.helpers.collection.Iterables.count; -import static org.neo4j.helpers.collection.MapUtil.stringMap; -import static org.neo4j.io.fs.FileUtils.copyRecursively; - /** * Utility for spinning up an HA cluster inside the same JVM. Only intended for being used in tests * as well as other tools that may need a cluster conveniently within the same JVM. @@ -935,6 +936,13 @@ public String getBoltAddress( HighlyAvailableGraphDatabase db ) new GraphDatabaseSettings.BoltConnector( "bolt" ).advertised_address ).toString(); } + public HostnamePort getBackupAddress( HighlyAvailableGraphDatabase hagdb ) + { + return hagdb.getDependencyResolver() + .resolveDependency( Config.class ) + .get( OnlineBackupSettings.online_backup_server ); + } + /** * @return the current master in the cluster. * @throws IllegalStateException if there's no current master. @@ -1192,12 +1200,15 @@ public void stop() throws Throwable else { URI clusterUri = clusterUri( member ); - Config config = Config.defaults( MapUtil.stringMap( - ClusterSettings.cluster_name.name(), name, - ClusterSettings.initial_hosts.name(), initialHosts, - ClusterSettings.server_id.name(), serverId + "", - ClusterSettings.cluster_server.name(), "0.0.0.0:" + clusterUri.getPort() ) ); - + Config config = Config.defaults( + MapUtil.stringMap( + ClusterSettings.cluster_name.name(), name, + ClusterSettings.initial_hosts.name(), initialHosts, + ClusterSettings.server_id.name(), serverId + "", + ClusterSettings.cluster_server.name(), "0.0.0.0:" + clusterUri.getPort(), + OnlineBackupSettings.online_backup_enabled.name(), Settings.FALSE + ) + ); LifeSupport clusterClientLife = new LifeSupport(); LogService logService = NullLogService.getInstance(); ClusterClientModule clusterClientModule = new ClusterClientModule( clusterClientLife, diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/internal/HaKernelDataTest.java b/enterprise/ha/src/test/java/org/neo4j/kernel/internal/HaKernelDataIT.java similarity index 80% rename from enterprise/ha/src/test/java/org/neo4j/kernel/internal/HaKernelDataTest.java rename to enterprise/ha/src/test/java/org/neo4j/kernel/internal/HaKernelDataIT.java index 50c3b7bf25f18..83c2893768274 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/internal/HaKernelDataTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/internal/HaKernelDataIT.java @@ -22,15 +22,18 @@ import org.junit.Rule; import org.junit.Test; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.cluster.ClusterSettings; +import org.neo4j.com.ports.allocation.PortAuthority; import org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory; +import org.neo4j.kernel.ha.HaSettings; import org.neo4j.kernel.ha.HighlyAvailableGraphDatabase; import org.neo4j.test.ManagedResource; import org.neo4j.test.rule.TestDirectory; import static org.junit.Assert.assertSame; -public class HaKernelDataTest +public class HaKernelDataIT { @Test public void shouldReturnHaGraphDbFromKernelData() throws Exception @@ -49,10 +52,15 @@ public void shouldReturnHaGraphDbFromKernelData() throws Exception @Override protected HighlyAvailableGraphDatabase createResource( TestDirectory dir ) throws Exception { + int clusterPort = PortAuthority.allocatePort(); + return (HighlyAvailableGraphDatabase) new TestHighlyAvailableGraphDatabaseFactory(). newEmbeddedDatabaseBuilder( dir.directory().getAbsoluteFile() ) .setConfig( ClusterSettings.server_id, "1" ) - .setConfig( ClusterSettings.initial_hosts, ":5001" ) + .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort ) + .setConfig( ClusterSettings.initial_hosts, "127.0.0.1:" + clusterPort ) + .setConfig( HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ) .newGraphDatabase(); } diff --git a/enterprise/ha/src/test/java/org/neo4j/test/ha/ClusterIT.java b/enterprise/ha/src/test/java/org/neo4j/test/ha/ClusterIT.java index af383a74da492..52eb0b684a08f 100644 --- a/enterprise/ha/src/test/java/org/neo4j/test/ha/ClusterIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/test/ha/ClusterIT.java @@ -30,6 +30,7 @@ import java.util.logging.Level; import org.junit.rules.TestName; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.cluster.ClusterSettings; import org.neo4j.com.ports.allocation.PortAuthority; import org.neo4j.graphdb.DependencyResolver; @@ -86,7 +87,8 @@ public void testCluster() throws Throwable .withSharedConfig( stringMap( HaSettings.ha_server.name(), "localhost:6001-9999", - HaSettings.tx_push_factor.name(), "2" ) ) + HaSettings.tx_push_factor.name(), "2", + OnlineBackupSettings.online_backup_enabled.name(), Boolean.FALSE.toString() ) ) .build(); createClusterWithNode( clusterManager ); @@ -105,7 +107,8 @@ public void testClusterWithHostnames() throws Throwable .withCluster( clusterOfSize( "localhost", 3 ) ) .withSharedConfig( stringMap( HaSettings.ha_server.name(), "localhost:6001-9999", - HaSettings.tx_push_factor.name(), "2" ) ) + HaSettings.tx_push_factor.name(), "2", + OnlineBackupSettings.online_backup_enabled.name(), Boolean.FALSE.toString() ) ) .build(); createClusterWithNode( clusterManager ); } @@ -118,7 +121,10 @@ public void testClusterWithWildcardIP() throws Throwable .withSharedConfig( stringMap( HaSettings.ha_server.name(), "0.0.0.0:6001-9999", - HaSettings.tx_push_factor.name(), "2" ) ) + HaSettings.tx_push_factor.name(), "2", + OnlineBackupSettings.online_backup_enabled.name(), Boolean.FALSE.toString() + ) + ) .build(); createClusterWithNode( clusterManager ); } @@ -140,6 +146,7 @@ public void testInstancesWithConflictingClusterPorts() throws Throwable .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort ) .setConfig( ClusterSettings.server_id, "1" ) .setConfig( HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ) .newGraphDatabase(); try @@ -152,6 +159,7 @@ public void testInstancesWithConflictingClusterPorts() throws Throwable .setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort ) .setConfig( ClusterSettings.server_id, "2" ) .setConfig( HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ) + .setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ) .newGraphDatabase(); failed.shutdown(); fail("Should not start when ports conflict"); @@ -211,7 +219,10 @@ public void givenEmptyHostListWhenClusterStartupThenFormClusterWithSingleInstanc HighlyAvailableGraphDatabase db = (HighlyAvailableGraphDatabase) new TestHighlyAvailableGraphDatabaseFactory(). newEmbeddedDatabaseBuilder( testDirectory.directory( testName.getMethodName() ) ). setConfig( ClusterSettings.server_id, "1" ). + setConfig( ClusterSettings.cluster_server, "127.0.0.1:" + PortAuthority.allocatePort() ). setConfig( ClusterSettings.initial_hosts, "" ). + setConfig( HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort() ). + setConfig( OnlineBackupSettings.online_backup_enabled, Boolean.FALSE.toString() ). newGraphDatabase(); try diff --git a/enterprise/ha/src/test/java/slavetest/InstanceJoinIT.java b/enterprise/ha/src/test/java/slavetest/InstanceJoinIT.java index 06a23690256c1..d08f4bd321264 100644 --- a/enterprise/ha/src/test/java/slavetest/InstanceJoinIT.java +++ b/enterprise/ha/src/test/java/slavetest/InstanceJoinIT.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.util.Map; +import org.neo4j.backup.OnlineBackupSettings; import org.neo4j.cluster.ClusterSettings; import org.neo4j.com.ports.allocation.PortAuthority; import org.neo4j.graphdb.Node; @@ -179,6 +180,7 @@ private static HighlyAvailableGraphDatabase start( File storeDir, int i, Map