use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.
the class ExportLogsDUnitTest method verifyLogFileContents.
private void verifyLogFileContents(Set<String> acceptedLogLevels, File dirForMember) throws IOException {
String memberName = dirForMember.getName();
MemberVM member = expectedMessages.keySet().stream().filter((Member aMember) -> aMember.getName().equals(memberName)).findFirst().get();
assertThat(member).isNotNull();
Set<String> fileNamesInDir = Stream.of(dirForMember.listFiles()).map(File::getName).collect(toSet());
System.out.println(dirForMember.getCanonicalPath() + " : " + fileNamesInDir);
File logFileForMember = new File(dirForMember, memberName + ".log");
assertThat(logFileForMember).exists();
assertThat(fileNamesInDir).hasSize(1);
String logFileContents = FileUtils.readLines(logFileForMember, Charset.defaultCharset()).stream().collect(joining("\n"));
for (LogLine logLine : expectedMessages.get(member)) {
boolean shouldExpectLogLine = acceptedLogLevels.contains(logLine.level) && !logLine.shouldBeIgnoredDueToTimestamp;
if (shouldExpectLogLine) {
assertThat(logFileContents).contains(logLine.getMessage());
} else {
assertThat(logFileContents).doesNotContain(logLine.getMessage());
}
}
}
use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.
the class ExportLogsDUnitTest method setup.
@Before
public void setup() throws Exception {
Properties properties = new Properties();
properties.setProperty(ConfigurationProperties.LOG_LEVEL, "debug");
locator = lsRule.startLocatorVM(0, properties);
server1 = lsRule.startServerVM(1, properties, locator.getPort());
server2 = lsRule.startServerVM(2, properties, locator.getPort());
IgnoredException.addIgnoredException(ERROR_LOG_PREFIX);
expectedMessages = new HashMap<>();
expectedMessages.put(locator, listOfLogLines(locator, "info", "error", "debug"));
expectedMessages.put(server1, listOfLogLines(server1, "info", "error", "debug"));
expectedMessages.put(server2, listOfLogLines(server2, "info", "error", "debug"));
// log the messages in each of the members
for (MemberVM member : expectedMessages.keySet()) {
List<LogLine> logLines = expectedMessages.get(member);
member.invoke(() -> {
Logger logger = LogService.getLogger();
logLines.forEach((LogLine logLine) -> logLine.writeLog(logger));
});
}
gfshConnector.connectAndVerify(locator);
}
use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.
the class ExportLogsOnServerManagerDUnit method testExportWithOneServer.
@Test
public void testExportWithOneServer() throws Exception {
MemberVM server0 = lsRule.startServerAsJmxManager(0);
gfshConnector.connect(server0.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
gfshConnector.executeAndVerifyCommand("export logs");
String message = gfshConnector.getGfshOutput();
assertThat(message).contains(server0.getWorkingDir().getAbsolutePath());
String zipPath = getZipPathFromCommandResult(message);
Set<String> expectedZipEntries = Sets.newHashSet("server-0/server-0.log");
Set<String> actualZipEnries = new ZipFile(zipPath).stream().map(ZipEntry::getName).collect(Collectors.toSet());
assertThat(actualZipEnries).isEqualTo(expectedZipEntries);
}
use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.
the class MergeLogsDUnitTest method setup.
@Before
public void setup() throws Exception {
Properties properties = new Properties();
properties.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info");
locator = lsRule.startLocatorVM(0, properties);
properties.setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + locator.getPort() + "]");
MemberVM server = lsRule.startServerVM(1, properties);
MemberVM server2 = lsRule.startServerVM(2, properties);
locator.invoke(() -> LogService.getLogger().info(MESSAGE_1));
server.invoke(() -> LogService.getLogger().info(MESSAGE_2));
server2.invoke(() -> LogService.getLogger().info(MESSAGE_3));
locator.invoke(() -> LogService.getLogger().info(MESSAGE_4));
server.invoke(() -> LogService.getLogger().info(MESSAGE_5));
server2.invoke(() -> LogService.getLogger().info(MESSAGE_6));
}
use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.
the class ClusterConfigDeployJarDUnitTest method testDeployToNoServer.
@Test
public void testDeployToNoServer() throws Exception {
String clusterJarPath = clusterJar;
// set up the locator/servers
MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
gfshConnector.connect(locator);
assertThat(gfshConnector.isConnected()).isTrue();
gfshConnector.executeAndVerifyCommand("deploy --jar=" + clusterJarPath);
ConfigGroup cluster = new ConfigGroup("cluster").jars("cluster.jar");
ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
expectedClusterConfig.verify(locator);
// start a server and verify that the server gets the jar
MemberVM server1 = lsRule.startServerVM(1, locator.getPort());
expectedClusterConfig.verify(server1);
}
Aggregations