summaryrefslogtreecommitdiff
path: root/test/partitions_test.erl
blob: 834719b7cb837d65d0de734c2f701af0fa4a2460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-module(partitions_test).
-author('brad@cloudant.com').

-include("../include/config.hrl").
-include("../include/common.hrl").
-include_lib("eunit/include/eunit.hrl").

-define(FOUR_NODES, [a,b,c,d]).
-define(Map1, [{d,0},
                {a,292300327466180583640736966543256603931186508596},
                {b,584600654932361167281473933086513207862373017192},
                {c,876900982398541750922210899629769811793559525788},
                {d,1169201309864722334562947866173026415724746034384}]).
-define(Map2, [{c,0},
                {d,182687704666362864775460604089535377456991567873},
                {a,365375409332725729550921208179070754913983135746},
                {b,548063113999088594326381812268606132370974703619},
                {c,730750818665451459101842416358141509827966271492},
                {d,913438523331814323877303020447676887284957839365},
                {a,1096126227998177188652763624537212264741949407238},
                {b,1278813932664540053428224228626747642198940975111}]).
-define(Map3, [{d,0},
                {c,0},
                {a,365375409332725729550921208179070754913983135745},
                {d,365375409332725729550921208179070754913983135745},
                {b,730750818665451459101842416358141509827966271490},
                {a,730750818665451459101842416358141509827966271490},
                {c,1096126227998177188652763624537212264741949407235},
                {b,1096126227998177188652763624537212264741949407235}]).

%%====================================================================
%% Tests
%%====================================================================

fullmap_n1_test() ->
    Map1 = partitions:fullmap(<<"test">>, ?FOUR_NODES, opts(1,5)),
    ?assertEqual(?Map1, Map1),
    Map2 = partitions:fullmap(<<"boorad">>, ?FOUR_NODES, opts(1,8)),
    ?assertEqual(?Map2, Map2),
    ok.

fullmap_Ngt1_test() ->
    Map3 = partitions:fullmap(<<"boorad">>, ?FOUR_NODES, opts(2,4)),
    ?assertEqual(?Map3, Map3),
    ok.


%%====================================================================
%% Internal functions
%%====================================================================

opts(N,Q) ->
    [{n,integer_to_list(N)},{q,integer_to_list(Q)}].