Search in sources :

Example 46 with CommandStringBuilder

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

the class ListAndDescribeRegionDUnitTest method testListRegion.

@Test
public void testListRegion() {
    setupSystem();
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_REGION);
    String commandString = csb.toString();
    CommandResult commandResult = executeCommand(commandString);
    String commandResultAsString = commandResultToString(commandResult);
    getLogWriter().info("Command String : " + commandString);
    getLogWriter().info("Output : \n" + commandResultAsString);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(commandResultAsString.contains(PR1));
    assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
    assertTrue(commandResultAsString.contains(REGION1));
    assertTrue(commandResultAsString.contains(REGION2));
    assertTrue(commandResultAsString.contains(REGION3));
    csb = new CommandStringBuilder(CliStrings.LIST_REGION);
    csb.addOption(CliStrings.LIST_REGION__MEMBER, "Manager");
    commandString = csb.toString();
    commandResult = executeCommand(commandString);
    commandResultAsString = commandResultToString(commandResult);
    getLogWriter().info("Command String : " + commandString);
    getLogWriter().info("Output : \n" + commandResultAsString);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(commandResultAsString.contains(PR1));
    assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
    csb = new CommandStringBuilder(CliStrings.LIST_REGION);
    csb.addOption(CliStrings.LIST_REGION__MEMBER, "Server1");
    commandString = csb.toString();
    commandResult = executeCommand(commandString);
    commandResultAsString = commandResultToString(commandResult);
    getLogWriter().info("Command String : " + commandString);
    getLogWriter().info("Output : \n" + commandResultAsString);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(commandResultAsString.contains(PR1));
    assertTrue(commandResultAsString.contains(REGION1));
    assertTrue(commandResultAsString.contains(REGION2));
    assertTrue(commandResultAsString.contains(REGION3));
    assertTrue(commandResultAsString.contains(SUBREGION1A));
    csb = new CommandStringBuilder(CliStrings.LIST_REGION);
    csb.addOption(CliStrings.LIST_REGION__GROUP, "G1");
    commandString = csb.toString();
    commandResult = executeCommand(commandString);
    commandResultAsString = commandResultToString(commandResult);
    getLogWriter().info("Command String : " + commandString);
    getLogWriter().info("Output : \n" + commandResultAsString);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(commandResultAsString.contains(PR1));
    assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
    csb = new CommandStringBuilder(CliStrings.LIST_REGION);
    csb.addOption(CliStrings.LIST_REGION__GROUP, "G2");
    commandString = csb.toString();
    commandResult = executeCommand(commandString);
    commandResultAsString = commandResultToString(commandResult);
    getLogWriter().info("Command String : " + commandString);
    getLogWriter().info("Output : \n" + commandResultAsString);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(commandResultAsString.contains(PR1));
    assertTrue(commandResultAsString.contains(REGION1));
    assertTrue(commandResultAsString.contains(REGION2));
    assertTrue(commandResultAsString.contains(REGION3));
    assertTrue(commandResultAsString.contains(SUBREGION1A));
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 47 with CommandStringBuilder

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

the class ListAndDescribeRegionDUnitTest method testDescribeRegionWithCompressionCodec.

/**
   * Asserts that a describe region command issued on a region with compression returns the correct
   * non default region attribute for compression and the correct codec value.
   */
// GEODE-1033: HeadlesssGFSH, random port, Snappy dependency
@Category(FlakyTest.class)
@Test
public void testDescribeRegionWithCompressionCodec() {
    final String regionName = "compressedRegion";
    VM vm = Host.getHost(0).getVM(1);
    setupSystem();
    // Create compressed region
    vm.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            createCompressedRegion(regionName);
        }
    });
    // Test the describe command; look for compression
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
    csb.addOption(CliStrings.DESCRIBE_REGION__NAME, regionName);
    String commandString = csb.toString();
    CommandResult commandResult = executeCommand(commandString);
    String commandResultAsString = commandResultToString(commandResult);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(commandResultAsString.contains(regionName));
    assertTrue(commandResultAsString.contains(RegionAttributesNames.COMPRESSOR));
    assertTrue(commandResultAsString.contains(RegionEntryContext.DEFAULT_COMPRESSION_PROVIDER));
    // Destroy compressed region
    vm.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            Region region = getCache().getRegion(regionName);
            assertNotNull(region);
            region.destroyRegion();
        }
    });
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 48 with CommandStringBuilder

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

the class ListAndDescribeRegionDUnitTest method testDescribeRegion.

@Test
public void testDescribeRegion() {
    setupSystem();
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
    csb.addOption(CliStrings.DESCRIBE_REGION__NAME, PR1);
    String commandString = csb.toString();
    CommandResult commandResult = executeCommand(commandString);
    String commandResultAsString = commandResultToString(commandResult);
    getLogWriter().info("Command String : " + commandString);
    getLogWriter().info("Output : \n" + commandResultAsString);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(commandResultAsString.contains(PR1));
    assertTrue(commandResultAsString.contains("Server1"));
    csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
    csb.addOption(CliStrings.DESCRIBE_REGION__NAME, LOCALREGIONONMANAGER);
    commandString = csb.toString();
    commandResult = executeCommand(commandString);
    commandResultAsString = commandResultToString(commandResult);
    getLogWriter().info("Command String : " + commandString);
    getLogWriter().info("Output : \n" + commandResultAsString);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
    assertTrue(commandResultAsString.contains("Manager"));
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 49 with CommandStringBuilder

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

the class LauncherLifecycleCommands method doOnConnectionFailure.

private void doOnConnectionFailure(final String locatorHostName, final int locatorPort, final boolean jmxManagerAuthEnabled, final boolean jmxManagerSslEnabled, final InfoResultData infoResultData) {
    infoResultData.addLine("\n");
    infoResultData.addLine(CliStrings.format(CliStrings.START_LOCATOR__USE__0__TO__CONNECT, new CommandStringBuilder(CliStrings.CONNECT).addOption(CliStrings.CONNECT__LOCATOR, locatorHostName + "[" + locatorPort + "]").toString()));
    StringBuilder message = new StringBuilder();
    if (jmxManagerAuthEnabled) {
        message.append("Authentication");
    }
    if (jmxManagerSslEnabled) {
        message.append(jmxManagerAuthEnabled ? " and " : StringUtils.EMPTY).append("SSL configuration");
    }
    if (jmxManagerAuthEnabled || jmxManagerSslEnabled) {
        message.append(" required to connect to the Manager.");
        infoResultData.addLine("\n");
        infoResultData.addLine(message.toString());
    }
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder)

Example 50 with CommandStringBuilder

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

the class DurableClientCommandsController method closeDurableContinuousQuery.

@RequestMapping(method = RequestMethod.POST, value = "/durable-clients/{durable-client-id}/cqs/{durable-cq-name}", params = "op=close")
@ResponseBody
public String closeDurableContinuousQuery(@PathVariable(ConfigurationProperties.DURABLE_CLIENT_ID) final String durableClientId, @PathVariable("durable-cq-name") final String durableCqName, @RequestParam(value = CliStrings.CLOSE_DURABLE_CQS__MEMBER, required = false) final String memberNameId, @RequestParam(value = CliStrings.CLOSE_DURABLE_CQS__GROUP, required = false) final String[] groups) {
    final CommandStringBuilder command = new CommandStringBuilder(CliStrings.CLOSE_DURABLE_CQS);
    command.addOption(CliStrings.CLOSE_DURABLE_CQS__DURABLE__CLIENT__ID, decode(durableClientId));
    command.addOption(CliStrings.CLOSE_DURABLE_CQS__NAME, decode(durableCqName));
    if (hasValue(memberNameId)) {
        command.addOption(CliStrings.CLOSE_DURABLE_CQS__MEMBER, memberNameId);
    }
    if (hasValue(groups)) {
        command.addOption(CliStrings.CLOSE_DURABLE_CQS__GROUP, StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
    }
    return processCommand(command.toString());
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

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