use of alluxio.SystemPropertyRule in project alluxio by Alluxio.
the class FileSystemFactoryTest method zkFileSystemCacheTest.
@Test
public void zkFileSystemCacheTest() {
Map<String, String> sysProps = new HashMap<>();
sysProps.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), Boolean.toString(true));
sysProps.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), "zk@192.168.0.5");
sysProps.put(PropertyKey.ZOOKEEPER_ELECTION_PATH.getName(), "/alluxio/leader");
try (Closeable p = new SystemPropertyRule(sysProps).toResource()) {
ConfigurationUtils.reloadProperties();
InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
MasterInquireClient.ConnectDetails connectDetails = MasterInquireClient.Factory.getConnectDetails(conf);
// Make sure we have a Zookeeper authority
assertTrue(connectDetails.toAuthority() instanceof ZookeeperAuthority);
fileSystemCacheTest();
} catch (IOException e) {
fail("Unable to set system properties");
}
}
use of alluxio.SystemPropertyRule in project alluxio by Alluxio.
the class InstancedConfigurationTest method noWhitespaceTrailingInSiteProperties.
@Test
public void noWhitespaceTrailingInSiteProperties() throws Exception {
Properties siteProps = new Properties();
siteProps.setProperty(PropertyKey.MASTER_HOSTNAME.toString(), " host-1 ");
siteProps.setProperty(PropertyKey.WEB_THREADS.toString(), "\t123\t");
File propsFile = mFolder.newFile(Constants.SITE_PROPERTIES);
siteProps.store(new FileOutputStream(propsFile), "tmp site properties file");
// Avoid interference from system properties. Reset SITE_CONF_DIR to include the temp
// site-properties file
HashMap<String, String> sysProps = new HashMap<>();
sysProps.put(PropertyKey.SITE_CONF_DIR.toString(), mFolder.getRoot().getAbsolutePath());
sysProps.put(PropertyKey.TEST_MODE.toString(), "false");
try (Closeable p = new SystemPropertyRule(sysProps).toResource()) {
resetConf();
assertEquals("host-1", mConfiguration.get(PropertyKey.MASTER_HOSTNAME));
assertEquals("123", mConfiguration.get(PropertyKey.WEB_THREADS));
}
}
use of alluxio.SystemPropertyRule in project alluxio by Alluxio.
the class InstancedConfigurationTest method defaultLoggerCorrectlyLoaded.
@Test
public void defaultLoggerCorrectlyLoaded() throws Exception {
// Avoid interference from system properties. site-properties will not be loaded during tests
try (Closeable p = new SystemPropertyRule(PropertyKey.LOGGER_TYPE.toString(), null).toResource()) {
String loggerType = mConfiguration.getString(PropertyKey.LOGGER_TYPE);
assertEquals("Console", loggerType);
}
}
use of alluxio.SystemPropertyRule in project alluxio by Alluxio.
the class InstancedConfigurationTest method sitePropertiesLoadedNotInTest.
@Test
public void sitePropertiesLoadedNotInTest() throws Exception {
Properties props = new Properties();
props.setProperty(PropertyKey.LOGGER_TYPE.toString(), "TEST_LOGGER");
File propsFile = mFolder.newFile(Constants.SITE_PROPERTIES);
props.store(new FileOutputStream(propsFile), "ignored header");
// Avoid interference from system properties. Reset SITE_CONF_DIR to include the temp
// site-properties file
HashMap<String, String> sysProps = new HashMap<>();
sysProps.put(PropertyKey.LOGGER_TYPE.toString(), null);
sysProps.put(PropertyKey.SITE_CONF_DIR.toString(), mFolder.getRoot().getAbsolutePath());
sysProps.put(PropertyKey.TEST_MODE.toString(), "false");
try (Closeable p = new SystemPropertyRule(sysProps).toResource()) {
resetConf();
assertEquals("TEST_LOGGER", mConfiguration.get(PropertyKey.LOGGER_TYPE));
}
}
use of alluxio.SystemPropertyRule in project alluxio by Alluxio.
the class InstancedConfigurationTest method noPropertiesAnywhere.
@Test
public void noPropertiesAnywhere() throws Exception {
try (Closeable p = new SystemPropertyRule(PropertyKey.TEST_MODE.toString(), "false").toResource()) {
mConfiguration.unset(PropertyKey.SITE_CONF_DIR);
resetConf();
assertEquals("0.0.0.0", mConfiguration.get(PropertyKey.PROXY_WEB_BIND_HOST));
}
}
Aggregations