diff --git a/.gitignore b/.gitignore index cf58051..62de294 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ c_src/system test/logs test/test.cover +int_test/logs +int_test/test.cover diff --git a/Rakefile b/Rakefile index 3254178..09f2d22 100644 --- a/Rakefile +++ b/Rakefile @@ -37,3 +37,15 @@ task :test do run_tests "test", "+A10" end +task :int_test do + run_tests "int_test", "+A10" +end + +# task :compile_perf_tests do +# do_compile_tests("perftest") +# end +# +# desc "Run performance tests" +# task :perftest => [:compile, :compile_perf_tests] do +# run_tests "perftest", "+A10" +# end diff --git a/base.rake b/base.rake index a36f24f..a3a5902 100644 --- a/base.rake +++ b/base.rake @@ -136,7 +136,7 @@ def run_tests(dir, rest = "") -noshell -s ct_run script_start -s erlang halt \ #{get_cover(dir)} \ #{get_suites(dir)} -logdir #{dir}/logs -env TEST_DIR #{PWD}/#{dir} \ - #{rest}" , :verbose => false + #{rest}"# , :verbose => false end diff --git a/int_test/DB_CONFIG b/int_test/DB_CONFIG new file mode 100644 index 0000000..d52a847 --- /dev/null +++ b/int_test/DB_CONFIG @@ -0,0 +1,5 @@ +set_flags DB_TXN_WRITE_NOSYNC +set_cachesize 0 536870912 1 +set_lg_max 104857600 +set_lg_bsize 536870912 +set_log_config DB_LOG_IN_MEMORY diff --git a/int_test/stress_SUITE.erl b/int_test/stress_SUITE.erl new file mode 100644 index 0000000..3d08c2b --- /dev/null +++ b/int_test/stress_SUITE.erl @@ -0,0 +1,92 @@ +%% ------------------------------------------------------------------- +%% +%% bdberl: Port Driver Stress tests +%% Copyright (c) 2008 The Hive. All rights reserved. +%% +%% ------------------------------------------------------------------- +-module(stress_SUITE). +-compile(export_all). +-include_lib("ct.hrl"). + +%% NOTE: all of the tests are set for a low number of iterations to guarantee +%% that they all pass and run in a reasonable amount of time. That kinda defeats +%% the purpose of the test, tho. Work is ongoing to make this a useful test suite. + +all() -> + [rewrite_array_test, + rewrite_bytes_test, + write_array_test, + write_bytes_test]. + +init_per_suite(Config) -> + {ok, Cwd} = file:get_cwd(), + {ok, _} = file:copy(lists:append([Cwd, "/../../../int_test/DB_CONFIG"]), + lists:append([Cwd, "/DB_CONFIG"])), + crypto:start(), + Config. + +end_per_suite(_Config) -> + ok. + +init_per_testcase(TestCase, Config) -> + Size = 1024 * 1024, + Chunk = crypto:rand_bytes(Size), + Name = io_lib:format("~p.db", [TestCase]), + {ok, Db} = bdberl:open(Name, hash), + [{size, Size}, {chunk, Chunk}, {db, Db}|Config]. + +end_per_testcase(_TestCase, Config) -> + bdberl:close(?config(db, Config)), + ok. + +%%--------------------------------------------------------------------------- + +rewrite_array_test(Config) -> + %% If you try to run this one for more than 2K iterations than the Erlang + %% VM will die with a memory allocation error when creating the binary. + ct:print("Running rewrite_array test for 2000 iterations..."), + Chunk = ?config(chunk, Config), + rewrite_array(?config(db, Config), Chunk, [Chunk], 20). + +rewrite_array(_Db, _Block, _Bytes, 0) -> + ok; +rewrite_array(Db, Block, Bytes, Iter) -> + bdberl:put(Db, 1, Bytes), + rewrite_array(Db, Block, [Block|Bytes], Iter - 1). + +%%--------------------------------------------------------------------------- + +rewrite_bytes_test(Config) -> + ct:print("Running rewrite_bytes test for 2500 iterations..."), + rewrite_bytes(?config(db, Config), ?config(chunk, Config), 25). + +rewrite_bytes(_Db, _Bytes, 0) -> + ok; +rewrite_bytes(Db, Bytes, Iter) -> + bdberl:put(Db, 1, Bytes), + rewrite_bytes(Db, Bytes, Iter - 1). + +%%--------------------------------------------------------------------------- + +write_array_test(Config) -> + ct:print("Running write_array test for 150 iterations..."), + Chunk = ?config(chunk, Config), + write_array(?config(db, Config), Chunk, [Chunk], 15). + +write_array(_Db, _Block, _Bytes, 0) -> + ok; +write_array(Db, Block, Bytes, Iter) -> + bdberl:put(Db, Iter, Bytes), + write_array(Db, Block, [Block|Bytes], Iter - 1). + +%%--------------------------------------------------------------------------- + +write_bytes_test(Config) -> + ct:print("Running write_bytes test for 2500 iterations..."), + write_bytes(?config(db, Config), ?config(chunk, Config), 25). + +write_bytes(_Db, _Bytes, 0) -> + ok; +write_bytes(Db, Bytes, Iter) -> + bdberl:put(Db, Iter, Bytes), + write_bytes(Db, Bytes, Iter - 1). diff --git a/test/thrash_SUITE.erl b/int_test/thrash_SUITE.erl similarity index 97% rename from test/thrash_SUITE.erl rename to int_test/thrash_SUITE.erl index 5e6b7a3..61d4b2b 100644 --- a/test/thrash_SUITE.erl +++ b/int_test/thrash_SUITE.erl @@ -47,7 +47,7 @@ thrash_run(Owner) -> thrash_incr_loop(Owner, 0) -> Owner ! {finished, self()}; thrash_incr_loop(Owner, Count) -> - ct:print("~p", [Count]), + % ct:print("~p", [Count]), %% Choose random key Key = random:uniform(1200),