Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
0358-Add-test-to-check-persistence-of-disc_copi...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0358-Add-test-to-check-persistence-of-disc_copies-table-w.patch of Package erlang
From e47ef7c1ec13fbbe26ba3903e41fb3558affc82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=C4=85sowski?= <michal@erlang.org> Date: Mon, 14 Oct 2024 08:25:52 +0200 Subject: [PATCH 2/2] Add test to check persistence of disc_copies table when converting from ext --- lib/mnesia/test/Makefile | 3 +- lib/mnesia/test/mnesia_SUITE.erl | 5 +- .../test/mnesia_external_backend_test.erl | 79 +++++++++++++++++++ lib/mnesia/test/mt.erl | 1 + 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 lib/mnesia/test/mnesia_external_backend_test.erl diff --git a/lib/mnesia/test/Makefile b/lib/mnesia/test/Makefile index c3fbad88ca..9e0f19765a 100644 --- a/lib/mnesia/test/Makefile +++ b/lib/mnesia/test/Makefile @@ -54,7 +54,8 @@ MODULES= \ mnesia_cost \ mnesia_dbn_meters \ ext_test \ - mnesia_index_plugin_test + mnesia_index_plugin_test \ + mnesia_external_backend_test DocExamplesDir := ../doc/src/ diff --git a/lib/mnesia/test/mnesia_SUITE.erl b/lib/mnesia/test/mnesia_SUITE.erl index 123d16023f..9791088227 100644 --- a/lib/mnesia/test/mnesia_SUITE.erl +++ b/lib/mnesia/test/mnesia_SUITE.erl @@ -58,7 +58,7 @@ suite() -> [{ct_hooks,[{ts_install_cth,[{nodenames,2}]}]}]. all() -> [app, appup, {group, light}, {group, medium}, {group, heavy}, - clean_up_suite]. + clean_up_suite, {group, external}]. groups() -> %% The 'light' test suite runs a selected set of test suites and is @@ -123,7 +123,8 @@ groups() -> {mnesia_dirty_access_test, dirty_index_update_set_disc_only}, {mnesia_evil_coverage_test, - create_live_table_index_disc_only}]}]. + create_live_table_index_disc_only}]}, + {external, [], [{mnesia_external_backend_test, all}]}]. init_per_group(_GroupName, Config) -> Config. diff --git a/lib/mnesia/test/mnesia_external_backend_test.erl b/lib/mnesia/test/mnesia_external_backend_test.erl new file mode 100644 index 0000000000..1391be7c88 --- /dev/null +++ b/lib/mnesia/test/mnesia_external_backend_test.erl @@ -0,0 +1,79 @@ +-module(mnesia_external_backend_test). + +-export([init_per_testcase/2, end_per_testcase/2, + init_per_group/2, end_per_group/2, + suite/0, all/0, groups/0]). + +-export([conversion_from_external_to_disc_copies_results_in_data_loss_after_node_restart/1]). + +-include("mnesia_test_lib.hrl"). + +-record(some_rec, {some_id :: atom(), some_int :: number(), some_string :: string()}). + +-define(acquire(N, Config), + mnesia_test_lib:prepare_test_case([{init_test_case, [mnesia]}, + delete_schema], + N, Config, ?FILE, ?LINE)). + +all() -> + [conversion_from_external_to_disc_copies_results_in_data_loss_after_node_restart]. + +groups() -> + []. + +init_per_testcase(Func, Conf) -> + mnesia_test_lib:init_per_testcase(Func, Conf). + +end_per_testcase(Func, Conf) -> + mnesia_test_lib:end_per_testcase(Func, Conf). + +init_per_group(_GroupName, Config) -> + Config. + +end_per_group(_GroupName, Config) -> + Config. + +suite() -> [{ct_hooks,[{ts_install_cth,[{nodenames,1}]}]}]. + +conversion_from_external_to_disc_copies_results_in_data_loss_after_node_restart(Config) when is_list(Config) -> + Node = node(), + Data = [ + #some_rec{some_id = a, some_int = 1, some_string = "something" }, + #some_rec{some_id = b, some_int = 2, some_string = "anything" }, + #some_rec{some_id = c, some_int = 3, some_string = "everything"}, + #some_rec{some_id = d, some_int = 4, some_string = "nothing" } + ], + + [Node] = ?acquire(1, Config), + ok = mnesia:create_schema([Node]), + ok = mnesia:start(), + {atomic, ok} = mnesia:add_backend_type(ext_ets, ext_test), + {atomic, ok} = mnesia:add_backend_type(ext_dets, ext_test), + {atomic, ok} = mnesia:create_table(table, [ + {type, ordered_set}, + {record_name, some_rec}, + {attributes, record_info(fields, some_rec)}, + {disc_copies, [Node]} + ]), + + ok = mnesia:activity(transaction, fun() -> + lists:foreach(fun(Elem) -> mnesia:write(table, Elem, write) end, Data) + end), + + {atomic, ok} = mnesia:change_table_copy_type(table, Node, ext_ets), + Data = mnesia:activity(transaction, fun() -> + mnesia:match_object(table, #some_rec{_ = '_'}, read) end + ), + + {atomic, ok} = mnesia:change_table_copy_type(table, Node, disc_copies), + Data = mnesia:activity(transaction, fun() -> + mnesia:match_object(table, #some_rec{_ = '_'}, read) end + ), + + stopped = mnesia:stop(), + ok = mnesia:start(), + ok = mnesia:wait_for_tables([schema, table], 10000), + + Data = mnesia:activity(transaction, fun() -> + mnesia:match_object(table, #some_rec{_ = '_'}, read) end + ). diff --git a/lib/mnesia/test/mt.erl b/lib/mnesia/test/mt.erl index b5eea30690..06b76f0e64 100644 --- a/lib/mnesia/test/mt.erl +++ b/lib/mnesia/test/mt.erl @@ -68,6 +68,7 @@ alias(registry) -> mnesia_registry_test; alias(suite) -> mnesia_SUITE; alias(trans) -> mnesia_trans_access_test; alias(ixp) -> mnesia_index_plugin_test; +alias(external) -> mnesia_external_backend_test; alias(Other) -> Other. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- 2.43.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor