use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class TieredIdentityFactoryTest method fromScriptClasspath.
@Test
public void fromScriptClasspath() throws Exception {
String customScriptName = "my-alluxio-locality.sh";
File dir = mFolder.newFolder("fromScriptClasspath");
CommonUtils.classLoadURL(dir.getCanonicalPath());
File script = new File(dir, customScriptName);
setupScript("node=myhost,rack=myrack,custom=mycustom", script);
try (Closeable c = new ConfigurationRule(ImmutableMap.of(PropertyKey.LOCALITY_ORDER, "node,rack,custom", PropertyKey.LOCALITY_SCRIPT, customScriptName), mConfiguration).toResource()) {
TieredIdentity identity = TieredIdentityFactory.create(mConfiguration);
TieredIdentity expected = new TieredIdentity(Arrays.asList(new LocalityTier("node", "myhost"), new LocalityTier("rack", "myrack"), new LocalityTier("custom", "mycustom")));
assertEquals(expected, identity);
}
script.delete();
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class TieredIdentityFactoryTest method outOfOrderScript.
@Test
public void outOfOrderScript() throws Exception {
String scriptPath = setupScript("rack=myrack,node=myhost", mFolder.newFile());
try (Closeable c = new ConfigurationRule(ImmutableMap.of(PropertyKey.LOCALITY_SCRIPT, scriptPath), mConfiguration).toResource()) {
TieredIdentity identity = TieredIdentityFactory.create(mConfiguration);
TieredIdentity expected = new TieredIdentity(Arrays.asList(new LocalityTier("node", "myhost"), new LocalityTier("rack", "myrack")));
assertEquals(expected, identity);
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class UnderFileSystemConfigurationTest method getValueWhenGlobalConfHasProperty.
@Test
public void getValueWhenGlobalConfHasProperty() throws Exception {
// Set property in global configuration
try (Closeable c = new ConfigurationRule(PropertyKey.S3A_ACCESS_KEY, "bar", mConfiguration).toResource()) {
Random random = new Random();
boolean readOnly = random.nextBoolean();
boolean shared = random.nextBoolean();
UnderFileSystemConfiguration conf = UnderFileSystemConfiguration.defaults(ConfigurationTestUtils.defaults()).setReadOnly(readOnly).setShared(shared);
assertEquals(readOnly, conf.isReadOnly());
assertEquals(shared, conf.isShared());
assertEquals("bar", mConfiguration.get(PropertyKey.S3A_ACCESS_KEY));
conf = UnderFileSystemConfiguration.defaults(ConfigurationTestUtils.defaults()).setReadOnly(readOnly).setShared(shared).createMountSpecificConf(ImmutableMap.of(PropertyKey.S3A_ACCESS_KEY.toString(), "foo"));
assertEquals(readOnly, conf.isReadOnly());
assertEquals(shared, conf.isShared());
assertEquals("foo", conf.get(PropertyKey.S3A_ACCESS_KEY));
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class UnderFileSystemConfigurationTest method getValueWhenGlobalConfHasNotProperty.
@Test
public void getValueWhenGlobalConfHasNotProperty() throws Exception {
// Set property in global configuration
try (Closeable c = new ConfigurationRule(PropertyKey.S3A_ACCESS_KEY, null, mConfiguration).toResource()) {
Random random = new Random();
boolean readOnly = random.nextBoolean();
boolean shared = random.nextBoolean();
UnderFileSystemConfiguration conf = UnderFileSystemConfiguration.defaults(mConfiguration).setReadOnly(readOnly).setShared(shared);
try {
conf.get(PropertyKey.S3A_ACCESS_KEY);
fail("this key should not exist");
} catch (Exception e) {
// expect to pass
}
UnderFileSystemConfiguration conf2 = conf.createMountSpecificConf(ImmutableMap.of(PropertyKey.S3A_ACCESS_KEY.toString(), "foo"));
assertEquals(readOnly, conf2.isReadOnly());
assertEquals(shared, conf2.isShared());
assertEquals("foo", conf2.get(PropertyKey.S3A_ACCESS_KEY));
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class UnderFileSystemConfigurationTest method containsWhenGlobalConfHasNotProperty.
@Test
public void containsWhenGlobalConfHasNotProperty() throws Exception {
// Unset property in global configuration
try (Closeable c = new ConfigurationRule(PropertyKey.S3A_ACCESS_KEY, null, mConfiguration).toResource()) {
Random random = new Random();
boolean readOnly = random.nextBoolean();
boolean shared = random.nextBoolean();
UnderFileSystemConfiguration conf = UnderFileSystemConfiguration.defaults(mConfiguration).setReadOnly(readOnly).setShared(shared);
assertFalse(conf.isSet(PropertyKey.S3A_ACCESS_KEY));
UnderFileSystemConfiguration conf2 = conf.createMountSpecificConf(ImmutableMap.of(PropertyKey.S3A_ACCESS_KEY.toString(), "foo"));
assertEquals(readOnly, conf2.isReadOnly());
assertEquals(shared, conf2.isShared());
assertTrue(conf2.isSet(PropertyKey.S3A_ACCESS_KEY));
}
}
Aggregations