Upgrade elasticsearch to 2.2.0

Closes gh-5443
pull/5561/merge
Huang YunKun 9 years ago committed by Stephane Nicoll
parent c98b8098b4
commit 6a2ff3f02a

@ -393,8 +393,6 @@ public class HealthIndicatorAutoConfigurationTests {
@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);
@ -411,8 +409,6 @@ public class HealthIndicatorAutoConfigurationTests {
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);

@ -23,13 +23,13 @@ import org.elasticsearch.ElasticsearchException;
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;
@ -176,9 +176,9 @@ public class ElasticsearchHealthIndicatorTests {
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;
}

@ -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;
@ -26,7 +27,7 @@ import org.apache.commons.logging.LogFactory;
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;
@ -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);
}
@ -95,7 +97,7 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
}
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());

@ -56,9 +56,7 @@ public class ElasticsearchAutoConfigurationTests {
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();
@ -74,8 +72,6 @@ public class ElasticsearchAutoConfigurationTests {
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");
@ -108,9 +104,7 @@ public class ElasticsearchAutoConfigurationTests {
// 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);

@ -26,7 +26,6 @@ import org.springframework.boot.autoconfigure.data.alt.elasticsearch.CityElastic
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;
@ -50,7 +49,6 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
@Test
public void testDefaultRepositoryConfiguration() throws Exception {
this.context = new AnnotationConfigApplicationContext();
addElasticsearchProperties(this.context);
this.context.register(TestConfiguration.class,
ElasticsearchAutoConfiguration.class,
ElasticsearchRepositoriesAutoConfiguration.class,
@ -64,7 +62,6 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
@Test
public void testNoRepositoryConfiguration() throws Exception {
this.context = new AnnotationConfigApplicationContext();
addElasticsearchProperties(this.context);
this.context.register(EmptyConfiguration.class,
ElasticsearchAutoConfiguration.class,
ElasticsearchRepositoriesAutoConfiguration.class,
@ -77,7 +74,6 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
@Test
public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
this.context = new AnnotationConfigApplicationContext();
addElasticsearchProperties(this.context);
this.context.register(CustomizedConfiguration.class,
ElasticsearchAutoConfiguration.class,
ElasticsearchRepositoriesAutoConfiguration.class,
@ -87,12 +83,6 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
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 {

@ -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>

@ -33,19 +33,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @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)) {

Loading…
Cancel
Save