Denovo1998 commented on code in PR #24883:
URL: https://github.com/apache/pulsar/pull/24883#discussion_r2534009776


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/LinuxBrokerHostUsageImplTest.java:
##########
@@ -47,6 +54,34 @@ public void checkOverrideBrokerNicSpeedGbps() {
         Assert.assertEquals(totalLimit, 3.0 * 1000 * 1000 * 3);
     }
 
+    @Test
+    public void checkOverrideBrokerNics() {
+        try (MockedStatic<LinuxInfoUtils> mockedUtils = 
Mockito.mockStatic(LinuxInfoUtils.class)) {
+            mockedUtils.when(() -> LinuxInfoUtils.getTotalNicUsage(any(), 
any(), any())).thenReturn(3.0d);
+            
mockedUtils.when(LinuxInfoUtils::getCpuUsageForEntireHost).thenReturn(LinuxInfoUtils.ResourceUsage.empty());
+            List<String> nics = new ArrayList<>();
+            nics.add("1");
+            nics.add("2");
+            nics.add("3");
+            ServiceConfiguration config = new ServiceConfiguration();
+            
config.setLoadBalancerOverrideBrokerNicSpeedGbps(Optional.of(3.0d));
+            config.setLoadBalancerOverrideBrokerNics(nics);
+            PulsarService pulsarService = mock(PulsarService.class);
+            when(pulsarService.getConfiguration()).thenReturn(config);
+            @Cleanup("shutdown")
+            ScheduledExecutorService executorService = 
Executors.newSingleThreadScheduledExecutor();
+            
when(pulsarService.getLoadManagerExecutor()).thenReturn(executorService);
+            LinuxBrokerHostUsageImpl linuxBrokerHostUsage = new 
LinuxBrokerHostUsageImpl(pulsarService);
+            linuxBrokerHostUsage.calculateBrokerHostUsage();
+            double totalLimit = 
linuxBrokerHostUsage.getTotalNicLimitWithConfiguration(nics);
+            Assert.assertEquals(totalLimit, 3.0 * 1000 * 1000 * 3);
+            double totalNicLimitRx = 
linuxBrokerHostUsage.getBrokerHostUsage().getBandwidthIn().limit;
+            double totalNicLimitTx = 
linuxBrokerHostUsage.getBrokerHostUsage().getBandwidthIn().limit;

Review Comment:
   May be `getBandwidthOut`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to