Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.test.GenericTestUtils;

import static org.apache.hadoop.util.PlatformName.IBM_JAVA;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -341,8 +343,7 @@ public void testGetLocalPath() throws IOException {
Configuration conf = new Configuration();
String[] dirs = new String[]{"a", "b", "c"};
for (int i = 0; i < dirs.length; i++) {
dirs[i] = new Path(System.getProperty("test.build.data"), dirs[i])
.toString();
dirs[i] = new Path(GenericTestUtils.getTempPath(dirs[i])).toString();
}
conf.set("dirs", StringUtils.join(dirs, ","));
for (int i = 0; i < 1000; i++) {
Expand All @@ -358,8 +359,7 @@ public void testGetFile() throws IOException {
Configuration conf = new Configuration();
String[] dirs = new String[]{"a", "b", "c"};
for (int i = 0; i < dirs.length; i++) {
dirs[i] = new Path(System.getProperty("test.build.data"), dirs[i])
.toString();
dirs[i] = new Path(GenericTestUtils.getTempPath(dirs[i])).toString();
}
conf.set("dirs", StringUtils.join(dirs, ","));
for (int i = 0; i < 1000; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
Expand All @@ -38,8 +39,8 @@
import org.junit.Test;

public class TestCryptoStreamsForLocalFS extends CryptoStreamsTestBase {
private static final String TEST_ROOT_DIR
= System.getProperty("test.build.data","build/test/data") + "/work-dir/localfs";
private static final String TEST_ROOT_DIR =
GenericTestUtils.getTempPath("work-dir/testcryptostreamsforlocalfs");

private final File base = new File(TEST_ROOT_DIR);
private final Path file = new Path(TEST_ROOT_DIR, "test-file");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -47,8 +48,8 @@ public class TestKeyShell {
public void setup() throws Exception {
outContent.reset();
errContent.reset();
final File tmpDir = new File(System.getProperty("test.build.data", "target"),
UUID.randomUUID().toString());
final File tmpDir = GenericTestUtils.getTestDir(UUID.randomUUID()
.toString());
if (!tmpDir.mkdirs()) {
throw new IOException("Unable to create " + tmpDir);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.commons.lang.RandomStringUtils;
import org.apache.hadoop.fs.Options.CreateOpts;
import org.apache.hadoop.test.GenericTestUtils;

/**
* Abstraction of filesystem functionality with additional helper methods
Expand All @@ -43,7 +44,7 @@ public abstract class FSTestWrapper implements FSWrapper {
public FSTestWrapper(String testRootDir) {
// Use default test dir if not provided
if (testRootDir == null || testRootDir.isEmpty()) {
testRootDir = System.getProperty("test.build.data", "build/test/data");
testRootDir = GenericTestUtils.getTestDir().getAbsolutePath();
}
// salt test dir with some random digits for safe parallel runs
this.testRootDir = testRootDir + "/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.hadoop.fs.Options.CreateOpts;
import org.apache.hadoop.fs.Options.Rename;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.After;
import org.junit.Assert;
import static org.junit.Assert.*;
Expand Down Expand Up @@ -99,8 +100,7 @@ public boolean accept(Path file) {

@Before
public void setUp() throws Exception {
File testBuildData = new File(System.getProperty("test.build.data",
"build/test/data"), RandomStringUtils.randomAlphanumeric(10));
File testBuildData = GenericTestUtils.getRandomizedTestDir();
Path rootPath = new Path(testBuildData.getAbsolutePath(),
"root-uri");
localFsRootPath = rootPath.makeQualified(LocalFileSystem.NAME, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.hadoop.fs.Options.CreateOpts;
import org.apache.hadoop.fs.Options.CreateOpts.BlockSize;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.Assert;

/**
Expand All @@ -39,11 +40,10 @@ public final class FileContextTestHelper {
private String absTestRootDir = null;

/**
* Create a context with test root relative to the <wd>/build/test/data
* Create a context with test root relative to the test directory
*/
public FileContextTestHelper() {
this(System.getProperty("test.build.data", "target/test/data") + "/" +
RandomStringUtils.randomAlphanumeric(10));
this(GenericTestUtils.getRandomizedTestDir().getAbsolutePath());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.io.*;
import java.util.ArrayList;
import java.util.regex.Pattern;

import org.apache.hadoop.test.GenericTestUtils;
import org.junit.Assert;

import org.apache.hadoop.fs.permission.FsPermission;
Expand Down Expand Up @@ -51,8 +53,8 @@
* </p>
*/
public abstract class FileContextURIBase {
private static final String basePath = System.getProperty("test.build.data",
"build/test/data") + "/testContextURI";
private static final String basePath =
GenericTestUtils.getTempPath("testContextURI");
private static final Path BASE = new Path(basePath);

// Matches anything containing <, >, :, ", |, ?, *, or anything that ends with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import java.net.URI;
import java.util.Random;

import org.apache.commons.lang.RandomStringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.Assert;

import static org.junit.Assert.*;
Expand All @@ -45,7 +45,7 @@ public class FileSystemTestHelper {
* Create helper with test root located at <wd>/build/test/data
*/
public FileSystemTestHelper() {
this(System.getProperty("test.build.data", "target/test/data") + "/" + RandomStringUtils.randomAlphanumeric(10));
this(GenericTestUtils.getRandomizedTempPath());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.OutputStreamWriter;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;

import junit.framework.TestCase;

Expand All @@ -30,15 +31,9 @@ public class TestAvroFSInput extends TestCase {
private static final String INPUT_DIR = "AvroFSInput";

private Path getInputPath() {
String dataDir = System.getProperty("test.build.data");
if (null == dataDir) {
return new Path(INPUT_DIR);
} else {
return new Path(new Path(dataDir), INPUT_DIR);
}
return new Path(GenericTestUtils.getTempPath(INPUT_DIR));
}


public void testAFSInput() throws Exception {
Configuration conf = new Configuration();
FileSystem fs = FileSystem.getLocal(conf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
import org.apache.hadoop.fs.FSDataOutputStream;
import static org.apache.hadoop.fs.FileSystemTestHelper.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.*;
import static org.junit.Assert.*;

public class TestChecksumFileSystem {
static final String TEST_ROOT_DIR
= System.getProperty("test.build.data","build/test/data/work-dir/localfs");
static final String TEST_ROOT_DIR =
GenericTestUtils.getTempPath("work-dir/localfs");

static LocalFileSystem localFs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

public class TestDFVariations {
private static final String TEST_ROOT_DIR =
System.getProperty("test.build.data","build/test/data") + "/TestDFVariations";
GenericTestUtils.getTestDir("testdfvariations").getAbsolutePath();
private static File test_root = null;

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.test.GenericTestUtils;

/** This test makes sure that "DU" does not get to run on each call to getUsed */
public class TestDU extends TestCase {
final static private File DU_DIR = new File(
System.getProperty("test.build.data","/tmp"), "dutmp");
final static private File DU_DIR = GenericTestUtils.getTestDir("dutmp");

@Override
public void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Set;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -34,9 +35,10 @@ public class TestFileContextResolveAfs {
static{
FileSystem.enableSymlinks();
}
private static String TEST_ROOT_DIR_LOCAL
= System.getProperty("test.build.data","/tmp");


private static String TEST_ROOT_DIR_LOCAL =
GenericTestUtils.getTestDir().getAbsolutePath();

private FileContext fc;
private FileSystem localFs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.hadoop.fs;

import org.apache.hadoop.test.GenericTestUtils;
import org.junit.*;

import java.io.BufferedReader;
Expand Down Expand Up @@ -58,9 +59,7 @@
public class TestFileUtil {
private static final Log LOG = LogFactory.getLog(TestFileUtil.class);

private static final String TEST_ROOT_DIR = System.getProperty(
"test.build.data", "/tmp") + "/fu";
private static final File TEST_DIR = new File(TEST_ROOT_DIR);
private static final File TEST_DIR = GenericTestUtils.getTestDir("fu");
private static final String FILE = "x";
private static final String LINK = "y";
private static final String DIR = "dir";
Expand Down Expand Up @@ -1020,10 +1019,10 @@ private void doUntarAndVerify(File tarFile, File untarDir)
@Test (timeout = 30000)
public void testUntar() throws IOException {
String tarGzFileName = System.getProperty("test.cache.data",
"build/test/cache") + "/test-untar.tgz";
"target/test/cache") + "/test-untar.tgz";
String tarFileName = System.getProperty("test.cache.data",
"build/test/cache") + "/test-untar.tar";
String dataDir = System.getProperty("test.build.data", "build/test/data");
File dataDir = GenericTestUtils.getTestDir();
File untarDir = new File(dataDir, "untarDir");

doUntarAndVerify(new File(tarGzFileName), untarDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.StringUtils;
import org.junit.Before;
import org.junit.BeforeClass;
Expand All @@ -50,9 +51,8 @@ public static void setup() throws Exception {
conf = new Configuration();
shell = new FsShell(conf);
lfs = FileSystem.getLocal(conf);
testRootDir = lfs.makeQualified(new Path(
System.getProperty("test.build.data","test/build/data"),
"testFsShellCopy"));
testRootDir = lfs.makeQualified(new Path(GenericTestUtils.getTempPath(
"testFsShellCopy")));

lfs.mkdirs(testRootDir);
lfs.setWorkingDirectory(testRootDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import org.apache.hadoop.fs.shell.PathData;
import org.apache.hadoop.io.IOUtils;
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY;

import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.Shell;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -61,9 +63,9 @@ public static void setup() throws IOException {
fileSys = FileSystem.get(conf);
fsShell = new FsShell(conf);
}
private static String TEST_ROOT_DIR = System.getProperty("test.build.data",
"build/test/data/testCHReturnCode");

private static String TEST_ROOT_DIR =
GenericTestUtils.getTempPath("testCHReturnCode");

static void writeFile(FileSystem fs, Path name) throws Exception {
FSDataOutputStream stm = fs.create(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.StringUtils;
import org.junit.Before;
import org.junit.BeforeClass;
Expand All @@ -41,9 +42,8 @@ public static void setup() throws Exception {
Configuration conf = new Configuration();
shell = new FsShell(conf);
lfs = FileSystem.getLocal(conf);
testRootDir = lfs.makeQualified(new Path(
System.getProperty("test.build.data","test/build/data"),
"testFsShell"));
testRootDir = lfs.makeQualified(
new Path(GenericTestUtils.getTempPath("testFsShell")));

lfs.mkdirs(testRootDir);
lfs.setWorkingDirectory(testRootDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
import junit.framework.TestCase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;

/**
* Testing the correctness of FileSystem.getFileBlockLocations.
*/
public class TestGetFileBlockLocations extends TestCase {
private static String TEST_ROOT_DIR =
System.getProperty("test.build.data", "/tmp/testGetFileBlockLocations");
private static String TEST_ROOT_DIR = GenericTestUtils.getTempPath(
"testGetFileBlockLocations");
private static final int FileLength = 4 * 1024 * 1024; // 4MB
private Configuration conf;
private Path path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.Shell;
import org.junit.After;
import org.junit.Assert;
Expand All @@ -45,8 +46,8 @@
*/
public class TestHarFileSystemBasics {

private static final String ROOT_PATH = System.getProperty("test.build.data",
"build/test/data");
private static final String ROOT_PATH =
GenericTestUtils.getTempPath("testharfilesystembasics");
private static final Path rootPath;
static {
String root = new Path(new File(ROOT_PATH).getAbsolutePath(), "localfs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.IOException;
import java.util.Arrays;

import org.apache.hadoop.test.GenericTestUtils;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
Expand Down Expand Up @@ -57,9 +58,7 @@
*/
public class TestHardLink {

public static final String TEST_ROOT_DIR =
System.getProperty("test.build.data", "build/test/data") + "/test";
final static private File TEST_DIR = new File(TEST_ROOT_DIR, "hl");
final static private File TEST_DIR = GenericTestUtils.getTestDir("test/hl");
private static String DIR = "dir_";
//define source and target directories
private static File src = new File(TEST_DIR, DIR + "src");
Expand Down
Loading