From 2c1911f8e5d667561467249f466f030785d0f8ba Mon Sep 17 00:00:00 2001 From: kjnilsson Date: Fri, 7 Oct 2016 12:35:50 +0100 Subject: [PATCH] Symlink private_log directory for the last test run inside logs --- .../src/rabbit_ct_helpers.erl | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl b/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl index b8879d8c4ed9..2cfe07072941 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl @@ -72,7 +72,8 @@ run_teardown_steps(Config) -> run_teardown_steps(Config, ExtraSteps) -> Steps = [ - fun stop_long_running_testsuite_monitor/1 + fun stop_long_running_testsuite_monitor/1, + fun symlink_priv_dir/1 ], run_steps(Config, ExtraSteps ++ Steps). @@ -258,6 +259,43 @@ ensure_ssl_certs(Config) -> {skip, "Failed to create SSL certificates"} end. +link_name(["deps", _ | Tail]) -> + case lists:reverse(Tail) of + ["logs" | Rest] -> + string:join(lists:reverse(["private_log" | Rest]), "."); + _ -> + string:join(Tail, ".") + end; +link_name(X) -> X. + +get_selection_from_tc_logfile(["logs", _, S | _Tail]) -> + {ok, link_name(string:tokens(S, "."))}; +get_selection_from_tc_logfile([_ | Tail]) -> + get_selection_from_tc_logfile(Tail); +get_selection_from_tc_logfile([]) -> not_found. + +get_selection(Config) -> + TcLogFile = ?config(tc_logfile, Config), + get_selection_from_tc_logfile(filename:split(TcLogFile)). + + +symlink_priv_dir(Config) -> + SrcDir = ?config(current_srcdir, Config), + PrivDir = ?config(priv_dir, Config), + case get_selection(Config) of + {ok, Name} -> + Target = filename:join([SrcDir, "logs", Name]), + case exec(["ln", "-snf", PrivDir, Target]) of + {ok, _} -> ok; + _ -> ct:pal(?LOW_IMPORTANCE, + "Failed to symlink private_log directory.") + end, + Config; + not_found -> + ct:pal(?LOW_IMPORTANCE, "Failed to symlink private_log directory."), + Config + end. + %% ------------------------------------------------------------------- %% Process to log a message every minute during long testcases. %% -------------------------------------------------------------------