Add basic {error, bad_checksum} tests to proxy & CR clients
This commit is contained in:
parent
e3162fdcda
commit
dd4160b963
3 changed files with 33 additions and 5 deletions
|
@ -295,6 +295,8 @@ do_append_head2(Prefix, Chunk, ChunkExtra, Depth, STime,
|
||||||
%% io:format(user, "append ~w,", [HeadFLU]),
|
%% io:format(user, "append ~w,", [HeadFLU]),
|
||||||
do_append_midtail(RestFLUs, Prefix, File, Offset, Chunk, ChunkExtra,
|
do_append_midtail(RestFLUs, Prefix, File, Offset, Chunk, ChunkExtra,
|
||||||
[HeadFLU], 0, STime, S);
|
[HeadFLU], 0, STime, S);
|
||||||
|
{error, bad_checksum}=BadCS ->
|
||||||
|
{reply, BadCS, S};
|
||||||
{error, Retry}
|
{error, Retry}
|
||||||
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
||||||
do_append_head(Prefix, Chunk, ChunkExtra, Depth, STime, S);
|
do_append_head(Prefix, Chunk, ChunkExtra, Depth, STime, S);
|
||||||
|
@ -359,6 +361,9 @@ do_append_midtail2([FLU|RestFLUs]=FLUs, Prefix, File, Offset, Chunk,
|
||||||
%% io:format(user, "write ~w,", [FLU]),
|
%% io:format(user, "write ~w,", [FLU]),
|
||||||
do_append_midtail2(RestFLUs, Prefix, File, Offset, Chunk,
|
do_append_midtail2(RestFLUs, Prefix, File, Offset, Chunk,
|
||||||
ChunkExtra, [FLU|Ws], Depth, STime, S);
|
ChunkExtra, [FLU|Ws], Depth, STime, S);
|
||||||
|
{error, bad_checksum}=BadCS ->
|
||||||
|
%% TODO: alternate strategy?
|
||||||
|
{reply, BadCS, S};
|
||||||
{error, Retry}
|
{error, Retry}
|
||||||
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
||||||
do_append_midtail(FLUs, Prefix, File, Offset, Chunk,
|
do_append_midtail(FLUs, Prefix, File, Offset, Chunk,
|
||||||
|
@ -407,6 +412,9 @@ do_read_chunk2(File, Offset, Size, Depth, STime,
|
||||||
got, byte_size(BadChunk)});
|
got, byte_size(BadChunk)});
|
||||||
{error, partial_read}=Err ->
|
{error, partial_read}=Err ->
|
||||||
{reply, Err, S};
|
{reply, Err, S};
|
||||||
|
{error, bad_checksum}=BadCS ->
|
||||||
|
%% TODO: alternate strategy?
|
||||||
|
{reply, BadCS, S};
|
||||||
{error, Retry}
|
{error, Retry}
|
||||||
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
||||||
do_read_chunk(File, Offset, Size, Depth, STime, S);
|
do_read_chunk(File, Offset, Size, Depth, STime, S);
|
||||||
|
@ -461,6 +469,9 @@ read_repair2(cp_mode=ConsistencyMode,
|
||||||
{ok, BadChunk} ->
|
{ok, BadChunk} ->
|
||||||
exit({todo, bad_chunk_size, ?MODULE, ?LINE, File, Offset,
|
exit({todo, bad_chunk_size, ?MODULE, ?LINE, File, Offset,
|
||||||
Size, got, byte_size(BadChunk)});
|
Size, got, byte_size(BadChunk)});
|
||||||
|
{error, bad_checksum}=BadCS ->
|
||||||
|
%% TODO: alternate strategy?
|
||||||
|
{reply, BadCS, S};
|
||||||
{error, Retry}
|
{error, Retry}
|
||||||
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
||||||
read_repair(ConsistencyMode, ReturnMode, File, Offset,
|
read_repair(ConsistencyMode, ReturnMode, File, Offset,
|
||||||
|
@ -482,6 +493,9 @@ read_repair2(ap_mode=ConsistencyMode,
|
||||||
{ok, BadChunk} ->
|
{ok, BadChunk} ->
|
||||||
exit({todo, bad_chunk_size, ?MODULE, ?LINE, File,
|
exit({todo, bad_chunk_size, ?MODULE, ?LINE, File,
|
||||||
Offset, Size, got, byte_size(BadChunk)});
|
Offset, Size, got, byte_size(BadChunk)});
|
||||||
|
{error, bad_checksum}=BadCS ->
|
||||||
|
%% TODO: alternate strategy?
|
||||||
|
{reply, BadCS, S};
|
||||||
{error, Retry}
|
{error, Retry}
|
||||||
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
||||||
read_repair(ConsistencyMode, ReturnMode, File,
|
read_repair(ConsistencyMode, ReturnMode, File,
|
||||||
|
@ -537,6 +551,9 @@ read_repair4([First|Rest]=ToRepair, ReturnMode, Chunk, Repaired, File, Offset,
|
||||||
ok ->
|
ok ->
|
||||||
read_repair4(Rest, ReturnMode, Chunk, [First|Repaired], File,
|
read_repair4(Rest, ReturnMode, Chunk, [First|Repaired], File,
|
||||||
Offset, Size, Depth, STime, S);
|
Offset, Size, Depth, STime, S);
|
||||||
|
{error, bad_checksum}=BadCS ->
|
||||||
|
%% TODO: alternate strategy?
|
||||||
|
{reply, BadCS, S};
|
||||||
{error, Retry}
|
{error, Retry}
|
||||||
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
when Retry == partition; Retry == bad_epoch; Retry == wedged ->
|
||||||
read_repair3(ToRepair, ReturnMode, Chunk, Repaired, File,
|
read_repair3(ToRepair, ReturnMode, Chunk, Repaired, File,
|
||||||
|
|
|
@ -86,6 +86,9 @@ smoke_test() ->
|
||||||
machi_cr_client:append_chunk(C1, Prefix, Chunk1),
|
machi_cr_client:append_chunk(C1, Prefix, Chunk1),
|
||||||
{ok, {Off1,Size1,File1}} =
|
{ok, {Off1,Size1,File1}} =
|
||||||
machi_cr_client:append_chunk(C1, Prefix, Chunk1),
|
machi_cr_client:append_chunk(C1, Prefix, Chunk1),
|
||||||
|
Chunk1_badcs = {<<?CSUM_TAG_CLIENT_GEN:8, 0:(8*20)>>, Chunk1},
|
||||||
|
{error, bad_checksum} =
|
||||||
|
machi_cr_client:append_chunk(C1, Prefix, Chunk1_badcs),
|
||||||
{ok, Chunk1} = machi_cr_client:read_chunk(C1, File1, Off1, Size1),
|
{ok, Chunk1} = machi_cr_client:read_chunk(C1, File1, Off1, Size1),
|
||||||
{ok, PPP} = machi_flu1_client:read_latest_projection(Host, PortBase+0,
|
{ok, PPP} = machi_flu1_client:read_latest_projection(Host, PortBase+0,
|
||||||
private),
|
private),
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
-module(machi_proxy_flu1_client_test).
|
-module(machi_proxy_flu1_client_test).
|
||||||
-compile(export_all).
|
-compile(export_all).
|
||||||
|
|
||||||
|
-include("machi.hrl").
|
||||||
-include("machi_projection.hrl").
|
-include("machi_projection.hrl").
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ api_smoke_test() ->
|
||||||
TcpPort = 57124,
|
TcpPort = 57124,
|
||||||
DataDir = "./data.api_smoke_flu",
|
DataDir = "./data.api_smoke_flu",
|
||||||
W_props = [{initial_wedged, false}],
|
W_props = [{initial_wedged, false}],
|
||||||
|
Prefix = <<"prefix">>,
|
||||||
FLU1 = machi_flu1_test:setup_test_flu(RegName, TcpPort, DataDir,
|
FLU1 = machi_flu1_test:setup_test_flu(RegName, TcpPort, DataDir,
|
||||||
W_props),
|
W_props),
|
||||||
erase(flu_pid),
|
erase(flu_pid),
|
||||||
|
@ -44,15 +46,15 @@ api_smoke_test() ->
|
||||||
try
|
try
|
||||||
FakeEpoch = ?DUMMY_PV1_EPOCH,
|
FakeEpoch = ?DUMMY_PV1_EPOCH,
|
||||||
[{ok, {_,_,_}} = ?MUT:append_chunk(Prox1,
|
[{ok, {_,_,_}} = ?MUT:append_chunk(Prox1,
|
||||||
FakeEpoch, <<"prefix">>, <<"data">>,
|
FakeEpoch, Prefix, <<"data">>,
|
||||||
infinity) || _ <- lists:seq(1,5)],
|
infinity) || _ <- lists:seq(1,5)],
|
||||||
%% Stop the FLU, what happens?
|
%% Stop the FLU, what happens?
|
||||||
machi_flu1:stop(FLU1),
|
machi_flu1:stop(FLU1),
|
||||||
{error,_} = ?MUT:append_chunk(Prox1,
|
{error,_} = ?MUT:append_chunk(Prox1,
|
||||||
FakeEpoch, <<"prefix">>, <<"data">>,
|
FakeEpoch, Prefix, <<"data">>,
|
||||||
infinity),
|
infinity),
|
||||||
{error,partition} = ?MUT:append_chunk(Prox1,
|
{error,partition} = ?MUT:append_chunk(Prox1,
|
||||||
FakeEpoch, <<"prefix">>, <<"data">>,
|
FakeEpoch, Prefix, <<"data">>,
|
||||||
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,
|
||||||
|
@ -60,14 +62,20 @@ api_smoke_test() ->
|
||||||
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),
|
||||||
MyChunk2 = <<"my chunk data, yeah, again">>,
|
MyChunk2 = <<"my chunk data, yeah, again">>,
|
||||||
{ok, {MyOff2,MySize2,MyFile2}} =
|
{ok, {MyOff2,MySize2,MyFile2}} =
|
||||||
?MUT:append_chunk_extra(Prox1, FakeEpoch, <<"prefix">>,
|
?MUT:append_chunk_extra(Prox1, FakeEpoch, Prefix,
|
||||||
MyChunk2, 4242, infinity),
|
MyChunk2, 4242, infinity),
|
||||||
{ok, MyChunk2} = ?MUT:read_chunk(Prox1, FakeEpoch, MyFile2, MyOff2, MySize2),
|
{ok, MyChunk2} = ?MUT:read_chunk(Prox1, FakeEpoch, MyFile2, MyOff2, MySize2),
|
||||||
|
MyChunk_badcs = {<<?CSUM_TAG_CLIENT_GEN:8, 0:(8*20)>>, MyChunk},
|
||||||
|
{error, bad_checksum} = ?MUT:append_chunk(Prox1, FakeEpoch,
|
||||||
|
Prefix, MyChunk_badcs),
|
||||||
|
{error, bad_checksum} = ?MUT:write_chunk(Prox1, FakeEpoch,
|
||||||
|
<<"foo-file">>, 99832,
|
||||||
|
MyChunk_badcs),
|
||||||
|
|
||||||
%% 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">>,
|
||||||
|
|
Loading…
Reference in a new issue