use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class IndexCommandsDUnitTest method testCreateAndDestroyIndexOnGroup.
// GEODE-1684
@Category(FlakyTest.class)
@Test
public void testCreateAndDestroyIndexOnGroup() {
setupSystem();
/***
* Basic Create and Destroy
*/
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
csb.addOption(CliStrings.CREATE_INDEX__GROUP, group1);
String commandString = csb.toString();
CommandResult commandResult = executeCommand(commandString);
String resultAsString = commandResultToString(commandResult);
writeToLog("Command String :\n ", commandString);
writeToLog("testCreateAndDestroyIndexOnGroup", resultAsString);
assertEquals(Status.OK, commandResult.getStatus());
csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
commandString = csb.toString();
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
assertEquals(Status.OK, commandResult.getStatus());
assertEquals(true, resultAsString.contains(indexName));
assertEquals(true, resultAsString.contains(VM1Name));
csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
csb.addOption(CliStrings.DESTROY_INDEX__REGION, "/StocksParReg");
csb.addOption(CliStrings.DESTROY_INDEX__GROUP, group1);
commandString = csb.toString();
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
writeToLog("Command String :\n ", commandString);
writeToLog("testCreateAndDestroyIndexOnGroup", resultAsString);
assertEquals(commandResult.getStatus(), Status.OK);
commandResult = executeCommand(CliStrings.LIST_INDEX);
resultAsString = commandResultToString(commandResult);
assertEquals(commandResult.getStatus(), Status.OK);
assertFalse(resultAsString.contains(VM1Name));
/***
* In case of a partitioned region , the index might get created on a member which hosts the
* region and is not the member of the group1
*/
if (resultAsString.contains(indexName)) {
csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
csb.addOption(CliStrings.DESTROY_INDEX__REGION, "/StocksParReg");
commandString = csb.toString();
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
assertEquals(commandResult.getStatus(), Status.OK);
commandResult = executeCommand(CliStrings.LIST_INDEX);
resultAsString = commandResultToString(commandResult);
writeToLog("Command String :\n ", commandString);
writeToLog("testCreateAndDestroyIndexOnGroup", resultAsString);
assertEquals(commandResult.getStatus(), Status.OK);
assertFalse(resultAsString.contains(indexName));
assertTrue(resultAsString.contains(CliStrings.LIST_INDEX__INDEXES_NOT_FOUND_MESSAGE));
}
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class DurableClientCommandsDUnitTest method testCountSubscriptionQueueSize.
@Test
public void testCountSubscriptionQueueSize() throws Exception {
setupSystem();
setupCqs();
doPuts(regionName, Host.getHost(0).getVM(1));
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.COUNT_DURABLE_CQ_EVENTS);
csb.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CLIENT__ID, clientName);
String commandString = csb.toString();
writeToLog("Command String : ", commandString);
CommandResult commandResult = executeCommand(commandString);
String resultAsString = commandResultToString(commandResult);
writeToLog("Command Result :\n", resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
assertTrue(resultAsString.contains("4"));
csb = new CommandStringBuilder(CliStrings.COUNT_DURABLE_CQ_EVENTS);
csb.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CLIENT__ID, clientName);
csb.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CQ__NAME, cq3);
commandString = csb.toString();
writeToLog("Command String : ", commandString);
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
writeToLog("Command Result :\n", resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
// CLOSE all the cqs
closeCq(cq1);
closeCq(cq2);
closeCq(cq3);
// Run the commands again
csb = new CommandStringBuilder(CliStrings.COUNT_DURABLE_CQ_EVENTS);
csb.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CLIENT__ID, clientName);
csb.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CQ__NAME, cq1);
commandString = csb.toString();
writeToLog("Command String : ", commandString);
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
writeToLog("Command Result :\n", resultAsString);
assertTrue(Status.ERROR.equals(commandResult.getStatus()));
String errorMessage = CliStrings.format(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE_CQ_NOT_FOUND, clientName, cq1);
assertTrue(resultAsString.contains(errorMessage));
csb = new CommandStringBuilder(CliStrings.COUNT_DURABLE_CQ_EVENTS);
csb.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CLIENT__ID, clientName);
commandString = csb.toString();
writeToLog("Command String : ", commandString);
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
writeToLog("Command Result :\n", resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
// Disconnect the client
closeDurableClient();
// Close the client
csb = new CommandStringBuilder(CliStrings.CLOSE_DURABLE_CLIENTS);
csb.addOption(CliStrings.CLOSE_DURABLE_CLIENTS__CLIENT__ID, clientName);
commandString = csb.toString();
// since it can take the server a bit to know that the client has disconnected
// we loop here
long giveUpTime = System.currentTimeMillis() + 20000;
do {
writeToLog("Command String : ", commandString);
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
} while (resultAsString.contains("Cannot close a running durable client") && giveUpTime > System.currentTimeMillis());
writeToLog("Command Result :\n", resultAsString);
assertTrue("failed executing" + commandString + "; result = " + resultAsString, Status.OK.equals(commandResult.getStatus()));
csb = new CommandStringBuilder(CliStrings.COUNT_DURABLE_CQ_EVENTS);
csb.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CLIENT__ID, clientName);
commandString = csb.toString();
writeToLog("Command String : ", commandString);
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
writeToLog("Command Result :\n", resultAsString);
assertTrue(Status.ERROR.equals(commandResult.getStatus()));
assertTrue(resultAsString.contains(CliStrings.format(CliStrings.NO_CLIENT_FOUND_WITH_CLIENT_ID, clientName)));
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class DurableClientCommandsDUnitTest method testListDurableClientCqs.
@Test
public void testListDurableClientCqs() throws Exception {
setupSystem();
setupCqs();
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_DURABLE_CQS);
csb.addOption(CliStrings.LIST_DURABLE_CQS__DURABLECLIENTID, clientName);
String commandString = csb.toString();
writeToLog("Command String :\n ", commandString);
CommandResult commandResult = executeCommand(commandString);
String resultAsString = commandResultToString(commandResult);
writeToLog("Command Result :\n", resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
assertTrue(resultAsString.contains(cq1));
assertTrue(resultAsString.contains(cq2));
assertTrue(resultAsString.contains(cq3));
closeCq(cq1);
closeCq(cq2);
closeCq(cq3);
csb = new CommandStringBuilder(CliStrings.LIST_DURABLE_CQS);
csb.addOption(CliStrings.LIST_DURABLE_CQS__DURABLECLIENTID, clientName);
commandString = csb.toString();
writeToLog("Command String :\n ", commandString);
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
writeToLog("Command Result :\n", resultAsString);
assertTrue(Status.ERROR.equals(commandResult.getStatus()));
String errorMessage = CliStrings.format(CliStrings.LIST_DURABLE_CQS__NO__CQS__FOR__CLIENT, clientName);
assertTrue(resultAsString.contains(errorMessage));
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class DurableClientCommandsDUnitTest method testCloseDurableCQ.
// GEODE-1705
@Category(FlakyTest.class)
@Test
public void testCloseDurableCQ() throws Exception {
setupSystem();
setupCqs();
closeDurableClient();
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CLOSE_DURABLE_CQS);
csb.addOption(CliStrings.CLOSE_DURABLE_CQS__DURABLE__CLIENT__ID, clientName);
csb.addOption(CliStrings.CLOSE_DURABLE_CQS__NAME, cq1);
String commandString = csb.toString();
writeToLog("Command String : ", commandString);
CommandResult commandResult = executeCommand(commandString);
String resultAsString = commandResultToString(commandResult);
writeToLog("Command Result :\n", resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
csb = new CommandStringBuilder(CliStrings.CLOSE_DURABLE_CQS);
csb.addOption(CliStrings.CLOSE_DURABLE_CQS__DURABLE__CLIENT__ID, clientName);
csb.addOption(CliStrings.CLOSE_DURABLE_CQS__NAME, cq1);
commandString = csb.toString();
writeToLog("Command String : ", commandString);
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
writeToLog("Command Result : ", resultAsString);
assertTrue(Status.ERROR.equals(commandResult.getStatus()));
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LuceneCommandsSecurityDUnitTest method getDescribeIndexCommand.
private String getDescribeIndexCommand() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
return csb.toString();
}
Aggregations