HDFS-13296. GenericTestUtils generates paths with drive letter in Windows and fail webhdfs related test cases. Contributed by Xiao Liang.
(cherry picked from commit e65ff1c8be
)
This commit is contained in:
parent
a4f0dbcb44
commit
7eb0bdbd32
|
@ -44,6 +44,7 @@ import org.apache.commons.lang.RandomStringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.impl.Log4JLogger;
|
import org.apache.commons.logging.impl.Log4JLogger;
|
||||||
import org.apache.hadoop.fs.FileUtil;
|
import org.apache.hadoop.fs.FileUtil;
|
||||||
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.util.StringUtils;
|
import org.apache.hadoop.util.StringUtils;
|
||||||
import org.apache.hadoop.util.Time;
|
import org.apache.hadoop.util.Time;
|
||||||
import org.apache.log4j.Appender;
|
import org.apache.log4j.Appender;
|
||||||
|
@ -248,7 +249,7 @@ public abstract class GenericTestUtils {
|
||||||
* @return the absolute directory for tests. Caller is expected to create it.
|
* @return the absolute directory for tests. Caller is expected to create it.
|
||||||
*/
|
*/
|
||||||
public static File getRandomizedTestDir() {
|
public static File getRandomizedTestDir() {
|
||||||
return new File(getRandomizedTempPath()).getAbsoluteFile();
|
return new File(getRandomizedTempPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -259,7 +260,9 @@ public abstract class GenericTestUtils {
|
||||||
* @return a string to use in paths
|
* @return a string to use in paths
|
||||||
*/
|
*/
|
||||||
public static String getTempPath(String subpath) {
|
public static String getTempPath(String subpath) {
|
||||||
String prop = System.getProperty(SYSPROP_TEST_DATA_DIR, DEFAULT_TEST_DATA_PATH);
|
String prop = (Path.WINDOWS) ? DEFAULT_TEST_DATA_PATH
|
||||||
|
: System.getProperty(SYSPROP_TEST_DATA_DIR, DEFAULT_TEST_DATA_PATH);
|
||||||
|
|
||||||
if (prop.isEmpty()) {
|
if (prop.isEmpty()) {
|
||||||
// corner case: property is there but empty
|
// corner case: property is there but empty
|
||||||
prop = DEFAULT_TEST_DATA_PATH;
|
prop = DEFAULT_TEST_DATA_PATH;
|
||||||
|
|
Loading…
Reference in New Issue