From 1183f06c169ddbe075410767c326e67d397e40b3 Mon Sep 17 00:00:00 2001 From: LiangJun He <2005hithlj@163.com> Date: Thu, 4 Aug 2022 22:42:36 +0800 Subject: [PATCH] HBASE-27269 The implementation of TestReplicationStatus.waitOnMetricsReport is incorrect (#4678) Signed-off-by: Duo Zhang (cherry picked from commit 2dc26082be978796046d9124212e8c9d2d8a1f5d) --- .../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 waitOnMetricsReport(int greaterThan, ServerName serverName) - throws IOException { - ClusterMetrics metrics = hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)); - List list = - metrics.getLiveServerMetrics().get(serverName).getReplicationLoadSourceList(); - while (list.size() <= greaterThan) { - Threads.sleep(1000); - } - return list; + throws Exception { + UTIL1.waitFor(30000, 1000, new Waiter.ExplainingPredicate() { + @Override + public boolean evaluate() throws Exception { + List 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(); } }