Search in sources :

Example 21 with SystemPropertyRule

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));
    }
}
Also used : SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) Test(org.junit.Test)

Example 22 with SystemPropertyRule

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));
    }
}
Also used : HashMap(java.util.HashMap) SystemPropertyRule(alluxio.SystemPropertyRule) FileOutputStream(java.io.FileOutputStream) Closeable(java.io.Closeable) Properties(java.util.Properties) File(java.io.File) Test(org.junit.Test)

Example 23 with SystemPropertyRule

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();
    }
}
Also used : HashMap(java.util.HashMap) SystemPropertyRule(alluxio.SystemPropertyRule) FileOutputStream(java.io.FileOutputStream) Closeable(java.io.Closeable) Properties(java.util.Properties) File(java.io.File) Test(org.junit.Test)

Example 24 with SystemPropertyRule

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());
    }
}
Also used : HashMap(java.util.HashMap) SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test) FileSystemShellUtilsTest(alluxio.client.cli.fs.FileSystemShellUtilsTest)

Aggregations

SystemPropertyRule (alluxio.SystemPropertyRule)24 Closeable (java.io.Closeable)24 Test (org.junit.Test)24 HashMap (java.util.HashMap)13 File (java.io.File)9 FileOutputStream (java.io.FileOutputStream)6 Properties (java.util.Properties)6 AlluxioURI (alluxio.AlluxioURI)3 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)3 FileSystemShellUtilsTest (alluxio.client.cli.fs.FileSystemShellUtilsTest)3 InstancedConfiguration (alluxio.conf.InstancedConfiguration)2 MasterInquireClient (alluxio.master.MasterInquireClient)2 IOException (java.io.IOException)2 URI (java.net.URI)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ClientContext (alluxio.ClientContext)1 MultiMasterAuthority (alluxio.uri.MultiMasterAuthority)1 ZookeeperAuthority (alluxio.uri.ZookeeperAuthority)1 BufferedWriter (java.io.BufferedWriter)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1