mirror of
https://github.com/valitydev/riak_test.git
synced 2024-11-06 08:35:22 +00:00
Use rt functions to safely remove backend data
Use riak_test_runner:metadata/0 to get the configured backend instead of defaulting to bitcask. Additionally we use rt:clean_data_dir/2 to safely remove backend directories.
This commit is contained in:
parent
5319e75269
commit
3bed92cfb4
@ -201,7 +201,7 @@ start_nodes(PL) ->
|
||||
[rt:start_and_wait(Node) || {{_, Node}, _} <- PL].
|
||||
|
||||
data_path(Node) ->
|
||||
?HARNESS:node_path(Node) ++ "/data/bitcask".
|
||||
?HARNESS:node_path(Node) ++ "/data/"++backend_dir().
|
||||
|
||||
backup_path(Node, N) ->
|
||||
data_path(Node) ++ integer_to_list(N) ++ ".bak".
|
||||
@ -221,8 +221,9 @@ restore_data(N, PL) ->
|
||||
restore_node(Node, N) ->
|
||||
Path = data_path(Node),
|
||||
BackupPath = backup_path(Node, N),
|
||||
Cmd = "rm -rf "++Path++" && mv "++BackupPath++" "++Path,
|
||||
lager:info("~p", [os:cmd(Cmd)]).
|
||||
rm_backend_dir(Node),
|
||||
Cmd = "mv "++BackupPath++" "++Path,
|
||||
?assertEqual([], os:cmd(Cmd)).
|
||||
|
||||
assert_lose_synctrees_and_recover(PBC, Bucket, Key, Val, PL, ToLose) ->
|
||||
{{Idx0, Node0}, primary} = hd(PL),
|
||||
@ -270,9 +271,29 @@ wipe_tree(Ensemble, Idx, Node) ->
|
||||
exit(Pid, kill).
|
||||
|
||||
wipe_partition(Idx, Node) ->
|
||||
rt:clean_data_dir([Node], "bitcask/"++integer_to_list(Idx)),
|
||||
rm_partition_dir(Idx, Node),
|
||||
vnode_util:kill_vnode({Idx, Node}).
|
||||
|
||||
rm_backend_dir(Node) ->
|
||||
rt:clean_data_dir([Node], backend_dir()).
|
||||
|
||||
rm_partition_dir(Idx, Node) ->
|
||||
RelativePath = backend_dir() ++ "/" ++ integer_to_list(Idx),
|
||||
rt:clean_data_dir([Node], RelativePath).
|
||||
|
||||
backend_dir() ->
|
||||
TestMetaData = riak_test_runner:metadata(),
|
||||
KVBackend = proplists:get_value(backend, TestMetaData),
|
||||
backend_dir(KVBackend).
|
||||
|
||||
backend_dir(undefined) ->
|
||||
%% riak_test defaults to bitcask when undefined
|
||||
backend_dir(bitcask);
|
||||
backend_dir(bitcask) ->
|
||||
"bitcask";
|
||||
backend_dir(eleveldb) ->
|
||||
"leveldb".
|
||||
|
||||
get_preflist(Node, Bucket, Key, NVal) ->
|
||||
DocIdx = rpc:call(Node, riak_core_util, chash_std_keyfun, [{Bucket, Key}]),
|
||||
PL = rpc:call(Node, riak_core_apl, get_primary_apl, [DocIdx, NVal, riak_kv]),
|
||||
|
Loading…
Reference in New Issue
Block a user