Skip to content

Commit

Permalink
Test: Enable some modules so ejabberd creates their SQL tables
Browse files Browse the repository at this point in the history
and later those tables can be updated without errors by mod_admin_update_sql
when ci.yml calls "make test" to check update_sql.

However, mod_shared_roster should be stopped before running the actual tests,
as it introduces undesired IQ queries

On the other hand, a few SQL tables are global RAM, and cannot be created
in SQL just for a vhost that is not the first one defined.
  • Loading branch information
badlop committed Jan 13, 2025
1 parent 33ca118 commit 7b95332
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/ejabberd_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ do_init_per_group(mysql, Config) ->
{selected, _, _} ->
mod_muc:shutdown_rooms(?MYSQL_VHOST),
update_sql(?MYSQL_VHOST, Config),
stop_temporary_modules(?MYSQL_VHOST),
set_opt(server, ?MYSQL_VHOST, Config);
Err ->
{skip, {mysql_not_available, Err}}
Expand All @@ -109,6 +110,7 @@ do_init_per_group(mssql, Config) ->
{selected, _, _} ->
mod_muc:shutdown_rooms(?MSSQL_VHOST),
update_sql(?MSSQL_VHOST, Config),
stop_temporary_modules(?MSSQL_VHOST),
set_opt(server, ?MSSQL_VHOST, Config);
Err ->
{skip, {mssql_not_available, Err}}
Expand All @@ -118,6 +120,7 @@ do_init_per_group(pgsql, Config) ->
{selected, _, _} ->
mod_muc:shutdown_rooms(?PGSQL_VHOST),
update_sql(?PGSQL_VHOST, Config),
stop_temporary_modules(?PGSQL_VHOST),
set_opt(server, ?PGSQL_VHOST, Config);
Err ->
{skip, {pgsql_not_available, Err}}
Expand Down Expand Up @@ -161,6 +164,10 @@ do_init_per_group(GroupName, Config) ->
_ -> NewConfig
end.

stop_temporary_modules(Host) ->
Modules = [mod_shared_roster],
[gen_mod:stop_module(Host, M) || M <- Modules].

end_per_group(mnesia, _Config) ->
ok;
end_per_group(redis, _Config) ->
Expand Down Expand Up @@ -1094,7 +1101,17 @@ clear_table_queries(Queries) ->
fun(Query, Acc) ->
case split(str:to_lower(Query)) of
[<<"create">>, <<"table">>, Table|_] ->
[<<"DELETE FROM ", Table/binary, ";">>|Acc];
GlobalRamTables = [<<"bosh">>,
<<"oauth_client">>,
<<"oauth_token">>,
<<"proxy65">>,
<<"route">>],
case lists:member(Table, GlobalRamTables) of
true ->
Acc;
false ->
[<<"DELETE FROM ", Table/binary, ";">>|Acc]
end;
_ ->
Acc
end
Expand Down
8 changes: 8 additions & 0 deletions test/ejabberd_SUITE_data/ejabberd.mssql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,11 @@ Welcome to this XMPP server."
mod_stats: []
mod_time: []
mod_version: []
mod_mix:
db_type: sql
mod_mix_pam:
db_type: sql
mod_mqtt:
db_type: sql
mod_shared_roster:
db_type: sql
8 changes: 8 additions & 0 deletions test/ejabberd_SUITE_data/ejabberd.mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ Welcome to this XMPP server."
mod_stats: []
mod_time: []
mod_version: []
mod_mix:
db_type: sql
mod_mix_pam:
db_type: sql
mod_mqtt:
db_type: sql
mod_shared_roster:
db_type: sql
8 changes: 8 additions & 0 deletions test/ejabberd_SUITE_data/ejabberd.pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ Welcome to this XMPP server."
mod_stats: []
mod_time: []
mod_version: []
mod_mix:
db_type: sql
mod_mix_pam:
db_type: sql
mod_mqtt:
db_type: sql
mod_shared_roster:
db_type: sql

0 comments on commit 7b95332

Please sign in to comment.