Skip to content

Commit

Permalink
Speedup WebFlux tests by reducing the interval period
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sdeleuze committed Oct 18, 2024
1 parent 912c067 commit 4c44b91
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response)
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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void sseAsEvent(HttpServer httpServer) throws Exception {

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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static class JacksonStreamingController {
@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));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Flux<Msg> messages() {

@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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public String uri(ServerHttpRequest request) {

@GetMapping("/stream")
public Publisher<Long> stream() {
return testInterval(Duration.ofMillis(50), 5);
return testInterval(Duration.ofMillis(1), 5);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void serverDetectsClientDisconnect(HttpServer httpServer, ClientHttpConnector co
@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();

Expand Down

0 comments on commit 4c44b91

Please sign in to comment.