Skip to content

Commit 167414b

Browse files
committed
Add s3_buckets test
Create a new S3 bucket and test that it exists on each node.
1 parent 3f19fe9 commit 167414b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/s3_buckets.erl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-module(s3_buckets).
2+
3+
-behaviour(riak_test).
4+
5+
-export([confirm/0]).
6+
7+
-define(BUCKET, <<"bucket">>).
8+
-define(USERNAME, "user").
9+
10+
confirm() ->
11+
Cluster = [Node1, _Node2] = rt:build_cluster(2),
12+
create_bucket(Node1),
13+
lists:foreach(fun (Node) ->
14+
rt:wait_until(fun () -> verify_bucket(Node) end)
15+
end, Cluster),
16+
pass.
17+
18+
create_bucket(Node) ->
19+
rpc:call(Node, riak_s3_bucket, create, [?BUCKET, ?USERNAME]).
20+
21+
verify_bucket(Node) ->
22+
case rpc:call(Node, riak_s3_bucket, get, [?BUCKET]) of
23+
not_found ->
24+
not_found;
25+
{error, Reason} ->
26+
Reason;
27+
Bucket ->
28+
BucketName = riak_s3_bucket:get_name(Bucket),
29+
User = riak_s3_bucket:get_username(Bucket),
30+
if BucketName == ?BUCKET andalso User == ?USERNAME ->
31+
true;
32+
BucketName /= ?BUCKET ->
33+
{incorrect_bucket_name, BucketName};
34+
User /= ?USERNAME ->
35+
{incorrect_user, User}
36+
end
37+
end.
38+

0 commit comments

Comments
 (0)