WIP: fix other broken eunit tests, surrounding wedge state
This commit is contained in:
parent
6f7818fca7
commit
0dd9282789
4 changed files with 25 additions and 21 deletions
|
@ -108,13 +108,20 @@ ets_table_name(FluName) when is_binary(FluName) ->
|
|||
list_to_atom(binary_to_list(FluName) ++ "_epoch").
|
||||
|
||||
main2(FluName, TcpPort, DataDir, Rest) ->
|
||||
{Props, DbgProps} = case proplists:get_value(dbg, Rest) of
|
||||
undefined ->
|
||||
{Rest, []};
|
||||
DPs ->
|
||||
{lists:keydelete(dbg, 1, Rest), DPs}
|
||||
end,
|
||||
S0 = #state{flu_name=FluName,
|
||||
tcp_port=TcpPort,
|
||||
data_dir=DataDir,
|
||||
wedged=true,
|
||||
wedged=proplists:get_value(initial_wedged, DbgProps, true),
|
||||
etstab=ets_table_name(FluName),
|
||||
epoch_id=undefined,
|
||||
props=Rest},
|
||||
dbg_props=DbgProps,
|
||||
props=Props},
|
||||
AppendPid = start_append_server(S0, self()),
|
||||
receive
|
||||
append_server_ack -> ok
|
||||
|
@ -131,14 +138,7 @@ main2(FluName, TcpPort, DataDir, Rest) ->
|
|||
end,
|
||||
S1 = S0#state{append_pid=AppendPid,
|
||||
proj_store=ProjectionPid},
|
||||
S2 = case proplists:get_value(dbg, Rest) of
|
||||
undefined ->
|
||||
S1;
|
||||
DbgProps ->
|
||||
S1#state{dbg_props=DbgProps,
|
||||
props=lists:keydelete(dbg, 1, Rest)}
|
||||
end,
|
||||
ListenPid = start_listen_server(S2),
|
||||
ListenPid = start_listen_server(S1),
|
||||
|
||||
Config_e = machi_util:make_config_filename(DataDir, "unused"),
|
||||
ok = filelib:ensure_dir(Config_e),
|
||||
|
@ -174,12 +174,13 @@ run_listen_server(#state{flu_name=FluName, tcp_port=TcpPort}=S) ->
|
|||
{ok, LSock} = gen_tcp:listen(TcpPort, SockOpts),
|
||||
listen_server_loop(LSock, S).
|
||||
|
||||
run_append_server(FluPid, AckPid, #state{flu_name=Name}=S) ->
|
||||
run_append_server(FluPid, AckPid, #state{flu_name=Name,dbg_props=DbgProps}=S) ->
|
||||
%% Reminder: Name is the "main" name of the FLU, i.e., no suffix
|
||||
register(Name, self()),
|
||||
TID = ets:new(ets_table_name(Name),
|
||||
[set, protected, named_table, {read_concurrency, true}]),
|
||||
ets:insert(TID, {epoch, {true, {-1, <<>>}}}),
|
||||
InitialWedged = proplists:get_value(initial_wedged, DbgProps, true),
|
||||
ets:insert(TID, {epoch, {InitialWedged, {-65, <<"bogus epoch, yo">>}}}),
|
||||
AckPid ! append_server_ack,
|
||||
append_server_loop(FluPid, S#state{etstab=TID}).
|
||||
|
||||
|
@ -236,8 +237,6 @@ net_server_loop(Sock, #state{flu_name=FluName, data_dir=DataDir}=S) ->
|
|||
OffsetHex:16/binary, LenHex:8/binary,
|
||||
File:FileLenLF/binary, "\n">> ->
|
||||
{Wedged_p, CurrentEpochId} = ets:lookup_element(S#state.etstab, epoch, 2),
|
||||
io:format(user, "TT wedged ~p, CurrentEpochId ~p\n", [Wedged_p, CurrentEpochId]),
|
||||
timer:sleep(50),
|
||||
do_net_server_read(Sock, OffsetHex, LenHex, File, DataDir,
|
||||
EpochIDRaw, Wedged_p, CurrentEpochId);
|
||||
<<"L ", _EpochIDRaw:(?EpochIDSpace)/binary, "\n">> ->
|
||||
|
|
|
@ -35,7 +35,9 @@ verify_file_checksums_test() ->
|
|||
Host = "localhost",
|
||||
TcpPort = 32958,
|
||||
DataDir = "./data",
|
||||
FLU1 = machi_flu1_test:setup_test_flu(verify1_flu, TcpPort, DataDir),
|
||||
W_props = [{initial_wedged, false}],
|
||||
FLU1 = machi_flu1_test:setup_test_flu(verify1_flu, TcpPort, DataDir,
|
||||
W_props),
|
||||
Sock1 = machi_util:connect(Host, TcpPort),
|
||||
try
|
||||
Prefix = <<"verify_prefix">>,
|
||||
|
|
|
@ -55,7 +55,8 @@ flu_smoke_test() ->
|
|||
Prefix = <<"prefix!">>,
|
||||
BadPrefix = BadFile = "no/good",
|
||||
|
||||
FLU1 = setup_test_flu(smoke_flu, TcpPort, DataDir),
|
||||
W_props = [{initial_wedged, false}],
|
||||
FLU1 = setup_test_flu(smoke_flu, TcpPort, DataDir, W_props),
|
||||
try
|
||||
{error, no_such_file} = ?FLU_C:checksum_list(Host, TcpPort,
|
||||
?DUMMY_PV1_EPOCH,
|
||||
|
@ -64,7 +65,7 @@ flu_smoke_test() ->
|
|||
?DUMMY_PV1_EPOCH, BadFile),
|
||||
|
||||
{ok, []} = ?FLU_C:list_files(Host, TcpPort, ?DUMMY_PV1_EPOCH),
|
||||
{ok, {true, {0,<<0:(20*8)/big>>}}} = ?FLU_C:wedge_status(Host, TcpPort),
|
||||
{ok, {false, _}} = ?FLU_C:wedge_status(Host, TcpPort),
|
||||
|
||||
Chunk1 = <<"yo!">>,
|
||||
{ok, {Off1,Len1,File1}} = ?FLU_C:append_chunk(Host, TcpPort,
|
||||
|
|
|
@ -33,7 +33,9 @@ api_smoke_test() ->
|
|||
Host = "localhost",
|
||||
TcpPort = 57124,
|
||||
DataDir = "./data.api_smoke_flu",
|
||||
FLU1 = machi_flu1_test:setup_test_flu(RegName, TcpPort, DataDir),
|
||||
W_props = [{initial_wedged, false}],
|
||||
FLU1 = machi_flu1_test:setup_test_flu(RegName, TcpPort, DataDir,
|
||||
W_props),
|
||||
erase(flu_pid),
|
||||
|
||||
try
|
||||
|
@ -54,19 +56,19 @@ api_smoke_test() ->
|
|||
infinity),
|
||||
%% Start the FLU again, we should be able to do stuff immediately
|
||||
FLU1b = machi_flu1_test:setup_test_flu(RegName, TcpPort, DataDir,
|
||||
[save_data_dir]),
|
||||
[save_data_dir|W_props]),
|
||||
put(flu_pid, FLU1b),
|
||||
MyChunk = <<"my chunk data">>,
|
||||
{ok, {MyOff,MySize,MyFile}} =
|
||||
?MUT:append_chunk(Prox1, FakeEpoch, <<"prefix">>, MyChunk,
|
||||
infinity),
|
||||
infinity),
|
||||
{ok, MyChunk} = ?MUT:read_chunk(Prox1, FakeEpoch, MyFile, MyOff, MySize),
|
||||
|
||||
%% Alright, now for the rest of the API, whee
|
||||
BadFile = <<"no-such-file">>,
|
||||
{error, no_such_file} = ?MUT:checksum_list(Prox1, FakeEpoch, BadFile),
|
||||
{ok, [_|_]} = ?MUT:list_files(Prox1, FakeEpoch),
|
||||
{ok, {true, {0,<<0:(20*8)/big>>}}} = ?MUT:wedge_status(Prox1),
|
||||
{ok, {false, _}} = ?MUT:wedge_status(Prox1),
|
||||
{ok, FakeEpoch} = ?MUT:get_latest_epoch(Prox1, public),
|
||||
{error, not_written} = ?MUT:read_latest_projection(Prox1, public),
|
||||
{error, not_written} = ?MUT:read_projection(Prox1, public, 44),
|
||||
|
|
Loading…
Reference in a new issue