Skip to content

Commit

Permalink
Merge pull request #10 from nhs-riak/nhse-d32-nhscore.i5-tracer
Browse files Browse the repository at this point in the history
OTP 26 Support
  • Loading branch information
martinsumner authored May 9, 2024
2 parents 3654131 + 52af913 commit 9e9f064
Show file tree
Hide file tree
Showing 16 changed files with 257 additions and 278 deletions.
27 changes: 10 additions & 17 deletions .github/workflows/erlang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ name: Erlang CI

on:
push:
branches: [ nhse-develop ]
branches:
- nhse-develop
- nhse-develop-3.2
- nhse-develop-3.4
pull_request:
branches: [ nhse-develop ]
branches:
- nhse-develop
- nhse-develop-3.2
- nhse-develop-3.4


jobs:
Expand All @@ -17,25 +23,12 @@ jobs:
strategy:
fail-fast: false
matrix:
otp: [22, 24, 25]
otp: [24, 26]
os: [ubuntu-latest]
# OTP lower than 23 does not run on ubuntu-latest (22.04), see
# https://github.com/erlef/setup-beam#compatibility-between-operating-system-and-erlangotp
exclude:
- otp: 22
os: ubuntu-latest
include:
- otp: 22
os: ubuntu-20.04

steps:
- uses: lukka/get-cmake@latest
- uses: actions/checkout@v2
- name: Install dependencies (Ubuntu)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt-get -qq update
sudo apt-get -qq install libsnappy-dev libc6-dev
- uses: actions/checkout@v4
- name: Install Erlang/OTP
uses: erlef/setup-beam@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{riak_ensemble, {git, "https://github.com/nhs-riak/riak_ensemble", {branch, "nhse-develop"}}},
{pbkdf2, {git, "https://github.com/nhs-riak/erlang-pbkdf2.git", {branch, "nhse-develop"}}},
{cluster_info, {git, "https://github.com/nhs-riak/cluster_info.git", {branch, "nhse-develop"}}},
{exometer_core, {git, "https://github.com/Feuerlabs/exometer_core.git", {tag, "1.6.1"}}},
{exometer_core, "2.0.0"},
{basho_stats, {git, "https://github.com/nhs-riak/basho_stats.git", {branch, "nhse-develop"}}}
]}.

Expand Down
82 changes: 0 additions & 82 deletions src/riak_core_exo_monitor.erl

This file was deleted.

4 changes: 2 additions & 2 deletions src/riak_core_membership_leave.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ check_balanced_or_wanting(Ring) ->
%% although this may result in a large number of transfers
-spec attempt_simple_transfer(transfer_ring(),
term(),
random:ran(),
rand:state(),
[{integer(), term()}],
[term()]) ->
{ok, transfer_ring()}|
Expand Down Expand Up @@ -159,7 +159,7 @@ attempt_simple_transfer(Ring, ExitingNode, Seed, Owners, Members) ->
pos_integer(),
term()},
transfer_ring(),
{random:ran(),
{rand:state(),
[{integer(), term()}],
[{term(), non_neg_integer()}]}) ->
{ok, transfer_ring()}|target_n_fail.
Expand Down
14 changes: 8 additions & 6 deletions src/riak_core_stat_calc_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ cache_get(TS, TTL) ->
check_freshness(TS, TTL).

check_freshness(TStamp, TTL) ->
case (TStamp + TTL) > folsom_utils:now_epoch() of
case (TStamp + TTL) > now_epoch() of
true ->
hit;
hit;
false ->
stale
end.
Expand All @@ -166,10 +166,10 @@ maybe_get_stat(_Stat, From, Pid, Awaiting) ->
do_calc_stat(Stat) ->
ServerPid = self(),
spawn_link(
fun() ->
StatVal = riak_core_stat_q:calc_stat(Stat),
gen_server:cast(ServerPid, {value, StatVal, folsom_utils:now_epoch()}) end
).
fun() ->
StatVal = riak_core_stat_q:calc_stat(Stat),
gen_server:cast(ServerPid, {value, StatVal, now_epoch()}) end
).

maybe_tag_stale(Value) ->
case Value of
Expand All @@ -180,3 +180,5 @@ maybe_tag_stale(Value) ->
iolist_to_binary(V)
end.

now_epoch() ->
os:system_time(seconds).
36 changes: 32 additions & 4 deletions src/riak_core_tcp_mon.erl
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,30 @@ nodeupdown_test_() ->
ssl_test_() ->
%% Test depends on self-signed certificates
%% Certificates generated with:
%% openssl req -x509 -newkey rsa:4096 -keyout site1-key.pem -out site1-cert.pem -sha256 -days 3650 -subj "/CN=site1.basho.com" -nodes
%% openssl req -x509 -newkey rsa:4096 -keyout site2-key.pem -out site2-cert.pem -sha256 -days 3650 -subj "/CN=site1.basho.com" -nodes
%% openssl genrsa -aes256 -out ca.key 4096
%% openssl req -x509 -new -nodes -key ca.key -sha256 -days 3650 -out ca.crt -subj '/CN=ca.basho.com'
%%
%% openssl req -new -nodes -out site1.csr -newkey rsa:4096 -keyout site1.key -subj '/CN=site1.basho.com'
%% openssl req -new -nodes -out site2.csr -newkey rsa:4096 -keyout site1.key -subj '/CN=site2.basho.com'
%%
%% openssl x509 -req -in site1.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out site1.crt -days 3650 -sha256
%% openssl x509 -req -in site2.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out site2.crt -days 3650 -sha256
{timeout, 60, fun() ->
ssl:start(),
% Set the stat gathering interval to 100ms
{ok, TCPMonPid} = riak_core_tcp_mon:start_link([{interval, 100}]),
% set up a server to hear us out.
{ok, LS} = ssl:listen(0, [{active, true}, binary, {certfile, "test/site1-cert.pem"}, {keyfile, "test/site1-key.pem"}]),
{ok, LS} =
ssl:listen(
0,
[
{active, true},
binary,
{certfile, "test/site1.crt"},
{keyfile, "test/site1.key"},
{cacertfile, "test/ca.crt"}
]
),
{ok, {_, Port}} = ssl:sockname(LS),
spawn(fun () ->
%% server
Expand All @@ -478,7 +494,19 @@ ssl_test_() ->
ssl_recv_loop(SslSock)
end),

{ok, Socket} = ssl:connect("localhost", Port, [binary, {active, true}, {certfile, "test/site2-cert.pem"}, {keyfile, "test/site2-key.pem"}]),
{ok, Socket} =
ssl:connect(
"localhost",
Port,
[{active, true},
{customize_hostname_check,
[{match_fun,
fun("localhost", {cn,"site1.basho.com"}) -> true end}]},
{certfile, "test/site2.crt"},
{keyfile, "test/site2.key"},
{cacertfile, "test/ca.crt"}
]
),
riak_core_tcp_mon:monitor(Socket, "test", ssl),
% so we have stats to see
lists:foreach(fun(_) ->
Expand Down
14 changes: 12 additions & 2 deletions src/riak_core_tracer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
filter/2,
collect/0, collect/1, collect/2,
results/0,
stop_and_clear/0,
stop_collect/0]).
-export([test_all_events/1]).

Expand Down Expand Up @@ -107,7 +108,7 @@ handle_call({filter, MFs, Filter}, _From, State) ->
handle_call({collect, Duration, Nodes}, _From, State) ->
cancel_timer(State#state.stop_tref),
Tref = timer:send_after(Duration, collect_timeout),
dbg:stop_clear(),
stop_and_clear(),
dbg:tracer(process, {fun ({trace, _, call, {?MODULE, trigger_sentinel, _}}, Pid) ->
gen_server:cast(Pid, stop_sentinel),
Pid;
Expand Down Expand Up @@ -161,7 +162,7 @@ handle_call(stop, _From, State) ->
{stop, normal, ok, State}.

handle_cast(stop_sentinel, State) ->
dbg:stop_clear(),
stop_and_clear(),
case State#state.stop_from of
undefined ->
ok;
Expand All @@ -183,6 +184,15 @@ terminate(_Reason, _State) ->
code_change(_OldVsn, State, _Extra) ->
{ok, State}.


-if(?OTP_RELEASE >= 25).
stop_and_clear() ->
dbg:stop().
-else.
stop_and_clear() ->
dbg:stop_clear().
-endif.

%%%===================================================================
%%% Internal functions
%%%===================================================================
Expand Down
30 changes: 30 additions & 0 deletions test/ca.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-----BEGIN CERTIFICATE-----
MIIFDzCCAvegAwIBAgIUYQ85PFznzvyEToNnKweLLgSiz5EwDQYJKoZIhvcNAQEL
BQAwFzEVMBMGA1UEAwwMY2EuYmFzaG8uY29tMB4XDTI0MDUwMjEwMDEzMVoXDTM0
MDQzMDEwMDEzMVowFzEVMBMGA1UEAwwMY2EuYmFzaG8uY29tMIICIjANBgkqhkiG
9w0BAQEFAAOCAg8AMIICCgKCAgEA2KTXG3parK7BtTOCgTLUgfVdP2gd3leyeidr
l5CM3svnqpiBFGaLU1Tt0Civu6z4c/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aRJPXbKFm1Axt8a
yaD0z1yOLL0Lps3BScw970LWs0YWQXmEnBO0knkBCyYx3K30QGXIFAUyaMhhG6iG
QDYu7uP8yynjsEtgWQm4MKeAGgl1MsBuHQ4QTAgEYXrz6VXpsAkTdSDX5TRUWkNI
LpZA1t4oA+LOd7DSxDHSMBdbVeNGpt13AkGoLldkC6vQfLCATgHQOSdoTBgZ5Ws+
+1D1Nscs/5E53O4KMokuuuL5gCQj6csGNcSCjZ+8pKT8EKoA3am+z+QNeKyghrdW
9fYekKEfLfaCFtHqoEhAaIv0JO9YmHDT3h1GqemW84WWpz3mfFhIgj54xzUgdImq
iuf3n5sjWE4tmCH3EmI+5Ze/iyArOBe5krg5ac8DbAMnj5jDjKs0guXVzacDM+Ni
ugZi
-----END CERTIFICATE-----
30 changes: 0 additions & 30 deletions test/site1-cert.pem

This file was deleted.

Loading

0 comments on commit 9e9f064

Please sign in to comment.