Skip to content

Commit

Permalink
fix epmd not stopping after run.
Browse files Browse the repository at this point in the history
Summary:
as per title.

The underlying error is that we were trying to kill the "port" of the epmd, but port in the sense the port number that the epmd was operating on, instead of the port in the sense what erlang:open_port returned.

Reviewed By: jcpetruzza

Differential Revision: D67194989

fbshipit-source-id: ff6b71b026d20bec1764f6c1a6a18e8526220e7d
  • Loading branch information
Thomas David Cuvillier authored and facebook-github-bot committed Dec 13, 2024
1 parent 4226f35 commit bd95c36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions erlang/common_test/test_binary/src/test_runner.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,13 @@ run_test(
)
);
{run_succeed, Result} ->
ensure_test_exec_stopped(),
test_run_succeed(TestEnv, Result);
{run_failed, Result} ->
ensure_test_exec_stopped(),
test_run_fail(TestEnv, Result)
after max_timeout(TestEnv) ->
{Pid, Monitor} = erlang:spawn_monitor(fun() -> application:stop(test_exec) end),
receive
{'DOWN', Monitor, process, Pid, _} -> ok
after 5000 -> ok
end,
ensure_test_exec_stopped(),
ErrorMsg =
"\n***************************************************************\n"
"* the suite timed out, all tests will be reported as failure. *\n"
Expand All @@ -125,6 +123,14 @@ run_test(
)
end.

-spec ensure_test_exec_stopped() -> ok.
ensure_test_exec_stopped() ->
{Pid, Monitor} = erlang:spawn_monitor(fun() -> application:stop(test_exec) end),
receive
{'DOWN', Monitor, process, Pid, _} -> ok
after 5000 -> ok
end.

%% @doc Provides xml result as specified by the tpx protocol when test failed to ran.
-spec test_run_fail(#test_env{}, string()) -> ok.
test_run_fail(#test_env{} = TestEnv, Reason) ->
Expand Down
6 changes: 3 additions & 3 deletions erlang/common_test/test_exec/src/epmd_manager.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ init([#test_env{output_dir = OutputDir}]) ->
undefined ->
EpmdOutPath = get_epmd_out_path(OutputDir),
case start_epmd(EpmdOutPath) of
{ok, Port, _PortEpmd, LogHandle} ->
{ok, #{epmd_port => Port, log_handle => LogHandle, global_epmd => false}};
{ok, Port, PortEpmd, LogHandle} ->
{ok, #{epmd_port => Port, epmd_erlang_port => PortEpmd, log_handle => LogHandle, global_epmd => false}};
Error ->
{stop, {epmd_start_failed, Error}, #{}}
end;
Expand Down Expand Up @@ -72,7 +72,7 @@ handle_info({PortEpmd, {data, TaggedData}}, #{epmd_port := PortEpmd, log_handle
handle_info(_Info, State) ->
{noreply, State}.

terminate(_Reason, #{epmd_port := EpmdPort, global_epmd := false}) ->
terminate(_Reason, #{epmd_erlang_port := EpmdPort, global_epmd := false}) ->
test_exec:kill_process(EpmdPort);
terminate(_Reason, _State) ->
ok.
Expand Down

0 comments on commit bd95c36

Please sign in to comment.