Skip to content

Commit 5a54a27

Browse files
committed
Switch testsuite to common_test, part #2
The migrated tests are: o rabbit_ctl_timeout_tests o vm_memory_monitor_tests o credit_flow_test o on_disk_store_tunable_parameter_validation_test o password_hashing_tests o rabbit_resource_monitor_misc_test References #725. [#116526487]
1 parent b620cfb commit 5a54a27

6 files changed

+539
-0
lines changed

test/credit_flow_SUITE.erl

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
%% The contents of this file are subject to the Mozilla Public License
2+
%% Version 1.1 (the "License"); you may not use this file except in
3+
%% compliance with the License. You may obtain a copy of the License at
4+
%% http://www.mozilla.org/MPL/
5+
%%
6+
%% Software distributed under the License is distributed on an "AS IS"
7+
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
8+
%% License for the specific language governing rights and limitations
9+
%% under the License.
10+
%%
11+
%% The Original Code is RabbitMQ.
12+
%%
13+
%% The Initial Developer of the Original Code is GoPivotal, Inc.
14+
%% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
15+
%%
16+
17+
-module(credit_flow_SUITE).
18+
19+
-include_lib("common_test/include/ct.hrl").
20+
21+
-compile(export_all).
22+
23+
all() ->
24+
[
25+
credit_flow_settings
26+
].
27+
28+
%% -------------------------------------------------------------------
29+
%% Testsuite setup/teardown.
30+
%% -------------------------------------------------------------------
31+
32+
init_per_suite(Config) ->
33+
rabbit_ct_helpers:log_environment(),
34+
rabbit_ct_helpers:run_setup_steps(?MODULE, Config).
35+
36+
end_per_suite(Config) ->
37+
rabbit_ct_helpers:run_teardown_steps(Config).
38+
39+
%% ---------------------------------------------------------------------------
40+
%% Test cases
41+
%% ---------------------------------------------------------------------------
42+
43+
credit_flow_settings(Config) ->
44+
passed = rabbit_ct_broker_helpers:run_test_on_broker(
45+
?config(rmq_nodename, Config),
46+
?MODULE, credit_flow_settings1, [Config]).
47+
48+
credit_flow_settings1(_Config) ->
49+
%% default values
50+
passed = test_proc(200, 50),
51+
52+
application:set_env(rabbit, credit_flow_default_credit, {100, 20}),
53+
passed = test_proc(100, 20),
54+
55+
application:unset_env(rabbit, credit_flow_default_credit),
56+
57+
% back to defaults
58+
passed = test_proc(200, 50),
59+
passed.
60+
61+
test_proc(InitialCredit, MoreCreditAfter) ->
62+
Pid = spawn(fun dummy/0),
63+
Pid ! {credit, self()},
64+
{InitialCredit, MoreCreditAfter} =
65+
receive
66+
{credit, Val} -> Val
67+
end,
68+
passed.
69+
70+
dummy() ->
71+
credit_flow:send(self()),
72+
receive
73+
{credit, From} ->
74+
From ! {credit, get(credit_flow_default_credit)};
75+
_ ->
76+
dummy()
77+
end.

test/msg_store_SUITE.erl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
%% The contents of this file are subject to the Mozilla Public License
2+
%% Version 1.1 (the "License"); you may not use this file except in
3+
%% compliance with the License. You may obtain a copy of the License at
4+
%% http://www.mozilla.org/MPL/
5+
%%
6+
%% Software distributed under the License is distributed on an "AS IS"
7+
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
8+
%% License for the specific language governing rights and limitations
9+
%% under the License.
10+
%%
11+
%% The Original Code is RabbitMQ.
12+
%%
13+
%% The Initial Developer of the Original Code is GoPivotal, Inc.
14+
%% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
15+
%%
16+
17+
-module(msg_store_SUITE).
18+
19+
-include_lib("common_test/include/ct.hrl").
20+
-include_lib("rabbit_common/include/rabbit.hrl").
21+
22+
-compile(export_all).
23+
24+
-define(T(Fun, Args), (catch apply(rabbit, Fun, Args))).
25+
26+
all() ->
27+
[
28+
parameter_validation
29+
].
30+
31+
parameter_validation(_Config) ->
32+
%% make sure it works with default values
33+
ok = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
34+
[?CREDIT_DISC_BOUND, ?IO_BATCH_SIZE]),
35+
36+
%% IO_BATCH_SIZE must be greater than CREDIT_DISC_BOUND initial credit
37+
ok = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
38+
[{2000, 500}, 3000]),
39+
{error, _} = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
40+
[{2000, 500}, 1500]),
41+
42+
%% All values must be integers
43+
{error, _} = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
44+
[{2000, 500}, "1500"]),
45+
{error, _} = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
46+
[{"2000", 500}, abc]),
47+
{error, _} = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
48+
[{2000, "500"}, 2048]),
49+
50+
%% CREDIT_DISC_BOUND must be a tuple
51+
{error, _} = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
52+
[[2000, 500], 1500]),
53+
{error, _} = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
54+
[2000, 1500]),
55+
56+
%% config values can't be smaller than default values
57+
{error, _} = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
58+
[{1999, 500}, 2048]),
59+
{error, _} = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
60+
[{2000, 499}, 2048]),
61+
{error, _} = ?T(validate_msg_store_io_batch_size_and_credit_disc_bound,
62+
[{2000, 500}, 2047]).

test/password_hashing_SUITE.erl

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
%% The contents of this file are subject to the Mozilla Public License
2+
%% Version 1.1 (the "License"); you may not use this file except in
3+
%% compliance with the License. You may obtain a copy of the License at
4+
%% http://www.mozilla.org/MPL/
5+
%%
6+
%% Software distributed under the License is distributed on an "AS IS"
7+
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
8+
%% License for the specific language governing rights and limitations
9+
%% under the License.
10+
%%
11+
%% The Original Code is RabbitMQ.
12+
%%
13+
%% The Initial Developer of the Original Code is GoPivotal, Inc.
14+
%% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
15+
%%
16+
17+
-module(password_hashing_SUITE).
18+
19+
-include_lib("common_test/include/ct.hrl").
20+
-include_lib("rabbit_common/include/rabbit.hrl").
21+
22+
-compile(export_all).
23+
24+
all() ->
25+
[
26+
password_hashing,
27+
change_password
28+
].
29+
30+
%% -------------------------------------------------------------------
31+
%% Testsuite setup/teardown.
32+
%% -------------------------------------------------------------------
33+
34+
init_per_suite(Config) ->
35+
rabbit_ct_helpers:log_environment(),
36+
rabbit_ct_helpers:run_setup_steps(?MODULE, Config).
37+
38+
end_per_suite(Config) ->
39+
rabbit_ct_helpers:run_teardown_steps(Config).
40+
41+
%% ---------------------------------------------------------------------------
42+
%% Test cases
43+
%% ---------------------------------------------------------------------------
44+
45+
password_hashing(Config) ->
46+
passed = rabbit_ct_broker_helpers:run_test_on_broker(
47+
?config(rmq_nodename, Config),
48+
?MODULE, password_hashing1, [Config]).
49+
50+
password_hashing1(_Config) ->
51+
rabbit_password_hashing_sha256 = rabbit_password:hashing_mod(),
52+
application:set_env(rabbit, password_hashing_module,
53+
rabbit_password_hashing_md5),
54+
rabbit_password_hashing_md5 = rabbit_password:hashing_mod(),
55+
application:set_env(rabbit, password_hashing_module,
56+
rabbit_password_hashing_sha256),
57+
rabbit_password_hashing_sha256 = rabbit_password:hashing_mod(),
58+
59+
rabbit_password_hashing_sha256 =
60+
rabbit_password:hashing_mod(rabbit_password_hashing_sha256),
61+
rabbit_password_hashing_md5 =
62+
rabbit_password:hashing_mod(rabbit_password_hashing_md5),
63+
rabbit_password_hashing_md5 =
64+
rabbit_password:hashing_mod(undefined),
65+
66+
rabbit_password_hashing_md5 =
67+
rabbit_auth_backend_internal:hashing_module_for_user(
68+
#internal_user{}),
69+
rabbit_password_hashing_md5 =
70+
rabbit_auth_backend_internal:hashing_module_for_user(
71+
#internal_user{
72+
hashing_algorithm = undefined
73+
}),
74+
rabbit_password_hashing_md5 =
75+
rabbit_auth_backend_internal:hashing_module_for_user(
76+
#internal_user{
77+
hashing_algorithm = rabbit_password_hashing_md5
78+
}),
79+
80+
rabbit_password_hashing_sha256 =
81+
rabbit_auth_backend_internal:hashing_module_for_user(
82+
#internal_user{
83+
hashing_algorithm = rabbit_password_hashing_sha256
84+
}),
85+
86+
passed.
87+
88+
change_password(Config) ->
89+
passed = rabbit_ct_broker_helpers:run_test_on_broker(
90+
?config(rmq_nodename, Config),
91+
?MODULE, change_password1, [Config]).
92+
93+
change_password1(_Config) ->
94+
UserName = <<"test_user">>,
95+
Password = <<"test_password">>,
96+
case rabbit_auth_backend_internal:lookup_user(UserName) of
97+
{ok, _} -> rabbit_auth_backend_internal:delete_user(UserName);
98+
_ -> ok
99+
end,
100+
ok = application:set_env(rabbit, password_hashing_module,
101+
rabbit_password_hashing_md5),
102+
ok = rabbit_auth_backend_internal:add_user(UserName, Password),
103+
{ok, #auth_user{username = UserName}} =
104+
rabbit_auth_backend_internal:user_login_authentication(
105+
UserName, [{password, Password}]),
106+
ok = application:set_env(rabbit, password_hashing_module,
107+
rabbit_password_hashing_sha256),
108+
{ok, #auth_user{username = UserName}} =
109+
rabbit_auth_backend_internal:user_login_authentication(
110+
UserName, [{password, Password}]),
111+
112+
NewPassword = <<"test_password1">>,
113+
ok = rabbit_auth_backend_internal:change_password(UserName, NewPassword),
114+
{ok, #auth_user{username = UserName}} =
115+
rabbit_auth_backend_internal:user_login_authentication(
116+
UserName, [{password, NewPassword}]),
117+
118+
{refused, _, [UserName]} =
119+
rabbit_auth_backend_internal:user_login_authentication(
120+
UserName, [{password, Password}]),
121+
passed.

0 commit comments

Comments
 (0)