Squash several small testsuites in unit_SUITE and unit_inbroker_SUITE
This allows to run most of the testcases in parallel. As the name of the new testsuites suggests, testcases are grouped by the fact they must run inside a running broker or not. References #725. [#116526487]
This commit is contained in:
parent
4d2e3bbcbb
commit
ed6588bd1e
|
|
@ -1,77 +0,0 @@
|
|||
%% The contents of this file are subject to the Mozilla Public License
|
||||
%% Version 1.1 (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.mozilla.org/MPL/
|
||||
%%
|
||||
%% Software distributed under the License is distributed on an "AS IS"
|
||||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
%% License for the specific language governing rights and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
%% The Original Code is RabbitMQ.
|
||||
%%
|
||||
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
%% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(credit_flow_SUITE).
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
-compile(export_all).
|
||||
|
||||
all() ->
|
||||
[
|
||||
credit_flow_settings
|
||||
].
|
||||
|
||||
%% -------------------------------------------------------------------
|
||||
%% Testsuite setup/teardown.
|
||||
%% -------------------------------------------------------------------
|
||||
|
||||
init_per_suite(Config) ->
|
||||
rabbit_ct_helpers:log_environment(),
|
||||
rabbit_ct_helpers:run_setup_steps(?MODULE, Config).
|
||||
|
||||
end_per_suite(Config) ->
|
||||
rabbit_ct_helpers:run_teardown_steps(Config).
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
%% Test cases
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
credit_flow_settings(Config) ->
|
||||
passed = rabbit_ct_broker_helpers:run_test_on_broker(
|
||||
?config(rmq_nodename, Config),
|
||||
?MODULE, credit_flow_settings1, [Config]).
|
||||
|
||||
credit_flow_settings1(_Config) ->
|
||||
%% default values
|
||||
passed = test_proc(200, 50),
|
||||
|
||||
application:set_env(rabbit, credit_flow_default_credit, {100, 20}),
|
||||
passed = test_proc(100, 20),
|
||||
|
||||
application:unset_env(rabbit, credit_flow_default_credit),
|
||||
|
||||
% back to defaults
|
||||
passed = test_proc(200, 50),
|
||||
passed.
|
||||
|
||||
test_proc(InitialCredit, MoreCreditAfter) ->
|
||||
Pid = spawn(fun dummy/0),
|
||||
Pid ! {credit, self()},
|
||||
{InitialCredit, MoreCreditAfter} =
|
||||
receive
|
||||
{credit, Val} -> Val
|
||||
end,
|
||||
passed.
|
||||
|
||||
dummy() ->
|
||||
credit_flow:send(self()),
|
||||
receive
|
||||
{credit, From} ->
|
||||
From ! {credit, get(credit_flow_default_credit)};
|
||||
_ ->
|
||||
dummy()
|
||||
end.
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
%% The contents of this file are subject to the Mozilla Public License
|
||||
%% Version 1.1 (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.mozilla.org/MPL/
|
||||
%%
|
||||
%% Software distributed under the License is distributed on an "AS IS"
|
||||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
%% License for the specific language governing rights and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
%% The Original Code is RabbitMQ.
|
||||
%%
|
||||
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
%% Copyright (c) 2011-2016 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(dummy_supervisor2).
|
||||
|
||||
-behaviour(supervisor2).
|
||||
|
||||
-export([
|
||||
start_link/0,
|
||||
init/1
|
||||
]).
|
||||
|
||||
start_link() ->
|
||||
Pid = spawn_link(fun () ->
|
||||
process_flag(trap_exit, true),
|
||||
receive stop -> ok end
|
||||
end),
|
||||
{ok, Pid}.
|
||||
|
||||
init([Timeout]) ->
|
||||
{ok, {{one_for_one, 0, 1},
|
||||
[{test_sup, {supervisor2, start_link,
|
||||
[{local, ?MODULE}, ?MODULE, []]},
|
||||
transient, Timeout, supervisor, [?MODULE]}]}};
|
||||
init([]) ->
|
||||
{ok, {{simple_one_for_one, 0, 1},
|
||||
[{test_worker, {?MODULE, start_link, []},
|
||||
temporary, 1000, worker, [?MODULE]}]}}.
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
%% The contents of this file are subject to the Mozilla Public License
|
||||
%% Version 1.1 (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.mozilla.org/MPL/
|
||||
%%
|
||||
%% Software distributed under the License is distributed on an "AS IS"
|
||||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
%% License for the specific language governing rights and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
%% The Original Code is RabbitMQ.
|
||||
%%
|
||||
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
%% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(password_hashing_SUITE).
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
-include_lib("rabbit_common/include/rabbit.hrl").
|
||||
|
||||
-compile(export_all).
|
||||
|
||||
all() ->
|
||||
[
|
||||
password_hashing,
|
||||
change_password
|
||||
].
|
||||
|
||||
%% -------------------------------------------------------------------
|
||||
%% Testsuite setup/teardown.
|
||||
%% -------------------------------------------------------------------
|
||||
|
||||
init_per_suite(Config) ->
|
||||
rabbit_ct_helpers:log_environment(),
|
||||
rabbit_ct_helpers:run_setup_steps(?MODULE, Config).
|
||||
|
||||
end_per_suite(Config) ->
|
||||
rabbit_ct_helpers:run_teardown_steps(Config).
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
%% Test cases
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
password_hashing(Config) ->
|
||||
passed = rabbit_ct_broker_helpers:run_test_on_broker(
|
||||
?config(rmq_nodename, Config),
|
||||
?MODULE, password_hashing1, [Config]).
|
||||
|
||||
password_hashing1(_Config) ->
|
||||
rabbit_password_hashing_sha256 = rabbit_password:hashing_mod(),
|
||||
application:set_env(rabbit, password_hashing_module,
|
||||
rabbit_password_hashing_md5),
|
||||
rabbit_password_hashing_md5 = rabbit_password:hashing_mod(),
|
||||
application:set_env(rabbit, password_hashing_module,
|
||||
rabbit_password_hashing_sha256),
|
||||
rabbit_password_hashing_sha256 = rabbit_password:hashing_mod(),
|
||||
|
||||
rabbit_password_hashing_sha256 =
|
||||
rabbit_password:hashing_mod(rabbit_password_hashing_sha256),
|
||||
rabbit_password_hashing_md5 =
|
||||
rabbit_password:hashing_mod(rabbit_password_hashing_md5),
|
||||
rabbit_password_hashing_md5 =
|
||||
rabbit_password:hashing_mod(undefined),
|
||||
|
||||
rabbit_password_hashing_md5 =
|
||||
rabbit_auth_backend_internal:hashing_module_for_user(
|
||||
#internal_user{}),
|
||||
rabbit_password_hashing_md5 =
|
||||
rabbit_auth_backend_internal:hashing_module_for_user(
|
||||
#internal_user{
|
||||
hashing_algorithm = undefined
|
||||
}),
|
||||
rabbit_password_hashing_md5 =
|
||||
rabbit_auth_backend_internal:hashing_module_for_user(
|
||||
#internal_user{
|
||||
hashing_algorithm = rabbit_password_hashing_md5
|
||||
}),
|
||||
|
||||
rabbit_password_hashing_sha256 =
|
||||
rabbit_auth_backend_internal:hashing_module_for_user(
|
||||
#internal_user{
|
||||
hashing_algorithm = rabbit_password_hashing_sha256
|
||||
}),
|
||||
|
||||
passed.
|
||||
|
||||
change_password(Config) ->
|
||||
passed = rabbit_ct_broker_helpers:run_test_on_broker(
|
||||
?config(rmq_nodename, Config),
|
||||
?MODULE, change_password1, [Config]).
|
||||
|
||||
change_password1(_Config) ->
|
||||
UserName = <<"test_user">>,
|
||||
Password = <<"test_password">>,
|
||||
case rabbit_auth_backend_internal:lookup_user(UserName) of
|
||||
{ok, _} -> rabbit_auth_backend_internal:delete_user(UserName);
|
||||
_ -> ok
|
||||
end,
|
||||
ok = application:set_env(rabbit, password_hashing_module,
|
||||
rabbit_password_hashing_md5),
|
||||
ok = rabbit_auth_backend_internal:add_user(UserName, Password),
|
||||
{ok, #auth_user{username = UserName}} =
|
||||
rabbit_auth_backend_internal:user_login_authentication(
|
||||
UserName, [{password, Password}]),
|
||||
ok = application:set_env(rabbit, password_hashing_module,
|
||||
rabbit_password_hashing_sha256),
|
||||
{ok, #auth_user{username = UserName}} =
|
||||
rabbit_auth_backend_internal:user_login_authentication(
|
||||
UserName, [{password, Password}]),
|
||||
|
||||
NewPassword = <<"test_password1">>,
|
||||
ok = rabbit_auth_backend_internal:change_password(UserName, NewPassword),
|
||||
{ok, #auth_user{username = UserName}} =
|
||||
rabbit_auth_backend_internal:user_login_authentication(
|
||||
UserName, [{password, NewPassword}]),
|
||||
|
||||
{refused, _, [UserName]} =
|
||||
rabbit_auth_backend_internal:user_login_authentication(
|
||||
UserName, [{password, Password}]),
|
||||
passed.
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
%% The contents of this file are subject to the Mozilla Public License
|
||||
%% Version 1.1 (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.mozilla.org/MPL/
|
||||
%%
|
||||
%% Software distributed under the License is distributed on an "AS IS"
|
||||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
%% License for the specific language governing rights and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
%% The Original Code is RabbitMQ.
|
||||
%%
|
||||
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
%% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(resource_monitor_SUITE).
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
-compile(export_all).
|
||||
|
||||
all() ->
|
||||
[
|
||||
parse_information_unit
|
||||
].
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
%% Tests
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
parse_information_unit(_Config) ->
|
||||
lists:foreach(fun ({S, V}) ->
|
||||
V = rabbit_resource_monitor_misc:parse_information_unit(S)
|
||||
end,
|
||||
[
|
||||
{"1000", {ok, 1000}},
|
||||
|
||||
{"10kB", {ok, 10000}},
|
||||
{"10MB", {ok, 10000000}},
|
||||
{"10GB", {ok, 10000000000}},
|
||||
|
||||
{"10kiB", {ok, 10240}},
|
||||
{"10MiB", {ok, 10485760}},
|
||||
{"10GiB", {ok, 10737418240}},
|
||||
|
||||
{"10k", {ok, 10240}},
|
||||
{"10M", {ok, 10485760}},
|
||||
{"10G", {ok, 10737418240}},
|
||||
|
||||
{"10KB", {ok, 10000}},
|
||||
{"10K", {ok, 10240}},
|
||||
{"10m", {ok, 10485760}},
|
||||
{"10Mb", {ok, 10000000}},
|
||||
|
||||
{"0MB", {ok, 0}},
|
||||
|
||||
{"10 k", {error, parse_error}},
|
||||
{"MB", {error, parse_error}},
|
||||
{"", {error, parse_error}},
|
||||
{"0.5GB", {error, parse_error}},
|
||||
{"10TB", {error, parse_error}}
|
||||
]),
|
||||
passed.
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
%% The contents of this file are subject to the Mozilla Public License
|
||||
%% Version 1.1 (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.mozilla.org/MPL/
|
||||
%%
|
||||
%% Software distributed under the License is distributed on an "AS IS"
|
||||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
%% License for the specific language governing rights and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
%% The Original Code is RabbitMQ.
|
||||
%%
|
||||
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
%% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(supervisor2_SUITE).
|
||||
|
||||
-behaviour(supervisor2).
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
-compile(export_all).
|
||||
|
||||
all() ->
|
||||
[
|
||||
check_shutdown_stop,
|
||||
check_shutdown_ignored
|
||||
].
|
||||
|
||||
check_shutdown_stop(_Config) ->
|
||||
ok = check_shutdown(stop, 200, 200, 2000).
|
||||
|
||||
check_shutdown_ignored(_Config) ->
|
||||
ok = check_shutdown(ignored, 1, 2, 2000).
|
||||
|
||||
check_shutdown(SigStop, Iterations, ChildCount, SupTimeout) ->
|
||||
{ok, Sup} = supervisor2:start_link(?MODULE, [SupTimeout]),
|
||||
Res = lists:foldl(
|
||||
fun (I, ok) ->
|
||||
TestSupPid = erlang:whereis(?MODULE),
|
||||
ChildPids =
|
||||
[begin
|
||||
{ok, ChildPid} =
|
||||
supervisor2:start_child(TestSupPid, []),
|
||||
ChildPid
|
||||
end || _ <- lists:seq(1, ChildCount)],
|
||||
MRef = erlang:monitor(process, TestSupPid),
|
||||
[P ! SigStop || P <- ChildPids],
|
||||
ok = supervisor2:terminate_child(Sup, test_sup),
|
||||
{ok, _} = supervisor2:restart_child(Sup, test_sup),
|
||||
receive
|
||||
{'DOWN', MRef, process, TestSupPid, shutdown} ->
|
||||
ok;
|
||||
{'DOWN', MRef, process, TestSupPid, Reason} ->
|
||||
{error, {I, Reason}}
|
||||
end;
|
||||
(_, R) ->
|
||||
R
|
||||
end, ok, lists:seq(1, Iterations)),
|
||||
unlink(Sup),
|
||||
MSupRef = erlang:monitor(process, Sup),
|
||||
exit(Sup, shutdown),
|
||||
receive
|
||||
{'DOWN', MSupRef, process, Sup, _Reason} ->
|
||||
ok
|
||||
end,
|
||||
Res.
|
||||
|
||||
%% -------------------------------------------------------------------
|
||||
%% supervisor2 behavior callbacks.
|
||||
%% -------------------------------------------------------------------
|
||||
|
||||
start_link() ->
|
||||
Pid = spawn_link(fun () ->
|
||||
process_flag(trap_exit, true),
|
||||
receive stop -> ok end
|
||||
end),
|
||||
{ok, Pid}.
|
||||
|
||||
init([Timeout]) ->
|
||||
{ok, {{one_for_one, 0, 1},
|
||||
[{test_sup, {supervisor2, start_link,
|
||||
[{local, ?MODULE}, ?MODULE, []]},
|
||||
transient, Timeout, supervisor, [?MODULE]}]}};
|
||||
init([]) ->
|
||||
{ok, {{simple_one_for_one, 0, 1},
|
||||
[{test_worker, {?MODULE, start_link, []},
|
||||
temporary, 1000, worker, [?MODULE]}]}}.
|
||||
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
%% The contents of this file are subject to the Mozilla Public License
|
||||
%% Version 1.1 (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.mozilla.org/MPL/
|
||||
%%
|
||||
%% Software distributed under the License is distributed on an "AS IS"
|
||||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
%% the License for the specific language governing rights and
|
||||
%% limitations under the License.
|
||||
%%
|
||||
%% The Original Code is RabbitMQ.
|
||||
%%
|
||||
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
%% Copyright (c) 2007-2016 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(truncate_SUITE).
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
-compile(export_all).
|
||||
|
||||
all() ->
|
||||
[
|
||||
{group, all_tests}
|
||||
].
|
||||
|
||||
groups() ->
|
||||
[
|
||||
{all_tests, [parallel], [
|
||||
short_examples_exactly,
|
||||
term_limit,
|
||||
large_examples_for_size
|
||||
]}
|
||||
].
|
||||
|
||||
init_per_group(_, Config) -> Config.
|
||||
end_per_group(_, Config) -> Config.
|
||||
|
||||
short_examples_exactly(_Config) ->
|
||||
F = fun (Term, Exp) ->
|
||||
Exp = truncate:term(Term, {1, {10, 10, 5, 5}}),
|
||||
Term = truncate:term(Term, {100000, {10, 10, 5, 5}})
|
||||
end,
|
||||
FSmall = fun (Term, Exp) ->
|
||||
Exp = truncate:term(Term, {1, {2, 2, 2, 2}}),
|
||||
Term = truncate:term(Term, {100000, {2, 2, 2, 2}})
|
||||
end,
|
||||
F([], []),
|
||||
F("h", "h"),
|
||||
F("hello world", "hello w..."),
|
||||
F([[h,e,l,l,o,' ',w,o,r,l,d]], [[h,e,l,l,o,'...']]),
|
||||
F([a|b], [a|b]),
|
||||
F(<<"hello">>, <<"hello">>),
|
||||
F([<<"hello world">>], [<<"he...">>]),
|
||||
F(<<1:1>>, <<1:1>>),
|
||||
F(<<1:81>>, <<0:56, "...">>),
|
||||
F({{{{a}}},{b},c,d,e,f,g,h,i,j,k}, {{{'...'}},{b},c,d,e,f,g,h,i,j,'...'}),
|
||||
FSmall({a,30,40,40,40,40}, {a,30,'...'}),
|
||||
FSmall([a,30,40,40,40,40], [a,30,'...']),
|
||||
P = spawn(fun() -> receive die -> ok end end),
|
||||
F([0, 0.0, <<1:1>>, F, P], [0, 0.0, <<1:1>>, F, P]),
|
||||
P ! die,
|
||||
R = make_ref(),
|
||||
F([R], [R]),
|
||||
ok.
|
||||
|
||||
term_limit(_Config) ->
|
||||
W = erlang:system_info(wordsize),
|
||||
S = <<"abc">>,
|
||||
1 = truncate:term_size(S, 4, W),
|
||||
limit_exceeded = truncate:term_size(S, 3, W),
|
||||
case 100 - truncate:term_size([S, S], 100, W) of
|
||||
22 -> ok; %% 32 bit
|
||||
38 -> ok %% 64 bit
|
||||
end,
|
||||
case 100 - truncate:term_size([S, [S]], 100, W) of
|
||||
30 -> ok; %% ditto
|
||||
54 -> ok
|
||||
end,
|
||||
limit_exceeded = truncate:term_size([S, S], 6, W),
|
||||
ok.
|
||||
|
||||
large_examples_for_size(_Config) ->
|
||||
%% Real world values
|
||||
Shrink = fun(Term) -> truncate:term(Term, {1, {1000, 100, 50, 5}}) end,
|
||||
TestSize = fun(Term) ->
|
||||
true = 5000000 < size(term_to_binary(Term)),
|
||||
true = 500000 > size(term_to_binary(Shrink(Term)))
|
||||
end,
|
||||
TestSize(lists:seq(1, 5000000)),
|
||||
TestSize(recursive_list(1000, 10)),
|
||||
TestSize(recursive_list(5000, 20)),
|
||||
TestSize(gb_sets:from_list([I || I <- lists:seq(1, 1000000)])),
|
||||
TestSize(gb_trees:from_orddict([{I, I} || I <- lists:seq(1, 1000000)])),
|
||||
ok.
|
||||
|
||||
recursive_list(S, 0) -> lists:seq(1, S);
|
||||
recursive_list(S, N) -> [recursive_list(S div N, N-1) || _ <- lists:seq(1, S)].
|
||||
|
|
@ -0,0 +1,212 @@
|
|||
%% The contents of this file are subject to the Mozilla Public License
|
||||
%% Version 1.1 (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.mozilla.org/MPL/
|
||||
%%
|
||||
%% Software distributed under the License is distributed on an "AS IS"
|
||||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
%% License for the specific language governing rights and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
%% The Original Code is RabbitMQ.
|
||||
%%
|
||||
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
%% Copyright (c) 2011-2016 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(unit_SUITE).
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
-compile(export_all).
|
||||
|
||||
all() ->
|
||||
[
|
||||
{group, parallel_tests}
|
||||
].
|
||||
|
||||
groups() ->
|
||||
[
|
||||
{parallel_tests, [parallel], [
|
||||
{resource_monitor, [parallel], [
|
||||
parse_information_unit
|
||||
]},
|
||||
{supervisor2, [], [
|
||||
check_shutdown_stop,
|
||||
check_shutdown_ignored
|
||||
]},
|
||||
{truncate, [parallel], [
|
||||
short_examples_exactly,
|
||||
term_limit,
|
||||
large_examples_for_size
|
||||
]},
|
||||
{vm_memory_monitor, [parallel], [
|
||||
parse_line_linux
|
||||
]}
|
||||
]}
|
||||
].
|
||||
|
||||
init_per_group(_, Config) -> Config.
|
||||
end_per_group(_, Config) -> Config.
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
%% rabbit_resource_monitor.
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
parse_information_unit(_Config) ->
|
||||
lists:foreach(fun ({S, V}) ->
|
||||
V = rabbit_resource_monitor_misc:parse_information_unit(S)
|
||||
end,
|
||||
[
|
||||
{"1000", {ok, 1000}},
|
||||
|
||||
{"10kB", {ok, 10000}},
|
||||
{"10MB", {ok, 10000000}},
|
||||
{"10GB", {ok, 10000000000}},
|
||||
|
||||
{"10kiB", {ok, 10240}},
|
||||
{"10MiB", {ok, 10485760}},
|
||||
{"10GiB", {ok, 10737418240}},
|
||||
|
||||
{"10k", {ok, 10240}},
|
||||
{"10M", {ok, 10485760}},
|
||||
{"10G", {ok, 10737418240}},
|
||||
|
||||
{"10KB", {ok, 10000}},
|
||||
{"10K", {ok, 10240}},
|
||||
{"10m", {ok, 10485760}},
|
||||
{"10Mb", {ok, 10000000}},
|
||||
|
||||
{"0MB", {ok, 0}},
|
||||
|
||||
{"10 k", {error, parse_error}},
|
||||
{"MB", {error, parse_error}},
|
||||
{"", {error, parse_error}},
|
||||
{"0.5GB", {error, parse_error}},
|
||||
{"10TB", {error, parse_error}}
|
||||
]),
|
||||
passed.
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
%% supervisor2.
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
check_shutdown_stop(_Config) ->
|
||||
ok = check_shutdown(stop, 200, 200, 2000).
|
||||
|
||||
check_shutdown_ignored(_Config) ->
|
||||
ok = check_shutdown(ignored, 1, 2, 2000).
|
||||
|
||||
check_shutdown(SigStop, Iterations, ChildCount, SupTimeout) ->
|
||||
{ok, Sup} = supervisor2:start_link(dummy_supervisor2, [SupTimeout]),
|
||||
Res = lists:foldl(
|
||||
fun (I, ok) ->
|
||||
TestSupPid = erlang:whereis(dummy_supervisor2),
|
||||
ChildPids =
|
||||
[begin
|
||||
{ok, ChildPid} =
|
||||
supervisor2:start_child(TestSupPid, []),
|
||||
ChildPid
|
||||
end || _ <- lists:seq(1, ChildCount)],
|
||||
MRef = erlang:monitor(process, TestSupPid),
|
||||
[P ! SigStop || P <- ChildPids],
|
||||
ok = supervisor2:terminate_child(Sup, test_sup),
|
||||
{ok, _} = supervisor2:restart_child(Sup, test_sup),
|
||||
receive
|
||||
{'DOWN', MRef, process, TestSupPid, shutdown} ->
|
||||
ok;
|
||||
{'DOWN', MRef, process, TestSupPid, Reason} ->
|
||||
{error, {I, Reason}}
|
||||
end;
|
||||
(_, R) ->
|
||||
R
|
||||
end, ok, lists:seq(1, Iterations)),
|
||||
unlink(Sup),
|
||||
MSupRef = erlang:monitor(process, Sup),
|
||||
exit(Sup, shutdown),
|
||||
receive
|
||||
{'DOWN', MSupRef, process, Sup, _Reason} ->
|
||||
ok
|
||||
end,
|
||||
Res.
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
%% truncate.
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
short_examples_exactly(_Config) ->
|
||||
F = fun (Term, Exp) ->
|
||||
Exp = truncate:term(Term, {1, {10, 10, 5, 5}}),
|
||||
Term = truncate:term(Term, {100000, {10, 10, 5, 5}})
|
||||
end,
|
||||
FSmall = fun (Term, Exp) ->
|
||||
Exp = truncate:term(Term, {1, {2, 2, 2, 2}}),
|
||||
Term = truncate:term(Term, {100000, {2, 2, 2, 2}})
|
||||
end,
|
||||
F([], []),
|
||||
F("h", "h"),
|
||||
F("hello world", "hello w..."),
|
||||
F([[h,e,l,l,o,' ',w,o,r,l,d]], [[h,e,l,l,o,'...']]),
|
||||
F([a|b], [a|b]),
|
||||
F(<<"hello">>, <<"hello">>),
|
||||
F([<<"hello world">>], [<<"he...">>]),
|
||||
F(<<1:1>>, <<1:1>>),
|
||||
F(<<1:81>>, <<0:56, "...">>),
|
||||
F({{{{a}}},{b},c,d,e,f,g,h,i,j,k}, {{{'...'}},{b},c,d,e,f,g,h,i,j,'...'}),
|
||||
FSmall({a,30,40,40,40,40}, {a,30,'...'}),
|
||||
FSmall([a,30,40,40,40,40], [a,30,'...']),
|
||||
P = spawn(fun() -> receive die -> ok end end),
|
||||
F([0, 0.0, <<1:1>>, F, P], [0, 0.0, <<1:1>>, F, P]),
|
||||
P ! die,
|
||||
R = make_ref(),
|
||||
F([R], [R]),
|
||||
ok.
|
||||
|
||||
term_limit(_Config) ->
|
||||
W = erlang:system_info(wordsize),
|
||||
S = <<"abc">>,
|
||||
1 = truncate:term_size(S, 4, W),
|
||||
limit_exceeded = truncate:term_size(S, 3, W),
|
||||
case 100 - truncate:term_size([S, S], 100, W) of
|
||||
22 -> ok; %% 32 bit
|
||||
38 -> ok %% 64 bit
|
||||
end,
|
||||
case 100 - truncate:term_size([S, [S]], 100, W) of
|
||||
30 -> ok; %% ditto
|
||||
54 -> ok
|
||||
end,
|
||||
limit_exceeded = truncate:term_size([S, S], 6, W),
|
||||
ok.
|
||||
|
||||
large_examples_for_size(_Config) ->
|
||||
%% Real world values
|
||||
Shrink = fun(Term) -> truncate:term(Term, {1, {1000, 100, 50, 5}}) end,
|
||||
TestSize = fun(Term) ->
|
||||
true = 5000000 < size(term_to_binary(Term)),
|
||||
true = 500000 > size(term_to_binary(Shrink(Term)))
|
||||
end,
|
||||
TestSize(lists:seq(1, 5000000)),
|
||||
TestSize(recursive_list(1000, 10)),
|
||||
TestSize(recursive_list(5000, 20)),
|
||||
TestSize(gb_sets:from_list([I || I <- lists:seq(1, 1000000)])),
|
||||
TestSize(gb_trees:from_orddict([{I, I} || I <- lists:seq(1, 1000000)])),
|
||||
ok.
|
||||
|
||||
recursive_list(S, 0) -> lists:seq(1, S);
|
||||
recursive_list(S, N) -> [recursive_list(S div N, N-1) || _ <- lists:seq(1, S)].
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
%% vm_memory_monitor.
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
parse_line_linux(_Config) ->
|
||||
lists:foreach(fun ({S, {K, V}}) ->
|
||||
{K, V} = vm_memory_monitor:parse_line_linux(S)
|
||||
end,
|
||||
[{"MemTotal: 0 kB", {'MemTotal', 0}},
|
||||
{"MemTotal: 502968 kB ", {'MemTotal', 515039232}},
|
||||
{"MemFree: 178232 kB", {'MemFree', 182509568}},
|
||||
{"MemTotal: 50296888", {'MemTotal', 50296888}},
|
||||
{"MemTotal 502968 kB", {'MemTotal', 515039232}},
|
||||
{"MemTotal 50296866 ", {'MemTotal', 50296866}}]),
|
||||
ok.
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
%% The contents of this file are subject to the Mozilla Public License
|
||||
%% Version 1.1 (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.mozilla.org/MPL/
|
||||
%% compliance with the License. You may obtain a copy of the License at
|
||||
%% http://www.mozilla.org/MPL/
|
||||
%%
|
||||
%% Software distributed under the License is distributed on an "AS IS"
|
||||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
%% the License for the specific language governing rights and
|
||||
%% limitations under the License.
|
||||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
%% License for the specific language governing rights and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
%% The Original Code is RabbitMQ.
|
||||
%%
|
||||
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
%% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
|
||||
%% Copyright (c) 2011-2016 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(rabbit_ctl_timeout_SUITE).
|
||||
-module(unit_inbroker_SUITE).
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
-include_lib("rabbit_common/include/rabbit.hrl").
|
||||
|
|
@ -25,7 +25,23 @@
|
|||
|
||||
all() ->
|
||||
[
|
||||
list_operations_timeout_pass
|
||||
{group, parallel_tests}
|
||||
].
|
||||
|
||||
groups() ->
|
||||
[
|
||||
{parallel_tests, [parallel], [
|
||||
{credit_flow, [parallel], [
|
||||
credit_flow_settings
|
||||
]},
|
||||
{password_hashing, [parallel], [
|
||||
password_hashing,
|
||||
change_password
|
||||
]},
|
||||
{rabbitmqctl, [parallel], [
|
||||
list_operations_timeout_pass
|
||||
]}
|
||||
]}
|
||||
].
|
||||
|
||||
%% -------------------------------------------------------------------
|
||||
|
|
@ -39,12 +55,137 @@ init_per_suite(Config) ->
|
|||
end_per_suite(Config) ->
|
||||
rabbit_ct_helpers:run_teardown_steps(Config).
|
||||
|
||||
init_per_group(_, Config) -> Config.
|
||||
end_per_group(_, Config) -> Config.
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
%% Credit flow.
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
credit_flow_settings(Config) ->
|
||||
passed = rabbit_ct_broker_helpers:run_on_broker(
|
||||
?config(rmq_nodename, Config),
|
||||
?MODULE, credit_flow_settings1, [Config]).
|
||||
|
||||
credit_flow_settings1(_Config) ->
|
||||
%% default values
|
||||
passed = test_proc(200, 50),
|
||||
|
||||
application:set_env(rabbit, credit_flow_default_credit, {100, 20}),
|
||||
passed = test_proc(100, 20),
|
||||
|
||||
application:unset_env(rabbit, credit_flow_default_credit),
|
||||
|
||||
% back to defaults
|
||||
passed = test_proc(200, 50),
|
||||
passed.
|
||||
|
||||
test_proc(InitialCredit, MoreCreditAfter) ->
|
||||
Pid = spawn(fun dummy/0),
|
||||
Pid ! {credit, self()},
|
||||
{InitialCredit, MoreCreditAfter} =
|
||||
receive
|
||||
{credit, Val} -> Val
|
||||
end,
|
||||
passed.
|
||||
|
||||
dummy() ->
|
||||
credit_flow:send(self()),
|
||||
receive
|
||||
{credit, From} ->
|
||||
From ! {credit, get(credit_flow_default_credit)};
|
||||
_ ->
|
||||
dummy()
|
||||
end.
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
%% Password hashing.
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
password_hashing(Config) ->
|
||||
passed = rabbit_ct_broker_helpers:run_on_broker(
|
||||
?config(rmq_nodename, Config),
|
||||
?MODULE, password_hashing1, [Config]).
|
||||
|
||||
password_hashing1(_Config) ->
|
||||
rabbit_password_hashing_sha256 = rabbit_password:hashing_mod(),
|
||||
application:set_env(rabbit, password_hashing_module,
|
||||
rabbit_password_hashing_md5),
|
||||
rabbit_password_hashing_md5 = rabbit_password:hashing_mod(),
|
||||
application:set_env(rabbit, password_hashing_module,
|
||||
rabbit_password_hashing_sha256),
|
||||
rabbit_password_hashing_sha256 = rabbit_password:hashing_mod(),
|
||||
|
||||
rabbit_password_hashing_sha256 =
|
||||
rabbit_password:hashing_mod(rabbit_password_hashing_sha256),
|
||||
rabbit_password_hashing_md5 =
|
||||
rabbit_password:hashing_mod(rabbit_password_hashing_md5),
|
||||
rabbit_password_hashing_md5 =
|
||||
rabbit_password:hashing_mod(undefined),
|
||||
|
||||
rabbit_password_hashing_md5 =
|
||||
rabbit_auth_backend_internal:hashing_module_for_user(
|
||||
#internal_user{}),
|
||||
rabbit_password_hashing_md5 =
|
||||
rabbit_auth_backend_internal:hashing_module_for_user(
|
||||
#internal_user{
|
||||
hashing_algorithm = undefined
|
||||
}),
|
||||
rabbit_password_hashing_md5 =
|
||||
rabbit_auth_backend_internal:hashing_module_for_user(
|
||||
#internal_user{
|
||||
hashing_algorithm = rabbit_password_hashing_md5
|
||||
}),
|
||||
|
||||
rabbit_password_hashing_sha256 =
|
||||
rabbit_auth_backend_internal:hashing_module_for_user(
|
||||
#internal_user{
|
||||
hashing_algorithm = rabbit_password_hashing_sha256
|
||||
}),
|
||||
|
||||
passed.
|
||||
|
||||
change_password(Config) ->
|
||||
passed = rabbit_ct_broker_helpers:run_on_broker(
|
||||
?config(rmq_nodename, Config),
|
||||
?MODULE, change_password1, [Config]).
|
||||
|
||||
change_password1(_Config) ->
|
||||
UserName = <<"test_user">>,
|
||||
Password = <<"test_password">>,
|
||||
case rabbit_auth_backend_internal:lookup_user(UserName) of
|
||||
{ok, _} -> rabbit_auth_backend_internal:delete_user(UserName);
|
||||
_ -> ok
|
||||
end,
|
||||
ok = application:set_env(rabbit, password_hashing_module,
|
||||
rabbit_password_hashing_md5),
|
||||
ok = rabbit_auth_backend_internal:add_user(UserName, Password),
|
||||
{ok, #auth_user{username = UserName}} =
|
||||
rabbit_auth_backend_internal:user_login_authentication(
|
||||
UserName, [{password, Password}]),
|
||||
ok = application:set_env(rabbit, password_hashing_module,
|
||||
rabbit_password_hashing_sha256),
|
||||
{ok, #auth_user{username = UserName}} =
|
||||
rabbit_auth_backend_internal:user_login_authentication(
|
||||
UserName, [{password, Password}]),
|
||||
|
||||
NewPassword = <<"test_password1">>,
|
||||
ok = rabbit_auth_backend_internal:change_password(UserName, NewPassword),
|
||||
{ok, #auth_user{username = UserName}} =
|
||||
rabbit_auth_backend_internal:user_login_authentication(
|
||||
UserName, [{password, NewPassword}]),
|
||||
|
||||
{refused, _, [UserName]} =
|
||||
rabbit_auth_backend_internal:user_login_authentication(
|
||||
UserName, [{password, Password}]),
|
||||
passed.
|
||||
|
||||
%% -------------------------------------------------------------------
|
||||
%% Test cases.
|
||||
%% rabbitmqctl.
|
||||
%% -------------------------------------------------------------------
|
||||
|
||||
list_operations_timeout_pass(Config) ->
|
||||
passed = rabbit_ct_broker_helpers:run_test_on_broker(
|
||||
passed = rabbit_ct_broker_helpers:run_on_broker(
|
||||
?config(rmq_nodename, Config),
|
||||
?MODULE, list_operations_timeout_pass1, [Config]).
|
||||
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
%% The contents of this file are subject to the Mozilla Public License
|
||||
%% Version 1.1 (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.mozilla.org/MPL/
|
||||
%%
|
||||
%% Software distributed under the License is distributed on an "AS IS"
|
||||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
%% License for the specific language governing rights and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
%% The Original Code is RabbitMQ.
|
||||
%%
|
||||
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
%% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(vm_memory_monitor_SUITE).
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
-compile(export_all).
|
||||
|
||||
all() ->
|
||||
[
|
||||
parse_line_linux
|
||||
].
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
%% Test cases
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
parse_line_linux(_Config) ->
|
||||
lists:foreach(fun ({S, {K, V}}) ->
|
||||
{K, V} = vm_memory_monitor:parse_line_linux(S)
|
||||
end,
|
||||
[{"MemTotal: 0 kB", {'MemTotal', 0}},
|
||||
{"MemTotal: 502968 kB ", {'MemTotal', 515039232}},
|
||||
{"MemFree: 178232 kB", {'MemFree', 182509568}},
|
||||
{"MemTotal: 50296888", {'MemTotal', 50296888}},
|
||||
{"MemTotal 502968 kB", {'MemTotal', 515039232}},
|
||||
{"MemTotal 50296866 ", {'MemTotal', 50296866}}]),
|
||||
ok.
|
||||
Loading…
Reference in New Issue