Search in sources :

Example 1 with FileSystemAdminShell

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

the class QuorumCommandIntegrationTest method infoAfterElect.

@Test
public void infoAfterElect() 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());
        int success = shell.run("journal", "quorum", "elect", "-address", newLeaderAddr);
        Assert.assertEquals("elect command failed", 0, success);
        mOutput.reset();
        shell.run("journal", "quorum", "info", "-domain", "MASTER");
        String output = mOutput.toString().trim();
        for (MasterNetAddress masterAddr : mCluster.getMasterAddresses()) {
            String expected = String.format(QuorumInfoCommand.OUTPUT_SERVER_INFO, "AVAILABLE", "1", String.format("%s:%d", masterAddr.getHostname(), masterAddr.getEmbeddedJournalPort()));
            Assert.assertTrue(output.contains(expected.trim()));
        }
    }
    mCluster.notifySuccess();
}
Also used : MasterNetAddress(alluxio.multi.process.MasterNetAddress) FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 2 with FileSystemAdminShell

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

the class AddCommandIntegrationTest method overwriteProperty.

@Test
public void overwriteProperty() throws Exception {
    try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
        int ret = shell.run("pathConf", "add", "--property", READ_TYPE_NO_CACHE, "/");
        Assert.assertEquals(0, ret);
        mOutput.reset();
        ret = shell.run("pathConf", "show", "/");
        Assert.assertEquals(0, ret);
        Assert.assertEquals(READ_TYPE_NO_CACHE + "\n", mOutput.toString());
        ret = shell.run("pathConf", "add", "--property", READ_TYPE_CACHE, "/");
        Assert.assertEquals(0, ret);
        mOutput.reset();
        ret = shell.run("pathConf", "show", "/");
        Assert.assertEquals(0, ret);
        Assert.assertEquals(READ_TYPE_CACHE + "\n", mOutput.toString());
    }
}
Also used : FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) Test(org.junit.Test) AbstractShellIntegrationTest(alluxio.client.cli.fs.AbstractShellIntegrationTest)

Example 3 with FileSystemAdminShell

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

the class AddCommandIntegrationTest method immediatelyEffectiveForShellCommands.

@Test
public void immediatelyEffectiveForShellCommands() throws Exception {
    // Tests that after adding some path configuration, it's immediately effective for command
    // line calls afterwards.
    InstancedConfiguration conf = ServerConfiguration.global();
    try (FileSystemShell fsShell = new FileSystemShell(conf);
        FileSystemAdminShell fsAdminShell = new FileSystemAdminShell(conf)) {
        Assert.assertEquals(0, fsAdminShell.run("pathConf", "add", "--property", WRITE_TYPE_THROUGH, PATH1));
        Assert.assertEquals(0, fsAdminShell.run("pathConf", "add", "--property", WRITE_TYPE_CACHE_THROUGH, PATH2));
        FileSystem fs = sLocalAlluxioClusterResource.get().getClient();
        String file = "/file";
        FileSystemTestUtils.createByteFile(fs, file, 100, CreateFilePOptions.getDefaultInstance());
        fs.createDirectory(new AlluxioURI(PATH1), CreateDirectoryPOptions.newBuilder().setRecursive(true).build());
        fs.createDirectory(new AlluxioURI(PATH2), CreateDirectoryPOptions.newBuilder().setRecursive(true).build());
        AlluxioURI target = new AlluxioURI(PATH1 + file);
        Assert.assertEquals(0, fsShell.run("cp", file, target.toString()));
        URIStatus status = fs.getStatus(target);
        Assert.assertEquals(0, status.getInMemoryPercentage());
        Assert.assertEquals(PersistenceState.PERSISTED.toString(), status.getPersistenceState());
        target = new AlluxioURI(PATH2 + file);
        Assert.assertEquals(0, fsShell.run("cp", file, target.toString()));
        status = fs.getStatus(target);
        Assert.assertEquals(100, status.getInMemoryPercentage());
        Assert.assertEquals(PersistenceState.PERSISTED.toString(), status.getPersistenceState());
    }
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) FileSystem(alluxio.client.file.FileSystem) FileSystemShell(alluxio.cli.fs.FileSystemShell) FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AbstractShellIntegrationTest(alluxio.client.cli.fs.AbstractShellIntegrationTest)

Example 4 with FileSystemAdminShell

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

the class AddCommandIntegrationTest method addNoProperty.

@Test
public void addNoProperty() throws Exception {
    try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
        int ret = shell.run("pathConf", "add", "/");
        Assert.assertEquals(0, ret);
    }
}
Also used : FileSystemAdminShell(alluxio.cli.fsadmin.FileSystemAdminShell) Test(org.junit.Test) AbstractShellIntegrationTest(alluxio.client.cli.fs.AbstractShellIntegrationTest)

Example 5 with FileSystemAdminShell

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

the class ShowCommandIntegrationTest method showDir1.

@Test
public void showDir1() throws Exception {
    try (FileSystemAdminShell shell = new FileSystemAdminShell(setPathConfigurations())) {
        int ret = shell.run("pathConf", "show", 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)

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