Search in sources :

Example 1 with ConfExpectingUnderFileSystemFactory

use of alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory 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));
    }
}
Also used : Closeable(java.io.Closeable) UnderFileSystemFactoryRegistryRule(alluxio.UnderFileSystemFactoryRegistryRule) ConfExpectingUnderFileSystemFactory(alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test)

Example 2 with ConfExpectingUnderFileSystemFactory

use of alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory 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());
    }
}
Also used : Closeable(java.io.Closeable) URIStatus(alluxio.client.file.URIStatus) UnderFileSystemFactoryRegistryRule(alluxio.UnderFileSystemFactoryRegistryRule) ConfExpectingUnderFileSystemFactory(alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test)

Example 3 with ConfExpectingUnderFileSystemFactory

use of alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory in project alluxio by Alluxio.

the class MultiUfsMountIntegrationTest method mountNestedWithUpdatedOptions.

@Test
public void mountNestedWithUpdatedOptions() throws Exception {
    MountPOptions options3 = MountPOptions.newBuilder().putAllProperties(UFS_CONF3).build();
    mFileSystem.mount(mMountPoint3, new AlluxioURI(mUfsUri3), options3);
    MountPOptions options4 = MountPOptions.newBuilder().putAllProperties(UFS_CONF4).build();
    mFileSystem.mount(mMountPoint4, new AlluxioURI(mUfsUri4), options4);
    Map<String, MountPointInfo> mountTable = mFileSystem.getMountTable();
    Assert.assertTrue(mountTable.containsKey(MOUNT_POINT3));
    MountPointInfo mountPointInfo3 = mountTable.get(MOUNT_POINT3);
    Assert.assertEquals(mUfsUri3, mountPointInfo3.getUfsUri());
    Assert.assertEquals(UFS_CONF3.size(), mountPointInfo3.getProperties().size());
    Assert.assertTrue(mountPointInfo3.getProperties().containsKey(PropertyKey.Name.S3A_ACCESS_KEY));
    Assert.assertNotEquals(UFS_CONF3.get(PropertyKey.Name.S3A_ACCESS_KEY), mountPointInfo3.getProperties().get(PropertyKey.Name.S3A_ACCESS_KEY));
    Assert.assertTrue(mountTable.containsKey(MOUNT_POINT4_NESTED));
    MountPointInfo mountPointInfo4 = mountTable.get(MOUNT_POINT4_NESTED);
    Assert.assertEquals(mUfsUri4, mountPointInfo4.getUfsUri());
    Assert.assertEquals(UFS_CONF4.size(), mountPointInfo3.getProperties().size());
    Assert.assertEquals(UFS_CONF4, mountPointInfo4.getProperties());
    MountPOptions options5 = MountPOptions.newBuilder().putAllProperties(UFS_CONF2).build();
    UnderFileSystemFactoryRegistry.register(new ConfExpectingUnderFileSystemFactory("ufs3", UFS_CONF2));
    mFileSystem.updateMount(mMountPoint3, options5);
    mountTable = mFileSystem.getMountTable();
    Assert.assertTrue(mountTable.containsKey(MOUNT_POINT3));
    MountPointInfo mountPointInfo5 = mountTable.get(MOUNT_POINT3);
    Assert.assertEquals(UFS_CONF2, mountPointInfo5.getProperties());
}
Also used : MountPOptions(alluxio.grpc.MountPOptions) MountPointInfo(alluxio.wire.MountPointInfo) ConfExpectingUnderFileSystemFactory(alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 4 with ConfExpectingUnderFileSystemFactory

use of alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory in project alluxio by Alluxio.

the class MultiUfsMountIntegrationTest method mountWithUpdatedOptions.

@Test
public void mountWithUpdatedOptions() throws Exception {
    MountPOptions options3 = MountPOptions.newBuilder().putAllProperties(UFS_CONF3).build();
    mFileSystem.mount(mMountPoint3, new AlluxioURI(mUfsUri3), options3);
    Map<String, MountPointInfo> mountTable = mFileSystem.getMountTable();
    Assert.assertTrue(mountTable.containsKey(MOUNT_POINT3));
    MountPointInfo mountPointInfo3 = mountTable.get(MOUNT_POINT3);
    Assert.assertEquals(mUfsUri3, mountPointInfo3.getUfsUri());
    Assert.assertEquals(UFS_CONF3.size(), mountPointInfo3.getProperties().size());
    Assert.assertTrue(mountPointInfo3.getProperties().containsKey(PropertyKey.Name.S3A_ACCESS_KEY));
    Assert.assertNotEquals(UFS_CONF3.get(PropertyKey.Name.S3A_ACCESS_KEY), mountPointInfo3.getProperties().get(PropertyKey.Name.S3A_ACCESS_KEY));
    MountPOptions options4 = MountPOptions.newBuilder().putAllProperties(UFS_CONF2).build();
    UnderFileSystemFactoryRegistry.register(new ConfExpectingUnderFileSystemFactory("ufs3", UFS_CONF2));
    mFileSystem.updateMount(mMountPoint3, options4);
    mountTable = mFileSystem.getMountTable();
    Assert.assertTrue(mountTable.containsKey(MOUNT_POINT3));
    MountPointInfo mountPointInfo4 = mountTable.get(MOUNT_POINT3);
    Assert.assertEquals(UFS_CONF2, mountPointInfo4.getProperties());
}
Also used : MountPOptions(alluxio.grpc.MountPOptions) MountPointInfo(alluxio.wire.MountPointInfo) ConfExpectingUnderFileSystemFactory(alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 5 with ConfExpectingUnderFileSystemFactory

use of alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory in project alluxio by Alluxio.

the class MultiUfsMountIntegrationTest method before.

@Before
public void before() throws Exception {
    mUfsFactory1 = new ConfExpectingUnderFileSystemFactory("ufs1", UFS_CONF1);
    mUfsFactory2 = new ConfExpectingUnderFileSystemFactory("ufs2", UFS_CONF2);
    mUfsFactory3 = new ConfExpectingUnderFileSystemFactory("ufs3", UFS_CONF3);
    mUfsFactory4 = new ConfExpectingUnderFileSystemFactory("ufs4", UFS_CONF4);
    UnderFileSystemFactoryRegistry.register(mUfsFactory1);
    UnderFileSystemFactoryRegistry.register(mUfsFactory2);
    UnderFileSystemFactoryRegistry.register(mUfsFactory3);
    UnderFileSystemFactoryRegistry.register(mUfsFactory4);
    mUfsUri1 = "ufs1://" + mFolder.newFolder().getAbsoluteFile();
    mUfsUri2 = "ufs2://" + mFolder.newFolder().getAbsoluteFile();
    mUfsUri3 = "ufs3://" + mFolder.newFolder().getAbsoluteFile();
    mUfsUri4 = "ufs4://" + mFolder.newFolder().getAbsoluteFile();
    mLocalUfs = new LocalUnderFileSystemFactory().create(mFolder.getRoot().getAbsolutePath(), UnderFileSystemConfiguration.defaults(ServerConfiguration.global()));
    mLocalAlluxioCluster = mLocalAlluxioClusterResource.get();
    mFileSystem = mLocalAlluxioCluster.getClient();
    // Mount ufs1 to /mnt1 with specified options.
    MountPOptions options1 = MountPOptions.newBuilder().putAllProperties(UFS_CONF1).build();
    mFileSystem.mount(mMountPoint1, new AlluxioURI(mUfsUri1), options1);
    // Mount ufs2 to /mnt2 with specified options.
    MountPOptions options2 = MountPOptions.newBuilder().putAllProperties(UFS_CONF2).build();
    mFileSystem.mount(mMountPoint2, new AlluxioURI(mUfsUri2), options2);
}
Also used : LocalUnderFileSystemFactory(alluxio.underfs.local.LocalUnderFileSystemFactory) MountPOptions(alluxio.grpc.MountPOptions) ConfExpectingUnderFileSystemFactory(alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory) AlluxioURI(alluxio.AlluxioURI) Before(org.junit.Before)

Aggregations

AlluxioURI (alluxio.AlluxioURI)7 ConfExpectingUnderFileSystemFactory (alluxio.testutils.underfs.ConfExpectingUnderFileSystemFactory)7 Test (org.junit.Test)6 UnderFileSystemFactoryRegistryRule (alluxio.UnderFileSystemFactoryRegistryRule)4 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)4 Closeable (java.io.Closeable)4 URIStatus (alluxio.client.file.URIStatus)3 MountPOptions (alluxio.grpc.MountPOptions)3 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)2 MountPointInfo (alluxio.wire.MountPointInfo)2 LocalUnderFileSystemFactory (alluxio.underfs.local.LocalUnderFileSystemFactory)1 Before (org.junit.Before)1