-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inaccurate s3 rewrite rule. #1040
Changes from 5 commits
b762609
3210e1f
69305b1
3bfdf3f
d1c3d02
9c137e6
886b2bb
40609c5
976f335
6c9953b
8d044a1
0aefa63
b144eed
950ac69
f4c58a4
b4cc578
1b9847b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
%% --------------------------------------------------------------------- | ||
%% | ||
%% 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). | ||
|
||
%% @doc `riak_test' module for testing object get behavior. | ||
|
||
-export([confirm/0]). | ||
-include_lib("erlcloud/include/erlcloud_aws.hrl"). | ||
-include_lib("eunit/include/eunit.hrl"). | ||
|
||
-define(TEST_BUCKET, "legacy-s3-rewrite-test"). | ||
|
||
confirm() -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be good if this test includes the exact case where the problem happened, like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it's about testing legacy code, so I'd say this is enough to test old behaviour. |
||
%% 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}], | ||
case execute_cmd(Cmd, [{cd, CsSrcDir}, {env, Env}, {args, Args}]) of | ||
ok -> | ||
pass; | ||
{error, Reason} -> | ||
lager:error("Error : ~p", [Reason]), | ||
error({external_client_tests, Reason}) | ||
end. | ||
|
||
execute_cmd(Cmd, Opts) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd recommend just using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like duplicate code ^^; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rt_cs_dev:cmd/2 doesn't look suitable for this case because it doesn't handle exit code, or output log until the command finishes.I'd like to extract these function to rtcs module. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In master branch of riak_test rtdev:cmd/2 handles the return value. We're just stale. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And also in master branch, |
||
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(), | ||
{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} | ||
] | ||
}]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a stale comment from copy source.