You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by jl...@apache.org on 2013/06/04 02:29:38 UTC
svn commit: r1489250 [1/2] - in
/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common: ./
src/test/java/org/apache/hadoop/conf/ src/test/java/org/apache/hadoop/fs/
src/test/java/org/apache/hadoop/fs/shell/ src/test/java/org/apache/hadoop...
Author: jlowe
Date: Tue Jun 4 00:29:37 2013
New Revision: 1489250
URL: http://svn.apache.org/r1489250
Log:
HADOOP-9287. Parallel-testing hadoop-common. Contributed by Andrey Klochkov
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/pom.xml
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationDeprecation.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FCStatisticsBaseTest.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSMainOperationsBaseTest.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextCreateMkdirBaseTest.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextPermissionBase.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextSymlinkBaseTest.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextUtilBase.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFSMainOperationsLocalFileSystem.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFcLocalFsPermission.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextSymlink.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFsFCStatistics.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsTestSetup.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSerialization.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileJClassComparatorByteArrays.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileLzoCodecsByteArrays.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileLzoCodecsStreams.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsByteArrays.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsJClassComparatorByteArrays.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsStreams.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileStreams.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt Tue Jun 4 00:29:37 2013
@@ -95,6 +95,8 @@ Release 2.1.0-beta - UNRELEASED
HADOOP-7391 Document Interface Classification from HADOOP-5073 (sanjay Radia)
+ HADOOP-9287. Parallel-testing hadoop-common (Andrey Klochkov via jlowe)
+
OPTIMIZATIONS
HADOOP-9150. Avoid unnecessary DNS resolution attempts for logical URIs
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/pom.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/pom.xml?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/pom.xml (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/pom.xml Tue Jun 4 00:29:37 2013
@@ -653,5 +653,22 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>parallel-tests</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>perthread</forkMode>
+ <threadCount>${testsThreadCount}</threadCount>
+ <parallel>classes</parallel>
+ <argLine>-Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -DminiClusterDedicatedDirs=true</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java Tue Jun 4 00:29:37 2013
@@ -39,6 +39,7 @@ import java.util.regex.Pattern;
import junit.framework.TestCase;
import static org.junit.Assert.assertArrayEquals;
+
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration.IntegerRanges;
import org.apache.hadoop.fs.Path;
@@ -49,8 +50,8 @@ import org.codehaus.jackson.map.ObjectMa
public class TestConfiguration extends TestCase {
private Configuration conf;
- final static String CONFIG = new File("./test-config.xml").getAbsolutePath();
- final static String CONFIG2 = new File("./test-config2.xml").getAbsolutePath();
+ final static String CONFIG = new File("./test-config-TestConfiguration.xml").getAbsolutePath();
+ final static String CONFIG2 = new File("./test-config2-TestConfiguration.xml").getAbsolutePath();
final static Random RAN = new Random();
final static String XMLHEADER =
IBM_JAVA?"<?xml version=\"1.0\" encoding=\"UTF-8\"?><configuration>":
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationDeprecation.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationDeprecation.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationDeprecation.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationDeprecation.java Tue Jun 4 00:29:37 2013
@@ -36,11 +36,9 @@ import org.junit.Test;
public class TestConfigurationDeprecation {
private Configuration conf;
- final static String CONFIG = new File("./test-config.xml").getAbsolutePath();
- final static String CONFIG2 =
- new File("./test-config2.xml").getAbsolutePath();
- final static String CONFIG3 =
- new File("./test-config3.xml").getAbsolutePath();
+ final static String CONFIG = new File("./test-config-TestConfigurationDeprecation.xml").getAbsolutePath();
+ final static String CONFIG2 = new File("./test-config2-TestConfigurationDeprecation.xml").getAbsolutePath();
+ final static String CONFIG3 = new File("./test-config3-TestConfigurationDeprecation.xml").getAbsolutePath();
BufferedWriter out;
static {
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FCStatisticsBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FCStatisticsBaseTest.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FCStatisticsBaseTest.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FCStatisticsBaseTest.java Tue Jun 4 00:29:37 2013
@@ -39,6 +39,8 @@ public abstract class FCStatisticsBaseTe
static protected int blockSize = 512;
static protected int numBlocks = 1;
+ protected final FileContextTestHelper fileContextTestHelper = new FileContextTestHelper();
+
//fc should be set appropriately by the deriving test.
protected static FileContext fc = null;
@@ -47,7 +49,7 @@ public abstract class FCStatisticsBaseTe
URI fsUri = getFsUri();
Statistics stats = FileContext.getStatistics(fsUri);
Assert.assertEquals(0, stats.getBytesRead());
- Path filePath = getTestRootPath(fc, "file1");
+ Path filePath = fileContextTestHelper .getTestRootPath(fc, "file1");
createFile(fc, filePath, numBlocks, blockSize);
Assert.assertEquals(0, stats.getBytesRead());
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSMainOperationsBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSMainOperationsBaseTest.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSMainOperationsBaseTest.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSMainOperationsBaseTest.java Tue Jun 4 00:29:37 2013
@@ -34,8 +34,6 @@ import org.junit.Before;
import org.junit.Test;
import org.mortbay.log.Log;
-import static org.apache.hadoop.fs.FileSystemTestHelper.*;
-
/**
* <p>
* A collection of tests for the {@link FileSystem}.
@@ -55,7 +53,7 @@ import static org.apache.hadoop.fs.FileS
* @AfterClass public static void ClusterShutdownAtEnd()
* </p>
*/
-public abstract class FSMainOperationsBaseTest {
+public abstract class FSMainOperationsBaseTest extends FileSystemTestHelper {
private static String TEST_DIR_AAA2 = "test/hadoop2/aaa";
private static String TEST_DIR_AAA = "test/hadoop/aaa";
@@ -63,8 +61,8 @@ public abstract class FSMainOperationsBa
private static String TEST_DIR_AXX = "test/hadoop/axx";
private static int numBlocks = 2;
-
- protected static FileSystem fSys;
+
+ protected FileSystem fSys;
final private static PathFilter DEFAULT_FILTER = new PathFilter() {
@Override
@@ -87,8 +85,18 @@ public abstract class FSMainOperationsBa
protected static final byte[] data = getFileData(numBlocks,
getDefaultBlockSize());
+ abstract protected FileSystem createFileSystem() throws Exception;
+
+ public FSMainOperationsBaseTest() {
+ }
+
+ public FSMainOperationsBaseTest(String testRootDir) {
+ super(testRootDir);
+ }
+
@Before
public void setUp() throws Exception {
+ fSys = createFileSystem();
fSys.mkdirs(getTestRootPath(fSys, "test"));
}
@@ -157,7 +165,7 @@ public abstract class FSMainOperationsBa
// Now open a file relative to the wd we just set above.
Path absolutePath = new Path(absoluteDir, "foo");
- FileSystemTestHelper.createFile(fSys, absolutePath);
+ createFile(fSys, absolutePath);
fSys.open(new Path("foo")).close();
@@ -308,11 +316,11 @@ public abstract class FSMainOperationsBa
paths = fSys.listStatus(getTestRootPath(fSys, "test/hadoop"));
Assert.assertEquals(3, paths.length);
- Assert.assertTrue(containsPath(getTestRootPath(fSys, "test/hadoop/a"),
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, "test/hadoop/a"),
paths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys, "test/hadoop/b"),
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, "test/hadoop/b"),
paths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys, "test/hadoop/c"),
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, "test/hadoop/c"),
paths));
paths = fSys.listStatus(getTestRootPath(fSys, "test/hadoop/a"));
@@ -359,9 +367,9 @@ public abstract class FSMainOperationsBa
FileStatus[] filteredPaths = fSys.listStatus(
getTestRootPath(fSys, "test/hadoop"), TEST_X_FILTER);
Assert.assertEquals(2,filteredPaths.length);
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
TEST_DIR_AXA), filteredPaths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
TEST_DIR_AXX), filteredPaths));
}
@@ -417,9 +425,9 @@ public abstract class FSMainOperationsBa
FileStatus[] paths = fSys.globStatus(
getTestRootPath(fSys, "test/hadoop*"));
Assert.assertEquals(2, paths.length);
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
"test/hadoop"), paths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
"test/hadoop2"), paths));
}
@@ -442,10 +450,10 @@ public abstract class FSMainOperationsBa
FileStatus[] paths = fSys.globStatus(
getTestRootPath(fSys, "test/hadoop*/*"));
Assert.assertEquals(4, paths.length);
- Assert.assertTrue(containsPath(getTestRootPath(fSys, TEST_DIR_AAA), paths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys, TEST_DIR_AXA), paths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys, TEST_DIR_AXX), paths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys, TEST_DIR_AAA2), paths));
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, TEST_DIR_AAA), paths));
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, TEST_DIR_AXA), paths));
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, TEST_DIR_AXX), paths));
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, TEST_DIR_AAA2), paths));
}
@Test
@@ -466,9 +474,9 @@ public abstract class FSMainOperationsBa
FileStatus[] paths = fSys.globStatus(
getTestRootPath(fSys, "test/hadoop/ax?"));
Assert.assertEquals(2, paths.length);
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
TEST_DIR_AXA), paths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
TEST_DIR_AXX), paths));
}
@@ -513,11 +521,11 @@ public abstract class FSMainOperationsBa
getTestRootPath(fSys, "test/hadoop/*"),
DEFAULT_FILTER);
Assert.assertEquals(3, filteredPaths.length);
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
TEST_DIR_AAA), filteredPaths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
TEST_DIR_AXA), filteredPaths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
TEST_DIR_AXX), filteredPaths));
}
@@ -541,11 +549,11 @@ public abstract class FSMainOperationsBa
getTestRootPath(fSys, "test/hadoop/a??"),
DEFAULT_FILTER);
Assert.assertEquals(3, filteredPaths.length);
- Assert.assertTrue(containsPath(getTestRootPath(fSys, TEST_DIR_AAA),
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, TEST_DIR_AAA),
filteredPaths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys, TEST_DIR_AXA),
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, TEST_DIR_AXA),
filteredPaths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys, TEST_DIR_AXX),
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, TEST_DIR_AXX),
filteredPaths));
}
@@ -569,9 +577,9 @@ public abstract class FSMainOperationsBa
getTestRootPath(fSys, "test/hadoop/*"),
TEST_X_FILTER);
Assert.assertEquals(2, filteredPaths.length);
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
TEST_DIR_AXA), filteredPaths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys,
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys,
TEST_DIR_AXX), filteredPaths));
}
@@ -617,9 +625,9 @@ public abstract class FSMainOperationsBa
getTestRootPath(fSys, "test/hadoop/a??"),
TEST_X_FILTER);
Assert.assertEquals(2, filteredPaths.length);
- Assert.assertTrue(containsPath(getTestRootPath(fSys, TEST_DIR_AXA),
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, TEST_DIR_AXA),
filteredPaths));
- Assert.assertTrue(containsPath(getTestRootPath(fSys, TEST_DIR_AXX),
+ Assert.assertTrue(containsTestRootPath(getTestRootPath(fSys, TEST_DIR_AXX),
filteredPaths));
}
@@ -1090,9 +1098,9 @@ public abstract class FSMainOperationsBa
public void testCopyToLocalWithUseRawLocalFileSystemOption() throws Exception {
Configuration conf = new Configuration();
FileSystem fSys = new RawLocalFileSystem();
- Path fileToFS = new Path(TEST_ROOT_DIR, "fs.txt");
- Path fileToLFS = new Path(TEST_ROOT_DIR, "test.txt");
- Path crcFileAtLFS = new Path(TEST_ROOT_DIR, ".test.txt.crc");
+ Path fileToFS = new Path(getTestRootDir(), "fs.txt");
+ Path fileToLFS = new Path(getTestRootDir(), "test.txt");
+ Path crcFileAtLFS = new Path(getTestRootDir(), ".test.txt.crc");
fSys.initialize(new URI("file:///"), conf);
writeFile(fSys, fileToFS);
if (fSys.exists(crcFileAtLFS))
@@ -1112,7 +1120,7 @@ public abstract class FSMainOperationsBa
}
protected void createFile(Path path) throws IOException {
- FileSystemTestHelper.createFile(fSys, path);
+ createFile(fSys, path);
}
@SuppressWarnings("deprecation")
@@ -1125,10 +1133,11 @@ public abstract class FSMainOperationsBa
Assert.assertEquals("Source exists", srcExists, exists(fSys, src));
Assert.assertEquals("Destination exists", dstExists, exists(fSys, dst));
}
- private boolean containsPath(Path path, FileStatus[] filteredPaths)
+ private boolean containsTestRootPath(Path path, FileStatus[] filteredPaths)
throws IOException {
+ Path testRootPath = getTestRootPath(fSys, path.toString());
for(int i = 0; i < filteredPaths.length; i ++) {
- if (getTestRootPath(fSys, path.toString()).equals(
+ if (testRootPath.equals(
filteredPaths[i].getPath()))
return true;
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextCreateMkdirBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextCreateMkdirBaseTest.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextCreateMkdirBaseTest.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextCreateMkdirBaseTest.java Tue Jun 4 00:29:37 2013
@@ -50,7 +50,8 @@ import org.apache.commons.logging.impl.L
*/
public abstract class FileContextCreateMkdirBaseTest {
-
+
+ protected final FileContextTestHelper fileContextTestHelper;
protected static FileContext fc;
{
@@ -63,6 +64,13 @@ public abstract class FileContextCreateM
}
}
+ public FileContextCreateMkdirBaseTest() {
+ fileContextTestHelper = createFileContextHelper();
+ }
+
+ protected FileContextTestHelper createFileContextHelper() {
+ return new FileContextTestHelper();
+ }
@Before
public void setUp() throws Exception {
@@ -149,4 +157,13 @@ public abstract class FileContextCreateM
createFile(fc, f);
Assert.assertTrue(isFile(fc, f));
}
+
+ private Path getTestRootPath(FileContext fc) {
+ return fileContextTestHelper.getTestRootPath(fc);
+ }
+
+ private Path getTestRootPath(FileContext fc, String pathString) {
+ return fileContextTestHelper.getTestRootPath(fc, pathString);
+ }
+
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java Tue Jun 4 00:29:37 2013
@@ -23,6 +23,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.EnumSet;
+import org.apache.commons.lang.RandomStringUtils;
import org.apache.hadoop.HadoopIllegalArgumentException;
import org.apache.hadoop.fs.Options.CreateOpts;
import org.apache.hadoop.fs.Options.Rename;
@@ -61,17 +62,10 @@ public abstract class FileContextMainOpe
private static String TEST_DIR_AXA = "test/hadoop/axa";
private static String TEST_DIR_AXX = "test/hadoop/axx";
private static int numBlocks = 2;
-
- public static final Path LOCAL_FS_ROOT_PATH;
-
- static {
- File testBuildData = new File(System.getProperty("test.build.data",
- "build/test/data"));
- Path localFsRootPath = new Path(testBuildData.getAbsolutePath(),
- "root-uri");
- LOCAL_FS_ROOT_PATH = localFsRootPath.makeQualified(LocalFileSystem.NAME, null);
- }
-
+
+ public Path localFsRootPath;
+
+ protected final FileContextTestHelper fileContextTestHelper = new FileContextTestHelper();
protected static FileContext fc;
final private static PathFilter DEFAULT_FILTER = new PathFilter() {
@@ -97,13 +91,18 @@ public abstract class FileContextMainOpe
@Before
public void setUp() throws Exception {
+ File testBuildData = new File(System.getProperty("test.build.data",
+ "build/test/data"), RandomStringUtils.randomAlphanumeric(10));
+ Path rootPath = new Path(testBuildData.getAbsolutePath(),
+ "root-uri");
+ localFsRootPath = rootPath.makeQualified(LocalFileSystem.NAME, null);
fc.mkdir(getTestRootPath(fc, "test"), FileContext.DEFAULT_PERM, true);
}
@After
public void tearDown() throws Exception {
- fc.delete(new Path(getAbsoluteTestRootPath(fc), new Path("test")), true);
- fc.delete(LOCAL_FS_ROOT_PATH, true);
+ fc.delete(new Path(fileContextTestHelper.getAbsoluteTestRootPath(fc), new Path("test")), true);
+ fc.delete(localFsRootPath, true);
}
@@ -136,7 +135,7 @@ public abstract class FileContextMainOpe
public void testWorkingDirectory() throws Exception {
// First we cd to our test root
- Path workDir = new Path(getAbsoluteTestRootPath(fc), new Path("test"));
+ Path workDir = new Path(fileContextTestHelper.getAbsoluteTestRootPath(fc), new Path("test"));
fc.setWorkingDirectory(workDir);
Assert.assertEquals(workDir, fc.getWorkingDirectory());
@@ -149,7 +148,7 @@ public abstract class FileContextMainOpe
// cd using a relative path
// Go back to our test root
- workDir = new Path(getAbsoluteTestRootPath(fc), new Path("test"));
+ workDir = new Path(fileContextTestHelper.getAbsoluteTestRootPath(fc), new Path("test"));
fc.setWorkingDirectory(workDir);
Assert.assertEquals(workDir, fc.getWorkingDirectory());
@@ -184,7 +183,7 @@ public abstract class FileContextMainOpe
// Try a URI
- absoluteDir = new Path(LOCAL_FS_ROOT_PATH, "existingDir");
+ absoluteDir = new Path(localFsRootPath, "existingDir");
fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
fc.setWorkingDirectory(absoluteDir);
Assert.assertEquals(absoluteDir, fc.getWorkingDirectory());
@@ -1181,6 +1180,7 @@ public abstract class FileContextMainOpe
Assert.assertEquals("Source exists", srcExists, exists(fc, src));
Assert.assertEquals("Destination exists", dstExists, exists(fc, dst));
}
+
private boolean containsPath(Path path, FileStatus[] filteredPaths)
throws IOException {
for(int i = 0; i < filteredPaths.length; i ++) {
@@ -1189,5 +1189,9 @@ public abstract class FileContextMainOpe
return true;
}
return false;
- }
+ }
+
+ private Path getTestRootPath(FileContext fc, String pathString) {
+ return fileContextTestHelper.getTestRootPath(fc, pathString);
+ }
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextPermissionBase.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextPermissionBase.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextPermissionBase.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextPermissionBase.java Tue Jun 4 00:29:37 2013
@@ -68,16 +68,25 @@ public abstract class FileContextPermiss
}
}
- protected static FileContext fc;
+ protected FileContextTestHelper fileContextTestHelper;
+ protected FileContext fc;
+ protected FileContextTestHelper getFileContextHelper() {
+ return new FileContextTestHelper();
+ }
+
+ protected abstract FileContext getFileContext() throws Exception;
+
@Before
public void setUp() throws Exception {
- fc.mkdir(getTestRootPath(fc), FileContext.DEFAULT_PERM, true);
+ fileContextTestHelper = getFileContextHelper();
+ fc = getFileContext();
+ fc.mkdir(fileContextTestHelper.getTestRootPath(fc), FileContext.DEFAULT_PERM, true);
}
@After
public void tearDown() throws Exception {
- fc.delete(getTestRootPath(fc), true);
+ fc.delete(fileContextTestHelper.getTestRootPath(fc), true);
}
private void cleanupFile(FileContext fc, Path name) throws IOException {
@@ -93,8 +102,8 @@ public abstract class FileContextPermiss
return;
}
String filename = "foo";
- Path f = getTestRootPath(fc, filename);
- createFile(fc, filename);
+ Path f = fileContextTestHelper.getTestRootPath(fc, filename);
+ fileContextTestHelper.createFile(fc, filename);
doFilePermissionCheck(FileContext.FILE_DEFAULT_PERM.applyUMask(fc.getUMask()),
fc.getFileStatus(f).getPermission());
}
@@ -108,7 +117,7 @@ public abstract class FileContextPermiss
}
String filename = "foo";
- Path f = getTestRootPath(fc, filename);
+ Path f = fileContextTestHelper.getTestRootPath(fc, filename);
createFile(fc, f);
try {
@@ -133,7 +142,7 @@ public abstract class FileContextPermiss
}
String filename = "bar";
- Path f = getTestRootPath(fc, filename);
+ Path f = fileContextTestHelper.getTestRootPath(fc, filename);
createFile(fc, f);
List<String> groups = null;
try {
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextSymlinkBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextSymlinkBaseTest.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextSymlinkBaseTest.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextSymlinkBaseTest.java Tue Jun 4 00:29:37 2013
@@ -43,6 +43,7 @@ public abstract class FileContextSymlink
static final int blockSize = 8192;
static final int fileSize = 16384;
+ protected final FileContextTestHelper fileContextTestHelper = new FileContextTestHelper();
protected static FileContext fc;
abstract protected String getScheme();
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java Tue Jun 4 00:29:37 2013
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.FileNotFoundException;
import java.util.EnumSet;
+import org.apache.commons.lang.RandomStringUtils;
import org.apache.hadoop.fs.Options.CreateOpts;
import org.apache.hadoop.fs.Options.CreateOpts.BlockSize;
import org.apache.hadoop.io.IOUtils;
@@ -31,15 +32,18 @@ import org.junit.Assert;
* Helper class for unit tests.
*/
public final class FileContextTestHelper {
- // The test root is relative to the <wd>/build/test/data by default
- public static final String TEST_ROOT_DIR =
- System.getProperty("test.build.data", "build/test/data") + "/test";
private static final int DEFAULT_BLOCK_SIZE = 1024;
private static final int DEFAULT_NUM_BLOCKS = 2;
- private static String absTestRootDir = null;
- /** Hidden constructor */
- private FileContextTestHelper() {}
+ private final String testRootDir;
+ private String absTestRootDir = null;
+
+ /**
+ * Create a context with test root relative to the <wd>/build/test/data
+ */
+ public FileContextTestHelper() {
+ testRootDir = System.getProperty("test.build.data", "target/test/data") + "/" + RandomStringUtils.randomAlphanumeric(10);
+ }
public static int getDefaultBlockSize() {
return DEFAULT_BLOCK_SIZE;
@@ -53,36 +57,36 @@ public final class FileContextTestHelper
return data;
}
- public static Path getTestRootPath(FileContext fc) {
- return fc.makeQualified(new Path(TEST_ROOT_DIR));
+ public Path getTestRootPath(FileContext fc) {
+ return fc.makeQualified(new Path(testRootDir));
}
- public static Path getTestRootPath(FileContext fc, String pathString) {
- return fc.makeQualified(new Path(TEST_ROOT_DIR, pathString));
+ public Path getTestRootPath(FileContext fc, String pathString) {
+ return fc.makeQualified(new Path(testRootDir, pathString));
}
// the getAbsolutexxx method is needed because the root test dir
// can be messed up by changing the working dir.
- public static String getAbsoluteTestRootDir(FileContext fc)
+ public String getAbsoluteTestRootDir(FileContext fc)
throws IOException {
if (absTestRootDir == null) {
- if (new Path(TEST_ROOT_DIR).isAbsolute()) {
- absTestRootDir = TEST_ROOT_DIR;
+ if (new Path(testRootDir).isAbsolute()) {
+ absTestRootDir = testRootDir;
} else {
absTestRootDir = fc.getWorkingDirectory().toString() + "/"
- + TEST_ROOT_DIR;
+ + testRootDir;
}
}
return absTestRootDir;
}
- public static Path getAbsoluteTestRootPath(FileContext fc) throws IOException {
+ public Path getAbsoluteTestRootPath(FileContext fc) throws IOException {
return fc.makeQualified(new Path(getAbsoluteTestRootDir(fc)));
}
- public static Path getDefaultWorkingDirectory(FileContext fc)
+ public Path getDefaultWorkingDirectory(FileContext fc)
throws IOException {
return getTestRootPath(fc, "/user/" + System.getProperty("user.name"))
.makeQualified(fc.getDefaultFileSystem().getUri(),
@@ -116,12 +120,12 @@ public final class FileContextTestHelper
return createFile(fc, path, DEFAULT_NUM_BLOCKS, CreateOpts.createParent());
}
- public static long createFile(FileContext fc, String name) throws IOException {
+ public long createFile(FileContext fc, String name) throws IOException {
Path path = getTestRootPath(fc, name);
return createFile(fc, path);
}
- public static long createFileNonRecursive(FileContext fc, String name)
+ public long createFileNonRecursive(FileContext fc, String name)
throws IOException {
Path path = getTestRootPath(fc, name);
return createFileNonRecursive(fc, path);
@@ -190,7 +194,7 @@ public final class FileContextTestHelper
return buffer;
}
- public static FileStatus containsPath(FileContext fc, Path path,
+ public FileStatus containsPath(FileContext fc, Path path,
FileStatus[] dirList)
throws IOException {
return containsPath(getTestRootPath(fc, path.toString()), dirList);
@@ -206,7 +210,7 @@ public final class FileContextTestHelper
return null;
}
- public static FileStatus containsPath(FileContext fc, String path,
+ public FileStatus containsPath(FileContext fc, String path,
FileStatus[] dirList)
throws IOException {
return containsPath(fc, new Path(path), dirList);
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextUtilBase.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextUtilBase.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextUtilBase.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextUtilBase.java Tue Jun 4 00:29:37 2013
@@ -17,7 +17,6 @@
*/
package org.apache.hadoop.fs;
-import static org.apache.hadoop.fs.FileContextTestHelper.getTestRootPath;
import static org.apache.hadoop.fs.FileContextTestHelper.readFile;
import static org.apache.hadoop.fs.FileContextTestHelper.writeFile;
import static org.junit.Assert.assertTrue;
@@ -44,6 +43,7 @@ import org.junit.Test;
* </p>
*/
public abstract class FileContextUtilBase {
+ protected final FileContextTestHelper fileContextTestHelper = new FileContextTestHelper();
protected FileContext fc;
{
@@ -58,19 +58,19 @@ public abstract class FileContextUtilBas
@Before
public void setUp() throws Exception {
- fc.mkdir(getTestRootPath(fc), FileContext.DEFAULT_PERM, true);
+ fc.mkdir(fileContextTestHelper.getTestRootPath(fc), FileContext.DEFAULT_PERM, true);
}
@After
public void tearDown() throws Exception {
- fc.delete(getTestRootPath(fc), true);
+ fc.delete(fileContextTestHelper.getTestRootPath(fc), true);
}
@Test
public void testFcCopy() throws Exception{
final String ts = "some random text";
- Path file1 = getTestRootPath(fc, "file1");
- Path file2 = getTestRootPath(fc, "file2");
+ Path file1 = fileContextTestHelper.getTestRootPath(fc, "file1");
+ Path file2 = fileContextTestHelper.getTestRootPath(fc, "file2");
writeFile(fc, file1, ts.getBytes());
assertTrue(fc.util().exists(file1));
@@ -87,8 +87,8 @@ public abstract class FileContextUtilBas
public void testRecursiveFcCopy() throws Exception {
final String ts = "some random text";
- Path dir1 = getTestRootPath(fc, "dir1");
- Path dir2 = getTestRootPath(fc, "dir2");
+ Path dir1 = fileContextTestHelper.getTestRootPath(fc, "dir1");
+ Path dir2 = fileContextTestHelper.getTestRootPath(fc, "dir2");
Path file1 = new Path(dir1, "file1");
fc.mkdir(dir1, null, false);
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java Tue Jun 4 00:29:37 2013
@@ -23,27 +23,39 @@ 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.junit.Assert;
+
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
/**
* Helper class for unit tests.
*/
-public final class FileSystemTestHelper {
- // The test root is relative to the <wd>/build/test/data by default
- public static final String TEST_ROOT_DIR =
- System.getProperty("test.build.data", "target/test/data") + "/test";
+public class FileSystemTestHelper {
private static final int DEFAULT_BLOCK_SIZE = 1024;
private static final int DEFAULT_NUM_BLOCKS = 2;
private static final short DEFAULT_NUM_REPL = 1;
- private static String absTestRootDir = null;
- /** Hidden constructor */
- private FileSystemTestHelper() {}
-
+ protected final String testRootDir;
+ private String absTestRootDir = null;
+
+ /**
+ * 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));
+ }
+
+ /**
+ * Create helper with the specified test root dir
+ */
+ public FileSystemTestHelper(String testRootDir) {
+ this.testRootDir = testRootDir;
+ }
+
public static void addFileSystemForTesting(URI uri, Configuration conf,
FileSystem fs) throws IOException {
FileSystem.addFileSystemForTesting(uri, conf, fs);
@@ -61,19 +73,22 @@ public final class FileSystemTestHelper
return data;
}
+ public String getTestRootDir() {
+ return testRootDir;
+ }
/*
* get testRootPath qualified for fSys
*/
- public static Path getTestRootPath(FileSystem fSys) {
- return fSys.makeQualified(new Path(TEST_ROOT_DIR));
+ public Path getTestRootPath(FileSystem fSys) {
+ return fSys.makeQualified(new Path(testRootDir));
}
/*
* get testRootPath + pathString qualified for fSys
*/
- public static Path getTestRootPath(FileSystem fSys, String pathString) {
- return fSys.makeQualified(new Path(TEST_ROOT_DIR, pathString));
+ public Path getTestRootPath(FileSystem fSys, String pathString) {
+ return fSys.makeQualified(new Path(testRootDir, pathString));
}
@@ -82,25 +97,25 @@ public final class FileSystemTestHelper
// is often relative to the working directory of process
// running the unit tests.
- static String getAbsoluteTestRootDir(FileSystem fSys)
+ String getAbsoluteTestRootDir(FileSystem fSys)
throws IOException {
// NOTE: can't cache because of different filesystems!
//if (absTestRootDir == null)
- if (new Path(TEST_ROOT_DIR).isAbsolute()) {
- absTestRootDir = TEST_ROOT_DIR;
+ if (new Path(testRootDir).isAbsolute()) {
+ absTestRootDir = testRootDir;
} else {
absTestRootDir = fSys.getWorkingDirectory().toString() + "/"
- + TEST_ROOT_DIR;
+ + testRootDir;
}
//}
return absTestRootDir;
}
- public static Path getAbsoluteTestRootPath(FileSystem fSys) throws IOException {
+ public Path getAbsoluteTestRootPath(FileSystem fSys) throws IOException {
return fSys.makeQualified(new Path(getAbsoluteTestRootDir(fSys)));
}
- public static Path getDefaultWorkingDirectory(FileSystem fSys)
+ public Path getDefaultWorkingDirectory(FileSystem fSys)
throws IOException {
return getTestRootPath(fSys, "/user/" + System.getProperty("user.name"))
.makeQualified(fSys.getUri(),
@@ -136,7 +151,7 @@ public final class FileSystemTestHelper
return createFile(fSys, path, DEFAULT_NUM_BLOCKS, DEFAULT_BLOCK_SIZE, DEFAULT_NUM_REPL, true);
}
- public static long createFile(FileSystem fSys, String name) throws IOException {
+ public long createFile(FileSystem fSys, String name) throws IOException {
Path path = getTestRootPath(fSys, name);
return createFile(fSys, path);
}
@@ -188,7 +203,7 @@ public final class FileSystemTestHelper
return s;
}
- public static FileStatus containsPath(FileSystem fSys, Path path,
+ public FileStatus containsPath(FileSystem fSys, Path path,
FileStatus[] dirList)
throws IOException {
for(int i = 0; i < dirList.length; i ++) {
@@ -210,7 +225,7 @@ public final class FileSystemTestHelper
}
- public static FileStatus containsPath(FileSystem fSys, String path, FileStatus[] dirList)
+ public FileStatus containsPath(FileSystem fSys, String path, FileStatus[] dirList)
throws IOException {
return containsPath(fSys, new Path(path), dirList);
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFSMainOperationsLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFSMainOperationsLocalFileSystem.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFSMainOperationsLocalFileSystem.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFSMainOperationsLocalFileSystem.java Tue Jun 4 00:29:37 2013
@@ -29,9 +29,13 @@ import org.junit.Test;
public class TestFSMainOperationsLocalFileSystem extends FSMainOperationsBaseTest {
@Override
+ protected FileSystem createFileSystem() throws IOException {
+ return FileSystem.getLocal(new Configuration());
+ }
+
+ @Override
@Before
public void setUp() throws Exception {
- fSys = FileSystem.getLocal(new Configuration());
super.setUp();
}
@@ -52,8 +56,7 @@ public class TestFSMainOperationsLocalFi
@Test
@Override
public void testWDAbsolute() throws IOException {
- Path absoluteDir = FileSystemTestHelper.getTestRootPath(fSys,
- "test/existingDir");
+ Path absoluteDir = getTestRootPath(fSys, "test/existingDir");
fSys.mkdirs(absoluteDir);
fSys.setWorkingDirectory(absoluteDir);
Assert.assertEquals(absoluteDir, fSys.getWorkingDirectory());
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFcLocalFsPermission.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFcLocalFsPermission.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFcLocalFsPermission.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFcLocalFsPermission.java Tue Jun 4 00:29:37 2013
@@ -29,7 +29,6 @@ public class TestFcLocalFsPermission ext
@Override
@Before
public void setUp() throws Exception {
- fc = FileContext.getLocalFSFileContext();
super.setUp();
}
@@ -39,4 +38,9 @@ public class TestFcLocalFsPermission ext
super.tearDown();
}
+ @Override
+ protected FileContext getFileContext() throws UnsupportedFileSystemException {
+ return FileContext.getLocalFSFileContext();
+ }
+
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java Tue Jun 4 00:29:37 2013
@@ -35,6 +35,7 @@ public class TestFileContextDeleteOnExit
private static int blockSize = 1024;
private static int numBlocks = 2;
+ private final FileContextTestHelper helper = new FileContextTestHelper();
private FileContext fc;
@Before
@@ -44,7 +45,7 @@ public class TestFileContextDeleteOnExit
@After
public void tearDown() throws IOException {
- fc.delete(getTestRootPath(fc), true);
+ fc.delete(helper.getTestRootPath(fc), true);
}
@@ -60,7 +61,7 @@ public class TestFileContextDeleteOnExit
@Test
public void testDeleteOnExit() throws Exception {
// Create deleteOnExit entries
- Path file1 = getTestRootPath(fc, "file1");
+ Path file1 = helper.getTestRootPath(fc, "file1");
createFile(fc, file1, numBlocks, blockSize);
fc.deleteOnExit(file1);
checkDeleteOnExitData(1, fc, file1);
@@ -68,12 +69,12 @@ public class TestFileContextDeleteOnExit
// Ensure shutdown hook is added
Assert.assertTrue(ShutdownHookManager.get().hasShutdownHook(FileContext.FINALIZER));
- Path file2 = getTestRootPath(fc, "dir1/file2");
+ Path file2 = helper.getTestRootPath(fc, "dir1/file2");
createFile(fc, file2, numBlocks, blockSize);
fc.deleteOnExit(file2);
checkDeleteOnExitData(1, fc, file1, file2);
- Path dir = getTestRootPath(fc, "dir3/dir4/dir5/dir6");
+ Path dir = helper.getTestRootPath(fc, "dir3/dir4/dir5/dir6");
createFile(fc, dir, numBlocks, blockSize);
fc.deleteOnExit(dir);
checkDeleteOnExitData(1, fc, file1, file2, dir);
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java Tue Jun 4 00:29:37 2013
@@ -52,7 +52,7 @@ public class TestLocalFSFileContextMainO
@Test
public void testDefaultFilePermission() throws IOException {
- Path file = FileContextTestHelper.getTestRootPath(fc,
+ Path file = fileContextTestHelper.getTestRootPath(fc,
"testDefaultFilePermission");
FileContextTestHelper.createFile(fc, file);
FsPermission expect = FileContext.FILE_DEFAULT_PERM.applyUMask(fc.getUMask());
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextSymlink.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextSymlink.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextSymlink.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextSymlink.java Tue Jun 4 00:29:37 2013
@@ -25,7 +25,6 @@ import org.apache.hadoop.fs.FileContext;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.FileUtil;
-import static org.apache.hadoop.fs.FileContextTestHelper.*;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
import org.junit.Test;
@@ -43,12 +42,12 @@ public class TestLocalFSFileContextSymli
@Override
protected String testBaseDir1() throws IOException {
- return getAbsoluteTestRootDir(fc)+"/test1";
+ return fileContextTestHelper.getAbsoluteTestRootDir(fc)+"/test1";
}
@Override
protected String testBaseDir2() throws IOException {
- return getAbsoluteTestRootDir(fc)+"/test2";
+ return fileContextTestHelper.getAbsoluteTestRootDir(fc)+"/test2";
}
@Override
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java Tue Jun 4 00:29:37 2013
@@ -69,7 +69,7 @@ public class TestLocalFileSystem {
/**
* Test the capability of setting the working directory.
*/
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testWorkingDirectory() throws IOException {
Path origDir = fileSys.getWorkingDirectory();
Path subdir = new Path(TEST_ROOT_DIR, "new");
@@ -156,7 +156,7 @@ public class TestLocalFileSystem {
}
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testCopy() throws IOException {
Path src = new Path(TEST_ROOT_DIR, "dingo");
Path dst = new Path(TEST_ROOT_DIR, "yak");
@@ -271,7 +271,7 @@ public class TestLocalFileSystem {
stats[0].getPath().toUri().getPath());
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testReportChecksumFailure() throws IOException {
base.mkdirs();
assertTrue(base.exists() && base.isDirectory());
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFsFCStatistics.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFsFCStatistics.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFsFCStatistics.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFsFCStatistics.java Tue Jun 4 00:29:37 2013
@@ -25,8 +25,6 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
-import static org.apache.hadoop.fs.FileContextTestHelper.*;
-
/**
* <p>
* Tests the File Context Statistics for {@link LocalFileSystem}
@@ -39,12 +37,12 @@ public class TestLocalFsFCStatistics ext
@Before
public void setUp() throws Exception {
fc = FileContext.getLocalFSFileContext();
- fc.mkdir(getTestRootPath(fc, "test"), FileContext.DEFAULT_PERM, true);
+ fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "test"), FileContext.DEFAULT_PERM, true);
}
@After
public void tearDown() throws Exception {
- fc.delete(getTestRootPath(fc, "test"), true);
+ fc.delete(fileContextTestHelper.getTestRootPath(fc, "test"), true);
}
@Override
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java Tue Jun 4 00:29:37 2013
@@ -97,37 +97,37 @@ public class TestCopyPreserveFlag {
assertEquals(0, cmd.run(args));
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testPutWithP() throws Exception {
run(new Put(), "-p", FROM.toString(), TO.toString());
assertAttributesPreserved();
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testPutWithoutP() throws Exception {
run(new Put(), FROM.toString(), TO.toString());
assertAttributesChanged();
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testGetWithP() throws Exception {
run(new Get(), "-p", FROM.toString(), TO.toString());
assertAttributesPreserved();
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testGetWithoutP() throws Exception {
run(new Get(), FROM.toString(), TO.toString());
assertAttributesChanged();
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testCpWithP() throws Exception {
run(new Cp(), "-p", FROM.toString(), TO.toString());
assertAttributesPreserved();
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testCpWithoutP() throws Exception {
run(new Cp(), FROM.toString(), TO.toString());
assertAttributesChanged();
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java Tue Jun 4 00:29:37 2013
@@ -40,13 +40,15 @@ public class TestChRootedFileSystem {
FileSystem fSys; // The ChRoootedFs
FileSystem fSysTarget; //
Path chrootedTo;
-
+ FileSystemTestHelper fileSystemTestHelper;
+
@Before
public void setUp() throws Exception {
// create the test root on local_fs
Configuration conf = new Configuration();
fSysTarget = FileSystem.getLocal(conf);
- chrootedTo = FileSystemTestHelper.getAbsoluteTestRootPath(fSysTarget);
+ fileSystemTestHelper = new FileSystemTestHelper();
+ chrootedTo = fileSystemTestHelper.getAbsoluteTestRootPath(fSysTarget);
// In case previous test was killed before cleanup
fSysTarget.delete(chrootedTo, true);
@@ -107,12 +109,12 @@ public class TestChRootedFileSystem {
// Create file
- FileSystemTestHelper.createFile(fSys, "/foo");
+ fileSystemTestHelper.createFile(fSys, "/foo");
Assert.assertTrue(fSys.isFile(new Path("/foo")));
Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo, "foo")));
// Create file with recursive dir
- FileSystemTestHelper.createFile(fSys, "/newDir/foo");
+ fileSystemTestHelper.createFile(fSys, "/newDir/foo");
Assert.assertTrue(fSys.isFile(new Path("/newDir/foo")));
Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo,"newDir/foo")));
@@ -122,7 +124,7 @@ public class TestChRootedFileSystem {
Assert.assertFalse(fSysTarget.exists(new Path(chrootedTo, "newDir/foo")));
// Create file with a 2 component dirs recursively
- FileSystemTestHelper.createFile(fSys, "/newDir/newDir2/foo");
+ fileSystemTestHelper.createFile(fSys, "/newDir/newDir2/foo");
Assert.assertTrue(fSys.isFile(new Path("/newDir/newDir2/foo")));
Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo,"newDir/newDir2/foo")));
@@ -135,11 +137,11 @@ public class TestChRootedFileSystem {
@Test
public void testMkdirDelete() throws IOException {
- fSys.mkdirs(FileSystemTestHelper.getTestRootPath(fSys, "/dirX"));
+ fSys.mkdirs(fileSystemTestHelper.getTestRootPath(fSys, "/dirX"));
Assert.assertTrue(fSys.isDirectory(new Path("/dirX")));
Assert.assertTrue(fSysTarget.isDirectory(new Path(chrootedTo,"dirX")));
- fSys.mkdirs(FileSystemTestHelper.getTestRootPath(fSys, "/dirX/dirY"));
+ fSys.mkdirs(fileSystemTestHelper.getTestRootPath(fSys, "/dirX/dirY"));
Assert.assertTrue(fSys.isDirectory(new Path("/dirX/dirY")));
Assert.assertTrue(fSysTarget.isDirectory(new Path(chrootedTo,"dirX/dirY")));
@@ -157,11 +159,11 @@ public class TestChRootedFileSystem {
@Test
public void testRename() throws IOException {
// Rename a file
- FileSystemTestHelper.createFile(fSys, "/newDir/foo");
+ fileSystemTestHelper.createFile(fSys, "/newDir/foo");
fSys.rename(new Path("/newDir/foo"), new Path("/newDir/fooBar"));
Assert.assertFalse(fSys.exists(new Path("/newDir/foo")));
Assert.assertFalse(fSysTarget.exists(new Path(chrootedTo,"newDir/foo")));
- Assert.assertTrue(fSys.isFile(FileSystemTestHelper.getTestRootPath(fSys,"/newDir/fooBar")));
+ Assert.assertTrue(fSys.isFile(fileSystemTestHelper.getTestRootPath(fSys,"/newDir/fooBar")));
Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo,"newDir/fooBar")));
@@ -170,7 +172,7 @@ public class TestChRootedFileSystem {
fSys.rename(new Path("/newDir/dirFoo"), new Path("/newDir/dirFooBar"));
Assert.assertFalse(fSys.exists(new Path("/newDir/dirFoo")));
Assert.assertFalse(fSysTarget.exists(new Path(chrootedTo,"newDir/dirFoo")));
- Assert.assertTrue(fSys.isDirectory(FileSystemTestHelper.getTestRootPath(fSys,"/newDir/dirFooBar")));
+ Assert.assertTrue(fSys.isDirectory(fileSystemTestHelper.getTestRootPath(fSys,"/newDir/dirFooBar")));
Assert.assertTrue(fSysTarget.isDirectory(new Path(chrootedTo,"newDir/dirFooBar")));
}
@@ -214,10 +216,10 @@ public class TestChRootedFileSystem {
- FileSystemTestHelper.createFile(fSys, "/foo");
- FileSystemTestHelper.createFile(fSys, "/bar");
+ fileSystemTestHelper.createFile(fSys, "/foo");
+ fileSystemTestHelper.createFile(fSys, "/bar");
fSys.mkdirs(new Path("/dirX"));
- fSys.mkdirs(FileSystemTestHelper.getTestRootPath(fSys, "/dirY"));
+ fSys.mkdirs(fileSystemTestHelper.getTestRootPath(fSys, "/dirY"));
fSys.mkdirs(new Path("/dirX/dirXX"));
dirPaths = fSys.listStatus(new Path("/"));
@@ -307,7 +309,7 @@ public class TestChRootedFileSystem {
@Test
public void testResolvePath() throws IOException {
Assert.assertEquals(chrootedTo, fSys.resolvePath(new Path("/")));
- FileSystemTestHelper.createFile(fSys, "/foo");
+ fileSystemTestHelper.createFile(fSys, "/foo");
Assert.assertEquals(new Path(chrootedTo, "foo"),
fSys.resolvePath(new Path("/foo")));
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java Tue Jun 4 00:29:37 2013
@@ -38,6 +38,7 @@ import org.junit.Before;
import org.junit.Test;
public class TestChRootedFs {
+ FileContextTestHelper fileContextTestHelper = new FileContextTestHelper();
FileContext fc; // The ChRoootedFs
FileContext fcTarget; //
Path chrootedTo;
@@ -46,7 +47,7 @@ public class TestChRootedFs {
public void setUp() throws Exception {
// create the test root on local_fs
fcTarget = FileContext.getLocalFSFileContext();
- chrootedTo = FileContextTestHelper.getAbsoluteTestRootPath(fcTarget);
+ chrootedTo = fileContextTestHelper.getAbsoluteTestRootPath(fcTarget);
// In case previous test was killed before cleanup
fcTarget.delete(chrootedTo, true);
@@ -105,12 +106,12 @@ public class TestChRootedFs {
// Create file
- FileContextTestHelper.createFileNonRecursive(fc, "/foo");
+ fileContextTestHelper.createFileNonRecursive(fc, "/foo");
Assert.assertTrue(isFile(fc, new Path("/foo")));
Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo, "foo")));
// Create file with recursive dir
- FileContextTestHelper.createFile(fc, "/newDir/foo");
+ fileContextTestHelper.createFile(fc, "/newDir/foo");
Assert.assertTrue(isFile(fc, new Path("/newDir/foo")));
Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/foo")));
@@ -120,7 +121,7 @@ public class TestChRootedFs {
Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/foo")));
// Create file with a 2 component dirs recursively
- FileContextTestHelper.createFile(fc, "/newDir/newDir2/foo");
+ fileContextTestHelper.createFile(fc, "/newDir/newDir2/foo");
Assert.assertTrue(isFile(fc, new Path("/newDir/newDir2/foo")));
Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/newDir2/foo")));
@@ -133,11 +134,11 @@ public class TestChRootedFs {
@Test
public void testMkdirDelete() throws IOException {
- fc.mkdir(FileContextTestHelper.getTestRootPath(fc, "/dirX"), FileContext.DEFAULT_PERM, false);
+ fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX"), FileContext.DEFAULT_PERM, false);
Assert.assertTrue(isDir(fc, new Path("/dirX")));
Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"dirX")));
- fc.mkdir(FileContextTestHelper.getTestRootPath(fc, "/dirX/dirY"), FileContext.DEFAULT_PERM, false);
+ fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX/dirY"), FileContext.DEFAULT_PERM, false);
Assert.assertTrue(isDir(fc, new Path("/dirX/dirY")));
Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"dirX/dirY")));
@@ -155,11 +156,11 @@ public class TestChRootedFs {
@Test
public void testRename() throws IOException {
// Rename a file
- FileContextTestHelper.createFile(fc, "/newDir/foo");
+ fileContextTestHelper.createFile(fc, "/newDir/foo");
fc.rename(new Path("/newDir/foo"), new Path("/newDir/fooBar"));
Assert.assertFalse(exists(fc, new Path("/newDir/foo")));
Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/foo")));
- Assert.assertTrue(isFile(fc, FileContextTestHelper.getTestRootPath(fc,"/newDir/fooBar")));
+ Assert.assertTrue(isFile(fc, fileContextTestHelper.getTestRootPath(fc,"/newDir/fooBar")));
Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/fooBar")));
@@ -168,7 +169,7 @@ public class TestChRootedFs {
fc.rename(new Path("/newDir/dirFoo"), new Path("/newDir/dirFooBar"));
Assert.assertFalse(exists(fc, new Path("/newDir/dirFoo")));
Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/dirFoo")));
- Assert.assertTrue(isDir(fc, FileContextTestHelper.getTestRootPath(fc,"/newDir/dirFooBar")));
+ Assert.assertTrue(isDir(fc, fileContextTestHelper.getTestRootPath(fc,"/newDir/dirFooBar")));
Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"newDir/dirFooBar")));
}
@@ -202,10 +203,10 @@ public class TestChRootedFs {
- FileContextTestHelper.createFileNonRecursive(fc, "/foo");
- FileContextTestHelper.createFileNonRecursive(fc, "/bar");
+ fileContextTestHelper.createFileNonRecursive(fc, "/foo");
+ fileContextTestHelper.createFileNonRecursive(fc, "/bar");
fc.mkdir(new Path("/dirX"), FileContext.DEFAULT_PERM, false);
- fc.mkdir(FileContextTestHelper.getTestRootPath(fc, "/dirY"),
+ fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirY"),
FileContext.DEFAULT_PERM, false);
fc.mkdir(new Path("/dirX/dirXX"), FileContext.DEFAULT_PERM, false);
@@ -213,16 +214,16 @@ public class TestChRootedFs {
Assert.assertEquals(4, dirPaths.length);
// Note the the file status paths are the full paths on target
- fs = FileContextTestHelper.containsPath(fcTarget, "foo", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcTarget, "foo", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue(fs.isFile());
- fs = FileContextTestHelper.containsPath(fcTarget, "bar", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcTarget, "bar", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue(fs.isFile());
- fs = FileContextTestHelper.containsPath(fcTarget, "dirX", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcTarget, "dirX", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue(fs.isDirectory());
- fs = FileContextTestHelper.containsPath(fcTarget, "dirY", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcTarget, "dirY", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue(fs.isDirectory());
}
@@ -273,7 +274,7 @@ public class TestChRootedFs {
fc.mkdir(new Path("newDir"), FileContext.DEFAULT_PERM, true);
Assert.assertTrue(isDir(fc, new Path(absoluteDir, "newDir")));
- absoluteDir = getTestRootPath(fc, "nonexistingPath");
+ absoluteDir = fileContextTestHelper.getTestRootPath(fc, "nonexistingPath");
try {
fc.setWorkingDirectory(absoluteDir);
Assert.fail("cd to non existing dir should have failed");
@@ -297,7 +298,7 @@ public class TestChRootedFs {
@Test
public void testResolvePath() throws IOException {
Assert.assertEquals(chrootedTo, fc.getDefaultFileSystem().resolvePath(new Path("/")));
- FileContextTestHelper.createFile(fc, "/foo");
+ fileContextTestHelper.createFile(fc, "/foo");
Assert.assertEquals(new Path(chrootedTo, "foo"),
fc.getDefaultFileSystem().resolvePath(new Path("/foo")));
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java Tue Jun 4 00:29:37 2013
@@ -23,7 +23,6 @@ import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSMainOperationsBaseTest;
-import org.apache.hadoop.fs.FileSystemTestHelper;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.junit.After;
@@ -32,14 +31,19 @@ import org.junit.Before;
import org.junit.Test;
public class TestFSMainOperationsLocalFileSystem extends FSMainOperationsBaseTest {
- static FileSystem fcTarget;
+ FileSystem fcTarget;
+
+ @Override
+ protected FileSystem createFileSystem() throws Exception {
+ return ViewFileSystemTestSetup.setupForViewFileSystem(
+ ViewFileSystemTestSetup.createConfig(), this, fcTarget);
+ }
+
@Override
@Before
public void setUp() throws Exception {
Configuration conf = new Configuration();
fcTarget = FileSystem.getLocal(conf);
- fSys = ViewFileSystemTestSetup.setupForViewFileSystem(
- ViewFileSystemTestSetup.createConfig(), fcTarget);
super.setUp();
}
@@ -47,14 +51,13 @@ public class TestFSMainOperationsLocalFi
@After
public void tearDown() throws Exception {
super.tearDown();
- ViewFileSystemTestSetup.tearDown(fcTarget);
+ ViewFileSystemTestSetup.tearDown(this, fcTarget);
}
@Test
@Override
public void testWDAbsolute() throws IOException {
- Path absoluteDir = FileSystemTestHelper.getTestRootPath(fSys,
- "test/existingDir");
+ Path absoluteDir = getTestRootPath(fSys, "test/existingDir");
fSys.mkdirs(absoluteDir);
fSys.setWorkingDirectory(absoluteDir);
Assert.assertEquals(absoluteDir, fSys.getWorkingDirectory());
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java Tue Jun 4 00:29:37 2013
@@ -31,7 +31,7 @@ public class TestFcCreateMkdirLocalFs e
@Override
@Before
public void setUp() throws Exception {
- fc = ViewFsTestSetup.setupForViewFsLocalFs();
+ fc = ViewFsTestSetup.setupForViewFsLocalFs(fileContextTestHelper);
super.setUp();
}
@@ -39,6 +39,6 @@ public class TestFcCreateMkdirLocalFs e
@After
public void tearDown() throws Exception {
super.tearDown();
- ViewFsTestSetup.tearDownForViewFsLocalFs();
+ ViewFsTestSetup.tearDownForViewFsLocalFs(fileContextTestHelper);
}
}
\ No newline at end of file
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java Tue Jun 4 00:29:37 2013
@@ -39,7 +39,7 @@ public class TestFcMainOperationsLocalFs
@Override
@Before
public void setUp() throws Exception {
- fc = ViewFsTestSetup.setupForViewFsLocalFs();
+ fc = ViewFsTestSetup.setupForViewFsLocalFs(fileContextTestHelper);
super.setUp();
}
@@ -47,6 +47,6 @@ public class TestFcMainOperationsLocalFs
@After
public void tearDown() throws Exception {
super.tearDown();
- ViewFsTestSetup.tearDownForViewFsLocalFs();
+ ViewFsTestSetup.tearDownForViewFsLocalFs(fileContextTestHelper);
}
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java Tue Jun 4 00:29:37 2013
@@ -18,6 +18,7 @@
package org.apache.hadoop.fs.viewfs;
+import org.apache.hadoop.fs.FileContext;
import org.apache.hadoop.fs.FileContextPermissionBase;
import org.junit.After;
@@ -26,11 +27,9 @@ import org.junit.Before;
public class TestFcPermissionsLocalFs extends FileContextPermissionBase {
-
@Override
@Before
public void setUp() throws Exception {
- fc = ViewFsTestSetup.setupForViewFsLocalFs();
super.setUp();
}
@@ -38,6 +37,11 @@ public class TestFcPermissionsLocalFs e
@After
public void tearDown() throws Exception {
super.tearDown();
- ViewFsTestSetup.tearDownForViewFsLocalFs();
+ ViewFsTestSetup.tearDownForViewFsLocalFs(fileContextTestHelper);
+ }
+
+ @Override
+ protected FileContext getFileContext() throws Exception {
+ return ViewFsTestSetup.setupForViewFsLocalFs(fileContextTestHelper);
}
}
\ No newline at end of file
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java Tue Jun 4 00:29:37 2013
@@ -52,7 +52,7 @@ public class TestViewFileSystemDelegatio
conf.set("fs."+scheme+".impl", clazz.getName());
FakeFileSystem fs = (FakeFileSystem)FileSystem.get(uri, conf);
assertEquals(uri, fs.getUri());
- Path targetPath = FileSystemTestHelper.getAbsoluteTestRootPath(fs);
+ Path targetPath = new FileSystemTestHelper().getAbsoluteTestRootPath(fs);
ConfigUtil.addLink(conf, "/mounts/"+scheme, targetPath.toUri());
return fs;
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java Tue Jun 4 00:29:37 2013
@@ -38,7 +38,6 @@ import org.junit.Before;
public class TestViewFileSystemLocalFileSystem extends ViewFileSystemBaseTest {
-
@Override
@Before
public void setUp() throws Exception {
@@ -51,7 +50,7 @@ public class TestViewFileSystemLocalFile
@Override
@After
public void tearDown() throws Exception {
- fsTarget.delete(FileSystemTestHelper.getTestRootPath(fsTarget), true);
+ fsTarget.delete(fileSystemTestHelper.getTestRootPath(fsTarget), true);
super.tearDown();
}
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java Tue Jun 4 00:29:37 2013
@@ -59,7 +59,7 @@ public class TestViewFileSystemWithAutho
@Override
@After
public void tearDown() throws Exception {
- fsTarget.delete(FileSystemTestHelper.getTestRootPath(fsTarget), true);
+ fsTarget.delete(fileSystemTestHelper.getTestRootPath(fsTarget), true);
super.tearDown();
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java?rev=1489250&r1=1489249&r2=1489250&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java Tue Jun 4 00:29:37 2013
@@ -35,11 +35,12 @@ public class TestViewFsTrash {
FileSystem fsTarget; // the target file system - the mount will point here
FileSystem fsView;
Configuration conf;
+ FileSystemTestHelper fileSystemTestHelper = new FileSystemTestHelper();
- static class TestLFS extends LocalFileSystem {
+ class TestLFS extends LocalFileSystem {
Path home;
TestLFS() throws IOException {
- this(new Path(FileSystemTestHelper.TEST_ROOT_DIR));
+ this(new Path(fileSystemTestHelper.getTestRootDir()));
}
TestLFS(Path home) throws IOException {
super();
@@ -54,23 +55,23 @@ public class TestViewFsTrash {
@Before
public void setUp() throws Exception {
fsTarget = FileSystem.getLocal(new Configuration());
- fsTarget.mkdirs(new Path(FileSystemTestHelper.
+ fsTarget.mkdirs(new Path(fileSystemTestHelper.
getTestRootPath(fsTarget), "dir1"));
conf = ViewFileSystemTestSetup.createConfig();
- fsView = ViewFileSystemTestSetup.setupForViewFileSystem(conf, fsTarget);
+ fsView = ViewFileSystemTestSetup.setupForViewFileSystem(conf, fileSystemTestHelper, fsTarget);
conf.set("fs.defaultFS", FsConstants.VIEWFS_URI.toString());
}
@After
public void tearDown() throws Exception {
- ViewFileSystemTestSetup.tearDown(fsTarget);
+ ViewFileSystemTestSetup.tearDown(fileSystemTestHelper, fsTarget);
fsTarget.delete(new Path(fsTarget.getHomeDirectory(), ".Trash/Current"),
true);
}
@Test
public void testTrash() throws IOException {
- TestTrash.trashShell(conf, FileSystemTestHelper.getTestRootPath(fsView),
+ TestTrash.trashShell(conf, fileSystemTestHelper.getTestRootPath(fsView),
fsTarget, new Path(fsTarget.getHomeDirectory(), ".Trash/Current"));
}