Skip to content

Commit

Permalink
Renaming mnesia info graphql function to mnesia systemInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Janusz Jakubiec authored and Janusz Jakubiec committed Aug 23, 2022
1 parent 6c4aa15 commit fb3bf4d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
14 changes: 8 additions & 6 deletions big_tests/tests/graphql_mnesia_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ change_nodename_bad_file_error_test(Config) ->
get_info_test(Config) ->
Res = get_info(maps:keys(mnesia_info_check()) ++ [<<"AAA">>], Config),
?assertEqual(<<"bad_key_error">>, get_err_code(Res)),
ParsedRes = get_err_value([data, mnesia, info], Res),
ParsedRes = get_err_value([data, mnesia, systemInfo], Res),
Map = mnesia_info_check(),
lists:foreach(fun
(#{<<"result">> := Element, <<"key">> := Key}) ->
Expand All @@ -217,8 +217,8 @@ get_info_test(Config) ->
end, ParsedRes).

get_all_info_test(Config) ->
Res = get_info([], Config),
ParsedRes = get_ok_value([data, mnesia, info], Res),
Res = get_info(null, Config),
ParsedRes = get_ok_value([data, mnesia, systemInfo], Res),
Map = mnesia_info_check(),
lists:foreach(fun (#{<<"result">> := Element, <<"key">> := Key}) ->
Fun = maps:get(Key, Map),
Expand Down Expand Up @@ -261,7 +261,7 @@ domain_admin_set_master_test(Config) ->
get_unauthorized(domain_admin_set_master(mim(), Config)).

domain_admin_get_info_test(Config) ->
get_unauthorized(domain_admin_get_info([<<"all">>], Config)).
get_unauthorized(domain_admin_get_info([<<"running_db_nodes">>], Config)).

%--------------------------------------------------------------------------------------------------
% Helpers
Expand Down Expand Up @@ -322,8 +322,10 @@ check_if_response_contains(Response, String) ->
delete_file(FullPath) ->
file:delete(FullPath).

get_info(null, Config) ->
execute_command(<<"mnesia">>, <<"systemInfo">>, #{}, Config);
get_info(Keys, Config) ->
execute_command(<<"mnesia">>, <<"info">>, #{keys => Keys}, Config).
execute_command(<<"mnesia">>, <<"systemInfo">>, #{keys => Keys}, Config).

install_fallback(Path, Config) ->
execute_command(<<"mnesia">>, <<"installFallback">>, #{path => Path}, Config).
Expand Down Expand Up @@ -352,7 +354,7 @@ set_master(Node, Config) ->
execute_command(<<"mnesia">>, <<"setMaster">>, Node, Config).

domain_admin_get_info(Keys, Config) ->
execute_domain_admin_command(<<"mnesia">>, <<"info">>, #{keys => Keys}, Config).
execute_domain_admin_command(<<"mnesia">>, <<"systemInfo">>, #{keys => Keys}, Config).

domain_admin_install_fallback(Path, Config) ->
execute_domain_admin_command(<<"mnesia">>, <<"installFallback">>, #{path => Path}, Config).
Expand Down
2 changes: 1 addition & 1 deletion priv/graphql/schemas/admin/mnesia.gql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Allow admin to acquire information about mnesia database
"""
type MnesiaAdminQuery @protected{
"Allow to acquire information about mnesia database"
info(keys: [String!]!): [MnesiaInfo]
systemInfo(keys: [String!]): [MnesiaInfo]
@protected(type: GLOBAL)
}

Expand Down
6 changes: 0 additions & 6 deletions src/ejabberd_ctl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,6 @@ process(["mnesia"]) ->
process(["mnesia", "info"]) ->
mnesia:info(),
?STATUS_SUCCESS;
process(["mnesia", Arg]) when is_list(Arg) ->
case catch mnesia:system_info(list_to_atom(Arg)) of
{'EXIT', Error} -> ?PRINT("Error: ~p~n", [Error]);
Return -> ?PRINT("~p~n", [Return])
end,
?STATUS_SUCCESS;
process(["graphql", Arg]) when is_list(Arg) ->
Doc = list_to_binary(Arg),
Ep = mongoose_graphql:get_endpoint(admin),
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/mongoose_graphql_mnesia_admin_query.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-include("mongoose.hrl").
-include("jlib.hrl").

execute(_Ctx, mnesia, <<"info">>, #{<<"keys">> := Keys}) ->
execute(_Ctx, mnesia, <<"systemInfo">>, #{<<"keys">> := Keys}) ->
ResultList = mnesia_api:mnesia_info(Keys),
{ok, lists:map(fun process_result/1, ResultList)}.

Expand Down
2 changes: 1 addition & 1 deletion src/mnesia_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-type dump_error() :: table_does_not_exist | file_error | cannot_dump.

-spec mnesia_info(Keys::[binary()]) -> [info_result() | info_error()].
mnesia_info([]) ->
mnesia_info(null) ->
Value = mnesia:system_info(all),
lists:foldl(fun({Key, Result}, AllAcc) ->
AllAcc ++ [{ok, #{<<"result">> => convert_value(Result), <<"key">> => Key}}]
Expand Down

0 comments on commit fb3bf4d

Please sign in to comment.