Skip to content
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

Refactored the http driver #114

Merged
merged 6 commits into from
Dec 6, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixes
  • Loading branch information
Drew Kerrigan committed Dec 5, 2013
commit e92ea7a7de8b265d29eb247fdcc1832614d41820
61 changes: 32 additions & 29 deletions examples/http.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,47 @@
{key_generator, {int_to_str, {sequential_int, 50000}}}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend partitioned_sequential_int here: if the user ever changes the concurrent value larger than 1, it usually doesn't make sense to have all of the worker procs generating exactly the same sequential key sequence.

{value_generator, {fixed_bin, 10000}}.

%% {Name, KeyGen | ValGen}

%% Name: atom()
%% KeyGen: User or Basho Bench defined key generator
%% ValGen: User or Basho Bench defined value generator
%%% Generators: {Name, KeyGen | ValGen}
% Name: atom()
% KeyGen: User or Basho Bench defined key generator
% ValGen: User or Basho Bench defined value generator
{generators, [
{string_g, {key_generator, {int_to_str, {uniform_int, 50000}}}},
{binstring_g, {value_generator, {fixed_bin, 100}}},
{binstring_g, {value_generator, {fixed_bin, 100}}}
]}.

%% {Name, Value}
%% {Name, {FormattedValue, Generators}}

%% Name: atom()
%% Value: string() | atom() - named generator, can be key_generator or value_generator for default
%% FormattedValue: string() - formatted with io_lib:format
%% Generators: list() - list of generators, can be key_generator or value_generator for default
%%% Values: {Name, Value}
%%% {Name, {FormattedValue, Generators}}
% Name: atom()
% Value: string() | atom() - named generator, can be key_generator or value_generator for default
% FormattedValue: string() - formatted with io_lib:format
% Generators: list() - list of generators, can be key_generator or value_generator for default
{values, [
{json_v, {"{\"this\":\"is_json_~p\"}", [string_g]}},
{xml_v, {"<?xml version=\"1.0\"?><catalog><book><author>~p</author></book></catalog>", [binstring_g]}},
{json_v, {"{\"this\":\"is_json_~s\"}", [string_g]}},
{xml_v, {"<?xml version=\"1.0\"?><catalog><book><author>~s</author></book></catalog>", [binstring_g]}},
{plainstring_v, "hello"},
{smallbin_v, binstring_g},
{largebin_v, value_generator}
]}.

%% {Name, Headers}
%% Name: atom()

%% Headers: proplist()
%%% Headers: {Name, Headers}
% Name: atom()
% Headers: proplist()
{headers, [
{json_h, [{'Content-Type', 'application/json'}, {'Accept', 'application/json'}]},
{xml_h, [{'Content-Type', 'application/xml'}]},
{binary_h, [{'Content-Type', 'application/octet-stream'}]},
{empty_h, []}
]}.

%% {Name, {Host, Port, Path}}
%% {Name, {Host, Port, {FormattedPath, Generators}}}

%% Name: atom()
%% Host: string()
%% Port: integer()
%% Path: string()
%% FormattedPath: string() - formatted with io_lib:format
%% Generators: list() - list of generators, can be key_generator or value_generator for default
%%% Targets: {Name, {Host, Port, Path}}
%%% {Name, {Host, Port, {FormattedPath, Generators}}}
% Name: atom()
% Host: string()
% Port: integer()
% Path: string()
% FormattedPath: string() - formatted with io_lib:format
% Generators: list() - list of generators, can be key_generator or value_generator for default
{targets, [
{base_uri_t, {"localhost", 4567, "/"}},
{with_key_t, {"localhost", 4567, {"/~p", key_generator}}},
Expand All @@ -63,7 +59,14 @@
{upload_t, {"localhost", 4567, {"upload/~p", key_generator}}}
]}.

%% {{Operation,
%%% Operations: {{get|delete, Target}, Weight}
%%% {{get|delete, Target, Header}, Weight}
%%% {{put|post, Target, Value}, Weight}
%%% {{put|post, Target, Value, Header}, Weight}
% Target: atom() - defined target
% Header: atom() - defined header
% Value: atom() - defined value
% Weight: integer() - ratio of this operation to the rest (ThisWeight / TotalWeightSum = % of this Operation)

{operations, [
%% Get without a key
Expand Down
8 changes: 0 additions & 8 deletions src/basho_bench_driver_http.erl
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ build_value(ValueName, KeyGen, ValueGen, State) ->
end.

do_get(Url, Headers) ->
%%case send_request(Url, [], get, [], [{response_format, binary}]) of
case send_request(Url, Headers, get, [], [{response_format, binary}]) of
{ok, "404", _Header, _Body} ->
{not_found, Url};
Expand Down Expand Up @@ -364,10 +363,3 @@ should_retry(_) -> false.
normalize_error(Method, {'EXIT', {timeout, _}}) -> {error, {Method, timeout}};
normalize_error(Method, {'EXIT', Reason}) -> {error, {Method, 'EXIT', Reason}};
normalize_error(Method, {error, Reason}) -> {error, {Method, Reason}}.

any_to_str(Val) when is_binary(Val) ->
binary_to_list(Val);
any_to_str(Val) when is_integer(Val) ->
integer_to_list(Val);
any_to_str(Val) ->
Val.