From 9f752dabd4064c4f043576113988cd6d93da0b7d Mon Sep 17 00:00:00 2001 From: stack Date: Mon, 17 Feb 2020 13:15:59 -0800 Subject: [PATCH] HBASE-23863 [Flakey Test] TestReplicationEndpointWithMultipleWAL#testInterClusterReplication Debug --- .../replication/TestReplicationEndpoint.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java index 2a32e3da397..6f6fb59e3cf 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; - import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -210,11 +209,25 @@ public class TestReplicationEndpoint extends TestReplicationBase { final String id = "testInterClusterReplication"; List regions = UTIL1.getHBaseCluster().getRegions(tableName); + // This trick of waiting on peer to show up is taken from test above. + int peerCount = admin.getPeersCount(); + admin.addPeer(id, + new ReplicationPeerConfig().setClusterKey(ZKConfig.getZooKeeperClusterKey(CONF2)) + .setReplicationEndpointImpl(InterClusterReplicationEndpointForTest.class.getName()), + null); + // This test is flakey and then there is so much stuff flying around in here its, hard to + // debug. Peer needs to be up for the edit to make it across. This wait on + // peer count seems to be a hack that has us not progress till peer is up. + if (admin.getPeersCount() <= peerCount) { + LOG.info("Waiting on peercount to go up from " + peerCount); + Threads.sleep(100); + } + int totEdits = 0; // Make sure edits are spread across regions because we do region based batching // before shipping edits. - for(HRegion region: regions) { + for (HRegion region: regions) { RegionInfo hri = region.getRegionInfo(); byte[] row = hri.getStartKey(); for (int i = 0; i < 100; i++) { @@ -227,12 +240,8 @@ public class TestReplicationEndpoint extends TestReplicationBase { } } - admin.addPeer(id, - new ReplicationPeerConfig().setClusterKey(ZKConfig.getZooKeeperClusterKey(CONF2)) - .setReplicationEndpointImpl(InterClusterReplicationEndpointForTest.class.getName()), - null); - final int numEdits = totEdits; + LOG.info("Waiting on replication of {}", numEdits); Waiter.waitFor(CONF1, 30000, new Waiter.ExplainingPredicate() { @Override public boolean evaluate() throws Exception { @@ -560,7 +569,7 @@ public class TestReplicationEndpoint extends TestReplicationBase { return entry; } - public static boolean hasPassedAnEntry(){ + public static boolean hasPassedAnEntry() { return passedEntry; } }