Search in sources :

Example 6 with CommandProcessor

use of org.apache.geode.management.internal.cli.remote.CommandProcessor in project geode by apache.

the class ConfigCommandsDUnitTest method testDescribeConfig.

@Test
public void testDescribeConfig() throws Exception {
    setUpJmxManagerOnVm0ThenConnect(null);
    final String controllerName = "Member2";
    /*
     * Create properties for the controller VM
     */
    final Properties localProps = new Properties();
    localProps.setProperty(MCAST_PORT, "0");
    localProps.setProperty(LOG_LEVEL, "info");
    localProps.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
    localProps.setProperty(ENABLE_TIME_STATISTICS, "true");
    localProps.setProperty(NAME, controllerName);
    localProps.setProperty(GROUPS, "G1");
    getSystem(localProps);
    Cache cache = getCache();
    int[] ports = getRandomAvailableTCPPorts(1);
    CacheServer cs = getCache().addCacheServer();
    cs.setPort(ports[0]);
    cs.setMaxThreads(10);
    cs.setMaxConnections(9);
    cs.start();
    try {
        RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
        List<String> jvmArgs = runtimeBean.getInputArguments();
        getLogWriter().info("#SB Actual JVM Args : ");
        for (String jvmArg : jvmArgs) {
            getLogWriter().info("#SB JVM " + jvmArg);
        }
        InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem();
        DistributionConfig config = system.getConfig();
        config.setArchiveFileSizeLimit(1000);
        String command = CliStrings.DESCRIBE_CONFIG + " --member=" + controllerName;
        CommandProcessor cmdProcessor = new CommandProcessor();
        cmdProcessor.createCommandStatement(command, Collections.EMPTY_MAP).process();
        CommandResult cmdResult = executeCommand(command);
        String resultStr = commandResultToString(cmdResult);
        getLogWriter().info("#SB Hiding the defaults\n" + resultStr);
        assertEquals(true, cmdResult.getStatus().equals(Status.OK));
        assertEquals(true, resultStr.contains("G1"));
        assertEquals(true, resultStr.contains(controllerName));
        assertEquals(true, resultStr.contains(ARCHIVE_FILE_SIZE_LIMIT));
        assertEquals(true, !resultStr.contains("copy-on-read"));
        cmdResult = executeCommand(command + " --" + CliStrings.DESCRIBE_CONFIG__HIDE__DEFAULTS + "=false");
        resultStr = commandResultToString(cmdResult);
        getLogWriter().info("#SB No hiding of defaults\n" + resultStr);
        assertEquals(true, cmdResult.getStatus().equals(Status.OK));
        assertEquals(true, resultStr.contains("is-server"));
        assertEquals(true, resultStr.contains(controllerName));
        assertEquals(true, resultStr.contains("copy-on-read"));
    } finally {
        cs.stop();
    }
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) CacheServer(org.apache.geode.cache.server.CacheServer) CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) RuntimeMXBean(java.lang.management.RuntimeMXBean) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) Properties(java.util.Properties) Cache(org.apache.geode.cache.Cache) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 7 with CommandProcessor

use of org.apache.geode.management.internal.cli.remote.CommandProcessor in project geode by apache.

the class MemberCommandsDUnitTest method testListMemberAll.

/**
   * Tests the execution of "list member" command which should list out all the members in the DS
   *
   * @throws IOException
   * @throws ClassNotFoundException
   */
@Test
public void testListMemberAll() throws IOException, ClassNotFoundException {
    setupSystem();
    CommandProcessor commandProcessor = new CommandProcessor();
    Result result = commandProcessor.createCommandStatement(CliStrings.LIST_MEMBER, EMPTY_ENV).process();
    getLogWriter().info("#SB" + getResultAsString(result));
    assertEquals(true, result.getStatus().equals(Status.OK));
}
Also used : CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) Result(org.apache.geode.management.cli.Result) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 8 with CommandProcessor

use of org.apache.geode.management.internal.cli.remote.CommandProcessor 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));
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) Result(org.apache.geode.management.cli.Result) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 9 with CommandProcessor

use of org.apache.geode.management.internal.cli.remote.CommandProcessor in project geode by apache.

the class MemberCommandsDUnitTest method testDescribeMember.

/**
   * Tests the "describe member" command for all the members in the DS
   *
   * @throws IOException
   * @throws ClassNotFoundException
   */
@Test
public void testDescribeMember() throws IOException, ClassNotFoundException {
    setupSystem();
    CommandProcessor commandProcessor = new CommandProcessor();
    GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
    Set<DistributedMember> members = cache.getDistributedSystem().getAllOtherMembers();
    Iterator<DistributedMember> iters = members.iterator();
    while (iters.hasNext()) {
        DistributedMember member = iters.next();
        Result result = commandProcessor.createCommandStatement("describe member --name=" + member.getId(), EMPTY_ENV).process();
        assertEquals(true, result.getStatus().equals(Status.OK));
        getLogWriter().info("#SB" + getResultAsString(result));
    // assertIndexDetailsEquals(true, result.getStatus().equals(Status.OK));
    }
}
Also used : DistributedMember(org.apache.geode.distributed.DistributedMember) CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) Result(org.apache.geode.management.cli.Result) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 10 with CommandProcessor

use of org.apache.geode.management.internal.cli.remote.CommandProcessor in project geode by apache.

the class MemberCommandsDUnitTest method testListMemberWithNoCache.

/**
   * Tests the execution of "list member" command, when no cache is created
   *
   * @throws IOException
   * @throws ClassNotFoundException
   */
@Test
public void testListMemberWithNoCache() throws IOException, ClassNotFoundException {
    final Host host = Host.getHost(0);
    final VM[] servers = { host.getVM(0), host.getVM(1) };
    final int[] openPorts = AvailablePortHelper.getRandomAvailableTCPPorts(1);
    final File logFile = new File(getUniqueName() + "-locator" + openPorts[0] + ".log");
    Locator locator = Locator.startLocator(openPorts[0], logFile);
    try {
        final Properties props = createProperties(host, openPorts[0]);
        CommandProcessor commandProcessor = new CommandProcessor();
        Result result = commandProcessor.createCommandStatement(CliStrings.LIST_MEMBER, EMPTY_ENV).process();
        getLogWriter().info("#SB" + getResultAsString(result));
        assertEquals(true, result.getStatus().equals(Status.ERROR));
    } finally {
        // fix for bug 46562
        locator.stop();
    }
}
Also used : Locator(org.apache.geode.distributed.Locator) VM(org.apache.geode.test.dunit.VM) CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) Host(org.apache.geode.test.dunit.Host) Properties(java.util.Properties) File(java.io.File) Result(org.apache.geode.management.cli.Result) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

CommandProcessor (org.apache.geode.management.internal.cli.remote.CommandProcessor)13 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)13 Test (org.junit.Test)13 Result (org.apache.geode.management.cli.Result)12 File (java.io.File)7 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)7 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)7 Cache (org.apache.geode.cache.Cache)5 Properties (java.util.Properties)4 DistributedMember (org.apache.geode.distributed.DistributedMember)4 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)4 CacheServer (org.apache.geode.cache.server.CacheServer)2 DistributionConfig (org.apache.geode.distributed.internal.DistributionConfig)2 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)2 IOException (java.io.IOException)1 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 Region (org.apache.geode.cache.Region)1 RegionFactory (org.apache.geode.cache.RegionFactory)1 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)1 Locator (org.apache.geode.distributed.Locator)1