J-HowHuang commented on code in PR #15650: URL: https://github.com/apache/pinot/pull/15650#discussion_r2070873703
########## pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/rebalance/TestZkBasedTableRebalanceObserver.java: ########## @@ -67,23 +68,42 @@ void testZkObserverTracking() { 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.EXTERNAL_VIEW_TO_IDEAL_STATE_CONVERGENCE_TRIGGER, source, target, rebalanceContext); + checkProgressPercentMetrics(controllerMetrics, observer); // Both of the changes above will update ZK for progress stats assertEquals(observer.getNumUpdatesToZk(), 4); // Try a rollback and this should trigger a ZK update as well observer.onRollback(); assertEquals(observer.getNumUpdatesToZk(), 5); } + private void checkProgressPercentMetrics(ControllerMetrics controllerMetrics, + ZkBasedTableRebalanceObserver observer) { + Long progressGaugeValue = + controllerMetrics.getGaugeValue(ControllerGauge.TABLE_REBALANCE_JOB_PROGRESS_PERCENT.getGaugeName() + ".dummy"); + assertNotNull(progressGaugeValue); + TableRebalanceProgressStats.RebalanceProgressStats overallProgress = + observer.getTableRebalanceProgressStats().getRebalanceProgressStatsOverall(); + long progressRemained = (long) Math.ceil(TableRebalanceProgressStats.calculatePercentageChange( Review Comment: Test added to the existing `testZkObserverTracking`. Did verify it fails if the formula does not include carry over -- 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