diff options
Diffstat (limited to 'lib/mnesia/test')
24 files changed, 728 insertions, 182 deletions
diff --git a/lib/mnesia/test/ext_test.erl b/lib/mnesia/test/ext_test.erl index 3d1cc40c09..ad32245a11 100644 --- a/lib/mnesia/test/ext_test.erl +++ b/lib/mnesia/test/ext_test.erl @@ -233,5 +233,5 @@ select_1({Acc, C}) -> select(ext_ets, Tab, Ms, Limit) when is_integer(Limit); Limit =:= infinity -> ets:select(mnesia_lib:val({?MODULE,Tab}), Ms, Limit). -repair_continuation({Alias, Cont}, Ms) -> - {Alias, ets:repair_continuation(Cont, Ms)}. +repair_continuation(Cont, Ms) -> + ets:repair_continuation(Cont, Ms). diff --git a/lib/mnesia/test/mnesia_SUITE.erl b/lib/mnesia/test/mnesia_SUITE.erl index 3ec4847c5d..24c1def6da 100644 --- a/lib/mnesia/test/mnesia_SUITE.erl +++ b/lib/mnesia/test/mnesia_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2016. All Rights Reserved. +%% Copyright Ericsson AB 1997-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,12 @@ %% -module(mnesia_SUITE). -author('[email protected]'). --compile([export_all]). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_suite/1, end_per_suite/1, + init_per_group/2, end_per_group/2, + suite/0, all/0, groups/0]). +-export([app/1, appup/1, clean_up_suite/1, silly/0]). + -include_lib("common_test/include/ct.hrl"). -include("mnesia_test_lib.hrl"). @@ -92,16 +97,8 @@ groups() -> %% benchmarks {heavy, [], [{group, measure}]}, {measure, [], [{mnesia_measure_test, all}]}, - {prediction, [], - [{group, mnesia_measure_test, prediction}]}, - {fairness, [], - [{group, mnesia_measure_test, fairness}]}, {benchmarks, [], [{group, mnesia_measure_test, benchmarks}]}, - {consumption, [], - [{group, mnesia_measure_test, consumption}]}, - {scalability, [], - [{group, mnesia_measure_test, scalability}]}, %% This test suite is an extract of the grand Mnesia suite %% it contains OTP R4B specific test cases {otp_r4b, [], diff --git a/lib/mnesia/test/mnesia_atomicity_test.erl b/lib/mnesia/test/mnesia_atomicity_test.erl index cc32ba3826..4764f9e7c0 100644 --- a/lib/mnesia/test/mnesia_atomicity_test.erl +++ b/lib/mnesia/test/mnesia_atomicity_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2016. All Rights Reserved. +%% Copyright Ericsson AB 1997-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -22,9 +22,37 @@ -module(mnesia_atomicity_test). -author('[email protected]'). -author('[email protected]'). --compile([export_all]). -include("mnesia_test_lib.hrl"). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). +-export([explicit_abort_in_middle_of_trans/1, + runtime_error_in_middle_of_trans/1, + mnesia_down_during_infinite_trans/1, + kill_self_in_middle_of_trans/1, throw_in_middle_of_trans/1, + lock_waiter_sw_r/1, lock_waiter_sw_rt/1, lock_waiter_sw_wt/1, + lock_waiter_wr_r/1, lock_waiter_srw_r/1, lock_waiter_sw_sw/1, + lock_waiter_sw_w/1, lock_waiter_sw_wr/1, lock_waiter_sw_srw/1, + lock_waiter_wr_wt/1, lock_waiter_srw_wt/1, + lock_waiter_wr_sw/1, lock_waiter_srw_sw/1, lock_waiter_wr_w/1, + lock_waiter_srw_w/1, lock_waiter_r_sw/1, lock_waiter_r_w/1, + lock_waiter_r_wt/1, lock_waiter_rt_sw/1, lock_waiter_rt_w/1, + lock_waiter_rt_wt/1, lock_waiter_wr_wr/1, + lock_waiter_srw_srw/1, lock_waiter_wt_r/1, lock_waiter_wt_w/1, + lock_waiter_wt_rt/1, lock_waiter_wt_wt/1, lock_waiter_wt_wr/1, + lock_waiter_wt_srw/1, lock_waiter_wt_sw/1, lock_waiter_w_wr/1, + lock_waiter_w_srw/1, lock_waiter_w_sw/1, lock_waiter_w_r/1, + lock_waiter_w_w/1, lock_waiter_w_rt/1, lock_waiter_w_wt/1, + restart_r_one/1, restart_w_one/1, restart_rt_one/1, + restart_wt_one/1, restart_wr_one/1, restart_sw_one/1, + restart_r_two/1, restart_w_two/1, restart_rt_two/1, + restart_wt_two/1, restart_wr_two/1, restart_sw_two/1 + ] + ). + +-export([perform_restarted_transaction/1, sync_tid_release/0]). + init_per_testcase(Func, Conf) -> mnesia_test_lib:init_per_testcase(Func, Conf). diff --git a/lib/mnesia/test/mnesia_bench_SUITE.erl b/lib/mnesia/test/mnesia_bench_SUITE.erl index 7c86db383d..8a225629e6 100644 --- a/lib/mnesia/test/mnesia_bench_SUITE.erl +++ b/lib/mnesia/test/mnesia_bench_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2012-2016. All Rights Reserved. +%% Copyright Ericsson AB 2012-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,13 @@ %% -module(mnesia_bench_SUITE). -author('[email protected]'). --compile(export_all). + +-export([init_per_testcase/2, end_per_testcase/2, + init_per_suite/1, end_per_suite/1, + init_per_group/2, end_per_group/2, + suite/0, all/0, groups/0]). + +-export([tpcb_conflict_ramcopies/1, tpcb_conflict_disk_only_copies/1]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% suite() -> [{ct_hooks,[{ts_install_cth,[{nodenames,2}]}]}]. diff --git a/lib/mnesia/test/mnesia_consistency_test.erl b/lib/mnesia/test/mnesia_consistency_test.erl index 2fe1bd34e6..46bafaf65c 100644 --- a/lib/mnesia/test/mnesia_consistency_test.erl +++ b/lib/mnesia/test/mnesia_consistency_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2016. All Rights Reserved. +%% Copyright Ericsson AB 1997-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,78 @@ %% -module(mnesia_consistency_test). -author('[email protected]'). --compile([export_all]). + +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([consistency_after_change_table_copy_type/1, + consistency_after_rename_of_node/1, + consistency_after_restart_1_ram/1, + consistency_after_restart_1_disc/1, + consistency_after_restart_1_disc_only/1, + consistency_after_restart_2_ram/1, + consistency_after_restart_2_disc/1, + consistency_after_restart_2_disc_only/1, + consistency_after_dump_tables_1_ram/1, + consistency_after_dump_tables_2_ram/1, + consistency_after_add_replica_2_ram/1, + consistency_after_add_replica_2_disc/1, + consistency_after_add_replica_2_disc_only/1, + consistency_after_add_replica_3_ram/1, + consistency_after_add_replica_3_disc/1, + consistency_after_add_replica_3_disc_only/1, + consistency_after_del_replica_2_ram/1, + consistency_after_del_replica_2_disc/1, + consistency_after_del_replica_2_disc_only/1, + consistency_after_del_replica_3_ram/1, + consistency_after_del_replica_3_disc/1, + consistency_after_del_replica_3_disc_only/1, + consistency_after_move_replica_2_ram/1, + consistency_after_move_replica_2_disc/1, + consistency_after_move_replica_2_disc_only/1, + consistency_after_move_replica_3_ram/1, + consistency_after_move_replica_3_disc/1, + consistency_after_move_replica_3_disc_only/1, + consistency_after_transform_table_ram/1, + consistency_after_transform_table_disc/1, + consistency_after_transform_table_disc_only/1, + consistency_after_fallback_2_ram/1, + consistency_after_fallback_2_disc/1, + consistency_after_fallback_2_disc_only/1, + consistency_after_fallback_3_ram/1, + consistency_after_fallback_3_disc/1, + consistency_after_fallback_3_disc_only/1, + consistency_after_restore_clear_ram/1, + consistency_after_restore_clear_disc/1, + consistency_after_restore_clear_disc_only/1, + consistency_after_restore_recreate_ram/1, + consistency_after_restore_recreate_disc/1, + consistency_after_restore_recreate_disc_only/1, + updates_during_checkpoint_activation_1_ram/1, + updates_during_checkpoint_activation_1_disc/1, + updates_during_checkpoint_activation_1_disc_only/1, + updates_during_checkpoint_activation_2_ram/1, + updates_during_checkpoint_activation_2_disc/1, + updates_during_checkpoint_activation_2_disc_only/1, + updates_during_checkpoint_activation_3_ram/1, + updates_during_checkpoint_activation_3_disc/1, + updates_during_checkpoint_activation_3_disc_only/1, + updates_during_checkpoint_iteration_2_ram/1, + updates_during_checkpoint_iteration_2_disc/1, + updates_during_checkpoint_iteration_2_disc_only/1, + load_table_with_activated_checkpoint_ram/1, + load_table_with_activated_checkpoint_disc/1, + load_table_with_activated_checkpoint_disc_only/1, + add_table_copy_to_table_checkpoint_ram/1, + add_table_copy_to_table_checkpoint_disc/1, + add_table_copy_to_table_checkpoint_disc_only/1, + inst_fallback_process_dies/1, fatal_when_inconsistency/1, + after_delete/1,cause_switch_before/1, cause_switch_after/1, + cause_abort_before/1, cause_abort_after/1, + change_schema_before/1, change_schema_after/1]). + +-export([change_tab/3]). -include("mnesia_test_lib.hrl"). diff --git a/lib/mnesia/test/mnesia_cost.erl b/lib/mnesia/test/mnesia_cost.erl index a3fc8dfe20..b5d5253147 100644 --- a/lib/mnesia/test/mnesia_cost.erl +++ b/lib/mnesia/test/mnesia_cost.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ %% -module(mnesia_cost). --compile(export_all). +-export([go/0, go/1]). %% This code exercises the mnesia system and produces a bunch %% of measurements on what various things cost @@ -156,64 +156,3 @@ do_dirty(I, F) when I /= 0 -> F(), do_dirty(I-1, F); do_dirty(_,_) -> ok. - - - -table_load([N1,N2| _ ] = Ns) -> - Nodes = [N1,N2], - rpc:multicall(Ns, mnesia, lkill, []), - ok = mnesia:delete_schema(Ns), - ok = mnesia:create_schema(Nodes), - rpc:multicall(Nodes, mnesia, start, []), - TabDef = [{disc_copies,[N1]},{ram_copies,[N2]}, - {attributes,record_info(fields,item)},{record_name,item}], - Tabs = [list_to_atom("tab" ++ integer_to_list(I)) || I <- lists:seq(1,400)], - - [mnesia:create_table(Tab,TabDef) || Tab <- Tabs], - -%% InitTab = fun(Tab) -> -%% mnesia:write_lock_table(Tab), -%% InitRec = fun(Key) -> mnesia:write(Tab,#item{a=Key},write) end, -%% lists:foreach(InitRec, lists:seq(1,100)) -%% end, -%% -%% {Time,{atomic,ok}} = timer:tc(mnesia,transaction, [fun() ->lists:foreach(InitTab, Tabs) end]), - mnesia:dump_log(), -%% io:format("Init took ~p msec ~n", [Time/1000]), - rpc:call(N2, mnesia, stop, []), timer:sleep(1000), - mnesia:stop(), timer:sleep(500), - %% Warmup - ok = mnesia:start([{no_table_loaders, 1}]), - timer:tc(mnesia, wait_for_tables, [Tabs, infinity]), - mnesia:dump_log(), - rpc:call(N2, mnesia, dump_log, []), - io:format("Initialized ~n",[]), - - mnesia:stop(), timer:sleep(1000), - ok = mnesia:start([{no_table_loaders, 1}]), - {T1, ok} = timer:tc(mnesia, wait_for_tables, [Tabs, infinity]), - io:format("Loading from disc with 1 loader ~p msec~n",[T1/1000]), - mnesia:stop(), timer:sleep(1000), - ok = mnesia:start([{no_table_loaders, 4}]), - {T2, ok} = timer:tc(mnesia, wait_for_tables, [Tabs, infinity]), - io:format("Loading from disc with 4 loader ~p msec~n",[T2/1000]), - - %% Warmup - rpc:call(N2, ?MODULE, remote_load, [Tabs,4]), - io:format("Initialized ~n",[]), - - - T3 = rpc:call(N2, ?MODULE, remote_load, [Tabs,1]), - io:format("Loading from net with 1 loader ~p msec~n",[T3/1000]), - - T4 = rpc:call(N2, ?MODULE, remote_load, [Tabs,4]), - io:format("Loading from net with 4 loader ~p msec~n",[T4/1000]), - - ok. - -remote_load(Tabs,Loaders) -> - ok = mnesia:start([{no_table_loaders, Loaders}]), -%% io:format("~p ~n", [mnesia_controller:get_info(500)]), - {Time, ok} = timer:tc(mnesia, wait_for_tables, [Tabs, infinity]), - timer:sleep(1000), mnesia:stop(), timer:sleep(1000), - Time. diff --git a/lib/mnesia/test/mnesia_dirty_access_test.erl b/lib/mnesia/test/mnesia_dirty_access_test.erl index 6d970ac990..67ef1fe901 100644 --- a/lib/mnesia/test/mnesia_dirty_access_test.erl +++ b/lib/mnesia/test/mnesia_dirty_access_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,9 +21,37 @@ %% -module(mnesia_dirty_access_test). -author('[email protected]'). --compile([export_all]). -include("mnesia_test_lib.hrl"). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([dirty_write_ram/1, dirty_write_disc/1, dirty_write_disc_only/1, dirty_write_xets/1, + dirty_read_ram/1, dirty_read_disc/1, dirty_read_disc_only/1, dirty_read_xets/1, + dirty_update_counter_ram/1, dirty_update_counter_disc/1, + dirty_update_counter_disc_only/1, dirty_update_counter_xets/1, + dirty_delete_ram/1, dirty_delete_disc/1, dirty_delete_disc_only/1, dirty_delete_xets/1, + dirty_delete_object_ram/1, dirty_delete_object_disc/1, + dirty_delete_object_disc_only/1, dirty_delete_object_xets/1, + dirty_match_object_ram/1, dirty_match_object_disc/1, + dirty_match_object_disc_only/1, dirty_match_object_xets/1, + dirty_index_match_object_ram/1, dirty_index_match_object_disc/1, + dirty_index_match_object_disc_only/1, dirty_index_match_object_xets/1, + dirty_index_read_ram/1, dirty_index_read_disc/1, + dirty_index_read_disc_only/1, dirty_index_read_xets/1, + dirty_index_update_set_ram/1, dirty_index_update_set_disc/1, + dirty_index_update_set_disc_only/1, dirty_index_update_set_xets/1, + dirty_index_update_bag_ram/1, dirty_index_update_bag_disc/1, + dirty_index_update_bag_disc_only/1, dirty_index_update_bag_xets/1, + dirty_iter_ram/1, dirty_iter_disc/1, dirty_iter_disc_only/1,dirty_iter_xets/1, + del_table_copy_1/1, del_table_copy_2/1, del_table_copy_3/1, + add_table_copy_1/1, add_table_copy_2/1, add_table_copy_3/1, + add_table_copy_4/1, move_table_copy_1/1, move_table_copy_2/1, + move_table_copy_3/1, move_table_copy_4/1]). + +-export([update_trans/3]). + init_per_testcase(Func, Conf) -> mnesia_test_lib:init_per_testcase(Func, Conf). diff --git a/lib/mnesia/test/mnesia_durability_test.erl b/lib/mnesia/test/mnesia_durability_test.erl index 97bc84a2d8..ccbfdc9738 100644 --- a/lib/mnesia/test/mnesia_durability_test.erl +++ b/lib/mnesia/test/mnesia_durability_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2016. All Rights Reserved. +%% Copyright Ericsson AB 1997-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,34 @@ %% -module(mnesia_durability_test). -author('[email protected]'). --compile([export_all]). + +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([durability_of_disc_copies/1, + durability_of_disc_only_copies/1, + load_latest_data/1, load_local_contents_directly/1, + load_directly_when_all_are_ram_copiesA/1, + load_directly_when_all_are_ram_copiesB/1, + load_when_last_replica_becomes_available/1, + load_when_down_from_all_other_replica_nodes/1, + late_load_transforms_into_disc_load/1, + late_load_leads_to_hanging/1, + force_load_when_nobody_intents_to_load/1, + force_load_when_someone_has_decided_to_load/1, + force_load_when_someone_else_has_loaded/1, + force_load_when_we_has_loaded/1, + force_load_on_a_non_local_table/1, + force_load_when_the_table_does_not_exist/1, + late_load_all_ram_cs_ram_nodes1/1, + late_load_all_ram_cs_ram_nodes2/1, + master_nodes/1, starting_master_nodes/1, + master_on_non_local_tables/1, + remote_force_load_with_local_master_node/1, + master_node_with_ram_copy_2/1, master_node_with_ram_copy_3/1, + dump_ram_copies/1, dump_disc_copies/1, dump_disc_only/1]). + -include("mnesia_test_lib.hrl"). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -65,7 +92,8 @@ groups() -> {load_tables_with_master_tables, [], [master_nodes, starting_master_nodes, master_on_non_local_tables, - remote_force_load_with_local_master_node]}, + remote_force_load_with_local_master_node, + master_node_with_ram_copy_2, master_node_with_ram_copy_3]}, {durability_of_dump_tables, [], [dump_ram_copies, dump_disc_copies, dump_disc_only]}]. @@ -1139,6 +1167,107 @@ remote_force_load_with_local_master_node(Config) when is_list(Config) -> ?verify_mnesia(Nodes, []). +master_node_with_ram_copy_2(Config) when is_list(Config) -> + [A, B] = Nodes = ?acquire_nodes(2, Config), + Tab = ?FUNCTION_NAME, + ?match({atomic,ok}, mnesia:create_table(Tab, [{disc_copies, [A]}, {ram_copies, [B]}])), + ?match({atomic,ok}, mnesia:sync_transaction(?SDwrite({Tab, 1, init}))), + + %% Test that we don't load from ram_copies + ?match(stopped, rpc:call(A, mnesia, stop, [])), + ?match(stopped, rpc:call(B, mnesia, stop, [])), + ?match(ok, rpc:call(B, mnesia, start, [])), + ?match({timeout, [Tab]}, rpc:call(B, mnesia, wait_for_tables, [[Tab], 1000])), + ?match(ok, rpc:call(A, mnesia, start, [])), + ?match(ok, rpc:call(B, mnesia, wait_for_tables, [[Tab], 3000])), + ?match([{Tab, 1, init}], rpc:call(A, mnesia, dirty_read, [{Tab, 1}])), + ?match([{Tab, 1, init}], rpc:call(B, mnesia, dirty_read, [{Tab, 1}])), + + %% Test that master_nodes set to ram_copy node require force_load + ?match(ok, rpc:call(A, mnesia, set_master_nodes, [[B]])), + ?match(stopped, rpc:call(A, mnesia, stop, [])), + ?match(stopped, rpc:call(B, mnesia, stop, [])), + ?match(ok, rpc:call(B, mnesia, start, [])), + ?match({timeout, [Tab]}, rpc:call(B, mnesia, wait_for_tables, [[Tab], 1000])), + ?match(ok, rpc:call(A, mnesia, start, [])), + ?match({timeout, [Tab]}, rpc:call(B, mnesia, wait_for_tables, [[Tab], 1000])), + + ?match(yes, rpc:call(A, mnesia, force_load_table, [Tab])), + ?match(ok, rpc:call(A, mnesia, wait_for_tables, [[Tab], 1000])), + ?match(ok, rpc:call(B, mnesia, wait_for_tables, [[Tab], 1000])), + ?match([{Tab, 1, init}], rpc:call(A, mnesia, dirty_read, [{Tab, 1}])), + ?match([{Tab, 1, init}], rpc:call(B, mnesia, dirty_read, [{Tab, 1}])), + + ?verify_mnesia(Nodes, []). + + +master_node_with_ram_copy_3(Config) when is_list(Config) -> + [A, B, C] = Nodes = ?acquire_nodes(3, Config), + Tab = ?FUNCTION_NAME, + ?match({atomic,ok}, mnesia:create_table(Tab, [{disc_copies, [A,C]}, {ram_copies, [B]}])), + ?match({atomic,ok}, mnesia:sync_transaction(?SDwrite({Tab, 1, init}))), + + %% Test that we don't load from ram_copies + ?match(stopped, rpc:call(A, mnesia, stop, [])), + ?match(stopped, rpc:call(C, mnesia, stop, [])), + ?match(stopped, rpc:call(B, mnesia, stop, [])), + ?match(ok, rpc:call(B, mnesia, start, [])), + ?match({timeout, [Tab]}, rpc:call(B, mnesia, wait_for_tables, [[Tab], 1000])), + ?match(ok, rpc:call(A, mnesia, start, [])), + ?match(ok, rpc:call(C, mnesia, start, [])), + ?match(ok, rpc:call(B, mnesia, wait_for_tables, [[Tab], 3000])), + ?match(ok, rpc:call(A, mnesia, wait_for_tables, [[Tab], 3000])), + ?match([{Tab, 1, init}], rpc:call(A, mnesia, dirty_read, [{Tab, 1}])), + ?match([{Tab, 1, init}], rpc:call(B, mnesia, dirty_read, [{Tab, 1}])), + ?match([{Tab, 1, init}], rpc:call(C, mnesia, dirty_read, [{Tab, 1}])), + + %% Test that master_nodes set to ram_copy node will wait until loaded + ?match(ok, rpc:call(A, mnesia, set_master_nodes, [[B]])), + ?match(stopped, rpc:call(A, mnesia, stop, [])), + ?match({atomic,ok}, rpc:call(B, mnesia, sync_transaction, [?SDwrite({Tab, 1, update})])), + ?match(stopped, rpc:call(C, mnesia, stop, [])), + ?match({atomic,ok}, rpc:call(B, mnesia, sync_transaction, [?SDwrite({Tab, 1, ram_copies})])), + ?match(stopped, rpc:call(B, mnesia, stop, [])), + ?match(ok, rpc:call(B, mnesia, start, [])), + ?match({timeout, [Tab]}, rpc:call(B, mnesia, wait_for_tables, [[Tab], 500])), + ?match(ok, rpc:call(A, mnesia, start, [])), + ?match({timeout, [Tab]}, rpc:call(A, mnesia, wait_for_tables, [[Tab], 500])), + ?match(ok, rpc:call(C, mnesia, start, [])), + ?match(ok, rpc:call(B, mnesia, wait_for_tables, [[Tab], 3000])), + ?match(ok, rpc:call(A, mnesia, wait_for_tables, [[Tab], 3000])), + ?match([{Tab, 1, update}], rpc:call(A, mnesia, dirty_read, [{Tab, 1}])), + ?match([{Tab, 1, update}], rpc:call(B, mnesia, dirty_read, [{Tab, 1}])), + ?match([{Tab, 1, update}], rpc:call(C, mnesia, dirty_read, [{Tab, 1}])), + + %% Test that master_nodes set to ram_copy node requires force load + ?match({atomic,ok}, mnesia:sync_transaction(?SDwrite({Tab, 1, init}))), + ?match(ok, rpc:call(A, mnesia, set_master_nodes, [[B]])), + ?match(ok, rpc:call(C, mnesia, set_master_nodes, [[B]])), + + ?match(stopped, rpc:call(A, mnesia, stop, [])), + ?match({atomic,ok}, rpc:call(B, mnesia, sync_transaction, [?SDwrite({Tab, 1, update})])), + ?match(stopped, rpc:call(C, mnesia, stop, [])), + ?match({atomic,ok}, rpc:call(B, mnesia, sync_transaction, [?SDwrite({Tab, 1, ram_copies})])), + ?match(stopped, rpc:call(B, mnesia, stop, [])), + ?match(ok, rpc:call(B, mnesia, start, [])), + ?match({timeout, [Tab]}, rpc:call(B, mnesia, wait_for_tables, [[Tab], 500])), + ?match(ok, rpc:call(A, mnesia, start, [])), + ?match({timeout, [Tab]}, rpc:call(A, mnesia, wait_for_tables, [[Tab], 500])), + ?match(ok, rpc:call(C, mnesia, start, [])), + ?match({timeout, [Tab]}, rpc:call(A, mnesia, wait_for_tables, [[Tab], 500])), + ?match({timeout, [Tab]}, rpc:call(B, mnesia, wait_for_tables, [[Tab], 500])), + ?match({timeout, [Tab]}, rpc:call(B, mnesia, wait_for_tables, [[Tab], 500])), + ?match(yes, rpc:call(C, mnesia, force_load_table, [Tab])), + + ?match(ok, rpc:call(A, mnesia, wait_for_tables, [[Tab], 3000])), + ?match(ok, rpc:call(B, mnesia, wait_for_tables, [[Tab], 3000])), + ?match(ok, rpc:call(C, mnesia, wait_for_tables, [[Tab], 3000])), + ?match([{Tab, 1, update}], rpc:call(A, mnesia, dirty_read, [{Tab, 1}])), + ?match([{Tab, 1, update}], rpc:call(B, mnesia, dirty_read, [{Tab, 1}])), + ?match([{Tab, 1, update}], rpc:call(C, mnesia, dirty_read, [{Tab, 1}])), + + ?verify_mnesia(Nodes, []). + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1389,7 +1518,7 @@ do_disc_durability(Config,CopyType) -> [{Tab_bag, 22, a_2222}], [{Tab_bag, 33, a_3333}], [{Tab_set, counter, 10}]]), - timer:sleep(1000), %% Debugging strange msgs.. + timer:sleep(500), %% Debugging strange msgs.. ?log("Flushed ~p ~n", [mnesia_test_lib:flush()]), ?verify_mnesia(Nodes, []). diff --git a/lib/mnesia/test/mnesia_evil_backup.erl b/lib/mnesia/test/mnesia_evil_backup.erl index 044cf501fd..45b11f2f3f 100644 --- a/lib/mnesia/test/mnesia_evil_backup.erl +++ b/lib/mnesia/test/mnesia_evil_backup.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2016. All Rights Reserved. +%% Copyright Ericsson AB 1998-2017. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -28,10 +28,23 @@ -module(mnesia_evil_backup). -author('[email protected]'). --compile(export_all). -include("mnesia_test_lib.hrl"). -%%-export([Function/Arity, ...]). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([backup/1, bad_backup/1, global_backup_checkpoint/1, + traverse_backup/1, + selective_backup_checkpoint/1, + incremental_backup_checkpoint/1, install_fallback/1, + uninstall_fallback/1, local_fallback/1, + sops_with_checkpoint/1, + restore_errors/1, restore_clear/1, restore_keep/1, + restore_recreate/1, restore_clear_ram/1 + ]). + +-export([check_tab/2]). init_per_testcase(Func, Conf) -> mnesia_test_lib:init_per_testcase(Func, Conf). diff --git a/lib/mnesia/test/mnesia_evil_coverage_test.erl b/lib/mnesia/test/mnesia_evil_coverage_test.erl index 6e34040bc4..a451c8d0c8 100644 --- a/lib/mnesia/test/mnesia_evil_coverage_test.erl +++ b/lib/mnesia/test/mnesia_evil_coverage_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -23,7 +23,33 @@ -author('[email protected]'). -include("mnesia_test_lib.hrl"). --compile([export_all]). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([system_info/1, table_info/1, error_description/1, + db_node_lifecycle/1, evil_delete_db_node/1, start_and_stop/1, + checkpoint/1, table_lifecycle/1, storage_options/1, + add_copy_conflict/1, add_copy_when_going_down/1, + add_copy_with_down/1, + replica_management/1, clear_table_during_load/1, + schema_availability/1, local_content/1, + replica_location/1, user_properties/1, unsupp_user_props/1, + sorted_ets/1, index_cleanup/1, + change_table_access_mode/1, change_table_load_order/1, + set_master_nodes/1, offline_set_master_nodes/1, + dump_tables/1, dump_log/1, wait_for_tables/1, force_load_table/1, + snmp_open_table/1, snmp_close_table/1, snmp_get_next_index/1, + snmp_get_row/1, snmp_get_mnesia_key/1, snmp_update_counter/1, + snmp_order/1, subscribe_standard/1, subscribe_extended/1, + foldl/1, info/1, schema_0/1, schema_1/1, view_0/1, view_1/1, view_2/1, + lkill/1, kill/1, + record_name_dirty_access_ram/1, + record_name_dirty_access_disc/1, + record_name_dirty_access_disc_only/1, + record_name_dirty_access_xets/1]). + +-export([info_check/8, index_size/1]). -define(cleanup(N, Config), mnesia_test_lib:prepare_test_case([{reload_appls, [mnesia]}], @@ -40,13 +66,14 @@ all() -> db_node_lifecycle, evil_delete_db_node, start_and_stop, checkpoint, table_lifecycle, storage_options, add_copy_conflict, - add_copy_when_going_down, replica_management, clear_table_during_load, + add_copy_when_going_down, add_copy_with_down, replica_management, + clear_table_during_load, schema_availability, local_content, {group, table_access_modifications}, replica_location, {group, table_sync}, user_properties, unsupp_user_props, {group, record_name}, {group, snmp_access}, {group, subscriptions}, {group, iteration}, - {group, debug_support}, sorted_ets, + {group, debug_support}, sorted_ets, index_cleanup, {mnesia_dirty_access_test, all}, {mnesia_trans_access_test, all}, {mnesia_evil_backup, all}]. @@ -707,6 +734,49 @@ add_copy_when_going_down(Config) -> ?match_receive({test,{aborted,_}}), ?verify_mnesia([Node2], []). +add_copy_with_down(suite) -> []; +add_copy_with_down(Config) -> + %% Allow add_table_copy() with ram_copies even all other replicas are down + Nodes = [Node1, Node2, Node3] = ?acquire_nodes(3, Config), + ?match({atomic, ok}, mnesia:create_table(a, [{ram_copies, [Node3]}, {disc_copies, [Node2]}])), + stopped = rpc:call(Node2, mnesia, stop, []), + stopped = rpc:call(Node3, mnesia, stop, []), + ?match({aborted, _}, mnesia:add_table_copy(a, Node1, ram_copies)), + ?match({aborted, _}, mnesia:del_table_copy(a, Node2)), + ok = rpc:call(Node3, mnesia, start, []), + ?match({aborted, _}, mnesia:add_table_copy(a, Node1, ram_copies)), + ?match([], mnesia_test_lib:start_mnesia([Node2], [a])), + ?match({atomic, ok}, mnesia:change_table_copy_type(a, Node2, ram_copies)), + stopped = rpc:call(Node2, mnesia, stop, []), + stopped = rpc:call(Node3, mnesia, stop, []), + ?match({atomic, ok}, mnesia:add_table_copy(a, Node1, ram_copies)), + ?match(ok, mnesia:dirty_write({a,1,1})), + ?match([], mnesia_test_lib:start_mnesia([Node2,Node3], [a])), + ?match([{a,1,1}], rpc:call(Node1, mnesia, dirty_read, [{a,1}])), + ?match([{a,1,1}], rpc:call(Node2, mnesia, dirty_read, [{a,1}])), + ?match([{a,1,1}], rpc:call(Node3, mnesia, dirty_read, [{a,1}])), + + ?match({atomic, ok}, mnesia:del_table_copy(a, Node1)), + stopped = rpc:call(Node2, mnesia, stop, []), + stopped = rpc:call(Node3, mnesia, stop, []), + ?match({atomic, ok}, mnesia:add_table_copy(a, Node1, disc_copies)), + ?match(ok, mnesia:dirty_write({a,1,1})), + ?match([], mnesia_test_lib:start_mnesia([Node2,Node3], [a])), + ?match([{a,1,1}], rpc:call(Node1, mnesia, dirty_read, [{a,1}])), + ?match([{a,1,1}], rpc:call(Node2, mnesia, dirty_read, [{a,1}])), + ?match([{a,1,1}], rpc:call(Node3, mnesia, dirty_read, [{a,1}])), + + ?match({atomic, ok}, mnesia:del_table_copy(a, Node1)), + stopped = rpc:call(Node2, mnesia, stop, []), + stopped = rpc:call(Node3, mnesia, stop, []), + ?match({atomic, ok}, mnesia:add_table_copy(a, Node1, disc_only_copies)), + ?match(ok, mnesia:dirty_write({a,1,1})), + ?match([], mnesia_test_lib:start_mnesia([Node2,Node3], [a])), + ?match([{a,1,1}], rpc:call(Node1, mnesia, dirty_read, [{a,1}])), + ?match([{a,1,1}], rpc:call(Node2, mnesia, dirty_read, [{a,1}])), + ?match([{a,1,1}], rpc:call(Node3, mnesia, dirty_read, [{a,1}])), + + ?verify_mnesia(Nodes, []). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Add, drop and move replicas, change storage types @@ -2489,3 +2559,55 @@ sorted_ets(Config) when is_list(Config) -> ?match({atomic, [{rec,1,1}, {rec,2,1}]}, mnesia:transaction(TestIt)). +index_cleanup(Config) when is_list(Config) -> + [N1, N2] = All = ?acquire_nodes(2, Config), + ?match({atomic, ok}, mnesia:create_table(i_set, [{type, set}, {ram_copies, [N1]}, {index, [val]}, + {disc_only_copies, [N2]}])), + ?match({atomic, ok}, mnesia:create_table(i_bag, [{type, bag}, {ram_copies, [N1]}, {index, [val]}, + {disc_only_copies, [N2]}])), + ?match({atomic, ok}, mnesia:create_table(i_oset, [{type, ordered_set}, {ram_copies, [N1, N2]}, + {index, [val]}])), + + Tabs = [i_set, i_bag, i_oset], + + Add = fun(Tab) -> + Write = fun(Tab) -> + Recs = [{Tab, N, N rem 5} || N <- lists:seq(1,10)], + [ok = mnesia:write(Rec) || Rec <- Recs], + Recs + end, + {atomic, Recs} = mnesia:sync_transaction(Write, [Tab]), + lists:sort(Recs) + end, + + IRead = fun(Tab) -> + Read = fun(Tab) -> + [mnesia:index_read(Tab, N, val) || N <- lists:seq(0,4)] + end, + {atomic, Recs} = mnesia:transaction(Read, [Tab]), + lists:sort(lists:flatten(Recs)) + end, + + Delete = fun(Rec) -> + Del = fun() -> mnesia:delete_object(Rec) end, + {atomic, ok} = mnesia:sync_transaction(Del), + ok + end, + + + Recs = [Add(Tab) || Tab <- Tabs], + ?match(Recs, [IRead(Tab) || Tab <- Tabs]), + [Delete(Rec) || Rec <- lists:flatten(Recs)], + + [?match({Tab,0}, {Tab,mnesia:table_info(Tab, size)}) || Tab <- Tabs], + + [?match({Tab,Node,0, _}, rpc:call(Node, ?MODULE, index_size, [Tab])) + || Node <- All, Tab <- Tabs], + ?verify_mnesia(All, []). + +index_size(Tab) -> + %% White box testing + case mnesia:table_info(Tab, index_info) of + {index, _, [{_, {ram, Ref}}=Dbg]} -> {Tab, node(), ets:info(Ref, size), Dbg}; + {index, _, [{_, {dets, Ref}}=Dbg]} -> {Tab, node(), dets:info(Ref, size), Dbg} + end. diff --git a/lib/mnesia/test/mnesia_examples_test.erl b/lib/mnesia/test/mnesia_examples_test.erl index 808e62d9c2..3bbb6e4d77 100644 --- a/lib/mnesia/test/mnesia_examples_test.erl +++ b/lib/mnesia/test/mnesia_examples_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2016. All Rights Reserved. +%% Copyright Ericsson AB 1997-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,14 @@ %% -module(mnesia_examples_test). -author('[email protected]'). --compile([export_all]). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). +-export([bup/1, company/1, meter/1, + replica_test/1, sticky_replica_test/1, dist_test/1, + conflict_test/1, frag_test/1, frag2_test/1, remote_test/1, + remote_frag2_test/1, opt_load/1]). + -include("mnesia_test_lib.hrl"). init_per_testcase(Func, Conf) -> diff --git a/lib/mnesia/test/mnesia_frag_test.erl b/lib/mnesia/test/mnesia_frag_test.erl index 9f2102beb2..7b37fcb684 100644 --- a/lib/mnesia/test/mnesia_frag_test.erl +++ b/lib/mnesia/test/mnesia_frag_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2016. All Rights Reserved. +%% Copyright Ericsson AB 1999-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -23,7 +23,17 @@ -author('[email protected]'). -include("mnesia_test_lib.hrl"). --compile([export_all]). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + + +-export([nice_single/1, nice_multi/1, nice_access/1, iter_access/1, + consistency/1, evil_create/1, evil_delete/1, evil_change/1, evil_combine/1, + evil_loop/1, evil_delete_db_node/1]). + + +-export([frag_dist/1]). init_per_testcase(Func, Conf) -> mnesia_test_lib:init_per_testcase(Func, Conf). @@ -845,16 +855,7 @@ frag_rec_dist(Tab) -> Fun = fun() -> mnesia:table_info(Tab, frag_size) end, [Size || {_, Size} <- mnesia:activity(sync_dirty, Fun, mnesia_frag)]. -table_size(Tab) -> - Node = mnesia:table_info(Tab, where_to_read), - rpc:call(Node, mnesia, table_info, [Tab, size]). - sort_res(List) when is_list(List) -> lists:sort(List); sort_res(Else) -> Else. - -rev_res(List) when is_list(List) -> - lists:reverse(List); -rev_res(Else) -> - Else. diff --git a/lib/mnesia/test/mnesia_install_test.erl b/lib/mnesia/test/mnesia_install_test.erl index 103f85b3d6..2aee5137c3 100644 --- a/lib/mnesia/test/mnesia_install_test.erl +++ b/lib/mnesia/test/mnesia_install_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,8 +21,13 @@ %% -module(mnesia_install_test). -author('[email protected]'). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([silly_durability/1, silly_move/1, silly_upgrade/1, conflict/1, dist/1, + silly/0, silly2/1]). --compile([export_all]). -include("mnesia_test_lib.hrl"). init_per_testcase(Func, Conf) -> diff --git a/lib/mnesia/test/mnesia_isolation_test.erl b/lib/mnesia/test/mnesia_isolation_test.erl index 63940ec05c..49bcec14af 100644 --- a/lib/mnesia/test/mnesia_isolation_test.erl +++ b/lib/mnesia/test/mnesia_isolation_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2016. All Rights Reserved. +%% Copyright Ericsson AB 1997-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -22,7 +22,36 @@ -module(mnesia_isolation_test). -author('[email protected]'). --compile([export_all]). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([no_conflict/1, simple_queue_conflict/1, + advanced_queue_conflict/1, simple_deadlock_conflict/1, + advanced_deadlock_conflict/1, schema_deadlock/1, lock_burst/1, + nasty/1, basic_sticky_functionality/1, + unbound1/1, unbound2/1, + create_table/1, delete_table/1, move_table_copy/1, + add_table_index/1, del_table_index/1, transform_table/1, + snmp_open_table/1, snmp_close_table/1, + change_table_copy_type/1, change_table_access/1, + add_table_copy/1, del_table_copy/1, dump_tables/1, + del_table_copy_1/1, del_table_copy_2/1, del_table_copy_3/1, + add_table_copy_1/1, add_table_copy_2/1, add_table_copy_3/1, + add_table_copy_4/1, move_table_copy_1/1, move_table_copy_2/1, + move_table_copy_3/1, move_table_copy_4/1, + dirty_updates_visible_direct/1, + dirty_reads_regardless_of_trans/1, + trans_update_invisibible_outside_trans/1, + trans_update_visible_inside_trans/1, write_shadows/1, + delete_shadows/1, write_delete_shadows_bag/1, + write_delete_shadows_bag2/1, + shadow_search/1, snmp_shadows/1, + rr_kill_copy/1, foldl/1, first_next/1]). + +-export([do_fun/4, burst_counter/3, burst_incr/2, get_held/0, get_info/1, + get_sticky/0, op/4, update_own/3, update_shared/3]). + -include("mnesia_test_lib.hrl"). init_per_testcase(Func, Conf) -> @@ -668,16 +697,6 @@ unbound2(Config) when is_list(Config) -> {B, {atomic, [{ul,{key,{17,42}},val}]}}]), ok. -receiver() -> - receive - {_Pid, begin_trans} -> - receiver(); - Else -> - Else - after - 10000 -> - timeout - end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1544,7 +1563,8 @@ trans_update_visible_inside_trans(Config) when is_list(Config) -> ?match({atomic, ok}, mnesia:create_table([{name, Tab}, {ram_copies, [Node1]}])), ValPos = 3, - RecA = {Tab, a, 1}, + RecA = {Tab, a, 1}, + RecA2 = {Tab, a, 2}, PatA = {Tab, '$1', 1}, RecB = {Tab, b, 3}, PatB = {Tab, '$1', 3}, @@ -1579,6 +1599,14 @@ trans_update_visible_inside_trans(Config) when is_list(Config) -> ?match([], mnesia:index_read(Tab, 3, ValPos)), %% delete_object + ?match(ok, mnesia:delete_object(RecA2)), + ?match([RecA], mnesia:read({Tab, a})), + ?match([RecA], mnesia:wread({Tab, a})), + ?match([RecA], mnesia:match_object(PatA)), + ?match([a], mnesia:all_keys(Tab)), + ?match([RecA], mnesia:index_match_object(PatA, ValPos)), + ?match([RecA], mnesia:index_read(Tab, 1, ValPos)), + ?match(ok, mnesia:delete_object(RecA)), ?match([], mnesia:read({Tab, a})), ?match([], mnesia:wread({Tab, a})), diff --git a/lib/mnesia/test/mnesia_majority_test.erl b/lib/mnesia/test/mnesia_majority_test.erl index 9811de6ae7..aae27e069e 100644 --- a/lib/mnesia/test/mnesia_majority_test.erl +++ b/lib/mnesia/test/mnesia_majority_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2016. All Rights Reserved. +%% Copyright Ericsson AB 2010-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,13 @@ %% -module(mnesia_majority_test). -author('[email protected]'). --compile(export_all). +-export([init_per_testcase/2, end_per_testcase/2, + all/0]). + +-export([write/1, wread/1, delete/1, clear_table/1, frag/1, + change_majority/1, frag_change_majority/1 + ]). + -include("mnesia_test_lib.hrl"). init_per_testcase(Func, Conf) -> diff --git a/lib/mnesia/test/mnesia_measure_test.erl b/lib/mnesia/test/mnesia_measure_test.erl index ad71fafecb..8eb3590168 100644 --- a/lib/mnesia/test/mnesia_measure_test.erl +++ b/lib/mnesia/test/mnesia_measure_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,15 @@ %% -module(mnesia_measure_test). -author('[email protected]'). --compile([export_all]). + +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([cost/1, dbn_meters/1, + ram_tpcb/1, disc_tpcb/1, disc_only_tpcb/1, + ram_meter/1, disc_meter/1, disc_only_meter/1]). + -include("mnesia_test_lib.hrl"). @@ -39,41 +47,12 @@ end_per_testcase(Func, Conf) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% all() -> - [{group, prediction}, {group, consumption}, - {group, scalability}, {group, benchmarks}]. + [{group, benchmarks}]. groups() -> - [{prediction, [], - [reader_disturbed_by_node_down, - writer_disturbed_by_node_down, - reader_disturbed_by_node_up, - writer_disturbed_by_node_up, - reader_disturbed_by_schema_ops, - writer_disturbed_by_schema_ops, - reader_disturbed_by_checkpoint, - writer_disturbed_by_checkpoint, - reader_disturbed_by_dump_log, - writer_disturbed_by_dump_log, - reader_disturbed_by_backup, writer_disturbed_by_backup, - reader_disturbed_by_restore, - writer_disturbed_by_restore, {group, fairness}]}, - {fairness, [], - [reader_competing_with_reader, - reader_competing_with_writer, - writer_competing_with_reader, - writer_competing_with_writer]}, - {consumption, [], - [measure_resource_consumption, - determine_resource_leakage]}, - {scalability, [], - [determine_system_limits, performance_at_min_config, - performance_at_max_config, performance_at_full_load, - resource_consumption_at_min_config, - resource_consumption_at_max_config, - resource_consumption_at_full_load]}, - {benchmarks, [], + [{benchmarks, [], [{group, meter}, cost, dbn_meters, - measure_all_api_functions, {group, tpcb}]}, + {group, tpcb}]}, {tpcb, [], [ram_tpcb, disc_tpcb, disc_only_tpcb]}, {meter, [], [ram_meter, disc_meter, disc_only_meter]}]. diff --git a/lib/mnesia/test/mnesia_nice_coverage_test.erl b/lib/mnesia/test/mnesia_nice_coverage_test.erl index ffbe36e48d..f8c6b2ce20 100644 --- a/lib/mnesia/test/mnesia_nice_coverage_test.erl +++ b/lib/mnesia/test/mnesia_nice_coverage_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,13 @@ %% -module(mnesia_nice_coverage_test). -author('[email protected]'). --compile([export_all]). + +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([nice/1]). + -include("mnesia_test_lib.hrl"). -record(nice_tab, {key, val}). diff --git a/lib/mnesia/test/mnesia_qlc_test.erl b/lib/mnesia/test/mnesia_qlc_test.erl index 5067e86521..e66fd84995 100644 --- a/lib/mnesia/test/mnesia_qlc_test.erl +++ b/lib/mnesia/test/mnesia_qlc_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2016. All Rights Reserved. +%% Copyright Ericsson AB 2004-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,9 +21,18 @@ %% -module(mnesia_qlc_test). --compile(export_all). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([frag/1, info/1, mnesia_down/1, + dirty_nice_ram_copies/1, dirty_nice_disc_copies/1, + dirty_nice_disc_only_copies/1, + trans_nice_ram_copies/1, trans_nice_disc_copies/1, + trans_nice_disc_only_copies/1, atomic_eval/1, + nested_qlc/1 + ]). --export([all/0,groups/0,init_per_group/2,end_per_group/2]). -include("mnesia_test_lib.hrl"). -include_lib("stdlib/include/qlc.hrl"). diff --git a/lib/mnesia/test/mnesia_recovery_test.erl b/lib/mnesia/test/mnesia_recovery_test.erl index 130b87346f..b5749408f8 100644 --- a/lib/mnesia/test/mnesia_recovery_test.erl +++ b/lib/mnesia/test/mnesia_recovery_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,80 @@ %% -module(mnesia_recovery_test). -author('[email protected]'). --compile([export_all]). + +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([coord_dies/1, after_full_disc_partition/1, + disc_less/1, garb_decision/1, + system_upgrade/1, + delete_during_start/1, + no_master_2/1, no_master_3/1, one_master_2/1, one_master_3/1, + two_master_2/1, two_master_3/1, all_master_2/1, + all_master_3/1, + dirty_read_during_down/1, trans_read_during_down/1, + mnesia_down_during_startup_disk_ram/1, + mnesia_down_during_startup_init_ram/1, + mnesia_down_during_startup_init_disc/1, + mnesia_down_during_startup_init_disc_only/1, + mnesia_down_during_startup_tm_ram/1, + mnesia_down_during_startup_tm_disc/1, + mnesia_down_during_startup_tm_disc_only/1, + with_checkpoint_same/1, with_checkpoint_other/1, + explicit_stop_during_snmp/1, + sym_trans_before_commit_kill_coord_node/1, + sym_trans_before_commit_kill_coord_pid/1, + sym_trans_before_commit_kill_part_after_ask/1, + sym_trans_before_commit_kill_part_before_ask/1, + sym_trans_after_commit_kill_coord_node/1, + sym_trans_after_commit_kill_coord_pid/1, + sym_trans_after_commit_kill_part_after_ask/1, + sym_trans_after_commit_kill_part_do_commit_pre/1, + sym_trans_after_commit_kill_part_do_commit_post/1, + sync_dirty_pre_kill_part/1, + sync_dirty_pre_kill_coord_node/1, + sync_dirty_pre_kill_coord_pid/1, + sync_dirty_post_kill_part/1, + sync_dirty_post_kill_coord_node/1, + sync_dirty_post_kill_coord_pid/1, + async_dirty_pre_kill_part/1, + async_dirty_pre_kill_coord_node/1, + async_dirty_pre_kill_coord_pid/1, + async_dirty_post_kill_part/1, + async_dirty_post_kill_coord_node/1, + async_dirty_post_kill_coord_pid/1, + asymtrans_part_ask/1, + asymtrans_part_commit_vote/1, + asymtrans_part_pre_commit/1, + asymtrans_part_log_commit/1, + asymtrans_part_do_commit/1, + asymtrans_coord_got_votes/1, + asymtrans_coord_pid_got_votes/1, + asymtrans_coord_log_commit_rec/1, + asymtrans_coord_pid_log_commit_rec/1, + asymtrans_coord_log_commit_dec/1, + asymtrans_coord_pid_log_commit_dec/1, + asymtrans_coord_rec_acc_pre_commit_log_commit/1, + asymtrans_coord_pid_rec_acc_pre_commit_log_commit/1, + asymtrans_coord_rec_acc_pre_commit_done_commit/1, + asymtrans_coord_pid_rec_acc_pre_commit_done_commit/1, + after_corrupt_files_decision_log_head/1, + after_corrupt_files_decision_log_tail/1, + after_corrupt_files_latest_log_head/1, + after_corrupt_files_latest_log_tail/1, + after_corrupt_files_table_dat_head/1, + after_corrupt_files_table_dat_tail/1, + after_corrupt_files_schema_dat_head/1, + after_corrupt_files_schema_dat_tail/1]). + +-export([reader/2, check/0, get_all_retainers/1, + verify_data/2, verify_where2read/1, + do_trans_loop/2, + start_stop/3, do_sym_trans/2, do_sync_dirty/2, do_async_dirty/2, + do_asym_trans/2, garb_handler/1, mymnesia_start/1 + ]). + -include("mnesia_test_lib.hrl"). -include_lib("kernel/include/file.hrl"). @@ -657,6 +730,7 @@ do_trans_loop2(Tab, Father) -> do_trans_loop2(Tab, Father); Else -> ?error("Transaction failed: ~p ~n", [Else]), + io:format("INFO: ~p~n",[erlang:process_info(self())]), Father ! test_done, exit(shutdown) end. diff --git a/lib/mnesia/test/mnesia_registry_test.erl b/lib/mnesia/test/mnesia_registry_test.erl index 3df37a2c8c..c15b8e97af 100644 --- a/lib/mnesia/test/mnesia_registry_test.erl +++ b/lib/mnesia/test/mnesia_registry_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2016. All Rights Reserved. +%% Copyright Ericsson AB 1998-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,12 @@ %% -module(mnesia_registry_test). -author('[email protected]'). --compile([export_all]). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([good_dump/1, bad_dump/1, dump_registry/2, restore_registry/2]). + -include("mnesia_test_lib.hrl"). init_per_testcase(Func, Conf) -> diff --git a/lib/mnesia/test/mnesia_schema_recovery_test.erl b/lib/mnesia/test/mnesia_schema_recovery_test.erl index ca2dd74b34..e4199758c1 100644 --- a/lib/mnesia/test/mnesia_schema_recovery_test.erl +++ b/lib/mnesia/test/mnesia_schema_recovery_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2016. All Rights Reserved. +%% Copyright Ericsson AB 1998-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,79 @@ %% -module(mnesia_schema_recovery_test). -author('[email protected]'). --compile([export_all]). + +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([interrupted_before_create_ram/1, + interrupted_before_create_disc/1, + interrupted_before_create_do/1, + interrupted_before_create_nostore/1, + interrupted_before_delete_ram/1, + interrupted_before_delete_disc/1, + interrupted_before_delete_do/1, + interrupted_before_add_ram/1, + interrupted_before_add_disc/1, + interrupted_before_add_do/1, + interrupted_before_add_kill_copier/1, + interrupted_before_move_ram/1, + interrupted_before_move_disc/1, + interrupted_before_move_do/1, + interrupted_before_move_kill_copier/1, + interrupted_before_delcopy_ram/1, + interrupted_before_delcopy_disc/1, + interrupted_before_delcopy_do/1, + interrupted_before_delcopy_kill_copier/1, + interrupted_before_addindex_ram/1, + interrupted_before_addindex_disc/1, + interrupted_before_addindex_do/1, + interrupted_before_delindex_ram/1, + interrupted_before_delindex_disc/1, + interrupted_before_delindex_do/1, + interrupted_before_change_type_ram2disc/1, + interrupted_before_change_type_ram2do/1, + interrupted_before_change_type_disc2ram/1, + interrupted_before_change_type_disc2do/1, + interrupted_before_change_type_do2ram/1, + interrupted_before_change_type_do2disc/1, + interrupted_before_change_type_other_node/1, + interrupted_before_change_schema_type/1, + interrupted_after_create_ram/1, + interrupted_after_create_disc/1, + interrupted_after_create_do/1, + interrupted_after_create_nostore/1, + interrupted_after_delete_ram/1, + interrupted_after_delete_disc/1, + interrupted_after_delete_do/1, + interrupted_after_add_ram/1, + interrupted_after_add_disc/1, + interrupted_after_add_do/1, + interrupted_after_add_kill_copier/1, + interrupted_after_move_ram/1, + interrupted_after_move_disc/1, + interrupted_after_move_do/1, + interrupted_after_move_kill_copier/1, + interrupted_after_delcopy_ram/1, + interrupted_after_delcopy_disc/1, + interrupted_after_delcopy_do/1, + interrupted_after_delcopy_kill_copier/1, + interrupted_after_addindex_ram/1, + interrupted_after_addindex_disc/1, + interrupted_after_addindex_do/1, + interrupted_after_delindex_ram/1, + interrupted_after_delindex_disc/1, + interrupted_after_delindex_do/1, + interrupted_after_change_type_ram2disc/1, + interrupted_after_change_type_ram2do/1, + interrupted_after_change_type_disc2ram/1, + interrupted_after_change_type_disc2do/1, + interrupted_after_change_type_do2ram/1, + interrupted_after_change_type_do2disc/1, + interrupted_after_change_type_other_node/1, + interrupted_after_change_schema_type/1]). + + -include("mnesia_test_lib.hrl"). init_per_testcase(Func, Conf) -> diff --git a/lib/mnesia/test/mnesia_test_lib.erl b/lib/mnesia/test/mnesia_test_lib.erl index 0fabdc7929..1cdac3cde6 100644 --- a/lib/mnesia/test/mnesia_test_lib.erl +++ b/lib/mnesia/test/mnesia_test_lib.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -470,9 +470,9 @@ get_suite(Mod, {group, Suite}) -> {_, _, TCList} = lists:keyfind(Suite, 1, Groups), TCList catch - _:Reason -> + _:Reason:Stacktrace -> io:format("Not implemented ~p ~p (~p ~p)~n", - [Mod,Suite,Reason, erlang:get_stacktrace()]), + [Mod,Suite,Reason,Stacktrace]), 'NYI' end; get_suite(Mod, all) -> @@ -774,7 +774,7 @@ init_nodes([], _File, _Line) -> %% Returns [Name, Host] node_to_name_and_host(Node) -> - string:tokens(atom_to_list(Node), [$@]). + string:lexemes(atom_to_list(Node), [$@]). lookup_config(Key,Config) -> case lists:keysearch(Key,1,Config) of diff --git a/lib/mnesia/test/mnesia_test_lib.hrl b/lib/mnesia/test/mnesia_test_lib.hrl index ba7eb10ea2..b8eeb5783f 100644 --- a/lib/mnesia/test/mnesia_test_lib.hrl +++ b/lib/mnesia/test/mnesia_test_lib.hrl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -55,25 +55,25 @@ ?error("Not Matching Actual result was:~n ~p~n",[_AR_0]), {fail,_AR_0} catch - exit:{aborted, _ER_1} when + exit:{aborted, _ER_1}:Stacktrace when element(1, _ER_1) =:= node_not_running; element(1, _ER_1) =:= bad_commit; element(1, _ER_1) =:= cyclic -> %% Need to re-raise these to restart transaction - erlang:raise(exit, {aborted, _ER_1}, erlang:get_stacktrace()); - exit:_AR_1 -> + erlang:raise(exit, {aborted, _ER_1}, Stacktrace); + exit:_AR_1:Stacktrace -> case fun(_AR_EXIT_) -> {'EXIT', _AR_EXIT_} end(_AR_1) of _AR_2 = ExpectedRes -> ?verbose("ok, ~n Result as expected:~p~n",[_AR_2]), {success,_AR_2}; _AR_2 -> ?error("Not Matching Actual result was:~n ~p~n ~p~n", - [_AR_2, erlang:get_stacktrace()]), + [_AR_2, Stacktrace]), {fail,_AR_2} end; - _T1_:_AR_1 -> + _T1_:_AR_1:Stacktrace -> ?error("Not Matching Actual result was:~n ~p~n ~p~n", - [{_T1_,_AR_1}, erlang:get_stacktrace()]), + [{_T1_,_AR_1}, Stacktrace]), {fail,{_T1_,_AR_1}} end end()). diff --git a/lib/mnesia/test/mnesia_trans_access_test.erl b/lib/mnesia/test/mnesia_trans_access_test.erl index 4ed73ea859..723a85fd2c 100644 --- a/lib/mnesia/test/mnesia_trans_access_test.erl +++ b/lib/mnesia/test/mnesia_trans_access_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,28 @@ %% -module(mnesia_trans_access_test). -author('[email protected]'). --compile([export_all]). + +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + all/0, groups/0]). + +-export([write/1, read/1, wread/1, delete/1, delete_object/1, + match_object/1, select/1, select14/1, all_keys/1, transaction/1, + basic_nested/1, mix_of_nested_activities/1, + nested_trans_both_ok/1, nested_trans_child_dies/1, + nested_trans_parent_dies/1, nested_trans_both_dies/1, + index_match_object/1, index_read/1,index_write/1, + index_update_set/1, index_update_bag/1, + add_table_index_ram/1, add_table_index_disc/1, + add_table_index_disc_only/1, create_live_table_index_ram/1, + create_live_table_index_disc/1, + create_live_table_index_disc_only/1, del_table_index_ram/1, + del_table_index_disc/1, del_table_index_disc_only/1, + idx_schema_changes_ram/1, idx_schema_changes_disc/1, + idx_schema_changes_disc_only/1]). + +-export([do_nested/1]). + -include("mnesia_test_lib.hrl"). init_per_testcase(Func, Conf) -> |
