Search in sources :

Example 6 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class LauncherLifecycleCommandsDUnitTest method test000StartLocatorCapturesOutputOnError.

@Test
public void test000StartLocatorCapturesOutputOnError() throws IOException {
    final int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
    String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
    File workingDirectory = temporaryFolder.newFolder(pathname);
    assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
    File pidFile = new File(workingDirectory, ProcessType.LOCATOR.getPidFileName());
    assertTrue(pidFile.createNewFile());
    writePid(pidFile, getPidOrOne());
    pidFile.deleteOnExit();
    assertTrue(pidFile.isFile());
    CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
    command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
    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__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
    command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort());
    CommandResult result = executeCommand(command.toString());
    assertNotNull(result);
    assertEquals(Result.Status.ERROR, result.getStatus());
    String resultString = toString(result);
    assertTrue(resultString, resultString.contains("Exception in thread \"main\" java.lang.RuntimeException: A PID file already exists and a Locator may be running in " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory)));
    assertTrue(resultString, resultString.contains("Caused by: org.apache.geode.internal.process.FileAlreadyExistsException: Pid file already exists: " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(pidFile)));
}
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 7 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class ClusterConfigurationServiceEndToEndDUnitTest method createAndDeployJar.

private void createAndDeployJar(final String jarName) throws IOException {
    File newDeployableJarFile = new File(jarName);
    this.classBuilder.writeJarFromName("ShareConfigClass", newDeployableJarFile);
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEPLOY);
    csb.addOption(CliStrings.DEPLOY__JAR, jarName);
    executeAndVerifyCommand(csb.getCommandString());
    jarFileNames.add(jarName);
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) File(java.io.File)

Example 8 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class ClusterConfigurationServiceEndToEndDUnitTest method createRegion.

private void createRegion(final String regionName, final RegionShortcut regionShortCut, final String group) {
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
    csb.addOption(CliStrings.CREATE_REGION__REGION, regionName);
    csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, regionShortCut.name());
    executeAndVerifyCommand(csb.getCommandString());
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder)

Example 9 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class ClusterConfigurationServiceEndToEndDUnitTest method destroyIndex.

private void destroyIndex(final String indexName, final String regionName, final String group) {
    if (isBlank(indexName) && isBlank(regionName) && isBlank(group)) {
        return;
    }
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
    if (!isBlank(indexName)) {
        csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
    }
    if (!isBlank(regionName)) {
        csb.addOption(CliStrings.DESTROY_INDEX__REGION, regionName);
    }
    if (!isBlank(group)) {
        csb.addOption(CliStrings.DESTROY_INDEX__GROUP, group);
    }
    executeAndVerifyCommand(csb.getCommandString());
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder)

Example 10 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class LauncherLifecycleCommandsDUnitTest method test006StartLocatorInRelativeDirectory.

@Test
public void test006StartLocatorInRelativeDirectory() {
    final int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
    String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
    File workingDirectory = new File(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, pathname);
        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__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
        command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort());
        CommandResult result = executeCommand(command.toString());
        assertNotNull(result);
        assertEquals(Result.Status.OK, result.getStatus());
        String locatorOutput = toString(result);
        assertNotNull(locatorOutput);
        assertTrue("Locator output was: " + locatorOutput, locatorOutput.contains("Locator in " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory)));
    } finally {
        stopLocator(workingDirectory);
    }
}
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)

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