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;
}
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);
}
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")));
}
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));
}
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);
}
Aggregations