Search in sources :

Example 6 with FileSystemTestHelper

use of org.apache.hadoop.fs.FileSystemTestHelper in project hadoop by apache.

the class TestHdfsHelper method startMiniHdfs.

private static synchronized MiniDFSCluster startMiniHdfs(Configuration conf) throws Exception {
    if (MINI_DFS == null) {
        if (System.getProperty("hadoop.log.dir") == null) {
            System.setProperty("hadoop.log.dir", new File(TEST_DIR_ROOT, "hadoop-log").getAbsolutePath());
        }
        if (System.getProperty("test.build.data") == null) {
            System.setProperty("test.build.data", new File(TEST_DIR_ROOT, "hadoop-data").getAbsolutePath());
        }
        conf = new Configuration(conf);
        HadoopUsersConfTestHelper.addUserConf(conf);
        conf.set("fs.hdfs.impl.disable.cache", "true");
        conf.set("dfs.block.access.token.enable", "false");
        conf.set("dfs.permissions", "true");
        conf.set("hadoop.security.authentication", "simple");
        conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_ACLS_ENABLED_KEY, true);
        conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_XATTRS_ENABLED_KEY, true);
        FileSystemTestHelper helper = new FileSystemTestHelper();
        final String jceksPath = JavaKeyStoreProvider.SCHEME_NAME + "://file" + new Path(helper.getTestRootDir(), "test.jks").toUri();
        conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH, jceksPath);
        MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
        builder.numDataNodes(2);
        MiniDFSCluster miniHdfs = builder.build();
        final String testkey = "testkey";
        DFSTestUtil.createKey(testkey, miniHdfs, conf);
        DistributedFileSystem fileSystem = miniHdfs.getFileSystem();
        fileSystem.getClient().setKeyProvider(miniHdfs.getNameNode().getNamesystem().getProvider());
        fileSystem.mkdirs(new Path("/tmp"));
        fileSystem.mkdirs(new Path("/user"));
        fileSystem.setPermission(new Path("/tmp"), FsPermission.valueOf("-rwxrwxrwx"));
        fileSystem.setPermission(new Path("/user"), FsPermission.valueOf("-rwxrwxrwx"));
        fileSystem.mkdirs(ENCRYPTION_ZONE);
        fileSystem.createEncryptionZone(ENCRYPTION_ZONE, testkey);
        fileSystem.create(ENCRYPTED_FILE).close();
        MINI_DFS = miniHdfs;
    }
    return MINI_DFS;
}
Also used : FileSystemTestHelper(org.apache.hadoop.fs.FileSystemTestHelper) Path(org.apache.hadoop.fs.Path) MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) Configuration(org.apache.hadoop.conf.Configuration) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) File(java.io.File)

Example 7 with FileSystemTestHelper

use of org.apache.hadoop.fs.FileSystemTestHelper in project hadoop by apache.

the class TestFsVolumeList method setUp.

@Before
public void setUp() {
    dataset = mock(FsDatasetImpl.class);
    baseDir = new FileSystemTestHelper().getTestRootDir();
    Configuration blockScannerConf = new Configuration();
    blockScannerConf.setInt(DFSConfigKeys.DFS_DATANODE_SCAN_PERIOD_HOURS_KEY, -1);
    blockScanner = new BlockScanner(null, blockScannerConf);
}
Also used : FileSystemTestHelper(org.apache.hadoop.fs.FileSystemTestHelper) Configuration(org.apache.hadoop.conf.Configuration) BlockScanner(org.apache.hadoop.hdfs.server.datanode.BlockScanner) Before(org.junit.Before)

Example 8 with FileSystemTestHelper

use of org.apache.hadoop.fs.FileSystemTestHelper in project hadoop by apache.

the class TestOfflineImageViewer method testPBDelimitedWriter.

@Test
public void testPBDelimitedWriter() throws IOException, InterruptedException {
    // Test in memory db.
    testPBDelimitedWriter("");
    testPBDelimitedWriter(new FileSystemTestHelper().getTestRootDir() + "/delimited.db");
}
Also used : FileSystemTestHelper(org.apache.hadoop.fs.FileSystemTestHelper) Test(org.junit.Test)

Example 9 with FileSystemTestHelper

use of org.apache.hadoop.fs.FileSystemTestHelper in project hadoop by apache.

the class TestKeyProviderFactory method setup.

@Before
public void setup() {
    fsHelper = new FileSystemTestHelper();
    String testRoot = fsHelper.getTestRootDir();
    testRootDir = new File(testRoot).getAbsoluteFile();
}
Also used : FileSystemTestHelper(org.apache.hadoop.fs.FileSystemTestHelper) File(java.io.File) Before(org.junit.Before)

Example 10 with FileSystemTestHelper

use of org.apache.hadoop.fs.FileSystemTestHelper in project hadoop by apache.

the class TestViewFileSystemDelegation method setupFileSystem.

static FakeFileSystem setupFileSystem(URI uri, Class clazz) throws Exception {
    String scheme = uri.getScheme();
    conf.set("fs." + scheme + ".impl", clazz.getName());
    FakeFileSystem fs = (FakeFileSystem) FileSystem.get(uri, conf);
    assertEquals(uri, fs.getUri());
    Path targetPath = new FileSystemTestHelper().getAbsoluteTestRootPath(fs);
    ConfigUtil.addLink(conf, "/mounts/" + scheme, targetPath.toUri());
    return fs;
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystemTestHelper(org.apache.hadoop.fs.FileSystemTestHelper)

Aggregations

FileSystemTestHelper (org.apache.hadoop.fs.FileSystemTestHelper)18 File (java.io.File)12 Configuration (org.apache.hadoop.conf.Configuration)9 Path (org.apache.hadoop.fs.Path)9 Before (org.junit.Before)9 HdfsAdmin (org.apache.hadoop.hdfs.client.HdfsAdmin)6 FileSystemTestWrapper (org.apache.hadoop.fs.FileSystemTestWrapper)4 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)4 Test (org.junit.Test)4 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)3 EncryptionZoneManager (org.apache.hadoop.hdfs.server.namenode.EncryptionZoneManager)3 FileContextTestWrapper (org.apache.hadoop.fs.FileContextTestWrapper)2 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)2 BeforeClass (org.junit.BeforeClass)2 FileOutputStream (java.io.FileOutputStream)1 RandomAccessFile (java.io.RandomAccessFile)1 SocketTimeoutException (java.net.SocketTimeoutException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1