Skip to content

Commit 2772261

Browse files
authored
Bump min erlang ver and add CI (#181)
* Add Github Actions CI tests - Travis CI doesn't work any longer * Update for Erlang version >= 25
1 parent 22d6fd6 commit 2772261

7 files changed

Lines changed: 34 additions & 58 deletions

File tree

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
jobs:
7+
test:
8+
name: test ${{matrix.otp}} on ${{matrix.os}}
9+
runs-on: ${{matrix.os}}
10+
container:
11+
image: erlang:${{matrix.otp}}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os:
16+
- ubuntu-latest
17+
otp:
18+
- "28"
19+
- "27"
20+
- "26"
21+
- "25"
22+
steps:
23+
- uses: actions/checkout@v5
24+
- run: make
25+
- run: make unit_tests
26+

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ibrowse [![Build Status](https://secure.travis-ci.org/cmullaparthi/ibrowse.svg?branch=master)](http://travis-ci.org/cmullaparthi/ibrowse)
1+
# ibrowse ![CI](https://github.com/cmullaparthi/ibrowse/actions/workflows/ci.yml/badge.svg)
22

33
ibrowse is a HTTP client written in erlang.
44

rebar.config

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
warnings_as_errors,
44
warn_unused_vars,
55
nowarn_shadow_vars,
6-
warn_unused_import,
7-
{platform_define, "18|19|^2", new_rand},
8-
{platform_define, "^2", ets_ref}
6+
warn_unused_import
97
]}.
8+
% rebar 2
9+
{require_min_otp_vsn, "25"},
10+
% rebar 3
11+
{minimum_otp_vsn, "25"}.
1012
{xref_checks, [undefined_function_calls, deprecated_function_calls]}.
1113
{eunit_opts, [verbose]}.

src/ibrowse.erl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,6 @@ all_trace_off() ->
688688
%% @doc Shows some internal information about load balancing. Info
689689
%% about workers spawned using spawn_worker_process/2 or
690690
%% spawn_link_worker_process/2 is not included.
691-
-ifdef(ets_ref).
692691
show_dest_status() ->
693692
io:format("~-40.40s | ~-5.5s | ~-10.10s | ~s~n",
694693
["Server:port", "ETS", "Num conns", "LB Pid"]),
@@ -702,21 +701,6 @@ show_dest_status() ->
702701
integer_to_list(Size),
703702
Lb_pid])
704703
end, Metrics).
705-
-else.
706-
show_dest_status() ->
707-
io:format("~-40.40s | ~-5.5s | ~-10.10s | ~s~n",
708-
["Server:port", "ETS", "Num conns", "LB Pid"]),
709-
io:format("~80.80.=s~n", [""]),
710-
Metrics = get_metrics(),
711-
lists:foreach(
712-
fun({Host, Port, {Lb_pid, _, Tid, Size, _}}) ->
713-
io:format("~40.40s | ~-5.5s | ~-5.5s | ~p~n",
714-
[Host ++ ":" ++ integer_to_list(Port),
715-
integer_to_list(Tid),
716-
integer_to_list(Size),
717-
Lb_pid])
718-
end, Metrics).
719-
-endif.
720704

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

test/ibrowse_load_test.erl

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
-module(ibrowse_load_test).
22
%%-compile(export_all).
33
-export([
4-
random_seed/0,
54
start/3,
65
query_state/0,
76
shutdown/0,
@@ -15,20 +14,6 @@
1514
update_unknown_counter/2
1615
]).
1716

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.
31-
3217
-define(ibrowse_load_test_counters, ibrowse_load_test_counters).
3318

3419
start(Num_workers, Num_requests, Max_sess) ->
@@ -123,7 +108,6 @@ spawn_workers(0, _Num_requests, _Parent, Acc) ->
123108
lists:reverse(Acc);
124109
spawn_workers(Num_workers, Num_requests, Parent, Acc) ->
125110
Pid_ref = spawn_monitor(fun() ->
126-
random_seed(),
127111
case catch worker_loop(Parent, Num_requests) of
128112
{'EXIT', Rsn} ->
129113
io:format("Worker crashed with reason: ~p~n", [Rsn]);
@@ -163,7 +147,7 @@ wait_for_workers([{Pid, Pid_ref} | T] = Pids) ->
163147
worker_loop(Parent, 0) ->
164148
Parent ! {done, self()};
165149
worker_loop(Parent, N) ->
166-
Delay = ?RAND:uniform(100),
150+
Delay = rand:uniform(100),
167151
Url = case Delay rem 10 of
168152
%% Change 10 to some number between 0-9 depending on how
169153
%% much chaos you want to introduce into the server

test/ibrowse_test_server.erl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
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-
2014
-record(request, {method, uri, version, headers = [], body = [], state}).
2115

2216
-define(dec2hex(X), erlang:integer_to_list(X, 16)).
@@ -307,7 +301,7 @@ process_request(Sock, Sock_type, Req) ->
307301
do_trace("Recvd req: ~p~n", [Req]),
308302
Resp = <<"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n">>,
309303
do_send(Sock, Sock_type, Resp),
310-
timer:sleep(?RAND:uniform(100)).
304+
timer:sleep(rand:uniform(100)).
311305

312306
do_send(Sock, tcp, Resp) ->
313307
gen_tcp:send(Sock, Resp);

0 commit comments

Comments
 (0)