diff options
| author | Michael Klishin <michael@clojurewerkz.org> | 2017-07-11 04:30:53 +0300 |
|---|---|---|
| committer | Michael Klishin <michael@clojurewerkz.org> | 2017-07-11 04:30:53 +0300 |
| commit | 9aad266b813f12cf9e2dd31f48c02433eec1431c (patch) | |
| tree | b161c90397e5cae14e7379c11e9ccd6c1359c955 | |
| parent | 36ef3ab70f56938e14f7ed0d65f8fa5ff2171219 (diff) | |
| parent | 6967bb30cec8af59e76bcbe098dd0e959c09eacc (diff) | |
| download | rabbitmq-server-git-9aad266b813f12cf9e2dd31f48c02433eec1431c.tar.gz | |
Merge branch 'stable'
Conflicts:
test/unit_inbroker_parallel_SUITE.erl
| -rw-r--r-- | src/rabbit_vm.erl | 7 | ||||
| -rw-r--r-- | test/unit_inbroker_parallel_SUITE.erl | 46 |
2 files changed, 49 insertions, 4 deletions
diff --git a/src/rabbit_vm.erl b/src/rabbit_vm.erl index c2353ab85f..3ae482a934 100644 --- a/src/rabbit_vm.erl +++ b/src/rabbit_vm.erl @@ -54,14 +54,13 @@ memory() -> MgmtDbETS = ets_memory([rabbit_mgmt_storage]), OsTotal = vm_memory_monitor:get_process_memory(), - [{total, ErlangTotal}, - {processes, Processes}, + [{processes, Processes}, {ets, ETS}, {atom, Atom}, {binary, Bin}, {code, Code}, {system, System}] = - erlang:memory([total, processes, ets, atom, binary, code, system]), + erlang:memory([processes, ets, atom, binary, code, system]), OtherProc = Processes - ConnsReader - ConnsWriter - ConnsChannel - ConnsOther @@ -97,7 +96,7 @@ memory() -> %% System {code, Code}, {atom, Atom}, - {other_system, System - ETS - Bin - Code - Atom + (OsTotal - ErlangTotal)}, + {other_system, System - ETS - Bin - Code - Atom}, {total, OsTotal} ]. diff --git a/test/unit_inbroker_parallel_SUITE.erl b/test/unit_inbroker_parallel_SUITE.erl index 453f4b2e72..dd8cd48b5a 100644 --- a/test/unit_inbroker_parallel_SUITE.erl +++ b/test/unit_inbroker_parallel_SUITE.erl @@ -46,6 +46,8 @@ groups() -> password_hashing, change_password ]}, + set_disk_free_limit_command, + set_vm_memory_high_watermark_command, topic_matching ]} ]. @@ -972,6 +974,50 @@ configurable_server_properties1(_Config) -> application:set_env(rabbit, server_properties, ServerProperties), passed. +set_disk_free_limit_command(Config) -> + passed = rabbit_ct_broker_helpers:rpc(Config, 0, + ?MODULE, set_disk_free_limit_command1, [Config]). + +set_disk_free_limit_command1(_Config) -> + rabbit_disk_monitor:set_disk_free_limit("2000kiB"), + 2048000 = rabbit_disk_monitor:get_disk_free_limit(), + + %% Use an integer + rabbit_disk_monitor:set_disk_free_limit({mem_relative, 1}), + disk_free_limit_to_total_memory_ratio_is(1), + + %% Use a float + rabbit_disk_monitor:set_disk_free_limit({mem_relative, 1.5}), + disk_free_limit_to_total_memory_ratio_is(1.5), + + rabbit_disk_monitor:set_disk_free_limit("50MB"), + passed. + +disk_free_limit_to_total_memory_ratio_is(MemRatio) -> + ExpectedLimit = MemRatio * vm_memory_monitor:get_total_memory(), + % Total memory is unstable, so checking order + true = ExpectedLimit/rabbit_disk_monitor:get_disk_free_limit() < 1.2, + true = ExpectedLimit/rabbit_disk_monitor:get_disk_free_limit() > 0.98. + +set_vm_memory_high_watermark_command(Config) -> + rabbit_ct_broker_helpers:rpc(Config, 0, + ?MODULE, set_vm_memory_high_watermark_command1, [Config]). + +set_vm_memory_high_watermark_command1(_Config) -> + MemLimitRatio = 1.0, + MemTotal = vm_memory_monitor:get_total_memory(), + + vm_memory_monitor:set_vm_memory_high_watermark(MemLimitRatio), + MemLimit = vm_memory_monitor:get_memory_limit(), + case MemLimit of + MemTotal -> ok; + _ -> MemTotalToMemLimitRatio = MemLimit * 100.0 / MemTotal / 100, + ct:fail( + "Expected memory high watermark to be ~p (~s), but it was ~p (~.1f)", + [MemTotal, MemLimitRatio, MemLimit, MemTotalToMemLimitRatio] + ) + end. + %% --------------------------------------------------------------------------- %% rabbitmqctl helpers. %% --------------------------------------------------------------------------- |
