Search in sources :

Example 11 with SystemPropertyRule

use of alluxio.SystemPropertyRule in project alluxio by Alluxio.

the class FileSystemFactoryTest method multiMasterFileSystemCacheTest.

@Test
public void multiMasterFileSystemCacheTest() {
    try (Closeable p = new SystemPropertyRule(PropertyKey.MASTER_RPC_ADDRESSES.getName(), "192.168.0.1:1234,192.168.0.2:1445,192.168.0.3:9943").toResource()) {
        ConfigurationUtils.reloadProperties();
        InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
        MasterInquireClient.ConnectDetails connectDetails = MasterInquireClient.Factory.getConnectDetails(conf);
        // Make sure we have a MultiMaster authority
        assertTrue(connectDetails.toAuthority() instanceof MultiMasterAuthority);
        fileSystemCacheTest();
    } catch (IOException e) {
        fail("Unable to set system properties");
    }
}
Also used : MasterInquireClient(alluxio.master.MasterInquireClient) InstancedConfiguration(alluxio.conf.InstancedConfiguration) MultiMasterAuthority(alluxio.uri.MultiMasterAuthority) SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) IOException(java.io.IOException) Test(org.junit.Test)

Example 12 with SystemPropertyRule

use of alluxio.SystemPropertyRule in project alluxio by Alluxio.

the class CopyToLocalCommandIntegrationTest method copyToLocalRelativePathDir.

@Test
public void copyToLocalRelativePathDir() 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;
    }
    FileSystemTestUtils.createByteFile(sFileSystem, "/testFile", WritePType.MUST_CACHE, 10);
    HashMap<String, String> sysProps = new HashMap<>();
    sysProps.put("user.dir", mTestFolder.getRoot().getAbsolutePath());
    try (Closeable p = new SystemPropertyRule(sysProps).toResource()) {
        File localDir = mTestFolder.newFolder("localDir");
        localDir.mkdir();
        sFsShell.run("copyToLocal", "/testFile", "localDir");
        Assert.assertEquals("Copied /testFile to file://" + mTestFolder.getRoot().getAbsolutePath() + "/localDir/testFile" + "\n", mOutput.toString());
    }
}
Also used : HashMap(java.util.HashMap) SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) File(java.io.File) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test) FileSystemShellUtilsTest(alluxio.client.cli.fs.FileSystemShellUtilsTest)

Example 13 with SystemPropertyRule

use of alluxio.SystemPropertyRule in project alluxio by Alluxio.

the class GetConfTest method getConfWithInvalidConf.

@Test
public void getConfWithInvalidConf() throws Exception {
    try (Closeable p = new SystemPropertyRule(ImmutableMap.of(PropertyKey.CONF_VALIDATION_ENABLED.toString(), "false", PropertyKey.ZOOKEEPER_ENABLED.toString(), "true")).toResource()) {
        ServerConfiguration.reset();
        ClientContext ctx = ClientContext.create(ServerConfiguration.global());
        assertEquals(0, GetConf.getConf(ctx, PropertyKey.ZOOKEEPER_ENABLED.toString()));
        assertEquals("true\n", mOutputStream.toString());
    } finally {
        ServerConfiguration.reset();
    }
}
Also used : SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) ClientContext(alluxio.ClientContext) Test(org.junit.Test)

Example 14 with SystemPropertyRule

use of alluxio.SystemPropertyRule in project alluxio by Alluxio.

the class CopyFromLocalCommandIntegrationTest method copyFromLocalRelativePath.

@Test
public void copyFromLocalRelativePath() 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()) {
        File localDir = mTestFolder.newFolder("testDir");
        generateRelativeFileContent(localDir.getPath() + "/testFile", BufferUtils.getIncreasingByteArray(10));
        int ret = sFsShell.run("copyFromLocal", "testDir/testFile", "/testFile");
        Assert.assertEquals(0, ret);
        Assert.assertTrue(fileExists(new AlluxioURI(("/testFile"))));
    }
}
Also used : HashMap(java.util.HashMap) SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test) FileSystemShellUtilsTest(alluxio.client.cli.fs.FileSystemShellUtilsTest)

Example 15 with SystemPropertyRule

use of alluxio.SystemPropertyRule in project alluxio by Alluxio.

the class AbstractFileSystemTest method initializeWithZookeeperSystemProperties.

@Test
public void initializeWithZookeeperSystemProperties() throws Exception {
    HashMap<String, String> sysProps = new HashMap<>();
    sysProps.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), "true");
    sysProps.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), "zkHost:2181");
    try (Closeable p = new SystemPropertyRule(sysProps).toResource()) {
        ConfigurationUtils.reloadProperties();
        URI uri = URI.create("alluxio:///");
        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));
    }
}
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)

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