Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/runtests_errors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ server_endpoint = isempty(ARGS) ? "http://localhost:10000/" : ARGS[1]
@info("skipping code generation on Windows to avoid needing batch file execution permissions")
end
include("test_grpcerrors.jl")

@info("testing connect timeouts")
test_connect_timeout()

serverproc = start_server()

@info("testing grpcerrors...")
Expand Down
21 changes: 21 additions & 0 deletions test/test_grpcerrors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,27 @@ function test_blocking_client(server_endpoint::String)
end
end

function test_connect_timeout()
timeout_server_endpoint = "http://10.255.255.1/" # a non routable IP
timeout_secs = 5
client = GRPCErrorsBlockingClient(timeout_server_endpoint; verbose=false, connect_timeout=timeout_secs)
@testset "connect timeout" begin
data = GrpcerrorsClients.Data(; mode=1, param=0)
t1 = time()
try
_, status_future = GrpcerrorsClients.SimpleRPC(client, data)
gRPCCheck(status_future)
error("error not caught")
catch ex
t2 = time()
@test isa(ex, gRPCServiceCallException)
@test ex.message == StatusCode.DEADLINE_EXCEEDED.message
@test ex.grpc_status == StatusCode.DEADLINE_EXCEEDED.code
@test (timeout_secs - 1) <= (t2 - t1) <= (timeout_secs + 1)
end
end
end

function test_clients(server_endpoint::String)
@info("testing blocking client")
test_blocking_client(server_endpoint)
Expand Down