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").
|
list_to_atom(binary_to_list(FluName) ++ "_epoch").
|
||||||
|
|
||||||
main2(FluName, TcpPort, DataDir, Rest) ->
|
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,
|
S0 = #state{flu_name=FluName,
|
||||||
tcp_port=TcpPort,
|
tcp_port=TcpPort,
|
||||||
data_dir=DataDir,
|
data_dir=DataDir,
|
||||||
wedged=true,
|
wedged=proplists:get_value(initial_wedged, DbgProps, true),
|
||||||
etstab=ets_table_name(FluName),
|
etstab=ets_table_name(FluName),
|
||||||
epoch_id=undefined,
|
epoch_id=undefined,
|
||||||
props=Rest},
|
dbg_props=DbgProps,
|
||||||
|
props=Props},
|
||||||
AppendPid = start_append_server(S0, self()),
|
AppendPid = start_append_server(S0, self()),
|
||||||
receive
|
receive
|
||||||
append_server_ack -> ok
|
append_server_ack -> ok
|
||||||
|
@ -131,14 +138,7 @@ main2(FluName, TcpPort, DataDir, Rest) ->
|
||||||
end,
|
end,
|
||||||
S1 = S0#state{append_pid=AppendPid,
|
S1 = S0#state{append_pid=AppendPid,
|
||||||
proj_store=ProjectionPid},
|
proj_store=ProjectionPid},
|
||||||
S2 = case proplists:get_value(dbg, Rest) of
|
ListenPid = start_listen_server(S1),
|
||||||
undefined ->
|
|
||||||
S1;
|
|
||||||
DbgProps ->
|
|
||||||
S1#state{dbg_props=DbgProps,
|
|
||||||
props=lists:keydelete(dbg, 1, Rest)}
|
|
||||||
end,
|
|
||||||
ListenPid = start_listen_server(S2),
|
|
||||||
|
|
||||||
Config_e = machi_util:make_config_filename(DataDir, "unused"),
|
Config_e = machi_util:make_config_filename(DataDir, "unused"),
|
||||||
ok = filelib:ensure_dir(Config_e),
|
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),
|
{ok, LSock} = gen_tcp:listen(TcpPort, SockOpts),
|
||||||
listen_server_loop(LSock, S).
|
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
|
%% Reminder: Name is the "main" name of the FLU, i.e., no suffix
|
||||||
register(Name, self()),
|
register(Name, self()),
|
||||||
TID = ets:new(ets_table_name(Name),
|
TID = ets:new(ets_table_name(Name),
|
||||||
[set, protected, named_table, {read_concurrency, true}]),
|
[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,
|
AckPid ! append_server_ack,
|
||||||
append_server_loop(FluPid, S#state{etstab=TID}).
|
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,
|
OffsetHex:16/binary, LenHex:8/binary,
|
||||||
File:FileLenLF/binary, "\n">> ->
|
File:FileLenLF/binary, "\n">> ->
|
||||||
{Wedged_p, CurrentEpochId} = ets:lookup_element(S#state.etstab, epoch, 2),
|
{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,
|
do_net_server_read(Sock, OffsetHex, LenHex, File, DataDir,
|
||||||
EpochIDRaw, Wedged_p, CurrentEpochId);
|
EpochIDRaw, Wedged_p, CurrentEpochId);
|
||||||
<<"L ", _EpochIDRaw:(?EpochIDSpace)/binary, "\n">> ->
|
<<"L ", _EpochIDRaw:(?EpochIDSpace)/binary, "\n">> ->
|
||||||
|
|
|
@ -35,7 +35,9 @@ verify_file_checksums_test() ->
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
TcpPort = 32958,
|
TcpPort = 32958,
|
||||||
DataDir = "./data",
|
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),
|
Sock1 = machi_util:connect(Host, TcpPort),
|
||||||
try
|
try
|
||||||
Prefix = <<"verify_prefix">>,
|
Prefix = <<"verify_prefix">>,
|
||||||
|
|
|
@ -55,7 +55,8 @@ flu_smoke_test() ->
|
||||||
Prefix = <<"prefix!">>,
|
Prefix = <<"prefix!">>,
|
||||||
BadPrefix = BadFile = "no/good",
|
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
|
try
|
||||||
{error, no_such_file} = ?FLU_C:checksum_list(Host, TcpPort,
|
{error, no_such_file} = ?FLU_C:checksum_list(Host, TcpPort,
|
||||||
?DUMMY_PV1_EPOCH,
|
?DUMMY_PV1_EPOCH,
|
||||||
|
@ -64,7 +65,7 @@ flu_smoke_test() ->
|
||||||
?DUMMY_PV1_EPOCH, BadFile),
|
?DUMMY_PV1_EPOCH, BadFile),
|
||||||
|
|
||||||
{ok, []} = ?FLU_C:list_files(Host, TcpPort, ?DUMMY_PV1_EPOCH),
|
{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!">>,
|
Chunk1 = <<"yo!">>,
|
||||||
{ok, {Off1,Len1,File1}} = ?FLU_C:append_chunk(Host, TcpPort,
|
{ok, {Off1,Len1,File1}} = ?FLU_C:append_chunk(Host, TcpPort,
|
||||||
|
|
|
@ -33,7 +33,9 @@ api_smoke_test() ->
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
TcpPort = 57124,
|
TcpPort = 57124,
|
||||||
DataDir = "./data.api_smoke_flu",
|
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),
|
erase(flu_pid),
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -54,19 +56,19 @@ api_smoke_test() ->
|
||||||
infinity),
|
infinity),
|
||||||
%% Start the FLU again, we should be able to do stuff immediately
|
%% Start the FLU again, we should be able to do stuff immediately
|
||||||
FLU1b = machi_flu1_test:setup_test_flu(RegName, TcpPort, DataDir,
|
FLU1b = machi_flu1_test:setup_test_flu(RegName, TcpPort, DataDir,
|
||||||
[save_data_dir]),
|
[save_data_dir|W_props]),
|
||||||
put(flu_pid, FLU1b),
|
put(flu_pid, FLU1b),
|
||||||
MyChunk = <<"my chunk data">>,
|
MyChunk = <<"my chunk data">>,
|
||||||
{ok, {MyOff,MySize,MyFile}} =
|
{ok, {MyOff,MySize,MyFile}} =
|
||||||
?MUT:append_chunk(Prox1, FakeEpoch, <<"prefix">>, MyChunk,
|
?MUT:append_chunk(Prox1, FakeEpoch, <<"prefix">>, MyChunk,
|
||||||
infinity),
|
infinity),
|
||||||
{ok, MyChunk} = ?MUT:read_chunk(Prox1, FakeEpoch, MyFile, MyOff, MySize),
|
{ok, MyChunk} = ?MUT:read_chunk(Prox1, FakeEpoch, MyFile, MyOff, MySize),
|
||||||
|
|
||||||
%% Alright, now for the rest of the API, whee
|
%% Alright, now for the rest of the API, whee
|
||||||
BadFile = <<"no-such-file">>,
|
BadFile = <<"no-such-file">>,
|
||||||
{error, no_such_file} = ?MUT:checksum_list(Prox1, FakeEpoch, BadFile),
|
{error, no_such_file} = ?MUT:checksum_list(Prox1, FakeEpoch, BadFile),
|
||||||
{ok, [_|_]} = ?MUT:list_files(Prox1, FakeEpoch),
|
{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),
|
{ok, FakeEpoch} = ?MUT:get_latest_epoch(Prox1, public),
|
||||||
{error, not_written} = ?MUT:read_latest_projection(Prox1, public),
|
{error, not_written} = ?MUT:read_latest_projection(Prox1, public),
|
||||||
{error, not_written} = ?MUT:read_projection(Prox1, public, 44),
|
{error, not_written} = ?MUT:read_projection(Prox1, public, 44),
|
||||||
|
|
Loading…
Reference in a new issue