Skip to content

Commit 963aa9f

Browse files
Fix UT failures
1 parent 29bc490 commit 963aa9f

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBulkLoadReplication.java

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
import org.apache.hadoop.hbase.util.Bytes;
7373
import org.apache.hadoop.hbase.util.Pair;
7474
import org.apache.hadoop.hdfs.MiniDFSCluster;
75-
import org.junit.After;
7675
import org.junit.Before;
7776
import org.junit.BeforeClass;
7877
import org.junit.ClassRule;
@@ -128,6 +127,8 @@ public class TestBulkLoadReplication extends TestReplicationBase {
128127

129128
private static ReplicationQueueStorage queueStorage;
130129

130+
private static boolean replicationPeersAdded = false;
131+
131132
@BeforeClass
132133
public static void setUpBeforeClass() throws Exception {
133134
setupBulkLoadConfigsForCluster(CONF1, PEER1_CLUSTER_ID);
@@ -161,22 +162,27 @@ private static void startThirdCluster() throws Exception {
161162
@Before
162163
@Override
163164
public void setUpBase() throws Exception {
164-
// "super.setUpBase()" already sets replication from 1->2,
165-
// then on the subsequent lines, sets 2->1, 2->3 and 3->2.
166-
// So we have following topology: "1 <-> 2 <->3"
167-
super.setUpBase();
168-
ReplicationPeerConfig peer1Config = getPeerConfigForCluster(UTIL1);
169-
ReplicationPeerConfig peer2Config = getPeerConfigForCluster(UTIL2);
170-
ReplicationPeerConfig peer3Config = getPeerConfigForCluster(UTIL3);
171-
// adds cluster1 as a remote peer on cluster2
172-
UTIL2.getAdmin().addReplicationPeer(PEER_ID1, peer1Config);
173-
// adds cluster3 as a remote peer on cluster2
174-
UTIL2.getAdmin().addReplicationPeer(PEER_ID3, peer3Config);
175-
// adds cluster2 as a remote peer on cluster3
176-
UTIL3.getAdmin().addReplicationPeer(PEER_ID2, peer2Config);
177-
setupCoprocessor(UTIL1);
178-
setupCoprocessor(UTIL2);
179-
setupCoprocessor(UTIL3);
165+
// removing the peer and adding again causing the previously completed bulk load jobs getting
166+
// submitted again, adding a check to add the peers only once.
167+
if (!replicationPeersAdded) {
168+
// "super.setUpBase()" already sets replication from 1->2,
169+
// then on the subsequent lines, sets 2->1, 2->3 and 3->2.
170+
// So we have following topology: "1 <-> 2 <->3"
171+
super.setUpBase();
172+
ReplicationPeerConfig peer1Config = getPeerConfigForCluster(UTIL1);
173+
ReplicationPeerConfig peer2Config = getPeerConfigForCluster(UTIL2);
174+
ReplicationPeerConfig peer3Config = getPeerConfigForCluster(UTIL3);
175+
// adds cluster1 as a remote peer on cluster2
176+
UTIL2.getAdmin().addReplicationPeer(PEER_ID1, peer1Config);
177+
// adds cluster3 as a remote peer on cluster2
178+
UTIL2.getAdmin().addReplicationPeer(PEER_ID3, peer3Config);
179+
// adds cluster2 as a remote peer on cluster3
180+
UTIL3.getAdmin().addReplicationPeer(PEER_ID2, peer2Config);
181+
setupCoprocessor(UTIL1);
182+
setupCoprocessor(UTIL2);
183+
setupCoprocessor(UTIL3);
184+
replicationPeersAdded = true;
185+
}
180186
BULK_LOADS_COUNT = new AtomicInteger(0);
181187
}
182188

@@ -204,15 +210,6 @@ private void setupCoprocessor(HBaseTestingUtil cluster) {
204210
});
205211
}
206212

207-
@After
208-
@Override
209-
public void tearDownBase() throws Exception {
210-
super.tearDownBase();
211-
UTIL2.getAdmin().removeReplicationPeer(PEER_ID1);
212-
UTIL2.getAdmin().removeReplicationPeer(PEER_ID3);
213-
UTIL3.getAdmin().removeReplicationPeer(PEER_ID2);
214-
}
215-
216213
protected static void setupBulkLoadConfigsForCluster(Configuration config,
217214
String clusterReplicationId) throws Exception {
218215
config.setBoolean(HConstants.REPLICATION_BULKLOAD_ENABLE_KEY, true);

0 commit comments

Comments
 (0)