J-HowHuang commented on code in PR #18366:
URL: https://github.com/apache/pinot/pull/18366#discussion_r3163199282


##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/SegmentOperationsThrottlerSetTest.java:
##########
@@ -195,15 +198,76 @@ public void testBasicAcquireAllPermits()
 
   @Test
   public void testThrowExceptionOnSettingInvalidConfigValues() {
-    // All invalid constructor args should throw IllegalArgumentException 
regardless of isServingQueries
+    // Negative constructor args should throw IllegalArgumentException 
regardless of isServingQueries.
     Assert.assertThrows(IllegalArgumentException.class, () -> new 
SegmentOperationsThrottler(-1, 4, true));
-    Assert.assertThrows(IllegalArgumentException.class, () -> new 
SegmentOperationsThrottler(0, 4, true));
     Assert.assertThrows(IllegalArgumentException.class, () -> new 
SegmentOperationsThrottler(1, -4, true));
-    Assert.assertThrows(IllegalArgumentException.class, () -> new 
SegmentOperationsThrottler(1, 0, true));
     Assert.assertThrows(IllegalArgumentException.class, () -> new 
SegmentOperationsThrottler(-1, 4, false));
-    Assert.assertThrows(IllegalArgumentException.class, () -> new 
SegmentOperationsThrottler(0, 4, false));
     Assert.assertThrows(IllegalArgumentException.class, () -> new 
SegmentOperationsThrottler(1, -4, false));
-    Assert.assertThrows(IllegalArgumentException.class, () -> new 
SegmentOperationsThrottler(1, 0, false));
+  }
+
+  @Test
+  public void testZeroPermitsKillSwitch()
+      throws Exception {
+    SegmentOperationsThrottler t = new SegmentOperationsThrottler(0, 0, true);
+    Assert.assertEquals(t.totalPermits(), 0);
+    Assert.assertEquals(t.availablePermits(), 0);
+
+    // Updating to a positive value lifts the kill switch.
+    t.updatePermits(2, 2);
+    Assert.assertEquals(t.totalPermits(), 2);
+    Assert.assertEquals(t.availablePermits(), 2);
+
+    // Setting back to 0 restores the kill switch without throwing.
+    t.updatePermits(0, 0);
+    Assert.assertEquals(t.totalPermits(), 0);
+    Assert.assertEquals(t.availablePermits(), 0);
+  }
+
+  @Test(timeOut = 10_000)
+  public void testZeroPermitsBlocksAcquireUntilPermitsRestored()

Review Comment:
   I think the blocking part is trivial, might as well remove the test that 
tests blocking. I'll keep the test to verify the unblocking part.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to