mirror of
https://github.com/valitydev/riak_test.git
synced 2024-11-06 08:35:22 +00:00
Merge branch 'jdb-handoff-ip'
This commit is contained in:
commit
d6327e080f
60
tests/gh_riak_core_176.erl
Normal file
60
tests/gh_riak_core_176.erl
Normal file
@ -0,0 +1,60 @@
|
||||
-module(gh_riak_core_176).
|
||||
-export([gh_riak_core_176/0]).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
gh_riak_core_176() ->
|
||||
Nodes = rt:deploy_nodes(3),
|
||||
[Node1, Node2, Node3] = Nodes,
|
||||
Nodes12 = [Node1, Node2],
|
||||
Nodes123 = Nodes,
|
||||
|
||||
%% Stolen from riak_core_handoff_sender.erl
|
||||
[_Name,Host] = string:tokens(atom_to_list(Node2), "@"),
|
||||
|
||||
%% Get IP associated with node name
|
||||
{ok, NodeIP} = inet:getaddr(Host, inet),
|
||||
|
||||
%% Find alternative IP
|
||||
{ok, IfAddrs} = inet:getifaddrs(),
|
||||
Addrs =
|
||||
lists:flatmap(
|
||||
fun({_If, Props}) ->
|
||||
[Addr || {addr, Addr} <- Props,
|
||||
size(Addr) == 4]
|
||||
end, IfAddrs),
|
||||
AlternateIP = ip_tuple_to_string(hd(Addrs -- [NodeIP])),
|
||||
|
||||
lager:info("Change ~p handoff_ip from ~p to ~p",
|
||||
[Node2, NodeIP, AlternateIP]),
|
||||
NewConfig = [{riak_core, [{handoff_ip, AlternateIP}]}],
|
||||
rt:update_app_config(Node2, NewConfig),
|
||||
|
||||
lager:info("Write data to the cluster"),
|
||||
rt:systest_write(Node1, 100),
|
||||
|
||||
lager:info("Join ~p to the cluster and wait for handoff to finish",
|
||||
[Node2]),
|
||||
rt:join(Node2, Node1),
|
||||
?assertEqual(ok, rt:wait_until_nodes_ready(Nodes12)),
|
||||
?assertEqual(ok, rt:wait_until_no_pending_changes(Nodes12)),
|
||||
[?assertEqual(Nodes12, rt:owners_according_to(Node)) || Node <- Nodes12],
|
||||
|
||||
%% Check 0.0.0.0 address works
|
||||
lager:info("Change ~p handoff_ip to \"0.0.0.0\"", [Node3]),
|
||||
rt:update_app_config(Node3,
|
||||
[{riak_core, [{handoff_ip, "0.0.0.0"}]}]),
|
||||
|
||||
lager:info("Join ~p to the cluster and wait for handoff to finish",
|
||||
[Node3]),
|
||||
rt:join(Node3, Node1),
|
||||
?assertEqual(ok, rt:wait_until_nodes_ready(Nodes123)),
|
||||
?assertEqual(ok, rt:wait_until_no_pending_changes(Nodes123)),
|
||||
[?assertEqual(Nodes123, rt:owners_according_to(Node)) || Node <- Nodes123],
|
||||
|
||||
lager:info("Test gh_riak_core_176 passed"),
|
||||
ok.
|
||||
|
||||
ip_tuple_to_string(T) ->
|
||||
L = tuple_to_list(T),
|
||||
string:join([integer_to_list(X) || X <- L], ".").
|
||||
|
Loading…
Reference in New Issue
Block a user