From 2fd27fdae6bb5c59d375f54cfb6a338d2915bad5 Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Fri, 26 Jun 2015 23:58:34 +0900 Subject: [PATCH] WIP: hairball, but flu_projection_smoke_test() works! --- src/machi_flu1.erl | 35 +++++++-- src/machi_flu1_client.erl | 24 +++---- src/machi_pb_translate.erl | 144 ++++++++++++++++++++++++++++++++++++- src/machi_pb_wrap.erl | 125 -------------------------------- test/machi_flu1_test.erl | 30 -------- 5 files changed, 185 insertions(+), 173 deletions(-) diff --git a/src/machi_flu1.erl b/src/machi_flu1.erl index 1d335bf..29b8197 100644 --- a/src/machi_flu1.erl +++ b/src/machi_flu1.erl @@ -293,6 +293,10 @@ do_pb_request(PB_request, S) -> io:format(user, "\nSSS Req ~p\n", [Req]), {ReqID, Cmd, Result, S2} = case Req of + {RqID, {low_proj, _}=CMD} -> + %% Skip wedge check for projection commands! + {Rs, NewS} = do_pb_request3(CMD, S), + {RqID, CMD, Rs, NewS}; {RqID, CMD} -> EpochID = element(2, CMD), % by common convention {Rs, NewS} = do_pb_request2(EpochID, CMD, S), @@ -306,7 +310,7 @@ do_pb_request(PB_request, S) -> do_pb_request2(EpochID, CMD, S) -> {Wedged_p, CurrentEpochID} = ets:lookup_element(S#state.etstab, epoch, 2), if Wedged_p == true -> - {error, wedged}; + {{error, wedged}, S}; EpochID /= undefined andalso EpochID /= CurrentEpochID -> {Epoch, _} = EpochID, {CurrentEpoch, _} = CurrentEpochID, @@ -318,7 +322,7 @@ do_pb_request2(EpochID, CMD, S) -> io:format(user, "\n\nTODO: wedge myself!\n\n", []), todo_wedge_myself end, - {error, bad_epoch}; + {{error, bad_epoch}, S}; true -> do_pb_request3(CMD, S) end. @@ -343,7 +347,28 @@ do_pb_request3({low_wedge_status, _EpochID}, S) -> do_pb_request3({low_delete_migration, _EpochID, File}, S) -> {do_pb_server_delete_migration(File, S), S}; do_pb_request3({low_trunc_hack, _EpochID, File}, S) -> - {do_pb_server_trunc_hack(File, S), S}. + {do_pb_server_trunc_hack(File, S), S}; +do_pb_request3({low_proj, PCMD}, S) -> + {do_pb_server_proj_request(PCMD, S), S}. + +do_pb_server_proj_request({get_latest_epochid, ProjType}, + #state{proj_store=ProjStore}) -> + machi_projection_store:get_latest_epochid(ProjStore, ProjType); +do_pb_server_proj_request({read_latest_projection, ProjType}, + #state{proj_store=ProjStore}) -> + machi_projection_store:read_latest_projection(ProjStore, ProjType); +do_pb_server_proj_request({read_projection, ProjType, Epoch}, + #state{proj_store=ProjStore}) -> + machi_projection_store:read(ProjStore, ProjType, Epoch); +do_pb_server_proj_request({write_projection, ProjType, Proj}, + #state{proj_store=ProjStore}) -> + machi_projection_store:write(ProjStore, ProjType, Proj); +do_pb_server_proj_request({get_all_projections, ProjType}, + #state{proj_store=ProjStore}) -> + machi_projection_store:get_all_projections(ProjStore, ProjType); +do_pb_server_proj_request({list_all_projections, ProjType}, + #state{proj_store=ProjStore}) -> + machi_projection_store:list_all_projections(ProjStore, ProjType). do_pb_server_append_chunk(PKey, Prefix, Chunk, CSum_tag, CSum, ChunkExtra, S) -> @@ -593,8 +618,8 @@ net_server_loop_old(Sock, #state{flu_name=FluName, data_dir=DataDir}=S) -> - 8 - 8 - 1, %% FileLenLF = byte_size(Line) - 2 - ?EpochIDSpace - 16 - 8 - 1, CSumFileLenLF = byte_size(Line) - 2 - ?EpochIDSpace - 1, - WriteFileLenLF = byte_size(Line) - 7 - ?EpochIDSpace - ?CSumSpace - - 16 - 8 - 1, + %% WriteFileLenLF = byte_size(Line) - 7 - ?EpochIDSpace - ?CSumSpace + %% - 16 - 8 - 1, DelFileLenLF = byte_size(Line) - 14 - ?EpochIDSpace - 1, case Line of %% For normal use diff --git a/src/machi_flu1_client.erl b/src/machi_flu1_client.erl index ca52b71..e8985b0 100644 --- a/src/machi_flu1_client.erl +++ b/src/machi_flu1_client.erl @@ -584,38 +584,38 @@ trunc_hack2(Sock, EpochID, File) -> get_latest_epochid2(Sock, ProjType) -> ReqID = <<42>>, - Req = machi_pb_wrap:make_projection_req( - ReqID, {get_latest_epochid, ProjType}), + Req = machi_pb_translate:to_pb_request( + ReqID, {low_proj, {get_latest_epochid, ProjType}}), do_pb_request_common(Sock, ReqID, Req). read_latest_projection2(Sock, ProjType) -> ReqID = <<42>>, - Req = machi_pb_wrap:make_projection_req( - ReqID, {read_latest_projection, ProjType}), + Req = machi_pb_translate:to_pb_request( + ReqID, {low_proj, {read_latest_projection, ProjType}}), do_pb_request_common(Sock, ReqID, Req). read_projection2(Sock, ProjType, Epoch) -> ReqID = <<42>>, - Req = machi_pb_wrap:make_projection_req( - ReqID, {read_projection, ProjType, Epoch}), + Req = machi_pb_translate:to_pb_request( + ReqID, {low_proj, {read_projection, ProjType, Epoch}}), do_pb_request_common(Sock, ReqID, Req). write_projection2(Sock, ProjType, Proj) -> ReqID = <<42>>, - Req = machi_pb_wrap:make_projection_req( - ReqID, {write_projection, ProjType, Proj}), + Req = machi_pb_translate:to_pb_request( + ReqID, {low_proj, {write_projection, ProjType, Proj}}), do_pb_request_common(Sock, ReqID, Req). get_all_projections2(Sock, ProjType) -> ReqID = <<42>>, - Req = machi_pb_wrap:make_projection_req( - ReqID, {get_all_projections, ProjType}), + Req = machi_pb_translate:to_pb_request( + ReqID, {low_proj, {get_all_projections, ProjType}}), do_pb_request_common(Sock, ReqID, Req). list_all_projections2(Sock, ProjType) -> ReqID = <<42>>, - Req = machi_pb_wrap:make_projection_req( - ReqID, {list_all_projections, ProjType}), + Req = machi_pb_translate:to_pb_request( + ReqID, {low_proj, {list_all_projections, ProjType}}), do_pb_request_common(Sock, ReqID, Req). do_pb_request_common(Sock, ReqID, Req) -> diff --git a/src/machi_pb_translate.erl b/src/machi_pb_translate.erl index dc5b331..acb8856 100644 --- a/src/machi_pb_translate.erl +++ b/src/machi_pb_translate.erl @@ -108,6 +108,33 @@ from_pb_request(#mpb_ll_request{ file=File}}) -> EpochID = conv_to_epoch_id(PB_EpochID), {ReqID, {low_trunc_hack, EpochID, File}}; +from_pb_request(#mpb_ll_request{ + req_id=ReqID, + proj_gl=#mpb_ll_getlatestepochidreq{type=ProjType}}) -> + {ReqID, {low_proj, {get_latest_epochid, conv_to_type(ProjType)}}}; +from_pb_request(#mpb_ll_request{ + req_id=ReqID, + proj_rl=#mpb_ll_readlatestprojectionreq{type=ProjType}}) -> + {ReqID, {low_proj, {read_latest_projection, conv_to_type(ProjType)}}}; +from_pb_request(#mpb_ll_request{ + req_id=ReqID, + proj_rp=#mpb_ll_readprojectionreq{type=ProjType, + epoch_number=Epoch}}) -> + {ReqID, {low_proj, {read_projection, conv_to_type(ProjType), Epoch}}}; +from_pb_request(#mpb_ll_request{ + req_id=ReqID, + proj_wp=#mpb_ll_writeprojectionreq{type=ProjType, + proj=ProjM}}) -> + Proj = conv_to_projection_v1(ProjM), + {ReqID, {low_proj, {write_projection, conv_to_type(ProjType), Proj}}}; +from_pb_request(#mpb_ll_request{ + req_id=ReqID, + proj_ga=#mpb_ll_getallprojectionsreq{type=ProjType}}) -> + {ReqID, {low_proj, {get_all_projections, conv_to_type(ProjType)}}}; +from_pb_request(#mpb_ll_request{ + req_id=ReqID, + proj_la=#mpb_ll_listallprojectionsreq{type=ProjType}}) -> + {ReqID, {low_proj, {list_all_projections, conv_to_type(ProjType)}}}; %%qqq from_pb_request(#mpb_request{req_id=ReqID, echo=#mpb_echoreq{message=Msg}}) -> @@ -355,7 +382,28 @@ to_pb_request(ReqID, {low_trunc_hack, EpochID, File}) -> #mpb_ll_request{req_id=ReqID, trunc_hack=#mpb_ll_trunchackreq{ epoch_id=PB_EpochID, - file=File}}. + file=File}}; +to_pb_request(ReqID, {low_proj, {get_latest_epochid, ProjType}}) -> + #mpb_ll_request{req_id=ReqID, + proj_gl=#mpb_ll_getlatestepochidreq{type=conv_from_type(ProjType)}}; +to_pb_request(ReqID, {low_proj, {read_latest_projection, ProjType}}) -> + #mpb_ll_request{req_id=ReqID, + proj_rl=#mpb_ll_readlatestprojectionreq{type=conv_from_type(ProjType)}}; +to_pb_request(ReqID, {low_proj, {read_projection, ProjType, Epoch}}) -> + #mpb_ll_request{req_id=ReqID, + proj_rp=#mpb_ll_readprojectionreq{type=conv_from_type(ProjType), + epoch_number=Epoch}}; +to_pb_request(ReqID, {low_proj, {write_projection, ProjType, Proj}}) -> + ProjM = conv_from_projection_v1(Proj), + #mpb_ll_request{req_id=ReqID, + proj_wp=#mpb_ll_writeprojectionreq{type=conv_from_type(ProjType), + proj=ProjM}}; +to_pb_request(ReqID, {low_proj, {get_all_projections, ProjType}}) -> + #mpb_ll_request{req_id=ReqID, + proj_ga=#mpb_ll_getallprojectionsreq{type=conv_from_type(ProjType)}}; +to_pb_request(ReqID, {low_proj, {list_all_projections, ProjType}}) -> + #mpb_ll_request{req_id=ReqID, + proj_la=#mpb_ll_listallprojectionsreq{type=conv_from_type(ProjType)}}. %%qqq to_pb_response(ReqID, {low_echo, _BogusEpochID, _Msg}, Resp) -> @@ -444,6 +492,71 @@ to_pb_response(ReqID, {low_trunc_hack, _EID, _Fl}, Resp)-> Status = conv_from_status(Resp), #mpb_ll_response{req_id=ReqID, trunc_hack=#mpb_ll_trunchackresp{status=Status}}; +to_pb_response(ReqID, {low_proj, {get_latest_epochid, _ProjType}}, Resp)-> + case Resp of + {ok, {Epoch, CSum}} -> + EID = #mpb_epochid{epoch_number=Epoch, epoch_csum=CSum}, + #mpb_ll_response{req_id=ReqID, + proj_gl=#mpb_ll_getlatestepochidresp{ + status='OK', epoch_id=EID}}; + {error, _}=Error -> + Status = conv_from_status(Error), + #mpb_ll_response{req_id=ReqID, + proj_gl=#mpb_ll_getlatestepochidresp{status=Status}} + end; +to_pb_response(ReqID, {low_proj, {read_latest_projection, _ProjType}}, Resp) -> + case Resp of + {ok, Proj} -> + ProjM = conv_from_projection_v1(Proj), + #mpb_ll_response{req_id=ReqID, + proj_rl=#mpb_ll_readlatestprojectionresp{ + status='OK', proj=ProjM}}; + {error, _}=Error -> + Status = conv_from_status(Error), + #mpb_ll_response{req_id=ReqID, + proj_rl=#mpb_ll_readlatestprojectionresp{status=Status}} + end; +to_pb_response(ReqID, {low_proj, {read_projection, _ProjType, _Epoch}}, Resp)-> + case Resp of + {ok, Proj} -> + ProjM = conv_from_projection_v1(Proj), + #mpb_ll_response{req_id=ReqID, + proj_rp=#mpb_ll_readprojectionresp{ + status='OK', proj=ProjM}}; + {error, _}=Error -> + Status = conv_from_status(Error), + #mpb_ll_response{req_id=ReqID, + proj_rp=#mpb_ll_readprojectionresp{status=Status}} + end; +to_pb_response(ReqID, {low_proj, {write_projection, _ProjType, _Proj}}, Resp) -> + Status = conv_from_status(Resp), + #mpb_ll_response{req_id=ReqID, + proj_wp=#mpb_ll_writeprojectionresp{status=Status}}; +to_pb_response(ReqID, {low_proj, {get_all_projections, _ProjType}}, Resp)-> + case Resp of + {ok, Projs} -> + ProjsM = [conv_from_projection_v1(Proj) || Proj <- Projs], + #mpb_ll_response{req_id=ReqID, + proj_ga=#mpb_ll_getallprojectionsresp{ + status='OK', projs=ProjsM}}; + {error, _}=Error -> + Status = conv_from_status(Error), + #mpb_ll_response{req_id=ReqID, + proj_ga=#mpb_ll_getallprojectionsresp{ + status=Status}} + end; +to_pb_response(ReqID, {low_proj, {list_all_projections, _ProjType}}, Resp)-> + case Resp of + {ok, Epochs} -> + #mpb_ll_response{req_id=ReqID, + proj_la=#mpb_ll_listallprojectionsresp{ + status='OK', epochs=Epochs}}; + {error, _}=Error -> + Status = conv_from_status(Error), + #mpb_ll_response{req_id=ReqID, + proj_la=#mpb_ll_listallprojectionsresp{ + status=Status}} + end; %%qqq to_pb_response(ReqID, {high_echo, _Msg}, Resp) -> Msg = Resp, @@ -717,3 +830,32 @@ conv_from_boolean(false) -> 0; conv_from_boolean(true) -> 1. + +conv_from_projection_v1(#projection_v1{epoch_number=Epoch, + epoch_csum=CSum, + author_server=Author, + all_members=AllMembers, + creation_time=CTime, + mode=Mode, + upi=UPI, + repairing=Repairing, + down=Down, + flap=Flap, + inner=Inner, + dbg=Dbg, + dbg2=Dbg2, + members_dict=MembersDict}) -> + #mpb_projectionv1{epoch_number=Epoch, + epoch_csum=CSum, + author_server=to_list(Author), + all_members=[to_list(X) || X <- AllMembers], + creation_time=conv_from_now(CTime), + mode=conv_from_mode(Mode), + upi=[to_list(X) || X <- UPI], + repairing=[to_list(X) || X <- Repairing], + down=[to_list(X) || X <- Down], + opaque_flap=enc_optional_sexp(Flap), + opaque_inner=enc_optional_sexp(Inner), + opaque_dbg=enc_sexp(Dbg), + opaque_dbg2=enc_sexp(Dbg2), + members_dict=conv_from_members_dict(MembersDict)}. diff --git a/src/machi_pb_wrap.erl b/src/machi_pb_wrap.erl index 13e5653..8bfaf0e 100644 --- a/src/machi_pb_wrap.erl +++ b/src/machi_pb_wrap.erl @@ -80,133 +80,8 @@ dec_projection_v1(Bin) -> delme. %% conv_to_projection_v1(machi_pb:decode_mpb_projectionv1(Bin)). -conv_from_projection_v1(#projection_v1{epoch_number=Epoch, - epoch_csum=CSum, - author_server=Author, - all_members=AllMembers, - creation_time=CTime, - mode=Mode, - upi=UPI, - repairing=Repairing, - down=Down, - flap=Flap, - inner=Inner, - dbg=Dbg, - dbg2=Dbg2, - members_dict=MembersDict}) -> - #mpb_projectionv1{epoch_number=Epoch, - epoch_csum=CSum, - author_server=to_list(Author), - all_members=[to_list(X) || X <- AllMembers], - creation_time=conv_from_now(CTime), - mode=conv_from_mode(Mode), - upi=[to_list(X) || X <- UPI], - repairing=[to_list(X) || X <- Repairing], - down=[to_list(X) || X <- Down], - opaque_flap=enc_optional_sexp(Flap), - opaque_inner=enc_optional_sexp(Inner), - opaque_dbg=enc_sexp(Dbg), - opaque_dbg2=enc_sexp(Dbg2), - members_dict=conv_from_members_dict(MembersDict)}. -make_projection_req(ID, {get_latest_epochid, ProjType}) -> - #mpb_ll_request{req_id=ID, - proj_gl=#mpb_ll_getlatestepochidreq{type=conv_from_type(ProjType)}}; -make_projection_req(ID, {read_latest_projection, ProjType}) -> - #mpb_ll_request{req_id=ID, - proj_rl=#mpb_ll_readlatestprojectionreq{type=conv_from_type(ProjType)}}; -make_projection_req(ID, {read_projection, ProjType, Epoch}) -> - #mpb_ll_request{req_id=ID, - proj_rp=#mpb_ll_readprojectionreq{type=conv_from_type(ProjType), - epoch_number=Epoch}}; -make_projection_req(ID, {write_projection, ProjType, Proj}) -> - ProjM = conv_from_projection_v1(Proj), - #mpb_ll_request{req_id=ID, - proj_wp=#mpb_ll_writeprojectionreq{type=conv_from_type(ProjType), - proj=ProjM}}; -make_projection_req(ID, {get_all_projections, ProjType}) -> - #mpb_ll_request{req_id=ID, - proj_ga=#mpb_ll_getallprojectionsreq{type=conv_from_type(ProjType)}}; -make_projection_req(ID, {list_all_projections, ProjType}) -> - #mpb_ll_request{req_id=ID, - proj_la=#mpb_ll_listallprojectionsreq{type=conv_from_type(ProjType)}}. -unmake_projection_req( - #mpb_ll_request{req_id=ID, - proj_gl=#mpb_ll_getlatestepochidreq{type=ProjType}}) -> - {ID, {get_latest_epochid, conv_to_type(ProjType)}}; -unmake_projection_req( - #mpb_ll_request{req_id=ID, - proj_rl=#mpb_ll_readlatestprojectionreq{type=ProjType}}) -> - {ID, {read_latest_projection, conv_to_type(ProjType)}}; -unmake_projection_req( - #mpb_ll_request{req_id=ID, - proj_rp=#mpb_ll_readprojectionreq{type=ProjType, - epoch_number=Epoch}}) -> - {ID, {read_projection, conv_to_type(ProjType), Epoch}}; -unmake_projection_req( - #mpb_ll_request{req_id=ID, - proj_wp=#mpb_ll_writeprojectionreq{type=ProjType, - proj=ProjM}}) -> - Proj = delme, %% conv_to_projection_v1(ProjM), - {ID, {write_projection, conv_to_type(ProjType), Proj}}; -unmake_projection_req( - #mpb_ll_request{req_id=ID, - proj_ga=#mpb_ll_getallprojectionsreq{type=ProjType}}) -> - {ID, {get_all_projections, conv_to_type(ProjType)}}; -unmake_projection_req( - #mpb_ll_request{req_id=ID, - proj_la=#mpb_ll_listallprojectionsreq{type=ProjType}}) -> - {ID, {list_all_projections, conv_to_type(ProjType)}}. - -make_projection_resp(ID, get_latest_epochid, {ok, {Epoch, CSum}}) -> - EID = #mpb_epochid{epoch_number=Epoch, epoch_csum=CSum}, - #mpb_ll_response{req_id=ID, - proj_gl=#mpb_ll_getlatestepochidresp{ - status='OK', epoch_id=EID}}; -make_projection_resp(ID, get_latest_epochid, Status) -> - #mpb_ll_response{req_id=ID, - proj_gl=#mpb_ll_getlatestepochidresp{ - status=conv_from_status(Status)}}; -make_projection_resp(ID, read_latest_projection, {ok, Proj}) -> - ProjM = conv_from_projection_v1(Proj), - #mpb_ll_response{req_id=ID, - proj_rl=#mpb_ll_readlatestprojectionresp{ - status='OK', proj=ProjM}}; -make_projection_resp(ID, read_latest_projection, Status) -> - #mpb_ll_response{req_id=ID, - proj_rl=#mpb_ll_readlatestprojectionresp{ - status=conv_from_status(Status)}}; -make_projection_resp(ID, read_projection, {ok, Proj}) -> - ProjM = conv_from_projection_v1(Proj), - #mpb_ll_response{req_id=ID, - proj_rp=#mpb_ll_readprojectionresp{ - status='OK', proj=ProjM}}; -make_projection_resp(ID, read_projection, Status) -> - #mpb_ll_response{req_id=ID, - proj_rp=#mpb_ll_readprojectionresp{ - status=conv_from_status(Status)}}; -make_projection_resp(ID, write_projection, Status) -> - #mpb_ll_response{req_id=ID, - proj_wp=#mpb_ll_writeprojectionresp{ - status=conv_from_status(Status)}}; -make_projection_resp(ID, get_all_projections, {ok, Projs}) -> - ProjsM = [conv_from_projection_v1(Proj) || Proj <- Projs], - #mpb_ll_response{req_id=ID, - proj_ga=#mpb_ll_getallprojectionsresp{ - status='OK', projs=ProjsM}}; -make_projection_resp(ID, get_all_projections, Status) -> - #mpb_ll_response{req_id=ID, - proj_ga=#mpb_ll_getallprojectionsresp{ - status=conv_from_status(Status)}}; -make_projection_resp(ID, list_all_projections, {ok, Epochs}) -> - #mpb_ll_response{req_id=ID, - proj_la=#mpb_ll_listallprojectionsresp{ - status='OK', epochs=Epochs}}; -make_projection_resp(ID, list_all_projections, Status) -> - #mpb_ll_response{req_id=ID, - proj_la=#mpb_ll_listallprojectionsresp{ - status=conv_from_status(Status)}}. %%%%%%%%%%%%%%%%%%% diff --git a/test/machi_flu1_test.erl b/test/machi_flu1_test.erl index 76d0f25..0a343cf 100644 --- a/test/machi_flu1_test.erl +++ b/test/machi_flu1_test.erl @@ -72,64 +72,48 @@ flu_smoke_test() -> try Msg = "Hello, world!", Msg = ?FLU_C:echo(Host, TcpPort, Msg), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, no_such_file} = ?FLU_C:checksum_list(Host, TcpPort, ?DUMMY_PV1_EPOCH, "does-not-exist"), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, bad_arg} = ?FLU_C:checksum_list(Host, TcpPort, ?DUMMY_PV1_EPOCH, BadFile), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {ok, []} = ?FLU_C:list_files(Host, TcpPort, ?DUMMY_PV1_EPOCH), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {ok, {false, _}} = ?FLU_C:wedge_status(Host, TcpPort), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), Chunk1 = <<"yo!">>, -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {ok, {Off1,Len1,File1}} = ?FLU_C:append_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, Prefix, Chunk1), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {ok, Chunk1} = ?FLU_C:read_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, File1, Off1, Len1), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), %% TODO: when checksum_list() is refactored, restore this test! %% {ok, [{_,_,_}]} = ?FLU_C:checksum_list(Host, TcpPort, %% ?DUMMY_PV1_EPOCH, File1), {ok, _} = ?FLU_C:checksum_list(Host, TcpPort, ?DUMMY_PV1_EPOCH, File1), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, bad_arg} = ?FLU_C:append_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, BadPrefix, Chunk1), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {ok, [{_,File1}]} = ?FLU_C:list_files(Host, TcpPort, ?DUMMY_PV1_EPOCH), Len1 = size(Chunk1), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, not_written} = ?FLU_C:read_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, File1, Off1*983829323, Len1), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, partial_read} = ?FLU_C:read_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, File1, Off1, Len1*9999), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {ok, {Off1b,Len1b,File1b}} = ?FLU_C:append_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, Prefix, Chunk1), Extra = 42, -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {ok, {Off1c,Len1c,File1c}} = ?FLU_C:append_chunk_extra(Host, TcpPort, ?DUMMY_PV1_EPOCH, Prefix, Chunk1, Extra), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {ok, {Off1d,Len1d,File1d}} = ?FLU_C:append_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, Prefix, Chunk1), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), if File1b == File1c, File1c == File1d -> true = (Off1c == Off1b + Len1b), true = (Off1d == Off1c + Len1c + Extra); @@ -138,56 +122,42 @@ io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), end, Chunk1_cs = {<>, Chunk1}, -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {ok, {Off1e,Len1e,File1e}} = ?FLU_C:append_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, Prefix, Chunk1_cs), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), Chunk2 = <<"yo yo">>, Len2 = byte_size(Chunk2), Off2 = ?MINIMUM_OFFSET + 77, File2 = "smoke-whole-file", -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), ok = ?FLU_C:write_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, File2, Off2, Chunk2), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, bad_arg} = ?FLU_C:write_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, BadFile, Off2, Chunk2), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {ok, Chunk2} = ?FLU_C:read_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, File2, Off2, Len2), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, not_written} = ?FLU_C:read_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, "no!!", Off2, Len2), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, bad_arg} = ?FLU_C:read_chunk(Host, TcpPort, ?DUMMY_PV1_EPOCH, BadFile, Off2, Len2), %% We know that File1 still exists. Pretend that we've done a %% migration and exercise the delete_migration() API. -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), ok = ?FLU_C:delete_migration(Host, TcpPort, ?DUMMY_PV1_EPOCH, File1), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, no_such_file} = ?FLU_C:delete_migration(Host, TcpPort, ?DUMMY_PV1_EPOCH, File1), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, bad_arg} = ?FLU_C:delete_migration(Host, TcpPort, ?DUMMY_PV1_EPOCH, BadFile), %% We know that File2 still exists. Pretend that we've done a %% migration and exercise the trunc_hack() API. -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), ok = ?FLU_C:trunc_hack(Host, TcpPort, ?DUMMY_PV1_EPOCH, File2), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), ok = ?FLU_C:trunc_hack(Host, TcpPort, ?DUMMY_PV1_EPOCH, File2), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), {error, bad_arg} = ?FLU_C:trunc_hack(Host, TcpPort, ?DUMMY_PV1_EPOCH, BadFile), -io:format(user, "LINE ~s ~p\n", [?MODULE, ?LINE]), ok = ?FLU_C:quit(?FLU_C:connect(#p_srvr{address=Host, port=TcpPort})) after