Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Massive days work doing basic integration
- Loading branch information
Showing
13 changed files
with
307 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
.beam | ||
tests/.*$ | ||
riak_bench$ | ||
erl_crash.dump$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
|
||
all: | ||
./rebar compile test | ||
./rebar compile test escriptize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
|
||
-define(FAIL_MSG(Str, Args), ?ERROR(Str, Args), halt(1)). | ||
|
||
-define(CONSOLE(Str, Args), io:format(Str, Args)). | ||
|
||
-define(DEBUG(Str, Args), riak_bench_log:log(debug, Str, Args)). | ||
-define(INFO(Str, Args), riak_bench_log:log(info, Str, Args)). | ||
-define(WARN(Str, Args), riak_bench_log:log(warn, Str, Args)). | ||
-define(ERROR(Str, Args), riak_bench_log:log(error, Str, Args)). | ||
|
||
-define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
%% ------------------------------------------------------------------- | ||
%% | ||
%% riak_bench: Benchmarking Suite for Riak | ||
%% | ||
%% Copyright (c) 2009 Basho Techonologies | ||
%% | ||
%% This file is provided to you under the Apache License, | ||
%% Version 2.0 (the "License"); you may not use this file | ||
%% except in compliance with the License. You may obtain | ||
%% a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, | ||
%% software distributed under the License is distributed on an | ||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
%% KIND, either express or implied. See the License for the | ||
%% specific language governing permissions and limitations | ||
%% under the License. | ||
%% | ||
%% ------------------------------------------------------------------- | ||
-module(riak_bench). | ||
|
||
-export([main/1]). | ||
|
||
-include("riak_bench.hrl"). | ||
|
||
%% ==================================================================== | ||
%% API | ||
%% ==================================================================== | ||
|
||
main([Config]) -> | ||
%% Load baseline config | ||
ok = application:load(riak_bench), | ||
|
||
%% Initialize basic logging system | ||
riak_bench_log:init(), | ||
|
||
%% Load the config file | ||
riak_bench_config:load(Config), | ||
|
||
%% Setup working directory for this test. All logs, stats, and config | ||
%% info will be placed here | ||
{ok, Cwd} = file:get_cwd(), | ||
TestId = id(), | ||
TestDir = filename:join([Cwd, riak_bench_config:get(test_dir), TestId]), | ||
ok = filelib:ensure_dir(filename:join(TestDir, "foobar")), | ||
riak_bench_config:set(test_id, TestId), | ||
|
||
%% Create a link to the test dir for convenience | ||
TestLink = filename:join([Cwd, riak_bench_config:get(test_dir), "current"]), | ||
[] = os:cmd(?FMT("rm -f ~s; ln -sf ~s ~s", [TestLink, TestDir, TestLink])), | ||
|
||
%% Copy the config into the test dir for posterity | ||
{ok, _} = file:copy(Config, filename:join(TestDir, filename:basename(Config))), | ||
|
||
%% Spin up the application | ||
application:start(sasl), | ||
{ok, Pid} = riak_bench_sup:start_link(), | ||
|
||
?CONSOLE("Started!\n", []), | ||
|
||
?CONSOLE("Procs: ~p\n", [supervisor:which_children(Pid)]). | ||
|
||
|
||
|
||
%% ==================================================================== | ||
%% Internal functions | ||
%% ==================================================================== | ||
|
||
|
||
%% | ||
%% Construct a string suitable for use as a unique ID for this test run | ||
%% | ||
id() -> | ||
{{Y, M, D}, {H, Min, S}} = calendar:local_time(), | ||
?FMT("~w~2..0w~2..0w_~2..0w~2..0w~2..0w", [Y, M, D, H, Min, S]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
%% ------------------------------------------------------------------- | ||
%% | ||
%% riak_bench: Benchmarking Suite for Riak | ||
%% | ||
%% Copyright (c) 2009 Basho Techonologies | ||
%% | ||
%% This file is provided to you under the Apache License, | ||
%% Version 2.0 (the "License"); you may not use this file | ||
%% except in compliance with the License. You may obtain | ||
%% a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, | ||
%% software distributed under the License is distributed on an | ||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
%% KIND, either express or implied. See the License for the | ||
%% specific language governing permissions and limitations | ||
%% under the License. | ||
%% | ||
%% ------------------------------------------------------------------- | ||
-module(riak_bench_config). | ||
|
||
-export([load/1, | ||
set/2, | ||
get/1]). | ||
|
||
-include("riak_bench.hrl"). | ||
|
||
%% =================================================================== | ||
%% Public API | ||
%% =================================================================== | ||
|
||
load(File) -> | ||
case file:consult(File) of | ||
{ok, Terms} -> | ||
load_config(Terms); | ||
{error, Reason} -> | ||
?FAIL_MSG("Failed to parse config file ~s: ~p\n", [File, Reason]) | ||
end. | ||
|
||
set(Key, Value) -> | ||
ok = application:set_env(riak_bench, Key, Value). | ||
|
||
get(Key) -> | ||
case application:get_env(riak_bench, Key) of | ||
{ok, Value} -> | ||
Value; | ||
undefined -> | ||
erlang:error("Missing configuration key", [Key]) | ||
end. | ||
|
||
|
||
%% =================================================================== | ||
%% Internal functions | ||
%% =================================================================== | ||
|
||
load_config([]) -> | ||
ok; | ||
load_config([{Key, Value} | Rest]) -> | ||
?MODULE:set(Key, Value), | ||
load_config(Rest); | ||
load_config([ Other | Rest]) -> | ||
?WARN("Ignoring non-tuple config value: ~p\n", [Other]), | ||
load_config(Rest). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
%% ------------------------------------------------------------------- | ||
%% | ||
%% riak_bench: Benchmarking Suite for Riak | ||
%% | ||
%% Copyright (c) 2009 Basho Techonologies | ||
%% | ||
%% This file is provided to you under the Apache License, | ||
%% Version 2.0 (the "License"); you may not use this file | ||
%% except in compliance with the License. You may obtain | ||
%% a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, | ||
%% software distributed under the License is distributed on an | ||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
%% KIND, either express or implied. See the License for the | ||
%% specific language governing permissions and limitations | ||
%% under the License. | ||
%% | ||
%% ------------------------------------------------------------------- | ||
-module(riak_bench_log). | ||
|
||
-export([init/0, | ||
log/3]). | ||
|
||
%% =================================================================== | ||
%% Public API | ||
%% =================================================================== | ||
|
||
init() -> | ||
application:set_env(riak_bench, log_level, debug). | ||
|
||
log(Level, Str, Args) -> | ||
{ok, LogLevel} = application:get_env(riak_bench, log_level), | ||
case should_log(LogLevel, Level) of | ||
true -> | ||
io:format(log_prefix(Level) ++ Str, Args); | ||
false -> | ||
ok | ||
end. | ||
|
||
%% =================================================================== | ||
%% Internal functions | ||
%% =================================================================== | ||
|
||
should_log(debug, _) -> true; | ||
should_log(info, debug) -> false; | ||
should_log(info, _) -> true; | ||
should_log(warn, debug) -> false; | ||
should_log(warn, info) -> false; | ||
should_log(warn, _) -> true; | ||
should_log(error, error) -> true; | ||
should_log(error, _) -> false; | ||
should_log(_, _) -> false. | ||
|
||
log_prefix(debug) -> "DEBUG:" ; | ||
log_prefix(info) -> "INFO: "; | ||
log_prefix(warn) -> "WARN: "; | ||
log_prefix(error) -> "ERROR: ". | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.