Skip to content

Commit

Permalink
Merge commit 'cc73f8c36ebb76bc22c' (pull request #1040) into develop
Browse files Browse the repository at this point in the history
Conflicts:
	riak_test/src/rtcs.erl
  • Loading branch information
kuenishi committed Jan 16, 2015
2 parents afed87e + cc73f8c commit 541d30e
Show file tree
Hide file tree
Showing 10 changed files with 571 additions and 260 deletions.
1 change: 1 addition & 0 deletions include/riak_cs.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@
-define(JSON_TYPE, "application/json").
-define(XML_TYPE, "application/xml").
-define(S3_API_MOD, riak_cs_s3_rewrite).
-define(S3_LEGACY_API_MOD, riak_cs_s3_rewrite_legacy).
-define(OOS_API_MOD, riak_cs_oos_rewrite).
-define(S3_RESPONSE_MOD, riak_cs_s3_response).
-define(OOS_RESPONSE_MOD, riak_cs_oos_response).
Expand Down
9 changes: 8 additions & 1 deletion riak_test/src/rtcs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -923,4 +923,11 @@ upgrade_stanchion(Config, AdminCreds, Vsn) ->
proplists:get_value(stanchion, Config),
AdminCreds).

%% maybe_stop_stanchion(1) ->
%% TODO: this is added as riak-1.4 branch of riak_test/src/rt_cs_dev.erl
%% throws out the return value. Let's get rid of these functions when
%% we entered to Riak CS 2.0 dev, updating to riak_test master branch
cmd(Cmd, Opts) ->
rt_cs_dev:cmd(Cmd, Opts).

cmd(Cmd, Opts, WaitTime) ->
rt_cs_dev:cmd(Cmd, Opts, WaitTime).
28 changes: 2 additions & 26 deletions riak_test/tests/external_client_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,15 @@ confirm() ->
{"AWS_ACCESS_KEY_ID", UserConfig#aws_config.access_key_id},
{"AWS_SECRET_ACCESS_KEY", UserConfig#aws_config.secret_access_key},
{"CS_BUCKET", ?TEST_BUCKET}],
case execute_cmd(Cmd, [{cd, CsSrcDir}, {env, Env}, {args, Args}]) of
WaitTime = 2 * rt_config:get(rt_max_wait_time),
case rtcs:cmd(Cmd, [{cd, CsSrcDir}, {env, Env}, {args, Args}], WaitTime) of
ok ->
rtcs:pass();
{error, Reason} ->
lager:error("Error : ~p", [Reason]),
error({external_client_tests, Reason})
end.

execute_cmd(Cmd, Opts) ->
lager:info("Command: ~s", [Cmd]),
lager:info("Options: ~p", [Opts]),
Port = open_port({spawn_executable, Cmd},
[in, exit_status, binary,
stream, stderr_to_stdout,{line, 200} | Opts]),
get_cmd_result(Port).

get_cmd_result(Port) ->
WaitTime = rt_config:get(rt_max_wait_time),
receive
{Port, {data, {Flag, Line}}} when Flag =:= eol orelse Flag =:= noeol ->
lager:info(Line),
get_cmd_result(Port);
{Port, {exit_status, 0}} ->
ok;
{Port, {exit_status, Status}} ->
{error, {exit_status, Status}};
{Port, Other} ->
lager:warning("Other data from port: ~p", [Other]),
get_cmd_result(Port)
after WaitTime * 2 ->
{error, timeout}
end.

cs_config() ->
[
rtcs:lager_config(),
Expand Down
69 changes: 69 additions & 0 deletions riak_test/tests/legacy_s3_rewrite_test.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
%% ---------------------------------------------------------------------
%%
%% Copyright (c) 2007-2015 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
%% ---------------------------------------------------------------------

-module(legacy_s3_rewrite_test).

-export([confirm/0]).
-include_lib("erlcloud/include/erlcloud_aws.hrl").
-include_lib("eunit/include/eunit.hrl").

-define(TEST_BUCKET, "legacy-s3-rewrite-test").

confirm() ->
%% NOTE: This 'cs_src_root' path must appear in
%% ~/.riak_test.config in the 'rt_cs_dev' section, 'src_paths'
%% subsection.
CsSrcDir = rt_cs_dev:srcpath(cs_src_root),
lager:debug("cs_src_root = ~p", [CsSrcDir]),

{UserConfig, {RiakNodes, _CSNodes, _Stanchion}} = rtcs:setup(1, [{cs, cs_config()}]),
ok = erlcloud_s3:create_bucket(?TEST_BUCKET, UserConfig),
CsPortStr = integer_to_list(rtcs:cs_port(hd(RiakNodes))),

Cmd = os:find_executable("make"),
Args = ["test-python"],
Env = [{"CS_HTTP_PORT", CsPortStr},
{"AWS_ACCESS_KEY_ID", UserConfig#aws_config.access_key_id},
{"AWS_SECRET_ACCESS_KEY", UserConfig#aws_config.secret_access_key},
{"CS_BUCKET", ?TEST_BUCKET}],
WaitTime = 2 * rt_config:get(rt_max_wait_time),
case rtcs:cmd(Cmd, [{cd, CsSrcDir}, {env, Env}, {args, Args}], WaitTime) of
ok ->
pass;
{error, Reason} ->
lager:error("Error : ~p", [Reason]),
error({?MODULE, Reason})
end.

cs_config() ->
[
rtcs:lager_config(),
{riak_cs,
[
{proxy_get, enabled},
{anonymous_user_creation, true},
{riak_pb_port, 10017},
{stanchion_port, 9095},
{cs_version, 010300},
{enforce_multipart_part_size, false},
{max_buckets_per_user, 150},
{rewrite_module, riak_cs_s3_rewrite_legacy}
]
}].
2 changes: 2 additions & 0 deletions src/riak_cs_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ api() ->
-spec api({ok, atom()} | undefined) -> s3 | oos | undefined.
api({ok, ?S3_API_MOD}) ->
s3;
api({ok, ?S3_LEGACY_API_MOD}) ->
s3;
api({ok, ?OOS_API_MOD}) ->
oos;
api(_) ->
Expand Down
Loading

0 comments on commit 541d30e

Please sign in to comment.