use of org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData in project geode by apache.
the class GemfireDataCommandsDUnitTest method validateResult.
private void validateResult(CommandResult cmdResult, boolean expected) {
if (ResultData.TYPE_COMPOSITE.equals(cmdResult.getType())) {
CompositeResultData rd = (CompositeResultData) cmdResult.getResultData();
SectionResultData section = rd.retrieveSectionByIndex(0);
boolean result = (Boolean) section.retrieveObject("Result");
assertEquals(expected, result);
} else
fail("Expected CompositeResult Returned Result Type " + cmdResult.getType());
}
use of org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData in project geode by apache.
the class GemfireDataCommandsDUnitTest method validateSelectResult.
private void validateSelectResult(CommandResult cmdResult, boolean expectedFlag, int expectedRows, String[] cols) {
if (ResultData.TYPE_COMPOSITE.equals(cmdResult.getType())) {
CompositeResultData rd = (CompositeResultData) cmdResult.getResultData();
SectionResultData section = rd.retrieveSectionByIndex(0);
boolean result = (Boolean) section.retrieveObject("Result");
assertEquals(expectedFlag, result);
if (expectedFlag && expectedRows != -1) {
int rowsReturned = (Integer) section.retrieveObject("Rows");
assertEquals(expectedRows, rowsReturned);
if (rowsReturned > 0 && cols != null) {
try {
TabularResultData table = section.retrieveTableByIndex(0);
GfJsonArray array = table.getHeaders();
assertEquals(cols.length, array.size());
for (String col : cols) {
boolean found = false;
getLogWriter().info("Validating column " + col);
for (int i = 0; i < array.size(); i++) {
String header = (String) array.get(i);
if (col.equals(header))
found = true;
}
assertEquals(true, found);
}
} catch (GfJsonException e) {
fail("Error accessing table data", e);
}
}
}
} else
fail("Expected CompositeResult Returned Result Type " + cmdResult.getType());
}
use of org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData in project geode by apache.
the class MiscellaneousCommandsDUnitTest method testChangeLogLevelForMembers.
// GEODE-1605
@Category(FlakyTest.class)
@Test
public void testChangeLogLevelForMembers() {
final VM vm0 = Host.getHost(0).getVM(0);
final VM vm1 = Host.getHost(0).getVM(1);
setupForChangeLogLelvel();
String serverName1 = (String) vm0.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
cachedLogLevel = System.getProperty(DistributionConfig.GEMFIRE_PREFIX + "log-level");
return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
}
});
String serverName2 = (String) vm1.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
cachedLogLevel = System.getProperty(DistributionConfig.GEMFIRE_PREFIX + "log-level");
return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
}
});
String commandString = CliStrings.CHANGE_LOGLEVEL + " --" + CliStrings.CHANGE_LOGLEVEL__LOGLEVEL + "=finer" + " --" + CliStrings.CHANGE_LOGLEVEL__MEMBER + "=" + serverName1 + "," + serverName2;
CommandResult commandResult = executeCommand(commandString);
getLogWriter().info("testChangeLogLevel commandResult=" + commandResult);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
SectionResultData section = resultData.retrieveSection("section");
assertNotNull(section);
TabularResultData tableRsultData = section.retrieveTable("ChangeLogLevel");
assertNotNull(tableRsultData);
List<String> columns = tableRsultData.retrieveAllValues(CliStrings.CHANGE_LOGLEVEL__COLUMN_MEMBER);
List<String> status = tableRsultData.retrieveAllValues(CliStrings.CHANGE_LOGLEVEL__COLUMN_STATUS);
assertEquals(columns.size(), 2);
assertEquals(status.size(), 2);
assertTrue(columns.contains(serverName1));
assertTrue(columns.contains(serverName2));
assertTrue(status.contains("true"));
}
use of org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData in project geode by apache.
the class MiscellaneousCommandsDUnitTest method testChangeLogLevelForGrps.
@Test
public void testChangeLogLevelForGrps() {
Properties localProps = new Properties();
localProps.setProperty(NAME, "Manager");
localProps.setProperty(GROUPS, "Group0");
final VM vm1 = Host.getHost(0).getVM(1);
final VM vm2 = Host.getHost(0).getVM(2);
final String grp1 = "Group1";
final String grp2 = "Group2";
setUpJmxManagerOnVm0ThenConnect(localProps);
String vm1id = (String) vm1.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
Properties localProps = new Properties();
localProps.setProperty(GROUPS, grp1);
getSystem(localProps);
Cache cache = getCache();
return cache.getDistributedSystem().getDistributedMember().getId();
}
});
String vm2id = (String) vm2.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
Properties localProps = new Properties();
localProps.setProperty(GROUPS, grp2);
getSystem(localProps);
Cache cache = getCache();
return cache.getDistributedSystem().getDistributedMember().getId();
}
});
String commandString = CliStrings.CHANGE_LOGLEVEL + " --" + CliStrings.CHANGE_LOGLEVEL__LOGLEVEL + "=finer" + " --" + CliStrings.CHANGE_LOGLEVEL__GROUPS + "=" + grp1 + "," + grp2;
CommandResult commandResult = executeCommand(commandString);
getLogWriter().info("testChangeLogLevelForGrps commandResult=" + commandResult);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
SectionResultData section = resultData.retrieveSection("section");
assertNotNull(section);
TabularResultData tableRsultData = section.retrieveTable("ChangeLogLevel");
assertNotNull(tableRsultData);
List<String> columns = tableRsultData.retrieveAllValues(CliStrings.CHANGE_LOGLEVEL__COLUMN_MEMBER);
List<String> status = tableRsultData.retrieveAllValues(CliStrings.CHANGE_LOGLEVEL__COLUMN_STATUS);
assertEquals(columns.size(), 2);
assertEquals(status.size(), 2);
assertTrue(columns.contains(vm1id));
assertTrue(columns.contains(vm2id));
assertTrue(status.contains("true"));
}
use of org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData in project geode by apache.
the class GemfireDataCommandsDUnitTest method validateLocationsResult.
private void validateLocationsResult(CommandResult cmdResult, int expected) {
if (ResultData.TYPE_COMPOSITE.equals(cmdResult.getType())) {
CompositeResultData rd = (CompositeResultData) cmdResult.getResultData();
SectionResultData section = rd.retrieveSectionByIndex(0);
int result = (Integer) section.retrieveObject("Locations Found");
assertEquals(expected, result);
} else
fail("Expected CompositeResult Returned Result Type " + cmdResult.getType());
}
Aggregations