Skip to content

Commit

Permalink
Merge pull request #808 from basho/develop-3.0-292
Browse files Browse the repository at this point in the history
Develop 3.0 292
  • Loading branch information
martinsumner authored May 13, 2020
2 parents 1960254 + 404f56e commit 06facee
Show file tree
Hide file tree
Showing 31 changed files with 301 additions and 195 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ ebin/*.beam
ebin/*.app
deps
.eunit
.eqc/
.eqc-info
.qc/
current_counterexample.eqc
rebar3.crashdump
erl_crash.dump
repl_leader_eqc_data/
.local_dialyzer_plt
Expand All @@ -19,3 +21,6 @@ include/riak_repl_pb.hrl
src/riak_repl_pb.erl
undefined
data/*
.rebar3/erlcinfo
test/*.beam
log/*.log
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: erlang
otp_release: R15B01
notifications:
webhooks: http://basho-engbot.herokuapp.com/travis?key=0696aba4b1ddb1efe2bf124558c7e03bd8b9763d
email: [email protected]
source_key: LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFb3dJQkFBS0NBUUVBeFB0dU5BRGRveHJRY3h5cWdjRDNtRCtOOXBKYnZzUG8yKzA5QnMyR1FHZjR2TmZDCmZqNDc0V0RmSzNQaDBGc3hoS21wdmJSV2VIdGxJSEI5WWFXQjFvYnpCRVBNRmovQ2s1bFIwNllEQVJDUkt0WkUKVWo4VGpmNzc5cDlvSDU5d2NuSDk0VTcyaEVVSVhJTnN4b09oR3NFdTJGd1FqYVh2MWVSYmVZWDVmQjczZmE0aApuT3E0UlBHd3BTa2szNFVDV1VXRUhBeUlvSWNocFZoOWtoWGtrWEtFYWtqL25PQVNVNVdka3hhUldCczlnUVAwCkRiN01IZjhoUlZPTmxmS2s5RGE5THptdlpNNysxK1JTL2NOVVp1REplUUtuM09OZzh5MHRJaXIvK0ZJUGxFVFAKaytLZE4wNlZsbmNWR3U2T2JFb1UrVUZWcmV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b3diTDVRSGVoTEdEeVhpRAp4dWk2cWRYelhlWVA0Q0gwd1hWOUNwQjNKOVdzYzM3YTB0b25xTWNjQjBpaGFJOWNVMlhKZVdjN2I5YlFrd2JOCmpWVGcxOWJiMDBDNllKa01kVU9EY1FLQmdHa1FLQ0gxRXBPWXI4RHBZOEtYR045L3hoQ1VWN0ZHUHExVmJQSmsKc0RJbGY3UkFPa3k3Q3ZBS2pVSGtET29sdEFBYnZ0SmFYeXlDOU1wSmptNzU2S0xXUHBwbGhXa2ttNkQwRkp6RwpHd0UrVksrd0thdCsvT2pzby94RC94V0NxR1VlTWV0K3VmUzB6SWsyQk1vTEVvb3g2VFkvZUlEYUp0V2p4T1hWCkwzci9Bb0dCQUxXdnBNclZRN0EyUjA2VGtyWURtZXBWSzlXNlcyUWpnbDVoMEp2Wkk1S2praWVOaXhzc2VDSXAKeUw3VkRYeFZuQXhkZFZFendaSk9vdXA3dkkrWHZGUlJ1VkJORWpkVjhkRC9VbndqMUN0T1krZW9WOEx3NG4zVwpCSFNaN0dHVnFuYTZUYmxxSk1nZGZTN0lKTU9NdmJWVjBUeTdnelU0VCtEcFhUbXE3OUJ2Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==
otp_release:
- 20.3.8
- 21.3
- 22.3
script:
- chmod u+x rebar3
- ./rebar3 do upgrade, compile, xref, dialyzer, eunit
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: compile rel cover test dialyzer
.PHONY: compile rel cover test dialyzer eqc
REBAR=./rebar3

compile:
Expand All @@ -9,16 +9,21 @@ clean:
rm -f src/*_pb.erl
$(REBAR) clean

cover: test
cover:
$(REBAR) eunit --cover
$(REBAR) cover

test: compile
$(REBAR) as test do eunit
$(REBAR) eunit

dialyzer:
$(REBAR) dialyzer

xref:
$(REBAR) xref

eqc:
$(REBAR) as test eqc --testing_budget 120
$(REBAR) as eqc eunit

check: test dialyzer xref
4 changes: 1 addition & 3 deletions attic/repl_leader_eqc.erl → eqc/repl_leader_eqc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@

-module(repl_leader_eqc).

-ifdef(EQC).
-include_lib("eqc/include/eqc.hrl").
-include_lib("eqc/include/eqc_fsm.hrl").
-include_lib("eunit/include/eunit.hrl").

-compile(export_all).
-compile([export_all, nowarn_export_all]).

-record(replnode, {node,
running=false,
Expand Down Expand Up @@ -623,4 +622,3 @@ register_receiver() ->
Leader2 = riak_repl_leader:leader_node(),
{Leader1, Leader2, Res, Pid}.

-endif. % EQC
35 changes: 19 additions & 16 deletions int_test/riak_repl2_rt_eqc.erl → eqc_int/riak_repl2_rt_eqc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
-include_lib("eqc/include/eqc.hrl").
-eqc_group_commands(true).
-include_lib("eqc/include/eqc_statem.hrl").
-compile(export_all).
-compile([export_all, nowarn_export_all]).

-record(remote,
{node, % node running as the remote
Expand Down Expand Up @@ -76,15 +76,15 @@ initial_state() ->
enable_command(S) ->
{call, ?MODULE, enable, [S#ts.local, elements(remote_names(S))]}.

enable_next(S, _R, [Local, Remote]) ->
enable_next(S, _R, [_Local, Remote]) ->
case lists:member(Remote, expect_disabled(S)) of
true ->
update_tr(Remote, fun(TR) -> TR#remote{rtstate=enabled} end, S);
false ->
S
end.

enable_post(S, [Local, Remote], Res) ->
enable_post(S, [_Local, Remote], Res) ->
Expect = case lists:member(Remote, expect_disabled(S)) of
true ->
ok;
Expand All @@ -103,15 +103,15 @@ enable(Local, Remote) ->
disable_command(S) ->
{call, ?MODULE, disable, [S#ts.local, elements(remote_names(S))]}.

disable_next(S, _R, [Local, Remote]) ->
disable_next(S, _R, [_Local, Remote]) ->
case lists:member(Remote, expect_disabled(S)) of
false ->
update_tr(Remote, fun(TR) -> TR#remote{rtstate=disabled} end, S);
true ->
S
end.

disable_post(S, [Local, Remote], Res) ->
disable_post(S, [_Local, Remote], Res) ->
Expect = case lists:member(Remote, expect_disabled(S)) of
false ->
ok;
Expand All @@ -130,15 +130,15 @@ disable(Local, Remote) ->
start_command(S) ->
{call, ?MODULE, start, [S#ts.local, elements(remote_names(S))]}.

start_next(S, _R, [Local, Remote]) ->
start_next(S, _R, [_Local, Remote]) ->
case expect_rtstate(Remote, S) of
enabled ->
update_tr(Remote, fun(TR) -> TR#remote{rtstate=started} end, S);
_ ->
S
end.

start_post(S, [Local, Remote], Res) ->
start_post(S, [_Local, Remote], Res) ->
Expect = case expect_rtstate(Remote, S) of
disabled ->
{not_changed, {not_enabled, Remote}};
Expand All @@ -159,15 +159,15 @@ start(Local, Remote) ->
stop_command(S) ->
{call, ?MODULE, stop, [S#ts.local, elements(remote_names(S))]}.

stop_next(S, _R, [Local, Remote]) ->
stop_next(S, _R, [_Local, Remote]) ->
case expect_rtstate(Remote, S) of
started ->
update_tr(Remote, fun(TR) -> TR#remote{rtstate=enabled} end, S);
_ ->
S
end.

stop_post(S, [Local, Remote], Res) ->
stop_post(S, [_Local, Remote], Res) ->
Expect = case expect_rtstate(Remote, S) of
disabled ->
{not_changed, {not_present, Remote}};
Expand All @@ -188,7 +188,7 @@ stop(Local, Remote) ->
status_command(S) ->
{call, ?MODULE, status, [S#ts.local]}.

status_post(S, [Local], Status) ->
status_post(S, [_Local], Status) ->
%% Check facts about status...
post_expect([{enabled, % must be enabled to be started
lists:sort(expect_enabled(S)++expect_started(S)),
Expand All @@ -211,12 +211,15 @@ write_object_next(S = #ts{remotes = Remotes},
%% Add the expected value
AddVal = fun(R) -> R#remote{expected = [NextVal | R#remote.expected]} end,
Remotes2 =
lists:foldl(fun(Cluster, Remotes) -> orddict:update(Cluster, AddVal, Remotes) end,
Remotes, orddict:fetch_keys(Remotes)),
lists:foldl(fun(Cluster, RemotesAcc) ->
orddict:update(Cluster, AddVal, RemotesAcc)
end,
Remotes,
orddict:fetch_keys(Remotes)),
%% Update next val
S#ts{next_val = <<(NextValInt + 1):64>>, remotes = Remotes2}.

write_object_post(S, [_Client, _NextVal, _Extra], Res) ->
write_object_post(_S, [_Client, _NextVal, _Extra], Res) ->
post_expect([{return, ok, Res}]).

write_object(Client, NextVal, Extra) ->
Expand All @@ -234,15 +237,15 @@ prop_repl2_rt() ->
S0 = initial_state(),
reset_nodes(S0),
%% run the test
{H,S,Result} = HSRes =
{_H,S,Result} = HSRes =
run_commands(?MODULE, Cmds),
pretty_commands(?MODULE, Cmds, HSRes,
aggregate(command_names(Cmds),
conjunction(check_remote_results(S) ++
[{commands, equals(Result, ok)}])))
end).

weight(S, write_object) ->
weight(_S, write_object) ->
20;
weight(_S, _) ->
1.
Expand Down Expand Up @@ -276,7 +279,7 @@ update_tr(Node, Fun, S = #ts{remotes = Remotes}) ->
S#ts{remotes = orddict:update(Node, Fun, Remotes)}.


check_remote_results(S = #ts{client = Client, remotes = Remotes}) ->
check_remote_results(_S = #ts{client = Client, remotes = Remotes}) ->
orddict:fold(fun(Cluster, #remote{expected = Expected}, Acc) ->
[check_remote_result(Client, Cluster, Expected) | Acc]
end, [], Remotes).
Expand Down
26 changes: 19 additions & 7 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
%%-*- mode: erlang -*-

{cover_enabled, true}.
{erl_opts, [debug_info, %warnings_as_errors,

{erl_opts, [debug_info,
warnings_as_errors,
{i, "./_build/default/plugins/gpb/include"},
{parse_transform, lager_transform},
{platform_define, "^[0-9]+", namespaced_types}]}.
{platform_define, "^[0-9]+", namespaced_types},
{platform_define, "^[2-9][1-9](.?[0-9]*)", otp21},
{platform_define, "^[2-9][2-9](.?[0-9]*)", otp22}]}.

{erl_first_files, ["src/gen_leader.erl"]}.
{xref_checks, []}.

{xref_checks,[
undefined_function_calls,
undefined_functions]}.

{xref_queries, [{"(XC - UC) || (XU - X - B - cluster_info : Mod)", []}]}.

{eunit_opts, [verbose]}.

{deps, [
gen_fsm_compat,
{lager, {git, "git://github.com/erlang-lager/lager.git", {tag, "3.6.4"}}},
{lager, {git, "git://github.com/erlang-lager/lager.git", {tag, "3.8.0"}}},
{ranch, {git, "git://github.com/ninenines/ranch.git", {tag, "1.6.0"}}},
{ebloom,{git, "git://github.com/basho/ebloom.git", {branch, "develop-3.0"}}},
{riak_kv, {git, "git://github.com/basho/riak_kv.git", {branch, "develop-3.0"}}},
{riak_pb, {git, "git://github.com/basho/riak_pb.git", {branch, "develop-3.0"}}}
]}.

{plugins, [rebar3_gpb_plugin]}.
{plugins, [rebar3_gpb_plugin,
{eqc_rebar, {git, "https://github.com/Quviq/eqc-rebar", {branch, "master"}}}]}.

{gpb_opts, [{module_name_suffix, "_pb"},
{msg_name_to_lower, true},
Expand All @@ -29,7 +40,8 @@
{dialyzer, [{plt_apps, all_deps}]}.

{profiles,
[{test, [{deps, [meck]}]}]
[{test, [{deps, [meck]}]},
{eqc, [{deps, [meck]}, {erl_opts, [{d, 'EQC'}]}]}]
}.

{edoc_opts, [{preprocess, true}]}.
Binary file modified rebar3
Binary file not shown.
10 changes: 9 additions & 1 deletion src/gen_leader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ dbg_opts(Name, Opts) ->
format_status(Opt, StatusData) ->
[PDict, SysState, Parent, Debug, [Mode, Server, Role, E]] = StatusData,
Header = lists:concat(["Status for gen_leader ", E#election.name]),
Log = sys:get_debug(log, Debug, []),
Log = get_debug(Debug),
#server{mod = Mod, state = State} = Server,
Specific =
case erlang:function_exported(Mod, format_status, 2) of
Expand All @@ -1234,6 +1234,14 @@ format_status(Opt, StatusData) ->
{"Election", format_election(E)}]} |
Specific].

-ifdef(otp22).
get_debug(Debug) ->
sys:get_log(Debug).
-else.
get_debug(Debug) ->
sys:get_debug(log, Debug, []).
-endif.

format_election(E) ->
[
{leader_pid, E#election.leader},
Expand Down
Loading

0 comments on commit 06facee

Please sign in to comment.