Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gen_fsm replaced by gen_statem in vnode #80

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 60 additions & 22 deletions .github/workflows/erlang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,82 @@ name: Erlang CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
erlang: [ 21,22,23 ]
erlang: [ 21,22,23,24 ]

container:
image: erlang:${{ matrix.erlang }}

steps:
- uses: actions/checkout@v2
- run: make compile

test:
runs-on: ubuntu-latest
strategy:
matrix:
erlang: [ 21,22,23,24 ]

container:
image: erlang:${{ matrix.erlang }}

steps:
- uses: actions/checkout@v2
- name: Compile
run: make compile
- name: Format
run: make format
- name: Unit Tests
run: make test
- name: Property-Based Tests
run: make proper
- name: Coverage
run: make coverage
- name: Lint
run: make lint
- name: XRef
run: make xref
- name: Dialyzer
run: make dialyzer
- name: Documentation
run: make docs
- run: make compile
- run: make test
- run: make proper
- run: make coverage
- name: Send Coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./rebar3 as test coveralls send

verify:
runs-on: ubuntu-latest
strategy:
matrix:
erlang: [ 21,22,23,24 ]

container:
image: erlang:${{ matrix.erlang }}

steps:
- uses: actions/checkout@v2
- run: make format
- run: make xref
- run: make lint
- run: make dialyzer

system-tests:
runs-on: ubuntu-latest
strategy:
matrix:
erlang: [ 21,22,23,24 ]

container:
image: erlang:${{ matrix.erlang }}

steps:
- uses: actions/checkout@v2
with:
repository: riak-core-lite/rclref
path: ./rclref

- uses: actions/checkout@v2
with:
path: ./riak_core/

- run: |
mkdir rclref/_checkouts;\
ln -s ../../riak_core/ rclref/_checkouts/riak_core;\
cd rclref;\
make ct

7 changes: 0 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
PULSE_TESTS = worker_pool_pulse
COVERPATH = ./_build/test/cover
REBAR ?= ./rebar3

Expand Down Expand Up @@ -26,12 +25,6 @@ clean-test:
rm -rf data.nonode@nohost
rm -rf data

# You should 'clean' before your first run of this target
# so that deps get built with PULSE where needed.
pulse:
${REBAR} compile -D PULSE
${REBAR} eunit -D PULSE skip_deps=true suite=$(PULSE_TESTS)

proper:
${REBAR} as proper do eunit

Expand Down
8 changes: 4 additions & 4 deletions include/riak_core_handoff.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

-record(ho_stats,
{interval_end :: erlang:timestamp(),
last_update :: erlang:timestamp() | undefined,
last_update = os:timestamp() :: erlang:timestamp(),
objs = 0 :: non_neg_integer(),
bytes = 0 :: non_neg_integer()}).

Expand Down Expand Up @@ -50,10 +50,10 @@
type :: ho_type() | undefined,
req_origin :: node(),
filter_mod_fun :: {module(), atom()} | undefined,
size ::
size = {0, objects}::
{function(), dynamic} |
{non_neg_integer(), bytes | objects} |
undefined}).
{non_neg_integer(), bytes | objects}
}).

-type handoff_status() :: #handoff_status{}.

Expand Down
10 changes: 6 additions & 4 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{deps,
% worker pool library
[{poolboy, "~>1.5.2"}]}
[poolboy]}

.

Expand Down Expand Up @@ -33,14 +33,16 @@

{profiles,
[{test,
[{erl_opts, [nowarn_export_all]},
[{extra_src_dirs, [{"test", [{recursive, true}]}]},
{erl_opts, [nowarn_export_all]},
{plugins, [coveralls]},
{deps, [meck]}]},
{proper,
[{erl_opts,
[{extra_src_dirs, [{"test", [{recursive, true}]}]},
{erl_opts,
[nowarn_export_all, {d, 'PROPER'}, {d, 'TEST'}]},
{plugins, [coveralls]},
{deps, [meck, {proper, "1.3.0"}, recon]}]},
{deps, [meck, {proper, "1.4.0"}, recon]}]},
{docs, [{deps, [{edown, "0.7.0"}]}]}]}

.
Expand Down
6 changes: 4 additions & 2 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{"1.1.0",
{"1.2.0",
[{<<"poolboy">>,{pkg,<<"poolboy">>,<<"1.5.2">>},0}]}.
[
{pkg_hash,[
{<<"poolboy">>, <<"392B007A1693A64540CEAD79830443ABF5762F5D30CF50BC95CB2C1AAAFA006B">>}]}
{<<"poolboy">>, <<"392B007A1693A64540CEAD79830443ABF5762F5D30CF50BC95CB2C1AAAFA006B">>}]},
{pkg_hash_ext,[
{<<"poolboy">>, <<"DAD79704CE5440F3D5A3681C8590B9DC25D1A561E8F5A9C995281012860901E3">>}]}
].
17 changes: 14 additions & 3 deletions src/chash.erl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fresh(NumPartitions, SeedNode) ->
Inc = ring_increment(NumPartitions),
{NumPartitions,
[{IndexAsInt, SeedNode}
|| IndexAsInt <- lists:seq(0, (?RINGTOP) - 1, Inc)]}.
|| IndexAsInt <- lists:seq(0, (?RINGTOP) -1 -(?RINGTOP rem NumPartitions), Inc)]}.

%% @doc Find the Node that owns the partition identified by IndexAsInt.
-spec lookup(IndexAsInt :: index_as_int(),
Expand Down Expand Up @@ -267,6 +267,11 @@ random_node(NodeA, NodeB) ->
%% ===================================================================
-ifdef(TEST).

fresh_sizes_test() ->
lists:foreach(fun(I) ->
?assertEqual(I, (length(chash:nodes(chash:fresh(I, the_node)))))
end, [1, 10000]).

update_test() ->
Node = old@host,
NewNode = new@host,
Expand All @@ -276,6 +281,14 @@ update_test() ->
{Index, _} = lists:nth(N, Nodes),
Index
end,

{5,
[{_, Node},
{_, Node},
{_, Node},
{_, Node},
{_, Node}]} = CHash,

% Test update...
FirstIndex = GetNthIndex(1, CHash),
ThirdIndex = GetNthIndex(3, CHash),
Expand All @@ -284,15 +297,13 @@ update_test() ->
{_, Node},
{_, Node},
{_, Node},
{_, Node},
{_, Node}]} =
update(FirstIndex, NewNode, CHash),
{5,
[{_, Node},
{_, Node},
{_, NewNode},
{_, Node},
{_, Node},
{_, Node}]} =
update(ThirdIndex, NewNode, CHash).

Expand Down
Loading