This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a commit to branch branch-2 in repository https://gitbox.apache.org/repos/asf/hbase.git
commit c5b22d973bacbfdd3aa02272506144cc18b2f809 Author: LiangJun He <[email protected]> AuthorDate: Thu Aug 4 22:42:36 2022 +0800 HBASE-27269 The implementation of TestReplicationStatus.waitOnMetricsReport is incorrect (#4678) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 2dc26082be978796046d9124212e8c9d2d8a1f5d) --- .../hbase/replication/TestReplicationStatus.java | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStatus.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStatus.java index a538d92a09e..c232550d41d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStatus.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStatus.java @@ -133,13 +133,24 @@ public class TestReplicationStatus extends TestReplicationBase { * @param greaterThan size of replicationLoadSourceList must be greater before we proceed */ private List<ReplicationLoadSource> waitOnMetricsReport(int greaterThan, ServerName serverName) - throws IOException { - ClusterMetrics metrics = hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)); - List<ReplicationLoadSource> list = - metrics.getLiveServerMetrics().get(serverName).getReplicationLoadSourceList(); - while (list.size() <= greaterThan) { - Threads.sleep(1000); - } - return list; + throws Exception { + UTIL1.waitFor(30000, 1000, new Waiter.ExplainingPredicate<Exception>() { + @Override + public boolean evaluate() throws Exception { + List<ReplicationLoadSource> list = + hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics() + .get(serverName).getReplicationLoadSourceList(); + return list.size() > greaterThan; + } + + @Override + public String explainFailure() throws Exception { + return "The ReplicationLoadSourceList's size is lesser than or equal to " + greaterThan + + " for " + serverName; + } + }); + + return hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics() + .get(serverName).getReplicationLoadSourceList(); } }
