Skip to content

Commit

Permalink
Use DC manager instead of configuring the test setup manually (#405)
Browse files Browse the repository at this point in the history
* Use DC manager instead of configuring the test setup manually

* Set sync_log flag to true for systests

* No need to filter own descriptor

* Bumped erlang 21 version and added erlang 22 to pipeline

* Added meta data broadcast test

* Fixed random_test to really send request to a random node
  • Loading branch information
albsch authored and peterzeller committed Nov 22, 2019
1 parent cc05b40 commit 7e48b47
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 201 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: erlang
otp_release:
- 21.2
- 21.3
- 22.1
install:
- make
- ./rebar3 update
Expand Down
40 changes: 35 additions & 5 deletions test/multidc/antidote_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
%% tests
-export([
dummy_test/1,
random_test/1
]).
random_test/1,
meta_data_env_test/1
]).

-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
Expand All @@ -68,7 +69,8 @@ end_per_testcase(Name, _) ->
all() ->
[
dummy_test,
random_test
random_test,
meta_data_env_test
].


Expand Down Expand Up @@ -96,15 +98,15 @@ dummy_test(Config) ->


%% Test that perform NumWrites increments to the key:key1.
%% Each increment is sent to a random node of the cluster.
%% Each increment is sent to a random node of a random DC.
%% Test normal behavior of the antidote
%% Performs a read to the first node of the cluster to check whether all the
%% increment operations where successfully applied.
%% Variables: N: Number of nodes
%% Nodes: List of the nodes that belong to the built cluster
random_test(Config) ->
Bucket = ?BUCKET,
Nodes = proplists:get_value(nodes, Config),
Nodes = lists:flatten(proplists:get_value(clusters, Config)),
N = length(Nodes),

% Distribute the updates randomly over all DCs
Expand All @@ -130,3 +132,31 @@ random_test(Config) ->
Retry = 360000 div Delay, %wait for max 1 min
ok = time_utils:wait_until_result(G, NumWrites, Retry, Delay),
pass.


%% tests the meta data broadcasting mechanism for environment variables
meta_data_env_test(Config) ->
[[Node1, Node2] | _] = proplists:get_value(clusters, Config),
DC = [Node1, Node2],

%% save old value, each node should have the same value
OldValue = rpc:call(Node1, dc_meta_data_utilities, get_env_meta_data, [sync_log, undefined]),
OldValue = rpc:call(Node2, dc_meta_data_utilities, get_env_meta_data, [sync_log, undefined]),

%% turn on sync and check for each node if update was propagated
ok = rpc:call(Node1, logging_vnode, set_sync_log, [true]),
lists:foreach(fun(Node) ->
time_utils:wait_until(fun() -> Value = rpc:call(Node, logging_vnode, is_sync_log, []), Value == true end)
end, DC),

%% turn off sync and check for each node if update was propagated
ok = rpc:call(Node2, logging_vnode, set_sync_log, [false]),
lists:foreach(fun(Node) ->
time_utils:wait_until(fun() -> Value = rpc:call(Node, logging_vnode, is_sync_log, []), Value == false end)
end, DC),

%% restore sync and check for each node if update was propagated
ok = rpc:call(Node1, logging_vnode, set_sync_log, [OldValue]),
lists:foreach(fun(Node) ->
time_utils:wait_until(fun() -> Value = rpc:call(Node, logging_vnode, is_sync_log, []), Value == OldValue end)
end, DC).
4 changes: 2 additions & 2 deletions test/multidc/pb_client_cluster_management_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ all() -> [
setup_cluster_test(Config) ->
NodeNames = [clusterdev1, clusterdev2, clusterdev3, clusterdev4],
Nodes = test_utils:pmap(fun(Node) -> test_utils:start_node(Node, Config) end, NodeNames),
[Node1, Node2, Node3, Node4] = Nodes,
[Node1, Node2, Node3, Node4] = test_utils:unpack(Nodes),

% join cluster 1:
P1 = spawn_link(fun() ->
{ok, Pb} = antidotec_pb_socket:start(?ADDRESS, test_utils:web_ports(clusterdev1) + 2),
ct:pal("joining clusterdev1, clusterdev2"),

Response = antidotec_pb_management:create_dc(Pb, [Node1, Node2]),
ct:pal("joined clusterdev1, clusterdev2: ~p", [Response]),
?assertEqual(ok, Response),
Expand Down
Loading

0 comments on commit 7e48b47

Please sign in to comment.