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