Browse Source

Speedup WebFlux tests by reducing the interval period

In WebFlux, we have various tests using a period of 50 or 100ms.
We should use a smaller value like 1ms to speedup tests.

Closes gh-33738
pull/33766/head
Sébastien Deleuze 1 year ago
parent
commit
4c44b91cf9
  1. 2
      spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java
  2. 2
      spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java
  3. 2
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonStreamingIntegrationTests.java
  4. 2
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java
  5. 2
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java
  6. 2
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java

2
spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java

@ -127,7 +127,7 @@ class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -127,7 +127,7 @@ class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTests {
String path = request.getURI().getPath();
return switch (path) {
case "/write-and-flush" -> response.writeAndFlushWith(
testInterval(Duration.ofMillis(50), 2)
testInterval(Duration.ofMillis(1), 2)
.map(longValue -> wrap("data" + longValue + "\n", response))
.map(Flux::just)
.mergeWith(Flux.never()));

2
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java

@ -125,7 +125,7 @@ class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIntegrati @@ -125,7 +125,7 @@ class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIntegrati
private static class SseHandler {
private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(100), 2);
private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(1), 2);
Mono<ServerResponse> string(ServerRequest request) {
return ServerResponse.ok()

2
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonStreamingIntegrationTests.java

@ -109,7 +109,7 @@ class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegrationTes @@ -109,7 +109,7 @@ class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegrationTes
@GetMapping(value = "/stream",
produces = { APPLICATION_NDJSON_VALUE, "application/stream+x-jackson-smile" })
Flux<Person> person() {
return testInterval(Duration.ofMillis(100), 50).map(l -> new Person("foo " + l));
return testInterval(Duration.ofMillis(1), 50).map(l -> new Person("foo " + l));
}
}

2
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java

@ -168,7 +168,7 @@ class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationTests { @@ -168,7 +168,7 @@ class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationTests {
@GetMapping(value = "/message-stream", produces = "application/x-protobuf;delimited=true")
Flux<Msg> messageStream() {
return testInterval(Duration.ofMillis(50), 5).map(l ->
return testInterval(Duration.ofMillis(1), 5).map(l ->
Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(l.intValue()).build()).build());
}

2
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java

@ -177,7 +177,7 @@ class RequestMappingIntegrationTests extends AbstractRequestMappingIntegrationTe @@ -177,7 +177,7 @@ class RequestMappingIntegrationTests extends AbstractRequestMappingIntegrationTe
@GetMapping("/stream")
public Publisher<Long> stream() {
return testInterval(Duration.ofMillis(50), 5);
return testInterval(Duration.ofMillis(1), 5);
}
}

2
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java

@ -202,7 +202,7 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -202,7 +202,7 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
@RequestMapping("/sse")
static class SseController {
private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(100), 50);
private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(1), 50);
private final Sinks.Empty<Void> cancelSink = Sinks.empty();

Loading…
Cancel
Save