Search in sources :

Example 36 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class WanCommandCreateGatewayReceiverDUnitTest method testCreateGatewayReceiver_onGroup.

/**
   * GatewayReceiver with given attributes on the given group.
   */
@Test
public void testCreateGatewayReceiver_onGroup() {
    VM puneLocator = Host.getLocator();
    int punePort = (Integer) puneLocator.invoke(() -> getLocatorPort());
    Properties props = getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
    setUpJmxManagerOnVm0ThenConnect(props);
    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
    vm3.invoke(() -> createCacheWithGroups(punePort, "receiverGroup1"));
    vm4.invoke(() -> createCacheWithGroups(punePort, "receiverGroup1"));
    vm5.invoke(() -> createCacheWithGroups(punePort, "receiverGroup1"));
    String command = CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART + "=true" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS + "=localhost" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT + "=10000" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=11000" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__GROUP + "=receiverGroup1";
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
        List<String> status = resultData.retrieveAllValues("Status");
        //
        assertEquals(3, status.size());
        // verify there is no error in the status
        for (int i = 0; i < status.size(); i++) {
            assertTrue("GatewayReceiver creation failed with: " + status.get(i), status.get(i).indexOf("ERROR:") == -1);
        }
    } else {
        fail("testCreateGatewayReceiver failed as did not get CommandResult");
    }
    vm3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null));
    vm4.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null));
    vm5.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null));
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) VM(org.apache.geode.test.dunit.VM) Properties(java.util.Properties) 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 37 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class WanCommandCreateDestroyGatewaySenderDUnitTest method doDestroyAndVerifyGatewaySender.

/**
   * doDestroyAndVerifyGatewaySender helper command.
   *
   * @param id if of the Gateway Sender
   * @param group Group for the GatewaySender
   * @param member Distributed Member for memeber id.
   * @param testName testName for the logging
   * @param vms list of vms where to verify the destroyed gateway sender
   * @param size command result.
   * @param isParallel true if parallel , false otherwise.
   */
private void doDestroyAndVerifyGatewaySender(final String id, final String group, final DistributedMember member, final String testName, final List<VM> vms, final int size, final boolean isParallel) {
    String command = CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=" + id;
    if (group != null) {
        command += " --" + CliStrings.DESTROY_GATEWAYSENDER__GROUP + "=" + group;
    }
    if (member != null) {
        command += " --" + CliStrings.CREATE_GATEWAYSENDER__MEMBER + "=" + member.getId();
    }
    final CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info(testName + " stringResult : " + strCmdResult + ">>>>");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
        List<String> status = resultData.retrieveAllValues("Status");
        assertEquals(size, status.size());
        for (int i = 0; i < status.size(); i++) {
            assertTrue("GatewaySender destroy failed with: " + status.get(i), status.get(i).indexOf("ERROR:") == -1);
        }
    } else {
        fail(testName + " failed as did not get CommandResult");
    }
    for (VM vm : vms) {
        vm.invoke(() -> verifySenderDestroyed(id, isParallel));
    }
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) VM(org.apache.geode.test.dunit.VM) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult)

Example 38 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class WanCommandCreateDestroyGatewaySenderDUnitTest method testCreateDestroyGatewaySenderWithDefault.

/**
   * GatewaySender with all default attributes
   */
@Test
public void testCreateDestroyGatewaySenderWithDefault() {
    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
    Properties props = getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
    setUpJmxManagerOnVm0ThenConnect(props);
    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
    vm3.invoke(() -> createCache(punePort));
    vm4.invoke(() -> createCache(punePort));
    vm5.invoke(() -> createCache(punePort));
    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2";
    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testCreateDestroyGatewaySenderWithDefault stringResult : " + strCmdResult + ">>>>");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
        List<String> status = resultData.retrieveAllValues("Status");
        assertEquals(5, status.size());
        for (int i = 0; i < status.size(); i++) {
            assertTrue("GatewaySender creation failed with: " + status.get(i), status.get(i).indexOf("ERROR:") == -1);
        }
    } else {
        fail("testCreateDestroyGatewaySenderWithDefault failed as did not get CommandResult");
    }
    vm3.invoke(() -> verifySenderState("ln", true, false));
    vm4.invoke(() -> verifySenderState("ln", true, false));
    vm5.invoke(() -> verifySenderState("ln", true, false));
    doDestroyAndVerifyGatewaySender("ln", null, null, "testCreateDestroyGatewaySenderWithDefault", Arrays.asList(vm3, vm4, vm5), 5, false);
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 39 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class WanCommandStatusDUnitTest method testGatewaySenderStatus.

@Test
public void testGatewaySenderStatus() {
    Integer lnPort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
    Properties props = getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + lnPort + "]");
    setUpJmxManagerOnVm0ThenConnect(props);
    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, lnPort));
    vm6.invoke(() -> createAndStartReceiver(nyPort));
    vm3.invoke(() -> createCache(lnPort));
    vm3.invoke(() -> createSender("ln_Serial", 2, false, 100, 400, false, false, null, true));
    vm3.invoke(() -> createSender("ln_Parallel", 2, true, 100, 400, false, false, null, true));
    vm4.invoke(() -> createCache(lnPort));
    vm4.invoke(() -> createSender("ln_Serial", 2, false, 100, 400, false, false, null, true));
    vm4.invoke(() -> createSender("ln_Parallel", 2, true, 100, 400, false, false, null, true));
    vm5.invoke(() -> createCache(lnPort));
    vm5.invoke(() -> createSender("ln_Serial", 2, false, 100, 400, false, false, null, true));
    vm5.invoke(() -> createSender("ln_Parallel", 2, true, 100, 400, false, false, null, true));
    pause(10000);
    String command = CliStrings.STATUS_GATEWAYSENDER + " --" + CliStrings.STATUS_GATEWAYSENDER__ID + "=ln_Serial";
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_SENDER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_SENDER);
        List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        assertEquals(3, result_Status.size());
        assertFalse(result_Status.contains(CliStrings.GATEWAY_RUNNING));
        tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_SENDER_NOT_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_SENDER);
        List<String> result_hosts = tableResultData.retrieveAllValues(CliStrings.RESULT_HOST_MEMBER);
        assertEquals(2, result_hosts.size());
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewaySenderStatus : " + strCmdResult + ">>>>> ");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testListGatewaySender failed as did not get CommandResult");
    }
    vm3.invoke(() -> startSender("ln_Serial"));
    vm3.invoke(() -> startSender("ln_Parallel"));
    vm4.invoke(() -> startSender("ln_Serial"));
    vm4.invoke(() -> startSender("ln_Parallel"));
    vm5.invoke(() -> startSender("ln_Serial"));
    vm5.invoke(() -> startSender("ln_Parallel"));
    pause(10000);
    command = CliStrings.STATUS_GATEWAYSENDER + " --" + CliStrings.STATUS_GATEWAYSENDER__ID + "=ln_Serial";
    cmdResult = executeCommand(command);
    if (cmdResult != null) {
        TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_SENDER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_SENDER);
        List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        assertEquals(3, result_Status.size());
        assertFalse(result_Status.contains(CliStrings.GATEWAY_NOT_RUNNING));
        tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_SENDER_NOT_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_SENDER);
        List<String> result_hosts = tableResultData.retrieveAllValues(CliStrings.RESULT_HOST_MEMBER);
        assertEquals(2, result_hosts.size());
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewaySenderStatus : " + strCmdResult + ">>>>> ");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testListGatewaySender failed as did not get CommandResult");
    }
}
Also used : CompositeResultData(org.apache.geode.management.internal.cli.result.CompositeResultData) TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) Properties(java.util.Properties) 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 40 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class WanCommandStatusDUnitTest method testGatewaySenderStatus_OnMember.

@Test
public void testGatewaySenderStatus_OnMember() {
    Integer lnPort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
    Properties props = getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + lnPort + "]");
    setUpJmxManagerOnVm0ThenConnect(props);
    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, lnPort));
    vm6.invoke(() -> createAndStartReceiver(nyPort));
    vm3.invoke(() -> createCache(lnPort));
    vm3.invoke(() -> createSender("ln_Serial", 2, false, 100, 400, false, false, null, true));
    vm3.invoke(() -> createSender("ln_Parallel", 2, true, 100, 400, false, false, null, true));
    vm4.invoke(() -> createCache(lnPort));
    vm4.invoke(() -> createSender("ln_Serial", 2, false, 100, 400, false, false, null, true));
    vm4.invoke(() -> createSender("ln_Parallel", 2, true, 100, 400, false, false, null, true));
    vm5.invoke(() -> createCache(lnPort));
    final DistributedMember vm1Member = (DistributedMember) vm3.invoke(() -> getMember());
    pause(10000);
    String command = CliStrings.STATUS_GATEWAYSENDER + " --" + CliStrings.STATUS_GATEWAYSENDER__ID + "=ln_Serial --" + CliStrings.STATUS_GATEWAYSENDER__MEMBER + "=" + vm1Member.getId();
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewaySenderStatus_OnMember : " + strCmdResult + ">>>>> ");
        TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_SENDER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_SENDER);
        List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        assertEquals(1, result_Status.size());
        assertFalse(result_Status.contains(CliStrings.GATEWAY_RUNNING));
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testListGatewaySender failed as did not get CommandResult");
    }
    vm3.invoke(() -> startSender("ln_Serial"));
    vm3.invoke(() -> startSender("ln_Parallel"));
    vm4.invoke(() -> startSender("ln_Serial"));
    vm4.invoke(() -> startSender("ln_Parallel"));
    pause(10000);
    command = CliStrings.STATUS_GATEWAYSENDER + " --" + CliStrings.STATUS_GATEWAYSENDER__ID + "=ln_Serial --" + CliStrings.STATUS_GATEWAYSENDER__MEMBER + "=" + vm1Member.getId();
    cmdResult = executeCommand(command);
    if (cmdResult != null) {
        // TabularResultData tableResultData =
        // (TabularResultData) cmdResult.getResultData();
        // List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        // assertIndexDetailsEquals(1, result_Status.size());
        // assertFalse(result_Status.contains(CliStrings.GATEWAY_NOT_RUNNING));
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewaySenderStatus_OnMember : " + strCmdResult + ">>>>> ");
        TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_SENDER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_SENDER);
        List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        assertEquals(1, result_Status.size());
        assertFalse(result_Status.contains(CliStrings.GATEWAY_NOT_RUNNING));
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testListGatewaySender failed as did not get CommandResult");
    }
    final DistributedMember vm5Member = (DistributedMember) vm5.invoke(() -> getMember());
    command = CliStrings.STATUS_GATEWAYSENDER + " --" + CliStrings.STATUS_GATEWAYSENDER__ID + "=ln_Serial --" + CliStrings.STATUS_GATEWAYSENDER__MEMBER + "=" + vm5Member.getId();
    cmdResult = executeCommand(command);
    if (cmdResult != null) {
        // ErrorResultData errorResultData =
        // (ErrorResultData) cmdResult.getResultData();
        assertTrue(cmdResult != null);
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewaySenderStatus_OnMember : " + strCmdResult + ">>>>> ");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testListGatewaySender failed as did not get CommandResult");
    }
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) DistributedMember(org.apache.geode.distributed.DistributedMember) Properties(java.util.Properties) 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)

Aggregations

CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)270 Test (org.junit.Test)222 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)208 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)131 Properties (java.util.Properties)94 VM (org.apache.geode.test.dunit.VM)80 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)71 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)67 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)45 File (java.io.File)44 Cache (org.apache.geode.cache.Cache)43 Region (org.apache.geode.cache.Region)39 Category (org.junit.experimental.categories.Category)33 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)32 InternalCache (org.apache.geode.internal.cache.InternalCache)29 DistributedMember (org.apache.geode.distributed.DistributedMember)26 ArrayList (java.util.ArrayList)16 RegionFactory (org.apache.geode.cache.RegionFactory)15 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)15 Gfsh (org.apache.geode.management.internal.cli.shell.Gfsh)14