mirror of
https://github.com/valitydev/riak_test.git
synced 2024-11-06 08:35:22 +00:00
Make this test deterministic whether it likes it or not: intercept init
This commit is contained in:
parent
e003ca8152
commit
2ce3a57b1b
7
intercepts/init_intercepts.erl
Normal file
7
intercepts/init_intercepts.erl
Normal file
@ -0,0 +1,7 @@
|
||||
-module(init_intercepts).
|
||||
-compile(export_all).
|
||||
-include("intercept.hrl").
|
||||
-define(M, init_orig).
|
||||
|
||||
get_status() ->
|
||||
{starting, starting}.
|
@ -22,19 +22,6 @@
|
||||
-export([confirm/0]).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
-import(rt, [wait_until_nodes_ready/1,
|
||||
wait_until_no_pending_changes/1]).
|
||||
|
||||
%% We have to define our own deploy_nodes to force a race condition
|
||||
-define(HARNESS, (rt_config:get(rt_harness))).
|
||||
|
||||
|
||||
deploy_nodes(InitialConfig) ->
|
||||
NodeConfig = [{current, Config} || Config <- InitialConfig],
|
||||
Nodes = ?HARNESS:deploy_nodes(NodeConfig),
|
||||
lager:info("Start nodes ~p without waiting for services", [Nodes]),
|
||||
Nodes.
|
||||
|
||||
staged_join(InitiatingNode, DestinationNode) ->
|
||||
rpc:call(InitiatingNode, riak_core, staged_join,
|
||||
[DestinationNode]).
|
||||
@ -43,15 +30,16 @@ confirm() ->
|
||||
%% Deploy a set of new nodes
|
||||
lager:info("Deploying nodes"),
|
||||
|
||||
%% We want riak_core to be slow to start on node 2 to verify that
|
||||
%% the join will be disallowed if init is not yet complete
|
||||
Configs = [
|
||||
[{riak_core, []}],
|
||||
[{riak_core, [{delayed_start, 20000}]}]
|
||||
],
|
||||
[Node1, Node2] = rt:deploy_nodes(2),
|
||||
|
||||
[Node1, Node2] = deploy_nodes(Configs),
|
||||
configure_intercept(Node2),
|
||||
|
||||
lager:info("joining Node 2 to the cluster..."),
|
||||
?assertMatch({error, _}, staged_join(Node2, Node1)),
|
||||
pass.
|
||||
|
||||
%% init must return `starting' status for join to fail
|
||||
configure_intercept(Node) ->
|
||||
lager:info("Doing unspeakably evil things to the VM"),
|
||||
rt_intercept:add(Node, {init,
|
||||
[{{get_status,0}, get_status}]}).
|
||||
|
Loading…
Reference in New Issue
Block a user