-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4063 from esl/feature/cets
Feature/cets
- Loading branch information
Showing
140 changed files
with
4,018 additions
and
1,817 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
-module(cets_disco_SUITE). | ||
-compile([export_all, nowarn_export_all]). | ||
|
||
-import(distributed_helper, [mim/0, rpc/4]). | ||
-include_lib("common_test/include/ct.hrl"). | ||
|
||
%%-------------------------------------------------------------------- | ||
%% Suite configuration | ||
%%-------------------------------------------------------------------- | ||
|
||
all() -> | ||
[{group, file}, {group, rdbms}]. | ||
|
||
groups() -> | ||
[{file, [], file_cases()}, | ||
{rdbms, [], rdbms_cases()}]. | ||
|
||
file_cases() -> | ||
[file_backend]. | ||
|
||
rdbms_cases() -> | ||
[rdbms_backend]. | ||
|
||
suite() -> | ||
escalus:suite(). | ||
|
||
%%-------------------------------------------------------------------- | ||
%% Init & teardown | ||
%%-------------------------------------------------------------------- | ||
init_per_suite(Config) -> | ||
escalus:init_per_suite(Config). | ||
|
||
end_per_suite(Config) -> | ||
escalus:end_per_suite(Config). | ||
|
||
init_per_group(rdbms, Config) -> | ||
case not ct_helper:is_ct_running() | ||
orelse mongoose_helper:is_rdbms_enabled(domain_helper:host_type()) of | ||
false -> {skip, rdbms_or_ct_not_running}; | ||
true -> Config | ||
end; | ||
init_per_group(_, Config) -> | ||
Config. | ||
|
||
end_per_group(_, Config) -> | ||
Config. | ||
|
||
init_per_testcase(CaseName, Config) -> | ||
escalus:init_per_testcase(CaseName, Config). | ||
|
||
end_per_testcase(CaseName, Config) -> | ||
escalus:end_per_testcase(CaseName, Config). | ||
|
||
%%-------------------------------------------------------------------- | ||
%% Test cases | ||
%%-------------------------------------------------------------------- | ||
|
||
file_backend(Config) -> | ||
Path = filename:join(?config(mim_data_dir, Config), "nodes.txt"), | ||
Opts = #{disco_file => Path}, | ||
State = rpc(mim(), cets_discovery_file, init, [Opts]), | ||
{{ok, Nodes}, _} = rpc(mim(), cets_discovery_file, get_nodes, [State]), | ||
['node1@localhost', 'node2@otherhost'] = lists:sort(Nodes). | ||
|
||
rdbms_backend(_Config) -> | ||
Opts1 = #{cluster_name => <<"big_test">>, node_name_to_insert => <<"test1">>}, | ||
Opts2 = #{cluster_name => <<"big_test">>, node_name_to_insert => <<"test2">>}, | ||
State1 = rpc(mim(), mongoose_cets_discovery_rdbms, init, [Opts1]), | ||
rpc(mim(), mongoose_cets_discovery_rdbms, get_nodes, [State1]), | ||
State2 = rpc(mim(), mongoose_cets_discovery_rdbms, init, [Opts2]), | ||
{{ok, Nodes}, State2_2} = rpc(mim(), mongoose_cets_discovery_rdbms, get_nodes, [State2]), | ||
%% "test2" node can see "test1" | ||
true = lists:member(test1, Nodes), | ||
{{ok, _}, State2_3} = rpc(mim(), mongoose_cets_discovery_rdbms, get_nodes, [State2_2]), | ||
%% Check that we follow the right code branch | ||
#{last_query_info := #{already_registered := true}} = State2_3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node1@localhost | ||
node2@otherhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
-module(graphql_cets_SUITE). | ||
-include_lib("eunit/include/eunit.hrl"). | ||
|
||
-compile([export_all, nowarn_export_all]). | ||
|
||
-import(distributed_helper, [mim/0]). | ||
-import(domain_helper, [host_type/1]). | ||
-import(mongooseimctl_helper, [rpc_call/3]). | ||
-import(graphql_helper, [execute_command/4, get_unauthorized/1, get_ok_value/2]). | ||
|
||
all() -> | ||
[{group, admin_cets_cli}, | ||
{group, admin_cets_http}, | ||
{group, domain_admin_cets}]. | ||
|
||
groups() -> | ||
[{admin_cets_http, [sequence], admin_cets_tests()}, | ||
{admin_cets_cli, [sequence], admin_cets_tests()}, | ||
{domain_admin_cets, [], domain_admin_tests()}]. | ||
|
||
admin_cets_tests() -> | ||
[has_sm_table_in_info]. | ||
|
||
domain_admin_tests() -> | ||
[domain_admin_get_info_test]. | ||
|
||
init_per_suite(Config) -> | ||
Config1 = escalus:init_per_suite(Config), | ||
ejabberd_node_utils:init(mim(), Config1). | ||
|
||
end_per_suite(Config) -> | ||
escalus:end_per_suite(Config). | ||
|
||
init_per_group(admin_cets_http, Config) -> | ||
graphql_helper:init_admin_handler(Config); | ||
init_per_group(admin_cets_cli, Config) -> | ||
graphql_helper:init_admin_cli(Config); | ||
init_per_group(domain_admin_cets, Config) -> | ||
graphql_helper:init_domain_admin_handler(Config). | ||
|
||
end_per_group(_, _Config) -> | ||
graphql_helper:clean(), | ||
escalus_fresh:clean(). | ||
|
||
init_per_testcase(has_sm_table_in_info, Config) -> | ||
case rpc_call(ejabberd_sm, sm_backend, []) of | ||
ejabberd_sm_cets -> | ||
Config; | ||
_ -> | ||
{skip, "SM backend is not CETS"} | ||
end; | ||
init_per_testcase(_, Config) -> | ||
Config. | ||
|
||
% Admin tests | ||
|
||
has_sm_table_in_info(Config) -> | ||
Res = get_info(Config), | ||
Tables = get_ok_value([data, cets, systemInfo], Res), | ||
[T] = [T || T = #{<<"tableName">> := <<"cets_session">>} <- Tables], | ||
#{<<"memory">> := Mem, <<"nodes">> := Nodes, <<"size">> := Size} = T, | ||
true = is_integer(Mem), | ||
true = is_integer(Size), | ||
#{node := Node1} = mim(), | ||
lists:member(Node1, Nodes). | ||
|
||
% Domain admin tests | ||
|
||
domain_admin_get_info_test(Config) -> | ||
get_unauthorized(get_info(Config)). | ||
|
||
%-------------------------------------------------------------------------------------------------- | ||
% Helpers | ||
%-------------------------------------------------------------------------------------------------- | ||
|
||
get_info(Config) -> | ||
execute_command(<<"cets">>, <<"systemInfo">>, #{}, Config). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.