Skip to content

Commit 2ec79ed

Browse files
committed
Working
1 parent a56fce4 commit 2ec79ed

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/test/java/io/fusionauth/http/CoreTest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ public void serverTimeout() throws Exception {
740740
HTTPHandler handler = (req, res) -> {
741741
println("Handling ... (slowly)");
742742
// Note that if you comment out the sleep, the test should fail.
743-
sleep(4_000L);
743+
sleep(3_000L);
744744
res.setStatus(200);
745745
var body = "I'm slow but I'm good.".getBytes(StandardCharsets.UTF_8);
746746
res.setContentLength(body.length);
@@ -749,12 +749,17 @@ public void serverTimeout() throws Exception {
749749
println("Closed");
750750
};
751751

752-
// TODO : Daniel : Review : what are we trying to test here, this test isn't doing what we think.
753-
// It seems we are writing to the server as a client, and the server is slow to write back.
754-
// But this would be a client timeout and not a server timeout?
755-
// Seems like we should use withProcessingTimeoutDuration instead of withInitialReadTimeout?
756752
var instrumenter = new CountingInstrumenter();
757-
try (var ignore = makeServer("http", handler, instrumenter).withProcessingTimeoutDuration(Duration.ofSeconds(1)).start(); Socket socket = new Socket("127.0.0.1", 4242)) {
753+
try (var ignore = makeServer("http", handler, instrumenter)
754+
// The processing timeout should be triggered due to how slow the server is to write back to the client.
755+
// - Increase other timeouts to be certain we are testing the correct one.
756+
.withProcessingTimeoutDuration(Duration.ofSeconds(1))
757+
.withInitialReadTimeout(Duration.ofSeconds(30))
758+
.withKeepAliveTimeoutDuration(Duration.ofSeconds(30))
759+
.start();
760+
761+
// Open a socket to the server and begin writing.
762+
Socket socket = new Socket("127.0.0.1", 4242)) {
758763
var out = socket.getOutputStream();
759764
// 1. Write a body to the server
760765
out.write("""

0 commit comments

Comments
 (0)