Skip to content

Commit

Permalink
Add s3_buckets test
Browse files Browse the repository at this point in the history
Create a new S3 bucket and test that it exists on each node.
  • Loading branch information
ian-mi committed Nov 30, 2016
1 parent 3f19fe9 commit 167414b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/s3_buckets.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-module(s3_buckets).

-behaviour(riak_test).

-export([confirm/0]).

-define(BUCKET, <<"bucket">>).
-define(USERNAME, "user").

confirm() ->
Cluster = [Node1, _Node2] = rt:build_cluster(2),
create_bucket(Node1),
lists:foreach(fun (Node) ->
rt:wait_until(fun () -> verify_bucket(Node) end)
end, Cluster),
pass.

create_bucket(Node) ->
rpc:call(Node, riak_s3_bucket, create, [?BUCKET, ?USERNAME]).

verify_bucket(Node) ->
case rpc:call(Node, riak_s3_bucket, get, [?BUCKET]) of
not_found ->
not_found;
{error, Reason} ->
Reason;
Bucket ->
BucketName = riak_s3_bucket:get_name(Bucket),
User = riak_s3_bucket:get_username(Bucket),
if BucketName == ?BUCKET andalso User == ?USERNAME ->
true;
BucketName /= ?BUCKET ->
{incorrect_bucket_name, BucketName};
User /= ?USERNAME ->
{incorrect_user, User}
end
end.

0 comments on commit 167414b

Please sign in to comment.