diff --git a/community/server/src/test/java/org/neo4j/server/BaseBootstrapperTest.java b/community/server/src/test/java/org/neo4j/server/BaseBootstrapperTest.java index 4402549be71fa..9bdd670d97724 100644 --- a/community/server/src/test/java/org/neo4j/server/BaseBootstrapperTest.java +++ b/community/server/src/test/java/org/neo4j/server/BaseBootstrapperTest.java @@ -52,23 +52,13 @@ public abstract class BaseBootstrapperTest extends ExclusiveServerTestBase protected Bootstrapper bootstrapper; - protected String[] baseConfig() - { - return new String[]{}; - } - - protected String[] completeCommandLineConfig( String... additional ) + protected String[] commandLineConfig( String... params ) { ArrayList config = new ArrayList<>(); - for ( String baseConfig : baseConfig() ) - { - config.add( baseConfig ); - } - - for ( String extra : additional ) + for ( String param : params ) { - config.add( extra ); + config.add( param ); } return config.toArray( new String[config.size()] ); @@ -95,7 +85,7 @@ public void after() public void shouldStartStopNeoServerWithoutAnyConfigFiles() { // When - int resultCode = start( bootstrapper, completeCommandLineConfig( "-c", configOption( legacy_db_location.name(), tempDir.getRoot().getAbsolutePath() ) ) ); + int resultCode = start( bootstrapper, commandLineConfig( "-c", configOption( legacy_db_location.name(), tempDir.getRoot().getAbsolutePath() ) ) ); // Then assertEquals( Bootstrapper.OK, resultCode ); @@ -113,7 +103,7 @@ public void canSpecifyConfigFile() throws Throwable ), configFile ); // When - start( bootstrapper, completeCommandLineConfig( + start( bootstrapper, commandLineConfig( "-C", configFile.getAbsolutePath(), "-c", configOption( legacy_db_location.name(), tempDir.getRoot().getAbsolutePath() ) ) ); @@ -132,7 +122,7 @@ public void canOverrideConfigValues() throws Throwable ), configFile ); // When - start( bootstrapper, completeCommandLineConfig( + start( bootstrapper, commandLineConfig( "-C", configFile.getAbsolutePath(), "-c", configOption( forced_kernel_id.name(), "mycustomvalue" ), "-c", configOption( legacy_db_location.name(), tempDir.getRoot().getAbsolutePath() ) ) ); diff --git a/enterprise/server-enterprise/src/main/java/org/neo4j/server/enterprise/EnterpriseServerConfigLoader.java b/enterprise/server-enterprise/src/main/java/org/neo4j/server/enterprise/EnterpriseServerConfigLoader.java index 11c1fe6f485ee..6bca16e9fd58d 100644 --- a/enterprise/server-enterprise/src/main/java/org/neo4j/server/enterprise/EnterpriseServerConfigLoader.java +++ b/enterprise/server-enterprise/src/main/java/org/neo4j/server/enterprise/EnterpriseServerConfigLoader.java @@ -36,7 +36,10 @@ public class EnterpriseServerConfigLoader extends BaseServerConfigLoader public Config loadConfig( File configFile, File legacyConfigFile, Log log, Pair... configOverrides ) { Config config = super.loadConfig( configFile, legacyConfigFile, log, configOverrides ); - config.registerSettingsClasses( asList( HaSettings.class, ClusterSettings.class ) ); + if ( config.get( EnterpriseServerSettings.mode ).equals( "HA" ) ) + { + config.registerSettingsClasses( asList( HaSettings.class, ClusterSettings.class ) ); + } return config; } } diff --git a/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/EnterpriseBootstrapperTest.java b/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/EnterpriseBootstrapperTest.java index 9dc9d8aa40e55..ae10524fccbc9 100644 --- a/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/EnterpriseBootstrapperTest.java +++ b/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/EnterpriseBootstrapperTest.java @@ -27,6 +27,7 @@ import org.neo4j.server.Bootstrapper; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.neo4j.server.CommunityBootstrapper.start; public class EnterpriseBootstrapperTest extends BaseBootstrapperTest @@ -37,21 +38,42 @@ protected Bootstrapper newBootstrapper() return new EnterpriseBootstrapper(); } - @Override - protected String[] baseConfig() + @Test + public void shouldBeAbleToStartInSingleMode() throws Exception + { + // When + int resultCode = start( bootstrapper, commandLineConfig( + "-c", configOption( EnterpriseServerSettings.mode.name(), "SINGLE" ) + )); + + // Then + assertEquals( Bootstrapper.OK, resultCode ); + assertNotNull( bootstrapper.getServer() ); + } + + @Test + public void shouldBeAbleToStartInHAMode() throws Exception { - return new String[] - { - "-c", configOption( ClusterSettings.server_id.name(), "1" ), - "-c", configOption( ClusterSettings.initial_hosts.name(), "127.0.0.1:5001" ) - }; + // When + int resultCode = start( bootstrapper, commandLineConfig( + "-c", configOption( EnterpriseServerSettings.mode.name(), "HA" ), + "-c", configOption( ClusterSettings.server_id.name(), "1" ), + "-c", configOption( ClusterSettings.initial_hosts.name(), "127.0.0.1:5001" ) + )); + + // Then + assertEquals( Bootstrapper.OK, resultCode ); + assertNotNull( bootstrapper.getServer() ); } @Test - public void shouldMigrateFixedPushStrategy() throws Exception + public void shouldMigrateFixedPushStrategyInHA() throws Exception { // When - start( bootstrapper, completeCommandLineConfig( + start( bootstrapper, commandLineConfig( + "-c", configOption( EnterpriseServerSettings.mode.name(), "HA" ), + "-c", configOption( ClusterSettings.server_id.name(), "1" ), + "-c", configOption( ClusterSettings.initial_hosts.name(), "127.0.0.1:5001" ), "-c", configOption( HaSettings.tx_push_strategy.name(), "fixed" ) ));