Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eqc trim tests to machi_file_proxy #35

Merged
merged 6 commits into from
Nov 5, 2015
Merged

Conversation

kuenishi
Copy link
Contributor

QuickCheck took me to the maze of my code.

@kuenishi kuenishi force-pushed the ku/making-file-proxy-spec branch 2 times, most recently from 9b02096 to b45dba9 Compare November 2, 2015 03:59
@kuenishi kuenishi changed the title [WIP] Rethinking spec of file proxy with new read and trim Add eqc trim tests to machi_file_proxy Nov 2, 2015
@@ -58,68 +58,110 @@
count=0 :: non_neg_integer()
}).

%% @doc official error types that is specific in Machi
-type error_atoms() :: bad_arg | wedged | bad_checksum |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems some built-in types are defined in singular, e.g. atom(), term(), boolean(). Which is better...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think singular is better, too.

@shino
Copy link
Contributor

shino commented Nov 4, 2015

csum_table:all_trimmed/3 says

all_trimmed(#machi_csum_table{table=T}, Left, Right) ->

(I guess Left and Right here are both offset (instead of length) only from the variable names)...

And then, file_proxy:handle_call({trim, ...) calls it as

case machi_csum_table:all_trimmed(CsumTable, Offset, Size) of

trim_args(S) ->
%% {Offset, Length} = hd(S#state.planned_trims),
%% [S#state.pid, Offset, Length].
[S#state.pid, offset(), len()].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

offset() returns small positive integers which probably inside 1024-byte header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in f560372.

* Add description on high client APIs
* Add notes to rethink high client specification
@shino
Copy link
Contributor

shino commented Nov 4, 2015

Making testing time to 600 sec, following errors happened.

** Reason for termination ==
** too_many_errors
...
=ERROR REPORT==== 4-Nov-2015::17:12:11 ===
** Too many db tables **

(x10).....(x1)........machi_file_proxy_eqc:41: eqc_test_...*failed*
in function eqc:quickcheck/1 (../src/eqc.erl, line 1276)
in call from machi_file_proxy_eqc:'-eqc_test_/0-fun-1-'/1 (test/machi_file_proxy_eqc.erl, line 41)
**exit:{system_limit,[{ets,new,[machi_csum_table,[private,ordered_set]],[]},

@shino
Copy link
Contributor

shino commented Nov 4, 2015

Changed a parameter to make more contention between planned_writes
and planned_trims as [1]

Then got an error (longer version [2]):

Sequential prefix:

   machi_file_proxy_eqc:start(#state{
     pid = undefined,
     prev_extra = 0,
     planned_writes = [{1025, 4}, {1029, 1}],
     planned_trims = [{1030, 1}],
     written = [{0, 1024}],
     trimmed = []}) ->
       <0.1338.0>
   machi_file_proxy_eqc:write(<0.1338.0>, 1025, {<<0, 0, 0, 0>>, 0, <<>>}) -> ok
   machi_file_proxy_eqc:append(<0.1338.0>, 0,
       {<<0, 0, 0, [snip] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>,
    0, <<>>}) ->
       {ok, "eqc_data7130.627044", 1029}
   machi_file_proxy_eqc:trim(<0.1338.0>, 1030, 1) -> ok
   machi_file_proxy_eqc:write(<0.1338.0>, 1029, {<<0>>, 0, <<>>}) -> {error, written}


Reason:
  Post-condition failed:
  {error, written} /= ok
machi_file_proxy_eqc:40: eqc_test_...*failed*
in function machi_file_proxy_eqc:'-eqc_test_/0-fun-1-'/1 (test/machi_file_proxy_eqc.erl, line 40)
**error:{assertEqual_failed,[{module,machi_file_proxy_eqc},
                     {line,40},
                     {expression,"eqc : quickcheck ( eqc : testing_time ( 15 , ? QC_OUT ( prop_ok ( ) ) ) )"},
                     {expected,true},
                     {value,false}]}

[1] https://gist.github.com/shino/7e77c2fac3af4e3a7c85
[2] https://gist.github.com/shino/ef91a984c5582d09f963

@kuenishi
Copy link
Contributor Author

kuenishi commented Nov 4, 2015

It looks file_proxy is behaving correctly. I think the verification is wrong.

@shino
Copy link
Contributor

shino commented Nov 4, 2015

Self comment to the above diff. It uses shorter intervals and makes each intervals filled. It will be useful to generate overlapped planned_writes and planned_trims but, downside is it does not have wide variety.

@jadeallenx
Copy link
Contributor

I think @kuenishi is right - the proxy is behaving correctly and the eqc test is not validating this case properly.

@kuenishi
Copy link
Contributor Author

kuenishi commented Nov 5, 2015

file_proxy returns {error, written} when a client tried to write to a written chunk (same size and offset, regardless of bytes and checksum), but write_ok believes it's okay if size and offset are exactly same as already written chunk.

%% as a special case if we get a call to write the EXACT
%% same data that's already on the disk, we return "ok"
%% instead of {error, written}.
mostly_true -> probably_error(Res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably_error/1 is not used.

@shino
Copy link
Contributor

shino commented Nov 5, 2015

Test passed for several runs, diff looks nice 👍
Feel free to merge after one tiny comment above ⛳

@shino
Copy link
Contributor

shino commented Nov 5, 2015

Comments outside of this RP, just for future note, not mandatory for this PR to be merged.

kuenishi added a commit that referenced this pull request Nov 5, 2015
Add eqc trim tests to machi_file_proxy
@kuenishi kuenishi merged commit 6786820 into master Nov 5, 2015
@kuenishi kuenishi deleted the ku/making-file-proxy-spec branch November 5, 2015 07:27
@jadeallenx jadeallenx mentioned this pull request Nov 5, 2015
@slfritchie
Copy link
Contributor

@shino "Are filenames in PB high clients string()?" I would like to keep file names as binary() in all code except the PB interface.

@shino
Copy link
Contributor

shino commented Nov 7, 2015

@slfritchie May I ask you a question, why use different types?

@slfritchie
Copy link
Contributor

Hrm, well, all of the library code is assuming a binary(). But the PB definition file uses "string", which the PB compiler converts to & from list()/string(). Since our conversation a week (?) or so ago in the office about valid char types for filenames, using a bytes type in the PB definition feels to me to be too big

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants