Skip to content
Open
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
40 changes: 40 additions & 0 deletions test/grpcbox_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ all() ->
chain_interceptor,
stream_interceptor,
bidirectional,
stress_test,
client_stream,
client_stream_garbage_collect_streams,
compression,
Expand Down Expand Up @@ -203,6 +204,15 @@ init_per_testcase(bidirectional, Config) ->
services => #{'routeguide.RouteGuide' => routeguide_route_guide}}}]),
application:ensure_all_started(grpcbox),
Config;
init_per_testcase(stress_test, Config) ->
application:load(grpcbox),
application:set_env(grpcbox, client, #{channels => [{default_channel,
[{http, "localhost", 8080, []}], #{}}]}),
application:set_env(grpcbox, servers,
[#{grpc_opts => #{service_protos => [route_guide_pb],
services => #{'routeguide.RouteGuide' => routeguide_route_guide}}}]),
application:ensure_all_started(grpcbox),
Config;
init_per_testcase(client_stream, Config) ->
application:set_env(grpcbox, client, #{channels => [{default_channel,
[{http, "localhost", 8080, []}], #{}}]}),
Expand Down Expand Up @@ -658,6 +668,36 @@ stream_interceptor(_Config) ->
?assertMatch({ok, #{name := <<"Louvre">>}}, grpcbox_client:recv_data(Stream)),
?assertMatch({ok, {_, _, #{<<"x-grpc-stream-interceptor">> := <<"true">>}}}, grpcbox_client:recv_trailers(Stream)).

stress_test_function(Fun, Config, Ref, Parent) ->
Parent ! {stress_test, Ref, Fun(Config)}.

stress_test(Config) ->
stress_test(Config,
erlang:list_to_integer(
os:getenv("GRPCBOX_STRESS_TEST", "10")
)).

stress_test(Config, Count) ->
lists:foreach(fun
(Ref) ->
Parent = self(),
spawn(fun() ->
stress_test_function(fun bidirectional/1, Config, Ref, Parent) end)
end, lists:seq(1, Count)),

Loop = fun Loop(LoopCount) ->
receive
{stress_test, _Ref, _Reply} when LoopCount < Count ->
Loop(LoopCount + 1);
{stress_test, _Ref, _Reply} when LoopCount < Count ->
LoopCount + 1
after
2000 ->
LoopCount
end
end,
?assertEqual(Count, Loop(0)).

%%

%% verify that the chatterbox stream isn't storing frame data
Expand Down
4 changes: 0 additions & 4 deletions test/routeguide_route_guide.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
#{lo => point(),
hi => point()}.

-type route_note() ::
#{location => point(),
message => string()}.

-type feature() ::
#{name => string(),
location => point()}.
Expand Down