diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/jaegertracing/thrift/lib/erl/test/multiplexing_test.erl | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/jaegertracing/thrift/lib/erl/test/multiplexing_test.erl')
-rw-r--r-- | src/jaegertracing/thrift/lib/erl/test/multiplexing_test.erl | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/jaegertracing/thrift/lib/erl/test/multiplexing_test.erl b/src/jaegertracing/thrift/lib/erl/test/multiplexing_test.erl new file mode 100644 index 000000000..0f2d616b8 --- /dev/null +++ b/src/jaegertracing/thrift/lib/erl/test/multiplexing_test.erl @@ -0,0 +1,57 @@ +-module(multiplexing_test). + +-include_lib("eunit/include/eunit.hrl"). + +-export([ + handle_function/2 + ,handle_error/2 +]). + +start_multiplexed_server_test() -> + + Port = 9090, + Services = [ + {"Multiplexing_Calculator", multiplexing__calculator_thrift}, + {"Multiplexing_WeatherReport", multiplexing__weather_report_thrift} + ], + + {ok, Pid} = thrift_socket_server:start([ + {ip, "127.0.0.1"}, + {port, Port}, + {name, ?MODULE}, + {service, Services}, + {handler, [ + {"error_handler", ?MODULE}, + {"Multiplexing_Calculator", ?MODULE}, + {"Multiplexing_WeatherReport", ?MODULE} + ]} + ]), + + {ok, [{"Multiplexing_Calculator", CalculatorClient0}, + {"Multiplexing_WeatherReport", WeatherReportClient0}]} = thrift_client_util:new_multiplexed("127.0.0.1", Port, Services, []), + + ?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(WeatherReportClient0, getTemperature, [1])), + ?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(CalculatorClient0, add, [1])), + ?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(CalculatorClient0, add, [1,1,1])), + + ?assertMatch({_, {error, {no_function, _}}}, thrift_client:call(CalculatorClient0, getTemperature, [])), + ?assertMatch({_, {error, {no_function, _}}}, thrift_client:call(WeatherReportClient0, add, [41, 1])), + + ?assertMatch({_, {ok, 42}}, thrift_client:call(CalculatorClient0, add, [41, 1])), + ?assertMatch({_, {ok, 42.0}}, thrift_client:call(WeatherReportClient0, getTemperature, [])), + + thrift_socket_server:stop(Pid). + +%% HANDLE FUNCTIONS + +%% Calculator handles +handle_function(add, {X, Y}) -> + {reply, X + Y}; + +%% WeatherReport handles +handle_function(getTemperature, {}) -> + {reply, 42.0}. + +handle_error(_F, _Reason) -> +%% ?debugHere, ?debugVal({_F, _Reason}), + ok.
\ No newline at end of file |