mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Shutdown rooms before starting test cases
This commit is contained in:
parent
4f8bb4f918
commit
89c3cf3677
@ -41,6 +41,7 @@
|
|||||||
restore_room/3,
|
restore_room/3,
|
||||||
forget_room/3,
|
forget_room/3,
|
||||||
create_room/5,
|
create_room/5,
|
||||||
|
shutdown_rooms/1,
|
||||||
process_iq_disco_items/4,
|
process_iq_disco_items/4,
|
||||||
broadcast_service_message/2,
|
broadcast_service_message/2,
|
||||||
can_use_nick/4]).
|
can_use_nick/4]).
|
||||||
@ -96,10 +97,23 @@ start(Host, Opts) ->
|
|||||||
supervisor:start_child(ejabberd_sup, ChildSpec).
|
supervisor:start_child(ejabberd_sup, ChildSpec).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
|
Rooms = shutdown_rooms(Host),
|
||||||
stop_supervisor(Host),
|
stop_supervisor(Host),
|
||||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||||
gen_server:call(Proc, stop),
|
gen_server:call(Proc, stop),
|
||||||
supervisor:delete_child(ejabberd_sup, Proc).
|
supervisor:delete_child(ejabberd_sup, Proc),
|
||||||
|
{wait, Rooms}.
|
||||||
|
|
||||||
|
shutdown_rooms(Host) ->
|
||||||
|
MyHost = gen_mod:get_module_opt_host(Host, mod_muc,
|
||||||
|
<<"conference.@HOST@">>),
|
||||||
|
Rooms = mnesia:dirty_select(muc_online_room,
|
||||||
|
[{#muc_online_room{name_host = '$1',
|
||||||
|
pid = '$2'},
|
||||||
|
[{'==', {element, 2, '$1'}, MyHost}],
|
||||||
|
['$2']}]),
|
||||||
|
[Pid ! shutdown || Pid <- Rooms],
|
||||||
|
Rooms.
|
||||||
|
|
||||||
%% This function is called by a room in three situations:
|
%% This function is called by a room in three situations:
|
||||||
%% A) The owner of the room destroyed it
|
%% A) The owner of the room destroyed it
|
||||||
|
@ -830,6 +830,8 @@ handle_info({captcha_failed, From}, normal_state,
|
|||||||
_ -> StateData
|
_ -> StateData
|
||||||
end,
|
end,
|
||||||
{next_state, normal_state, NewState};
|
{next_state, normal_state, NewState};
|
||||||
|
handle_info(shutdown, _StateName, StateData) ->
|
||||||
|
{stop, shutdown, StateData};
|
||||||
handle_info(_Info, StateName, StateData) ->
|
handle_info(_Info, StateName, StateData) ->
|
||||||
{next_state, StateName, StateData}.
|
{next_state, StateName, StateData}.
|
||||||
|
|
||||||
|
@ -110,10 +110,12 @@ init_per_group(no_db, Config) ->
|
|||||||
{atomic, ok} = ejabberd_auth:try_register(User, Server, Password),
|
{atomic, ok} = ejabberd_auth:try_register(User, Server, Password),
|
||||||
Config;
|
Config;
|
||||||
init_per_group(mnesia, Config) ->
|
init_per_group(mnesia, Config) ->
|
||||||
|
mod_muc:shutdown_rooms(?MNESIA_VHOST),
|
||||||
set_opt(server, ?MNESIA_VHOST, Config);
|
set_opt(server, ?MNESIA_VHOST, Config);
|
||||||
init_per_group(mysql, Config) ->
|
init_per_group(mysql, Config) ->
|
||||||
case catch ejabberd_odbc:sql_query(?MYSQL_VHOST, [<<"select 1;">>]) of
|
case catch ejabberd_odbc:sql_query(?MYSQL_VHOST, [<<"select 1;">>]) of
|
||||||
{selected, _, _} ->
|
{selected, _, _} ->
|
||||||
|
mod_muc:shutdown_rooms(?MYSQL_VHOST),
|
||||||
create_sql_tables(mysql, ?config(base_dir, Config)),
|
create_sql_tables(mysql, ?config(base_dir, Config)),
|
||||||
set_opt(server, ?MYSQL_VHOST, Config);
|
set_opt(server, ?MYSQL_VHOST, Config);
|
||||||
Err ->
|
Err ->
|
||||||
@ -122,6 +124,7 @@ init_per_group(mysql, Config) ->
|
|||||||
init_per_group(pgsql, Config) ->
|
init_per_group(pgsql, Config) ->
|
||||||
case catch ejabberd_odbc:sql_query(?PGSQL_VHOST, [<<"select 1;">>]) of
|
case catch ejabberd_odbc:sql_query(?PGSQL_VHOST, [<<"select 1;">>]) of
|
||||||
{selected, _, _} ->
|
{selected, _, _} ->
|
||||||
|
mod_muc:shutdown_rooms(?PGSQL_VHOST),
|
||||||
create_sql_tables(pgsql, ?config(base_dir, Config)),
|
create_sql_tables(pgsql, ?config(base_dir, Config)),
|
||||||
set_opt(server, ?PGSQL_VHOST, Config);
|
set_opt(server, ?PGSQL_VHOST, Config);
|
||||||
Err ->
|
Err ->
|
||||||
|
Loading…
Reference in New Issue
Block a user