virajjasani commented on code in PR #5432:
URL: https://github.com/apache/hadoop/pull/5432#discussion_r1122177909
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestFsDatasetImpl.java:
##########
@@ -1101,15 +1099,12 @@ public void testReportBadBlocks() throws Exception {
block = DFSTestUtil.getFirstBlock(fs, filePath);
// Test for the overloaded method reportBadBlocks
- dataNode.reportBadBlocks(block, dataNode.getFSDataset()
- .getFsVolumeReferences().get(0));
- Thread.sleep(3000);
- BlockManagerTestUtil.updateState(cluster.getNamesystem()
- .getBlockManager());
- // Verify the bad block has been reported to namenode
- Assert.assertEquals(1,
cluster.getNamesystem().getCorruptReplicaBlocks());
- } finally {
- cluster.shutdown();
+ dataNode.reportBadBlocks(block,
dataNode.getFSDataset().getFsVolumeReferences().get(0));
+ GenericTestUtils.waitFor(() -> {
+
BlockManagerTestUtil.updateState(cluster.getNamesystem().getBlockManager());
+ // Verify the bad block has been reported to namenode
+ return 1 == cluster.getNamesystem().getCorruptReplicaBlocks();
+ }, 100, 10000, "Corrupted replica blocks could not be found");
Review Comment:
> I gave it a try and was able to repro this. With triggerHeartbeat, it
worked for me. I think that is a standard practice for such cases running since
legacy time for such cases(At least my time).
Great, sound good.
> do you intend to say if we put a sleep just before processQueueMessages,
things should screw up?
Yes that's what I was suspecting so far but looks like even with sleep,
reproducing the screw up is difficult. I tried it now several times but unable
to reproduce failure with sleep.
Also, now I understand what could still possibly go wrong with the race
condition, let me update the patch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]