Skip to content

Commit 02be390

Browse files
committed
add erlang 19, 20 for test
1 parent 7529807 commit 02be390

6 files changed

+66
-6
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ otp_release:
77
- 18.0
88
- 18.1
99
- 18.2.1
10+
- 19.3
11+
- 20.0
1012
before_script:
1113
- "./bootstrap_travis.sh"
1214
script: "./rebar3 eunit"

rebar.config

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
{erl_opts, [debug_info, warnings_as_errors, warn_unused_vars, nowarn_shadow_vars, warn_unused_import]}.
1+
{erl_opts, [
2+
debug_info,
3+
warnings_as_errors,
4+
warn_unused_vars,
5+
nowarn_shadow_vars,
6+
warn_unused_import,
7+
{platform_define, "18|19|^2", new_rand},
8+
{platform_define, "^2", ets_ref}
9+
]}.
210
{xref_checks, [undefined_function_calls, deprecated_function_calls]}.
311
{eunit_opts, [verbose]}.

src/ibrowse.erl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,21 @@ all_trace_off() ->
679679
%% @doc Shows some internal information about load balancing. Info
680680
%% about workers spawned using spawn_worker_process/2 or
681681
%% spawn_link_worker_process/2 is not included.
682+
-ifdef(ets_ref).
683+
show_dest_status() ->
684+
io:format("~-40.40s | ~-5.5s | ~-10.10s | ~s~n",
685+
["Server:port", "ETS", "Num conns", "LB Pid"]),
686+
io:format("~80.80.=s~n", [""]),
687+
Metrics = get_metrics(),
688+
lists:foreach(
689+
fun({Host, Port, {Lb_pid, _, Tid, Size, _}}) ->
690+
io:format("~40.40s | ~-5.5s | ~-5.5s | ~p~n",
691+
[Host ++ ":" ++ integer_to_list(Port),
692+
ref_to_list(Tid),
693+
integer_to_list(Size),
694+
Lb_pid])
695+
end, Metrics).
696+
-else.
682697
show_dest_status() ->
683698
io:format("~-40.40s | ~-5.5s | ~-10.10s | ~s~n",
684699
["Server:port", "ETS", "Num conns", "LB Pid"]),
@@ -692,6 +707,7 @@ show_dest_status() ->
692707
integer_to_list(Size),
693708
Lb_pid])
694709
end, Metrics).
710+
-endif.
695711

696712
show_dest_status(Url) ->
697713
#url{host = Host, port = Port} = ibrowse_lib:parse_url(Url),

test/ibrowse_load_test.erl

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
-module(ibrowse_load_test).
2-
-compile(export_all).
2+
%%-compile(export_all).
3+
-export([
4+
random_seed/0,
5+
start/3,
6+
query_state/0,
7+
shutdown/0,
8+
start_1/3,
9+
calculate_timings/0,
10+
get_mmv/2,
11+
spawn_workers/2,
12+
spawn_workers/4,
13+
wait_for_workers/1,
14+
worker_loop/2,
15+
update_unknown_counter/2
16+
]).
17+
18+
-ifdef(new_rand).
19+
20+
-define(RAND, rand).
21+
random_seed() ->
22+
ok.
23+
24+
-else.
25+
26+
-define(RAND, random).
27+
random_seed() ->
28+
random:seed(os:timestamp()).
29+
30+
-endif.
331

432
-define(ibrowse_load_test_counters, ibrowse_load_test_counters).
533

@@ -95,7 +123,7 @@ spawn_workers(0, _Num_requests, _Parent, Acc) ->
95123
lists:reverse(Acc);
96124
spawn_workers(Num_workers, Num_requests, Parent, Acc) ->
97125
Pid_ref = spawn_monitor(fun() ->
98-
random:seed(os:timestamp()),
126+
random_seed(),
99127
case catch worker_loop(Parent, Num_requests) of
100128
{'EXIT', Rsn} ->
101129
io:format("Worker crashed with reason: ~p~n", [Rsn]);
@@ -135,7 +163,7 @@ wait_for_workers([{Pid, Pid_ref} | T] = Pids) ->
135163
worker_loop(Parent, 0) ->
136164
Parent ! {done, self()};
137165
worker_loop(Parent, N) ->
138-
Delay = random:uniform(100),
166+
Delay = ?RAND:uniform(100),
139167
Url = case Delay rem 10 of
140168
%% Change 10 to some number between 0-9 depending on how
141169
%% much chaos you want to introduce into the server

test/ibrowse_test_server.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
get_conn_pipeline_depth/0
1212
]).
1313

14+
-ifdef(new_rand).
15+
-define(RAND, rand).
16+
-else.
17+
-define(RAND, random).
18+
-endif.
19+
1420
-record(request, {method, uri, version, headers = [], body = [], state}).
1521

1622
-define(dec2hex(X), erlang:integer_to_list(X, 16)).
@@ -290,7 +296,7 @@ process_request(Sock, Sock_type, Req) ->
290296
do_trace("Recvd req: ~p~n", [Req]),
291297
Resp = <<"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n">>,
292298
do_send(Sock, Sock_type, Resp),
293-
timer:sleep(random:uniform(100)).
299+
timer:sleep(?RAND:uniform(100)).
294300

295301
do_send(Sock, tcp, Resp) ->
296302
gen_tcp:send(Sock, Resp);

test/ibrowse_tests.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
-define(LONG_TIMEOUT_MS, 30000).
1818
-define(PAUSE_FOR_CONNECTIONS_MS, 2000).
1919

20-
-compile(export_all).
20+
%%-compile(export_all).
2121

2222
setup() ->
2323
application:start(crypto),

0 commit comments

Comments
 (0)