Search in sources :

Example 11 with FileSystemAdminShell

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

the class QuorumCommandIntegrationTest method elect.

@Test
public void elect() throws Exception {
    final int MASTER_INDEX_WAIT_TIME = 5_000;
    int numMasters = 3;
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.QUORUM_SHELL_REMOVE).setClusterName("QuorumShellElect").setNumMasters(numMasters).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();
    try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
        int newLeaderIdx = (mCluster.getPrimaryMasterIndex(MASTER_INDEX_WAIT_TIME) + 1) % numMasters;
        // `getPrimaryMasterIndex` uses the same `mMasterAddresses` variable as getMasterAddresses
        // we can therefore access to the new leader's address this ways
        MasterNetAddress netAddress = mCluster.getMasterAddresses().get(newLeaderIdx);
        String newLeaderAddr = String.format("%s:%s", netAddress.getHostname(), netAddress.getEmbeddedJournalPort());
        mOutput.reset();
        shell.run("journal", "quorum", "elect", "-address", newLeaderAddr);
        String output = mOutput.toString().trim();
        String expected = String.format("%s\n%s\n%s\n%s", String.format(QuorumElectCommand.TRANSFER_INIT, newLeaderAddr), String.format(QuorumElectCommand.TRANSFER_SUCCESS, newLeaderAddr), String.format(QuorumElectCommand.RESET_INIT, "successful"), QuorumElectCommand.RESET_SUCCESS);
        Assert.assertEquals(expected, output);
    }
    mCluster.notifySuccess();
}
Also used : MasterNetAddress(alluxio.multi.process.MasterNetAddress) FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 12 with FileSystemAdminShell

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

the class QuorumCommandIntegrationTest method quorumCommand.

@Test
public void quorumCommand() throws Exception {
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.QUORUM_SHELL).setClusterName("QuorumShell").setNumMasters(3).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();
    try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
        String output;
        // Validate quorum sub-commands are validated.
        mOutput.reset();
        shell.run("journal", "quorum", "nonexistentCommand");
        output = mOutput.toString().trim();
        Assert.assertEquals(QuorumCommand.description(), lastLine(output));
        // Validate option counts are validated for "quorum info"
        mOutput.reset();
        shell.run("journal", "quorum", "info");
        output = mOutput.toString().trim();
        Assert.assertEquals(QuorumInfoCommand.description(), lastLine(output));
        mOutput.reset();
        shell.run("journal", "quorum", "info", "-op1", "val1", "-op2", "val2");
        output = mOutput.toString().trim();
        Assert.assertEquals(QuorumInfoCommand.description(), lastLine(output));
        // Validate option counts are validated for "quorum", "remove"
        mOutput.reset();
        shell.run("journal", "quorum", "remove");
        output = mOutput.toString().trim();
        Assert.assertEquals(QuorumRemoveCommand.description(), lastLine(output));
        mOutput.reset();
        shell.run("journal", "quorum", "remove", "-op1", "val1");
        output = mOutput.toString().trim();
        Assert.assertEquals(QuorumRemoveCommand.description(), lastLine(output));
        mOutput.reset();
        shell.run("journal", "quorum", "remove", "-op1", "val1", "-op2", "val2", "-op3", "val3");
        output = mOutput.toString().trim();
        Assert.assertEquals(QuorumRemoveCommand.description(), lastLine(output));
        // Validate option counts are validated for "quorum", "elect"
        mOutput.reset();
        shell.run("journal", "quorum", "elect");
        output = mOutput.toString().trim();
        Assert.assertEquals(QuorumElectCommand.description(), lastLine(output));
        mOutput.reset();
        shell.run("journal", "quorum", "elect", "-op1", "val1");
        output = mOutput.toString().trim();
        Assert.assertEquals(QuorumElectCommand.description(), lastLine(output));
        mOutput.reset();
        shell.run("journal", "quorum", "elect", "-op1", "val1", "-op2", "val2", "-op3", "val3");
        output = mOutput.toString().trim();
        Assert.assertEquals(QuorumElectCommand.description(), lastLine(output));
        // Validate option validation works for "quorum info".
        mOutput.reset();
        shell.run("journal", "quorum", "info", "-domain", "UNKNOWN");
        output = mOutput.toString().trim();
        Assert.assertEquals(ExceptionMessage.INVALID_OPTION_VALUE.getMessage(QuorumInfoCommand.DOMAIN_OPTION_NAME, Arrays.toString(JournalDomain.values())), output);
        // Validate option validation works for "journal quorum remove"
        // Validate -domain is validated.
        mOutput.reset();
        shell.run("journal", "quorum", "remove", "-domain", "UNKNOWN", "-address", "host:0");
        output = mOutput.toString().trim();
        Assert.assertEquals(ExceptionMessage.INVALID_OPTION_VALUE.getMessage(QuorumInfoCommand.DOMAIN_OPTION_NAME, Arrays.toString(JournalDomain.values())), output);
        // Validate -address is validated.
        mOutput.reset();
        shell.run("journal", "quorum", "remove", "-domain", "JOB_MASTER", "-address", "hostname:invalid_port");
        output = mOutput.toString().trim();
        Assert.assertEquals(ExceptionMessage.INVALID_ADDRESS_VALUE.getMessage(), output);
        // Validate -address is validated for transferLeader.
        mOutput.reset();
        shell.run("journal", "quorum", "elect", "-address", "hostname:invalid_port");
        output = mOutput.toString().trim();
        Assert.assertEquals(ExceptionMessage.INVALID_ADDRESS_VALUE.getMessage(), output);
    }
    mCluster.notifySuccess();
}
Also used : FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 13 with FileSystemAdminShell

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

the class QuorumCommandIntegrationTest method quorumInfo.

@Test
public void quorumInfo() throws Exception {
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.QUORUM_SHELL_INFO).setClusterName("QuorumShellInfo").setNumMasters(3).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())) {
        // Validate quorum state is dumped as expected.
        mOutput.reset();
        shell.run("journal", "quorum", "info", "-domain", "MASTER");
        output = mOutput.toString().trim();
        Assert.assertTrue(output.contains(String.format(QuorumInfoCommand.OUTPUT_HEADER_DOMAIN, JournalDomain.MASTER.name())));
        Assert.assertTrue(output.contains(String.format(QuorumInfoCommand.OUTPUT_HEADER_QUORUM_SIZE, 3)));
        String journalAddresses = ServerConfiguration.getString(PropertyKey.MASTER_EMBEDDED_JOURNAL_ADDRESSES);
        for (String address : journalAddresses.split(",")) {
            String format = String.format(QuorumInfoCommand.OUTPUT_SERVER_INFO, QuorumServerState.AVAILABLE.name(), "0", address).trim();
            Assert.assertTrue(output.contains(format));
        }
        // Validate quorum state is updated as expected after a fail-over.
        mCluster.stopMaster(0);
        // Wait for up to 2 election timeouts until quorum notices the change.
        // Use shell "quorum info" for validation.
        CommonUtils.waitFor("Quorum noticing change.", () -> {
            mOutput.reset();
            shell.run("journal", "quorum", "info", "-domain", "MASTER");
            return mOutput.toString().trim().contains(QuorumServerState.UNAVAILABLE.name());
        }, WaitForOptions.defaults().setTimeoutMs(2 * (int) ServerConfiguration.getMs(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT)));
    }
    mCluster.notifySuccess();
}
Also used : FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 14 with FileSystemAdminShell

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

the class AddCommandIntegrationTest method add.

@Test
public void add() throws Exception {
    try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
        int ret = shell.run("pathConf", "list");
        Assert.assertEquals(0, ret);
        String output = mOutput.toString();
        Assert.assertEquals("", output);
        ret = shell.run("pathConf", "show", PATH1);
        Assert.assertEquals(0, ret);
        output = mOutput.toString();
        Assert.assertEquals("", output);
        mOutput.reset();
        ret = shell.run("pathConf", "show", PATH2);
        Assert.assertEquals(0, ret);
        output = mOutput.toString();
        Assert.assertEquals("", output);
        mOutput.reset();
        ret = shell.run("pathConf", "add", "--property", READ_TYPE_NO_CACHE, "--property", WRITE_TYPE_CACHE_THROUGH, PATH1);
        Assert.assertEquals(0, ret);
        output = mOutput.toString();
        Assert.assertEquals("", output);
        mOutput.reset();
        ret = shell.run("pathConf", "list");
        Assert.assertEquals(0, ret);
        output = mOutput.toString();
        Assert.assertEquals(PATH1 + "\n", output);
        mOutput.reset();
        ret = shell.run("pathConf", "add", "--property", WRITE_TYPE_THROUGH, PATH2);
        Assert.assertEquals(0, ret);
        output = mOutput.toString();
        Assert.assertEquals("", output);
        mOutput.reset();
        ret = shell.run("pathConf", "list");
        Assert.assertEquals(0, ret);
        output = mOutput.toString();
        Assert.assertEquals(PATH1 + "\n" + PATH2 + "\n", output);
        mOutput.reset();
        ret = shell.run("pathConf", "show", PATH1);
        Assert.assertEquals(0, ret);
        String expected = READ_TYPE_NO_CACHE + "\n" + WRITE_TYPE_CACHE_THROUGH + "\n";
        output = mOutput.toString();
        Assert.assertEquals(expected, output);
        mOutput.reset();
        ret = shell.run("pathConf", "show", PATH2);
        Assert.assertEquals(0, ret);
        expected = WRITE_TYPE_THROUGH + "\n";
        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 15 with FileSystemAdminShell

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

the class AddCommandIntegrationTest method nonClientScopeKey.

@Test
public void nonClientScopeKey() throws Exception {
    try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
        PropertyKey key = PropertyKey.NETWORK_CONNECTION_SERVER_SHUTDOWN_TIMEOUT;
        int ret = shell.run("pathConf", "add", "--property", format(key, "10ms"), "/");
        Assert.assertEquals(-1, ret);
        String output = mOutput.toString();
        Assert.assertEquals(AddCommand.nonClientScopePropertyException(key) + "\n", output);
    }
}
Also used : FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) PropertyKey(alluxio.conf.PropertyKey) Test(org.junit.Test) AbstractShellIntegrationTest(alluxio.client.cli.fs.AbstractShellIntegrationTest)

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