Skip to content

Commit f3e5169

Browse files
committed
Apply Ra commands on different nodes
This commit adds a property test that applies the same Ra commands in the same order on two different Erlang nodes. The state in which both nodes end up should be exactly the same. Ideally, the two nodes should run different OTP versions because this way we could test for any non-determinism across OTP versions. However, for now, having a test with both nodes having the same OTP verison is good enough because running this test with rabbit_fifo machine version 5 fails while machine version 6 succeeds. This reveales another interesting: The default "undefined" map order can even be different using different Erlang nodes with the **same** OTP version.
1 parent 62cbb98 commit f3e5169

File tree

1 file changed

+71
-4
lines changed

1 file changed

+71
-4
lines changed

deps/rabbit/test/rabbit_fifo_prop_SUITE.erl

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
-compile(nowarn_export_all).
44
-compile(export_all).
55

6-
-export([
7-
]).
8-
96
-include_lib("proper/include/proper.hrl").
107
-include_lib("common_test/include/ct.hrl").
118
-include_lib("eunit/include/eunit.hrl").
@@ -87,7 +84,8 @@ all_tests() ->
8784
dlx_07,
8885
dlx_08,
8986
dlx_09,
90-
single_active_ordering_02
87+
single_active_ordering_02,
88+
different_nodes
9189
].
9290

9391
groups() ->
@@ -1095,6 +1093,39 @@ single_active_ordering_03(_Config) ->
10951093
false
10961094
end.
10971095

1096+
%% Test that running the state machine commands on different Erlang nodes
1097+
%% end up in exactly the same state.
1098+
different_nodes(Config) ->
1099+
Config1 = rabbit_ct_helpers:run_setup_steps(
1100+
Config,
1101+
rabbit_ct_broker_helpers:setup_steps()),
1102+
1103+
Size = 400,
1104+
run_proper(
1105+
fun () ->
1106+
?FORALL({Length, Bytes, DeliveryLimit, SingleActive},
1107+
frequency([{5, {undefined, undefined, undefined, false}},
1108+
{5, {oneof([range(1, 10), undefined]),
1109+
oneof([range(1, 1000), undefined]),
1110+
oneof([range(1, 3), undefined]),
1111+
oneof([true, false])
1112+
}}]),
1113+
begin
1114+
Conf = config(?FUNCTION_NAME,
1115+
Length,
1116+
Bytes,
1117+
SingleActive,
1118+
DeliveryLimit),
1119+
?FORALL(O, ?LET(Ops, log_gen_different_nodes(Size), expand(Ops, Conf)),
1120+
collect({log_size, length(O)},
1121+
different_nodes_prop(Config1, Conf, O)))
1122+
end)
1123+
end, [], Size),
1124+
1125+
rabbit_ct_helpers:run_teardown_steps(
1126+
Config1,
1127+
rabbit_ct_broker_helpers:teardown_steps()).
1128+
10981129
max_length(_Config) ->
10991130
%% tests that max length is never transgressed
11001131
Size = 1000,
@@ -1454,6 +1485,19 @@ single_active_prop(Conf0, Commands, ValidateOrder) ->
14541485
false
14551486
end.
14561487

1488+
different_nodes_prop(Config, Conf0, Commands) ->
1489+
Conf = Conf0#{release_cursor_interval => 100},
1490+
Indexes = lists:seq(1, length(Commands)),
1491+
Entries = lists:zip(Indexes, Commands),
1492+
InitState = test_init(Conf),
1493+
Fun = fun(_) -> true end,
1494+
Vsn = 6,
1495+
1496+
{State0, _Effs0} = run_log(InitState, Entries, Fun, Vsn),
1497+
{State1, _Effs1} = rabbit_ct_broker_helpers:rpc(Config, ?MODULE, run_log,
1498+
[InitState, Entries, Fun, Vsn]),
1499+
State0 =:= State1.
1500+
14571501
messages_total_prop(Conf0, Commands) ->
14581502
Conf = Conf0#{release_cursor_interval => 100},
14591503
Indexes = lists:seq(1, length(Commands)),
@@ -1797,6 +1841,29 @@ log_gen_without_checkout_cancel(Size) ->
17971841
{1, purge}
17981842
]))))).
17991843

1844+
log_gen_different_nodes(Size) ->
1845+
Nodes = [node(),
1846+
fakenode@fake,
1847+
fakenode@fake2
1848+
],
1849+
?LET(EPids, vector(4, pid_gen(Nodes)),
1850+
?LET(CPids, vector(4, pid_gen(Nodes)),
1851+
resize(Size,
1852+
list(
1853+
frequency(
1854+
[{10, enqueue_gen(oneof(EPids))},
1855+
{20, {input_event,
1856+
frequency([{10, settle},
1857+
{2, return},
1858+
{2, discard},
1859+
{2, requeue}])}},
1860+
{8, checkout_gen(oneof(CPids))},
1861+
{2, checkout_cancel_gen(oneof(CPids))},
1862+
{6, down_gen(oneof(EPids ++ CPids))},
1863+
{6, nodeup_gen(Nodes)},
1864+
{1, purge}
1865+
]))))).
1866+
18001867
monotonic_gen() ->
18011868
?LET(_, integer(), erlang:unique_integer([positive, monotonic])).
18021869

0 commit comments

Comments
 (0)