Skip to content

Commit 62f03fd

Browse files
author
Brett Hazen
committed
Re-sync all tests from master
1 parent 4186a46 commit 62f03fd

File tree

129 files changed

+687
-647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+687
-647
lines changed

tests/basic_command_line.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,4 @@ getpid_down_test(Node) ->
165165
lager:info("Test riak getpid fails on ~s", [Node]),
166166
{ok, PidOut} = rt:riak(Node, ["getpid"]),
167167
?assert(rt:str(PidOut, "Node is not running!")),
168-
ok.
168+
ok.

tests/bucket_props_roundtrip.erl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
%%
1919
%% -------------------------------------------------------------------
2020
-module(bucket_props_roundtrip).
21-
-export([properties/0, confirm/2]).
22-
21+
-behaviour(riak_test).
22+
-export([confirm/0]).
2323
-include_lib("eunit/include/eunit.hrl").
24-
-include("rt.hrl").
2524

2625
-define(BUCKET, <<"pbc_props_verify">>).
2726
-define(COMMIT_HOOK, {struct, [{<<"mod">>, <<"foo">>}, {<<"fun">>, <<"bar">>}]}).
@@ -53,11 +52,9 @@
5352
{young_vclock, 0, 20}
5453
]).
5554

56-
properties() ->
57-
rt_properties:new([{node_count, 1}]).
58-
59-
confirm(Properties, _MD) ->
60-
[Node] = rt_properties:get(nodes, Properties),
55+
confirm() ->
56+
[Node] = Nodes = rt:build_cluster(1),
57+
?assertEqual(ok, rt:wait_until_nodes_ready(Nodes)),
6158

6259
[ check_prop_set_and_get(Node, Prop, FirstVal, SecondVal) ||
6360
{Prop, FirstVal, SecondVal} <- ?PROPS ],
@@ -66,8 +63,8 @@ confirm(Properties, _MD) ->
6663

6764
check_prop_set_and_get(Node, Prop, One, Two) ->
6865
lager:info("-------- Testing roundtrip for property '~p' ---------", [Prop]),
69-
HTTP = rt_http:httpc(Node),
70-
PBC = rt_pb:pbc(Node),
66+
HTTP = rt:httpc(Node),
67+
PBC = rt:pbc(Node),
7168
lager:info("HTTP set = ~p", [One]),
7269
http_set_property(HTTP, Prop, One),
7370
lager:info("PBC get should == ~p", [One]),

tests/bucket_types.erl

Lines changed: 110 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,26 @@
11
-module(bucket_types).
22

3-
%% -behaviour(riak_test).
4-
5-
-export([properties/0,
6-
confirm/1,
7-
mapred_modfun/3,
8-
mapred_modfun_type/3]).
3+
-behavior(riak_test).
4+
-export([confirm/0, mapred_modfun/3, mapred_modfun_type/3]).
95

106
-include_lib("eunit/include/eunit.hrl").
11-
-include("rt.hrl").
12-
13-
-test_type([bucket_types]).
14-
15-
properties() ->
16-
CustomConfig = rt_cluster:augment_config(riak_core,
17-
{default_bucket_props, [{n_val, 2}]},
18-
rt_properties:default_config()),
19-
rt_properties:new([{node_count, 4},
20-
{config, CustomConfig}]).
21-
22-
-spec confirm(rt_properties:properties()) -> pass | fail.
23-
confirm(Properties) ->
24-
NodeIds = rt_properties:get(node_ids, Properties),
25-
NodeMap = rt_properties:get(node_map, Properties),
26-
Nodes = [rt_node:node_name(NodeId, NodeMap) || NodeId <- NodeIds],
27-
Node = hd(Nodes),
287

8+
confirm() ->
299
application:start(inets),
10+
lager:info("Deploy some nodes"),
11+
Nodes = rt:build_cluster(4, [], [
12+
{riak_core, [{default_bucket_props,
13+
[{n_val, 2}]}]}]),
14+
Node = hd(Nodes),
3015

31-
RMD = rt_properties:get(metadata, Properties),
16+
RMD = riak_test_runner:metadata(),
3217
HaveIndexes = case proplists:get_value(backend, RMD) of
3318
undefined -> false; %% default is da 'cask
3419
bitcask -> false;
3520
_ -> true
3621
end,
3722

38-
{ok, [{"127.0.0.1", Port}]} = rpc:call(Node, application, get_env,
39-
[riak_api, pb]),
40-
41-
{ok, PB} = riakc_pb_socket:start_link("127.0.0.1", Port, []),
23+
PB = rt:pbc(Node),
4224

4325
lager:info("default type get/put test"),
4426
%% write explicitly to the default type
@@ -99,9 +81,13 @@ confirm(Properties) ->
9981
%% read from the default bucket explicitly
10082
{error, notfound} = riakc_pb_socket:get(PB, {<<"default">>, <<"bucket">>}, <<"key">>),
10183

102-
timer:sleep(5000), %% wait for delete_mode 3s to expire
84+
?assertEqual(ok, rt:wait_until(fun() ->
85+
rt:pbc_really_deleted(PB,
86+
<<"bucket">>,
87+
[<<"key">>])
88+
end)),
10389

104-
%% now there shoyld be no buckets or keys to be listed...
90+
%% now there should be no buckets or keys to be listed...
10591
%%
10692
%% list keys
10793
?assertEqual({ok, []}, riakc_pb_socket:list_keys(PB, <<"bucket">>)),
@@ -114,13 +100,20 @@ confirm(Properties) ->
114100

115101
lager:info("custom type get/put test"),
116102
Type = <<"mytype">>,
117-
rt_bucket_types:create_and_activate_bucket_type(Node, Type, [{n_val, 3}]),
118-
rt_bucket_types:wait_until_bucket_type_status(Type, active, Nodes),
103+
TypeProps = [{n_val, 3}],
104+
lager:info("Create bucket type ~p, wait for propagation", [Type]),
105+
rt:create_and_activate_bucket_type(Node, Type, TypeProps),
106+
rt:wait_until_bucket_type_status(Type, active, Nodes),
107+
rt:wait_until_bucket_props(Nodes, {Type, <<"bucket">>}, TypeProps),
119108

120109
lager:info("doing put"),
121110
riakc_pb_socket:put(PB, riakc_obj:new({Type, <<"bucket">>},
122111
<<"key">>, <<"newestvalue">>)),
123112

113+
lager:info("custom type list_keys test"),
114+
?assertEqual({ok, []}, riakc_pb_socket:list_keys(PB, <<"bucket">>)),
115+
?assertEqual({ok, [<<"key">>]}, riakc_pb_socket:list_keys(PB, {Type,
116+
<<"bucket">>})),
124117
lager:info("doing get"),
125118
{ok, O5} = riakc_pb_socket:get(PB, {Type, <<"bucket">>}, <<"key">>),
126119

@@ -130,15 +123,42 @@ confirm(Properties) ->
130123
%% this type is NOT aliased to the default buckey
131124
{error, notfound} = riakc_pb_socket:get(PB, <<"bucket">>, <<"key">>),
132125

133-
lager:info("custom type list_keys test"),
134-
?assertEqual({ok, []}, riakc_pb_socket:list_keys(PB, <<"bucket">>)),
135-
?assertEqual({ok, [<<"key">>]}, riakc_pb_socket:list_keys(PB, {Type,
136-
<<"bucket">>})),
137126
lager:info("custom type list_buckets test"),
138127
%% list buckets
139128
?assertEqual({ok, []}, riakc_pb_socket:list_buckets(PB)),
140129
?assertEqual({ok, [<<"bucket">>]}, riakc_pb_socket:list_buckets(PB, Type)),
141130

131+
%%% Beginning of UTF-8 test
132+
133+
lager:info("UTF-8 type get/put test"),
134+
%% こんにちは - konnichiwa (Japanese)
135+
UnicodeType = unicode:characters_to_binary([12371,12435,12395,12385,12399], utf8),
136+
%% سلام - Salam (Arabic)
137+
UnicodeBucket = unicode:characters_to_binary([1587,1604,1575,1605], utf8),
138+
lager:info("Create bucket type, wait for propagation"),
139+
rt:create_and_activate_bucket_type(Node, UnicodeType, TypeProps),
140+
rt:wait_until_bucket_type_status(UnicodeType, active, Nodes),
141+
rt:wait_until_bucket_props(Nodes, {UnicodeType, UnicodeBucket}, TypeProps),
142+
143+
lager:info("doing put"),
144+
riakc_pb_socket:put(PB, riakc_obj:new({UnicodeType, UnicodeBucket},
145+
<<"key">>, <<"yetanothervalue">>)),
146+
147+
lager:info("custom type list_keys test"),
148+
?assertEqual({ok, [<<"key">>]}, riakc_pb_socket:list_keys(PB,
149+
{UnicodeType,
150+
UnicodeBucket})),
151+
lager:info("doing get"),
152+
{ok, O6} = riakc_pb_socket:get(PB, {UnicodeType, UnicodeBucket}, <<"key">>),
153+
154+
?assertEqual(<<"yetanothervalue">>, riakc_obj:get_value(O6)),
155+
156+
lager:info("custom type list_buckets test"),
157+
%% list buckets
158+
?assertEqual({ok, [UnicodeBucket]}, riakc_pb_socket:list_buckets(PB, UnicodeType)),
159+
160+
%%% End of UTF-8 test
161+
142162
lager:info("bucket properties tests"),
143163
riakc_pb_socket:set_bucket(PB, {<<"default">>, <<"mybucket">>},
144164
[{n_val, 5}]),
@@ -160,12 +180,38 @@ confirm(Properties) ->
160180
<<"mybucket">>}),
161181
?assertEqual(5, proplists:get_value(n_val, BProps3)),
162182

183+
%% Check our unicode brethren
184+
riakc_pb_socket:set_bucket(PB, {UnicodeType, UnicodeBucket},
185+
[{n_val, 4}]),
186+
{ok, UBProps1} = riakc_pb_socket:get_bucket(PB, {UnicodeType,
187+
UnicodeBucket}),
188+
?assertEqual(4, proplists:get_value(n_val, UBProps1)),
189+
163190
riakc_pb_socket:reset_bucket(PB, {Type, <<"mybucket">>}),
164191

165192
{ok, BProps4} = riakc_pb_socket:get_bucket(PB, {Type,
166193
<<"mybucket">>}),
167194
?assertEqual(3, proplists:get_value(n_val, BProps4)),
168195

196+
riakc_pb_socket:reset_bucket(PB, {UnicodeType, UnicodeBucket}),
197+
198+
{ok, UBProps2} = riakc_pb_socket:get_bucket(PB, {UnicodeType,
199+
UnicodeBucket}),
200+
201+
?assertEqual(3, proplists:get_value(n_val, UBProps2)),
202+
203+
{error, NTGR} = riakc_pb_socket:get_bucket(PB, {<<"nonexistent">>, <<"mybucket">>}),
204+
205+
lager:info("GOT ERROR ~s", [NTGR]),
206+
207+
?assertMatch(<<"No bucket-type named 'nonexistent'", _/binary>>, NTGR),
208+
209+
{error, NTSR} = riakc_pb_socket:set_bucket(PB, {<<"nonexistent">>, <<"mybucket">>}, [{n_val, 3}]),
210+
211+
lager:info("GOT ERROR ~s", [NTSR]),
212+
213+
?assertMatch(<<"No bucket-type named 'nonexistent'", _/binary>>, NTSR),
214+
169215
lager:info("bucket type properties test"),
170216

171217
riakc_pb_socket:set_bucket_type(PB, Type,
@@ -186,6 +232,27 @@ confirm(Properties) ->
186232

187233
?assertEqual(3, proplists:get_value(n_val, BProps7)),
188234

235+
%% Repeat type checks for unicode type/bucket
236+
237+
riakc_pb_socket:set_bucket_type(PB, UnicodeType,
238+
[{n_val, 5}]),
239+
240+
{ok, UBProps3} = riakc_pb_socket:get_bucket_type(PB, UnicodeType),
241+
242+
?assertEqual(5, proplists:get_value(n_val, UBProps3)),
243+
244+
%% check that the bucket inherits from its type
245+
{ok, UBProps4} = riakc_pb_socket:get_bucket(PB, {UnicodeType,
246+
UnicodeBucket}),
247+
248+
?assertEqual(5, proplists:get_value(n_val, UBProps4)),
249+
250+
riakc_pb_socket:set_bucket_type(PB, UnicodeType, [{n_val, 3}]),
251+
252+
{ok, UBProps5} = riakc_pb_socket:get_bucket_type(PB, UnicodeType),
253+
254+
?assertEqual(3, proplists:get_value(n_val, UBProps5)),
255+
189256
%% make sure a regular bucket under the default type reflects app.config
190257
{ok, BProps8} = riakc_pb_socket:get_bucket(PB, {<<"default">>,
191258
<<"mybucket">>}),
@@ -204,8 +271,8 @@ confirm(Properties) ->
204271
%% make sure a newly created type is not affected either
205272
%% create a new type
206273
Type2 = <<"mynewtype">>,
207-
rt_bucket_types:create_and_activate_bucket_type(Node, Type2, []),
208-
rt_bucket_types:wait_until_bucket_type_status(Type2, active, Nodes),
274+
rt:create_and_activate_bucket_type(Node, Type2, []),
275+
rt:wait_until_bucket_type_status(Type2, active, Nodes),
209276

210277
{ok, BProps11} = riakc_pb_socket:get_bucket_type(PB, Type2),
211278

@@ -296,6 +363,11 @@ confirm(Properties) ->
296363
{<<"baz">>, <<"4">>, <<"a">>, 4},
297364
{<<"bam">>, <<"5">>, <<"a">>, 3}]],
298365

366+
?assertEqual({ok, [{0, [<<"2">>]}]},
367+
riakc_pb_socket:mapred(PB, {{Type, <<"MRbucket">>},
368+
[[<<"starts_with">>, <<"f">>]]},
369+
[{map, {modfun, riak_kv_mapreduce, map_object_value}, none, true}])),
370+
299371
?assertEqual({ok, [{1, [14]}]},
300372
riakc_pb_socket:mapred_bucket(PB, {Type, <<"MRbucket">>},
301373
[{map, {jsfun, <<"Riak.mapValuesJson">>}, undefined, false},

tests/cluster_meta_basic.erl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,19 @@
1818
%%
1919
%% -------------------------------------------------------------------
2020
-module(cluster_meta_basic).
21-
-export([properties/0, confirm/2, object_count/2]).
22-
21+
-behavior(riak_test).
22+
-export([confirm/0, object_count/2]).
2323
-include_lib("eunit/include/eunit.hrl").
2424

25-
-include("rt.hrl").
2625
-define(PREFIX1, {a, b}).
2726
-define(PREFIX2, {fold, prefix}).
2827
-define(KEY1, key1).
2928
-define(KEY2, key2).
3029
-define(VAL1, val1).
3130
-define(VAL2, val2).
3231

33-
properties() ->
34-
rt_properties:new([{node_count, 5}]).
35-
36-
confirm(Properties, _MD) ->
37-
Nodes = rt_properties:get(nodes, Properties),
32+
confirm() ->
33+
Nodes = rt:build_cluster(5),
3834
ok = test_fold_full_prefix(Nodes),
3935
ok = test_metadata_conflicts(Nodes),
4036
ok = test_writes_after_partial_cluster_failure(Nodes),
@@ -54,13 +50,13 @@ test_writes_after_partial_cluster_failure([N1 | _]=Nodes) ->
5450
StopNodes = eager_peers(N1, N1),
5551
AliveNodes = Nodes -- StopNodes,
5652
lager:info("stopping nodes: ~p remaining nodes: ~p", [StopNodes, AliveNodes]),
57-
[rt_node:stop(N) || N <- StopNodes],
53+
[rt:stop(N) || N <- StopNodes],
5854

5955
metadata_put(N1, ?PREFIX1, ?KEY1, ?VAL2),
6056
wait_until_metadata_value(AliveNodes, ?PREFIX1, ?KEY1, ?VAL2),
6157

6258
lager:info("bring stopped nodes back up: ~p", [StopNodes]),
63-
[rt_node:start(N) || N <- StopNodes],
59+
[rt:start(N) || N <- StopNodes],
6460
wait_until_metadata_value(Nodes, ?PREFIX1, ?KEY1, ?VAL2),
6561
ok.
6662

tests/cluster_meta_rmr.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
-define(CM_PREFIX, {test, cm}).
2525

2626
confirm() ->
27-
rt_config:set_conf(all, [{"ring_size", "128"}]),
27+
rt:set_conf(all, [{"ring_size", "128"}]),
2828
Seed = erlang:now(),
2929
lager:info("SEED: ~p", [Seed]),
3030
random:seed(Seed),
@@ -59,10 +59,10 @@ run(NumNodes, NumRounds, StableRounds) ->
5959
exit(Pid, kill),
6060
%% start all the down nodes so we can clean them :(
6161
[rt:start(Node) || Node <- DownNodes],
62-
rt_cluster:clean_cluster(AllNodes).
62+
rt:clean_cluster(AllNodes).
6363

6464
setup_nodes(NumNodes) ->
65-
Nodes = rt_cluster:build_cluster(NumNodes),
65+
Nodes = rt:build_cluster(NumNodes),
6666
[begin
6767
ok = rpc:call(Node, application, set_env, [riak_core, broadcast_exchange_timer, 4294967295]),
6868
ok = rpc:call(Node, application, set_env, [riak_core, gossip_limit, {10000000, 4294967295}]),
@@ -108,7 +108,7 @@ run_rounds(Round, StableRound, SendFun, ConsistentFun, [SenderNode | _]=UpNodes,
108108
fail_node(Round, OtherNodes) ->
109109
Failed = lists:nth(random:uniform(length(OtherNodes)), OtherNodes),
110110
lager:info("round: ~p (unstable): shutting down ~p", [Round, Failed]),
111-
rt_node:stop(Failed),
111+
rt:stop(Failed),
112112
{Failed, lists:delete(Failed, OtherNodes)}.
113113

114114
calc_stuff(AllNodes, NumNodes, NumRounds) ->

tests/cuttlefish_configuration.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ confirm() ->
1212
{"leveldb.sync_on_write", "on"}
1313
],
1414

15-
[Node] = rt_cluster:deploy_nodes(1, {cuttlefish, CuttlefishConf}),
15+
[Node] = rt:deploy_nodes(1, {cuttlefish, CuttlefishConf}),
1616
{ok, RingSize} = rt:rpc_get_env(Node, [{riak_core, ring_creation_size}]),
1717
?assertEqual(8, RingSize),
1818

tests/ensemble_basic.erl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
-export([confirm/0]).
2323
-include_lib("eunit/include/eunit.hrl").
2424

25-
-test_type([ensemble]).
26-
2725
confirm() ->
2826
NumNodes = 5,
2927
NVal = 5,

tests/ensemble_basic2.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ confirm() ->
4242
timer:sleep(Delay),
4343
riak_kv_vnode_orig:init_orig(Args)
4444
end}}]}),
45-
rt_node:stop_and_wait(Node),
46-
rt_node:start(Node),
45+
rt:stop_and_wait(Node),
46+
rt:start(Node),
4747
lager:info("Polling peers while riak_kv starts. We should see none"),
4848
UpNoPeersFun =
4949
fun() ->

0 commit comments

Comments
 (0)