Search in sources :

Example 41 with CommandResult

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

the class WanCommandStatusDUnitTest method testGatewayReceiverStatus_OnMember.

// GEODE-1395
@Category(FlakyTest.class)
@Test
public void testGatewayReceiverStatus_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(() -> createAndStartReceiver(lnPort));
    vm4.invoke(() -> createAndStartReceiver(lnPort));
    vm5.invoke(() -> createAndStartReceiver(lnPort));
    final DistributedMember vm3Member = (DistributedMember) vm3.invoke(() -> getMember());
    pause(10000);
    String command = CliStrings.STATUS_GATEWAYRECEIVER + " --" + CliStrings.STATUS_GATEWAYRECEIVER__MEMBER + "=" + vm3Member.getId();
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewayReceiverStatus : " + strCmdResult + ">>>>> ");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        // TabularResultData tableResultData = (TabularResultData) cmdResult.getResultData();
        // List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        // assertIndexDetailsEquals(1, result_Status.size());
        // assertFalse(strCmdResult.contains(CliStrings.GATEWAY_NOT_RUNNING));
        TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_RECEIVER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_RECEIVER);
        List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        assertEquals(1, result_Status.size());
        assertFalse(result_Status.contains(CliStrings.GATEWAY_NOT_RUNNING));
    } else {
        fail("testGatewayReceiverStatus failed as did not get CommandResult");
    }
    vm3.invoke(() -> stopReceiver());
    vm4.invoke(() -> stopReceiver());
    vm5.invoke(() -> stopReceiver());
    pause(10000);
    command = CliStrings.STATUS_GATEWAYRECEIVER + " --" + CliStrings.STATUS_GATEWAYRECEIVER__MEMBER + "=" + vm3Member.getId();
    cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewayReceiverStatus : " + strCmdResult + ">>>>> ");
        // 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_RUNNING));
        TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_RECEIVER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_RECEIVER);
        List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        assertEquals(1, result_Status.size());
        assertFalse(result_Status.contains(CliStrings.GATEWAY_RUNNING));
    } else {
        fail("testGatewayReceiverStatus 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) 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 42 with CommandResult

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

the class WanCommandStatusDUnitTest method testGatewayReceiverStatus_OnGroups.

@Test
public void testGatewayReceiverStatus_OnGroups() {
    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));
    vm7.invoke(() -> createAndStartReceiver(nyPort));
    vm3.invoke(() -> createAndStartReceiverWithGroup(lnPort, "RG1, RG2"));
    vm4.invoke(() -> createAndStartReceiverWithGroup(lnPort, "RG1, RG2"));
    vm5.invoke(() -> createAndStartReceiverWithGroup(lnPort, "RG1"));
    vm6.invoke(() -> createAndStartReceiverWithGroup(lnPort, "RG2"));
    pause(10000);
    String command = CliStrings.STATUS_GATEWAYRECEIVER + " --" + CliStrings.STATUS_GATEWAYRECEIVER__GROUP + "=RG1";
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewayReceiverStatus : " + strCmdResult + ">>>>> ");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_RECEIVER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_RECEIVER);
        List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        assertEquals(3, result_Status.size());
        assertFalse(result_Status.contains(CliStrings.GATEWAY_NOT_RUNNING));
    } else {
        fail("testGatewayReceiverStatus failed as did not get CommandResult");
    }
    vm3.invoke(() -> stopReceiver());
    vm4.invoke(() -> stopReceiver());
    vm5.invoke(() -> stopReceiver());
    pause(10000);
    command = CliStrings.STATUS_GATEWAYRECEIVER + " --" + CliStrings.STATUS_GATEWAYRECEIVER__GROUP + "=RG1";
    cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewayReceiverStatus_OnGroups : " + strCmdResult + ">>>>> ");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_RECEIVER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_RECEIVER);
        List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        assertEquals(3, result_Status.size());
        assertFalse(result_Status.contains(CliStrings.GATEWAY_RUNNING));
    } else {
        fail("testGatewayReceiverStatus failed as did not get CommandResult");
    }
}
Also used : 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 43 with CommandResult

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

the class WanCommandPauseResumeDUnitTest method testResumeGatewaySender_onMember.

/**
   * test to validate that the start gateway sender starts the gateway sender on a member
   */
@Test
public void testResumeGatewaySender_onMember() {
    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));
    vm3.invoke(() -> createSender("ln", 2, false, 100, 400, false, false, null, true));
    vm3.invoke(() -> startSender("ln"));
    vm3.invoke(() -> verifySenderState("ln", true, false));
    vm3.invoke(() -> pauseSender("ln"));
    vm3.invoke(() -> verifySenderState("ln", true, true));
    final DistributedMember vm1Member = (DistributedMember) vm3.invoke(() -> getMember());
    pause(10000);
    String command = CliStrings.RESUME_GATEWAYSENDER + " --" + CliStrings.RESUME_GATEWAYSENDER__ID + "=ln --" + CliStrings.RESUME_GATEWAYSENDER__MEMBER + "=" + vm1Member.getId();
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testResumeGatewaySender stringResult : " + strCmdResult + ">>>>");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        assertTrue(strCmdResult.contains("is resumed on member"));
    } else {
        fail("testResumeGatewaySender failed as did not get CommandResult");
    }
    vm3.invoke(() -> verifySenderState("ln", true, false));
}
Also used : DistributedMember(org.apache.geode.distributed.DistributedMember) 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 44 with CommandResult

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

the class WanCommandPauseResumeDUnitTest method testPauseGatewaySender.

@Test
public void testPauseGatewaySender() {
    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));
    vm3.invoke(() -> createSender("ln", 2, false, 100, 400, false, false, null, true));
    vm4.invoke(() -> createCache(punePort));
    vm4.invoke(() -> createSender("ln", 2, false, 100, 400, false, false, null, true));
    vm5.invoke(() -> createCache(punePort));
    vm5.invoke(() -> createSender("ln", 2, false, 100, 400, false, false, null, true));
    vm3.invoke(() -> startSender("ln"));
    vm4.invoke(() -> startSender("ln"));
    vm5.invoke(() -> startSender("ln"));
    vm3.invoke(() -> verifySenderState("ln", true, false));
    vm4.invoke(() -> verifySenderState("ln", true, false));
    vm5.invoke(() -> verifySenderState("ln", true, false));
    pause(10000);
    String command = CliStrings.PAUSE_GATEWAYSENDER + " --" + CliStrings.PAUSE_GATEWAYSENDER__ID + "=ln";
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testPauseGatewaySender stringResult : " + strCmdResult + ">>>>");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
        List<String> status = resultData.retrieveAllValues("Result");
        assertEquals(5, status.size());
        assertTrue(status.contains("Error"));
        assertTrue(status.contains("OK"));
    } else {
        fail("testPauseGatewaySender failed as did not get CommandResult");
    }
    vm3.invoke(() -> verifySenderState("ln", true, true));
    vm4.invoke(() -> verifySenderState("ln", true, true));
    vm5.invoke(() -> verifySenderState("ln", true, true));
}
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 45 with CommandResult

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

the class WanCommandPauseResumeDUnitTest method testPauseGatewaySender_onMember.

/**
   * test to validate that the start gateway sender starts the gateway sender on a member
   */
@Test
public void testPauseGatewaySender_onMember() {
    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));
    vm3.invoke(() -> createSender("ln", 2, false, 100, 400, false, false, null, true));
    vm3.invoke(() -> startSender("ln"));
    vm3.invoke(() -> verifySenderState("ln", true, false));
    final DistributedMember vm1Member = (DistributedMember) vm3.invoke(() -> getMember());
    pause(10000);
    String command = CliStrings.PAUSE_GATEWAYSENDER + " --" + CliStrings.PAUSE_GATEWAYSENDER__ID + "=ln --" + CliStrings.PAUSE_GATEWAYSENDER__MEMBER + "=" + vm1Member.getId();
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testPauseGatewaySender stringResult : " + strCmdResult + ">>>>");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        assertTrue(strCmdResult.contains("is paused on member"));
    } else {
        fail("testPauseGatewaySender failed as did not get CommandResult");
    }
    vm3.invoke(() -> verifySenderState("ln", true, true));
}
Also used : DistributedMember(org.apache.geode.distributed.DistributedMember) 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)

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