Skip to content

Commit

Permalink
add tests for large payloads (#29)
Browse files Browse the repository at this point in the history
Added missing consts for send and recv max payload sizes.
Added tests for large payloads.
  • Loading branch information
tanmaykm authored Jul 19, 2022
1 parent 66e6860 commit e02547d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/limitio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ end
Default maximum gRPC message size
"""
const DEFAULT_MAX_MESSAGE_LENGTH = 1024*1024*4
const DEFAULT_MAX_RECV_MESSAGE_LENGTH = DEFAULT_MAX_MESSAGE_LENGTH
const DEFAULT_MAX_SEND_MESSAGE_LENGTH = DEFAULT_MAX_MESSAGE_LENGTH

"""
struct gRPCMessageTooLargeException
Expand Down
34 changes: 34 additions & 0 deletions test/test_routeclient.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,37 @@ function test_exception()
@test_throws ArgumentError RouteGuideBlockingClient("https://localhost:30000"; maxage=-1)
end

function test_large_payload(client::RouteGuideBlockingClient)
@sync begin
long_message1 = "Long message 1 - " * randstring(1000)
long_message2 = "Long message 2 - " * randstring(5000)

notes = RouteguideClients.RouteNote[
RouteguideClients.RouteNote(;location=RouteguideClients.Point(;latitude=0, longitude=1), message=long_message1),
RouteguideClients.RouteNote(;location=RouteguideClients.Point(;latitude=0, longitude=2), message=long_message2),
]
@debug("long messages in route chat")
in_channel = Channel{RouteguideClients.RouteNote}(1)
@async begin
for note in notes
put!(in_channel, note)
end
close(in_channel)
end
out_channel, status_future = RouteguideClients.RouteChat(client, in_channel)
nreceived = 0
for note in out_channel
nreceived += 1
@debug("received long note $note")
end
gRPCCheck(status_future)
@test nreceived > 0
@test isa(out_channel, Channel{RouteguideClients.RouteNote})
@test !isopen(out_channel)
@test !isopen(in_channel)
end
end

function test_message_length_limit(server_endpoint)
point = RouteguideClients.Point(; latitude=409146138, longitude=-746188906)

Expand Down Expand Up @@ -158,6 +189,9 @@ function test_blocking_client(server_endpoint::String)
@testset "streaming send recv" begin
test_route_chat(client)
end
@testset "large payloads" begin
test_large_payload(client)
end
@testset "error handling" begin
test_exception()
end
Expand Down

2 comments on commit e02547d

@tanmaykm
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/64579

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" e02547d66d330f403150f2f23887094ed3534541
git push origin v0.1.3

Please sign in to comment.