Skip to content

Commit

Permalink
Upgrade elasticsearch to 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
htynkn authored and snicoll committed Apr 5, 2016
1 parent c98b809 commit 6a2ff3f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ public void notJmsHealthIndicator() {
@Test
public void elasticSearchHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs",
"management.health.diskspace.enabled:false");
this.context.register(ElasticsearchAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
Expand All @@ -411,8 +409,6 @@ public void elasticSearchHealthIndicator() {
public void notElasticSearchHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.elasticsearch.enabled:false",
"spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs",
"management.health.diskspace.enabled:false");
this.context.register(ElasticsearchAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.client.AdminClient;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.ClusterAdminClient;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlocks;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.RoutingTable;
import org.junit.Before;
Expand Down Expand Up @@ -176,9 +176,9 @@ private StubClusterHealthResponse() {

private StubClusterHealthResponse(ClusterHealthStatus status) {
super("test-cluster", new String[0],
new ClusterState(null, 0, null, RoutingTable.builder().build(),
new ClusterState(null, 0, null, null, RoutingTable.builder().build(),
DiscoveryNodes.builder().build(),
ClusterBlocks.builder().build(), null));
ClusterBlocks.builder().build(), null, false));
this.status = status;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.boot.autoconfigure.data.elasticsearch;

import java.io.File;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -26,7 +27,7 @@
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.lease.Releasable;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;

Expand Down Expand Up @@ -62,6 +63,7 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
Map<String, String> defaults = new LinkedHashMap<String, String>();
defaults.put("http.enabled", String.valueOf(false));
defaults.put("node.local", String.valueOf(true));
defaults.put("path.home", new File(System.getProperty("java.io.tmpdir"), "elastic-home").getAbsolutePath());
DEFAULTS = Collections.unmodifiableMap(defaults);
}

Expand Down Expand Up @@ -95,7 +97,7 @@ private Client createClient() throws Exception {
}

private Client createNodeClient() throws Exception {
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();
Settings.Builder settings = Settings.settingsBuilder();
for (Map.Entry<String, String> entry : DEFAULTS.entrySet()) {
if (!this.properties.getProperties().containsKey(entry.getKey())) {
settings.put(entry.getKey(), entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ public void close() {
public void createNodeClientWithDefaults() {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.elasticsearch.properties.foo.bar:baz",
"spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs");
"spring.data.elasticsearch.properties.foo.bar:baz");
this.context.register(PropertyPlaceholderAutoConfiguration.class,
ElasticsearchAutoConfiguration.class);
this.context.refresh();
Expand All @@ -74,8 +72,6 @@ public void createNodeClientWithOverrides() {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.elasticsearch.properties.foo.bar:baz",
"spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs",
"spring.data.elasticsearch.properties.node.local:false",
"spring.data.elasticsearch.properties.node.data:true",
"spring.data.elasticsearch.properties.http.enabled:true");
Expand Down Expand Up @@ -108,9 +104,7 @@ public void createTransportClient() throws Exception {
// a port and check the exception
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.elasticsearch.cluster-nodes:localhost",
"spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs");
"spring.data.elasticsearch.cluster-nodes:localhost");
this.context.register(PropertyPlaceholderAutoConfiguration.class,
ElasticsearchAutoConfiguration.class);
this.thrown.expect(BeanCreationException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.springframework.boot.autoconfigure.data.elasticsearch.city.City;
import org.springframework.boot.autoconfigure.data.elasticsearch.city.CityRepository;
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
Expand All @@ -50,7 +49,6 @@ public void close() {
@Test
public void testDefaultRepositoryConfiguration() throws Exception {
this.context = new AnnotationConfigApplicationContext();
addElasticsearchProperties(this.context);
this.context.register(TestConfiguration.class,
ElasticsearchAutoConfiguration.class,
ElasticsearchRepositoriesAutoConfiguration.class,
Expand All @@ -64,7 +62,6 @@ public void testDefaultRepositoryConfiguration() throws Exception {
@Test
public void testNoRepositoryConfiguration() throws Exception {
this.context = new AnnotationConfigApplicationContext();
addElasticsearchProperties(this.context);
this.context.register(EmptyConfiguration.class,
ElasticsearchAutoConfiguration.class,
ElasticsearchRepositoriesAutoConfiguration.class,
Expand All @@ -77,7 +74,6 @@ public void testNoRepositoryConfiguration() throws Exception {
@Test
public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
this.context = new AnnotationConfigApplicationContext();
addElasticsearchProperties(this.context);
this.context.register(CustomizedConfiguration.class,
ElasticsearchAutoConfiguration.class,
ElasticsearchRepositoriesAutoConfiguration.class,
Expand All @@ -87,12 +83,6 @@ public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
assertThat(this.context.getBean(CityElasticsearchDbRepository.class)).isNotNull();
}

private void addElasticsearchProperties(AnnotationConfigApplicationContext context) {
EnvironmentTestUtils.addEnvironment(context,
"spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs");
}

@Configuration
@TestAutoConfigurationPackage(City.class)
protected static class TestConfiguration {
Expand Down
2 changes: 1 addition & 1 deletion spring-boot-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<embedded-mongo.version>1.50.2</embedded-mongo.version>
<flyway.version>3.2.1</flyway.version>
<freemarker.version>2.3.23</freemarker.version>
<elasticsearch.version>1.7.5</elasticsearch.version>
<elasticsearch.version>2.2.0</elasticsearch.version>
<gemfire.version>8.2.0</gemfire.version>
<glassfish-el.version>3.0.0</glassfish-el.version>
<gradle.version>1.12</gradle.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,13 @@
* @author Artur Konczak
*/
public class SampleElasticsearchApplicationTests {

private static final String[] PROPERTIES = {
"spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs" };

@Rule
public OutputCapture outputCapture = new OutputCapture();

@Test
public void testDefaultSettings() throws Exception {
try {
new SpringApplicationBuilder(SampleElasticsearchApplication.class)
.properties(PROPERTIES).run();
new SpringApplicationBuilder(SampleElasticsearchApplication.class).run();
}
catch (IllegalStateException ex) {
if (serverNotRunning(ex)) {
Expand Down

0 comments on commit 6a2ff3f

Please sign in to comment.