Skip to content

Commit

Permalink
Additional test following review
Browse files Browse the repository at this point in the history
Just to explicitly state the requirement that input to the function (Owners) must be sorted.  This is a common assumption in riak_core, and was an assumption of the replaced function.
  • Loading branch information
martinsumner committed Oct 7, 2021
1 parent e4f7f16 commit cc95353
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/riak_core_gossip.erl
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ attempt_simple_transfer(Ring, ExitingNode, Seed, Owners, Members) ->
end.

%% @doc Simple transfer of leaving node's vnodes to safe place
%% Iterates over Owners, which must be sorted by Index (from 0...), and
%% attempts to safely re-allocate each ownerhsip which is currently set to
%% the exiting node
-spec simple_transfer([{integer(), term()}],
{fun((integer(),
term(),
Expand Down Expand Up @@ -624,7 +627,23 @@ simple_transfer_simple_test() ->
{FixedSeed,
[],
lists:keydelete(n4, 1, count_nodes(R4))}).


simple_transfer_needstobesorted_test() ->
lists:foreach(fun transfer_needstobesorted_tester/1, lists:seq(1, 100)).

transfer_needstobesorted_tester(I) ->
R0 = [{6,n3}, {13,n3}, {12,n6}, {11,n5}, {10,n4}, {9,n3}, {8,n2},
{7,n1}, {5,n6}, {4,n5}, {3,n4}, {2,n3}, {1,n2}, {0,n1}],
VariableSeed = rand:seed(exrop, {1632, 989499, I * 13}),
{ok, R1} =
simple_transfer(lists:keysort(1, R0),
{fun test_ring_fun/3, 3, n3},
R0,
{VariableSeed,
[],
lists:keydelete(n3, 1, count_nodes(R0))}),
?assertMatch({13, n4}, lists:keyfind(13, 1, R1)).

simple_transfer_evendistribution_test() ->
R0 = [{0, n1}, {1, n2}, {2, n3}, {3, n4}, {4, n5},
{5, n6}, {6, n7}, {7, n8}, {8, n9}, {9, n10},
Expand Down

0 comments on commit cc95353

Please sign in to comment.