Skip to content

Commit c4beb62

Browse files
committed
test: Add a testcase verifying full cluster restart
1 parent efccc2d commit c4beb62

1 file changed

Lines changed: 44 additions & 2 deletions

File tree

test/mria_SUITE.erl

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%%--------------------------------------------------------------------
2-
%% Copyright (c) 2019-2025 EMQ Technologies Co., Ltd. All Rights Reserved.
2+
%% Copyright (c) 2019-2026 EMQ Technologies Co., Ltd. All Rights Reserved.
33
%%
44
%% Licensed under the Apache License, Version 2.0 (the "License");
55
%% you may not use this file except in compliance with the License.
@@ -1234,7 +1234,49 @@ t_cluster_nodes(_) ->
12341234
end,
12351235
[]).
12361236

1237-
schema_merge(_) -> %% TODO: this is a testcase, enable it after merging the patch to OTP
1237+
%% This testcase verifies that nodes don't get stuck waiting for each
1238+
%% other during a full cluster restart. To make things realistic, this
1239+
%% testcase creates a wait chain of tables, where creation of one
1240+
%% table depends on waiting for another.
1241+
t_full_cluster_restart(_) ->
1242+
Cluster = mria_ct:cluster([core, core, core], mria_mnesia_test_util:common_env()),
1243+
?check_trace(
1244+
#{timetrap => 30_000},
1245+
try
1246+
Nodes = [N1, N2, N3] = mria_ct:start_cluster(mria, Cluster),
1247+
OK = [{ok, ok}, {ok, ok}, {ok, ok}],
1248+
OK = erpc:multicall(Nodes, ?MODULE, full_restart_load_chain, [], infinity),
1249+
%% Write some data:
1250+
ok = ?ON(N1, mria:dirty_write(tab1, {tab1, foo, bar})),
1251+
ok = ?ON(N2, mria:dirty_write(tab2, {tab2, foo, bar})),
1252+
ok = ?ON(N3, mria:dirty_write(tab3, {tab3, foo, bar})),
1253+
%% Restart nodes simulataneously:
1254+
?tp(notice, test_restart_nodes, #{}),
1255+
[ok = slave:stop(N) || N <- Nodes],
1256+
[mria_ct:start_slave(mria, CN) || CN <- Cluster],
1257+
%% Restart the chain:
1258+
OK = erpc:multicall(Nodes, ?MODULE, full_restart_load_chain, [], infinity),
1259+
ok
1260+
after
1261+
ok = mria_ct:teardown_cluster(Cluster)
1262+
end,
1263+
[]).
1264+
1265+
%% This function creates an an inter-dependent table load order that
1266+
%% simulates startup sequence of a release containing multiple OTP
1267+
%% applications with complex dependencies:
1268+
full_restart_load_chain() ->
1269+
ok = mria:create_table(tab1, [{storage, disc_copies}, {rlog_shard, shard1}]),
1270+
ok = mria:wait_for_tables([tab1]),
1271+
?tp(notice, test_tab1_loaded, #{node => node()}),
1272+
ok = mria:create_table(tab2, [{storage, disc_copies}, {rlog_shard, shard2}]),
1273+
ok = mria:wait_for_tables([tab2]),
1274+
?tp(notice, test_tab2_loaded, #{node => node()}),
1275+
ok = mria:create_table(tab3, [{storage, disc_copies}, {rlog_shard, shard3}]),
1276+
ok = mria:wait_for_tables([tab3]),
1277+
?tp(notice, test_all_loaded, #{node => node()}).
1278+
1279+
t_schema_merge(_) ->
12381280
Cluster = [C1, C2, C3] = mria_ct:cluster([core, core, core], mria_mnesia_test_util:common_env()),
12391281
?check_trace(
12401282
#{timetrap => 30000},

0 commit comments

Comments
 (0)