diff --git a/.travis.yml b/.travis.yml index 2dd9ad6..3993bf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ otp_release: - 18.0 - 18.1 - 18.2.1 + - 19.3 + - 20.0 before_script: - "./bootstrap_travis.sh" script: "./rebar3 eunit" diff --git a/rebar.config b/rebar.config index 4485a22..eaa892c 100644 --- a/rebar.config +++ b/rebar.config @@ -1,3 +1,11 @@ -{erl_opts, [debug_info, warnings_as_errors, warn_unused_vars, nowarn_shadow_vars, warn_unused_import]}. +{erl_opts, [ + debug_info, + warnings_as_errors, + warn_unused_vars, + nowarn_shadow_vars, + warn_unused_import, + {platform_define, "18|19|^2", new_rand}, + {platform_define, "^2", ets_ref} + ]}. {xref_checks, [undefined_function_calls, deprecated_function_calls]}. {eunit_opts, [verbose]}. diff --git a/src/ibrowse.erl b/src/ibrowse.erl index 648c698..2066799 100644 --- a/src/ibrowse.erl +++ b/src/ibrowse.erl @@ -679,6 +679,21 @@ all_trace_off() -> %% @doc Shows some internal information about load balancing. Info %% about workers spawned using spawn_worker_process/2 or %% spawn_link_worker_process/2 is not included. +-ifdef(ets_ref). +show_dest_status() -> + io:format("~-40.40s | ~-5.5s | ~-10.10s | ~s~n", + ["Server:port", "ETS", "Num conns", "LB Pid"]), + io:format("~80.80.=s~n", [""]), + Metrics = get_metrics(), + lists:foreach( + fun({Host, Port, {Lb_pid, _, Tid, Size, _}}) -> + io:format("~40.40s | ~-5.5s | ~-5.5s | ~p~n", + [Host ++ ":" ++ integer_to_list(Port), + ref_to_list(Tid), + integer_to_list(Size), + Lb_pid]) + end, Metrics). +-else. show_dest_status() -> io:format("~-40.40s | ~-5.5s | ~-10.10s | ~s~n", ["Server:port", "ETS", "Num conns", "LB Pid"]), @@ -692,6 +707,7 @@ show_dest_status() -> integer_to_list(Size), Lb_pid]) end, Metrics). +-endif. show_dest_status(Url) -> #url{host = Host, port = Port} = ibrowse_lib:parse_url(Url), diff --git a/test/ibrowse_load_test.erl b/test/ibrowse_load_test.erl index eef0aaf..076c46b 100644 --- a/test/ibrowse_load_test.erl +++ b/test/ibrowse_load_test.erl @@ -1,5 +1,33 @@ -module(ibrowse_load_test). --compile(export_all). +%%-compile(export_all). +-export([ + random_seed/0, + start/3, + query_state/0, + shutdown/0, + start_1/3, + calculate_timings/0, + get_mmv/2, + spawn_workers/2, + spawn_workers/4, + wait_for_workers/1, + worker_loop/2, + update_unknown_counter/2 + ]). + +-ifdef(new_rand). + +-define(RAND, rand). +random_seed() -> + ok. + +-else. + +-define(RAND, random). +random_seed() -> + random:seed(os:timestamp()). + +-endif. -define(ibrowse_load_test_counters, ibrowse_load_test_counters). @@ -95,7 +123,7 @@ spawn_workers(0, _Num_requests, _Parent, Acc) -> lists:reverse(Acc); spawn_workers(Num_workers, Num_requests, Parent, Acc) -> Pid_ref = spawn_monitor(fun() -> - random:seed(os:timestamp()), + random_seed(), case catch worker_loop(Parent, Num_requests) of {'EXIT', Rsn} -> io:format("Worker crashed with reason: ~p~n", [Rsn]); @@ -135,7 +163,7 @@ wait_for_workers([{Pid, Pid_ref} | T] = Pids) -> worker_loop(Parent, 0) -> Parent ! {done, self()}; worker_loop(Parent, N) -> - Delay = random:uniform(100), + Delay = ?RAND:uniform(100), Url = case Delay rem 10 of %% Change 10 to some number between 0-9 depending on how %% much chaos you want to introduce into the server diff --git a/test/ibrowse_test_server.erl b/test/ibrowse_test_server.erl index f30e895..3ba7c67 100644 --- a/test/ibrowse_test_server.erl +++ b/test/ibrowse_test_server.erl @@ -11,6 +11,12 @@ get_conn_pipeline_depth/0 ]). +-ifdef(new_rand). +-define(RAND, rand). +-else. +-define(RAND, random). +-endif. + -record(request, {method, uri, version, headers = [], body = [], state}). -define(dec2hex(X), erlang:integer_to_list(X, 16)). @@ -290,7 +296,7 @@ process_request(Sock, Sock_type, Req) -> do_trace("Recvd req: ~p~n", [Req]), Resp = <<"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n">>, do_send(Sock, Sock_type, Resp), - timer:sleep(random:uniform(100)). + timer:sleep(?RAND:uniform(100)). do_send(Sock, tcp, Resp) -> gen_tcp:send(Sock, Resp); diff --git a/test/ibrowse_tests.erl b/test/ibrowse_tests.erl index d3b07b1..594b8ed 100644 --- a/test/ibrowse_tests.erl +++ b/test/ibrowse_tests.erl @@ -17,7 +17,7 @@ -define(LONG_TIMEOUT_MS, 30000). -define(PAUSE_FOR_CONNECTIONS_MS, 2000). --compile(export_all). +%%-compile(export_all). setup() -> application:start(crypto),