This is an automated email from the ASF dual-hosted git repository.
smengcl pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new b152cadd75d HDFS-17927. Make TestDiskError.testShutdown use
deterministic volume failure injection (#8517)
b152cadd75d is described below
commit b152cadd75dda082bfd6f223d087c05ec34aa1a6
Author: Siyao Meng <[email protected]>
AuthorDate: Fri Jun 5 11:12:24 2026 -0700
HDFS-17927. Make TestDiskError.testShutdown use deterministic volume
failure injection (#8517)
---
.../hadoop/hdfs/server/datanode/TestDiskError.java | 54 +++++-----------------
1 file changed, 12 insertions(+), 42 deletions(-)
diff --git
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDiskError.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDiskError.java
index b602b396b14..c858d532119 100644
---
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDiskError.java
+++
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDiskError.java
@@ -17,9 +17,8 @@
*/
package org.apache.hadoop.hdfs.server.datanode;
+import static org.apache.hadoop.test.PlatformAssumptions.assumeNotWindows;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
import java.io.DataOutputStream;
import java.io.File;
@@ -28,12 +27,11 @@
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.concurrent.TimeUnit;
-
import java.util.function.Supplier;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.StorageType;
@@ -54,7 +52,6 @@
import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.DataChecksum;
-import org.apache.hadoop.util.Time;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -94,47 +91,20 @@ public void tearDown() throws Exception {
* Test to check that a DN goes down when all its volumes have failed.
*/
@Test
+ @Timeout(value = 60)
public void testShutdown() throws Exception {
- if (System.getProperty("os.name").startsWith("Windows")) {
- /**
- * This test depends on OS not allowing file creations on a directory
- * that does not have write permissions for the user. Apparently it is
- * not the case on Windows (at least under Cygwin), and possibly AIX.
- * This is disabled on Windows.
- */
- return;
- }
- // Bring up two more datanodes
- cluster.startDataNodes(conf, 2, true, null, null);
- cluster.waitActive();
+ assumeNotWindows();
final int dnIndex = 0;
- String bpid = cluster.getNamesystem().getBlockPoolId();
- File storageDir = cluster.getInstanceStorageDir(dnIndex, 0);
- File dir1 = MiniDFSCluster.getRbwDir(storageDir, bpid);
- storageDir = cluster.getInstanceStorageDir(dnIndex, 1);
- File dir2 = MiniDFSCluster.getRbwDir(storageDir, bpid);
+ final File dir1 = cluster.getInstanceStorageDir(dnIndex, 0);
+ final File dir2 = cluster.getInstanceStorageDir(dnIndex, 1);
+ final DataNode dn = cluster.getDataNodes().get(dnIndex);
try {
- // make the data directory of the first datanode to be readonly
- assertTrue(dir1.setReadOnly(), "Couldn't chmod local vol");
- assertTrue(dir2.setReadOnly(), "Couldn't chmod local vol");
-
- // create files and make sure that first datanode will be down
- DataNode dn = cluster.getDataNodes().get(dnIndex);
- long deadline = Time.monotonicNow() + 60000;
- for (int i=0; dn.isDatanodeUp(); i++) {
- if (Time.monotonicNow() > deadline) {
- fail("DataNode stayed UP for 60s despite Disk Errors.");
- }
- Path fileName = new Path("/test.txt"+i);
- DFSTestUtil.createFile(fs, fileName, 1024, (short)2, 1L);
- DFSTestUtil.waitReplication(fs, fileName, (short)2);
- fs.delete(fileName, true);
- Thread.sleep(200);
- }
+ DataNodeTestUtils.injectDataDirFailure(dir1, dir2);
+ dn.checkDiskError();
+ GenericTestUtils.waitFor(() -> !dn.isDatanodeUp(), 100, 30000,
+ "DataNode should exit when all volumes fail.");
} finally {
- // restore its old permission
- FileUtil.setWritable(dir1, true);
- FileUtil.setWritable(dir2, true);
+ DataNodeTestUtils.restoreDataDirFromFailure(dir1, dir2);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]