Skip to content

Commit

Permalink
test reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
kjnilsson committed Apr 25, 2024
1 parent 4f19473 commit 6b54def
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/coordination_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ grow_cluster(Config) ->
{ok, [A], []} = ra:start_cluster(?SYS, ClusterName, Machine, [A]),

ok = ra:start_server(?SYS, ClusterName, B, Machine, [A]),
_ = ra:members(A),
{ok, _, _} = ra:add_member(A, B),
{ok, _, _} = ra:process_command(A, banana),

Expand Down
10 changes: 10 additions & 0 deletions test/ra_log_wal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -651,13 +651,18 @@ recover_overwrite_in_same_batch(Config) ->
% open wal and write a few entreis
% close wal + delete mem_tables
% re-open wal and validate mem_tables are re-created
ets:delete_all_objects(ra_log_open_mem_tables),
ets:delete_all_objects(ra_log_closed_mem_tables),
Conf0 = ?config(wal_conf, Config),
{UId, _} = WriterId = ?config(writer_id, Config),
Conf = Conf0#{segment_writer => spawn(fun () -> ok end)},
meck:new(ra_log_segment_writer, [passthrough]),
meck:expect(ra_log_segment_writer, await, fun(_) -> ok end),
{ok, _Wal} = ra_log_wal:start_link(Conf),
%% it is not possible to guarantee these two writes will definitely
%% be processed in the same batch
{ok, _} = ra_log_wal:write(WriterId, ra_log_wal, 1, 1, <<"data1">>),
timer:sleep(1),
{ok, _} = ra_log_wal:write(WriterId, ra_log_wal, 1, 2, <<"data2">>),
_ = await_written(WriterId, {1, 1, 2}),
ra_log_wal:force_roll_over(ra_log_wal),
Expand All @@ -677,6 +682,7 @@ recover_overwrite_in_same_batch(Config) ->
% check that both mem_tables notifications are received by the segment writer
flush(),


meck:unload(),
proc_lib:stop(Pid),
ok.
Expand Down Expand Up @@ -878,6 +884,10 @@ await_written({UId, _} = Id, {From, To, Term} = Written) ->
receive
{ra_log_event, {written, Written}} ->
mem_tbl_read(UId, To);
{ra_log_event, {written, {From, To, _}}} ->
%% indexes are the same but term is different,
%% lets wait for the original
await_written(Id, Written);
{ra_log_event, {written, {From, T, _}}} ->
await_written(Id, {T+1, To, Term})
after 5000 ->
Expand Down

0 comments on commit 6b54def

Please sign in to comment.