Merge branch '2.1.x'

This commit is contained in:
Andy Wilkinson
2018-12-20 15:30:51 +00:00
22 changed files with 166 additions and 109 deletions

View File

@@ -16,6 +16,7 @@
package org.springframework.boot.actuate.couchbase;
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -52,7 +53,7 @@ public class CouchbaseReactiveHealthIndicatorTests {
DiagnosticsReport diagnostics = new DiagnosticsReport(endpoints, "test-sdk",
"test-id", null);
given(cluster.diagnostics()).willReturn(diagnostics);
Health health = healthIndicator.health().block();
Health health = healthIndicator.health().block(Duration.ofSeconds(30));
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
assertThat(health.getDetails()).containsKey("endpoints");
@@ -77,7 +78,7 @@ public class CouchbaseReactiveHealthIndicatorTests {
DiagnosticsReport diagnostics = new DiagnosticsReport(endpoints, "test-sdk",
"test-id", null);
given(cluster.diagnostics()).willReturn(diagnostics);
Health health = healthIndicator.health().block();
Health health = healthIndicator.health().block(Duration.ofSeconds(30));
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
assertThat(health.getDetails()).containsKey("endpoints");

View File

@@ -16,6 +16,7 @@
package org.springframework.boot.actuate.endpoint.web.reactive;
import java.time.Duration;
import java.util.Arrays;
import org.junit.Test;
@@ -95,7 +96,8 @@ public class ControllerEndpointHandlerMappingTests {
private Object getHandler(ControllerEndpointHandlerMapping mapping, HttpMethod method,
String requestURI) {
return mapping.getHandler(exchange(method, requestURI)).block();
return mapping.getHandler(exchange(method, requestURI))
.block(Duration.ofSeconds(30));
}
private ControllerEndpointHandlerMapping createMapping(String prefix,

View File

@@ -73,7 +73,7 @@ public class MetricsWebClientFilterFunctionTests {
ClientRequest request = ClientRequest.create(HttpMethod.GET,
URI.create("http://example.com/projects/spring-boot")).build();
given(this.response.statusCode()).willReturn(HttpStatus.OK);
this.filterFunction.filter(request, this.exchange).block();
this.filterFunction.filter(request, this.exchange).block(Duration.ofSeconds(30));
assertThat(this.registry.get("http.client.requests")
.tags("method", "GET", "uri", "/projects/spring-boot", "status", "200")
.timer().count()).isEqualTo(1);
@@ -86,7 +86,7 @@ public class MetricsWebClientFilterFunctionTests {
URI.create("http://example.com/projects/spring-boot"))
.attribute(URI_TEMPLATE_ATTRIBUTE, "/projects/{project}").build();
given(this.response.statusCode()).willReturn(HttpStatus.OK);
this.filterFunction.filter(request, this.exchange).block();
this.filterFunction.filter(request, this.exchange).block(Duration.ofSeconds(30));
assertThat(this.registry.get("http.client.requests")
.tags("method", "GET", "uri", "/projects/{project}", "status", "200")
.timer().count()).isEqualTo(1);
@@ -98,7 +98,8 @@ public class MetricsWebClientFilterFunctionTests {
URI.create("http://example.com/projects/spring-boot")).build();
ExchangeFunction errorExchange = (r) -> Mono.error(new IOException());
this.filterFunction.filter(request, errorExchange)
.onErrorResume(IOException.class, (t) -> Mono.empty()).block();
.onErrorResume(IOException.class, (t) -> Mono.empty())
.block(Duration.ofSeconds(30));
assertThat(
this.registry
.get("http.client.requests").tags("method", "GET", "uri",
@@ -113,7 +114,7 @@ public class MetricsWebClientFilterFunctionTests {
ExchangeFunction exchange = (r) -> Mono.error(new IllegalArgumentException());
this.filterFunction.filter(request, exchange)
.onErrorResume(IllegalArgumentException.class, (t) -> Mono.empty())
.block();
.block(Duration.ofSeconds(30));
assertThat(this.registry
.get("http.client.requests").tags("method", "GET", "uri",
"/projects/spring-boot", "status", "CLIENT_ERROR")
@@ -128,7 +129,7 @@ public class MetricsWebClientFilterFunctionTests {
.delaySubscription(Duration.ofMillis(300)).cast(ClientResponse.class);
this.filterFunction.filter(request, exchange).retry(1)
.onErrorResume(IllegalArgumentException.class, (t) -> Mono.empty())
.block();
.block(Duration.ofSeconds(30));
Timer timer = this.registry.get("http.client.requests").tags("method", "GET",
"uri", "/projects/spring-boot", "status", "CLIENT_ERROR").timer();
assertThat(timer.count()).isEqualTo(2);

View File

@@ -16,6 +16,8 @@
package org.springframework.boot.actuate.metrics.web.reactive.server;
import java.time.Duration;
import io.micrometer.core.instrument.MockClock;
import io.micrometer.core.instrument.simple.SimpleConfig;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
@@ -58,7 +60,7 @@ public class MetricsWebFilterTests {
this.webFilter
.filter(exchange,
(serverWebExchange) -> exchange.getResponse().setComplete())
.block();
.block(Duration.ofSeconds(30));
assertMetricsContainsTag("uri", "/projects/{project}");
assertMetricsContainsTag("status", "200");
}
@@ -74,7 +76,7 @@ public class MetricsWebFilterTests {
.onErrorResume((t) -> {
exchange.getResponse().setStatusCodeValue(500);
return exchange.getResponse().setComplete();
}).block();
}).block(Duration.ofSeconds(30));
assertMetricsContainsTag("uri", "/projects/{project}");
assertMetricsContainsTag("status", "500");
assertMetricsContainsTag("exception", "IllegalStateException");
@@ -91,7 +93,7 @@ public class MetricsWebFilterTests {
.onErrorResume((t) -> {
exchange.getResponse().setStatusCodeValue(500);
return exchange.getResponse().setComplete();
}).block();
}).block(Duration.ofSeconds(30));
assertMetricsContainsTag("uri", "/projects/{project}");
assertMetricsContainsTag("status", "500");
assertMetricsContainsTag("exception", anonymous.getClass().getName());
@@ -105,7 +107,7 @@ public class MetricsWebFilterTests {
exchange.getResponse().setStatusCodeValue(500);
return exchange.getResponse().setComplete()
.then(Mono.error(new IllegalStateException("test error")));
}).onErrorResume((t) -> Mono.empty()).block();
}).onErrorResume((t) -> Mono.empty()).block(Duration.ofSeconds(30));
assertMetricsContainsTag("uri", "/projects/{project}");
assertMetricsContainsTag("status", "500");
}

View File

@@ -18,6 +18,7 @@ package org.springframework.boot.actuate.trace.http.reactive;
import java.io.IOException;
import java.security.Principal;
import java.time.Duration;
import java.util.EnumSet;
import javax.servlet.ServletException;
@@ -68,7 +69,7 @@ public class HttpTraceWebFilterTests {
return Mono.empty();
}
}).block();
}).block(Duration.ofSeconds(30));
assertThat(this.repository.findAll()).hasSize(1);
}
@@ -82,11 +83,12 @@ public class HttpTraceWebFilterTests {
@Override
public Mono<Void> filter(ServerWebExchange exchange) {
exchange.getSession().block().getAttributes().put("a", "alpha");
exchange.getSession().block(Duration.ofSeconds(30))
.getAttributes().put("a", "alpha");
return Mono.empty();
}
}).block();
}).block(Duration.ofSeconds(30));
assertThat(this.repository.findAll()).hasSize(1);
Session session = this.repository.findAll().get(0).getSession();
assertThat(session).isNotNull();
@@ -103,11 +105,11 @@ public class HttpTraceWebFilterTests {
@Override
public Mono<Void> filter(ServerWebExchange exchange) {
exchange.getSession().block();
exchange.getSession().block(Duration.ofSeconds(30));
return Mono.empty();
}
}).block();
}).block(Duration.ofSeconds(30));
assertThat(this.repository.findAll()).hasSize(1);
Session session = this.repository.findAll().get(0).getSession();
assertThat(session).isNull();
@@ -129,11 +131,12 @@ public class HttpTraceWebFilterTests {
@Override
public Mono<Void> filter(ServerWebExchange exchange) {
exchange.getSession().block().getAttributes().put("a", "alpha");
exchange.getSession().block(Duration.ofSeconds(30)).getAttributes()
.put("a", "alpha");
return Mono.empty();
}
}).block();
}).block(Duration.ofSeconds(30));
assertThat(this.repository.findAll()).hasSize(1);
org.springframework.boot.actuate.trace.http.HttpTrace.Principal tracedPrincipal = this.repository
.findAll().get(0).getPrincipal();
@@ -155,7 +158,7 @@ public class HttpTraceWebFilterTests {
return Mono.error(new RuntimeException());
}
}).block();
}).block(Duration.ofSeconds(30));
fail();
}
catch (Exception ex) {