Skip to content

Commit 2862963

Browse files
Merge pull request #2 from rabbitmq/symlink_private_log_dir
Symlink private_log directory for the last test run inside logs
2 parents 7a63804 + 2c1911f commit 2862963

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ run_teardown_steps(Config) ->
7272

7373
run_teardown_steps(Config, ExtraSteps) ->
7474
Steps = [
75-
fun stop_long_running_testsuite_monitor/1
75+
fun stop_long_running_testsuite_monitor/1,
76+
fun symlink_priv_dir/1
7677
],
7778
run_steps(Config, ExtraSteps ++ Steps).
7879

@@ -258,6 +259,43 @@ ensure_ssl_certs(Config) ->
258259
{skip, "Failed to create SSL certificates"}
259260
end.
260261

262+
link_name(["deps", _ | Tail]) ->
263+
case lists:reverse(Tail) of
264+
["logs" | Rest] ->
265+
string:join(lists:reverse(["private_log" | Rest]), ".");
266+
_ ->
267+
string:join(Tail, ".")
268+
end;
269+
link_name(X) -> X.
270+
271+
get_selection_from_tc_logfile(["logs", _, S | _Tail]) ->
272+
{ok, link_name(string:tokens(S, "."))};
273+
get_selection_from_tc_logfile([_ | Tail]) ->
274+
get_selection_from_tc_logfile(Tail);
275+
get_selection_from_tc_logfile([]) -> not_found.
276+
277+
get_selection(Config) ->
278+
TcLogFile = ?config(tc_logfile, Config),
279+
get_selection_from_tc_logfile(filename:split(TcLogFile)).
280+
281+
282+
symlink_priv_dir(Config) ->
283+
SrcDir = ?config(current_srcdir, Config),
284+
PrivDir = ?config(priv_dir, Config),
285+
case get_selection(Config) of
286+
{ok, Name} ->
287+
Target = filename:join([SrcDir, "logs", Name]),
288+
case exec(["ln", "-snf", PrivDir, Target]) of
289+
{ok, _} -> ok;
290+
_ -> ct:pal(?LOW_IMPORTANCE,
291+
"Failed to symlink private_log directory.")
292+
end,
293+
Config;
294+
not_found ->
295+
ct:pal(?LOW_IMPORTANCE, "Failed to symlink private_log directory."),
296+
Config
297+
end.
298+
261299
%% -------------------------------------------------------------------
262300
%% Process to log a message every minute during long testcases.
263301
%% -------------------------------------------------------------------

0 commit comments

Comments
 (0)