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
@@ -152,6 +169,95 @@ is_prefetch_limited(ServerCh) ->
152
169
LimiterState = element (3 , ChState ),
153
170
element (3 , LimiterState ).
154
171
172
+ % % -------------------------------------------------------------------
173
+ % % RAM node type.
174
+ % % -------------------------------------------------------------------
175
+
176
+ join_when_ram_node_type_is_permitted_by_default (Config ) ->
177
+ [NodeA , NodeB ] = rabbit_ct_broker_helpers :get_node_configs (
178
+ Config , nodename ),
179
+
180
+ ok = rabbit_control_helper :command (stop_app , NodeA ),
181
+ ok = rabbit_control_helper :command_with_output (
182
+ join_cluster , NodeA ,
183
+ [atom_to_list (NodeB )], [{" --ram" , true }]),
184
+ ok = rabbit_control_helper :command (start_app , NodeA ),
185
+
186
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeA )),
187
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeB )),
188
+ ? assertEqual ([NodeB ], get_disc_nodes (Config , NodeA )),
189
+ ? assertEqual ([NodeB ], get_disc_nodes (Config , NodeB )),
190
+
191
+ ? assert (
192
+ log_file_contains_message (
193
+ Config , NodeA ,
194
+ [" Deprecated features: `ram_node_type`: Feature `ram_node_type` is deprecated" ,
195
+ " By default, this feature can still be used for now." ])),
196
+
197
+ % % Change the advanced configuration file to turn off RAM node type.
198
+ ConfigFilename0 = rabbit_ct_broker_helpers :get_node_config (
199
+ Config , NodeA , erlang_node_config_filename ),
200
+ ConfigFilename = ConfigFilename0 ++ " .config" ,
201
+ {ok , [ConfigContent0 ]} = file :consult (ConfigFilename ),
202
+ ConfigContent1 = rabbit_ct_helpers :merge_app_env_in_erlconf (
203
+ ConfigContent0 ,
204
+ {rabbit , [{permit_deprecated_features ,
205
+ #{ram_node_type => false }}]}),
206
+ ConfigContent2 = lists :flatten (io_lib :format (" ~p .~n " , [ConfigContent1 ])),
207
+ ok = file :write_file (ConfigFilename , ConfigContent2 ),
208
+ ? assertEqual ({ok , [ConfigContent1 ]}, file :consult (ConfigFilename )),
209
+
210
+ % % Restart the node and see if it was correctly converted to a disc node.
211
+ ok = rabbit_control_helper :command (stop_app , NodeA ),
212
+ Ret = rabbit_control_helper :command (start_app , NodeA ),
213
+
214
+ case Ret of
215
+ ok ->
216
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeA )),
217
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeB )),
218
+ ? assertEqual ([NodeA , NodeB ], get_disc_nodes (Config , NodeA )),
219
+ ? assertEqual ([NodeA , NodeB ], get_disc_nodes (Config , NodeB ));
220
+ {error , 69 ,
221
+ <<" Error:\n {:rabbit, {:incompatible_feature_flags, " , _ /binary >>} ->
222
+ {skip , " Incompatible feature flags between nodes A and B" }
223
+ end .
224
+
225
+ join_when_ram_node_type_is_not_permitted_from_conf (Config ) ->
226
+ [NodeA , NodeB ] = rabbit_ct_broker_helpers :get_node_configs (
227
+ Config , nodename ),
228
+
229
+ ok = rabbit_control_helper :command (stop_app , NodeA ),
230
+ Ret = rabbit_control_helper :command_with_output (
231
+ join_cluster , NodeA ,
232
+ [atom_to_list (NodeB )], [{" --ram" , true }]),
233
+ case Ret of
234
+ ok ->
235
+ ok = rabbit_control_helper :command (start_app , NodeA ),
236
+
237
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeA )),
238
+ ? assertEqual ([NodeA , NodeB ], get_all_nodes (Config , NodeB )),
239
+ ? assertEqual ([NodeA , NodeB ], get_disc_nodes (Config , NodeA )),
240
+ ? assertEqual ([NodeA , NodeB ], get_disc_nodes (Config , NodeB )),
241
+
242
+ ? assert (
243
+ log_file_contains_message (
244
+ Config , NodeA ,
245
+ [" Deprecated features: `ram_node_type`: Feature `ram_node_type` is deprecated" ,
246
+ " Its use is not permitted per the configuration" ]));
247
+ {error , 69 , <<" Error:\n incompatible_feature_flags" >>} ->
248
+ {skip , " Incompatible feature flags between nodes A and B" }
249
+ end .
250
+
251
+ get_all_nodes (Config , Node ) ->
252
+ lists :sort (
253
+ rabbit_ct_broker_helpers :rpc (
254
+ Config , Node , rabbit_mnesia , cluster_nodes , [all ])).
255
+
256
+ get_disc_nodes (Config , Node ) ->
257
+ lists :sort (
258
+ rabbit_ct_broker_helpers :rpc (
259
+ Config , Node , rabbit_mnesia , cluster_nodes , [disc ])).
260
+
155
261
% % -------------------------------------------------------------------
156
262
% % Helpers.
157
263
% % -------------------------------------------------------------------
0 commit comments