Search in sources :

Example 6 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class ValidateUniquePortsStepTest method testWithTwoInstancesWithDuplicateHttpPorts.

/**
 * Test with 2 instances; the http ports are duplicates, the transport ports are unique.
 */
@Test(expected = ElasticsearchSetupException.class)
public void testWithTwoInstancesWithDuplicateHttpPorts() {
    ClusterConfiguration config = buildConfig(2000, 2010, 2000, 2011);
    new ValidateUniquePortsStep().execute(config);
}
Also used : ClusterConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration) Test(org.junit.Test)

Example 7 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class RemoveExistingDataStepTest method testRemoveExistingData.

@Test
public void testRemoveExistingData() {
    InstanceConfiguration instanceConfig = mock(InstanceConfiguration.class);
    when(instanceConfig.getBaseDir()).thenReturn(".");
    ClusterConfiguration clusterConfig = new ClusterConfiguration.Builder().withKeepExistingData(false).build();
    when(instanceConfig.getClusterConfiguration()).thenReturn(clusterConfig);
    new RemoveExistingDataStep().execute(instanceConfig);
    // a bit convoluted, but this check that getBaseDir()
    // was called in order to build the data and logs directories.
    Mockito.verify(instanceConfig).getBaseDir();
}
Also used : InstanceConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration) ClusterConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration) Test(org.junit.Test)

Example 8 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class RemoveExistingDataStepTest method testKeepExistingData.

@Test
public void testKeepExistingData() {
    InstanceConfiguration instanceConfig = mock(InstanceConfiguration.class);
    ClusterConfiguration clusterConfig = new ClusterConfiguration.Builder().withKeepExistingData(true).build();
    when(instanceConfig.getClusterConfiguration()).thenReturn(clusterConfig);
    new RemoveExistingDataStep().execute(instanceConfig);
    // a bit convoluted, but this check that getBaseDir()
    // was never called in order to build the data and logs directories.
    Mockito.verify(instanceConfig, never()).getBaseDir();
}
Also used : InstanceConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration) ClusterConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration) Test(org.junit.Test)

Example 9 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class WaitToStartClusterStep method execute.

@Override
public void execute(ClusterConfiguration config) {
    try (ElasticsearchClient client = new ElasticsearchClient.Builder().withInstanceConfiguration(config.getInstanceConfigurationList().get(0)).withHostname("localhost").build()) {
        Monitor monitor = new Monitor(client, config.getLog());
        monitor.waitToStartCluster(config.getClusterName(), config.getInstanceConfigurationList().size(), config.getStartupTimeout());
    }
}
Also used : Monitor(com.github.alexcojocaru.mojo.elasticsearch.v2.client.Monitor) ElasticsearchClient(com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchClient)

Example 10 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class ValidateVersionStepTest method testCheckVersionWithCorrectVersion.

/**
 * Test the version check with correct version
 */
@Test
public void testCheckVersionWithCorrectVersion() {
    String version = "5.1";
    ClusterConfiguration config = buildConfig(version);
    new ValidateVersionStep().execute(config);
}
Also used : ClusterConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration) Test(org.junit.Test)

Aggregations

ClusterConfiguration (com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration)13 Test (org.junit.Test)12 ElasticsearchSetupException (com.github.alexcojocaru.mojo.elasticsearch.v2.ElasticsearchSetupException)2 InstanceConfiguration (com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration)2 ElasticsearchClient (com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchClient)2 Monitor (com.github.alexcojocaru.mojo.elasticsearch.v2.client.Monitor)1 PostStartClusterSequence (com.github.alexcojocaru.mojo.elasticsearch.v2.step.PostStartClusterSequence)1 PostStartInstanceSequence (com.github.alexcojocaru.mojo.elasticsearch.v2.step.PostStartInstanceSequence)1 PreStartClusterSequence (com.github.alexcojocaru.mojo.elasticsearch.v2.step.PreStartClusterSequence)1 File (java.io.File)1 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1