somandal commented on code in PR #15650: URL: https://github.com/apache/pinot/pull/15650#discussion_r2070882931
########## 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); observer.onTrigger(TableRebalanceObserver.Trigger.IDEAL_STATE_CHANGE_TRIGGER, source, source, rebalanceContext); + checkProgressPercentMetrics(controllerMetrics, observer); observer.onTrigger(TableRebalanceObserver.Trigger.EXTERNAL_VIEW_TO_IDEAL_STATE_CONVERGENCE_TRIGGER, source, source, rebalanceContext); + checkProgressPercentMetrics(controllerMetrics, observer); // START_TRIGGER will set up the ZK progress stats to have the diff between source and target. When calling the // triggers for IS and EV-IS, since source and source are compared, the diff will change for the IS trigger // but not for the EV-IS trigger, so ZK must be updated 1 extra time assertEquals(observer.getNumUpdatesToZk(), 2); observer.onTrigger(TableRebalanceObserver.Trigger.IDEAL_STATE_CHANGE_TRIGGER, source, target, rebalanceContext); + checkProgressPercentMetrics(controllerMetrics, observer); + observer.onTrigger(TableRebalanceObserver.Trigger.NEXT_ASSINGMENT_CALCULATION_TRIGGER, source, targetIntermediate, + rebalanceContext); + checkProgressPercentMetrics(controllerMetrics, observer); + observer.onTrigger(TableRebalanceObserver.Trigger.EXTERNAL_VIEW_TO_IDEAL_STATE_CONVERGENCE_TRIGGER, source, + targetIntermediate, + rebalanceContext); + checkProgressPercentMetrics(controllerMetrics, observer); + source.put("segment1", + SegmentAssignmentUtils.getInstanceStateMap(Arrays.asList("host1"), ONLINE)); + observer.onTrigger(TableRebalanceObserver.Trigger.EXTERNAL_VIEW_TO_IDEAL_STATE_CONVERGENCE_TRIGGER, source, + targetIntermediate, + rebalanceContext); + observer.onTrigger(TableRebalanceObserver.Trigger.NEXT_ASSINGMENT_CALCULATION_TRIGGER, targetIntermediate, target, + rebalanceContext); + checkProgressPercentMetrics(controllerMetrics, observer); observer.onTrigger(TableRebalanceObserver.Trigger.EXTERNAL_VIEW_TO_IDEAL_STATE_CONVERGENCE_TRIGGER, source, target, rebalanceContext); + checkProgressPercentMetrics(controllerMetrics, observer); // Both of the changes above will update ZK for progress stats Review Comment: since you've added intermediate steps, these existing comments don't make that much sense anymore. can you update all comments for this 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-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