Search in sources :

Example 1 with SystemPropertyRule

use of alluxio.SystemPropertyRule in project alluxio by Alluxio.

the class AbstractFileSystemTest method initializeWithZookeeperUriAndSystemProperty.

@Test
public void initializeWithZookeeperUriAndSystemProperty() throws Exception {
    // those in the URI has the highest priority.
    try (Closeable p = new SystemPropertyRule(PropertyKey.ZOOKEEPER_ENABLED.getName(), "false").toResource()) {
        ConfigurationUtils.reloadProperties();
        URI uri = URI.create("alluxio://zk@zkHost:2181");
        FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf()));
        assertTrue(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED));
        assertEquals("zkHost:2181", fs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS));
        fs.close();
    }
    HashMap<String, String> sysProps = new HashMap<>();
    sysProps.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), "true");
    sysProps.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), "zkHost1:2181");
    try (Closeable p = new SystemPropertyRule(sysProps).toResource()) {
        ConfigurationUtils.reloadProperties();
        URI uri = URI.create("alluxio://zk@zkHost2:2181");
        FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf()));
        assertTrue(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED));
        assertEquals("zkHost2:2181", fs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS));
        fs.close();
    }
    ConfigurationUtils.reloadProperties();
}
Also used : HashMap(java.util.HashMap) SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) URI(java.net.URI) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with SystemPropertyRule

use of alluxio.SystemPropertyRule in project alluxio by Alluxio.

the class InstancedConfigurationTest method alias.

@Test
public void alias() throws Exception {
    try (Closeable p = new SystemPropertyRule("alluxio.master.worker.timeout.ms", "100").toResource()) {
        resetConf();
        assertEquals(100, mConfiguration.getMs(PropertyKey.MASTER_WORKER_TIMEOUT_MS));
    }
}
Also used : SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) Test(org.junit.Test)

Example 3 with SystemPropertyRule

use of alluxio.SystemPropertyRule in project alluxio by Alluxio.

the class InstancedConfigurationTest method wrongTieredStorageLevel.

@Test
public void wrongTieredStorageLevel() throws Exception {
    try (Closeable p = new SystemPropertyRule(ImmutableMap.of("alluxio.master.tieredstore.global.levels", "1", "alluxio.worker.tieredstore.levels", "2")).toResource()) {
        resetConf();
        mConfiguration.validate();
        fail("Should have thrown a runtime exception when setting an unknown tier level");
    } catch (RuntimeException e) {
        assertTrue(e.getMessage().contains(String.format("%s tiers on worker (configured by %s), larger than global %s tiers " + "(configured by %s) ", 2, PropertyKey.WORKER_TIERED_STORE_LEVELS, 1, PropertyKey.MASTER_TIERED_STORE_GLOBAL_LEVELS)));
    }
}
Also used : SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) Test(org.junit.Test)

Example 4 with SystemPropertyRule

use of alluxio.SystemPropertyRule in project alluxio by Alluxio.

the class InstancedConfigurationTest method systemPropertySubstitution.

@Test
public void systemPropertySubstitution() throws Exception {
    try (Closeable p = new SystemPropertyRule("user.home", "/home").toResource()) {
        resetConf();
        mConfiguration.set(PropertyKey.WORK_DIR, "${user.home}/work");
        assertEquals("/home/work", mConfiguration.get(PropertyKey.WORK_DIR));
    }
}
Also used : SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) Test(org.junit.Test)

Example 5 with SystemPropertyRule

use of alluxio.SystemPropertyRule in project alluxio by Alluxio.

the class InstancedConfigurationTest method initConfWithExtenstionProperty.

@Test
public void initConfWithExtenstionProperty() throws Exception {
    try (Closeable p = new SystemPropertyRule("alluxio.master.journal.ufs.option.fs.obs.endpoint", "foo").toResource()) {
        resetConf();
        assertEquals("foo", mConfiguration.get(Template.MASTER_JOURNAL_UFS_OPTION_PROPERTY.format("fs.obs.endpoint")));
    }
}
Also used : SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) Test(org.junit.Test)

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