Skip to content

Commit 9aad266

Browse files
Merge branch 'stable'
Conflicts: test/unit_inbroker_parallel_SUITE.erl
2 parents 36ef3ab + 6967bb3 commit 9aad266

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

src/rabbit_vm.erl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ memory() ->
5454
MgmtDbETS = ets_memory([rabbit_mgmt_storage]),
5555
OsTotal = vm_memory_monitor:get_process_memory(),
5656

57-
[{total, ErlangTotal},
58-
{processes, Processes},
57+
[{processes, Processes},
5958
{ets, ETS},
6059
{atom, Atom},
6160
{binary, Bin},
6261
{code, Code},
6362
{system, System}] =
64-
erlang:memory([total, processes, ets, atom, binary, code, system]),
63+
erlang:memory([processes, ets, atom, binary, code, system]),
6564

6665
OtherProc = Processes
6766
- ConnsReader - ConnsWriter - ConnsChannel - ConnsOther
@@ -97,7 +96,7 @@ memory() ->
9796
%% System
9897
{code, Code},
9998
{atom, Atom},
100-
{other_system, System - ETS - Bin - Code - Atom + (OsTotal - ErlangTotal)},
99+
{other_system, System - ETS - Bin - Code - Atom},
101100

102101
{total, OsTotal}
103102
].

test/unit_inbroker_parallel_SUITE.erl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ groups() ->
4646
password_hashing,
4747
change_password
4848
]},
49+
set_disk_free_limit_command,
50+
set_vm_memory_high_watermark_command,
4951
topic_matching
5052
]}
5153
].
@@ -972,6 +974,50 @@ configurable_server_properties1(_Config) ->
972974
application:set_env(rabbit, server_properties, ServerProperties),
973975
passed.
974976

977+
set_disk_free_limit_command(Config) ->
978+
passed = rabbit_ct_broker_helpers:rpc(Config, 0,
979+
?MODULE, set_disk_free_limit_command1, [Config]).
980+
981+
set_disk_free_limit_command1(_Config) ->
982+
rabbit_disk_monitor:set_disk_free_limit("2000kiB"),
983+
2048000 = rabbit_disk_monitor:get_disk_free_limit(),
984+
985+
%% Use an integer
986+
rabbit_disk_monitor:set_disk_free_limit({mem_relative, 1}),
987+
disk_free_limit_to_total_memory_ratio_is(1),
988+
989+
%% Use a float
990+
rabbit_disk_monitor:set_disk_free_limit({mem_relative, 1.5}),
991+
disk_free_limit_to_total_memory_ratio_is(1.5),
992+
993+
rabbit_disk_monitor:set_disk_free_limit("50MB"),
994+
passed.
995+
996+
disk_free_limit_to_total_memory_ratio_is(MemRatio) ->
997+
ExpectedLimit = MemRatio * vm_memory_monitor:get_total_memory(),
998+
% Total memory is unstable, so checking order
999+
true = ExpectedLimit/rabbit_disk_monitor:get_disk_free_limit() < 1.2,
1000+
true = ExpectedLimit/rabbit_disk_monitor:get_disk_free_limit() > 0.98.
1001+
1002+
set_vm_memory_high_watermark_command(Config) ->
1003+
rabbit_ct_broker_helpers:rpc(Config, 0,
1004+
?MODULE, set_vm_memory_high_watermark_command1, [Config]).
1005+
1006+
set_vm_memory_high_watermark_command1(_Config) ->
1007+
MemLimitRatio = 1.0,
1008+
MemTotal = vm_memory_monitor:get_total_memory(),
1009+
1010+
vm_memory_monitor:set_vm_memory_high_watermark(MemLimitRatio),
1011+
MemLimit = vm_memory_monitor:get_memory_limit(),
1012+
case MemLimit of
1013+
MemTotal -> ok;
1014+
_ -> MemTotalToMemLimitRatio = MemLimit * 100.0 / MemTotal / 100,
1015+
ct:fail(
1016+
"Expected memory high watermark to be ~p (~s), but it was ~p (~.1f)",
1017+
[MemTotal, MemLimitRatio, MemLimit, MemTotalToMemLimitRatio]
1018+
)
1019+
end.
1020+
9751021
%% ---------------------------------------------------------------------------
9761022
%% rabbitmqctl helpers.
9771023
%% ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)