somandal commented on code in PR #15650: URL: https://github.com/apache/pinot/pull/15650#discussion_r2070881999
########## pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/rebalance/TestZkBasedTableRebalanceObserver.java: ########## @@ -49,39 +50,83 @@ void testZkObserverTracking() { PinotHelixResourceManager pinotHelixResourceManager = mock(PinotHelixResourceManager.class); // Mocking this. We will verify using numZkUpdate stat when(pinotHelixResourceManager.addControllerJobToZK(any(), any(), any())).thenReturn(true); - ControllerMetrics controllerMetrics = Mockito.mock(ControllerMetrics.class); + ControllerMetrics controllerMetrics = ControllerMetrics.get(); TableRebalanceContext retryCtx = new TableRebalanceContext(); retryCtx.setConfig(new RebalanceConfig()); ZkBasedTableRebalanceObserver observer = new ZkBasedTableRebalanceObserver("dummy", "dummyId", retryCtx, pinotHelixResourceManager); Map<String, Map<String, String>> source = new TreeMap<>(); Map<String, Map<String, String>> target = new TreeMap<>(); + Map<String, Map<String, String>> targetIntermediate = new TreeMap<>(); target.put("segment1", SegmentAssignmentUtils.getInstanceStateMap(Arrays.asList("host1", "host2", "host3"), ONLINE)); + target.put("segment3", + SegmentAssignmentUtils.getInstanceStateMap(Arrays.asList("host1", "host2", "host3"), ONLINE)); + targetIntermediate.put("segment1", + SegmentAssignmentUtils.getInstanceStateMap(Arrays.asList("host1", "host2", "host3"), ONLINE)); + targetIntermediate.put("segment3", + SegmentAssignmentUtils.getInstanceStateMap(Arrays.asList("host4", "host5", "host6"), ONLINE)); source.put("segment2", SegmentAssignmentUtils.getInstanceStateMap(Arrays.asList("host2", "host3", "host4"), ONLINE)); + source.put("segment3", + SegmentAssignmentUtils.getInstanceStateMap(Arrays.asList("host4", "host5", "host6"), ONLINE)); Set<String> segmentSet = new HashSet<>(source.keySet()); segmentSet.addAll(target.keySet()); TableRebalanceObserver.RebalanceContext rebalanceContext = new TableRebalanceObserver.RebalanceContext(-1, segmentSet, segmentSet); observer.onTrigger(TableRebalanceObserver.Trigger.START_TRIGGER, source, target, rebalanceContext); assertEquals(observer.getNumUpdatesToZk(), 1); + checkProgressPercentMetrics(controllerMetrics, observer); Review Comment: nit: it'll be good to add comments explaining the steps so it's easier to understand when we're dealing with just remaining, vs. carry + remaining etc -- 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-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org