Skip to content

Commit e02547d

Browse files
authored
add tests for large payloads (#29)
Added missing consts for send and recv max payload sizes. Added tests for large payloads.
1 parent 66e6860 commit e02547d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/limitio.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ end
1818
Default maximum gRPC message size
1919
"""
2020
const DEFAULT_MAX_MESSAGE_LENGTH = 1024*1024*4
21+
const DEFAULT_MAX_RECV_MESSAGE_LENGTH = DEFAULT_MAX_MESSAGE_LENGTH
22+
const DEFAULT_MAX_SEND_MESSAGE_LENGTH = DEFAULT_MAX_MESSAGE_LENGTH
2123

2224
"""
2325
struct gRPCMessageTooLargeException

test/test_routeclient.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,37 @@ function test_exception()
108108
@test_throws ArgumentError RouteGuideBlockingClient("https://localhost:30000"; maxage=-1)
109109
end
110110

111+
function test_large_payload(client::RouteGuideBlockingClient)
112+
@sync begin
113+
long_message1 = "Long message 1 - " * randstring(1000)
114+
long_message2 = "Long message 2 - " * randstring(5000)
115+
116+
notes = RouteguideClients.RouteNote[
117+
RouteguideClients.RouteNote(;location=RouteguideClients.Point(;latitude=0, longitude=1), message=long_message1),
118+
RouteguideClients.RouteNote(;location=RouteguideClients.Point(;latitude=0, longitude=2), message=long_message2),
119+
]
120+
@debug("long messages in route chat")
121+
in_channel = Channel{RouteguideClients.RouteNote}(1)
122+
@async begin
123+
for note in notes
124+
put!(in_channel, note)
125+
end
126+
close(in_channel)
127+
end
128+
out_channel, status_future = RouteguideClients.RouteChat(client, in_channel)
129+
nreceived = 0
130+
for note in out_channel
131+
nreceived += 1
132+
@debug("received long note $note")
133+
end
134+
gRPCCheck(status_future)
135+
@test nreceived > 0
136+
@test isa(out_channel, Channel{RouteguideClients.RouteNote})
137+
@test !isopen(out_channel)
138+
@test !isopen(in_channel)
139+
end
140+
end
141+
111142
function test_message_length_limit(server_endpoint)
112143
point = RouteguideClients.Point(; latitude=409146138, longitude=-746188906)
113144

@@ -158,6 +189,9 @@ function test_blocking_client(server_endpoint::String)
158189
@testset "streaming send recv" begin
159190
test_route_chat(client)
160191
end
192+
@testset "large payloads" begin
193+
test_large_payload(client)
194+
end
161195
@testset "error handling" begin
162196
test_exception()
163197
end

0 commit comments

Comments
 (0)