Skip to content

Commit

Permalink
fix: slow gRPC test by setting default client timeout (#347)
Browse files Browse the repository at this point in the history
Though gRPC code says default is infinity, but local test also align with CI, seems that 20s is set
https://github.com/grpc/grpc/blob/53d69cc581c5b7305708587f4f1939278477c28a/src/ruby/lib/grpc/generic/client_stub.rb#L28-L29

20s is somewhat same as the example, maybe an coincide https://grpc.io/blog/deadlines/#adjusting-deadlines

Make tests faster setup smaller timeout - 3 seconds.

Closes issue #315
  • Loading branch information
jychen7 authored Jun 20, 2022
1 parent 1d4b53b commit 473d0f2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/grpc_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require "echo_service"

class TestGRPC < Minitest::Test
DEFAULT_CLIENT_TIMEOUT_IN_SECONDS = 3
ERROR_THRESHOLD = 1
SEMIAN_OPTIONS = {
name: :testing,
Expand Down Expand Up @@ -173,7 +174,7 @@ def test_bulkheads_tickets_are_working

def open_circuit!(stub, method, args)
ERROR_THRESHOLD.times do
assert_raises(GRPC::Unavailable) do
assert_raises(GRPC::DeadlineExceeded) do
stub.send(method, args)
end
end
Expand All @@ -190,7 +191,7 @@ def build_rpc_server(server_opts: {}, client_opts: {})
@server = new_rpc_server_for_testing({ poll_period: 1 }.merge(server_opts))
@port = @server.add_http2_port("0.0.0.0:#{SemianConfig["grpc_port"]}", :this_port_is_insecure)
@host = "#{@hostname}:#{@port}"
@client_opts = client_opts
@client_opts = { timeout: DEFAULT_CLIENT_TIMEOUT_IN_SECONDS }.merge(client_opts)
@server
end

Expand Down

0 comments on commit 473d0f2

Please sign in to comment.