Search in sources :

Example 66 with CommandStringBuilder

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));
    }
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult)

Example 67 with CommandStringBuilder

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());
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder)

Example 68 with CommandStringBuilder

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"));
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) File(java.io.File) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Example 69 with CommandStringBuilder

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);
    }
}
Also used : LocatorLauncher(org.apache.geode.distributed.LocatorLauncher) CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) Builder(org.apache.geode.distributed.LocatorLauncher.Builder) LocatorState(org.apache.geode.distributed.LocatorLauncher.LocatorState) File(java.io.File) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Example 70 with CommandStringBuilder

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);
    }
}
Also used : LocatorLauncher(org.apache.geode.distributed.LocatorLauncher) CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) Builder(org.apache.geode.distributed.LocatorLauncher.Builder) LocatorState(org.apache.geode.distributed.LocatorLauncher.LocatorState) File(java.io.File) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Aggregations

CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)186 Test (org.junit.Test)88 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)87 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)71 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)47 VM (org.apache.geode.test.dunit.VM)41 File (java.io.File)39 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)37 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)36 Properties (java.util.Properties)16 Region (org.apache.geode.cache.Region)14 Category (org.junit.experimental.categories.Category)14 Cache (org.apache.geode.cache.Cache)12 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)12 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)11 IOException (java.io.IOException)10 UnknownHostException (java.net.UnknownHostException)7 HashMap (java.util.HashMap)6 RegionAttributes (org.apache.geode.cache.RegionAttributes)6 ClusterConfigurationService (org.apache.geode.distributed.internal.ClusterConfigurationService)6