Search in sources :

Example 31 with CommandResult

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

the class WanCommandGatewayReceiverStartDUnitTest method testStartGatewayReceiver_MultipleGroup.

/**
   * Test to validate the scenario gateway sender is started when one or more sender members belongs
   * to multiple groups
   * 
   */
@Test
public void testStartGatewayReceiver_MultipleGroup() {
    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(() -> createReceiverWithGroup(punePort, "RG1"));
    vm4.invoke(() -> createReceiverWithGroup(punePort, "RG1"));
    vm5.invoke(() -> createReceiverWithGroup(punePort, "RG1, RG2"));
    vm6.invoke(() -> createReceiverWithGroup(punePort, "RG1, RG2"));
    vm7.invoke(() -> createReceiverWithGroup(punePort, "RG3"));
    vm3.invoke(() -> verifyReceiverState(false));
    vm4.invoke(() -> verifyReceiverState(false));
    vm5.invoke(() -> verifyReceiverState(false));
    vm6.invoke(() -> verifyReceiverState(false));
    vm7.invoke(() -> verifyReceiverState(false));
    pause(10000);
    String command = CliStrings.START_GATEWAYRECEIVER + " --" + CliStrings.START_GATEWAYRECEIVER__GROUP + "=RG1,RG2";
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testStartGatewayReceiver_Group stringResult : " + strCmdResult + ">>>>");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
        List<String> status = resultData.retrieveAllValues("Result");
        assertEquals(4, status.size());
        assertFalse(status.contains("Error"));
        assertTrue(status.contains("OK"));
    } else {
        fail("testStartGatewayReceiver failed as did not get CommandResult");
    }
    vm3.invoke(() -> verifyReceiverState(true));
    vm4.invoke(() -> verifyReceiverState(true));
    vm5.invoke(() -> verifyReceiverState(true));
    vm6.invoke(() -> verifyReceiverState(true));
    vm7.invoke(() -> verifyReceiverState(false));
}
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 32 with CommandResult

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

the class WanCommandGatewayReceiverStartDUnitTest method testStartGatewayReceiver_Group.

/**
   * test to validate that the start gateway sender starts the gateway sender on a group of members
   */
@Test
public void testStartGatewayReceiver_Group() {
    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(() -> createReceiverWithGroup(punePort, "RG1"));
    vm4.invoke(() -> createReceiverWithGroup(punePort, "RG1"));
    vm5.invoke(() -> createReceiverWithGroup(punePort, "RG1"));
    vm3.invoke(() -> verifyReceiverState(false));
    vm4.invoke(() -> verifyReceiverState(false));
    vm5.invoke(() -> verifyReceiverState(false));
    pause(10000);
    String command = CliStrings.START_GATEWAYRECEIVER + " --" + CliStrings.START_GATEWAYRECEIVER__GROUP + "=RG1";
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testStartGatewayReceiver_Group stringResult : " + strCmdResult + ">>>>");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
        List<String> status = resultData.retrieveAllValues("Result");
        assertEquals(3, status.size());
        assertFalse(status.contains("Error"));
        assertTrue(status.contains("OK"));
    } else {
        fail("testStartGatewayReceiver_Group failed as did not get CommandResult");
    }
    vm3.invoke(() -> verifyReceiverState(true));
    vm4.invoke(() -> verifyReceiverState(true));
    vm5.invoke(() -> verifyReceiverState(true));
}
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 33 with CommandResult

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

the class WanCommandCreateDestroyGatewaySenderDUnitTest method testDestroyGatewaySender_NotCreatedSender.

@Test
public void testDestroyGatewaySender_NotCreatedSender() {
    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));
    // Test Destroy Command
    String command = CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testDestroyGatewaySender_NotCreatedSender 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 destroy should fail", status.get(i).indexOf("ERROR:") != -1);
        }
    } else {
        fail("testCreateDestroyParallelGatewaySender failed as did not get CommandResult");
    }
}
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 34 with CommandResult

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

the class WanCommandCreateDestroyGatewaySenderDUnitTest method testCreateDestroyParallelGatewaySender.

/**
   * + * Parallel GatewaySender with given attribute values +
   */
@Test
public void testCreateDestroyParallelGatewaySender() {
    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));
    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --" + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=true" + " --" + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --" + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --" + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --" + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --" + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --" + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --" + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --" + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --" + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --" + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100";
    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testCreateDestroyParallelGatewaySender 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("testCreateDestroyParallelGatewaySender failed as did not get CommandResult");
    }
    vm3.invoke(() -> verifySenderState("ln", false, false));
    vm4.invoke(() -> verifySenderState("ln", false, false));
    vm5.invoke(() -> verifySenderState("ln", false, false));
    vm3.invoke(() -> verifySenderAttributes("ln", 2, true, true, 1000, socketReadTimeout, true, 1000, 5000, true, false, 1000, 100, GatewaySender.DEFAULT_DISPATCHER_THREADS, null, null, null));
    vm4.invoke(() -> verifySenderAttributes("ln", 2, true, true, 1000, socketReadTimeout, true, 1000, 5000, true, false, 1000, 100, GatewaySender.DEFAULT_DISPATCHER_THREADS, null, null, null));
    vm5.invoke(() -> verifySenderAttributes("ln", 2, true, true, 1000, socketReadTimeout, true, 1000, 5000, true, false, 1000, 100, GatewaySender.DEFAULT_DISPATCHER_THREADS, null, null, null));
    doDestroyAndVerifyGatewaySender("ln", null, null, "testCreateDestroyParallelGatewaySender", Arrays.asList(vm3, vm4), 5, 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 35 with CommandResult

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

the class WanCommandCreateGatewayReceiverDUnitTest method testCreateGatewayReceiver.

/**
   * GatewayReceiver with given attributes
   */
@Test
public void testCreateGatewayReceiver() {
    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(() -> createCache(punePort));
    vm4.invoke(() -> createCache(punePort));
    vm5.invoke(() -> createCache(punePort));
    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";
    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");
        // expected size 4 includes the manager node
        assertEquals(4, 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)

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