use of alluxio.UnderFileSystemFactoryRegistryRule in project alluxio by Alluxio.
the class MountCommandTest method mountWithWrongOptions.
@Test
public void mountWithWrongOptions() throws Exception {
ConfExpectingUnderFileSystemFactory factory = new ConfExpectingUnderFileSystemFactory("ufs", ImmutableMap.of("k1", "v1", "k2", "v2"));
try (Closeable closeable = new UnderFileSystemFactoryRegistryRule(factory).toResource()) {
AlluxioURI mountPoint = new AlluxioURI("/mnt");
String ufsPath = "ufs://" + mFolder.getRoot().getAbsolutePath();
// one property is wrong
Assert.assertEquals(-1, sFsShell.run("mount", "--option", "k1=not_v1", "--option", "k2=v2", mountPoint.toString(), ufsPath));
// one property is missing
Assert.assertEquals(-1, sFsShell.run("mount", "--option", "k1=v1", mountPoint.toString(), ufsPath));
// one property is unnecessary
Assert.assertEquals(-1, sFsShell.run("mount", "--option", "k1=v1", "--option", "k2=v2", "--option", "k3=v3", mountPoint.toString(), ufsPath));
}
}
use of alluxio.UnderFileSystemFactoryRegistryRule in project alluxio by Alluxio.
the class UpdateMountCommandTest method updateMountWithWrongOptionsAndThenCorrected.
@Test
public void updateMountWithWrongOptionsAndThenCorrected() throws Exception {
AlluxioURI mountPoint = new AlluxioURI("/mnt");
String ufsPath = "ufs://" + mFolder.getRoot().getAbsolutePath();
ImmutableMap<String, String> options = ImmutableMap.of("k1", "v1", "k2", "v2");
ConfExpectingUnderFileSystemFactory factory = new ConfExpectingUnderFileSystemFactory("ufs", options);
try (Closeable closeable = new UnderFileSystemFactoryRegistryRule(factory).toResource()) {
Assert.assertEquals(0, sFsShell.run("mount", "--option", "k1=v1", "--option", "k2=v2", mountPoint.toString(), ufsPath));
Assert.assertEquals(-1, sFsShell.run("updateMount", "--option", "k1=not_v1", "--option", "k2=v2", mountPoint.toString()));
boolean gotException = false;
// check mount point is still usable if updateMount fails
FileSystemTestUtils.createByteFile(sFileSystem, "/mnt/testFile1", WritePType.CACHE_THROUGH, 20);
// check mount point options are not changed
Assert.assertEquals(options, sFileSystem.getMountTable().get(mountPoint.getPath()).getProperties());
}
ImmutableMap<String, String> options2 = ImmutableMap.of("k1", "v3", "k2", "v4");
ConfExpectingUnderFileSystemFactory factory2 = new ConfExpectingUnderFileSystemFactory("ufs", options2);
try (Closeable closeable = new UnderFileSystemFactoryRegistryRule(factory2).toResource()) {
Assert.assertEquals(0, sFsShell.run("updateMount", "--option", "k1=v3", "--option", "k2=v4", mountPoint.toString()));
// check mount point is in working state after updated with correct options
FileSystemTestUtils.createByteFile(sFileSystem, "/mnt/testFile2", WritePType.CACHE_THROUGH, 20);
Assert.assertTrue(sFileSystem.exists(new AlluxioURI("/mnt/testFile2")));
URIStatus status = sFileSystem.getStatus(new AlluxioURI("/mnt/testFile2"));
Assert.assertTrue(status.isPersisted());
// check mount point options are not changed
Assert.assertEquals(options2, sFileSystem.getMountTable().get(mountPoint.getPath()).getProperties());
}
}
use of alluxio.UnderFileSystemFactoryRegistryRule in project alluxio by Alluxio.
the class MountCommandTest method mountWithMultipleOptions.
@Test
public void mountWithMultipleOptions() throws Exception {
ConfExpectingUnderFileSystemFactory factory = new ConfExpectingUnderFileSystemFactory("ufs", ImmutableMap.of("k1", "v1", "k2", "v2"));
try (Closeable closeable = new UnderFileSystemFactoryRegistryRule(factory).toResource()) {
AlluxioURI mountPoint = new AlluxioURI("/mnt");
String ufsPath = "ufs://" + mFolder.getRoot().getAbsolutePath();
Assert.assertEquals(0, sFsShell.run("mount", "--option", "k1=v1", "--option", "k2=v2", mountPoint.toString(), ufsPath));
FileSystemTestUtils.createByteFile(sFileSystem, "/mnt/testFile1", WritePType.CACHE_THROUGH, 20);
Assert.assertTrue(sFileSystem.exists(new AlluxioURI("/mnt/testFile1")));
URIStatus status = sFileSystem.getStatus(new AlluxioURI("/mnt/testFile1"));
Assert.assertTrue(status.isPersisted());
}
}
use of alluxio.UnderFileSystemFactoryRegistryRule in project alluxio by Alluxio.
the class UpdateMountCommandTest method updateMountWithMultipleOptions.
@Test
public void updateMountWithMultipleOptions() throws Exception {
ConfExpectingUnderFileSystemFactory factory = new ConfExpectingUnderFileSystemFactory("ufs", ImmutableMap.of("k1", "v1", "k2", "v2"));
AlluxioURI mountPoint = new AlluxioURI("/mnt");
String ufsPath = "ufs://" + mFolder.getRoot().getAbsolutePath();
try (Closeable closeable = new UnderFileSystemFactoryRegistryRule(factory).toResource()) {
Assert.assertEquals(0, sFsShell.run("mount", "--option", "k1=v1", "--option", "k2=v2", mountPoint.toString(), ufsPath));
FileSystemTestUtils.createByteFile(sFileSystem, "/mnt/testFile1", WritePType.CACHE_THROUGH, 20);
Assert.assertTrue(sFileSystem.exists(new AlluxioURI("/mnt/testFile1")));
URIStatus status = sFileSystem.getStatus(new AlluxioURI("/mnt/testFile1"));
Assert.assertTrue(status.isPersisted());
}
ConfExpectingUnderFileSystemFactory newFactory = new ConfExpectingUnderFileSystemFactory("ufs", ImmutableMap.of("k1", "v3", "k2", "v4"));
try (Closeable closeable = new UnderFileSystemFactoryRegistryRule(newFactory).toResource()) {
Assert.assertEquals(0, sFsShell.run("updateMount", "--option", "k1=v3", "--option", "k2=v4", mountPoint.toString()));
FileSystemTestUtils.createByteFile(sFileSystem, "/mnt/testFile2", WritePType.CACHE_THROUGH, 20);
Assert.assertTrue(sFileSystem.exists(new AlluxioURI("/mnt/testFile2")));
URIStatus status = sFileSystem.getStatus(new AlluxioURI("/mnt/testFile2"));
Assert.assertTrue(status.isPersisted());
}
}
Aggregations