25
1
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:
Evgeniy Khramtsov 2013-06-19 21:30:31 +10:00
parent 4f8bb4f918
commit 89c3cf3677
3 changed files with 20 additions and 1 deletions

View File

@ -41,6 +41,7 @@
restore_room/3,
forget_room/3,
create_room/5,
shutdown_rooms/1,
process_iq_disco_items/4,
broadcast_service_message/2,
can_use_nick/4]).
@ -96,10 +97,23 @@ start(Host, Opts) ->
supervisor:start_child(ejabberd_sup, ChildSpec).
stop(Host) ->
Rooms = shutdown_rooms(Host),
stop_supervisor(Host),
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
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:
%% A) The owner of the room destroyed it

View File

@ -830,6 +830,8 @@ handle_info({captcha_failed, From}, normal_state,
_ -> StateData
end,
{next_state, normal_state, NewState};
handle_info(shutdown, _StateName, StateData) ->
{stop, shutdown, StateData};
handle_info(_Info, StateName, StateData) ->
{next_state, StateName, StateData}.

View File

@ -110,10 +110,12 @@ init_per_group(no_db, Config) ->
{atomic, ok} = ejabberd_auth:try_register(User, Server, Password),
Config;
init_per_group(mnesia, Config) ->
mod_muc:shutdown_rooms(?MNESIA_VHOST),
set_opt(server, ?MNESIA_VHOST, Config);
init_per_group(mysql, Config) ->
case catch ejabberd_odbc:sql_query(?MYSQL_VHOST, [<<"select 1;">>]) of
{selected, _, _} ->
mod_muc:shutdown_rooms(?MYSQL_VHOST),
create_sql_tables(mysql, ?config(base_dir, Config)),
set_opt(server, ?MYSQL_VHOST, Config);
Err ->
@ -122,6 +124,7 @@ init_per_group(mysql, Config) ->
init_per_group(pgsql, Config) ->
case catch ejabberd_odbc:sql_query(?PGSQL_VHOST, [<<"select 1;">>]) of
{selected, _, _} ->
mod_muc:shutdown_rooms(?PGSQL_VHOST),
create_sql_tables(pgsql, ?config(base_dir, Config)),
set_opt(server, ?PGSQL_VHOST, Config);
Err ->