Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow secondary location for intercepts. #818

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions intercepts/riak_core_vnode_master_intercepts.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ stop_vnode_after_bloom_fold_request_succeeds(IndexNode, Req, Sender, VMaster) ->

case (ReqFun == fun riak_repl_aae_source:bloom_fold/3 orelse ReqFun == fun riak_repl_keylist_server:bloom_fold/3) of
true ->
random:seed(erlang:now()),
random:seed(time_compat:timestamp()),
case random:uniform(10) of
5 ->
%% Simulate what happens when a VNode completes handoff between command_returning_vnode
Expand All @@ -32,4 +32,4 @@ stop_vnode_after_bloom_fold_request_succeeds(IndexNode, Req, Sender, VMaster) ->
?M:command_return_vnode_orig(IndexNode, Req, Sender, VMaster)
end;
false -> ?M:command_return_vnode_orig(IndexNode, Req, Sender, VMaster)
end.
end.
2 changes: 1 addition & 1 deletion intercepts/riak_kv_vnode_intercepts.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ wrong_node(_Partition) ->

%% @doc Make all KV vnode coverage commands take abnormally long.
slow_handle_coverage(Req, Filter, Sender, State) ->
random:seed(erlang:now()),
random:seed(time_compat:timestamp()),
Rand = random:uniform(5000),
error_logger:info_msg("coverage sleeping ~p", [Rand]),
timer:sleep(Rand),
Expand Down
18 changes: 9 additions & 9 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{require_otp_vsn, "R13B04|R14|R15|R16"}.
{cover_enabled, true}.
{edoc_opts, [{preprocess, true}]}.
%%{edoc_opts, [{doclet, edown_doclet}, {pretty_printer, erl_pp}]}.
%%{edoc_opts, [{doclet, my_layout}, {pretty_printer, erl_pp}]}.
%%{edoc_opts, [{layout, my_layout}, {file_suffix, ".xml"}, {pretty_printer, erl_pp}]}.
{erl_opts, [{src_dirs, [src, intercepts, perf]},
warnings_as_errors, {parse_transform, lager_transform}]}.
{platform_define, "^[0-9]+", namespaced_types},
warnings_as_errors,
{parse_transform, lager_transform}]}.

{erl_first_files, ["src/rt_intercept_pt.erl"]}.

{eunit_opts, [verbose]}.

{deps, [
{lager, ".*", {git, "git://github.com/basho/lager", {tag, "2.0.3"}}},
{lager, "(2.0|2.1|2.2).*", {git, "git://github.com/basho/lager.git", {tag, "2.2.0"}}},
{getopt, ".*", {git, "git://github.com/jcomellas/getopt", {tag, "v0.4"}}},
{meck, ".*", {git, "git://github.com/basho/meck.git", {tag, "0.8.2"}}},
{mapred_verify, ".*", {git, "git://github.com/basho/mapred_verify", {branch, "master"}}},
{riakc, ".*", {git, "git://github.com/basho/riak-erlang-client", {branch, "master"}}},
{riakhttpc, ".*", {git, "git://github.com/basho/riak-erlang-http-client", {branch, "master"}}},
{kvc, "1.3.0", {git, "https://github.com/etrepum/kvc", {tag, "v1.3.0"}}},
{druuid, ".*", {git, "git://github.com/kellymclaughlin/druuid.git", {tag, "0.2"}}}
{kvc, ".*", {git, "https://github.com/etrepum/kvc", {branch, "master"}}},
{druuid, ".*", {git, "git://github.com/kellymclaughlin/druuid.git", {tag, "0.2"}}},
{time_compat, ".*", {git, "git://github.com/lasp-lang/time_compat.git", {branch, "master"}}}
]}.

{escript_incl_apps, [goldrush, lager, getopt, riakhttpc, riakc, ibrowse, mochiweb, kvc]}.
{escript_incl_apps, [goldrush, lager, getopt, kvc]}.
{escript_emu_args, "%%! -escript main riak_test_escript +K true +P 10000 -env ERL_MAX_PORTS 10000\n"}.
{plugin_dir, "src"}.
{plugins, [rebar_riak_test_plugin]}.
Expand Down
1 change: 0 additions & 1 deletion riak

This file was deleted.

8 changes: 4 additions & 4 deletions src/rt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,18 @@ cmd(Cmd, Opts) ->
-spec stream_cmd(string()) -> {integer(), string()}.
stream_cmd(Cmd) ->
Port = open_port({spawn, binary_to_list(iolist_to_binary(Cmd))}, [stream, stderr_to_stdout, exit_status]),
stream_cmd_loop(Port, "", "", now()).
stream_cmd_loop(Port, "", "", time_compat:timestamp()).

%% @doc same as rt:stream_cmd/1, but with options, like open_port/2
-spec stream_cmd(string(), string()) -> {integer(), string()}.
stream_cmd(Cmd, Opts) ->
Port = open_port({spawn, binary_to_list(iolist_to_binary(Cmd))}, [stream, stderr_to_stdout, exit_status] ++ Opts),
stream_cmd_loop(Port, "", "", now()).
stream_cmd_loop(Port, "", "", time_compat:timestamp()).

stream_cmd_loop(Port, Buffer, NewLineBuffer, Time={_MegaSecs, Secs, _MicroSecs}) ->
receive
{Port, {data, Data}} ->
{_, Now, _} = now(),
{_, Now, _} = time_compat:timestamp(),
NewNewLineBuffer = case Now > Secs of
true ->
lager:info(NewLineBuffer),
Expand All @@ -560,7 +560,7 @@ stream_cmd_loop(Port, Buffer, NewLineBuffer, Time={_MegaSecs, Secs, _MicroSecs})
[ lager:info(Token) || Token <- Tokens ],
stream_cmd_loop(Port, Buffer ++ NewNewLineBuffer ++ Data, "", Time);
_ ->
stream_cmd_loop(Port, Buffer, NewNewLineBuffer ++ Data, now())
stream_cmd_loop(Port, Buffer, NewNewLineBuffer ++ Data, time_compat:timestamp())
end;
{Port, {exit_status, Status}} ->
catch port_close(Port),
Expand Down
2 changes: 1 addition & 1 deletion src/rt_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ get_os_env(Var, Default) ->

%% @doc Load the configuration from the specified config file.
load(Config, undefined) ->
load(Config, filename:join([os:getenv("HOME"), ".riak_test.config"]));
load(Config, filename:join([os:getenv("PWD"), ".riak_test.config"]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the motivation, but shouldn't this be additive? Check pwd first, if it's not there, check HOME?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change shouldn't have made it in; this is a Lasp-specific change.

load(undefined, ConfigFile) ->
load_dot_config("default", ConfigFile);
load(ConfigName, ConfigFile) ->
Expand Down
8 changes: 7 additions & 1 deletion src/rt_cover.erl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
stop_on_node/1
]).

-ifdef(namespaced_types).
-type cover_dict() :: dict:dict().
-else.
-type cover_dict() :: dict().
-endif.

-define(COVER_SERVER, cover_server).

-record(cover_info, {module :: atom(),
Expand Down Expand Up @@ -280,7 +286,7 @@ acc_cov(CovList) when is_list(CovList) ->
end,
lists:foldl(AddCov, {0, 0}, CovList).

-spec group_by_app(ModCovList:: [#cover_info{}], Mod2App :: dict()) ->
-spec group_by_app(ModCovList:: [#cover_info{}], Mod2App :: cover_dict()) ->
[{string(), number(), [#cover_info{}]}].
group_by_app(ModCovList, Mod2App) ->
D1 = lists:foldl(fun(ModCov = #cover_info{module=Mod}, Acc) ->
Expand Down
13 changes: 7 additions & 6 deletions src/rt_intercept.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@
files_to_mods(Files) ->
[list_to_atom(filename:basename(F, ".erl")) || F <- Files].

default_intercept_path_glob() ->
filename:join([rt_local:home_dir(), "intercepts", "*.erl"]).
default_intercept_path_globs() ->
Globs = rt_config:get(intercept_globs, []),
[filename:join([rt_local:home_dir(), "intercepts", "*.erl"])] ++ Globs.

intercept_files() ->
intercept_files([default_intercept_path_glob()]).
intercept_files(default_intercept_path_globs()).

intercept_files(Globs) ->
lists:concat([filelib:wildcard(Glob) || Glob <- Globs]).

%% @doc Load the intercepts on the nodes under test.
-spec load_intercepts([node()]) -> ok.
load_intercepts(Nodes) ->
load_intercepts(Nodes, [default_intercept_path_glob()]).
load_intercepts(Nodes, default_intercept_path_globs()).

-spec load_intercepts([node()], [string()]) -> ok.
load_intercepts(Nodes, Globs) ->
Expand All @@ -52,7 +53,7 @@ load_intercepts(Nodes, Globs) ->
end.

load_code(Node) ->
load_code(Node, [default_intercept_path_glob()]).
load_code(Node, default_intercept_path_globs()).

load_code(Node, Globs) ->
rt:wait_until_pingable(Node),
Expand Down Expand Up @@ -122,7 +123,7 @@ wait_until_loaded(Node, Tries) ->
end.

are_intercepts_loaded(Node) ->
are_intercepts_loaded(Node, [default_intercept_path_glob()]).
are_intercepts_loaded(Node, default_intercept_path_globs()).

are_intercepts_loaded(Node, Globs) ->
Results = [rpc:call(Node, code, is_loaded, [Mod])
Expand Down
10 changes: 5 additions & 5 deletions src/rt_local.erl
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ install_on_absence(Command, InstallCommand) ->
-spec stream_cmd(string()) -> {integer(), string()}.
stream_cmd(Cmd) ->
Port = open_port({spawn, binary_to_list(iolist_to_binary(Cmd))}, [stream, stderr_to_stdout, exit_status]),
stream_cmd_loop(Port, "", "", now()).
stream_cmd_loop(Port, "", "", time_compat:timestamp()).

%% @doc same as rt:stream_cmd/1, but with options, like open_port/2
-spec stream_cmd(string(), string()) -> {integer(), string()}.
stream_cmd(Cmd, Opts) ->
Port = open_port({spawn, binary_to_list(iolist_to_binary(Cmd))}, [stream, stderr_to_stdout, exit_status] ++ Opts),
stream_cmd_loop(Port, "", "", now()).
stream_cmd_loop(Port, "", "", time_compat:timestamp()).

stream_cmd_loop(Port, Buffer, NewLineBuffer, Time={_MegaSecs, Secs, _MicroSecs}) ->
receive
{Port, {data, Data}} ->
{_, Now, _} = now(),
{_, Now, _} = time_compat:timestamp(),
NewNewLineBuffer = case Now > Secs of
true ->
lager:info(NewLineBuffer),
Expand All @@ -110,11 +110,11 @@ stream_cmd_loop(Port, Buffer, NewLineBuffer, Time={_MegaSecs, Secs, _MicroSecs})
[ lager:info(Token) || Token <- Tokens ],
stream_cmd_loop(Port, Buffer ++ NewNewLineBuffer ++ Data, "", Time);
_ ->
stream_cmd_loop(Port, Buffer, NewNewLineBuffer ++ Data, now())
stream_cmd_loop(Port, Buffer, NewNewLineBuffer ++ Data, time_compat:timestamp())
end;
{Port, {exit_status, Status}} ->
catch port_close(Port),
{Status, Buffer}
after rt_config:get(rt_max_wait_time) ->
{-1, Buffer}
end.
end.
2 changes: 1 addition & 1 deletion src/observer.erl → src/rt_observer.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-module(observer).
-module(rt_observer).
-compile(export_all).

-record(history, {network,
Expand Down
2 changes: 1 addition & 1 deletion src/rtperf.erl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ start_data_collectors(Nodes) ->
PrepDir = "/tmp/perf-"++OSPid,
file:make_dir(PrepDir),
{ok, Hostname} = inet:gethostname(),
P = observer:watch(Nodes, {Hostname, 65001, PrepDir}),
P = rt_observer:watch(Nodes, {Hostname, 65001, PrepDir}),
lager:info("started data collector: ~p", [P]),
P.

Expand Down
Loading