From 6b54def9293e44dfaacf618aea96e7d1d8b74c05 Mon Sep 17 00:00:00 2001 From: Karl Nilsson Date: Thu, 25 Apr 2024 09:54:15 +0100 Subject: [PATCH] test reliability --- test/coordination_SUITE.erl | 1 + test/ra_log_wal_SUITE.erl | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/test/coordination_SUITE.erl b/test/coordination_SUITE.erl index 3945df25..dc5cf9a0 100644 --- a/test/coordination_SUITE.erl +++ b/test/coordination_SUITE.erl @@ -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), diff --git a/test/ra_log_wal_SUITE.erl b/test/ra_log_wal_SUITE.erl index 0713abc7..86ce5481 100644 --- a/test/ra_log_wal_SUITE.erl +++ b/test/ra_log_wal_SUITE.erl @@ -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), @@ -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. @@ -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 ->