use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class ExportLogsStatsDUnitTest method startAndEndDateCanExcludeLogs.
@Test
public void startAndEndDateCanExcludeLogs() throws Exception {
connectIfNeeded();
ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());
ZonedDateTime tomorrow = now.plusDays(1);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
commandStringBuilder.addOption("start-time", dateTimeFormatter.format(tomorrow));
commandStringBuilder.addOption("log-level", "debug");
String output = connector.execute(commandStringBuilder.toString());
assertThat(output).contains("No files to be exported");
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class CreateAlterDestroyRegionCommandsDUnitTest method regionAlterGroupTest.
private void regionAlterGroupTest() {
CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, this.alterRegionName);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__GROUP, "Group1");
commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "5764");
CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
assertEquals(Result.Status.OK, cmdResult.getStatus());
String stringResult = commandResultToString(cmdResult);
assertEquals(4, countLinesInString(stringResult, false));
assertEquals(false, stringResult.contains("ERROR"));
assertTrue(stringContainsLine(stringResult, this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
assertTrue(stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
this.alterVm1.invoke(() -> {
RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
});
this.alterVm2.invoke(() -> {
RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
});
commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__GROUP, "Group2");
commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "6963");
cmdResult = executeCommand(commandStringBuilder.toString());
assertEquals(Result.Status.OK, cmdResult.getStatus());
stringResult = commandResultToString(cmdResult);
assertEquals(3, countLinesInString(stringResult, false));
assertEquals(false, stringResult.contains("ERROR"));
assertFalse(stringContainsLine(stringResult, this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
assertTrue(stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
this.alterVm1.invoke(() -> {
RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
});
this.alterVm2.invoke(() -> {
RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
assertEquals(6963, attributes.getEvictionAttributes().getMaximum());
});
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest method testGetOnCacheMiss.
@Test
public void testGetOnCacheMiss() {
doHousekeeping();
CommandStringBuilder command = new CommandStringBuilder(CliStrings.GET);
command.addOption(CliStrings.GET__REGIONNAME, USERS_REGION_NAME);
command.addOption(CliStrings.GET__KEY, "jonbloom");
assertResult(true, runCommand(command.toString()));
command = new CommandStringBuilder(CliStrings.GET);
command.addOption(CliStrings.GET__REGIONNAME, USERS_REGION_NAME);
command.addOption(CliStrings.GET__KEY, "jondoe");
command.addOption(CliStrings.GET__LOAD, "false");
assertResult(false, runCommand(command.toString()));
command = new CommandStringBuilder(CliStrings.GET);
command.addOption(CliStrings.GET__REGIONNAME, USERS_REGION_NAME);
command.addOption(CliStrings.GET__KEY, "jondoe");
command.addOption(CliStrings.GET__LOAD, "true");
assertResult(true, runCommand(command.toString()));
// NOTE test the unspecified default value for the --load-on-cache-miss
command = new CommandStringBuilder(CliStrings.GET);
command.addOption(CliStrings.GET__REGIONNAME, USERS_REGION_NAME);
command.addOption(CliStrings.GET__KEY, "janedoe");
assertResult(true, runCommand(command.toString()));
// NOTE now test an absolute cache miss both for in the Region as well as the CacheLoader
command = new CommandStringBuilder(CliStrings.GET);
command.addOption(CliStrings.GET__REGIONNAME, USERS_REGION_NAME);
command.addOption(CliStrings.GET__KEY, "nonexistinguser");
command.addOption(CliStrings.GET__LOAD, "true");
assertResult(false, runCommand(command.toString()));
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class MemberCommandsDUnitTest method testListMemberWithGroups.
/**
* Tests list member --group=G1
*
* @throws IOException
* @throws ClassNotFoundException
*/
@Test
public void testListMemberWithGroups() throws IOException, ClassNotFoundException {
setupSystem();
CommandProcessor commandProcessor = new CommandProcessor();
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_MEMBER);
csb.addOption(CliStrings.LIST_MEMBER__GROUP, "G1");
Result result = commandProcessor.createCommandStatement(csb.toString(), EMPTY_ENV).process();
getLogWriter().info("#SB" + getResultAsString(result));
assertEquals(true, result.getStatus().equals(Status.OK));
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class IndexCommandsDUnitTest method testDestroyIndexWithoutIndexName.
// GEODE-1315
@Category(FlakyTest.class)
@Test
public void testDestroyIndexWithoutIndexName() {
setupSystem();
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");
String commandString = csb.toString();
CommandResult commandResult = executeCommand(commandString);
String resultAsString = commandResultToString(commandResult);
assertEquals(commandResult.getStatus(), Status.OK);
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__GROUP, group1);
commandString = csb.toString();
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
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());
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");
commandString = csb.toString();
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
assertEquals(Status.OK, commandResult.getStatus());
csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
csb.addOption(CliStrings.DESTROY_INDEX__REGION, "StocksParReg");
commandString = csb.toString();
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
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());
assertTrue(resultAsString.contains(CliStrings.LIST_INDEX__INDEXES_NOT_FOUND_MESSAGE));
}
Aggregations