diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/DiskBalancerTestUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/DiskBalancerTestUtil.java index bd8dbce85b..fef9c631a0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/DiskBalancerTestUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/DiskBalancerTestUtil.java @@ -38,6 +38,7 @@ import org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerDataNode; import org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerVolume; import org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerVolumeSet; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Time; import org.slf4j.Logger; @@ -46,6 +47,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.io.File; import java.io.IOException; import java.util.Random; import java.util.UUID; @@ -307,7 +309,8 @@ public static MiniDFSCluster newImbalancedCluster( "need to specify capacities for two storages."); // Write a file and restart the cluster - MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) + File basedir = new File(GenericTestUtils.getRandomizedTempPath()); + MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf, basedir) .numDataNodes(numDatanodes) .storageCapacities(storageCapacities) .storageTypes(new StorageType[]{StorageType.DISK, StorageType.DISK}) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/command/TestDiskBalancerCommand.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/command/TestDiskBalancerCommand.java index 8266c1f5b1..dee2a905c8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/command/TestDiskBalancerCommand.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/command/TestDiskBalancerCommand.java @@ -615,15 +615,15 @@ public void testReportNodeWithoutJson() throws Exception { assertThat( outputs.get(3), is(allOf(containsString("DISK"), - containsString(cluster.getInstanceStorageDir(0, 0) - .getAbsolutePath()), + containsString(new Path(cluster.getInstanceStorageDir(0, 0) + .getAbsolutePath()).toString()), containsString("0.00"), containsString("1.00")))); assertThat( outputs.get(4), is(allOf(containsString("DISK"), - containsString(cluster.getInstanceStorageDir(0, 1) - .getAbsolutePath()), + containsString(new Path(cluster.getInstanceStorageDir(0, 1) + .getAbsolutePath()).toString()), containsString("0.00"), containsString("1.00")))); } @@ -719,9 +719,7 @@ public void testHelpCommand() throws Exception { @Test public void testPrintFullPathOfPlan() throws Exception { - final Path parent = new Path( - PathUtils.getTestPath(getClass()), - GenericTestUtils.getMethodName()); + String parent = GenericTestUtils.getRandomizedTempPath(); MiniDFSCluster miniCluster = null; try { @@ -815,7 +813,8 @@ public void testDiskBalancerQueryWithoutSubmit() throws Exception { Configuration conf = new HdfsConfiguration(); conf.setBoolean(DFSConfigKeys.DFS_DISK_BALANCER_ENABLED, true); final int numDatanodes = 2; - MiniDFSCluster miniDFSCluster = new MiniDFSCluster.Builder(conf) + File basedir = new File(GenericTestUtils.getRandomizedTempPath()); + MiniDFSCluster miniDFSCluster = new MiniDFSCluster.Builder(conf, basedir) .numDataNodes(numDatanodes).build(); try { miniDFSCluster.waitActive();