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");
}
}
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");
}
}
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);
}
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");
}
}
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);
}
Aggregations