Search in sources :

Example 6 with FileSystemAdminShell

use of alluxio.cli.fsadmin.FileSystemAdminShell in project alluxio by Alluxio.

the class ShowCommandIntegrationTest method showResolveDir1.

@Test
public void showResolveDir1() throws Exception {
    try (FileSystemAdminShell shell = new FileSystemAdminShell(setPathConfigurations())) {
        int ret = shell.run("pathConf", "show", "--all", DIR1);
        Assert.assertEquals(0, ret);
        String expected = format(PROPERTY_KEY11, PROPERTY_VALUE11) + "\n" + format(PROPERTY_KEY12, PROPERTY_VALUE12) + "\n";
        String output = mOutput.toString();
        Assert.assertEquals(expected, output);
    }
}
Also used : FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) Test(org.junit.Test) AbstractShellIntegrationTest(alluxio.client.cli.fs.AbstractShellIntegrationTest)

Example 7 with FileSystemAdminShell

use of alluxio.cli.fsadmin.FileSystemAdminShell in project alluxio by Alluxio.

the class ShowCommandIntegrationTest method showDir2.

@Test
public void showDir2() throws Exception {
    try (FileSystemAdminShell shell = new FileSystemAdminShell(setPathConfigurations())) {
        int ret = shell.run("pathConf", "show", DIR2);
        Assert.assertEquals(0, ret);
        String expected = format(PROPERTY_KEY2, PROPERTY_VALUE2) + "\n";
        String output = mOutput.toString();
        Assert.assertEquals(expected, output);
    }
}
Also used : FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) Test(org.junit.Test) AbstractShellIntegrationTest(alluxio.client.cli.fs.AbstractShellIntegrationTest)

Example 8 with FileSystemAdminShell

use of alluxio.cli.fsadmin.FileSystemAdminShell in project alluxio by Alluxio.

the class ShowCommandIntegrationTest method showDir3.

@Test
public void showDir3() throws Exception {
    try (FileSystemAdminShell shell = new FileSystemAdminShell(setPathConfigurations())) {
        int ret = shell.run("pathConf", "show", DIR3);
        Assert.assertEquals(0, ret);
        String output = mOutput.toString();
        Assert.assertEquals("", output);
    }
}
Also used : FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) Test(org.junit.Test) AbstractShellIntegrationTest(alluxio.client.cli.fs.AbstractShellIntegrationTest)

Example 9 with FileSystemAdminShell

use of alluxio.cli.fsadmin.FileSystemAdminShell in project alluxio by Alluxio.

the class ShowCommandIntegrationTest method showResolveDir2.

@Test
public void showResolveDir2() throws Exception {
    try (FileSystemAdminShell shell = new FileSystemAdminShell(setPathConfigurations())) {
        int ret = shell.run("pathConf", "show", "--all", DIR2);
        Assert.assertEquals(0, ret);
        String expected = format(PROPERTY_KEY11, PROPERTY_VALUE11) + "\n" + format(PROPERTY_KEY2, PROPERTY_VALUE2) + "\n";
        String output = mOutput.toString();
        Assert.assertEquals(expected, output);
    }
}
Also used : FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) Test(org.junit.Test) AbstractShellIntegrationTest(alluxio.client.cli.fs.AbstractShellIntegrationTest)

Example 10 with FileSystemAdminShell

use of alluxio.cli.fsadmin.FileSystemAdminShell in project alluxio by Alluxio.

the class QuorumCommandIntegrationTest method quorumRemove.

@Test
public void quorumRemove() throws Exception {
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.QUORUM_SHELL_REMOVE).setClusterName("QuorumShellRemove").setNumMasters(5).setNumWorkers(0).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).addProperty(PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS, "5min").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MIN_ELECTION_TIMEOUT, "750ms").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT, "1500ms").build();
    mCluster.start();
    String output;
    try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
        AlluxioURI testDir = new AlluxioURI("/testDir");
        mCluster.getFileSystemClient().createDirectory(testDir);
        // Verify cluster is reachable.
        Assert.assertTrue(mCluster.getFileSystemClient().exists(testDir));
        // Validate quorum state is updated as expected after shutting down 2 masters.
        mCluster.stopMaster(0);
        mCluster.stopMaster(1);
        // Verify cluster is reachable.
        Assert.assertTrue(mCluster.getFileSystemClient().exists(testDir));
        // Wait for up to 2 election timeouts until quorum notices changes.
        CommonUtils.waitFor("Quorum noticing change.", () -> {
            try {
                return mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().stream().filter((info) -> info.getServerState() == QuorumServerState.UNAVAILABLE).collect(Collectors.toList()).size() == 2;
            } catch (Exception e) {
                return false;
            }
        }, WaitForOptions.defaults().setTimeoutMs(6 * (int) ServerConfiguration.getMs(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT)));
        // Remove unavailable masters using shell.
        for (QuorumServerInfo serverInfo : mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList()) {
            if (serverInfo.getServerState() == QuorumServerState.UNAVAILABLE) {
                mOutput.reset();
                String serverAddress = String.format("%s:%d", serverInfo.getServerAddress().getHost(), serverInfo.getServerAddress().getRpcPort());
                shell.run("journal", "quorum", "remove", "-domain", "MASTER", "-address", serverAddress);
                output = mOutput.toString().trim();
                Assert.assertEquals(String.format(QuorumRemoveCommand.OUTPUT_RESULT, serverAddress, JournalDomain.MASTER.name()), lastLine(output));
            }
        }
        // Verify quorum size is resized down to 3 after removing 2 masters.
        Assert.assertEquals(3, mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().size());
        mCluster.stopMaster(2);
        // Verify cluster is reachable.
        Assert.assertTrue(mCluster.getFileSystemClient().exists(testDir));
    }
    mCluster.notifySuccess();
}
Also used : Arrays(java.util.Arrays) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MultiProcessCluster(alluxio.multi.process.MultiProcessCluster) QuorumCommand(alluxio.cli.fsadmin.journal.QuorumCommand) MasterNetAddress(alluxio.multi.process.MasterNetAddress) QuorumInfoCommand(alluxio.cli.fsadmin.journal.QuorumInfoCommand) PropertyKey(alluxio.conf.PropertyKey) FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) WaitForOptions(alluxio.util.WaitForOptions) JournalType(alluxio.master.journal.JournalType) ConfigurationRule(alluxio.ConfigurationRule) QuorumElectCommand(alluxio.cli.fsadmin.journal.QuorumElectCommand) QuorumServerState(alluxio.grpc.QuorumServerState) AlluxioURI(alluxio.AlluxioURI) After(org.junit.After) PortCoordination(alluxio.multi.process.PortCoordination) SystemOutRule(alluxio.SystemOutRule) JournalDomain(alluxio.grpc.JournalDomain) ExpectedException(org.junit.rules.ExpectedException) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) QuorumServerInfo(alluxio.grpc.QuorumServerInfo) ServerConfiguration(alluxio.conf.ServerConfiguration) ExceptionMessage(alluxio.exception.ExceptionMessage) Test(org.junit.Test) Collectors(java.util.stream.Collectors) Rule(org.junit.Rule) QuorumRemoveCommand(alluxio.cli.fsadmin.journal.QuorumRemoveCommand) SystemErrRule(alluxio.SystemErrRule) Assert(org.junit.Assert) CommonUtils(alluxio.util.CommonUtils) QuorumServerInfo(alluxio.grpc.QuorumServerInfo) FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) ExpectedException(org.junit.rules.ExpectedException) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Aggregations

FileSystemAdminShell (alluxio.cli.fsadmin.FileSystemAdminShell)23 Test (org.junit.Test)22 AbstractShellIntegrationTest (alluxio.client.cli.fs.AbstractShellIntegrationTest)17 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)5 MasterNetAddress (alluxio.multi.process.MasterNetAddress)3 AlluxioURI (alluxio.AlluxioURI)2 PropertyKey (alluxio.conf.PropertyKey)2 ConfigurationRule (alluxio.ConfigurationRule)1 SystemErrRule (alluxio.SystemErrRule)1 SystemOutRule (alluxio.SystemOutRule)1 FileSystemShell (alluxio.cli.fs.FileSystemShell)1 QuorumCommand (alluxio.cli.fsadmin.journal.QuorumCommand)1 QuorumElectCommand (alluxio.cli.fsadmin.journal.QuorumElectCommand)1 QuorumInfoCommand (alluxio.cli.fsadmin.journal.QuorumInfoCommand)1 QuorumRemoveCommand (alluxio.cli.fsadmin.journal.QuorumRemoveCommand)1 FileSystem (alluxio.client.file.FileSystem)1 URIStatus (alluxio.client.file.URIStatus)1 InstancedConfiguration (alluxio.conf.InstancedConfiguration)1 ServerConfiguration (alluxio.conf.ServerConfiguration)1 ExceptionMessage (alluxio.exception.ExceptionMessage)1