I'm writing a test using tsung extended by erlang modules, but I always get the same error and don't even send anything to the server.
the error is:
=INFO REPORT==== 7-Oct-2019::21:12:17 ===
ts_search:(7:<0.181.0>) found module name: "test"
=INFO REPORT==== 7-Oct-2019::21:12:17 ===
ts_search:(7:<0.181.0>) found function name: "authenticate"
=INFO REPORT==== 7-Oct-2019::21:12:17 ===
ts_search:(4:<0.181.0>) extract fun:bad result <<57,...,49>>
My tsung session is:
<sessions>
<session name="authenticate" weight="1" type="ts_raw">
<request subst="true">
<raw data="%%test:authenticate%%" ack="local"></raw>
</request>
</session>
</sessions>
My module is:
-module(test).
-include("test_protobuf.hrl").
-export([authenticate/1]).
authenticate({Pid, DynData}) ->
test_protobuf:encode_msg(#'Authenticate'{user="user", pass="pass"}).
And I'm using the erlang compiler: https://github.com/tomas-abrahamsson/gpb
What should I do?
The Tsung function that calls your authenticate/1
function, ts_search:extract_function/5
, expects a return value of either an integer or a string, but your function is returning a binary. Change it to
authenticate({Pid, DynData}) ->
binary_to_list(test_protobuf:encode_msg(#'Authenticate'{user="user", pass="pass"})).