2014-02-20 03:54:38 +00:00
|
|
|
-module(repl_fs_bench).
|
2014-02-28 21:04:21 +00:00
|
|
|
|
2014-02-19 22:11:02 +00:00
|
|
|
-export([confirm/0]).
|
2014-02-28 21:04:21 +00:00
|
|
|
|
2014-02-19 22:11:02 +00:00
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
|
2014-02-28 21:04:21 +00:00
|
|
|
-define(DIFF_NUM_KEYS, 10).
|
|
|
|
-define(FULL_NUM_KEYS, 100).
|
2014-02-19 22:11:02 +00:00
|
|
|
-define(TEST_BUCKET, <<"repl_bench">>).
|
2014-02-20 03:54:38 +00:00
|
|
|
|
2014-02-20 20:21:13 +00:00
|
|
|
-define(HARNESS, (rt_config:get(rt_harness))).
|
|
|
|
|
2014-02-20 03:54:38 +00:00
|
|
|
-define(CONF(Strategy), [
|
2014-02-19 22:11:02 +00:00
|
|
|
{riak_core,
|
|
|
|
[
|
|
|
|
{ring_creation_size, 8},
|
2014-02-20 19:58:03 +00:00
|
|
|
{default_bucket_props, [{n_val, 1}, {allow_mult, false}]}
|
2014-02-19 22:11:02 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{riak_kv,
|
|
|
|
[
|
|
|
|
{anti_entropy, {on, []}},
|
|
|
|
{anti_entropy_build_limit, {100, 1000}},
|
|
|
|
{anti_entropy_concurrency, 100}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{riak_repl,
|
|
|
|
[
|
2014-02-20 03:54:38 +00:00
|
|
|
{fullsync_strategy, Strategy},
|
2014-02-19 22:11:02 +00:00
|
|
|
{fullsync_on_connect, false},
|
|
|
|
{fullsync_interval, disabled},
|
2014-02-20 19:58:03 +00:00
|
|
|
{max_fssource_retries, infinity},
|
|
|
|
{max_fssource_cluster, 1},
|
|
|
|
{max_fssource_node, 1},
|
|
|
|
{max_fssink_node, 1}
|
2014-02-19 22:11:02 +00:00
|
|
|
]}
|
|
|
|
]).
|
|
|
|
|
|
|
|
confirm() ->
|
2014-02-28 21:04:21 +00:00
|
|
|
{E1, F1, D1, N1} = fullsync_test(keylist, 0),
|
|
|
|
{E2, F2, D2, N2} = fullsync_test(keylist, 10),
|
|
|
|
{E3, F3, D3, N3} = fullsync_test(keylist, 100),
|
2014-02-20 20:21:13 +00:00
|
|
|
|
2014-02-28 21:04:21 +00:00
|
|
|
{E4, F4, D4, N4} = fullsync_test(aae, 0),
|
|
|
|
{E5, F5, D5, N5} = fullsync_test(aae, 10),
|
|
|
|
{E6, F6, D6, N6} = fullsync_test(aae, 100),
|
2014-02-20 20:21:13 +00:00
|
|
|
|
2014-02-28 21:04:21 +00:00
|
|
|
lager:info("Keylist Empty: ~pms ~pms ~pms", [E1 / 1000, E2 / 1000, E3 / 1000]),
|
|
|
|
lager:info("Keylist Full: ~pms ~pms ~pms", [F1 / 1000, F2 / 1000, F3 / 1000]),
|
|
|
|
lager:info("Keylist Diff: ~pms ~pms ~pms", [D1 / 1000, D2 / 1000, D3 / 1000]),
|
|
|
|
lager:info("Keylist None: ~pms ~pms ~pms", [N1 / 1000, N2 / 1000, N3 / 1000]),
|
2014-02-20 03:54:38 +00:00
|
|
|
|
2014-02-28 21:04:21 +00:00
|
|
|
lager:info("AAE Empty: ~pms ~pms ~pms", [E4 / 1000, E5 / 1000, E6 / 1000]),
|
|
|
|
lager:info("AAE Full: ~pms ~pms ~pms", [F4 / 1000, F5 / 1000, F6 / 1000]),
|
|
|
|
lager:info("AAE Diff: ~pms ~pms ~pms", [D4 / 1000, D5 / 1000, D6 / 1000]),
|
|
|
|
lager:info("AAE None: ~pms ~pms ~pms", [N4 / 1000, N5 / 1000, N6 / 1000]),
|
2014-02-20 03:54:38 +00:00
|
|
|
|
|
|
|
pass.
|
|
|
|
|
2014-02-28 21:04:21 +00:00
|
|
|
%% @doc Perform a fullsync, with given latency injected via intercept
|
|
|
|
%% and return times for each fullsync time.
|
|
|
|
fullsync_test(Strategy, Latency) ->
|
2014-02-20 03:54:38 +00:00
|
|
|
rt:set_advanced_conf(all, ?CONF(Strategy)),
|
2014-02-20 20:21:13 +00:00
|
|
|
|
2014-02-24 16:56:54 +00:00
|
|
|
[ANodes, BNodes] = rt:build_clusters([3, 3]),
|
2014-02-19 22:11:02 +00:00
|
|
|
|
2014-12-18 21:07:00 +00:00
|
|
|
rt:wait_for_cluster_service(ANodes, riak_repl),
|
|
|
|
rt:wait_for_cluster_service(BNodes, riak_repl),
|
|
|
|
|
2014-02-19 22:11:02 +00:00
|
|
|
AFirst = hd(ANodes),
|
|
|
|
BFirst = hd(BNodes),
|
|
|
|
|
2014-03-04 21:21:22 +00:00
|
|
|
[rt_intercept:load_code(Node) || Node <- ANodes],
|
|
|
|
|
2014-02-28 21:04:21 +00:00
|
|
|
case {Strategy, Latency} of
|
|
|
|
{aae, 10} ->
|
|
|
|
[rt_intercept:add(Node,
|
|
|
|
{riak_repl_aae_source,
|
|
|
|
[{{get_reply, 1}, delayed_get_reply}]})
|
|
|
|
|| Node <- ANodes],
|
|
|
|
ok;
|
|
|
|
{keylist, 10} ->
|
|
|
|
[rt_intercept:add(Node,
|
|
|
|
{riak_repl2_fssource,
|
|
|
|
[{{handle_info, 2}, slow_handle_info}]})
|
|
|
|
|| Node <- ANodes],
|
|
|
|
ok;
|
|
|
|
{aae, 100} ->
|
|
|
|
[rt_intercept:add(Node,
|
|
|
|
{riak_repl_aae_source,
|
|
|
|
[{{get_reply, 1}, really_delayed_get_reply}]})
|
|
|
|
|| Node <- ANodes],
|
|
|
|
ok;
|
|
|
|
{keylist, 100} ->
|
|
|
|
[rt_intercept:add(Node,
|
|
|
|
{riak_repl2_fssource,
|
|
|
|
[{{handle_info, 2}, really_slow_handle_info}]})
|
|
|
|
|| Node <- ANodes],
|
|
|
|
ok;
|
|
|
|
_ ->
|
|
|
|
ok
|
|
|
|
end,
|
|
|
|
|
2014-02-19 22:11:02 +00:00
|
|
|
repl_util:name_cluster(AFirst, "A"),
|
|
|
|
repl_util:name_cluster(BFirst, "B"),
|
|
|
|
|
|
|
|
rt:wait_until_ring_converged(ANodes),
|
|
|
|
rt:wait_until_ring_converged(BNodes),
|
|
|
|
|
|
|
|
?assertEqual(ok, repl_util:wait_until_leader_converge(ANodes)),
|
|
|
|
?assertEqual(ok, repl_util:wait_until_leader_converge(BNodes)),
|
|
|
|
|
2014-02-28 21:04:21 +00:00
|
|
|
LeaderA = rpc:call(AFirst,
|
|
|
|
riak_core_cluster_mgr, get_leader, []),
|
2014-02-19 22:11:02 +00:00
|
|
|
|
2014-02-28 21:04:21 +00:00
|
|
|
{ok, {IP, Port}} = rpc:call(BFirst,
|
|
|
|
application, get_env, [riak_core, cluster_mgr]),
|
2014-02-19 22:11:02 +00:00
|
|
|
|
|
|
|
repl_util:connect_cluster(LeaderA, IP, Port),
|
|
|
|
?assertEqual(ok, repl_util:wait_for_connection(LeaderA, "B")),
|
|
|
|
|
|
|
|
repl_util:enable_fullsync(LeaderA, "B"),
|
|
|
|
rt:wait_until_ring_converged(ANodes),
|
|
|
|
|
|
|
|
?assertEqual(ok, repl_util:wait_for_connection(LeaderA, "B")),
|
|
|
|
|
|
|
|
%% Perform fullsync of an empty cluster.
|
2014-05-12 18:55:59 +00:00
|
|
|
rt:wait_until_aae_trees_built(ANodes ++ BNodes),
|
2014-02-20 19:58:03 +00:00
|
|
|
{EmptyTime, _} = timer:tc(repl_util,
|
|
|
|
start_and_wait_until_fullsync_complete,
|
|
|
|
[LeaderA]),
|
2014-02-19 22:11:02 +00:00
|
|
|
|
2014-02-20 03:54:38 +00:00
|
|
|
%% Write keys and perform fullsync.
|
2014-02-28 21:04:21 +00:00
|
|
|
repl_util:write_to_cluster(AFirst, 0, ?FULL_NUM_KEYS, ?TEST_BUCKET),
|
2014-05-12 18:55:59 +00:00
|
|
|
rt:wait_until_aae_trees_built(ANodes ++ BNodes),
|
2014-02-20 19:58:03 +00:00
|
|
|
{FullTime, _} = timer:tc(repl_util,
|
|
|
|
start_and_wait_until_fullsync_complete,
|
|
|
|
[LeaderA]),
|
2014-02-19 22:11:02 +00:00
|
|
|
|
2014-02-20 03:54:38 +00:00
|
|
|
%% Rewrite first 10% keys and perform fullsync.
|
2014-03-09 01:46:55 +00:00
|
|
|
repl_util:write_to_cluster(AFirst, 0, ?DIFF_NUM_KEYS, ?TEST_BUCKET),
|
2014-05-12 18:55:59 +00:00
|
|
|
rt:wait_until_aae_trees_built(ANodes ++ BNodes),
|
2014-02-20 19:58:03 +00:00
|
|
|
{DiffTime, _} = timer:tc(repl_util,
|
|
|
|
start_and_wait_until_fullsync_complete,
|
|
|
|
[LeaderA]),
|
2014-02-19 22:11:02 +00:00
|
|
|
|
2014-02-20 19:58:03 +00:00
|
|
|
%% Write no keys, and perform the fullsync.
|
2014-05-12 18:55:59 +00:00
|
|
|
rt:wait_until_aae_trees_built(ANodes ++ BNodes),
|
2014-02-20 19:58:03 +00:00
|
|
|
{NoneTime, _} = timer:tc(repl_util,
|
|
|
|
start_and_wait_until_fullsync_complete,
|
|
|
|
[LeaderA]),
|
|
|
|
|
2014-02-20 20:21:13 +00:00
|
|
|
rt:clean_cluster(ANodes),
|
|
|
|
rt:clean_cluster(BNodes),
|
|
|
|
|
2014-02-20 19:58:03 +00:00
|
|
|
{EmptyTime, FullTime, DiffTime, NoneTime}.
|