Search in sources :

Example 76 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class AlluxioShellUtilsTest method resetFileHierarchy.

/**
   * Resets the file hierarchy.
   *
   * @param fs the file system
   * @param writeType write types for creating a file in Alluxio
   * @return the test directory
   */
public static String resetFileHierarchy(FileSystem fs, WriteType writeType) throws IOException, AlluxioException {
    /**
     * Generate such local structure TEST_DIR
     *                                ├── foo |
     *                                        ├── foobar1
     *                                        └── foobar2
     *                                ├── bar |
     *                                        └── foobar3
     *                                └── foobar4
     */
    if (fs.exists(new AlluxioURI(TEST_DIR))) {
        fs.delete(new AlluxioURI(TEST_DIR), DeleteOptions.defaults().setRecursive(true));
    }
    fs.createDirectory(new AlluxioURI(TEST_DIR));
    fs.createDirectory(new AlluxioURI(TEST_DIR + "/foo"));
    fs.createDirectory(new AlluxioURI(TEST_DIR + "/bar"));
    FileSystemTestUtils.createByteFile(fs, TEST_DIR + "/foo/foobar1", writeType, 10);
    FileSystemTestUtils.createByteFile(fs, TEST_DIR + "/foo/foobar2", writeType, 20);
    FileSystemTestUtils.createByteFile(fs, TEST_DIR + "/bar/foobar3", writeType, 30);
    FileSystemTestUtils.createByteFile(fs, TEST_DIR + "/foobar4", writeType, 40);
    return TEST_DIR;
}
Also used : AlluxioURI(alluxio.AlluxioURI)

Example 77 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class ChmodCommandTest method chmodRecursively.

/**
   * Tests -R option for chmod recursively.
   */
@Test
public void chmodRecursively() throws IOException, AlluxioException {
    clearLoginUser();
    FileSystemTestUtils.createByteFile(mFileSystem, "/testDir/testFile", WriteType.MUST_CACHE, 10);
    mFsShell.run("chmod", "-R", "777", "/testDir");
    int permission = mFileSystem.getStatus(new AlluxioURI("/testDir")).getMode();
    Assert.assertEquals((short) 0777, permission);
    permission = mFileSystem.getStatus(new AlluxioURI("/testDir/testFile")).getMode();
    Assert.assertEquals((short) 0777, permission);
    mFsShell.run("chmod", "-R", "755", "/testDir");
    permission = mFileSystem.getStatus(new AlluxioURI("/testDir/testFile")).getMode();
    Assert.assertEquals((short) 0755, permission);
}
Also used : AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AbstractAlluxioShellTest(alluxio.shell.AbstractAlluxioShellTest)

Example 78 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class CopyFromLocalCommandTest method copyFromLocalWildcardExistingDir.

@Test
public void copyFromLocalWildcardExistingDir() throws IOException, AlluxioException {
    String testDir = AlluxioShellUtilsTest.resetLocalFileHierarchy(mLocalAlluxioCluster);
    mFileSystem.createDirectory(new AlluxioURI("/testDir"));
    int ret = mFsShell.run("copyFromLocal", testDir + "/*/foo*", "/testDir");
    Assert.assertEquals(0, ret);
    Assert.assertTrue(fileExists(new AlluxioURI("/testDir/foobar1")));
    Assert.assertTrue(fileExists(new AlluxioURI("/testDir/foobar2")));
    Assert.assertTrue(fileExists(new AlluxioURI("/testDir/foobar3")));
}
Also used : AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AlluxioShellUtilsTest(alluxio.shell.AlluxioShellUtilsTest) AbstractAlluxioShellTest(alluxio.shell.AbstractAlluxioShellTest)

Example 79 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class CopyFromLocalCommandTest method copyFromLocalTestWithFullURI.

@Test
public void copyFromLocalTestWithFullURI() throws IOException, AlluxioException {
    File testFile = generateFileContent("/srcFileURI", BufferUtils.getIncreasingByteArray(10));
    String alluxioURI = "alluxio://" + mLocalAlluxioCluster.getHostname() + ":" + mLocalAlluxioCluster.getMasterRpcPort() + "/destFileURI";
    // when
    mFsShell.run("copyFromLocal", testFile.getPath(), alluxioURI);
    String cmdOut = getCommandOutput(new String[] { "copyFromLocal", testFile.getPath(), alluxioURI });
    // then
    Assert.assertEquals(cmdOut, mOutput.toString());
    AlluxioURI uri = new AlluxioURI("/destFileURI");
    URIStatus status = mFileSystem.getStatus(uri);
    Assert.assertEquals(10L, status.getLength());
    byte[] read = readContent(uri, 10);
    Assert.assertTrue(BufferUtils.equalIncreasingByteArray(10, read));
}
Also used : URIStatus(alluxio.client.file.URIStatus) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AlluxioShellUtilsTest(alluxio.shell.AlluxioShellUtilsTest) AbstractAlluxioShellTest(alluxio.shell.AbstractAlluxioShellTest)

Example 80 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class CopyFromLocalCommandTest method copyFromLocalFileToDstPath.

@Test
public void copyFromLocalFileToDstPath() throws IOException, AlluxioException {
    String dataString = "copyFromLocalFileToDstPathTest";
    byte[] data = dataString.getBytes();
    File localDir = new File(mLocalAlluxioCluster.getAlluxioHome() + "/localDir");
    localDir.mkdir();
    File localFile = generateFileContent("/localDir/testFile", data);
    mFsShell.run("mkdir", "/dstDir");
    mFsShell.run("copyFromLocal", localFile.getPath(), "/dstDir");
    AlluxioURI uri = new AlluxioURI("/dstDir/testFile");
    URIStatus status = mFileSystem.getStatus(uri);
    Assert.assertNotNull(status);
    byte[] read = readContent(uri, data.length);
    Assert.assertEquals(new String(read), dataString);
}
Also used : URIStatus(alluxio.client.file.URIStatus) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AlluxioShellUtilsTest(alluxio.shell.AlluxioShellUtilsTest) AbstractAlluxioShellTest(alluxio.shell.AbstractAlluxioShellTest)

Aggregations

AlluxioURI (alluxio.AlluxioURI)1552 Test (org.junit.Test)1094 URIStatus (alluxio.client.file.URIStatus)356 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)303 IOException (java.io.IOException)154 FileInStream (alluxio.client.file.FileInStream)152 FileInfo (alluxio.wire.FileInfo)130 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)124 ArrayList (java.util.ArrayList)120 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)119 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)114 File (java.io.File)107 FileSystem (alluxio.client.file.FileSystem)99 FileOutStream (alluxio.client.file.FileOutStream)97 AlluxioException (alluxio.exception.AlluxioException)92 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)76 InvalidPathException (alluxio.exception.InvalidPathException)68 AbstractAlluxioShellTest (alluxio.shell.AbstractAlluxioShellTest)63 UnderFileSystem (alluxio.underfs.UnderFileSystem)63 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)62