Skip to content

Commit e43ac0c

Browse files
authored
Extend sibling test to test HTTP API (#22)
There is no test of the fetch of an individual vtag via the HTTP API - the riak erlang http client does not support it. It is a documented part of the API however, and it fails in Riak 3.4.0 when using the metadata_version v1.
1 parent 9305689 commit e43ac0c

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

tests/verify_siblingmerge_basic.erl

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626
-include_lib("stdlib/include/assert.hrl").
2727

2828
-define(DEFAULT_RING_SIZE, 8).
29-
-define(CFG(),
29+
-define(CFG(MetadataVersion),
3030
[{riak_kv,
3131
[
3232
% Speedy AAE configuration
3333
{anti_entropy, {off, []}},
34-
{tictacaae_active, passive}
34+
{tictacaae_active, passive},
35+
{metadata_version, MetadataVersion}
3536
]},
3637
{riak_core,
3738
[
@@ -44,9 +45,13 @@
4445
-define(N_VAL, 3).
4546

4647
confirm() ->
47-
C0 = rt:build_cluster(?NUM_NODES, ?CFG()),
48+
C0 = rt:build_cluster(?NUM_NODES, ?CFG(v0)),
4849
ok = rt:wait_until_nodes_agree_about_ownership(C0),
4950
ok = verify_siblingmerge(C0),
51+
rt:clean_cluster(C0),
52+
C1 = rt:build_cluster(?NUM_NODES, ?CFG(v1)),
53+
ok = rt:wait_until_nodes_agree_about_ownership(C1),
54+
ok = verify_siblingmerge(C1),
5055
pass.
5156

5257

@@ -66,6 +71,36 @@ verify_siblingmerge(Cluster) ->
6671
ExpectedValsBoth = [<<1:8/integer>>, <<2:8/integer>>],
6772
test_replicas(Node1A, ?AMT_BUCKET, to_key(1), ExpectedValsBoth),
6873

74+
?LOG_INFO("Test the HTTP API represents siblings as expected"),
75+
76+
application:ensure_started(inets),
77+
78+
{ok, _HTTPPid} = inets:start(httpc, [{profile, test_client}]),
79+
URLBase = rt:http_url(Node1A),
80+
KeyURL =
81+
io_lib:format(
82+
"~s/buckets/~s/keys/~s",
83+
[URLBase, ?AMT_BUCKET, to_key(1)]
84+
),
85+
{ok, Result} = httpc:request(KeyURL),
86+
87+
?assertMatch(300, element(2, element(1, Result))),
88+
["Siblings:", VT1, VT2] = string:tokens(element(3, Result), "\n"),
89+
?LOG_INFO("Vtags of siblings ~s ~s", [VT1, VT2]),
90+
91+
?LOG_INFO("Test that individual siblings can be fetched"),
92+
93+
{ok, R1} = httpc:request(io_lib:format("~s?vtag=~s", [KeyURL, VT1])),
94+
{ok, R2} = httpc:request(io_lib:format("~s?vtag=~s", [KeyURL, VT2])),
95+
96+
?assertMatch(200, element(2, element(1, R1))),
97+
?assertMatch(200, element(2, element(1, R2))),
98+
99+
BothResults = element(3,R1) ++ element(3, R2),
100+
?assertMatch([1, 2], lists:sort(BothResults)),
101+
102+
inets:stop(httpc, test_client),
103+
69104
?LOG_INFO("Testing allow_mult = false"),
70105
{Node1B, Node2B} =
71106
select_two_different_primarynodes(Cluster, ?AMF_BUCKET, to_key(1)),

0 commit comments

Comments
 (0)