23
23
end_per_testcase /2 ,
24
24
25
25
when_global_qos_is_permitted_by_default /1 ,
26
- when_global_qos_is_not_permitted_from_conf /1
26
+ when_global_qos_is_not_permitted_from_conf /1 ,
27
+
28
+ join_when_ram_node_type_is_permitted_by_default /1 ,
29
+ join_when_ram_node_type_is_not_permitted_from_conf /1
27
30
]).
28
31
29
32
suite () ->
30
33
[{timetrap , {minutes , 5 }}].
31
34
32
35
all () ->
33
36
[
34
- {group , global_qos }
37
+ {group , global_qos },
38
+ {group , ram_node_type }
35
39
].
36
40
37
41
groups () ->
38
42
[
39
43
{global_qos , [],
40
44
[when_global_qos_is_permitted_by_default ,
41
- when_global_qos_is_not_permitted_from_conf ]}
45
+ when_global_qos_is_not_permitted_from_conf ]},
46
+ {ram_node_type , [],
47
+ [join_when_ram_node_type_is_permitted_by_default ,
48
+ join_when_ram_node_type_is_not_permitted_from_conf ]}
42
49
].
43
50
44
51
% % -------------------------------------------------------------------
@@ -57,6 +64,9 @@ end_per_suite(Config) ->
57
64
58
65
init_per_group (global_qos , Config ) ->
59
66
rabbit_ct_helpers :set_config (Config , {rmq_nodes_count , 1 });
67
+ init_per_group (ram_node_type , Config ) ->
68
+ rabbit_ct_helpers :set_config (Config , [{rmq_nodes_count , 2 },
69
+ {rmq_nodes_clustered , false }]);
60
70
init_per_group (_Group , Config ) ->
61
71
Config .
62
72
@@ -70,6 +80,13 @@ init_per_testcase(
70
80
{rabbit ,
71
81
[{permit_deprecated_features , #{global_qos => false }}]}),
72
82
init_per_testcase1 (Testcase , Config1 );
83
+ init_per_testcase (
84
+ join_when_ram_node_type_is_not_permitted_from_conf = Testcase , Config ) ->
85
+ Config1 = rabbit_ct_helpers :merge_app_env (
86
+ Config ,
87
+ {rabbit ,
88
+ [{permit_deprecated_features , #{ram_node_type => false }}]}),
89
+ init_per_testcase1 (Testcase , Config1 );
73
90
init_per_testcase (Testcase , Config ) ->
74
91
init_per_testcase1 (Testcase , Config ).
75
92
@@ -139,3 +156,80 @@ is_prefetch_limited(ServerCh) ->
139
156
ct :pal (" Server channel (~p ) state: ~p " , [ServerCh , ChState ]),
140
157
LimiterState = element (3 , ChState ),
141
158
element (3 , LimiterState ).
159
+
160
+ % % -------------------------------------------------------------------
161
+ % % RAM node type.
162
+ % % -------------------------------------------------------------------
163
+
164
+ join_when_ram_node_type_is_permitted_by_default (Config ) ->
165
+ [NodeA , NodeB ] = rabbit_ct_broker_helpers :get_node_configs (
166
+ Config , nodename ),
167
+
168
+ ok = rabbit_control_helper :command (stop_app , NodeA ),
169
+ ok = rabbit_control_helper :command_with_output (
170
+ join_cluster , NodeA ,
171
+ [atom_to_list (NodeB )], [{" --ram" , true }]),
172
+ ok = rabbit_control_helper :command (start_app , NodeA ),
173
+
174
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeA )),
175
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeB )),
176
+ ? assertEqual ([NodeB ], get_disc_nodes (Config , NodeA )),
177
+ ? assertEqual ([NodeB ], get_disc_nodes (Config , NodeB )),
178
+
179
+ % % Change the advanced configuration file to turn off RAM node type.
180
+ ConfigFilename0 = rabbit_ct_broker_helpers :get_node_config (
181
+ Config , NodeA , erlang_node_config_filename ),
182
+ ConfigFilename = ConfigFilename0 ++ " .config" ,
183
+ {ok , [ConfigContent0 ]} = file :consult (ConfigFilename ),
184
+ ConfigContent1 = rabbit_ct_helpers :merge_app_env_in_erlconf (
185
+ ConfigContent0 ,
186
+ {rabbit , [{permit_deprecated_features ,
187
+ #{ram_node_type => false }}]}),
188
+ ConfigContent2 = lists :flatten (io_lib :format (" ~p .~n " , [ConfigContent1 ])),
189
+ ok = file :write_file (ConfigFilename , ConfigContent2 ),
190
+ ? assertEqual ({ok , [ConfigContent1 ]}, file :consult (ConfigFilename )),
191
+
192
+ % % Restart the node and see if it was correctly converted to a disc node.
193
+ ok = rabbit_control_helper :command (stop_app , NodeA ),
194
+ Ret = rabbit_control_helper :command (start_app , NodeA ),
195
+
196
+ case Ret of
197
+ ok ->
198
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeA )),
199
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeB )),
200
+ ? assertEqual ([NodeA , NodeB ], get_disc_nodes (Config , NodeA )),
201
+ ? assertEqual ([NodeA , NodeB ], get_disc_nodes (Config , NodeB ));
202
+ {error , 69 ,
203
+ <<" Error:\n {:rabbit, {:incompatible_feature_flags, " , _ /binary >>} ->
204
+ {skip , " Incompatible feature flags between nodes A and B" }
205
+ end .
206
+
207
+ join_when_ram_node_type_is_not_permitted_from_conf (Config ) ->
208
+ [NodeA , NodeB ] = rabbit_ct_broker_helpers :get_node_configs (
209
+ Config , nodename ),
210
+
211
+ ok = rabbit_control_helper :command (stop_app , NodeA ),
212
+ Ret = rabbit_control_helper :command_with_output (
213
+ join_cluster , NodeA ,
214
+ [atom_to_list (NodeB )], [{" --ram" , true }]),
215
+ case Ret of
216
+ ok ->
217
+ ok = rabbit_control_helper :command (start_app , NodeA ),
218
+
219
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeA )),
220
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeB )),
221
+ ? assertEqual ([NodeA , NodeB ], get_disc_nodes (Config , NodeA )),
222
+ ? assertEqual ([NodeA , NodeB ], get_disc_nodes (Config , NodeB ));
223
+ {error , 69 , <<" Error:\n incompatible_feature_flags" >>} ->
224
+ {skip , " Incompatible feature flags between nodes A and B" }
225
+ end .
226
+
227
+ get_all_nodes (Config , Node ) ->
228
+ lists :sort (
229
+ rabbit_ct_broker_helpers :rpc (
230
+ Config , Node , rabbit_mnesia , cluster_nodes , [all ])).
231
+
232
+ get_disc_nodes (Config , Node ) ->
233
+ lists :sort (
234
+ rabbit_ct_broker_helpers :rpc (
235
+ Config , Node , rabbit_mnesia , cluster_nodes , [disc ])).
0 commit comments