Move to private proj store for eunit tests

This commit is contained in:
Scott Lystig Fritchie 2014-10-27 17:17:07 +09:00
parent ddce145bfb
commit e9ea20e941
2 changed files with 9 additions and 5 deletions

View file

@ -118,6 +118,8 @@ make_proj(Epoch, FLUs) ->
init([Name]) -> init([Name]) ->
lclock_init(), lclock_init(),
[(catch exit(whereis(Name), kill)) || _ <- lists:seq(1,2)],
erlang:yield(),
{ok, #state{name=Name, {ok, #state{name=Name,
proj_epoch=-42, proj_epoch=-42,
proj_store_pub=orddict:new(), proj_store_pub=orddict:new(),
@ -218,7 +220,9 @@ do_proj_write(Epoch, StoreType, Proj, #state{proj_epoch=MyEpoch,
case orddict:find(Epoch, D) of case orddict:find(Epoch, D) of
error -> error ->
D2 = orddict:store(Epoch, Proj, D), D2 = orddict:store(Epoch, Proj, D),
{NewEpoch, NewWedged} = if Epoch > MyEpoch -> {NewEpoch, NewWedged} = if StoreType == public ->
{MyEpoch, MyWedged};
Epoch > MyEpoch ->
{Epoch, false}; {Epoch, false};
true -> true ->
{MyEpoch, MyWedged} {MyEpoch, MyWedged}

View file

@ -207,7 +207,7 @@ m_stop(Pid) ->
Res. Res.
m_proj_write(Pid, Epoch, Proj) -> m_proj_write(Pid, Epoch, Proj) ->
Res = machi_flu0:proj_write(Pid, Epoch, public, Proj), Res = machi_flu0:proj_write(Pid, Epoch, private, Proj),
event_add(proj_write, Pid, Res), event_add(proj_write, Pid, Res),
Res. Res.
@ -227,17 +227,17 @@ m_proj_write_with_check(Pid, Epoch, Proj) ->
end. end.
m_proj_read(Pid, Epoch) -> m_proj_read(Pid, Epoch) ->
Res = machi_flu0:proj_read(Pid, Epoch, public), Res = machi_flu0:proj_read(Pid, Epoch, private),
event_add(proj_read, Pid, Res), event_add(proj_read, Pid, Res),
Res. Res.
m_proj_get_latest_num(Pid) -> m_proj_get_latest_num(Pid) ->
Res = machi_flu0:proj_get_latest_num(Pid, public), Res = machi_flu0:proj_get_latest_num(Pid, private),
event_add(proj_get_latest_num, Pid, Res), event_add(proj_get_latest_num, Pid, Res),
Res. Res.
m_proj_read_latest(Pid) -> m_proj_read_latest(Pid) ->
Res = machi_flu0:proj_read_latest(Pid, public), Res = machi_flu0:proj_read_latest(Pid, private),
event_add(proj_read_latest, Pid, Res), event_add(proj_read_latest, Pid, Res),
Res. Res.