use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class ClusterConfigurationServiceEndToEndDUnitTest method verifyRegionCreateOnAllMembers.
private void verifyRegionCreateOnAllMembers(final String regionName) {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
csb.addOption(CliStrings.DESCRIBE_REGION__NAME, regionName);
CommandResult cmdResult = executeCommand(csb.getCommandString());
String resultAsString = commandResultToString(cmdResult);
for (String serverName : serverNames) {
assertTrue(resultAsString.contains(serverName));
}
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class ClusterConfigurationServiceEndToEndDUnitTest method destroyDiskStore.
private void destroyDiskStore(final String diskStoreName, final String group) {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_DISK_STORE);
csb.addOption(CliStrings.DESTROY_DISK_STORE__NAME, diskStoreName);
csb.addOptionWithValueCheck(CliStrings.DESTROY_DISK_STORE__GROUP, group);
executeAndVerifyCommand(csb.toString());
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LauncherLifecycleCommandsDUnitTest method testStartServerFailsFastOnMissingPassword.
@Test
public void testStartServerFailsFastOnMissingPassword() throws IOException {
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_SERVER);
String pathName = getClass().getSimpleName().concat("_").concat(getTestMethodName());
final File workingDirectory = temporaryFolder.newFolder(pathName);
command.addOption(CliStrings.START_SERVER__NAME, pathName);
command.addOption(CliStrings.START_SERVER__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_SERVER__USERNAME, "test");
CommandResult result = executeCommand(command.toString());
assertNotNull(result);
assertEquals(Result.Status.ERROR, result.getStatus());
String resultString = toString(result);
assertTrue(resultString, resultString.contains("password must be specified"));
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LauncherLifecycleCommandsDUnitTest method test009StatusLocatorUsingMemberId.
@Test
public void test009StatusLocatorUsingMemberId() throws Exception {
final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
final int jmxManagerPort = ports[0];
final int locatorPort = ports[1];
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
File workingDirectory = temporaryFolder.newFolder(pathname);
assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
try {
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString());
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort);
CommandResult result = executeCommand(command.toString());
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.STATUS).setBindAddress(null).setPort(locatorPort).setWorkingDirectory(workingDirectory.getPath()).build();
assertNotNull(locatorLauncher);
LocatorState expectedLocatorState = locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS);
assertNotNull(expectedLocatorState);
assertEquals(Status.ONLINE, expectedLocatorState.getStatus());
result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort));
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STATUS_LOCATOR, getMemberId(jmxManagerPort, pathname)));
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
assertTrue(serviceStateStatusStringNormalized(toString(result)).contains(serviceStateStatusStringNormalized(expectedLocatorState)));
} finally {
stopLocator(workingDirectory);
}
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LauncherLifecycleCommandsDUnitTest method test008StatusLocatorUsingMemberName.
@Test
public void test008StatusLocatorUsingMemberName() throws IOException {
final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
final int jmxManagerPort = ports[0];
final int locatorPort = ports[1];
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
File workingDirectory = temporaryFolder.newFolder(pathname);
assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
try {
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString());
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort);
CommandResult result = executeCommand(command.toString());
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.STATUS).setBindAddress(null).setPort(locatorPort).setWorkingDirectory(workingDirectory.getPath()).build();
assertNotNull(locatorLauncher);
LocatorState expectedLocatorState = locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS);
assertNotNull(expectedLocatorState);
assertEquals(Status.ONLINE, expectedLocatorState.getStatus());
result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort));
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
result = executeCommand(String.format("%1$s --name=invalidLocatorMemberName", CliStrings.STATUS_LOCATOR));
assertNotNull(result);
assertEquals(Result.Status.ERROR, result.getStatus());
assertEquals(CliStrings.format(CliStrings.STATUS_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, "invalidLocatorMemberName"), StringUtils.trim(toString(result)));
result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STATUS_LOCATOR, pathname));
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
assertTrue(serviceStateStatusStringNormalized(toString(result)).contains(serviceStateStatusStringNormalized(expectedLocatorState)));
} finally {
stopLocator(workingDirectory);
}
}
Aggregations