Skip to content

Commit be37c6b

Browse files
author
Brett Hazen
committed
Merge pull request #949 from basho/mra/repl-util-read-fix
Return 0 instead of doing another rt:sysread in repl_util:wait_for_reads/5
2 parents 36de6f9 + 3c88243 commit be37c6b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/rt.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ wait_until(Fun) when is_function(Fun) ->
664664

665665
%% @doc Convenience wrapper for wait_until for the myriad functions that
666666
%% take a node as single argument.
667-
-spec wait_until([node()], fun((node()) -> boolean())) -> ok.
667+
-spec wait_until(node(), fun(() -> boolean())) -> ok | {fail, Result :: term()}.
668668
wait_until(Node, Fun) when is_atom(Node), is_function(Fun) ->
669669
wait_until(fun() -> Fun(Node) end);
670670

tests/repl_util.erl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,17 @@ wait_until_fullsync_stopped(SourceLeader) ->
195195
end).
196196

197197
wait_for_reads(Node, Start, End, Bucket, R) ->
198-
rt:wait_until(Node,
198+
ok = rt:wait_until(Node,
199199
fun(_) ->
200200
Reads = rt:systest_read(Node, Start, End, Bucket, R, <<>>, true),
201201
Reads == []
202202
end),
203-
Reads = rt:systest_read(Node, Start, End, Bucket, R, <<>>, true),
204-
lager:info("Reads: ~p", [Reads]),
205-
length(Reads).
203+
%% rt:systest_read/6 returns a list of errors encountered while performing
204+
%% the requested reads. Since we are asserting this list is empty above,
205+
%% we already know that if we reached here, that the list of reads has
206+
%% no errors. Therefore, we simply return 0 and do not execute another
207+
%% systest_read call.
208+
0.
206209

207210
get_fs_coord_status_item(Node, SinkName, ItemName) ->
208211
Status = rpc:call(Node, riak_repl_console, status, [quiet]),

0 commit comments

Comments
 (0)