use of alluxio.SystemPropertyRule in project alluxio by Alluxio.
the class InstancedConfigurationTest method systemVariableSubstitution.
@Test
public void systemVariableSubstitution() throws Exception {
try (Closeable p = new SystemPropertyRule(PropertyKey.MASTER_HOSTNAME.toString(), "new_master").toResource()) {
resetConf();
assertEquals("new_master", mConfiguration.get(PropertyKey.MASTER_HOSTNAME));
}
}
use of alluxio.SystemPropertyRule in project alluxio by Alluxio.
the class InstancedConfigurationTest method sitePropertiesNotLoadedInTest.
@Test
public void sitePropertiesNotLoadedInTest() 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().getCanonicalPath());
try (Closeable p = new SystemPropertyRule(sysProps).toResource()) {
mConfiguration = ConfigurationTestUtils.defaults();
assertEquals(PropertyKey.LOGGER_TYPE.getDefaultStringValue(), mConfiguration.get(PropertyKey.LOGGER_TYPE));
}
}
use of alluxio.SystemPropertyRule in project alluxio by Alluxio.
the class InstancedConfigurationTest method setIgnoredPropertiesInSiteProperties.
@Test
public void setIgnoredPropertiesInSiteProperties() throws Exception {
resetConf();
Properties siteProps = new Properties();
siteProps.setProperty(PropertyKey.LOGS_DIR.toString(), "/tmp/logs1");
File propsFile = mFolder.newFile(Constants.SITE_PROPERTIES);
siteProps.store(new FileOutputStream(propsFile), "tmp site properties file");
Map<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()) {
mThrown.expect(IllegalStateException.class);
resetConf();
}
}
use of alluxio.SystemPropertyRule in project alluxio by Alluxio.
the class CopyToLocalCommandIntegrationTest method copyToLocalRelativePath.
@Test
public void copyToLocalRelativePath() throws Exception {
String version = System.getProperty("java.version");
if (version.startsWith("11")) {
// Breaks on Java 11+ because of https://bugs.openjdk.java.net/browse/JDK-8202127
return;
}
HashMap<String, String> sysProps = new HashMap<>();
sysProps.put("user.dir", mTestFolder.getRoot().getAbsolutePath());
try (Closeable p = new SystemPropertyRule(sysProps).toResource()) {
FileSystemTestUtils.createByteFile(sFileSystem, "/testFile", WritePType.MUST_CACHE, 10);
sFsShell.run("copyToLocal", "/testFile", ".");
Assert.assertEquals("Copied /testFile to file://" + mTestFolder.getRoot().getAbsolutePath() + "/testFile" + "\n", mOutput.toString());
mOutput.reset();
sFsShell.run("copyToLocal", "/testFile", "./testFile");
Assert.assertEquals("Copied /testFile to file://" + mTestFolder.getRoot().getAbsolutePath() + "/testFile" + "\n", mOutput.toString());
}
}
Aggregations