diff --git a/big_tests/tests/graphql_mnesia_SUITE.erl b/big_tests/tests/graphql_mnesia_SUITE.erl index 2e3d9fb14b..1e761cd098 100644 --- a/big_tests/tests/graphql_mnesia_SUITE.erl +++ b/big_tests/tests/graphql_mnesia_SUITE.erl @@ -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}) -> @@ -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), @@ -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 @@ -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). @@ -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). diff --git a/priv/graphql/schemas/admin/mnesia.gql b/priv/graphql/schemas/admin/mnesia.gql index ea8118fa4c..e08b17ad10 100644 --- a/priv/graphql/schemas/admin/mnesia.gql +++ b/priv/graphql/schemas/admin/mnesia.gql @@ -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) } diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl index cb003c528b..67427231f8 100644 --- a/src/ejabberd_ctl.erl +++ b/src/ejabberd_ctl.erl @@ -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), diff --git a/src/graphql/admin/mongoose_graphql_mnesia_admin_query.erl b/src/graphql/admin/mongoose_graphql_mnesia_admin_query.erl index 3a62492057..e3d6fe9fea 100644 --- a/src/graphql/admin/mongoose_graphql_mnesia_admin_query.erl +++ b/src/graphql/admin/mongoose_graphql_mnesia_admin_query.erl @@ -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)}. diff --git a/src/mnesia_api.erl b/src/mnesia_api.erl index ad93d93998..9ea10f32bb 100644 --- a/src/mnesia_api.erl +++ b/src/mnesia_api.erl @@ -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}}]