Skip to content

Commit 8c63877

Browse files
committed
Reuse node per group to make the test faster
1 parent 1c9f3e8 commit 8c63877

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

deps/rabbit/test/node_initial_run_SUITE.erl

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,32 @@ end_per_suite(Config) ->
4646
rabbit_ct_helpers:run_teardown_steps(Config).
4747

4848
init_per_group(Groupname, Config) ->
49-
rabbit_ct_helpers:set_config(Config, [
50-
{metadata_store, meta_store(Groupname)},
51-
{rmq_nodes_clustered, false},
52-
{rmq_nodename_suffix, Groupname},
53-
{rmq_nodes_count, 1}
54-
]).
55-
56-
end_per_group(_, Config) ->
57-
Config.
58-
59-
init_per_testcase(Testcase, Config) ->
60-
rabbit_ct_helpers:testcase_started(Config, Testcase),
61-
Config0 = maybe_enable_verify_initial_run(Config, Testcase),
49+
Config0 = rabbit_ct_helpers:set_config(Config, [
50+
{metadata_store, meta_store(Groupname)},
51+
{rmq_nodes_clustered, false},
52+
{rmq_nodename_suffix, Groupname},
53+
{rmq_nodes_count, 1}
54+
]),
6255
rabbit_ct_helpers:run_steps(
6356
Config0,
6457
rabbit_ct_broker_helpers:setup_steps() ++
6558
rabbit_ct_client_helpers:setup_steps()
6659
).
6760

68-
end_per_testcase(Testcase, Config) ->
69-
Config1 = rabbit_ct_helpers:run_steps(
61+
62+
end_per_group(_, Config) ->
63+
rabbit_ct_helpers:run_steps(
7064
Config,
7165
rabbit_ct_client_helpers:teardown_steps() ++
7266
rabbit_ct_broker_helpers:teardown_steps()
73-
),
74-
rabbit_ct_helpers:testcase_finished(Config1, Testcase).
67+
).
68+
69+
init_per_testcase(Testcase, Config) ->
70+
rabbit_ct_helpers:testcase_started(Config, Testcase),
71+
Config.
72+
73+
end_per_testcase(Testcase, Config) ->
74+
rabbit_ct_helpers:testcase_finished(Config, Testcase).
7575

7676
%% -------------------------------------------------------------------
7777
%% Test cases
@@ -86,6 +86,7 @@ verify_initial_run_disabled(Config) ->
8686

8787
% Restarting the node should work fine
8888
ok = stop_app(Config),
89+
set_env(Config, false),
8990
ok = start_app(Config),
9091
% Still no marker file
9192
?assertNot(filelib:is_file(MarkerFile)),
@@ -95,11 +96,16 @@ verify_initial_run_enabled(Config) ->
9596
DataDir = rabbit_ct_broker_helpers:get_node_config(Config, 0, data_dir),
9697
MarkerFile = filename:join(DataDir, "node_initialized.marker"),
9798

99+
100+
ok = stop_app(Config),
101+
set_env(Config, true),
102+
ok = start_app(Config),
98103
% Setting is enabled so marker file should be present after initial startup
99104
?assert(filelib:is_file(MarkerFile)),
100105

101106
% Restarting the node should be fine, as there is a marker file
102107
% and corresponding schema data (consistent state)
108+
103109
ok = stop_app(Config),
104110
ok = start_app(Config),
105111

@@ -158,3 +164,7 @@ schema_file(Config) ->
158164
NodeName = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
159165
filename:join([DataDir, "coordination", NodeName, "names.dets"])
160166
end.
167+
168+
set_env(Config, Bool) ->
169+
Node = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
170+
ok = rpc:call(Node, application, set_env, [rabbit, verify_initial_run, Bool]).

0 commit comments

Comments
 (0)