@@ -57,6 +57,7 @@ groups() ->
5757 ]},
5858 runtime_parameters ,
5959 set_disk_free_limit_command ,
60+ set_vm_memory_high_watermark_command ,
6061 topic_matching ,
6162 user_management
6263 ]}
@@ -1505,22 +1506,41 @@ set_disk_free_limit_command1(_Config) ->
15051506 % % Use an integer
15061507 ok = control_action (set_disk_free_limit ,
15071508 [" mem_relative" , " 1" ]),
1508- check_limit (1 ),
1509+ disk_free_limit_to_total_memory_ratio_is (1 ),
15091510
15101511 % % Use a float
15111512 ok = control_action (set_disk_free_limit ,
15121513 [" mem_relative" , " 1.5" ]),
1513- check_limit (1.5 ),
1514+ disk_free_limit_to_total_memory_ratio_is (1.5 ),
15141515
15151516 ok = control_action (set_disk_free_limit , [" 50MB" ]),
15161517 passed .
15171518
1518- check_limit ( Limit ) ->
1519- ExpectedLimit = Limit * vm_memory_monitor :get_total_memory (),
1519+ disk_free_limit_to_total_memory_ratio_is ( MemRatio ) ->
1520+ ExpectedLimit = MemRatio * vm_memory_monitor :get_total_memory (),
15201521 % Total memory is unstable, so checking order
15211522 true = ExpectedLimit / rabbit_disk_monitor :get_disk_free_limit () < 1.2 ,
15221523 true = ExpectedLimit / rabbit_disk_monitor :get_disk_free_limit () > 0.98 .
15231524
1525+ set_vm_memory_high_watermark_command (Config ) ->
1526+ rabbit_ct_broker_helpers :rpc (Config , 0 ,
1527+ ? MODULE , set_vm_memory_high_watermark_command1 , [Config ]).
1528+
1529+ set_vm_memory_high_watermark_command1 (_Config ) ->
1530+ MemLimitRatio = " 1.0" ,
1531+ MemTotal = vm_memory_monitor :get_total_memory (),
1532+
1533+ ok = control_action (set_vm_memory_high_watermark , [MemLimitRatio ]),
1534+ MemLimit = vm_memory_monitor :get_memory_limit (),
1535+ case MemLimit of
1536+ MemTotal -> ok ;
1537+ _ -> MemTotalToMemLimitRatio = MemLimit * 100.0 / MemTotal / 100 ,
1538+ ct :fail (
1539+ " Expected memory high watermark to be ~p (~s ), but it was ~p (~.1f )" ,
1540+ [MemTotal , MemLimitRatio , MemLimit , MemTotalToMemLimitRatio ]
1541+ )
1542+ end .
1543+
15241544% % ---------------------------------------------------------------------------
15251545% % rabbitmqctl helpers.
15261546% % ---------------------------------------------------------------------------
0 commit comments