You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/08/18 07:31:00 UTC

[GitHub] [pulsar] abhilashmandaliya opened a new pull request #11697: [server] Fixed Casting Error

abhilashmandaliya opened a new pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697


   Fixed a casting error introduced in #11671.
   The double value of user-configured backlogQuota in GB is converted to long before converting to bytes.


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-900911565


   Good catch @abhilashmandaliya 


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] abhilashmandaliya commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
abhilashmandaliya commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-901099857


   > > It seems that it's possible to just override the setter "setBacklogQuotaDefaultLimitGB" in ServiceConfiguration class and update the backlogQuotaDefaultLimitBytes field on the fly. It's necessary to keep the backlogQuotaDefaultLimitGB field so that the FieldContext annotation can be used for documenting the field.
   > > I would add a getBacklogQuotaDefaultLimitGB() method with private access to ensure that the method isn't used anywhere in the code directly anymore. ServiceConfiguration isn't part of any public API, there's no need to keep API backwards compatibility for the class itself. As long as the configuration file format is supported, it's sufficient.
   > 
   > I take this back. It's not currently possible to use setters with the configuration loading logic.
   > 
   > Since BacklogQuotaManager is the only location of the logic in production code. Please add a test for calculation logic. It should be pretty straightforward to add the unit test that verifies that getDefaultQuota().getLimitSize() returns the correct bytes when the configuration is using a fractional GB value.
   
   Thaks. I have added a unit test.


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#discussion_r691224136



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaConfiguration() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        double backlogQuotaDefaultLimitGB = 1.6;
+        initializeServiceConfiguration(serviceConfiguration, backlogQuotaDefaultLimitGB);
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+
+        // Test correct conversion of double value
+        BacklogQuotaManager backlogQuotaManager = new BacklogQuotaManager(pulsarService);
+        assertEquals((long) (backlogQuotaDefaultLimitGB * BacklogQuotaImpl.BYTES_IN_GIGABYTE),
+                backlogQuotaManager.getDefaultQuota().getLimitSize());
+
+        int backlogQuotaDefaultLimitBytes = 123;

Review comment:
       don't use a variable. Simply hard code the values in the test. That is better for testing the behavior although it might seem odd at first.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
eolivelli commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-900912023


   @lhotari which kind of test are you requiring  ?
   
   I am not sure it is worth to add the needed instrumentation to test this change.
   The rounding error is quite evident


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] abhilashmandaliya edited a comment on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
abhilashmandaliya edited a comment on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-901099857


   > > It seems that it's possible to just override the setter "setBacklogQuotaDefaultLimitGB" in ServiceConfiguration class and update the backlogQuotaDefaultLimitBytes field on the fly. It's necessary to keep the backlogQuotaDefaultLimitGB field so that the FieldContext annotation can be used for documenting the field.
   > > I would add a getBacklogQuotaDefaultLimitGB() method with private access to ensure that the method isn't used anywhere in the code directly anymore. ServiceConfiguration isn't part of any public API, there's no need to keep API backwards compatibility for the class itself. As long as the configuration file format is supported, it's sufficient.
   > 
   > I take this back. It's not currently possible to use setters with the configuration loading logic.
   > 
   > Since BacklogQuotaManager is the only location of the logic in production code. Please add a test for calculation logic. It should be pretty straightforward to add the unit test that verifies that getDefaultQuota().getLimitSize() returns the correct bytes when the configuration is using a fractional GB value.
   
   Thanks. I have added a unit test.


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-901250163


   LGTM. Good work @abhilashmandaliya ! Thanks for the contribution.


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-900911565






-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#discussion_r691219392



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaConfiguration() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        double backlogQuotaDefaultLimitGB = 1.6;
+        initializeServiceConfiguration(serviceConfiguration, backlogQuotaDefaultLimitGB);
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+
+        // Test correct conversion of double value
+        BacklogQuotaManager backlogQuotaManager = new BacklogQuotaManager(pulsarService);
+        assertEquals((long) (backlogQuotaDefaultLimitGB * BacklogQuotaImpl.BYTES_IN_GIGABYTE),
+                backlogQuotaManager.getDefaultQuota().getLimitSize());

Review comment:
       please add a hard coded byte value here. otherwise we won't be sure about the result.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] abhilashmandaliya edited a comment on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
abhilashmandaliya edited a comment on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-901099857


   > > It seems that it's possible to just override the setter "setBacklogQuotaDefaultLimitGB" in ServiceConfiguration class and update the backlogQuotaDefaultLimitBytes field on the fly. It's necessary to keep the backlogQuotaDefaultLimitGB field so that the FieldContext annotation can be used for documenting the field.
   > > I would add a getBacklogQuotaDefaultLimitGB() method with private access to ensure that the method isn't used anywhere in the code directly anymore. ServiceConfiguration isn't part of any public API, there's no need to keep API backwards compatibility for the class itself. As long as the configuration file format is supported, it's sufficient.
   > 
   > I take this back. It's not currently possible to use setters with the configuration loading logic.
   > 
   > Since BacklogQuotaManager is the only location of the logic in production code. Please add a test for calculation logic. It should be pretty straightforward to add the unit test that verifies that getDefaultQuota().getLimitSize() returns the correct bytes when the configuration is using a fractional GB value.
   
   Thanks. I have added a unit test.


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#discussion_r691226429



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaConfiguration() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        double backlogQuotaDefaultLimitGB = 1.6;
+        initializeServiceConfiguration(serviceConfiguration, backlogQuotaDefaultLimitGB);
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+
+        // Test correct conversion of double value

Review comment:
       split each small test to it's own test method, that's typically recommended. optimally a test method tests only a single behavior.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on a change in pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#discussion_r691319160



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaDefaultLimitGBConversion() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        initializeServiceConfiguration(serviceConfiguration);
+

Review comment:
       can we set here this ?
   `serviceConfiguration.setBacklogQuotaDefaultLimitGB(1.6);`
   
   otherwise is it quite tricky to see where 1717986918 comes from

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaDefaultLimitGBConversion() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        initializeServiceConfiguration(serviceConfiguration);
+
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+        BacklogQuotaManager backlogQuotaManager = new BacklogQuotaManager(pulsarService);
+
+        assertEquals(backlogQuotaManager.getDefaultQuota().getLimitSize(), 1717986918);
+    }
+
+    @Test
+    public void testBacklogQuotaDefaultLimitPrecedence() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        initializeServiceConfiguration(serviceConfiguration);
+        serviceConfiguration.setBacklogQuotaDefaultLimitBytes(123);

Review comment:
       can we set here this ?
   `serviceConfiguration.setBacklogQuotaDefaultLimitGB(1.6);`
   
   otherwise is it quite tricky to see where 1717986918 comes from




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#discussion_r691239823



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaDefaultLimitGBConversion() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        initializeServiceConfiguration(serviceConfiguration);
+
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+        BacklogQuotaManager backlogQuotaManager = new BacklogQuotaManager(pulsarService);

Review comment:
       you can move the common initialization code to a BeforeMethod or even a BeforeClass method (for example `@BeforeMethod public void setup() { ...` etc). That would be one way to reduce code duplication in the test methods.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#discussion_r691222376



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;

Review comment:
       please use the ordinary TestNG Assert class org.testng.Assert since most tests use it. Please note that the parameter order for assertion methods is different compared to Junit. The actual value becomes first, then the expected value.

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaConfiguration() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        double backlogQuotaDefaultLimitGB = 1.6;
+        initializeServiceConfiguration(serviceConfiguration, backlogQuotaDefaultLimitGB);
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+
+        // Test correct conversion of double value
+        BacklogQuotaManager backlogQuotaManager = new BacklogQuotaManager(pulsarService);
+        assertEquals((long) (backlogQuotaDefaultLimitGB * BacklogQuotaImpl.BYTES_IN_GIGABYTE),
+                backlogQuotaManager.getDefaultQuota().getLimitSize());

Review comment:
       please use TestNG's assertEquals instead of AssertJUnit . The parameter order for TestNG's assertEquals is swapped compared to Junit's assertEquals.
   In TestNG, it's `assertEquals(long actual, long expected)` so the actual value becomes first.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-901028370


   > It seems that it's possible to just override the setter "setBacklogQuotaDefaultLimitGB" in ServiceConfiguration class and update the backlogQuotaDefaultLimitBytes field on the fly. It's necessary to keep the backlogQuotaDefaultLimitGB field so that the FieldContext annotation can be used for documenting the field.
   I would add a getBacklogQuotaDefaultLimitGB() method with private access to ensure that the method isn't used anywhere in the code directly anymore. ServiceConfiguration isn't part of any public API, there's no need to keep API backwards compatibility for the class itself. As long as the configuration file format is supported, it's sufficient.
   
   I take this back. It's not currently possible to use setters with the configuration loading logic. 
   
   Since BacklogQuotaManager is the only location of the logic in production code. Please add a test for calculation logic. It should be pretty straightforward to add the unit test that verifies that getDefaultQuota().getLimitSize() returns the correct bytes when the configuration is using a fractional GB value.
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
eolivelli commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-900912023


   @lhotari which kind of test are you requiring  ?
   
   I am not sure it is worth to add the needed instrumentation to test this change.
   The rounding error is quite evident


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-901002619


   > @lhotari which kind of test are you requiring ?
   
   a unit test that verifies that the GB -> bytes calculation works as expected. 
   
   > 
   > I am not sure it is worth to add the needed instrumentation to test this change.
   > The rounding error is quite evident
   
   I feel that it's important to test that the calculation is correct since #11671 changed the way how the limit is configured. We cannot rely that the result is correct unless we have a test in place.
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] merlimat merged pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
merlimat merged pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697


   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] abhilashmandaliya commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
abhilashmandaliya commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-901238374


   Thanks, @lhotari, and @eolivelli for a thorough review and for helping me make it cleaner. I have considered all the suggestions.


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#discussion_r691219392



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaConfiguration() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        double backlogQuotaDefaultLimitGB = 1.6;
+        initializeServiceConfiguration(serviceConfiguration, backlogQuotaDefaultLimitGB);
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+
+        // Test correct conversion of double value
+        BacklogQuotaManager backlogQuotaManager = new BacklogQuotaManager(pulsarService);
+        assertEquals((long) (backlogQuotaDefaultLimitGB * BacklogQuotaImpl.BYTES_IN_GIGABYTE),
+                backlogQuotaManager.getDefaultQuota().getLimitSize());

Review comment:
       please add a hard coded byte value here. otherwise we won't be sure about the result.

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;

Review comment:
       please use the ordinary TestNG Assert class org.testng.Assert since most tests use it. Please note that the parameter order for assertion methods is different compared to Junit. The actual value becomes first, then the expected value.

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaConfiguration() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        double backlogQuotaDefaultLimitGB = 1.6;
+        initializeServiceConfiguration(serviceConfiguration, backlogQuotaDefaultLimitGB);
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+
+        // Test correct conversion of double value
+        BacklogQuotaManager backlogQuotaManager = new BacklogQuotaManager(pulsarService);
+        assertEquals((long) (backlogQuotaDefaultLimitGB * BacklogQuotaImpl.BYTES_IN_GIGABYTE),
+                backlogQuotaManager.getDefaultQuota().getLimitSize());

Review comment:
       please use TestNG's assertEquals instead of AssertJUnit . The parameter order for TestNG's assertEquals is swapped compared to Junit's assertEquals.
   In TestNG, it's `assertEquals(long actual, long expected)` so the actual value becomes first.

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaConfiguration() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        double backlogQuotaDefaultLimitGB = 1.6;
+        initializeServiceConfiguration(serviceConfiguration, backlogQuotaDefaultLimitGB);
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+
+        // Test correct conversion of double value
+        BacklogQuotaManager backlogQuotaManager = new BacklogQuotaManager(pulsarService);
+        assertEquals((long) (backlogQuotaDefaultLimitGB * BacklogQuotaImpl.BYTES_IN_GIGABYTE),
+                backlogQuotaManager.getDefaultQuota().getLimitSize());
+
+        int backlogQuotaDefaultLimitBytes = 123;

Review comment:
       don't use a variable. Simply hard code the values in the test. That is better for testing the behavior although it might seem odd at first.

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaConfiguration() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        double backlogQuotaDefaultLimitGB = 1.6;
+        initializeServiceConfiguration(serviceConfiguration, backlogQuotaDefaultLimitGB);
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+
+        // Test correct conversion of double value

Review comment:
       split each small test to it's own test method, that's typically recommended. optimally a test method tests only a single behavior.

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaDefaultLimitGBConversion() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        initializeServiceConfiguration(serviceConfiguration);
+
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+        BacklogQuotaManager backlogQuotaManager = new BacklogQuotaManager(pulsarService);

Review comment:
       you can move the common initialization code to a BeforeMethod or even a BeforeClass method (for example `@BeforeMethod public void setup() { ...` etc). That would be one way to reduce code duplication in the test methods.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] abhilashmandaliya commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
abhilashmandaliya commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-901099857






-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#issuecomment-901008509


   To unit test the logic, I'd recommend doing a refactoring.
   
   It seems that it's possible to just override the setter "setBacklogQuotaDefaultLimitGB" in ServiceConfiguration class and update the backlogQuotaDefaultLimitBytes field on the fly. It's necessary to keep the backlogQuotaDefaultLimitGB field so that the FieldContext annotation can be used for documenting the field.
   I would add a getBacklogQuotaDefaultLimitGB() method with private access to ensure that the method isn't used anywhere in the code directly anymore. ServiceConfiguration isn't part of any public API, there's no need to keep API backwards compatibility for the class itself. As long as the configuration file format is supported, it's sufficient.
   
   After making this refactoring, it's sufficient to unit test the logic of ServiceConfiguration class.
   
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on a change in pull request #11697: [server] Fixed Casting Error

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #11697:
URL: https://github.com/apache/pulsar/pull/11697#discussion_r691319160



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaDefaultLimitGBConversion() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        initializeServiceConfiguration(serviceConfiguration);
+

Review comment:
       can we set here this ?
   `serviceConfiguration.setBacklogQuotaDefaultLimitGB(1.6);`
   
   otherwise is it quite tricky to see where 1717986918 comes from

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerConfigurationTest.java
##########
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.cache.ConfigurationCacheService;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+
+@Test(groups = "broker")
+public class BacklogQuotaManagerConfigurationTest {
+
+    @Test
+    public void testBacklogQuotaDefaultLimitGBConversion() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        initializeServiceConfiguration(serviceConfiguration);
+
+        PulsarService pulsarService = getPulsarService(serviceConfiguration);
+        BacklogQuotaManager backlogQuotaManager = new BacklogQuotaManager(pulsarService);
+
+        assertEquals(backlogQuotaManager.getDefaultQuota().getLimitSize(), 1717986918);
+    }
+
+    @Test
+    public void testBacklogQuotaDefaultLimitPrecedence() {
+        ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
+        initializeServiceConfiguration(serviceConfiguration);
+        serviceConfiguration.setBacklogQuotaDefaultLimitBytes(123);

Review comment:
       can we set here this ?
   `serviceConfiguration.setBacklogQuotaDefaultLimitGB(1.6);`
   
   otherwise is it quite tricky to see where 1717986918 comes from




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org