Skip to content

Commit

Permalink
Lower default timeout to 100ms
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrudel committed Jan 3, 2025
1 parent 41b8fed commit 9c50ed8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions test/bandit/http2/plug_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ defmodule HTTP2PlugTest do
SimpleH2Client.send_body(socket, 1, false, "A")
{:ok, 0, _} = SimpleH2Client.recv_window_update(socket)
{:ok, 1, _} = SimpleH2Client.recv_window_update(socket)
Process.sleep(100)
Process.sleep(10)
SimpleH2Client.send_body(socket, 1, true, "BC")

assert SimpleH2Client.successful_response?(socket, 1, false)
Expand Down Expand Up @@ -574,7 +574,7 @@ defmodule HTTP2PlugTest do

# Sleep a bit before updating the window (we expect to see this delay in
# the timings for the blocked chunk below)
Process.sleep(100)
Process.sleep(10)

# Grow the connection window by 100 and observe we now unlocked the server
SimpleH2Client.send_window_update(socket, 0, 100_000)
Expand All @@ -588,9 +588,9 @@ defmodule HTTP2PlugTest do

# Ensure the non-blocked chunks (60k worth) were *much* faster than the
# blocked chunk (which only did 10k)
assert non_blocked < 20
assert blocked > 100
assert blocked < 300
assert non_blocked < 5
assert blocked > 10
assert blocked < 30
end

test "sending a body blocks on stream flow control", context do
Expand All @@ -617,7 +617,7 @@ defmodule HTTP2PlugTest do

# Sleep a bit before updating the window (we expect to see this delay in
# the timings for the blocked chunk below)
Process.sleep(100)
Process.sleep(10)

# Grow the stream window by 100 and observe we now unlocked the server
SimpleH2Client.send_window_update(socket, 1, 100_000)
Expand All @@ -631,9 +631,9 @@ defmodule HTTP2PlugTest do

# Ensure the the non-blocked chunks (60k worth) were *much* faster than the
# blocked chunk (which only did 10k)
assert non_blocked < 10
assert blocked > 100
assert blocked < 200
assert non_blocked < 5
assert blocked > 10
assert blocked < 20
end

def blocking_test(conn) do
Expand Down
8 changes: 4 additions & 4 deletions test/bandit/websocket/protocol_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,12 @@ defmodule WebSocketProtocolTest do
assert SimpleWebSocketClient.recv_connection_close_frame(client) == {:ok, <<1000::16>>}

# Wait a bit and validate that the server is still very much alive
Process.sleep(100)
Process.sleep(10)
assert Process.alive?(pid)

# Now send our half of the handshake and verify that the server has shut down
SimpleWebSocketClient.send_connection_close_frame(client, 1000)
Process.sleep(100)
Process.sleep(10)
refute Process.alive?(pid)

# Verify that the server didn't send any extraneous frames
Expand Down Expand Up @@ -597,11 +597,11 @@ defmodule WebSocketProtocolTest do
assert SimpleWebSocketClient.recv_connection_close_frame(client) == {:ok, <<1000::16>>}

# Wait a bit and validate that the server is still very much alive
Process.sleep(100)
Process.sleep(10)
assert Process.alive?(pid)

# Now wait for the server to timeout
Process.sleep(1500)
Process.sleep(110)

# Verify that the server has shut down
refute Process.alive?(pid)
Expand Down
4 changes: 2 additions & 2 deletions test/support/server_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule ServerHelpers do
scheme: :http,
port: 0,
ip: :loopback,
thousand_island_options: [read_timeout: 1000]
thousand_island_options: [read_timeout: 100]
]
|> start_server(opts)
end
Expand All @@ -27,7 +27,7 @@ defmodule ServerHelpers do
ip: :loopback,
certfile: Path.join(__DIR__, "../support/cert.pem") |> Path.expand(),
keyfile: Path.join(__DIR__, "../support/key.pem") |> Path.expand(),
thousand_island_options: [read_timeout: 1000]
thousand_island_options: [read_timeout: 100]
]
|> start_server(opts)
end
Expand Down

0 comments on commit 9c50ed8

Please sign in to comment.