Search in sources :

Example 36 with ConfigurationRule

use of alluxio.ConfigurationRule in project alluxio by Alluxio.

the class S3AUnderFileSystemTest method getPermissionsWithMapping.

@Test
public void getPermissionsWithMapping() throws Exception {
    Map<PropertyKey, Object> conf = new HashMap<>();
    conf.put(PropertyKey.UNDERFS_S3_OWNER_ID_TO_USERNAME_MAPPING, "111=altname");
    try (Closeable c = new ConfigurationRule(conf, sConf).toResource()) {
        UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(sConf);
        mS3UnderFileSystem = new S3AUnderFileSystem(new AlluxioURI("s3a://" + BUCKET_NAME), mClient, BUCKET_NAME, mExecutor, mManager, UnderFileSystemConfiguration.defaults(sConf), false);
    }
    Mockito.when(mClient.getS3AccountOwner()).thenReturn(new Owner("111", "test"));
    Mockito.when(mClient.getBucketAcl(Mockito.anyString())).thenReturn(new AccessControlList());
    ObjectUnderFileSystem.ObjectPermissions permissions = mS3UnderFileSystem.getPermissions();
    Assert.assertEquals("altname", permissions.getOwner());
    Assert.assertEquals("altname", permissions.getGroup());
    Assert.assertEquals(0, permissions.getMode());
}
Also used : AccessControlList(com.amazonaws.services.s3.model.AccessControlList) Owner(com.amazonaws.services.s3.model.Owner) HashMap(java.util.HashMap) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Closeable(java.io.Closeable) ObjectUnderFileSystem(alluxio.underfs.ObjectUnderFileSystem) ConfigurationRule(alluxio.ConfigurationRule) PropertyKey(alluxio.conf.PropertyKey) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 37 with ConfigurationRule

use of alluxio.ConfigurationRule in project alluxio by Alluxio.

the class S3AUnderFileSystemTest method getPermissionsNoMapping.

@Test
public void getPermissionsNoMapping() throws Exception {
    Map<PropertyKey, Object> conf = new HashMap<>();
    conf.put(PropertyKey.UNDERFS_S3_OWNER_ID_TO_USERNAME_MAPPING, "111=userid");
    try (Closeable c = new ConfigurationRule(conf, sConf).toResource()) {
        UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(sConf);
        mS3UnderFileSystem = new S3AUnderFileSystem(new AlluxioURI("s3a://" + BUCKET_NAME), mClient, BUCKET_NAME, mExecutor, mManager, UnderFileSystemConfiguration.defaults(sConf), false);
    }
    Mockito.when(mClient.getS3AccountOwner()).thenReturn(new Owner("0", "test"));
    Mockito.when(mClient.getBucketAcl(Mockito.anyString())).thenReturn(new AccessControlList());
    ObjectUnderFileSystem.ObjectPermissions permissions = mS3UnderFileSystem.getPermissions();
    Assert.assertEquals("test", permissions.getOwner());
    Assert.assertEquals("test", permissions.getGroup());
    Assert.assertEquals(0, permissions.getMode());
}
Also used : AccessControlList(com.amazonaws.services.s3.model.AccessControlList) Owner(com.amazonaws.services.s3.model.Owner) HashMap(java.util.HashMap) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Closeable(java.io.Closeable) ObjectUnderFileSystem(alluxio.underfs.ObjectUnderFileSystem) ConfigurationRule(alluxio.ConfigurationRule) PropertyKey(alluxio.conf.PropertyKey) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 38 with ConfigurationRule

use of alluxio.ConfigurationRule in project alluxio by Alluxio.

the class MasterInquireClientTest method zkConnectString.

@Test
public void zkConnectString() throws Exception {
    String zkAddr = "zkAddr:1234";
    String leaderPath = "/my/leader/path";
    try (Closeable c = new ConfigurationRule(new HashMap<PropertyKey, Object>() {

        {
            put(PropertyKey.MASTER_JOURNAL_TYPE, "UFS");
            put(PropertyKey.ZOOKEEPER_ADDRESS, zkAddr);
            put(PropertyKey.ZOOKEEPER_LEADER_PATH, leaderPath);
        }
    }, mConfiguration).toResource()) {
        ConnectDetails singleConnect = new SingleMasterConnectDetails(NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, mConfiguration));
        assertCurrentConnectString(singleConnect);
        try (Closeable c2 = new ConfigurationRule(PropertyKey.ZOOKEEPER_ENABLED, true, mConfiguration).toResource()) {
            ConnectDetails zkConnect = new ZkMasterConnectDetails(zkAddr, leaderPath);
            assertCurrentConnectString(zkConnect);
            assertEquals("zk@zkAddr:1234/my/leader/path", zkConnect.toString());
        }
    }
}
Also used : HashMap(java.util.HashMap) Closeable(java.io.Closeable) ConnectDetails(alluxio.master.MasterInquireClient.ConnectDetails) SingleMasterConnectDetails(alluxio.master.SingleMasterInquireClient.SingleMasterConnectDetails) ZkMasterConnectDetails(alluxio.master.ZkMasterInquireClient.ZkMasterConnectDetails) SingleMasterConnectDetails(alluxio.master.SingleMasterInquireClient.SingleMasterConnectDetails) ZkMasterConnectDetails(alluxio.master.ZkMasterInquireClient.ZkMasterConnectDetails) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Example 39 with ConfigurationRule

use of alluxio.ConfigurationRule in project alluxio by Alluxio.

the class MasterInquireClientTest method singleMasterConnectString.

@Test
public void singleMasterConnectString() throws Exception {
    String host = "testhost";
    int port = 123;
    try (Closeable c = new ConfigurationRule(new HashMap<PropertyKey, Object>() {

        {
            put(PropertyKey.MASTER_HOSTNAME, host);
            put(PropertyKey.MASTER_RPC_PORT, Integer.toString(port));
        }
    }, mConfiguration).toResource()) {
        ConnectDetails cs = new SingleMasterConnectDetails(InetSocketAddress.createUnresolved(host, port));
        assertCurrentConnectString(cs);
        assertEquals("testhost:123", cs.toString());
    }
}
Also used : HashMap(java.util.HashMap) Closeable(java.io.Closeable) ConnectDetails(alluxio.master.MasterInquireClient.ConnectDetails) SingleMasterConnectDetails(alluxio.master.SingleMasterInquireClient.SingleMasterConnectDetails) ZkMasterConnectDetails(alluxio.master.ZkMasterInquireClient.ZkMasterConnectDetails) SingleMasterConnectDetails(alluxio.master.SingleMasterInquireClient.SingleMasterConnectDetails) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Example 40 with ConfigurationRule

use of alluxio.ConfigurationRule in project alluxio by Alluxio.

the class TieredIdentityFactoryTest method notExecutable.

@Test
public void notExecutable() throws Exception {
    File script = mFolder.newFile();
    FileUtils.writeStringToFile(script, "#!/bin/bash");
    try (Closeable c = new ConfigurationRule(ImmutableMap.of(PropertyKey.LOCALITY_SCRIPT, script.getAbsolutePath()), mConfiguration).toResource()) {
        try {
            TieredIdentity identity = TieredIdentityFactory.create(mConfiguration);
        } catch (RuntimeException e) {
            assertThat(e.getMessage(), containsString(script.getAbsolutePath()));
            assertThat(e.getMessage(), containsString("Permission denied"));
        }
    }
}
Also used : TieredIdentity(alluxio.wire.TieredIdentity) Closeable(java.io.Closeable) File(java.io.File) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Aggregations

ConfigurationRule (alluxio.ConfigurationRule)42 Closeable (java.io.Closeable)42 Test (org.junit.Test)40 HashMap (java.util.HashMap)16 File (java.io.File)6 AlluxioURI (alluxio.AlluxioURI)5 PropertyKey (alluxio.conf.PropertyKey)5 SeekableUnderFileInputStream (alluxio.underfs.SeekableUnderFileInputStream)5 TieredIdentity (alluxio.wire.TieredIdentity)5 InputStream (java.io.InputStream)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 UnderFileSystemConfiguration (alluxio.underfs.UnderFileSystemConfiguration)4 LocalityTier (alluxio.wire.TieredIdentity.LocalityTier)4 WorkerNetAddress (alluxio.wire.WorkerNetAddress)4 Random (java.util.Random)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 URIStatus (alluxio.client.file.URIStatus)3 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)2 SetAttributePOptions (alluxio.grpc.SetAttributePOptions)2 ConnectDetails (alluxio.master.MasterInquireClient.ConnectDetails)2