manakbisht commented on code in PR #20291:
URL: https://github.com/apache/pinot/pull/20291#discussion_r4666107911


##########
pinot-controller/src/test/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResourceTest.java:
##########
@@ -217,6 +226,37 @@ public void 
testGetSegmentsWithInvalidPartitionMetadataWithColumnFilter()
     assertTrue(result.containsKey("seg3"));
   }
 
+  /// 1 segment x 3 replicas without columns is 3 entries. Every case is 
rejected before any server is contacted.
+  @Test
+  public void testGetServerMetadataEntryLimits()
+      throws Exception {
+    ControllerConf controllerConf = new ControllerConf();
+    
controllerConf.setProperty(ControllerConf.SEGMENT_METADATA_DEFAULT_ENTRY_LIMIT, 
2);
+    
controllerConf.setProperty(ControllerConf.SEGMENT_METADATA_MAX_ENTRY_LIMIT, 10);
+    _pinotSegmentRestletResource._controllerConf = controllerConf;
+    
when(_pinotHelixResourceManager.getExistingTableNamesWithType(eq("testTable"), 
any()))
+        .thenReturn(List.of("testTable_OFFLINE"));
+    
when(_pinotHelixResourceManager.getServerToSegmentsMap("testTable_OFFLINE"))
+        .thenReturn(Map.of("server0", List.of("seg0"), "server1", 
List.of("seg0"), "server2", List.of("seg0")));
+
+    // Omitted: the configured default applies
+    assertServerMetadataRejected(null, "above the limit of 2");
+    // Explicit: overrides the default, so a smaller value applies too
+    assertServerMetadataRejected(1, "above the limit of 1");
+    // Explicit: must be positive and at most the configured max
+    assertServerMetadataRejected(0, 
ControllerConf.SEGMENT_METADATA_MAX_ENTRY_LIMIT);
+    assertServerMetadataRejected(11, 
ControllerConf.SEGMENT_METADATA_MAX_ENTRY_LIMIT);

Review Comment:
   Added `testGetServerMetadataAtMaxEntryLimit`. With default 2, max 3, and one 
segment on three fake servers, an explicit `maxEntries=3` succeeds, which shows 
that callers can go above the default and that the max is inclusive.



##########
pinot-controller/src/test/java/org/apache/pinot/controller/ControllerConfTest.java:
##########
@@ -299,6 +300,40 @@ public void testSegmentReplaceConvergenceCustomValues() {
     Assert.assertEquals(conf.getSegmentReplaceMaxRetryAttempts(), 2);
   }
 
+  @DataProvider
+  public Object[][] segmentMetadataEntryLimits() {
+    return new Object[][]{
+        // default, max, valid
+        {10_001, 10_000, false},
+        {10_000, 10_000, true},
+        {1, 10_000, true},
+        {0, 10_000, false},
+        {-1, 10_000, false}
+    };
+  }
+
+  @Test(dataProvider = "segmentMetadataEntryLimits")
+  public void testSegmentMetadataEntryLimitsValidation(int defaultLimit, int 
maxLimit, boolean valid) {
+    ControllerConf conf = new ControllerConf();
+    conf.setProperty(ControllerConf.SEGMENT_METADATA_DEFAULT_ENTRY_LIMIT, 
defaultLimit);
+    conf.setProperty(ControllerConf.SEGMENT_METADATA_MAX_ENTRY_LIMIT, 
maxLimit);
+
+    if (valid) {
+      conf.validateSegmentMetadataEntryLimits();
+    } else {
+      Assert.expectThrows(IllegalStateException.class, 
conf::validateSegmentMetadataEntryLimits);

Review Comment:
   Done, `expectThrows` is now statically imported and used directly in both 
assertions.



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