use of org.apache.geode.management.internal.cli.result.CompositeResultData in project geode by apache.
the class ClientCommandsDUnitTest method testDescribeClientWithServers.
@Test
public void testDescribeClientWithServers() throws Exception {
setupSystem2();
String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId + "\"";
getLogWriter().info("testDescribeClientWithServers commandStr=" + commandString);
final VM server1 = Host.getHost(0).getVM(1);
String serverName = (String) server1.invoke("get Distributed Member Id", () -> getDistributedMemberId());
CommandResult commandResult = executeCommand(commandString);
getLogWriter().info("testDescribeClientWithServers commandResult=" + commandResult);
String resultAsString = commandResultToString(commandResult);
getLogWriter().info("testDescribeClientWithServers resultAsString=" + resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
SectionResultData section = resultData.retrieveSection("InfoSection");
assertNotNull(section);
TabularResultData tableRsultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
assertNotNull(tableRsultData);
List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
List<String> numCqs = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
assertTrue(minConn.contains("1"));
assertTrue(maxConn.contains("-1"));
assertTrue(redudancy.contains("1"));
assertTrue(numCqs.contains("3"));
String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
assertTrue(puts.equals("2"));
String queue = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_QUEUE_SIZE);
assertTrue(queue.equals("1"));
String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
assertTrue(calls.equals("1"));
String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
assertTrue(primServer.equals(serverName));
String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
assertTrue(durable.equals("No"));
String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
assertTrue(Integer.parseInt(threads) > 0);
String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
assertTrue(Integer.parseInt(cpu) > 0);
String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
assertTrue(Integer.parseInt(upTime) >= 0);
String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
assertTrue(Long.parseLong(prcTime) > 0);
closeNonDurableClient(Host.getHost(0).getVM(2));
closeNonDurableClient(Host.getHost(0).getVM(3));
closeCacheServer(Host.getHost(0).getVM(1));
}
use of org.apache.geode.management.internal.cli.result.CompositeResultData in project geode by apache.
the class ClientCommandsDUnitTest method testListClient.
// GEODE-908: random ports, BindException, time sensitive, HeadlessGfsh
@Category(FlakyTest.class)
@Test
public void testListClient() throws Exception {
setupSystemForListClient();
final VM manager = Host.getHost(0).getVM(0);
String commandString = CliStrings.LIST_CLIENTS;
getLogWriter().info("testListClient commandStr=" + commandString);
waitForListClientMbean();
final VM server1 = Host.getHost(0).getVM(1);
final DistributedMember serverMember = getMember(server1);
String[] clientIds = (String[]) manager.invoke("get client Ids", () -> {
final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
return bean.getClientIds();
});
String serverName = (String) server1.invoke("get distributed member Id", () -> getDistributedMemberId());
CommandResult commandResult = executeCommand(commandString);
getLogWriter().info("testListClient commandResult=" + commandResult);
String resultAsString = commandResultToString(commandResult);
getLogWriter().info("testListClient resultAsString=" + resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
SectionResultData section = resultData.retrieveSection("section1");
assertNotNull(section);
TabularResultData tableRsultData = section.retrieveTable("TableForClientList");
assertNotNull(tableRsultData);
List<String> serverNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_SERVERS);
List<String> clientNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_Clients);
getLogWriter().info("testListClients serverNames : " + serverNames);
getLogWriter().info("testListClients clientNames : " + clientNames);
assertEquals(2, serverNames.size());
assertEquals(2, clientNames.size());
assertTrue(clientNames.contains(clientIds[0]));
assertTrue(clientNames.contains(clientIds[1]));
serverName = serverName.replace(":", "-");
getLogWriter().info("testListClients serverName : " + serverName);
for (String str : serverNames) {
assertTrue(str.contains(serverName));
}
closeNonDurableClient(Host.getHost(0).getVM(2));
closeCacheServer(Host.getHost(0).getVM(1));
closeCacheServer(Host.getHost(0).getVM(3));
}
use of org.apache.geode.management.internal.cli.result.CompositeResultData in project geode by apache.
the class ClientCommandsDUnitTest method executeAndVerifyResultsForMixedClients.
void executeAndVerifyResultsForMixedClients(String commandString, String serverName) {
CommandResult commandResult = executeCommand(commandString);
getLogWriter().info("testDescribeMixClientWithServers commandResult=" + commandResult);
String resultAsString = commandResultToString(commandResult);
getLogWriter().info("testDescribeMixClientWithServers resultAsString=" + resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
SectionResultData section = resultData.retrieveSection("InfoSection");
assertNotNull(section);
TabularResultData tableResultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
assertNotNull(tableResultData);
List<String> minConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
List<String> maxConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
List<String> redudancy = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
assertTrue(minConn.contains("1"));
assertTrue(maxConn.contains("-1"));
assertTrue(redudancy.contains("1"));
String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
assertTrue(puts.equals("2"));
String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
assertTrue(calls.equals("1"));
String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
assertTrue(primServer.equals(serverName) || primServer.equals("N.A."));
String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
assertTrue(durable.equals("No"));
String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
assertTrue(Integer.parseInt(threads) > 0);
String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
assertTrue(Integer.parseInt(cpu) > 0);
String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
assertTrue(Integer.parseInt(upTime) >= 0);
String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
assertTrue(Long.parseLong(prcTime) > 0);
}
use of org.apache.geode.management.internal.cli.result.CompositeResultData in project geode by apache.
the class ClientCommandsDUnitTest method testDescribeClientForNonSubscribedClient.
// GEODE-910: random ports, HeadlessGfsh
@Category(FlakyTest.class)
@Test
public void testDescribeClientForNonSubscribedClient() throws Exception {
setUpNonSubscribedClient();
getLogWriter().info("testDescribeClientForNonSubscribedClient clientId=" + clientId);
assertNotNull(clientId);
String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId + "\"";
getLogWriter().info("testDescribeClientForNonSubscribedClient commandStr=" + commandString);
CommandResult commandResult = executeCommand(commandString);
getLogWriter().info("testDescribeClientForNonSubscribedClient commandResult=" + commandResult);
String resultAsString = commandResultToString(commandResult);
getLogWriter().info("testDescribeClientForNonSubscribedClient resultAsString=" + resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
SectionResultData section = resultData.retrieveSection("InfoSection");
assertNotNull(section);
TabularResultData tableRsultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
assertNotNull(tableRsultData);
List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
assertTrue(minConn.contains("1"));
assertTrue(maxConn.contains("-1"));
assertTrue(redudancy.contains("1"));
String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
assertTrue(puts.equals("2"));
String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
assertTrue(calls.equals("1"));
String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
assertTrue(primServer.equals("N.A."));
String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
assertTrue(durable.equals("No"));
String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
assertTrue(Integer.parseInt(threads) > 0);
String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
assertTrue(Integer.parseInt(cpu) > 0);
String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
assertTrue(Integer.parseInt(upTime) == 0);
String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
assertTrue(Long.parseLong(prcTime) > 0);
closeNonDurableClient(Host.getHost(0).getVM(2));
closeCacheServer(Host.getHost(0).getVM(1));
closeCacheServer(Host.getHost(0).getVM(3));
}
use of org.apache.geode.management.internal.cli.result.CompositeResultData 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");
}
}
Aggregations