From 8c520a27cbd9daba05367d3a83017a2eab5258eb Mon Sep 17 00:00:00 2001 From: Lei Xu Date: Fri, 14 Oct 2016 13:41:59 -0700 Subject: [PATCH] HDFS-10960. TestDataNodeHotSwapVolumes#testRemoveVolumeBeingWritten fails at disk error verification after volume remove. (Manoj Govindassamy via lei) --- .../datanode/TestDataNodeHotSwapVolumes.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeHotSwapVolumes.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeHotSwapVolumes.java index 06387c5968e..83c231d2332 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeHotSwapVolumes.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeHotSwapVolumes.java @@ -642,8 +642,6 @@ public class TestDataNodeHotSwapVolumes { final DataNode dn = cluster.getDataNodes().get(dataNodeIdx); final FileSystem fs = cluster.getFileSystem(); final Path testFile = new Path("/test"); - final long lastTimeDiskErrorCheck = dn.getLastDiskErrorCheck(); - FSDataOutputStream out = fs.create(testFile, REPLICATION); Random rb = new Random(0); @@ -699,17 +697,24 @@ public class TestDataNodeHotSwapVolumes { reconfigThread.join(); + // Verify if the data directory reconfigure was successful + FsDatasetSpi fsDatasetSpi = dn.getFSDataset(); + try (FsDatasetSpi.FsVolumeReferences fsVolumeReferences = fsDatasetSpi + .getFsVolumeReferences()) { + for (int i =0; i < fsVolumeReferences.size(); i++) { + System.out.println("Vol: " + + fsVolumeReferences.get(i).getBaseURI().toString()); + } + assertEquals("Volume remove wasn't successful.", + 1, fsVolumeReferences.size()); + } + // Verify the file has sufficient replications. DFSTestUtil.waitReplication(fs, testFile, REPLICATION); // Read the content back byte[] content = DFSTestUtil.readFileBuffer(fs, testFile); assertEquals(BLOCK_SIZE, content.length); - // If an IOException thrown from BlockReceiver#run, it triggers - // DataNode#checkDiskError(). So we can test whether checkDiskError() is called, - // to see whether there is IOException in BlockReceiver#run(). - assertEquals(lastTimeDiskErrorCheck, dn.getLastDiskErrorCheck()); - if (!exceptions.isEmpty()) { throw new IOException(exceptions.get(0).getCause()); }