HDFS-13629. Some tests in TestDiskBalancerCommand fail on Windows due to MiniDFSCluster path conflict and improper path usage. Contributed by Anbang Hu.

This commit is contained in:
Inigo Goiri 2018-05-30 10:22:04 -07:00
parent 8197b9b560
commit 47c31ff16b
2 changed files with 11 additions and 9 deletions

View File

@ -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})

View File

@ -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();