Bumping versions
This commit is contained in:
@@ -30,6 +30,7 @@ import org.springframework.context.annotation.Conditional;
|
||||
|
||||
/**
|
||||
* When both property and consul classes are on the classpath.
|
||||
*
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -130,9 +130,11 @@ public class ConsulAutoConfiguration {
|
||||
@Bean(name = "consulRetryInterceptor")
|
||||
@ConditionalOnMissingBean(name = "consulRetryInterceptor")
|
||||
public RetryOperationsInterceptor consulRetryInterceptor(RetryProperties properties) {
|
||||
return RetryInterceptorBuilder.stateless().backOffOptions(properties.getInitialInterval(),
|
||||
properties.getMultiplier(), properties.getMaxInterval()).maxAttempts(properties.getMaxAttempts())
|
||||
.build();
|
||||
return RetryInterceptorBuilder.stateless()
|
||||
.backOffOptions(properties.getInitialInterval(), properties.getMultiplier(),
|
||||
properties.getMaxInterval())
|
||||
.maxAttempts(properties.getMaxAttempts())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ConsulEndpoint {
|
||||
data.setAgentServices(agentServices.getValue());
|
||||
|
||||
Response<Map<String, List<String>>> catalogServices = this.consul
|
||||
.getCatalogServices(CatalogServicesRequest.newBuilder().setQueryParams(QueryParams.DEFAULT).build());
|
||||
.getCatalogServices(CatalogServicesRequest.newBuilder().setQueryParams(QueryParams.DEFAULT).build());
|
||||
|
||||
for (String serviceId : catalogServices.getValue().keySet()) {
|
||||
Response<List<CatalogService>> response = this.consul.getCatalogService(serviceId,
|
||||
@@ -63,7 +63,7 @@ public class ConsulEndpoint {
|
||||
}
|
||||
|
||||
Response<List<Node>> catalogNodes = this.consul
|
||||
.getCatalogNodes(CatalogNodesRequest.newBuilder().setQueryParams(QueryParams.DEFAULT).build());
|
||||
.getCatalogNodes(CatalogNodesRequest.newBuilder().setQueryParams(QueryParams.DEFAULT).build());
|
||||
data.setCatalogNodes(catalogNodes.getValue());
|
||||
|
||||
return data;
|
||||
@@ -110,7 +110,9 @@ public class ConsulEndpoint {
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this).append("catalogServices", this.catalogServices)
|
||||
.append("agentServices", this.agentServices).append("catalogNodes", this.catalogNodes).toString();
|
||||
.append("agentServices", this.agentServices)
|
||||
.append("catalogNodes", this.catalogNodes)
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ public class ConsulHealthIndicator extends AbstractHealthIndicator {
|
||||
final Response<String> leaderStatus = this.consul.getStatusLeader();
|
||||
builder.up().withDetail("leader", leaderStatus.getValue());
|
||||
if (properties.isIncludeServicesQuery()) {
|
||||
final Response<Map<String, List<String>>> services = this.consul.getCatalogServices(
|
||||
CatalogServicesRequest.newBuilder().setQueryParams(QueryParams.DEFAULT).build());
|
||||
final Response<Map<String, List<String>>> services = this.consul
|
||||
.getCatalogServices(CatalogServicesRequest.newBuilder().setQueryParams(QueryParams.DEFAULT).build());
|
||||
builder.withDetail("services", services.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,9 +189,11 @@ public class ConsulProperties {
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this).append("keyStoreInstanceType", this.keyStoreInstanceType)
|
||||
.append("keyStorePath", this.keyStorePath).append("keyStorePassword", this.keyStorePassword)
|
||||
.append("certificatePath", this.certificatePath)
|
||||
.append("certificatePassword", this.certificatePassword).toString();
|
||||
.append("keyStorePath", this.keyStorePath)
|
||||
.append("keyStorePassword", this.keyStorePassword)
|
||||
.append("certificatePath", this.certificatePath)
|
||||
.append("certificatePassword", this.certificatePassword)
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -90,9 +90,12 @@ public class RetryProperties {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this).append("enabled", this.enabled).append("initialInterval", this.initialInterval)
|
||||
.append("multiplier", this.multiplier).append("maxInterval", this.maxInterval)
|
||||
.append("maxAttempts", this.maxAttempts).toString();
|
||||
return new ToStringCreator(this).append("enabled", this.enabled)
|
||||
.append("initialInterval", this.initialInterval)
|
||||
.append("multiplier", this.multiplier)
|
||||
.append("maxInterval", this.maxInterval)
|
||||
.append("maxAttempts", this.maxAttempts)
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.consul.model;
|
||||
|
||||
/**
|
||||
* Gossip pool (serf) statuses. Created by nicu on 10.03.2015.
|
||||
*
|
||||
* @author Nicu Marasoiu
|
||||
*/
|
||||
public enum SerfStatusEnum {
|
||||
|
||||
@@ -42,22 +42,26 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class ConsulAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner appContextRunner = new ApplicationContextRunner()
|
||||
.withInitializer(new ConsulTestcontainers())
|
||||
.withConfiguration(AutoConfigurations.of(ConsulAutoConfiguration.class));
|
||||
.withInitializer(new ConsulTestcontainers())
|
||||
.withConfiguration(AutoConfigurations.of(ConsulAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void defaultConfiguration() {
|
||||
appContextRunner.run(context -> assertThat(context).hasNotFailed().hasSingleBean(ConsulProperties.class)
|
||||
.hasSingleBean(ConsulClient.class).hasSingleBean(ConsulHealthIndicator.class)
|
||||
.doesNotHaveBean(ConsulEndpoint.class));
|
||||
appContextRunner.run(context -> assertThat(context).hasNotFailed()
|
||||
.hasSingleBean(ConsulProperties.class)
|
||||
.hasSingleBean(ConsulClient.class)
|
||||
.hasSingleBean(ConsulHealthIndicator.class)
|
||||
.doesNotHaveBean(ConsulEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consulDisabled() {
|
||||
appContextRunner.withPropertyValues("spring.cloud.consul.enabled=false")
|
||||
.run(context -> assertThat(context).hasNotFailed().doesNotHaveBean(ConsulProperties.class)
|
||||
.doesNotHaveBean(ConsulClient.class).doesNotHaveBean(ConsulHealthIndicator.class)
|
||||
.doesNotHaveBean(ConsulEndpoint.class));
|
||||
.run(context -> assertThat(context).hasNotFailed()
|
||||
.doesNotHaveBean(ConsulProperties.class)
|
||||
.doesNotHaveBean(ConsulClient.class)
|
||||
.doesNotHaveBean(ConsulHealthIndicator.class)
|
||||
.doesNotHaveBean(ConsulEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,57 +82,61 @@ public class ConsulAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void tlsConfigured() {
|
||||
appContextRunner.withPropertyValues("spring.cloud.consul.tls.key-store-instance-type=JKS",
|
||||
"spring.cloud.consul.tls.key-store-path=src/test/resources/server.jks",
|
||||
"spring.cloud.consul.tls.key-store-password=letmein",
|
||||
"spring.cloud.consul.tls.certificate-path=src/test/resources/trustStore.jks",
|
||||
"spring.cloud.consul.tls.certificate-password=change_me").run(context -> {
|
||||
assertThat(context).hasNotFailed().hasSingleBean(ConsulClient.class);
|
||||
appContextRunner
|
||||
.withPropertyValues("spring.cloud.consul.tls.key-store-instance-type=JKS",
|
||||
"spring.cloud.consul.tls.key-store-path=src/test/resources/server.jks",
|
||||
"spring.cloud.consul.tls.key-store-password=letmein",
|
||||
"spring.cloud.consul.tls.certificate-path=src/test/resources/trustStore.jks",
|
||||
"spring.cloud.consul.tls.certificate-password=change_me")
|
||||
.run(context -> {
|
||||
assertThat(context).hasNotFailed().hasSingleBean(ConsulClient.class);
|
||||
|
||||
ConsulClient consulClient = context.getBean(ConsulClient.class);
|
||||
CatalogConsulClient client = (CatalogConsulClient) ReflectionTestUtils.getField(consulClient,
|
||||
"catalogClient");
|
||||
ConsulRawClient rawClient = (ConsulRawClient) ReflectionTestUtils.getField(client, "rawClient");
|
||||
HttpTransport httpTransport = (HttpTransport) ReflectionTestUtils.getField(rawClient,
|
||||
"httpTransport");
|
||||
assertThat(httpTransport).isInstanceOf(DefaultHttpsTransport.class);
|
||||
});
|
||||
ConsulClient consulClient = context.getBean(ConsulClient.class);
|
||||
CatalogConsulClient client = (CatalogConsulClient) ReflectionTestUtils.getField(consulClient,
|
||||
"catalogClient");
|
||||
ConsulRawClient rawClient = (ConsulRawClient) ReflectionTestUtils.getField(client, "rawClient");
|
||||
HttpTransport httpTransport = (HttpTransport) ReflectionTestUtils.getField(rawClient, "httpTransport");
|
||||
assertThat(httpTransport).isInstanceOf(DefaultHttpsTransport.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonActuatorAppGetsNoEndpointOrHealthIndicator() {
|
||||
appContextRunner.withClassLoader(new FilteredClassLoader(Endpoint.class))
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=consul")
|
||||
.run(context -> assertThat(context).hasNotFailed().doesNotHaveBean(ConsulHealthIndicator.class)
|
||||
.doesNotHaveBean(ConsulEndpoint.class));
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=consul")
|
||||
.run(context -> assertThat(context).hasNotFailed()
|
||||
.doesNotHaveBean(ConsulHealthIndicator.class)
|
||||
.doesNotHaveBean(ConsulEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consulEndpointAvailable() {
|
||||
appContextRunner.withPropertyValues("management.endpoints.web.exposure.include=consul")
|
||||
.run(context -> assertThat(context).hasNotFailed().hasSingleBean(ConsulEndpoint.class));
|
||||
.run(context -> assertThat(context).hasNotFailed().hasSingleBean(ConsulEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consulEndpointAvailableButDisabled() {
|
||||
appContextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=consul",
|
||||
"management.endpoint.consul.enabled=false")
|
||||
.run(context -> assertThat(context).hasNotFailed().doesNotHaveBean(ConsulEndpoint.class));
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=consul",
|
||||
"management.endpoint.consul.enabled=false")
|
||||
.run(context -> assertThat(context).hasNotFailed().doesNotHaveBean(ConsulEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consulEndpointDisabled() {
|
||||
appContextRunner.withPropertyValues("spring.cloud.consul.enabled=false")
|
||||
.run(context -> assertThat(context).hasNotFailed().doesNotHaveBean(ConsulProperties.class)
|
||||
.doesNotHaveBean(ConsulClient.class).doesNotHaveBean(ConsulHealthIndicator.class)
|
||||
.doesNotHaveBean(ConsulEndpoint.class));
|
||||
.run(context -> assertThat(context).hasNotFailed()
|
||||
.doesNotHaveBean(ConsulProperties.class)
|
||||
.doesNotHaveBean(ConsulClient.class)
|
||||
.doesNotHaveBean(ConsulHealthIndicator.class)
|
||||
.doesNotHaveBean(ConsulEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consulHealthIndicatorDisabled() {
|
||||
appContextRunner.withPropertyValues("management.health.consul.enabled=false")
|
||||
.run(context -> assertThat(context).hasNotFailed().doesNotHaveBean(ConsulHealthIndicator.class));
|
||||
.run(context -> assertThat(context).hasNotFailed().doesNotHaveBean(ConsulHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ConsulHealthIndicatorDownTest {
|
||||
Response<String> leaderStatus = new Response<>("OK", 5150L, true, System.currentTimeMillis());
|
||||
when(consulClient.getStatusLeader()).thenReturn(leaderStatus);
|
||||
when(consulClient.getCatalogServices(any(CatalogServicesRequest.class)))
|
||||
.thenThrow(new RuntimeException("no services"));
|
||||
.thenThrow(new RuntimeException("no services"));
|
||||
assertThat(this.healthEndpoint.health().getStatus()).as("health status was not DOWN").isEqualTo(Status.DOWN);
|
||||
verify(consulClient).getCatalogServices(any(CatalogServicesRequest.class));
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ConsulTestcontainers implements ApplicationContextInitializer<Confi
|
||||
public static ConsulContainer createConsulContainer(String consulVersion) {
|
||||
String dockerImageName = "consul:" + consulVersion;
|
||||
return new ConsulContainer(dockerImageName)
|
||||
.withLogConsumer(new Slf4jLogConsumer(logger).withSeparateOutputStreams());
|
||||
.withLogConsumer(new Slf4jLogConsumer(logger).withSeparateOutputStreams());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user