Fix failure on slow replication

This changes the test assertion so that it retries fetching the value
from the second cluster until it is the expected value, at which point
the test will either pass if the sibling count is reasonable or fail if
it is too damn high.
This commit is contained in:
Engel A. Sanchez 2014-12-23 16:41:59 -05:00
parent abfa0ebf8a
commit 0328b4e7d7

View File

@ -61,18 +61,24 @@ confirm() ->
Expected = lists:seq(1, 100),
%% NB: It is possible that there are three siblings because
%% Having up to 3 siblings could happen in rare cases when the writes hit
%% different nodes concurrently in the n_val=3 preflist.
?assertMatch(Count when Count =< 3, riakc_obj:value_count(AObj)),
rt:wait_until(fun() ->
lager:info("Checking sink object"),
BObj = get_object(ClientB),
?assertEqual(2, riakc_obj:value_count(BObj)),
Resolved = resolve(riakc_obj:get_values(BObj)),
%% Better check final value, no?
?assertEqual(Expected, lists:sort(sets:to_list(Resolved))),
true
end),
WaitFun = fun() ->
lager:info("Checking sink object"),
BObj = get_object(ClientB),
Resolved0 = resolve(riakc_obj:get_values(BObj)),
Resolved = lists:sort(sets:to_list(Resolved0)),
case Resolved of
Expected ->
BCount = riakc_obj:value_count(BObj),
?assertMatch(C when C =< 6, BCount),
true;
_ ->
false
end
end,
?assertEqual(ok, rt:wait_until(WaitFun)),
pass.