Added the capacity for a ~/.riak_test.config file

This commit is contained in:
Joe DeVivo 2012-08-15 12:48:50 -07:00
parent 0aef4b6c79
commit 5cd79f6bb2
3 changed files with 62 additions and 4 deletions

View File

@ -4,11 +4,12 @@
Assumes `riak_test` and `riak` and/or `riak-ee` are all checked out in the same parent folder
1. Edit your `rtdev.config` file's rt_deps url
1. Edit your `cp riak_test.config.sample` to `~/.riak_test.config`
1. Update your new `~/.riak_test.config` file's rt_deps url
1. `cd ../riak[-ee]`
1. `make devrel`
1. `. ../riak_test/rtdev-setup.sh`
1. `cd back to riak_test`
1. `riak_test rtdev.config verify_build_cluster`
1. `riak_test rtdev verify_build_cluster`
`~/.riak_test.config` stores multiple configurations, and you can pass them by name as the first argument to `riak_test`. First it looks for a file with that name in your local directory, if it doesn't find it, it looks for something with that name in `~/.riak_test.config`

39
riak_test.config.sample Normal file
View File

@ -0,0 +1,39 @@
{rtdev, [
{rt_deps, ["/Users/joe/dev/basho/riak/deps","deps"]},
{rt_max_wait_time, 180000},
{rt_retry_delay, 500},
{rt_harness, rtdev},
{rtdev_path, "/tmp/rt"}
]}.
{rtdev_mixed, [
{rt_deps, ["/Users/joe/dev/basho/riak/deps"]},
{rt_max_wait_time, 180000},
{rt_retry_delay, 500},
{rt_harness, rtdev},
{rtdev_path, [{root, "/tmp/rt"},
{current, "/tmp/rt/current"},
{"1.1.4", "/tmp/rt/riak-1.1.4"},
{"1.0.3", "/tmp/rt/riak-1.0.3"}]}
]}.
{rtdev_ee, [
{rt_deps, ["/Users/joe/dev/basho/riak_ee/deps","deps"]},
{rt_max_wait_time, 180000},
{rt_retry_delay, 500},
{rt_harness, rtdev},
{rtdev_path, "/tmp/rt_ee"}
]}.
{rtdev_ee_mixed, [
{rt_deps, ["/Users/joe/dev/basho/riak_ee/deps"]},
{rt_max_wait_time, 180000},
{rt_retry_delay, 500},
{rt_harness, rtdev},
{rtdev_path, [{root, "/tmp/rt"},
{current, "/tmp/rt/current"},
{"1.1.4", "/tmp/rt/riak_ee-1.1.4"},
{"1.0.3", "/tmp/rt/riak_ee-1.0.3"}]}
]}.

View File

@ -395,12 +395,30 @@ setup_harness(Test, Args) ->
cleanup_harness() ->
?HARNESS:cleanup_harness().
load_config(ConfigName) ->
case load_config_file(ConfigName) of
ok -> ok;
{error, enoent} -> load_dot_config(ConfigName)
end.
%% @private
load_config(File) ->
load_dot_config(ConfigName) ->
case file:consult(filename:join([os:getenv("HOME"), ".riak_test.config"])) of
{ok, Terms} ->
Config = proplists:get_value(list_to_atom(ConfigName), Terms),
[set_config(Key, Value) || {Key, Value} <- Config],
ok;
{error, Reason} ->
erlang:error("Failed to parse config file", ["~/.riak_test.config", Reason])
end.
%% @private
load_config_file(File) ->
case file:consult(File) of
{ok, Terms} ->
[set_config(Key, Value) || {Key, Value} <- Terms],
ok;
{error, enoent} ->
{error, enoent};
{error, Reason} ->
erlang:error("Failed to parse config file", [File, Reason])
end.