Skip to content

Commit 344108f

Browse files
Merge pull request #4245 from esl/cets_persistent_cluster_id
Fix starting cets for persistent_cluster_id
2 parents 0f5700b + 51a380e commit 344108f

File tree

5 files changed

+127
-68
lines changed

5 files changed

+127
-68
lines changed

Diff for: big_tests/tests/ejabberd_node_utils.erl

+26-5
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
-export([init/1, init/2,
2020
node_cwd/2,
2121
restart_application/1, restart_application/2,
22+
ensure_started_application/1, ensure_started_application/2,
2223
call_fun/3, call_fun/4,
2324
call_ctl/2, call_ctl/3,
2425
call_ctl_with_args/3,
2526
file_exists/1, file_exists/2,
2627
backup_config_file/1, backup_config_file/2,
2728
restore_config_file/1, restore_config_file/2,
2829
modify_config_file/2, modify_config_file/4,
30+
replace_config_file/1, replace_config_file/2,
2931
get_cwd/2]).
3032

3133
-include_lib("common_test/include/ct.hrl").
@@ -73,9 +75,18 @@ restart_application(ApplicationName) ->
7375

7476
-spec restart_application(node(), atom()) -> ok.
7577
restart_application(Node, ApplicationName) ->
76-
ok = ejabberd_node_utils:call_fun(Node, application, stop, [ApplicationName]),
77-
ok = ejabberd_node_utils:call_fun(Node, application, start, [ApplicationName]).
78+
ok = call_fun(Node, application, stop, [ApplicationName]),
79+
ok = call_fun(Node, application, start, [ApplicationName]).
7880

81+
-spec ensure_started_application(atom()) -> ok.
82+
ensure_started_application(ApplicationName) ->
83+
Node = distributed_helper:mim(),
84+
ensure_started_application(Node#{timeout => timer:seconds(30)}, ApplicationName).
85+
86+
-spec ensure_started_application(node(), atom()) -> ok.
87+
ensure_started_application(Node, ApplicationName) ->
88+
call_fun(Node, application, stop, [ApplicationName]),
89+
ok = call_fun(Node, application, start, [ApplicationName]).
7990

8091
-spec backup_config_file(ct_config()) -> ct_config().
8192
backup_config_file(Config) ->
@@ -166,7 +177,17 @@ modify_config_file(Host, VarsToChange, Config, Format) ->
166177

167178
RPCSpec = distributed_helper:Host(),
168179
NewCfgPath = update_config_path(RPCSpec, Format),
169-
ok = ejabberd_node_utils:call_fun(RPCSpec, file, write_file, [NewCfgPath, TemplatedConfig]).
180+
ok = call_fun(RPCSpec, file, write_file, [NewCfgPath, TemplatedConfig]).
181+
182+
-spec replace_config_file(binary()) -> ok.
183+
replace_config_file(TomlContent) ->
184+
Node = distributed_helper:mim(),
185+
replace_config_file(Node, TomlContent).
186+
187+
-spec replace_config_file(distributed_helper:node_spec(), binary()) -> ok.
188+
replace_config_file(RPCSpec, TomlContent) ->
189+
NewCfgPath = update_config_path(RPCSpec, toml),
190+
ok = call_fun(RPCSpec, file, write_file, [NewCfgPath, TomlContent]).
170191

171192
read_vars(File) ->
172193
{ok, Terms} = file:consult(File),
@@ -204,10 +225,10 @@ update_config_path(RPCSpec, Format) ->
204225
end.
205226

206227
get_config_path(RPCSpec) ->
207-
ejabberd_node_utils:call_fun(RPCSpec, os, getenv, ["EJABBERD_CONFIG_PATH"]).
228+
call_fun(RPCSpec, os, getenv, ["EJABBERD_CONFIG_PATH"]).
208229

209230
set_config_path(RPCSpec, Path) ->
210-
ejabberd_node_utils:call_fun(RPCSpec, os, putenv, ["EJABBERD_CONFIG_PATH", Path]).
231+
call_fun(RPCSpec, os, putenv, ["EJABBERD_CONFIG_PATH", Path]).
211232

212233
vars_file(toml) -> "vars-toml.config".
213234

Diff for: big_tests/tests/persistent_cluster_id_SUITE.erl

+35-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
%% test cases
1818
-export([
19+
can_start_with_cluster_id_in_cets_only/1,
1920
all_nodes_in_the_cluster_have_the_same_cluster_id/1,
2021
id_persists_after_restart/1,
2122
same_cluster_id_in_backend_and_mnesia/1,
@@ -30,6 +31,7 @@
3031

3132
all() ->
3233
[
34+
{group, cets},
3335
{group, mnesia},
3436
{group, rdbms}
3537
].
@@ -46,6 +48,7 @@ tests() ->
4648

4749
groups() ->
4850
[
51+
{cets, [], [can_start_with_cluster_id_in_cets_only]},
4952
{mnesia, [], [all_nodes_in_the_cluster_have_the_same_cluster_id]},
5053
{rdbms, [], tests()}
5154
].
@@ -65,15 +68,21 @@ end_per_suite(_Config) ->
6568
group(_Groupname) ->
6669
[].
6770

68-
init_per_group(mnesia, Config) ->
69-
case not mongoose_helper:is_rdbms_enabled(host_type()) of
71+
init_per_group(rdbms, Config) ->
72+
case mongoose_helper:is_rdbms_enabled(host_type()) of
7073
true -> Config;
74+
false -> {skip, require_rdbms}
75+
end;
76+
init_per_group(_, Config) ->
77+
case not mongoose_helper:is_rdbms_enabled(host_type()) of
78+
true ->
79+
Config;
7180
false -> {skip, require_no_rdbms}
7281
end;
73-
init_per_group(_Groupname, Config) ->
74-
case mongoose_helper:is_rdbms_enabled(host_type()) of
82+
init_per_group(mnesia, Config) ->
83+
case not mongoose_helper:is_rdbms_enabled(host_type()) of
7584
true -> Config;
76-
false -> {skip, require_rdbms}
85+
false -> {skip, require_no_rdbms}
7786
end.
7887

7988
end_per_group(_Groupname, _Config) ->
@@ -82,12 +91,19 @@ end_per_group(_Groupname, _Config) ->
8291
%%%===================================================================
8392
%%% Testcase specific setup/teardown
8493
%%%===================================================================
94+
init_per_testcase(can_start_with_cluster_id_in_cets_only, Config) ->
95+
Config1 = ejabberd_node_utils:init(Config),
96+
ejabberd_node_utils:backup_config_file(Config1),
97+
Config1;
8598
init_per_testcase(all_nodes_in_the_cluster_have_the_same_cluster_id, Config) ->
8699
distributed_helper:add_node_to_cluster(mim2(), Config),
87100
Config;
88101
init_per_testcase(_TestCase, Config) ->
89102
Config.
90103

104+
end_per_testcase(can_start_with_cluster_id_in_cets_only, Config) ->
105+
ejabberd_node_utils:restore_config_file(Config),
106+
ejabberd_node_utils:ensure_started_application(mongooseim);
91107
end_per_testcase(all_nodes_in_the_cluster_have_the_same_cluster_id, Config) ->
92108
distributed_helper:remove_node_from_cluster(mim2(), Config),
93109
Config;
@@ -97,6 +113,20 @@ end_per_testcase(_TestCase, _Config) ->
97113
%%%===================================================================
98114
%%% Individual Test Cases (from groups() definition)
99115
%%%===================================================================
116+
117+
can_start_with_cluster_id_in_cets_only(_Config) ->
118+
Toml = "[general]
119+
hosts = [\"example.com\"]
120+
default_server_domain = \"example.com\"
121+
sm_backend = \"cets\"
122+
s2s_backend = \"cets\"
123+
component_backend = \"cets\"
124+
[internal_databases.cets]
125+
backend = \"file\"
126+
node_list_file = \"etc/cets_disco.txt\"",
127+
ejabberd_node_utils:replace_config_file(Toml),
128+
ejabberd_node_utils:restart_application(mongooseim).
129+
100130
all_nodes_in_the_cluster_have_the_same_cluster_id(_Config) ->
101131
{ok, ID_mim1} = mongoose_helper:successful_rpc(
102132
mim(), mongoose_cluster_id, get_cached_cluster_id, []),

Diff for: doc/authentication-methods/dummy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ where `Base` is `base_time` and `Variance` is `variance`, as configured below.
2828

2929
```toml
3030
[auth.dummy]
31-
base = 5
31+
base_time = 5
3232
variance = 10
3333
```

Diff for: rel/files/mongooseim

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ EJABBERD_STATUS_PATH="{{mongooseim_status_dir}}/status"
1818
export EJABBERD_STATUS_PATH="$EJABBERD_STATUS_PATH"
1919

2020
EJABBERD_SO_PATH=`ls -dt "$RUNNER_BASE_DIR"/lib/mongooseim-*/priv/lib | head -1`
21-
EJABBERD_CONFIG_PATH="$RUNNER_ETC_DIR"/mongooseim.${MONGOOSEIM_CONFIG_FORMAT:-toml}
21+
EJABBERD_CONFIG_PATH=${EJABBERD_CONFIG_PATH:-$RUNNER_ETC_DIR/mongooseim.${MONGOOSEIM_CONFIG_FORMAT:-toml}}
2222
export EJABBERD_SO_PATH
2323
export EJABBERD_CONFIG_PATH
2424

0 commit comments

Comments
 (0)