2626-define (DEVS (N ), lists :concat ([" dev" , N , " @127.0.0.1" ])).
2727-define (DEV (N ), list_to_atom (? DEVS (N ))).
2828-define (PATH , (rt_config :get (rtdev_path ))).
29+ -define (DEBUG_LOG_FILE (N ),
30+ " dev" ++ integer_to_list (N ) ++ " @127.0.0.1-riak-debug.tar.gz" ).
2931
3032get_deps () ->
3133 lists :flatten (io_lib :format (" ~s /dev/dev1/lib" , [relpath (current )])).
@@ -52,6 +54,17 @@ riak_admin_cmd(Path, N, Args) ->
5254 ExecName = rt_config :get (exec_name , " riak" ),
5355 io_lib :format (" ~s /dev/dev~b /bin/~s -admin ~s " , [Path , N , ExecName , ArgStr ]).
5456
57+ riak_debug_cmd (Path , N , Args ) ->
58+ Quoted =
59+ lists :map (fun (Arg ) when is_list (Arg ) ->
60+ lists :flatten ([$" , Arg , $" ]);
61+ (_ ) ->
62+ erlang :error (badarg )
63+ end , Args ),
64+ ArgStr = string :join (Quoted , " " ),
65+ ExecName = rt_config :get (exec_name , " riak" ),
66+ io_lib :format (" ~s /dev/dev~b /bin/~s -debug ~s " , [Path , N , ExecName , ArgStr ]).
67+
5568run_git (Path , Cmd ) ->
5669 lager :info (" Running: ~s " , [gitcmd (Path , Cmd )]),
5770 {0 , Out } = cmd (gitcmd (Path , Cmd )),
@@ -765,6 +778,35 @@ get_node_logs() ->
765778 {lists :nthtail (RootLen , Filename ), Port }
766779 end || Filename <- filelib :wildcard (Root ++ " /*/dev/dev*/log/*" ) ].
767780
781+ get_node_debug_logs () ->
782+ NodeMap = rt_config :get (rt_nodes ),
783+ rt :pmap (fun (Node ) ->
784+ get_node_debug_logs (Node )
785+ end ,
786+ NodeMap ).
787+
788+ get_node_debug_logs ({_Node , NodeNum }) ->
789+ DebugLogFile = ? DEBUG_LOG_FILE (NodeNum ),
790+ delete_existing_debug_log_file (DebugLogFile ),
791+ Path = relpath (node_version (NodeNum )),
792+ Args = [" --logs" ],
793+ Cmd = riak_debug_cmd (Path , NodeNum , Args ),
794+ {ExitCode , Result } = wait_for_cmd (spawn_cmd (Cmd )),
795+ case ExitCode of
796+ 0 ->
797+ DebugLogFile ;
798+ _ ->
799+ exit ({ExitCode , Result })
800+ end .
801+
802+ % % If the debug log file exists from a previous test run it will cause the
803+ % % `riak_debug_cmd' to fail. Therefore, delete the `DebugLogFile' if it exists.
804+ % % Note that by ignoring the return value of `file:delete/1' this function
805+ % % works whether or not the `DebugLogFile' actually exists at the time it is
806+ % % called.
807+ delete_existing_debug_log_file (DebugLogFile ) ->
808+ file :delete (DebugLogFile ).
809+
768810% % @doc Performs a search against the log files on `Node' and returns all
769811% % matching lines.
770812-spec search_logs (node (), Pattern :: iodata ()) ->
0 commit comments