Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Feature/cets into master #4063

Merged
merged 175 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
9816787
Add ejabberd_sm_cets
arcusfelis Feb 22, 2022
839e606
Use mongoose_cleaner for mod_stream_management_cets
arcusfelis Apr 19, 2022
726f361
Update cets
arcusfelis May 6, 2022
e4c0bff
Add a note about partially bound key select
arcusfelis May 18, 2022
50f8ece
Make start_common function with common logic
arcusfelis Mar 21, 2023
195bb47
Remove cets_info
arcusfelis Mar 22, 2023
0482533
Clean SM state locally
arcusfelis Mar 29, 2023
76e7703
Remove long comment from create_session function
arcusfelis Mar 29, 2023
279d9c7
Update CETS
arcusfelis Mar 29, 2023
49f4ac7
Add callback to stop cleaner in mod_stream_management
arcusfelis Mar 30, 2023
a360ccd
Upgrade cets with dialyzer fix
arcusfelis Mar 30, 2023
3a34358
Remove cets_tables_are_in_mnesia_info testcase
arcusfelis Mar 31, 2023
e71c329
Expect two or three nodes in graphql_metric_SUITE:get_cluster_metrics…
arcusfelis Mar 31, 2023
7c522ef
Fix error formatting in rest_helper
arcusfelis Mar 31, 2023
09d95f0
Add GraphQL handler for CETS info
arcusfelis Apr 25, 2023
588f4c4
Patch ejabberd_sm_cets to work with new SM API
arcusfelis Apr 28, 2023
2a88080
Use pgsql in cets preset
arcusfelis May 10, 2023
205d997
Add CETS disco backend with pgsql support
arcusfelis May 10, 2023
74b679e
Allow to configure cluster_name
arcusfelis May 15, 2023
86bc534
Add discovery_nodes table for mysql/mssql
arcusfelis May 15, 2023
fce3b67
Enable PgSQL for pgsql_cets preset on CircleCI
arcusfelis May 15, 2023
9799dbd
add cluster_name into opts spec
arcusfelis May 15, 2023
5082295
Fix primary key in schema
arcusfelis May 15, 2023
309c09c
Update config_parser_SUITE with new internal_databases option
arcusfelis May 15, 2023
6a813cc
Update load_from_file test
arcusfelis May 15, 2023
7e4dfc2
Add tests for cets disco (unit big tests)
arcusfelis May 16, 2023
7c0e0ec
Make internal_databases block explicit
arcusfelis May 22, 2023
058c188
Docs for internal databases block
arcusfelis May 22, 2023
40bcaca
Remove default value for nodelist_file
arcusfelis May 25, 2023
712a164
Fix review comments
arcusfelis May 25, 2023
89bb2bd
Merge pull request #4022 from esl/mu-cets-rdbms5
chrzaszcz May 26, 2023
bd40df4
Add node_id for discovery_nodes table
arcusfelis Jun 21, 2023
5bbe39a
Start Mnesia based on config
arcusfelis Jun 21, 2023
33c8487
Use mongoose_start_node_id in ejabberd_local
arcusfelis Jun 21, 2023
7ba1f5e
Start CETS after outgoing pools
arcusfelis Jun 21, 2023
58fd64a
Implement mongoose_start_node_id
arcusfelis Jun 21, 2023
fd76743
Make mnesia an included application
arcusfelis Jun 21, 2023
f69dfda
Still start mnesia in pgsql_cets preset
arcusfelis Jun 21, 2023
e1b7ad2
Add mongoose_node_num instead of ejabberd_node_id
arcusfelis Jun 21, 2023
372b8fd
Fix xref for mongoose_start_node_id
arcusfelis Jun 21, 2023
506a7a4
Fix updated_timestamp column name
arcusfelis Jun 22, 2023
8167380
Fix cets_disco_SUITE:rdbms_backend backend
arcusfelis Jun 22, 2023
e3fd670
Ensure ejabberd_sup is started in mongoose_cleanup_SUITE
arcusfelis Jun 22, 2023
393ff75
Fix mnesia starting in small tests
arcusfelis Jun 22, 2023
22a8c88
Fix mssql schema
arcusfelis Jun 22, 2023
57456d8
Add test for mongoose_cets_discovery_rdbms:next_free_num
arcusfelis Jun 22, 2023
1f8bea8
Deregister node ids in mongoose_start_node_id when node is down
arcusfelis Jun 22, 2023
4bff87e
Add a comment why mnesia:stop() is inside the start function
arcusfelis Jun 23, 2023
1b25b2b
Improve coverage in cets_disco
arcusfelis Jun 23, 2023
171fa01
Add start_node_id_SUITE
arcusfelis Jun 23, 2023
8978847
Imrove mongoose_cets_discovery_rdbms debugging info
arcusfelis Jun 23, 2023
2b9d616
Use lookup_opt to check if mnesia is disabled
arcusfelis Jun 28, 2023
b6a1dde
Start mnesia permanently
arcusfelis Jun 28, 2023
a9ab441
Fix typo
arcusfelis Jun 29, 2023
80077e2
Moved mongoose_node_num:set_node_num away from try..catch
arcusfelis Jun 29, 2023
b83dc98
Fix shadowed variable NodeBin
arcusfelis Jun 29, 2023
461ba2d
Merge pull request #4042 from esl/feature-cets-node_id
chrzaszcz Jun 29, 2023
57a29b5
Add mod_bosh_cets
arcusfelis Jun 30, 2023
dee22c4
Update docs
arcusfelis Jul 10, 2023
72975d1
Use records in mod_bosh_cets
arcusfelis Jul 10, 2023
1cc81f6
Merge pull request #4050 from esl/mu-cets-bosh
chrzaszcz Jul 10, 2023
46fe85a
Move code into mongoose_component
arcusfelis Jun 29, 2023
c8a16bb
Fix dialyzer
arcusfelis Jun 29, 2023
ceb2881
Fix tests
arcusfelis Jun 30, 2023
5600487
Add mongoose_component_cets
arcusfelis Jun 30, 2023
baf6026
Fix component_reg_SUITE
arcusfelis Jun 30, 2023
f37241e
Delete old external_componenst schema
arcusfelis Jun 30, 2023
c58a0d2
Fix muc_light_SUITE
arcusfelis Jun 30, 2023
0b58e50
Fixes from review comments
arcusfelis Jul 11, 2023
8cda94d
Add test for node_cleanup for components
arcusfelis Jul 11, 2023
8d30969
Merge pull request #4047 from esl/mu-cets-components
pawlooss1 Jul 13, 2023
e84d816
Merge branch 'master' into feature/cets
chrzaszcz Jul 19, 2023
84ece51
CETS backend for S2S
arcusfelis Jun 29, 2023
b4cffd7
Rename ejabberd_s2s_backend to mongoose_s2s_backend
arcusfelis Jun 29, 2023
849c493
Fix xref (add missing callbacks into mongoose_s2s_backend)
arcusfelis Jun 29, 2023
bc397d3
Fix config parser for s2s
arcusfelis Jun 29, 2023
72c7a8c
Make mongoose_listener_sup:start_child more verbose
arcusfelis Jun 29, 2023
6dd4d43
Fix mongoose_config_SUITE
arcusfelis Jun 29, 2023
cf6a87f
Remove ejabberd_s2s:have_connection/1
arcusfelis Jul 5, 2023
3c6c988
Rename dirty_read_s2s_list_pids to get_s2s_out_pids
arcusfelis Jul 6, 2023
9cb1d12
Use get_s2s_out_pids function name
arcusfelis Jul 6, 2023
7ce404e
Pass FromTo into ejabberd_s2s_out as one argument
arcusfelis Jul 6, 2023
cd711da
Shorter names for max_connection variables and functions
arcusfelis Jul 6, 2023
1f7deb6
Only use fromto() in ejabberd_s2s_in
arcusfelis Jul 6, 2023
cebed05
Use is_registered instead of new as a record field name in s2s_out
arcusfelis Jul 6, 2023
362bfe6
Add step number comments into s2s in/out
arcusfelis Jul 7, 2023
519e76e
Replace replace_from_to_attrs with replace_from_to
arcusfelis Jul 7, 2023
923611d
Get rid of source from s2s_secret table
arcusfelis Jul 7, 2023
db076f4
Remove incoming_s2s_number/0, outgoing_s2s_number/0 from ignore_xref
arcusfelis Jul 7, 2023
fed53e6
Move get_info_s2s_connections into mongoose_s2s_info
arcusfelis Jul 7, 2023
76c3942
Remove unneeded formatting from ejabberd_s2s
arcusfelis Jul 7, 2023
babc56f
Move library functions into mongoose_s2s_lib
arcusfelis Jul 7, 2023
e4e3383
Remove SUPERVISOR_START macro
arcusfelis Jul 7, 2023
9bf4179
Add missing specs
arcusfelis Jul 7, 2023
16d1829
Rename Mnesia table back to s2s_shared
arcusfelis Jul 7, 2023
7f29448
Add conflict resolver for secrets in mongoose_s2s_cets
arcusfelis Jul 7, 2023
933b709
Improve specs and code style
arcusfelis Jul 7, 2023
b34821d
Play with dialback function names
arcusfelis Jul 7, 2023
69f8b2a
Replace db_ with dialback
arcusfelis Jul 7, 2023
5d5198f
Use Dialback steps (mongoose_s2s_dialback module)
arcusfelis Jul 7, 2023
0319a0d
Make ejabberd_s2s_in:send_validity_from_s2s_out function
arcusfelis Jul 7, 2023
c713663
Properly check if the local host exist
arcusfelis Jul 7, 2023
a3c4aad
Move make_key logic into mongoose_s2s_dialback
arcusfelis Jul 7, 2023
312928a
Use StreamID name in dialback functions
arcusfelis Jul 7, 2023
95a3d8b
Handle negative needed_extra_connections_number_if_allowed
arcusfelis Jul 7, 2023
6ca0ee1
Use fromto_to_attrs in mongoose_s2s_dialback
arcusfelis Jul 7, 2023
6f3271e
Add missing metrics/comments
arcusfelis Jul 7, 2023
e77160f
Improve logging and specs in ejabberd_s2s_in/out
arcusfelis Jul 10, 2023
a0ac802
Use ejabberd_sup:start_child/2 to report errors
arcusfelis Jul 10, 2023
8c908fe
Add s2s_dialback_SUITE
arcusfelis Jul 10, 2023
02dddfe
Use main branch for CETS library
arcusfelis Jul 11, 2023
adc892c
Document s2s_backend option
arcusfelis Jul 11, 2023
8fcfcee
Imrove get_connection function
arcusfelis Jul 20, 2023
936e2b1
Fix style and language
arcusfelis Jul 20, 2023
47af738
Add record specs in mongoose_s2s_cets
arcusfelis Jul 20, 2023
1ee1ccc
Move xeps into mongoose_s2s_dialback
arcusfelis Jul 20, 2023
300b37c
Address minor review comments (code style)
arcusfelis Jul 21, 2023
5f98eeb
Merge pull request #4046 from esl/mu-cets-s2s
chrzaszcz Jul 21, 2023
2067224
Change register_room output
arcusfelis Jun 30, 2023
cad94b6
Move muc_registered record into mod_muc_mnesia
arcusfelis Jul 11, 2023
106e13f
Add mongoose_muc_online_backend support
arcusfelis Jul 11, 2023
5efe813
Move mnesia:create_table into the backend module
arcusfelis Jul 12, 2023
566ba24
Move register_room into mongoose_muc_online_mnesia
arcusfelis Jul 20, 2023
e83128c
Move find_room_pid into mongoose_muc_online_mnesia
arcusfelis Jul 20, 2023
20864d1
Move get_online_rooms function
arcusfelis Jul 20, 2023
4bb0321
Remove clean_table_from_bad_node/1
arcusfelis Jul 20, 2023
077582c
Move node_cleanup into mongoose_muc_online_mnesia
arcusfelis Jul 20, 2023
a166de5
Run node_cleanup for each host type
arcusfelis Jul 20, 2023
5e41c46
Don't execute node_cleanup in MUC on start
arcusfelis Jul 20, 2023
1934ca0
Add mongoose_cleanup_SUITE:cleaner_runs_hook_on_nodedown_for_host_typ…
arcusfelis Jul 20, 2023
7d0da40
Define default online_backend in tests
arcusfelis Jul 21, 2023
e1d2037
Fix graphql_muc_SUITE tests
arcusfelis Jul 21, 2023
36161ef
Improve output spec of the start_room function
arcusfelis Jul 21, 2023
b645f81
Add CETS backend for mongoose_muc_online
arcusfelis Jul 31, 2023
7ca84d8
Fix dialyzer
arcusfelis Jul 31, 2023
5b11bf6
Fix unload_muc in tests
arcusfelis Jul 31, 2023
4f6a4f8
Use cets:insert_new/2
arcusfelis Jul 31, 2023
579b730
Implement clear_table function for tests
arcusfelis Jul 31, 2023
8a49ce3
Use mongoose_muc_online_backend in muc_helper:destroy_room
arcusfelis Aug 1, 2023
09a83fe
Add ignore_xref for mongoose_muc_online_backend:clear_table/1
arcusfelis Aug 1, 2023
db8b3e0
Add tests for mongoose_muc_online_backend:node_cleanup/2
arcusfelis Aug 1, 2023
83f0713
Use ets:match_object/2 instead of ets:select/2
arcusfelis Aug 2, 2023
7fc4538
Use jid:lserver() in specs for mud muc backends
arcusfelis Aug 2, 2023
b3bede2
Use mongoose_backend:call instead of tracked in mongoose_muc_online_b…
arcusfelis Aug 2, 2023
3407849
Merge pull request #4066 from esl/mu-cets-muc-legacy
chrzaszcz Aug 2, 2023
167297d
Merge pull request #4075 from esl/use-match-instead-of-select
chrzaszcz Aug 2, 2023
a7dfa25
Call mod_jingle_sip_backend:remove_session
arcusfelis Aug 3, 2023
9849b10
Move mod_jingle_sip_backend into mod_jingle_sip_mnesia
arcusfelis Aug 3, 2023
f3cfacb
Update CETS library
arcusfelis Aug 3, 2023
9dec04b
Add mod_jingle_sip_cets
arcusfelis Aug 3, 2023
1609279
Add backend option into docs for mod_jingle_sip
arcusfelis Aug 3, 2023
eac044b
Add mod_jingle_sip_session
arcusfelis Aug 4, 2023
fd37e0c
Merge pull request #4076 from esl/cets-for-sip
chrzaszcz Aug 4, 2023
86a25f1
Use latest CETS
arcusfelis Aug 4, 2023
f62752f
Merge remote-tracking branch 'origin/master' into merge-master-into-cets
arcusfelis Aug 4, 2023
feec967
Fix compilation warnings
arcusfelis Aug 4, 2023
df35aee
Better error reporting in graphql_metric_SUITE:values_are_integers
arcusfelis Aug 4, 2023
083ea91
Create metrics after starting the backend in ejabberd_sm
arcusfelis Aug 4, 2023
50a1d01
Disable mnesia in pgsql_cets preset
arcusfelis Aug 4, 2023
58169fc
Start mod_offline with correct backend in tests
arcusfelis Aug 5, 2023
2a9bd44
Restore loglevel after graphql_server_SUITE:set_and_get_loglevel_test…
arcusfelis Aug 5, 2023
128a7c7
Ignore graphql_server_SUITE:clustering_http_tests for CETS
arcusfelis Aug 5, 2023
38cbc4a
Set correct backend for mod_pubsub in push_pubsub_SUITE
arcusfelis Aug 5, 2023
5d98905
Set correct backend for mod_muclight in rest_client_SUITE
arcusfelis Aug 5, 2023
3677b77
Set correct backend in vcard_simple_SUITE
arcusfelis Aug 5, 2023
a5534f7
Configure mod_offline with correct backend in xep_0352_csi_SUITE
arcusfelis Aug 5, 2023
a3647ac
Merge pull request #4078 from esl/merge-master-into-cets
chrzaszcz Aug 7, 2023
e236998
Merge pull request #4079 from esl/disable-mnesia-in-cets-preset
NelsonVides Aug 7, 2023
32621f3
Update CETS dependency
arcusfelis Aug 7, 2023
411c007
Merge pull request #4081 from esl/update-cets
chrzaszcz Aug 7, 2023
48b9569
Merge branch 'master' into feature/cets
chrzaszcz Aug 8, 2023
fa0c589
Clean mongoose_node_num.erl
arcusfelis Aug 8, 2023
0c08e1d
Reorder init steps in ejabberd_app again
arcusfelis Aug 8, 2023
dd37252
Move CETS supervisor specs into mongoose_cets_discovery
arcusfelis Aug 8, 2023
c5faa49
Move cets into included_applications in app config
arcusfelis Aug 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .circleci/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ jobs:
preset:
type: enum
enum: [internal_mnesia, mysql_redis, odbc_mssql_mnesia, ldap_mnesia,
elasticsearch_and_cassandra_mnesia, pgsql_mnesia]
elasticsearch_and_cassandra_mnesia, pgsql_mnesia, pgsql_cets]
description: Preset to run
default: internal_mnesia
db:
Expand Down Expand Up @@ -865,6 +865,15 @@ workflows:
requires:
- otp_25_docker
filters: *all_tags
- big_tests_in_docker:
name: pgsql_cets_25
executor: otp_25_pgsql_redis
context: mongooseim-org
preset: pgsql_cets
db: "mnesia postgres cets"
requires:
- otp_25_docker
filters: *all_tags
- big_tests_in_docker:
name: mysql_redis_25
executor: otp_25_mysql_redis
Expand Down
3 changes: 3 additions & 0 deletions big_tests/default.spec
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
{suites, "tests", graphql_gdpr_SUITE}.
{suites, "tests", graphql_token_SUITE}.
{suites, "tests", graphql_mnesia_SUITE}.
{suites, "tests", graphql_cets_SUITE}.
{suites, "tests", graphql_vcard_SUITE}.
{suites, "tests", graphql_http_upload_SUITE}.
{suites, "tests", graphql_server_SUITE}.
Expand Down Expand Up @@ -115,6 +116,8 @@
{suites, "tests", dynamic_domains_SUITE}.
{suites, "tests", local_iq_SUITE}.
{suites, "tests", tcp_listener_SUITE}.
{suites, "tests", cets_disco_SUITE}.
{suites, "tests", start_node_id_SUITE}.

{config, ["test.config"]}.
{logdir, "ct_report"}.
Expand Down
3 changes: 3 additions & 0 deletions big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
{suites, "tests", graphql_gdpr_SUITE}.
{suites, "tests", graphql_token_SUITE}.
{suites, "tests", graphql_mnesia_SUITE}.
{suites, "tests", graphql_cets_SUITE}.
{suites, "tests", graphql_http_upload_SUITE}.
{suites, "tests", graphql_server_SUITE}.
{suites, "tests", graphql_metric_SUITE}.
Expand Down Expand Up @@ -157,6 +158,8 @@
{suites, "tests", domain_removal_SUITE}.
{suites, "tests", local_iq_SUITE}.
{suites, "tests", tcp_listener_SUITE}.
{suites, "tests", cets_disco_SUITE}.
{suites, "tests", start_node_id_SUITE}.

{config, ["dynamic_domains.config", "test.config"]}.

Expand Down
13 changes: 13 additions & 0 deletions big_tests/src/mim_loglevel.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-module(mim_loglevel).
-export([enable_logging/2]).
-export([disable_logging/2]).
-export([save_log_level/1]).
-export([restore_log_level/1]).

enable_logging(Hosts, Levels) ->
[set_custom(Host, Module, Level) || Host <- Hosts, {Module, Level} <- Levels].
Expand All @@ -15,3 +17,14 @@ set_custom(Host, Module, Level) ->
clear_custom(Host, Module, _Level) ->
Node = ct:get_config({hosts, Host, node}),
mongoose_helper:successful_rpc(#{node => Node}, mongoose_logs, clear_module_loglevel, [Module]).

save_log_level(Config) ->
Node = distributed_helper:mim(),
OldLogLevel = distributed_helper:rpc(Node, mongoose_logs, get_global_loglevel, []),
[{old_log_level, OldLogLevel} | Config].

restore_log_level(Config) ->
Node = distributed_helper:mim(),
{old_log_level, OldLogLevel} = lists:keyfind(old_log_level, 1, Config),
ok = distributed_helper:rpc(Node, mongoose_logs, set_global_loglevel, [OldLogLevel]),
ok.
30 changes: 30 additions & 0 deletions big_tests/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,36 @@
{outgoing_pools, "[outgoing_pools.redis.global_distrib]
scope = \"global\"
workers = 10"}]},
{pgsql_cets,
[{dbs, [redis, pgsql]},
{sm_backend, "\"cets\""},
{bosh_backend, "\"cets\""},
{component_backend, "\"cets\""},
{s2s_backend, "\"cets\""},
{stream_management_backend, cets},
{muc_online_backend, cets},
{jingle_sip_backend, cets},
{auth_method, "rdbms"},
{internal_databases, "[internal_databases.cets]
cluster_name = \"{{cluster_name}}\""},
{outgoing_pools, "[outgoing_pools.redis.global_distrib]
scope = \"global\"
workers = 10
[outgoing_pools.rdbms.default]
scope = \"global\"
workers = 5
connection.driver = \"pgsql\"
connection.host = \"localhost\"
connection.database = \"ejabberd\"
connection.username = \"ejabberd\"
connection.password = \"mongooseim_secret\"
connection.tls.required = true
connection.tls.cacertfile = \"priv/ssl/cacert.pem\"
connection.tls.server_name_indication.enabled = false"},
{service_domain_db, ""},
{mod_vcard, " backend = \"rdbms\"
host = \"vjud.@HOST@\"\n"},
{mod_roster, " backend = \"rdbms\"\n"}]},
{pgsql_mnesia,
[{dbs, [redis, pgsql]},
{auth_method, "rdbms"},
Expand Down
76 changes: 76 additions & 0 deletions big_tests/tests/cets_disco_SUITE.erl
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.
2 changes: 2 additions & 0 deletions big_tests/tests/cets_disco_SUITE_data/nodes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node1@localhost
node2@otherhost
2 changes: 1 addition & 1 deletion big_tests/tests/component_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ disconnect_component(Component, Addr) ->
disconnect_components(Components, Addr) ->
%% TODO replace 'kill' with 'stop' when server supports stream closing
[escalus_connection:kill(Component) || Component <- Components],
mongoose_helper:wait_until(fun() -> rpc(ejabberd_router, lookup_component, [Addr]) =:= [] end, true,
mongoose_helper:wait_until(fun() -> rpc(mongoose_component, lookup_component, [Addr]) =:= [] end, true,
#{name => rpc}).

rpc(M, F, A) ->
Expand Down
12 changes: 11 additions & 1 deletion big_tests/tests/ct_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
repeat_all_until_all_ok/2,
repeat_all_until_any_fail/1,
repeat_all_until_any_fail/2,
groups_to_all/1]).
groups_to_all/1,
get_preset_var/3]).

-type group_name() :: atom().

Expand Down Expand Up @@ -114,3 +115,12 @@ is_ct_started() ->

groups_to_all(Groups) ->
[{group, Name} || {Name, _Opts, _Cases} <- Groups].

get_preset_var(Config, Opt, Def) ->
case proplists:get_value(preset, Config, undefined) of
Preset ->
PresetAtom = list_to_existing_atom(Preset),
ct:get_config({presets, toml, PresetAtom, Opt}, Def);
_ ->
Def
end.
2 changes: 1 addition & 1 deletion big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ is_internal_or_rdbms() ->
%%%===================================================================

init_per_testcase(muc_removal, Config) ->
muc_helper:load_muc(),
muc_helper:load_muc(Config),
mongoose_helper:ensure_muc_clean(),
escalus:init_per_testcase(muc_removal, Config);
init_per_testcase(roster_removal, ConfigIn) ->
Expand Down
4 changes: 2 additions & 2 deletions big_tests/tests/gdpr_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ all_mam_testcases() ->
init_per_suite(Config) ->
#{node := MimNode} = distributed_helper:mim(),
Config1 = [{{ejabberd_cwd, MimNode}, get_mim_cwd()} | dynamic_modules:save_modules(host_type(), Config)],
muc_helper:load_muc(),
muc_helper:load_muc(Config),
escalus:init_per_suite(Config1).

end_per_suite(Config) ->
Expand Down Expand Up @@ -243,7 +243,7 @@ init_per_testcase(CN, Config) when
Config1;
init_per_testcase(CN, Config) when CN =:= retrieve_inbox_muc;
CN =:= remove_inbox_muc ->
muc_helper:load_muc(),
muc_helper:load_muc(Config),
Config0 = init_inbox(CN, Config, muc),
Config0;

Expand Down
77 changes: 77 additions & 0 deletions big_tests/tests/graphql_cets_SUITE.erl
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).
11 changes: 8 additions & 3 deletions big_tests/tests/graphql_metric_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,13 @@ get_cluster_metrics_by_nonexistent_name(Config) ->
Result = get_cluster_metrics_as_dicts_by_name([<<"nonexistent">>], Config),
ParsedResult = get_ok_value([data, metric, getClusterMetricsAsDicts], Result),
[#{<<"node">> := _, <<"result">> := []},
#{<<"node">> := _, <<"result">> := []}] = ParsedResult.
#{<<"node">> := _, <<"result">> := []}|_] = ParsedResult. %% two or three nodes.

get_cluster_metrics_with_nonexistent_key(Config) ->
Result = get_cluster_metrics_as_dicts_with_keys([<<"nonexistent">>], Config),
ParsedResult = get_ok_value([data, metric, getClusterMetricsAsDicts], Result),
[#{<<"node">> := _, <<"result">> := [_|_]},
#{<<"node">> := _, <<"result">> := [_|_]}] = ParsedResult.
#{<<"node">> := _, <<"result">> := [_|_]}|_] = ParsedResult.

get_cluster_metrics_empty_args(Config) ->
Node = atom_to_binary(maps:get(node, distributed_helper:mim2())),
Expand Down Expand Up @@ -445,7 +445,12 @@ check_spiral_dict(Dict) ->
?assert(is_integer(One)).

values_are_integers(Map, Keys) ->
lists:foreach(fun(Key) -> ?assert(is_integer(maps:get(Key, Map))) end, Keys).
case lists:all(fun(Key) -> is_integer(maps:get(Key, Map)) end, Keys) of
true ->
ok;
false ->
ct:fail({values_are_integers, Keys, Map})
end.

metric_host_type() ->
binary:replace(domain_helper:host_type(), <<" ">>, <<"_">>, [global]).
Loading