Skip to content

Commit 38435aa

Browse files
committed
HDFS-6470. TestBPOfferService.testBPInitErrorHandling is flaky. Contributed by Ming Ma.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1602490 13f79535-47bb-0310-9956-ffa450edef68
1 parent b7d4fae commit 38435aa

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ Release 2.5.0 - UNRELEASED
437437

438438
HDFS-6330. Move mkdirs() to FSNamesystem. (wheat9)
439439

440+
HDFS-6470. TestBPOfferService.testBPInitErrorHandling is flaky.
441+
(Ming Ma via wang)
442+
440443
OPTIMIZATIONS
441444

442445
HDFS-6214. Webhdfs has poor throughput for files >2GB (daryn)

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,14 @@ public Void answer(InvocationOnMock invocation) throws Throwable {
325325
}
326326
}).when(mockDn).initBlockPool(Mockito.any(BPOfferService.class));
327327
BPOfferService bpos = setupBPOSForNNs(mockDn, mockNN1, mockNN2);
328+
List<BPServiceActor> actors = bpos.getBPServiceActors();
329+
assertEquals(2, actors.size());
328330
bpos.start();
329331
try {
330332
waitForInitialization(bpos);
331-
List<BPServiceActor> actors = bpos.getBPServiceActors();
332-
// even if one of the actor initialization fails also other will be
333-
// running until both failed.
334-
assertEquals(2, actors.size());
335-
BPServiceActor actor = actors.get(0);
336-
waitForBlockReport(actor.getNameNodeProxy());
333+
// even if one of the actor initialization fails, the other one will be
334+
// finish block report.
335+
waitForBlockReport(mockNN1, mockNN2);
337336
} finally {
338337
bpos.stop();
339338
}
@@ -409,7 +408,32 @@ public Boolean get() {
409408
}
410409
}, 500, 10000);
411410
}
412-
411+
412+
private void waitForBlockReport(
413+
final DatanodeProtocolClientSideTranslatorPB mockNN1,
414+
final DatanodeProtocolClientSideTranslatorPB mockNN2)
415+
throws Exception {
416+
GenericTestUtils.waitFor(new Supplier<Boolean>() {
417+
@Override
418+
public Boolean get() {
419+
return get(mockNN1) || get(mockNN2);
420+
}
421+
422+
private Boolean get(DatanodeProtocolClientSideTranslatorPB mockNN) {
423+
try {
424+
Mockito.verify(mockNN).blockReport(
425+
Mockito.<DatanodeRegistration>anyObject(),
426+
Mockito.eq(FAKE_BPID),
427+
Mockito.<StorageBlockReport[]>anyObject());
428+
return true;
429+
} catch (Throwable t) {
430+
LOG.info("waiting on block report: " + t.getMessage());
431+
return false;
432+
}
433+
}
434+
}, 500, 10000);
435+
}
436+
413437
private ReceivedDeletedBlockInfo[] waitForBlockReceived(
414438
ExtendedBlock fakeBlock,
415439
DatanodeProtocolClientSideTranslatorPB mockNN) throws Exception {

0 commit comments

Comments
 (0)