use of org.apache.geode.management.internal.cli.result.TabularResultData 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");
}
}
use of org.apache.geode.management.internal.cli.result.TabularResultData 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");
}
}
use of org.apache.geode.management.internal.cli.result.TabularResultData 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));
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class LuceneIndexCommandsDUnitTest method searchWithLimitShouldReturnCorrectResults.
@Test
public void searchWithLimitShouldReturnCorrectResults() throws Exception {
final VM vm1 = Host.getHost(0).getVM(1);
createIndex(vm1);
Map<String, TestObject> entries = new HashMap<>();
entries.put("A", new TestObject("value1 ", "value2", "value3"));
entries.put("B", new TestObject("ABC", "EFG", "HIJ"));
entries.put("C", new TestObject("value1", "QWE", "RTY"));
entries.put("D", new TestObject("ABC", "EFG", "HIJ"));
entries.put("E", new TestObject("value1", "ABC", "EFG"));
entries.put("F", new TestObject("ABC", "EFG", "HIJ"));
entries.put("G", new TestObject(" value1", "JKR", "POW"));
entries.put("H", new TestObject("ABC", "EFG", "H2J"));
putEntries(vm1, entries, 8);
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:value1");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__LIMIT, "2");
executeCommandAndLogResult(csb);
TabularResultData data = (TabularResultData) executeCommandAndGetResult(csb).getResultData();
assertEquals(2, data.retrieveAllValues("key").size());
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class LuceneIndexCommandsDUnitTest method searchIndexShouldReturnCorrectKeys.
@Test
public void searchIndexShouldReturnCorrectKeys() throws Exception {
final VM vm1 = Host.getHost(0).getVM(1);
createIndex(vm1);
Map<String, TestObject> entries = new HashMap<>();
entries.put("A", new TestObject("value1 ", "value2", "value3"));
entries.put("B", new TestObject("ABC", "EFG", "HIJ"));
entries.put("C", new TestObject("value1", "QWE", "RTY"));
entries.put("D", new TestObject("ABC", "EFG", "HIJ"));
entries.put("E", new TestObject("value1", "ABC", "EFG"));
entries.put("F", new TestObject("ABC", "EFG", "HIJ"));
entries.put("G", new TestObject("value1", "JKR", "POW"));
entries.put("H", new TestObject("ABC", "EFG", "H2J"));
putEntries(vm1, entries, 8);
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "value1");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__KEYSONLY, "true");
executeCommandAndLogResult(csb);
TabularResultData data = (TabularResultData) executeCommandAndGetResult(csb).getResultData();
assertEquals(4, data.retrieveAllValues("key").size());
}
Aggregations