Search in sources :

Example 56 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class ShellCommandsDUnitTest method testEchoWithVariableAtStart.

@Test
public void testEchoWithVariableAtStart() {
    Gfsh gfshInstance = Gfsh.getCurrentInstance();
    if (gfshInstance == null) {
        fail("In testEcho command gfshInstance is null");
    }
    gfshInstance.setEnvProperty("TESTSYS", "SYS_VALUE");
    printAllEnvs(gfshInstance);
    String command = "echo --string=\"${TESTSYS} Hello World! This is Pivotal\"";
    CommandResult cmdResult = executeCommand(command);
    printCommandOutput(cmdResult);
    if (cmdResult != null) {
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        String stringResult = commandResultToString(cmdResult);
        assertTrue(stringResult.contains("SYS_VALUE Hello World! This is Pivotal"));
    } else {
        fail("testEchoWithVariableAtStart failed");
    }
}
Also used : Gfsh(org.apache.geode.management.internal.cli.shell.Gfsh) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 57 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class ShellCommandsDUnitTest method testEchoAllPropertyVariables.

@Test
public void testEchoAllPropertyVariables() {
    Gfsh gfshInstance = Gfsh.getCurrentInstance();
    if (gfshInstance == null) {
        fail("In testEcho command gfshInstance is null");
    }
    String command = "echo --string=\"$*\"";
    CommandResult cmdResult = executeCommand(command);
    printCommandOutput(cmdResult);
    if (cmdResult != null) {
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testEchoAllPropertyVariables failed");
    }
}
Also used : Gfsh(org.apache.geode.management.internal.cli.shell.Gfsh) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 58 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class ShellCommandsDUnitTest method testDebug.

@Test
public void testDebug() {
    Gfsh gfshInstance = Gfsh.getCurrentInstance();
    if (gfshInstance == null) {
        fail("In testDebug command gfshInstance is null");
    }
    gfshInstance.setDebug(false);
    String command = "debug --state=ON";
    CommandResult cmdResult = executeCommand(command);
    printCommandOutput(cmdResult);
    if (cmdResult != null) {
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testDebug failed");
    }
    assertEquals(gfshInstance.getDebug(), true);
}
Also used : Gfsh(org.apache.geode.management.internal.cli.shell.Gfsh) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 59 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class ShellCommandsDUnitTest method testEchoWithNoVariable.

@Test
public void testEchoWithNoVariable() {
    Gfsh gfshInstance = Gfsh.getCurrentInstance();
    if (gfshInstance == null) {
        fail("In testEcho command gfshInstance is null");
    }
    gfshInstance.setEnvProperty("TESTSYS", "SYS_VALUE");
    printAllEnvs(gfshInstance);
    String command = "echo --string=\"Hello World! This is Pivotal\"";
    CommandResult cmdResult = executeCommand(command);
    printCommandOutput(cmdResult);
    if (cmdResult != null) {
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        String stringResult = commandResultToString(cmdResult);
        assertTrue(stringResult.contains("Hello World! This is Pivotal"));
    } else {
        fail("testEchoWithNoVariable failed");
    }
}
Also used : Gfsh(org.apache.geode.management.internal.cli.shell.Gfsh) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 60 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class ShowMetricsDUnitTest method testShowMetricsRegionFromMember.

@Test
public void testShowMetricsRegionFromMember() throws ClassNotFoundException, IOException, InterruptedException {
    systemSetUp();
    Cache cache = getCache();
    final DistributedMember distributedMember = cache.getDistributedSystem().getDistributedMember();
    final String exportFileName = "regionOnAMemberReport.csv";
    final String regionName = "REGION1";
    SerializableCallable showMetricCmd = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            WaitCriterion wc = createMBeanWaitCriterion(4, regionName, distributedMember, 0);
            waitForCriterion(wc, 5000, 500, true);
            CommandProcessor commandProcessor = new CommandProcessor();
            Result result = commandProcessor.createCommandStatement("show metrics --region=" + regionName + " --member=" + distributedMember.getName() + " --file=" + exportFileName, Collections.EMPTY_MAP).process();
            String resultAsString = commandResultToString((CommandResult) result);
            assertEquals(resultAsString, true, result.getStatus().equals(Status.OK));
            assertTrue(result.hasIncomingFiles());
            result.saveIncomingFiles(null);
            File file = new File(exportFileName);
            file.deleteOnExit();
            assertTrue(file.exists());
            file.delete();
            return resultAsString;
        }
    };
    // Invoke the command in the Manager VM
    final VM managerVm = Host.getHost(0).getVM(0);
    Object managerResultObj = managerVm.invoke(showMetricCmd);
    String managerResult = (String) managerResultObj;
    getLogWriter().info("#SB Manager");
    getLogWriter().info(managerResult);
}
Also used : DistributedMember(org.apache.geode.distributed.DistributedMember) CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) File(java.io.File) Cache(org.apache.geode.cache.Cache) Result(org.apache.geode.management.cli.Result) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)270 Test (org.junit.Test)222 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)208 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)131 Properties (java.util.Properties)94 VM (org.apache.geode.test.dunit.VM)80 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)71 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)67 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)45 File (java.io.File)44 Cache (org.apache.geode.cache.Cache)43 Region (org.apache.geode.cache.Region)39 Category (org.junit.experimental.categories.Category)33 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)32 InternalCache (org.apache.geode.internal.cache.InternalCache)29 DistributedMember (org.apache.geode.distributed.DistributedMember)26 ArrayList (java.util.ArrayList)16 RegionFactory (org.apache.geode.cache.RegionFactory)15 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)15 Gfsh (org.apache.geode.management.internal.cli.shell.Gfsh)14