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