Skip to content

Commit

Permalink
Fix and add test for starting enterprise in SINGLE mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfurmanski committed Jan 27, 2016
1 parent 5881b93 commit f34e2ea
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
Expand Up @@ -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<String> 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()] );
Expand All @@ -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 );
Expand All @@ -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() ) ) );

Expand All @@ -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() ) ) );
Expand Down
Expand Up @@ -36,7 +36,10 @@ public class EnterpriseServerConfigLoader extends BaseServerConfigLoader
public Config loadConfig( File configFile, File legacyConfigFile, Log log, Pair<String,String>... 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;
}
}
Expand Up @@ -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
Expand All @@ -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" )
));

Expand Down

0 comments on commit f34e2ea

Please sign in to comment.