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));
}
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));
}
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");
}
}
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);
}
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));
}
Aggregations