@@ -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