Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 50 lines (43 sloc) 1.888 kb
83dc399 @rzezeski reinstate rest of tests
rzezeski authored
1 -module(luwak_put_stream_tests).
2
0314547 @kellymclaughlin Refactor luwak tests to group the tests into test suites to avoid
kellymclaughlin authored
3 -ifdef(TEST).
4
83dc399 @rzezeski reinstate rest of tests
rzezeski authored
5 -include_lib("eunit/include/eunit.hrl").
6
0314547 @kellymclaughlin Refactor luwak tests to group the tests into test suites to avoid
kellymclaughlin authored
7 put_stream_test_() ->
8 {spawn,
9 [{setup,
10 fun test_helper:setup/0,
11 fun test_helper:cleanup/1,
12 [
13 {timeout, 60000,
14 [fun aligned_put_stream/0,
15 fun unaligned_put_stream/0]}
16 ]
17 }
18 ]
19 }.
20
21 aligned_put_stream() ->
83dc399 @rzezeski reinstate rest of tests
rzezeski authored
22 test_helper:riak_test(fun(Riak) ->
23 {ok, File} = luwak_file:create(Riak, <<"file1">>, [{block_size,3},{tree_order,3}], dict:new()),
24 PutStream = luwak_put_stream:start(Riak, File, 0, 1000),
58654cc @beerriot sanitize test data
beerriot authored
25 Input = [<<"abc">>, <<"def">>, <<"ghi">>, <<"jkl">>, <<"mno">>],
83dc399 @rzezeski reinstate rest of tests
rzezeski authored
26 lists:foreach(fun(B) -> luwak_put_stream:send(PutStream, B) end, Input),
27 luwak_put_stream:close(PutStream),
28 {ok, File2} = luwak_put_stream:status(PutStream, 1000),
29 Blocks = luwak_io:get_range(Riak, File2, 0, 15),
58654cc @beerriot sanitize test data
beerriot authored
30 ?assertEqual(<<"abcdefghijklmno">>, iolist_to_binary(Blocks))
83dc399 @rzezeski reinstate rest of tests
rzezeski authored
31 end).
32
0314547 @kellymclaughlin Refactor luwak tests to group the tests into test suites to avoid
kellymclaughlin authored
33 unaligned_put_stream() ->
83dc399 @rzezeski reinstate rest of tests
rzezeski authored
34 test_helper:riak_test(fun(Riak) ->
35 {ok, File} = luwak_file:create(Riak, <<"file1">>, [{block_size,3},{tree_order,3}], dict:new()),
58654cc @beerriot sanitize test data
beerriot authored
36 {ok, _, File1} = luwak_io:put_range(Riak, File, 0, <<"abcdefghijklmno">>),
83dc399 @rzezeski reinstate rest of tests
rzezeski authored
37 ok = file:write_file("tree8.dot", luwak_tree:visualize_tree(Riak, luwak_file:get_property(File1, root))),
38 PutStream = luwak_put_stream:start(Riak, File1, 4, 1000),
58654cc @beerriot sanitize test data
beerriot authored
39 Input = [<<"zyx">>, <<"wvu">>, <<"t">>],
83dc399 @rzezeski reinstate rest of tests
rzezeski authored
40 lists:foreach(fun(B) -> luwak_put_stream:send(PutStream, B) end, Input),
41 luwak_put_stream:close(PutStream),
42 {ok, File2} = luwak_put_stream:status(PutStream, 1000),
43 ok = file:write_file("tree9.dot", luwak_tree:visualize_tree(Riak, luwak_file:get_property(File2, root))),
44 Blocks = luwak_io:get_range(Riak, File2, 0, 15),
45 timer:sleep(100),
58654cc @beerriot sanitize test data
beerriot authored
46 ?assertEqual(<<"abcdzyxwvutlmno">>, iolist_to_binary(Blocks))
83dc399 @rzezeski reinstate rest of tests
rzezeski authored
47 end).
0314547 @kellymclaughlin Refactor luwak tests to group the tests into test suites to avoid
kellymclaughlin authored
48
49 -endif.
Something went wrong with that request. Please try again.