diff options
Diffstat (limited to 'lib/kernel/test/erl_distribution_SUITE.erl')
-rw-r--r-- | lib/kernel/test/erl_distribution_SUITE.erl | 123 |
1 files changed, 109 insertions, 14 deletions
diff --git a/lib/kernel/test/erl_distribution_SUITE.erl b/lib/kernel/test/erl_distribution_SUITE.erl index 373be74e51..238f4d3365 100644 --- a/lib/kernel/test/erl_distribution_SUITE.erl +++ b/lib/kernel/test/erl_distribution_SUITE.erl @@ -21,6 +21,8 @@ -include_lib("common_test/include/ct.hrl"). -include_lib("kernel/include/dist.hrl"). +-include_lib("stdlib/include/assert.hrl"). +-include_lib("kernel/include/file.hrl"). -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2]). @@ -34,6 +36,7 @@ setopts/1, table_waste/1, net_setuptime/1, inet_dist_options_options/1, + net_ticker_spawn_options/1, monitor_nodes_nodedown_reason/1, monitor_nodes_complex_nodedown_reason/1, @@ -50,10 +53,12 @@ erl_uds_dist_smoke_test/1, erl_1424/1, differing_cookies/1, cmdline_setcookie_2/1, connection_cookie/1, - dyn_differing_cookies/1]). + dyn_differing_cookies/1, + xdg_cookie/1]). %% Performs the test at another node. -export([get_socket_priorities/0, + get_net_ticker_fullsweep_option/1, tick_cli_test/1, tick_cli_test1/1, tick_serv_test/2, tick_serv_test1/1, run_remote_test/1, @@ -95,6 +100,7 @@ all() -> epmd_reconnect, hidden_node, setopts, table_waste, net_setuptime, inet_dist_options_options, + net_ticker_spawn_options, {group, monitor_nodes}, erl_uds_dist_smoke_test, erl_1424, @@ -113,7 +119,8 @@ groups() -> [differing_cookies, cmdline_setcookie_2, connection_cookie, - dyn_differing_cookies]}]. + dyn_differing_cookies, + xdg_cookie]}]. init_per_suite(Config) -> start_gen_tcp_dist_test_type_server(), @@ -296,14 +303,14 @@ illegal(Name) -> test_node(Name) -> test_node(Name, false). -test_node(Name, Illigal) -> - test_node(Name, Illigal, ""). -test_node(Name, Illigal, ExtraArgs) -> +test_node(Name, Illegal) -> + test_node(Name, Illegal, ""). +test_node(Name, Illegal, ExtraArgs) -> ProgName = ct:get_progname(), Command = ProgName ++ " -noinput " ++ long_or_short() ++ Name ++ ExtraArgs ++ " -eval \"net_adm:ping('" ++ atom_to_list(node()) ++ "')\"" ++ - case Illigal of + case Illegal of true -> " -eval \"timer:sleep(10000),init:stop().\""; false -> @@ -1076,6 +1083,48 @@ get_socket_priorities() -> +%% check net_ticker_spawn_options +net_ticker_spawn_options(Config) when is_list(Config) -> + FullsweepString0 = "[{fullsweep_after,0}]", + FullsweepString = + case os:cmd("echo [{a,1}]") of + "[{a,1}]"++_ -> + FullsweepString0; + _ -> + %% Some shells need quoting of [{}] + "'"++FullsweepString0++"'" + end, + InetDistOptions = + "-hidden " + "-kernel net_ticker_spawn_options "++FullsweepString, + {ok,Node1} = + start_node("", net_ticker_spawn_options_1, InetDistOptions), + {ok,Node2} = + start_node("", net_ticker_spawn_options_2, InetDistOptions), + %% + pong = + rpc:call(Node1, net_adm, ping, [Node2]), + FullsweepOptionNode1 = + rpc:call(Node1, ?MODULE, get_net_ticker_fullsweep_option, [Node2]), + FullsweepOptionNode2 = + rpc:call(Node2, ?MODULE, get_net_ticker_fullsweep_option, [Node1]), + io:format("FullsweepOptionNode1 = ~p", [FullsweepOptionNode1]), + io:format("FullsweepOptionNode2 = ~p", [FullsweepOptionNode2]), + 0 = FullsweepOptionNode1, + 0 = FullsweepOptionNode2, + %% + stop_node(Node2), + stop_node(Node1), + ok. + +get_net_ticker_fullsweep_option(Node) -> + Port = proplists:get_value(Node, erlang:system_info(dist_ctrl)), + {links, [DistUtilPid, _NetKernelPid]} = erlang:port_info(Port, links), + {garbage_collection, GCOpts} = erlang:process_info(DistUtilPid, garbage_collection), + proplists:get_value(fullsweep_after, GCOpts). + + + %% %% Testcase: %% monitor_nodes_nodedown_reason @@ -1631,14 +1680,10 @@ monitor_nodes_many(DCfg, _Config) -> %% Test order of messages nodedown and nodeup. monitor_nodes_down_up(Config) when is_list(Config) -> - [An] = get_nodenames(1, monitor_nodeup), - {ok, A} = ct_slave:start(An), - - try - monitor_nodes_yoyo(A) - after - catch ct_slave:stop(A) - end. + {ok, Peer, Node} = ?CT_PEER(#{connection => 0}), + true = net_kernel:connect_node(Node), + monitor_nodes_yoyo(Node), + peer:stop(Peer). monitor_nodes_yoyo(A) -> net_kernel:monitor_nodes(true), @@ -2282,6 +2327,56 @@ ddc_remote_run(MotherNode, [SetCookie, MotherNodeCookieL]) -> error({unexpected, Other}) end. +xdg_cookie(Config) when is_list(Config) -> + PrivDir = proplists:get_value(priv_dir, Config), + + TestHome = filename:join(PrivDir, ?FUNCTION_NAME), + ok = file:make_dir(TestHome), + + HomeEnv = case os:type() of + {win32, _} -> + [Drive | Path] = filename:split(TestHome), + [{"APPDATA", filename:join(TestHome,"AppData")}, + {"HOMEDRIVE", Drive}, {"HOMEPATH", filename:join(Path)}]; + _ -> + [{"HOME", TestHome}] + end, + + NodeOpts = #{ env => HomeEnv ++ + [{"ERL_CRASH_DUMP", filename:join([TestHome,"erl_crash.dump"])}], + connection => 0 }, + + %% Test that a default .erlang.cookie file is created + {ok, CreatorPeer, _} = peer:start_link(NodeOpts#{ name => peer:random_name(?FUNCTION_NAME) }), + UserConfig = peer:call(CreatorPeer, filename, basedir, [user_config,"erlang"]), + ?assert(peer:call(CreatorPeer, filelib, is_regular, + [filename:join(TestHome, ".erlang.cookie")])), + OrigCookie = peer:call(CreatorPeer, erlang, get_cookie, []), + peer:stop(CreatorPeer), + + %% Test that the $HOME/.erlang.cookie file takes precedence over XDG + XDGCookie = filename:join([UserConfig, ".erlang.cookie"]), + ok = filelib:ensure_dir(XDGCookie), + ok = file:write_file(XDGCookie, "Me want cookie!"), + {ok, XDGFI} = file:read_file_info(XDGCookie), + ok = file:write_file_info(XDGCookie, XDGFI#file_info{ mode = 8#600 }), + + {ok, Peer, _} = peer:start_link(NodeOpts#{ name => peer:random_name(?FUNCTION_NAME) }), + + ?assertEqual(OrigCookie, peer:call(Peer, erlang, get_cookie, [])), + + peer:stop(Peer), + + %% Check that XDG cookie works after we delete the $HOME cookie + ok = file:delete(filename:join(TestHome, ".erlang.cookie")), + {ok, Peer2, _} = peer:start_link(NodeOpts#{ name => peer:random_name(?FUNCTION_NAME) }), + ?assertEqual('Me want cookie!', peer:call(Peer2, erlang, get_cookie, [])), + + peer:stop(Peer2), + + ok. + + %% Misc. functions |